xref: /freebsd/share/mk/bsd.prog.mk (revision 55ff8fb1324cbdd2138db6fc713d43539391df9d)
13585b293SGarrett Wollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
255ff8fb1SPoul-Henning Kamp#	$Id: bsd.prog.mk,v 1.11 1994/10/25 18:09:44 bde Exp $
3afe61c15SRodney W. Grimes
43585b293SGarrett Wollman.if exists(${.CURDIR}/../Makefile.inc)
5afe61c15SRodney W. Grimes.include "${.CURDIR}/../Makefile.inc"
6afe61c15SRodney W. Grimes.endif
7afe61c15SRodney W. Grimes
83585b293SGarrett Wollman.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9afe61c15SRodney W. Grimes
10e82b0b99SJordan K. HubbardCFLAGS+=${COPTS} ${DEBUG_FLAGS}
113585b293SGarrett Wollman.if defined(DESTDIR)
123585b293SGarrett WollmanCFLAGS+= -I${DESTDIR}/usr/include
133585b293SGarrett WollmanCXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
143585b293SGarrett Wollman.endif
15afe61c15SRodney W. Grimes
16e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS)
17afe61c15SRodney W. GrimesSTRIP?=	-s
18e82b0b99SJordan K. Hubbard.endif
19afe61c15SRodney W. Grimes
20afe61c15SRodney W. GrimesBINGRP?=	bin
21afe61c15SRodney W. GrimesBINOWN?=	bin
22afe61c15SRodney W. GrimesBINMODE?=	555
23afe61c15SRodney W. Grimes
243585b293SGarrett WollmanINSTALL?=	install
253585b293SGarrett Wollman.if !defined(DESTDIR)
263585b293SGarrett WollmanLIBCRT0?=	/usr/lib/crt0.o
27afe61c15SRodney W. GrimesLIBC?=		/usr/lib/libc.a
28afe61c15SRodney W. GrimesLIBCOMPAT?=	/usr/lib/libcompat.a
293585b293SGarrett WollmanLIBCRYPT?=	/usr/lib/libcrypt.a
30afe61c15SRodney W. GrimesLIBCURSES?=	/usr/lib/libcurses.a
31afe61c15SRodney W. GrimesLIBDBM?=	/usr/lib/libdbm.a
32afe61c15SRodney W. GrimesLIBDES?=	/usr/lib/libdes.a
3320bb37a7SAndrey A. ChernovLIBDIALOG?=	/usr/lib/libdialog.a
343585b293SGarrett WollmanLIBGNUMALLOC?=	/usr/lib/libgnumalloc.a
353585b293SGarrett WollmanLIBGNUREGEX?=	/usr/lib/libgnuregex.a
36afe61c15SRodney W. GrimesLIBL?=		/usr/lib/libl.a
37afe61c15SRodney W. GrimesLIBKDB?=	/usr/lib/libkdb.a
38afe61c15SRodney W. GrimesLIBKRB?=	/usr/lib/libkrb.a
39afe61c15SRodney W. GrimesLIBM?=		/usr/lib/libm.a
401c423e89SPaul TrainaLIBMD?=		/usr/lib/libmd.a
41afe61c15SRodney W. GrimesLIBMP?=		/usr/lib/libmp.a
4236ee0312SAndrey A. ChernovLIBMYTINFO?=	/usr/lib/libmytinfo.a
4336ee0312SAndrey A. ChernovLIBNCURSES?=	/usr/lib/libncurses.a
44afe61c15SRodney W. GrimesLIBPC?=		/usr/lib/libpc.a
45afe61c15SRodney W. GrimesLIBPLOT?=	/usr/lib/libplot.a
463585b293SGarrett WollmanLIBREADLINE?=	/usr/lib/libreadline.a
47afe61c15SRodney W. GrimesLIBRESOLV?=	/usr/lib/libresolv.a
483585b293SGarrett WollmanLIBRPCSVC?=	/usr/lib/librpcsvc.a
493585b293SGarrett WollmanLIBSKEY?=	/usr/lib/libskey.a
503585b293SGarrett WollmanLIBTELNET?=	/usr/lib/libtelnet.a
510e58d919SRodney W. GrimesLIBTERMCAP?=	/usr/lib/libtermcap.a
52afe61c15SRodney W. GrimesLIBUTIL?=	/usr/lib/libutil.a
533585b293SGarrett Wollman.else
543585b293SGarrett WollmanLIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
553585b293SGarrett WollmanLIBC?=		${DESTDIR}/usr/lib/libc.a
563585b293SGarrett WollmanLIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
573585b293SGarrett WollmanLIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
583585b293SGarrett WollmanLIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
593585b293SGarrett WollmanLIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
603585b293SGarrett WollmanLIBDES?=	${DESTDIR}/usr/lib/libdes.a
6120bb37a7SAndrey A. ChernovLIBDIALOG?=	${DESTDIR}/usr/lib/libdialog.a
623585b293SGarrett WollmanLIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
633585b293SGarrett WollmanLIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
643585b293SGarrett WollmanLIBL?=		${DESTDIR}/usr/lib/libl.a
653585b293SGarrett WollmanLIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
663585b293SGarrett WollmanLIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
673585b293SGarrett WollmanLIBM?=		${DESTDIR}/usr/lib/libm.a
681c423e89SPaul TrainaLIBMD?=		${DESTDIR}/usr/lib/libmd.a
693585b293SGarrett WollmanLIBMP?=		${DESTDIR}/usr/lib/libmp.a
7036ee0312SAndrey A. ChernovLIBMYTINFO?=	${DESTDIR}/usr/lib/libmytinfo.a
7136ee0312SAndrey A. ChernovLIBNCURSES?=	${DESTDIR}/usr/lib/libncurses.a
723585b293SGarrett WollmanLIBPC?=		${DESTDIR}/usr/lib/libpc.a
733585b293SGarrett WollmanLIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
743585b293SGarrett WollmanLIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
753585b293SGarrett WollmanLIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
763585b293SGarrett WollmanLIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
773585b293SGarrett WollmanLIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
783585b293SGarrett WollmanLIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
790e58d919SRodney W. GrimesLIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
803585b293SGarrett WollmanLIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
813585b293SGarrett Wollman.endif
823585b293SGarrett Wollman.if defined(NOSHARED)
833585b293SGarrett WollmanLDFLAGS+= -static
843585b293SGarrett Wollman.endif
85afe61c15SRodney W. Grimes
863585b293SGarrett Wollman.if defined(DESTDIR)
8743fae827SBruce EvansLDDESTDIR+=	-L${DESTDIR}/usr/lib
88afe61c15SRodney W. Grimes.endif
89afe61c15SRodney W. Grimes
90afe61c15SRodney W. Grimes.if defined(PROG)
91afe61c15SRodney W. Grimes.if defined(SRCS)
92afe61c15SRodney W. Grimes
933585b293SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
943585b293SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
95afe61c15SRodney W. Grimes
963585b293SGarrett Wollman.if defined(LDONLY)
97afe61c15SRodney W. Grimes
983585b293SGarrett Wollman${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
99a4c39c7aSBruce Evans	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
1003585b293SGarrett Wollman		${LDADD}
1013585b293SGarrett Wollman
1023585b293SGarrett Wollman.else defined(LDONLY)
1033585b293SGarrett Wollman
1043585b293SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
1053585b293SGarrett Wollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
1063585b293SGarrett Wollman
1073585b293SGarrett Wollman.endif
1083585b293SGarrett Wollman
1093585b293SGarrett Wollman.else defined(PROG)
110afe61c15SRodney W. Grimes
111afe61c15SRodney W. GrimesSRCS=	${PROG}.c
112afe61c15SRodney W. Grimes
113a4c39c7aSBruce Evans.if 0
1143585b293SGarrett Wollman${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
1153585b293SGarrett Wollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
1163585b293SGarrett Wollman		${LDDESTDIR} ${LDADD}
117a4c39c7aSBruce Evans.else
118a4c39c7aSBruce Evans# Always make an intermediate object file because:
119a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed
120a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of
121a4c39c7aSBruce Evans#   the name of a variable temporary object.
122a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching.
123a4c39c7aSBruce EvansOBJS=	${PROG}.o
124a4c39c7aSBruce Evans${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
125a4c39c7aSBruce Evans	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
126a4c39c7aSBruce Evans.endif
127afe61c15SRodney W. Grimes
128afe61c15SRodney W. GrimesMKDEP=	-p
129afe61c15SRodney W. Grimes
130afe61c15SRodney W. Grimes.endif
131afe61c15SRodney W. Grimes
132afe61c15SRodney W. Grimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
133afe61c15SRodney W. Grimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
134afe61c15SRodney W. Grimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
1353585b293SGarrett WollmanMAN1=	${PROG}.1
136afe61c15SRodney W. Grimes.endif
137afe61c15SRodney W. Grimes.endif
138afe61c15SRodney W. Grimes
139afe61c15SRodney W. Grimes_PROGSUBDIR: .USE
140afe61c15SRodney W. Grimes.if defined(SUBDIR) && !empty(SUBDIR)
141afe61c15SRodney W. Grimes	@for entry in ${SUBDIR}; do \
142a4c39c7aSBruce Evans		(${ECHODIR} "===> $$entry"; \
143afe61c15SRodney W. Grimes		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
144afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}.${MACHINE}; \
145afe61c15SRodney W. Grimes		else \
146afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}; \
147afe61c15SRodney W. Grimes		fi; \
148afe61c15SRodney W. Grimes		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
149afe61c15SRodney W. Grimes	done
150afe61c15SRodney W. Grimes.endif
151afe61c15SRodney W. Grimes
152afe61c15SRodney W. Grimes.MAIN: all
1533585b293SGarrett Wollmanall: ${PROG} _PROGSUBDIR
154afe61c15SRodney W. Grimes
155afe61c15SRodney W. Grimes.if !target(clean)
156afe61c15SRodney W. Grimesclean: _PROGSUBDIR
1573585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
158afe61c15SRodney W. Grimes.endif
159afe61c15SRodney W. Grimes
160afe61c15SRodney W. Grimes.if !target(cleandir)
161afe61c15SRodney W. Grimescleandir: _PROGSUBDIR
1623585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
1633585b293SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
1643585b293SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
165afe61c15SRodney W. Grimes.endif
166afe61c15SRodney W. Grimes
167afe61c15SRodney W. Grimes.if !target(install)
168afe61c15SRodney W. Grimes.if !target(beforeinstall)
169afe61c15SRodney W. Grimesbeforeinstall:
170afe61c15SRodney W. Grimes.endif
171afe61c15SRodney W. Grimes.if !target(afterinstall)
172afe61c15SRodney W. Grimesafterinstall:
173afe61c15SRodney W. Grimes.endif
174afe61c15SRodney W. Grimes
175afe61c15SRodney W. Grimesrealinstall: _PROGSUBDIR
176afe61c15SRodney W. Grimes.if defined(PROG)
1773585b293SGarrett Wollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
17845f7f888SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
179afe61c15SRodney W. Grimes.endif
180afe61c15SRodney W. Grimes.if defined(HIDEGAME)
181afe61c15SRodney W. Grimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
182afe61c15SRodney W. Grimes	    chown games.bin ${PROG})
183afe61c15SRodney W. Grimes.endif
184afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
185afe61c15SRodney W. Grimes	@set ${LINKS}; \
186afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
187afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
188afe61c15SRodney W. Grimes		shift; \
189afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
190afe61c15SRodney W. Grimes		shift; \
191a4c39c7aSBruce Evans		${ECHO} $$t -\> $$l; \
192afe61c15SRodney W. Grimes		rm -f $$t; \
193afe61c15SRodney W. Grimes		ln $$l $$t; \
194afe61c15SRodney W. Grimes	done; true
195afe61c15SRodney W. Grimes.endif
196afe61c15SRodney W. Grimes
1973585b293SGarrett Wollmaninstall: afterinstall
1983585b293SGarrett Wollman.if !defined(NOMAN)
1993585b293SGarrett Wollmanafterinstall: realinstall maninstall
2003585b293SGarrett Wollman.else
201afe61c15SRodney W. Grimesafterinstall: realinstall
2023585b293SGarrett Wollman.endif
203afe61c15SRodney W. Grimesrealinstall: beforeinstall
204afe61c15SRodney W. Grimes.endif
205afe61c15SRodney W. Grimes
20655ff8fb1SPoul-Henning KampDISTRIBUTION?=	bindist
20755ff8fb1SPoul-Henning Kamp.if !target(distribute)
20855ff8fb1SPoul-Henning Kampdistribute:
20955ff8fb1SPoul-Henning Kamp	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${RELEASEDIR}/${DISTRIBUTION} SHARED=copies
21055ff8fb1SPoul-Henning Kamp.endif
21155ff8fb1SPoul-Henning Kamp
212afe61c15SRodney W. Grimes.if !target(lint)
213afe61c15SRodney W. Grimeslint: ${SRCS} _PROGSUBDIR
214afe61c15SRodney W. Grimes.if defined(PROG)
215afe61c15SRodney W. Grimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
216afe61c15SRodney W. Grimes.endif
217afe61c15SRodney W. Grimes.endif
218afe61c15SRodney W. Grimes
219afe61c15SRodney W. Grimes.if !target(obj)
220afe61c15SRodney W. Grimes.if defined(NOOBJ)
221afe61c15SRodney W. Grimesobj: _PROGSUBDIR
222afe61c15SRodney W. Grimes.else
223afe61c15SRodney W. Grimesobj: _PROGSUBDIR
224afe61c15SRodney W. Grimes	@cd ${.CURDIR}; rm -rf obj; \
2253585b293SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
226a4c39c7aSBruce Evans	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
227afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
228afe61c15SRodney W. Grimes		mkdir -p $$dest; \
229afe61c15SRodney W. Grimes	else \
230afe61c15SRodney W. Grimes		true; \
231afe61c15SRodney W. Grimes	fi;
232afe61c15SRodney W. Grimes.endif
233afe61c15SRodney W. Grimes.endif
234afe61c15SRodney W. Grimes
235afe61c15SRodney W. Grimes.if !target(tags)
236afe61c15SRodney W. Grimestags: ${SRCS} _PROGSUBDIR
237afe61c15SRodney W. Grimes.if defined(PROG)
2383585b293SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
2393585b293SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
240afe61c15SRodney W. Grimes.endif
241afe61c15SRodney W. Grimes.endif
242afe61c15SRodney W. Grimes
243afe61c15SRodney W. Grimes.if !defined(NOMAN)
244afe61c15SRodney W. Grimes.include <bsd.man.mk>
2453585b293SGarrett Wollman.elif !target(maninstall)
246afe61c15SRodney W. Grimesmaninstall:
247afe61c15SRodney W. Grimes.endif
2483585b293SGarrett Wollman
2493585b293SGarrett Wollman.include <bsd.dep.mk>
250