Deleted Added
full compact
bsd.prog.mk (1639) bsd.prog.mk (1844)
1# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
1# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
2# $Id: bsd.prog.mk,v 1.28 1994/06/15 10:14:41 ache Exp $
2
3
3.if !defined(NOINCLUDE) && exists(${.CURDIR}/../Makefile.inc)
4.if exists(${.CURDIR}/../Makefile.inc)
4.include "${.CURDIR}/../Makefile.inc"
5.endif
6
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
7.SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
8
9
9.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
10 nroff -man ${.IMPSRC} > ${.TARGET}
11
12CFLAGS+=${COPTS}
10CFLAGS+=${COPTS}
11.if defined(DESTDIR)
12CFLAGS+= -I${DESTDIR}/usr/include
13CXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
14.endif
13
14STRIP?= -s
15
16BINGRP?= bin
17BINOWN?= bin
18BINMODE?= 555
19
15
16STRIP?= -s
17
18BINGRP?= bin
19BINOWN?= bin
20BINMODE?= 555
21
22INSTALL?= install
23.if !defined(DESTDIR)
24LIBCRT0?= /usr/lib/crt0.o
20LIBC?= /usr/lib/libc.a
21LIBCOMPAT?= /usr/lib/libcompat.a
25LIBC?= /usr/lib/libc.a
26LIBCOMPAT?= /usr/lib/libcompat.a
27LIBCRYPT?= /usr/lib/libcrypt.a
22LIBCURSES?= /usr/lib/libcurses.a
23LIBDBM?= /usr/lib/libdbm.a
24LIBDES?= /usr/lib/libdes.a
28LIBCURSES?= /usr/lib/libcurses.a
29LIBDBM?= /usr/lib/libdbm.a
30LIBDES?= /usr/lib/libdes.a
31LIBGNUMALLOC?= /usr/lib/libgnumalloc.a
32LIBGNUREGEX?= /usr/lib/libgnuregex.a
25LIBL?= /usr/lib/libl.a
26LIBKDB?= /usr/lib/libkdb.a
27LIBKRB?= /usr/lib/libkrb.a
33LIBL?= /usr/lib/libl.a
34LIBKDB?= /usr/lib/libkdb.a
35LIBKRB?= /usr/lib/libkrb.a
28LIBKVM?= /usr/lib/libkvm.a
29LIBM?= /usr/lib/libm.a
30LIBMP?= /usr/lib/libmp.a
31LIBPC?= /usr/lib/libpc.a
32LIBPLOT?= /usr/lib/libplot.a
36LIBM?= /usr/lib/libm.a
37LIBMP?= /usr/lib/libmp.a
38LIBPC?= /usr/lib/libpc.a
39LIBPLOT?= /usr/lib/libplot.a
40LIBREADLINE?= /usr/lib/libreadline.a
33LIBRESOLV?= /usr/lib/libresolv.a
41LIBRESOLV?= /usr/lib/libresolv.a
34LIBRPC?= /usr/lib/sunrpc.a
35LIBTERM?= /usr/lib/libterm.a
42LIBRPCSVC?= /usr/lib/librpcsvc.a
43LIBSKEY?= /usr/lib/libskey.a
44LIBTELNET?= /usr/lib/libtelnet.a
45LIBTERM?= /usr/lib/libtermcap.a
36LIBUTIL?= /usr/lib/libutil.a
46LIBUTIL?= /usr/lib/libutil.a
47.else
48LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
49LIBC?= ${DESTDIR}/usr/lib/libc.a
50LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a
51LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a
52LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a
53LIBDBM?= ${DESTDIR}/usr/lib/libdbm.a
54LIBDES?= ${DESTDIR}/usr/lib/libdes.a
55LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a
56LIBGNUREGEX?= ${DESTDIR}/usr/lib/libgnuregex.a
57LIBL?= ${DESTDIR}/usr/lib/libl.a
58LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a
59LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a
60LIBM?= ${DESTDIR}/usr/lib/libm.a
61LIBMP?= ${DESTDIR}/usr/lib/libmp.a
62LIBPC?= ${DESTDIR}/usr/lib/libpc.a
63LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a
64LIBREADLINE?= ${DESTDIR}/usr/lib/libreadline.a
65LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a
66LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a
67LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a
68LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a
69LIBTERM?= ${DESTDIR}/usr/lib/libtermcap.a
70LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a
71.endif
72.if defined(NOSHARED)
73LDFLAGS+= -static
74.endif
37
38.if defined(SHAREDSTRINGS)
39CLEANFILES+=strings
40.c.o:
41 ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
42 @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
43 @rm -f x.c
75
76.if defined(SHAREDSTRINGS)
77CLEANFILES+=strings
78.c.o:
79 ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
80 @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
81 @rm -f x.c
82
83.cc.o .cxx.o .C.o:
84 ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
85 @mv -f x.c x.cc
86 @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
87
44.endif
45
88.endif
89
90.if defined(DESTDIR)
91LDDESTDIR?= -L${DESTDIR}/usr/lib
92.endif
93
46.if defined(PROG)
47.if defined(SRCS)
48
94.if defined(PROG)
95.if defined(SRCS)
96
49OBJS+= ${SRCS:R:S/$/.o/g}
97DPSRCS+= ${SRCS:M*.h}
98OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
50
99
51${PROG}: ${OBJS} ${LIBC} ${DPADD}
52 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
100.if defined(LDONLY)
53
101
54.else defined(SRCS)
102${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
103 ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDR} \
104 ${LDADD}
55
105
106.else defined(LDONLY)
107
108${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
109 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
110
111.endif
112
113.else defined(PROG)
114
56SRCS= ${PROG}.c
57
115SRCS= ${PROG}.c
116
58${PROG}: ${SRCS} ${LIBC} ${DPADD}
59 ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
117${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
118 ${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
119 ${LDDESTDIR} ${LDADD}
60
61MKDEP= -p
62
63.endif
64
65.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
66 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
67 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
120
121MKDEP= -p
122
123.endif
124
125.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
126 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
127 !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
68MAN1= ${PROG}.0
128MAN1= ${PROG}.1
69.endif
70.endif
129.endif
130.endif
71.if !defined(NOMAN)
72MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
73.else
74MANALL=
75.endif
76manpages: ${MANALL}
77
78_PROGSUBDIR: .USE
79.if defined(SUBDIR) && !empty(SUBDIR)
80 @for entry in ${SUBDIR}; do \
81 (echo "===> $$entry"; \
82 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
83 cd ${.CURDIR}/$${entry}.${MACHINE}; \
84 else \
85 cd ${.CURDIR}/$${entry}; \
86 fi; \
87 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
88 done
89.endif
90
131
132_PROGSUBDIR: .USE
133.if defined(SUBDIR) && !empty(SUBDIR)
134 @for entry in ${SUBDIR}; do \
135 (echo "===> $$entry"; \
136 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
137 cd ${.CURDIR}/$${entry}.${MACHINE}; \
138 else \
139 cd ${.CURDIR}/$${entry}; \
140 fi; \
141 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
142 done
143.endif
144
91.if !target(all)
92.MAIN: all
145.MAIN: all
93all: ${PROG} ${MANALL} _PROGSUBDIR
94.endif
146all: ${PROG} _PROGSUBDIR
95
96.if !target(clean)
97clean: _PROGSUBDIR
147
148.if !target(clean)
149clean: _PROGSUBDIR
98 rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES}
150 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
99.endif
100
101.if !target(cleandir)
102cleandir: _PROGSUBDIR
151.endif
152
153.if !target(cleandir)
154cleandir: _PROGSUBDIR
103 rm -f a.out [Ee]rrs mklog ${PROG}.core ${PROG} ${OBJS} ${CLEANFILES}
104 rm -f .depend ${MANALL}
155 rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
156 rm -f ${.CURDIR}/tags .depend
157 cd ${.CURDIR}; rm -rf obj;
105.endif
106
158.endif
159
107# some of the rules involve .h sources, so remove them from mkdep line
108.if !target(depend)
109depend: .depend _PROGSUBDIR
110.depend: ${SRCS}
111.if defined(PROG)
112 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
113.endif
114.endif
115
116.if !target(install)
117.if !target(beforeinstall)
118beforeinstall:
119.endif
120.if !target(afterinstall)
121afterinstall:
122.endif
123
124realinstall: _PROGSUBDIR
125.if defined(PROG)
160.if !target(install)
161.if !target(beforeinstall)
162beforeinstall:
163.endif
164.if !target(afterinstall)
165afterinstall:
166.endif
167
168realinstall: _PROGSUBDIR
169.if defined(PROG)
126 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
127 ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
170 ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
171 ${PROG} ${DESTDIR}${BINDIR}
128.endif
129.if defined(HIDEGAME)
130 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
131 chown games.bin ${PROG})
132.endif
133.if defined(LINKS) && !empty(LINKS)
134 @set ${LINKS}; \
135 while test $$# -ge 2; do \
136 l=${DESTDIR}$$1; \
137 shift; \
138 t=${DESTDIR}$$1; \
139 shift; \
140 echo $$t -\> $$l; \
141 rm -f $$t; \
142 ln $$l $$t; \
143 done; true
144.endif
145
172.endif
173.if defined(HIDEGAME)
174 (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
175 chown games.bin ${PROG})
176.endif
177.if defined(LINKS) && !empty(LINKS)
178 @set ${LINKS}; \
179 while test $$# -ge 2; do \
180 l=${DESTDIR}$$1; \
181 shift; \
182 t=${DESTDIR}$$1; \
183 shift; \
184 echo $$t -\> $$l; \
185 rm -f $$t; \
186 ln $$l $$t; \
187 done; true
188.endif
189
146install: afterinstall maninstall
190install: afterinstall
191.if !defined(NOMAN)
192afterinstall: realinstall maninstall
193.else
147afterinstall: realinstall
194afterinstall: realinstall
195.endif
148realinstall: beforeinstall
149.endif
150
151.if !target(lint)
152lint: ${SRCS} _PROGSUBDIR
153.if defined(PROG)
154 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
155.endif
156.endif
157
158.if !target(obj)
159.if defined(NOOBJ)
160obj: _PROGSUBDIR
161.else
162obj: _PROGSUBDIR
163 @cd ${.CURDIR}; rm -rf obj; \
196realinstall: beforeinstall
197.endif
198
199.if !target(lint)
200lint: ${SRCS} _PROGSUBDIR
201.if defined(PROG)
202 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
203.endif
204.endif
205
206.if !target(obj)
207.if defined(NOOBJ)
208obj: _PROGSUBDIR
209.else
210obj: _PROGSUBDIR
211 @cd ${.CURDIR}; rm -rf obj; \
164 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
212 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
165 echo "$$here -> $$dest"; ln -s $$dest obj; \
166 if test -d /usr/obj -a ! -d $$dest; then \
167 mkdir -p $$dest; \
168 else \
169 true; \
170 fi;
171.endif
172.endif
173
213 echo "$$here -> $$dest"; ln -s $$dest obj; \
214 if test -d /usr/obj -a ! -d $$dest; then \
215 mkdir -p $$dest; \
216 else \
217 true; \
218 fi;
219.endif
220.endif
221
174.if !target(objdir)
175.if defined(NOOBJ)
176objdir: _PROGSUBDIR
177.else
178objdir: _PROGSUBDIR
179 @cd ${.CURDIR}; \
180 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
181 if test -d /usr/obj -a ! -d $$dest; then \
182 mkdir -p $$dest; \
183 else \
184 true; \
185 fi;
186.endif
187.endif
188
189.if !target(tags)
190tags: ${SRCS} _PROGSUBDIR
191.if defined(PROG)
222.if !target(tags)
223tags: ${SRCS} _PROGSUBDIR
224.if defined(PROG)
192 -ctags -f /dev/stdout ${.ALLSRC} | \
193 sed "s;${.CURDIR}/;;" > ${.CURDIR}/tags
225 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
226 sed "s;\${.CURDIR}/;;" > tags
194.endif
195.endif
196
197.if !defined(NOMAN)
198.include <bsd.man.mk>
227.endif
228.endif
229
230.if !defined(NOMAN)
231.include <bsd.man.mk>
199.else
232.elif !target(maninstall)
200maninstall:
201.endif
233maninstall:
234.endif
235
236.include <bsd.dep.mk>