Deleted Added
full compact
bsd.prog.mk (5257) bsd.prog.mk (5585)
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.14 1994/12/22 17:20:52 bde Exp $
2# $Id: bsd.prog.mk,v 1.15 1994/12/28 03:50:58 ache 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
32LIBGCC?= ${DESTDIR}/usr/lib/libgcc.a
33LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a
34LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a
35LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a # XXX doesn't exist
36LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a # XXX doesn't exist
37LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a
38LIBL?= ${DESTDIR}/usr/lib/libl.a
39LIBM?= ${DESTDIR}/usr/lib/libm.a
40LIBMD?= ${DESTDIR}/usr/lib/libmd.a
41LIBMP?= ${DESTDIR}/usr/lib/libmp.a # XXX doesn't exist
42LIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a
43LIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a
44LIBPC?= ${DESTDIR}/usr/lib/libpc.a # XXX doesn't exist
45LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a # XXX doesn't exist
46LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a
47LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a
48LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
49LIBSCRYPT?= ${DESTDIR}/usr/lib/libscrypt.a # XXX don't use, use LIBCRYPT
50LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
51LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a
52LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a
53LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a
54LIBY?= ${DESTDIR}/usr/lib/liby.a
55
56.if defined(NOSHARED)
57LDFLAGS+= -static
58.endif
59
60.if defined(DESTDIR)
61LDDESTDIR+= -L${DESTDIR}/usr/lib
62.endif
63
64.if defined(PROG)
65.if defined(SRCS)
66
67DPSRCS+= ${SRCS:M*.h}
68OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
69
70.if defined(LDONLY)
71
72${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
73 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
74 ${LDADD}
75
76.else defined(LDONLY)
77
78${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
79 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
80
81.endif
82
83.else defined(PROG)
84
85SRCS= ${PROG}.c
86
87.if 0
88${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
89 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
90 ${LDDESTDIR} ${LDADD}
91
92MKDEP= -p
93.else
94# Always make an intermediate object file because:
95# - it saves time rebuilding when only the library has changed
96# - the name of the object gets put into the executable symbol table instead of
97# the name of a variable temporary object.
98# - it's useful to keep objects around for crunching.
99OBJS= ${PROG}.o
100${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
101 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
102.endif
103
104.endif
105
106.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
107 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
108 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
109MAN1= ${PROG}.1
110.endif
111.endif
112
113_PROGSUBDIR: .USE
114.if defined(SUBDIR) && !empty(SUBDIR)
115 @for entry in ${SUBDIR}; do \
116 (${ECHODIR} "===> $$entry"; \
117 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
118 cd ${.CURDIR}/$${entry}.${MACHINE}; \
119 else \
120 cd ${.CURDIR}/$${entry}; \
121 fi; \
122 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
123 done
124.endif
125
126.MAIN: all
127all: ${PROG} _PROGSUBDIR
128
129.if !target(clean)
130clean: _PROGSUBDIR
131 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
132.endif
133
134.if !target(cleandir)
135cleandir: _PROGSUBDIR
136 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
137 rm -f ${.CURDIR}/tags .depend
138 cd ${.CURDIR}; rm -rf obj;
139.endif
140
141.if !target(install)
142.if !target(beforeinstall)
143beforeinstall:
144.endif
145.if !target(afterinstall)
146afterinstall:
147.endif
148
149realinstall: _PROGSUBDIR
150.if defined(PROG)
151 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
152 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
153.endif
154.if defined(HIDEGAME)
155 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
156 chown games.bin ${PROG})
157.endif
158.if defined(LINKS) && !empty(LINKS)
159 @set ${LINKS}; \
160 while test $$# -ge 2; do \
161 l=${DESTDIR}$$1; \
162 shift; \
163 t=${DESTDIR}$$1; \
164 shift; \
165 ${ECHO} $$t -\> $$l; \
166 rm -f $$t; \
167 ln $$l $$t; \
168 done; true
169.endif
170
171install: afterinstall
172.if !defined(NOMAN)
173afterinstall: realinstall maninstall
174.else
175afterinstall: realinstall
176.endif
177realinstall: beforeinstall
178.endif
179
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
32LIBGCC?= ${DESTDIR}/usr/lib/libgcc.a
33LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a
34LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a
35LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a # XXX doesn't exist
36LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a # XXX doesn't exist
37LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a
38LIBL?= ${DESTDIR}/usr/lib/libl.a
39LIBM?= ${DESTDIR}/usr/lib/libm.a
40LIBMD?= ${DESTDIR}/usr/lib/libmd.a
41LIBMP?= ${DESTDIR}/usr/lib/libmp.a # XXX doesn't exist
42LIBMYTINFO?= ${DESTDIR}/usr/lib/libmytinfo.a
43LIBNCURSES?= ${DESTDIR}/usr/lib/libncurses.a
44LIBPC?= ${DESTDIR}/usr/lib/libpc.a # XXX doesn't exist
45LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a # XXX doesn't exist
46LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a
47LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a
48LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
49LIBSCRYPT?= ${DESTDIR}/usr/lib/libscrypt.a # XXX don't use, use LIBCRYPT
50LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
51LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a
52LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a
53LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a
54LIBY?= ${DESTDIR}/usr/lib/liby.a
55
56.if defined(NOSHARED)
57LDFLAGS+= -static
58.endif
59
60.if defined(DESTDIR)
61LDDESTDIR+= -L${DESTDIR}/usr/lib
62.endif
63
64.if defined(PROG)
65.if defined(SRCS)
66
67DPSRCS+= ${SRCS:M*.h}
68OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
69
70.if defined(LDONLY)
71
72${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
73 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
74 ${LDADD}
75
76.else defined(LDONLY)
77
78${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
79 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
80
81.endif
82
83.else defined(PROG)
84
85SRCS= ${PROG}.c
86
87.if 0
88${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
89 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
90 ${LDDESTDIR} ${LDADD}
91
92MKDEP= -p
93.else
94# Always make an intermediate object file because:
95# - it saves time rebuilding when only the library has changed
96# - the name of the object gets put into the executable symbol table instead of
97# the name of a variable temporary object.
98# - it's useful to keep objects around for crunching.
99OBJS= ${PROG}.o
100${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
101 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
102.endif
103
104.endif
105
106.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
107 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
108 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
109MAN1= ${PROG}.1
110.endif
111.endif
112
113_PROGSUBDIR: .USE
114.if defined(SUBDIR) && !empty(SUBDIR)
115 @for entry in ${SUBDIR}; do \
116 (${ECHODIR} "===> $$entry"; \
117 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
118 cd ${.CURDIR}/$${entry}.${MACHINE}; \
119 else \
120 cd ${.CURDIR}/$${entry}; \
121 fi; \
122 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
123 done
124.endif
125
126.MAIN: all
127all: ${PROG} _PROGSUBDIR
128
129.if !target(clean)
130clean: _PROGSUBDIR
131 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
132.endif
133
134.if !target(cleandir)
135cleandir: _PROGSUBDIR
136 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
137 rm -f ${.CURDIR}/tags .depend
138 cd ${.CURDIR}; rm -rf obj;
139.endif
140
141.if !target(install)
142.if !target(beforeinstall)
143beforeinstall:
144.endif
145.if !target(afterinstall)
146afterinstall:
147.endif
148
149realinstall: _PROGSUBDIR
150.if defined(PROG)
151 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
152 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
153.endif
154.if defined(HIDEGAME)
155 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
156 chown games.bin ${PROG})
157.endif
158.if defined(LINKS) && !empty(LINKS)
159 @set ${LINKS}; \
160 while test $$# -ge 2; do \
161 l=${DESTDIR}$$1; \
162 shift; \
163 t=${DESTDIR}$$1; \
164 shift; \
165 ${ECHO} $$t -\> $$l; \
166 rm -f $$t; \
167 ln $$l $$t; \
168 done; true
169.endif
170
171install: afterinstall
172.if !defined(NOMAN)
173afterinstall: realinstall maninstall
174.else
175afterinstall: realinstall
176.endif
177realinstall: beforeinstall
178.endif
179
180DISTRIBUTION?= bindist
180DISTRIBUTION?= bin
181.if !target(distribute)
182distribute:
183 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${RELEASEDIR}/${DISTRIBUTION} SHARED=copies
184.endif
185
186.if !target(lint)
187lint: ${SRCS} _PROGSUBDIR
188.if defined(PROG)
189 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
190.endif
191.endif
192
193.if !target(obj)
194.if defined(NOOBJ)
195obj: _PROGSUBDIR
196.else
197obj: _PROGSUBDIR
198 @cd ${.CURDIR}; rm -rf obj; \
199 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
200 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
201 if test -d /usr/obj -a ! -d $$dest; then \
202 mkdir -p $$dest; \
203 else \
204 true; \
205 fi;
206.endif
207.endif
208
209.if !target(tags)
210tags: ${SRCS} _PROGSUBDIR
211.if defined(PROG)
212 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
213 sed "s;\${.CURDIR}/;;" > tags
214.endif
215.endif
216
217.if !defined(NOMAN)
218.include <bsd.man.mk>
219.elif !target(maninstall)
220maninstall:
221.endif
222
223.include <bsd.dep.mk>
181.if !target(distribute)
182distribute:
183 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${RELEASEDIR}/${DISTRIBUTION} SHARED=copies
184.endif
185
186.if !target(lint)
187lint: ${SRCS} _PROGSUBDIR
188.if defined(PROG)
189 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
190.endif
191.endif
192
193.if !target(obj)
194.if defined(NOOBJ)
195obj: _PROGSUBDIR
196.else
197obj: _PROGSUBDIR
198 @cd ${.CURDIR}; rm -rf obj; \
199 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
200 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
201 if test -d /usr/obj -a ! -d $$dest; then \
202 mkdir -p $$dest; \
203 else \
204 true; \
205 fi;
206.endif
207.endif
208
209.if !target(tags)
210tags: ${SRCS} _PROGSUBDIR
211.if defined(PROG)
212 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
213 sed "s;\${.CURDIR}/;;" > tags
214.endif
215.endif
216
217.if !defined(NOMAN)
218.include <bsd.man.mk>
219.elif !target(maninstall)
220maninstall:
221.endif
222
223.include <bsd.dep.mk>