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