bsd.prog.mk revision 8081
111820Sjulian#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
211820Sjulian#	$Id: bsd.prog.mk,v 1.24 1995/03/08 09:01:32 olah Exp $
311820Sjulian
411820Sjulian.if exists(${.CURDIR}/../Makefile.inc)
511820Sjulian.include "${.CURDIR}/../Makefile.inc"
611820Sjulian.endif
711820Sjulian
811820Sjulian.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
911820Sjulian
1011820SjulianCFLAGS+=${COPTS} ${DEBUG_FLAGS}
1111820Sjulian.if defined(DESTDIR)
1211820SjulianCFLAGS+= -I${DESTDIR}/usr/include
1311820SjulianCXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
1411820Sjulian.endif
1511820Sjulian
1611820Sjulian.if !defined(DEBUG_FLAGS)
1711820SjulianSTRIP?=	-s
1811820Sjulian.endif
1911820Sjulian
2011820SjulianBINGRP?=	bin
2111820SjulianBINOWN?=	bin
2211820SjulianBINMODE?=	555
2311820Sjulian
2411820SjulianLIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
2511820SjulianLIBC?=		${DESTDIR}/usr/lib/libc.a
2611820SjulianLIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
2711820SjulianLIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
2811820SjulianLIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
2911820SjulianLIBDES?=	${DESTDIR}/usr/lib/libdes.a	# XXX doesn't exist
3011820SjulianLIBDIALOG?=	${DESTDIR}/usr/lib/libdialog.a
3111820SjulianLIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
3211820SjulianLIBFORMS?=	${DESTDIR}/usr/lib/libforms.a
3311820SjulianLIBFTP?=	${DESTDIR}/usr/lib/libftp.a
3411820SjulianLIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
3511820SjulianLIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
3611820SjulianLIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
3750479SpeterLIBKDB?=	${DESTDIR}/usr/lib/libkdb.a	# XXX doesn't exist
3811820SjulianLIBKRB?=	${DESTDIR}/usr/lib/libkrb.a	# XXX doesn't exist
3911820SjulianLIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
4011820SjulianLIBL?=		${DESTDIR}/usr/lib/libl.a
4111820SjulianLIBM?=		${DESTDIR}/usr/lib/libm.a
4211820SjulianLIBMD?=		${DESTDIR}/usr/lib/libmd.a
4390868SmikeLIBMP?=		${DESTDIR}/usr/lib/libmp.a	# XXX doesn't exist
4411820SjulianLIBMYTINFO?=	${DESTDIR}/usr/lib/libmytinfo.a
4511820SjulianLIBNCURSES?=	${DESTDIR}/usr/lib/libncurses.a
4611820SjulianLIBPC?=		${DESTDIR}/usr/lib/libpc.a	# XXX doesn't exist
4711820SjulianLIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
4811820SjulianLIBPLOT?=	${DESTDIR}/usr/lib/libplot.a	# XXX doesn't exist
4911820SjulianLIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
5011820SjulianLIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
5111820SjulianLIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
5211820SjulianLIBSCRYPT?=	${DESTDIR}/usr/lib/libscrypt.a	# XXX don't use, use LIBCRYPT
5311820SjulianLIBSCSI?=	${DESTDIR}/usr/lib/libscsi.a
5411820SjulianLIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
5511820SjulianLIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
5611820SjulianLIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
5711820SjulianLIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
5811820SjulianLIBY?=		${DESTDIR}/usr/lib/liby.a
5911820Sjulian
6011820Sjulian.if defined(NOSHARED)
6111820SjulianLDFLAGS+= -static
6211820Sjulian.endif
6311820Sjulian
6411820Sjulian.if defined(DESTDIR)
6511820SjulianLDDESTDIR+=	-L${DESTDIR}/usr/lib
6611820Sjulian.endif
6711820Sjulian
6811820Sjulian.if defined(PROG)
6911820Sjulian.if defined(SRCS)
7011820Sjulian
7111820SjulianDPSRCS+= ${SRCS:M*.h}
7211820Sjulian.if !defined(NOOBJ)
7311820SjulianOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
7411820Sjulian.endif
7511820Sjulian
7611820Sjulian.if defined(LDONLY)
7711820Sjulian
7811820Sjulian${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 
7911820Sjulian	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
8011820Sjulian		${LDADD}
8145988Sjhay
8211820Sjulian.else defined(LDONLY)
8311820Sjulian
8411820Sjulian${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
8511820Sjulian	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
8611820Sjulian
8711820Sjulian.endif
8811820Sjulian
8911820Sjulian.else defined(PROG)
9011820Sjulian
9111820SjulianSRCS=	${PROG}.c
9215248Sjhay
9311820Sjulian.if 0
9411820Sjulian${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
9511820Sjulian	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
9611820Sjulian		${LDDESTDIR} ${LDADD}
9711820Sjulian
9811820SjulianMKDEP=	-p
9911820Sjulian.else
10011820Sjulian# Always make an intermediate object file because:
10127244Sjhay# - it saves time rebuilding when only the library has changed
10227244Sjhay# - the name of the object gets put into the executable symbol table instead of
10311820Sjulian#   the name of a variable temporary object.
10411820Sjulian# - it's useful to keep objects around for crunching.
10527244SjhayOBJS=	${PROG}.o
10627244Sjhay${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
10711820Sjulian	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
10811820Sjulian.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
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:
231.endif
232
233_DEPSUBDIR=	_PROGSUBDIR
234.include <bsd.dep.mk>
235