Deleted Added
full compact
bsd.prog.mk (8321) bsd.prog.mk (11136)
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2# $Id: bsd.prog.mk,v 1.25 1995/04/26 14:34:19 jkh Exp $
2# $Id: bsd.prog.mk,v 1.26 1995/05/07 06:39:30 bde Exp $
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9
10CFLAGS+=${COPTS} ${DEBUG_FLAGS}
11.if defined(DESTDIR)
12CFLAGS+= -I${DESTDIR}/usr/include
13CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
14.endif
15
16.if !defined(DEBUG_FLAGS)
17STRIP?= -s
18.endif
19
20BINGRP?= bin
21BINOWN?= bin
22BINMODE?= 555
23
24LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
25LIBC?= ${DESTDIR}/usr/lib/libc.a
26LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a
27LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a
28LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a
29LIBDES?= ${DESTDIR}/usr/lib/libdes.a # XXX doesn't exist
30LIBDIALOG?= ${DESTDIR}/usr/lib/libdialog.a
31LIBEDIT?= ${DESTDIR}/usr/lib/libedit.a
32LIBFORMS?= ${DESTDIR}/usr/lib/libforms.a
33LIBFTP?= ${DESTDIR}/usr/lib/libftp.a
34LIBGCC?= ${DESTDIR}/usr/lib/libgcc.a
35LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a
36LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a
37LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a # XXX doesn't exist
38LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a # XXX doesn't exist
39LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a
40LIBL?= ${DESTDIR}/usr/lib/libl.a
41LIBM?= ${DESTDIR}/usr/lib/libm.a
42LIBMD?= ${DESTDIR}/usr/lib/libmd.a
43LIBMP?= ${DESTDIR}/usr/lib/libmp.a # XXX doesn't exist
44LIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a
45LIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a
46LIBPC?= ${DESTDIR}/usr/lib/libpc.a # XXX doesn't exist
47LIBPCAP?= ${DESTDIR}/usr/lib/libpcap.a
48LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a # XXX doesn't exist
49LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a
50LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a
51LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
52LIBSCRYPT?= ${DESTDIR}/usr/lib/libscrypt.a # XXX don't use, use LIBCRYPT
53LIBSCSI?= ${DESTDIR}/usr/lib/libscsi.a
54LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
55LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a
56LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a
57LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a
58LIBY?= ${DESTDIR}/usr/lib/liby.a
59
60.if defined(NOSHARED)
61LDFLAGS+= -static
62.endif
63
64.if defined(DESTDIR)
65LDDESTDIR+= -L${DESTDIR}/usr/lib
66.endif
67
68.if defined(PROG)
69.if defined(SRCS)
70
71DPSRCS+= ${SRCS:M*.h}
72.if !defined(NOOBJ)
73OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
74.endif
75
76.if defined(LDONLY)
77
78${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
79 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
80 ${LDADD}
81
82.else defined(LDONLY)
83
84${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
85 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
86
87.endif
88
89.else !defined(SRCS)
90
91SRCS= ${PROG}.c
92
93.if 0
94${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
95 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
96 ${LDDESTDIR} ${LDADD}
97
98MKDEP= -p
99.else
100# Always make an intermediate object file because:
101# - it saves time rebuilding when only the library has changed
102# - the name of the object gets put into the executable symbol table instead of
103# the name of a variable temporary object.
104# - it's useful to keep objects around for crunching.
105OBJS= ${PROG}.o
106${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
107 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
108.endif
109
110.endif
111
112.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
113 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
114 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
115MAN1= ${PROG}.1
116.endif
117.endif
118
119_PROGSUBDIR: .USE
120.if defined(SUBDIR) && !empty(SUBDIR)
121 @for entry in ${SUBDIR}; do \
122 (${ECHODIR} "===> ${DIRPRFX}$$entry"; \
123 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
124 cd ${.CURDIR}/$${entry}.${MACHINE}; \
125 else \
126 cd ${.CURDIR}/$${entry}; \
127 fi; \
128 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
129 done
130.endif
131
132# XXX I think MANDEPEND is only used for groff. It should be named more
133# generally and perhaps not be in the maninstall dependencies now it is
134# here (or does maninstall always work when nothing is made?),
135
136.MAIN: all
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9
10CFLAGS+=${COPTS} ${DEBUG_FLAGS}
11.if defined(DESTDIR)
12CFLAGS+= -I${DESTDIR}/usr/include
13CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
14.endif
15
16.if !defined(DEBUG_FLAGS)
17STRIP?= -s
18.endif
19
20BINGRP?= bin
21BINOWN?= bin
22BINMODE?= 555
23
24LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
25LIBC?= ${DESTDIR}/usr/lib/libc.a
26LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a
27LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a
28LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a
29LIBDES?= ${DESTDIR}/usr/lib/libdes.a # XXX doesn't exist
30LIBDIALOG?= ${DESTDIR}/usr/lib/libdialog.a
31LIBEDIT?= ${DESTDIR}/usr/lib/libedit.a
32LIBFORMS?= ${DESTDIR}/usr/lib/libforms.a
33LIBFTP?= ${DESTDIR}/usr/lib/libftp.a
34LIBGCC?= ${DESTDIR}/usr/lib/libgcc.a
35LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a
36LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a
37LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a # XXX doesn't exist
38LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a # XXX doesn't exist
39LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a
40LIBL?= ${DESTDIR}/usr/lib/libl.a
41LIBM?= ${DESTDIR}/usr/lib/libm.a
42LIBMD?= ${DESTDIR}/usr/lib/libmd.a
43LIBMP?= ${DESTDIR}/usr/lib/libmp.a # XXX doesn't exist
44LIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a
45LIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a
46LIBPC?= ${DESTDIR}/usr/lib/libpc.a # XXX doesn't exist
47LIBPCAP?= ${DESTDIR}/usr/lib/libpcap.a
48LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a # XXX doesn't exist
49LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a
50LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a
51LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
52LIBSCRYPT?= ${DESTDIR}/usr/lib/libscrypt.a # XXX don't use, use LIBCRYPT
53LIBSCSI?= ${DESTDIR}/usr/lib/libscsi.a
54LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
55LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a
56LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a
57LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a
58LIBY?= ${DESTDIR}/usr/lib/liby.a
59
60.if defined(NOSHARED)
61LDFLAGS+= -static
62.endif
63
64.if defined(DESTDIR)
65LDDESTDIR+= -L${DESTDIR}/usr/lib
66.endif
67
68.if defined(PROG)
69.if defined(SRCS)
70
71DPSRCS+= ${SRCS:M*.h}
72.if !defined(NOOBJ)
73OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
74.endif
75
76.if defined(LDONLY)
77
78${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
79 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
80 ${LDADD}
81
82.else defined(LDONLY)
83
84${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
85 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
86
87.endif
88
89.else !defined(SRCS)
90
91SRCS= ${PROG}.c
92
93.if 0
94${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
95 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
96 ${LDDESTDIR} ${LDADD}
97
98MKDEP= -p
99.else
100# Always make an intermediate object file because:
101# - it saves time rebuilding when only the library has changed
102# - the name of the object gets put into the executable symbol table instead of
103# the name of a variable temporary object.
104# - it's useful to keep objects around for crunching.
105OBJS= ${PROG}.o
106${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
107 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
108.endif
109
110.endif
111
112.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
113 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
114 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
115MAN1= ${PROG}.1
116.endif
117.endif
118
119_PROGSUBDIR: .USE
120.if defined(SUBDIR) && !empty(SUBDIR)
121 @for entry in ${SUBDIR}; do \
122 (${ECHODIR} "===> ${DIRPRFX}$$entry"; \
123 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
124 cd ${.CURDIR}/$${entry}.${MACHINE}; \
125 else \
126 cd ${.CURDIR}/$${entry}; \
127 fi; \
128 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
129 done
130.endif
131
132# XXX I think MANDEPEND is only used for groff. It should be named more
133# generally and perhaps not be in the maninstall dependencies now it is
134# here (or does maninstall always work when nothing is made?),
135
136.MAIN: all
137all: ${PROG} ${MANDEPEND} _PROGSUBDIR
137all: ${PROG} all-man _PROGSUBDIR
138
139.if !target(clean)
140clean: _PROGSUBDIR
141 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
142.endif
143
144.if !target(cleandir)
145cleandir: _PROGSUBDIR
146 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
147 rm -f ${.CURDIR}/tags .depend
148 cd ${.CURDIR}; rm -rf obj;
149.endif
150
151.if !target(install)
152.if !target(beforeinstall)
153beforeinstall:
154.endif
155.if !target(afterinstall)
156afterinstall:
157.endif
158
159realinstall: _PROGSUBDIR
160.if defined(PROG)
161 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
162 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
163.endif
164.if defined(HIDEGAME)
165 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
166 chown games.bin ${PROG})
167.endif
168.if defined(LINKS) && !empty(LINKS)
169 @set ${LINKS}; \
170 while test $$# -ge 2; do \
171 l=${DESTDIR}$$1; \
172 shift; \
173 t=${DESTDIR}$$1; \
174 shift; \
175 ${ECHO} $$t -\> $$l; \
176 rm -f $$t; \
177 ln ${LN_FLAGS} $$l $$t; \
178 done; true
179.endif
180
181install: afterinstall
182.if !defined(NOMAN)
183afterinstall: realinstall maninstall
184.else
185afterinstall: realinstall
186.endif
187realinstall: beforeinstall
188.endif
189
190DISTRIBUTION?= bin
191.if !target(distribute)
192distribute:
193 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
194.endif
195
196.if !target(lint)
197lint: ${SRCS} _PROGSUBDIR
198.if defined(PROG)
199 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
200.endif
201.endif
202
203.if !target(obj)
204.if defined(NOOBJ)
205obj: _PROGSUBDIR
206.else
207obj: _PROGSUBDIR
208 @cd ${.CURDIR}; rm -rf obj; \
209 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
210 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
211 if test -d /usr/obj -a ! -d $$dest; then \
212 mkdir -p $$dest; \
213 else \
214 true; \
215 fi;
216.endif
217.endif
218
219.if !target(tags)
220tags: ${SRCS} _PROGSUBDIR
221.if defined(PROG)
222 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
223 sed "s;\${.CURDIR}/;;" > tags
224.endif
225.endif
226
227.if !defined(NOMAN)
228.include <bsd.man.mk>
229.elif !target(maninstall)
230maninstall:
138
139.if !target(clean)
140clean: _PROGSUBDIR
141 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
142.endif
143
144.if !target(cleandir)
145cleandir: _PROGSUBDIR
146 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
147 rm -f ${.CURDIR}/tags .depend
148 cd ${.CURDIR}; rm -rf obj;
149.endif
150
151.if !target(install)
152.if !target(beforeinstall)
153beforeinstall:
154.endif
155.if !target(afterinstall)
156afterinstall:
157.endif
158
159realinstall: _PROGSUBDIR
160.if defined(PROG)
161 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
162 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
163.endif
164.if defined(HIDEGAME)
165 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
166 chown games.bin ${PROG})
167.endif
168.if defined(LINKS) && !empty(LINKS)
169 @set ${LINKS}; \
170 while test $$# -ge 2; do \
171 l=${DESTDIR}$$1; \
172 shift; \
173 t=${DESTDIR}$$1; \
174 shift; \
175 ${ECHO} $$t -\> $$l; \
176 rm -f $$t; \
177 ln ${LN_FLAGS} $$l $$t; \
178 done; true
179.endif
180
181install: afterinstall
182.if !defined(NOMAN)
183afterinstall: realinstall maninstall
184.else
185afterinstall: realinstall
186.endif
187realinstall: beforeinstall
188.endif
189
190DISTRIBUTION?= bin
191.if !target(distribute)
192distribute:
193 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
194.endif
195
196.if !target(lint)
197lint: ${SRCS} _PROGSUBDIR
198.if defined(PROG)
199 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
200.endif
201.endif
202
203.if !target(obj)
204.if defined(NOOBJ)
205obj: _PROGSUBDIR
206.else
207obj: _PROGSUBDIR
208 @cd ${.CURDIR}; rm -rf obj; \
209 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
210 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
211 if test -d /usr/obj -a ! -d $$dest; then \
212 mkdir -p $$dest; \
213 else \
214 true; \
215 fi;
216.endif
217.endif
218
219.if !target(tags)
220tags: ${SRCS} _PROGSUBDIR
221.if defined(PROG)
222 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
223 sed "s;\${.CURDIR}/;;" > tags
224.endif
225.endif
226
227.if !defined(NOMAN)
228.include <bsd.man.mk>
229.elif !target(maninstall)
230maninstall:
231all-man:
231.endif
232
233_DEPSUBDIR= _PROGSUBDIR
234.include <bsd.dep.mk>
232.endif
233
234_DEPSUBDIR= _PROGSUBDIR
235.include <bsd.dep.mk>