This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / share / mk / bsd.prog.mk
CommitLineData
15637ed4
RG
1# @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2
3.if exists(${.CURDIR}/../Makefile.inc)
4.include "${.CURDIR}/../Makefile.inc"
5.endif
6
5d5ff2b2 7.SUFFIXES: .out .o .c .y .l .s
15637ed4
RG
8
9CFLAGS+=${COPTS}
10
11STRIP?= -s
12
13BINGRP?= bin
14BINOWN?= bin
15BINMODE?= 555
16
17LIBCRT0?= /usr/lib/crt0.o
18LIBC?= /usr/lib/libc.a
19LIBCOMPAT?= /usr/lib/libcompat.a
20LIBCURSES?= /usr/lib/libcurses.a
cd3f6cd2 21LIBCRYPT?= /usr/lib/libcrypt.a
15637ed4
RG
22LIBDBM?= /usr/lib/libdbm.a
23LIBDES?= /usr/lib/libdes.a
24LIBL?= /usr/lib/libl.a
25LIBKDB?= /usr/lib/libkdb.a
26LIBKRB?= /usr/lib/libkrb.a
27LIBM?= /usr/lib/libm.a
28LIBMP?= /usr/lib/libmp.a
29LIBPC?= /usr/lib/libpc.a
30LIBPLOT?= /usr/lib/libplot.a
31LIBRESOLV?= /usr/lib/libresolv.a
32LIBRPC?= /usr/lib/sunrpc.a
cd3f6cd2 33LIBTELNET?= /usr/lib/libtelnet.a
15637ed4
RG
34LIBTERM?= /usr/lib/libterm.a
35LIBUTIL?= /usr/lib/libutil.a
36
37.if defined(SHAREDSTRINGS)
38CLEANFILES+=strings
39.c.o:
40 ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
41 @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
42 @rm -f x.c
43.endif
44
45.if defined(PROG)
46.if defined(SRCS)
47
48OBJS+= ${SRCS:R:S/$/.o/g}
49
50.if defined(LDONLY)
51
52${PROG}: ${LIBCRT0} ${LIBC} ${OBJS} ${DPADD}
53 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDADD}
54
55.else defined(LDONLY)
56
57${PROG}: ${OBJS} ${LIBC} ${DPADD}
58 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
59
60.endif
61
62.else defined(PROG)
63
64SRCS= ${PROG}.c
65
66${PROG}: ${SRCS} ${LIBC} ${DPADD}
67 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
68
69MKDEP= -p
70
71.endif
72
73.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
74 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
75 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
5d5ff2b2 76MAN1= ${PROG}.1
15637ed4
RG
77.endif
78.endif
15637ed4
RG
79
80_PROGSUBDIR: .USE
81.if defined(SUBDIR) && !empty(SUBDIR)
82 @for entry in ${SUBDIR}; do \
83 (echo "===> $$entry"; \
84 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
85 cd ${.CURDIR}/$${entry}.${MACHINE}; \
86 else \
87 cd ${.CURDIR}/$${entry}; \
88 fi; \
89 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
90 done
91.endif
92
93.MAIN: all
5d5ff2b2 94all: ${PROG} _PROGSUBDIR
15637ed4
RG
95
96.if !target(clean)
97clean: _PROGSUBDIR
e3a1f265 98 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
15637ed4
RG
99.endif
100
101.if !target(cleandir)
102cleandir: _PROGSUBDIR
e3a1f265 103 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} \
5d5ff2b2 104 ${.CURDIR}/tags .depend
15637ed4
RG
105 cd ${.CURDIR}; rm -rf obj;
106.endif
107
108# some of the rules involve .h sources, so remove them from mkdep line
109.if !target(depend)
110depend: .depend _PROGSUBDIR
111.depend: ${SRCS}
112.if defined(PROG)
113 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
114.endif
115.endif
116
117.if !target(install)
118.if !target(beforeinstall)
119beforeinstall:
120.endif
121.if !target(afterinstall)
122afterinstall:
123.endif
124
125realinstall: _PROGSUBDIR
126.if defined(PROG)
127 install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
128 ${PROG} ${DESTDIR}${BINDIR}
129.endif
130.if defined(HIDEGAME)
131 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
132 chown games.bin ${PROG})
133.endif
134.if defined(LINKS) && !empty(LINKS)
135 @set ${LINKS}; \
136 while test $$# -ge 2; do \
137 l=${DESTDIR}$$1; \
138 shift; \
139 t=${DESTDIR}$$1; \
140 shift; \
141 echo $$t -\> $$l; \
142 rm -f $$t; \
143 ln $$l $$t; \
144 done; true
145.endif
146
66b3dc7c 147install: afterinstall
ceaa3638 148.if !defined(NOMAN)
66b3dc7c 149afterinstall: realinstall maninstall
ceaa3638
NW
150.else
151afterinstall: realinstall
152.endif
15637ed4
RG
153realinstall: beforeinstall
154.endif
155
156.if !target(lint)
157lint: ${SRCS} _PROGSUBDIR
158.if defined(PROG)
159 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
160.endif
161.endif
162
163.if !target(obj)
164.if defined(NOOBJ)
165obj: _PROGSUBDIR
166.else
167obj: _PROGSUBDIR
168 @cd ${.CURDIR}; rm -rf obj; \
169 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
170 echo "$$here -> $$dest"; ln -s $$dest obj; \
171 if test -d /usr/obj -a ! -d $$dest; then \
172 mkdir -p $$dest; \
173 else \
174 true; \
175 fi;
176.endif
177.endif
178
179.if !target(tags)
180tags: ${SRCS} _PROGSUBDIR
181.if defined(PROG)
182 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
183 sed "s;\${.CURDIR}/;;" > tags
184.endif
185.endif
ceaa3638
NW
186
187.if !defined(NOMAN)
188.include <bsd.man.mk>
189.endif