xref: /freebsd/share/mk/bsd.prog.mk (revision 45f7d107aced56bcf37c2bbda8f6ffddf9abb60d)
13585b293SGarrett Wollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
245f7d107SJordan K. Hubbard#	$Id: bsd.prog.mk,v 1.20 1995/01/25 20:24:01 ache 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 WollmanLIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
253585b293SGarrett WollmanLIBC?=		${DESTDIR}/usr/lib/libc.a
263585b293SGarrett WollmanLIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
273585b293SGarrett WollmanLIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
283585b293SGarrett WollmanLIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
293ecb4369SBruce EvansLIBDES?=	${DESTDIR}/usr/lib/libdes.a	# XXX doesn't exist
3020bb37a7SAndrey A. ChernovLIBDIALOG?=	${DESTDIR}/usr/lib/libdialog.a
313ecb4369SBruce EvansLIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
32316cd0cfSAndrey A. ChernovLIBFORMS?=	${DESTDIR}/usr/lib/libforms.a
333ecb4369SBruce EvansLIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
343585b293SGarrett WollmanLIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
353585b293SGarrett WollmanLIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
363ecb4369SBruce EvansLIBKDB?=	${DESTDIR}/usr/lib/libkdb.a	# XXX doesn't exist
373ecb4369SBruce EvansLIBKRB?=	${DESTDIR}/usr/lib/libkrb.a	# XXX doesn't exist
383ecb4369SBruce EvansLIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
393585b293SGarrett WollmanLIBL?=		${DESTDIR}/usr/lib/libl.a
403585b293SGarrett WollmanLIBM?=		${DESTDIR}/usr/lib/libm.a
411c423e89SPaul TrainaLIBMD?=		${DESTDIR}/usr/lib/libmd.a
423ecb4369SBruce EvansLIBMP?=		${DESTDIR}/usr/lib/libmp.a	# XXX doesn't exist
4336ee0312SAndrey A. ChernovLIBMYTINFO?=	${DESTDIR}/usr/lib/libmytinfo.a
4436ee0312SAndrey A. ChernovLIBNCURSES?=	${DESTDIR}/usr/lib/libncurses.a
453ecb4369SBruce EvansLIBPC?=		${DESTDIR}/usr/lib/libpc.a	# XXX doesn't exist
463ecb4369SBruce EvansLIBPLOT?=	${DESTDIR}/usr/lib/libplot.a	# XXX doesn't exist
473585b293SGarrett WollmanLIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
483585b293SGarrett WollmanLIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
493585b293SGarrett WollmanLIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
503ecb4369SBruce EvansLIBSCRYPT?=	${DESTDIR}/usr/lib/libscrypt.a	# XXX don't use, use LIBCRYPT
51316cd0cfSAndrey A. ChernovLIBSCSI?=	${DESTDIR}/usr/lib/libscsi.a
523585b293SGarrett WollmanLIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
533585b293SGarrett WollmanLIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
540e58d919SRodney W. GrimesLIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
553585b293SGarrett WollmanLIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
563ecb4369SBruce EvansLIBY?=		${DESTDIR}/usr/lib/liby.a
573ecb4369SBruce Evans
583585b293SGarrett Wollman.if defined(NOSHARED)
593585b293SGarrett WollmanLDFLAGS+= -static
603585b293SGarrett Wollman.endif
61afe61c15SRodney W. Grimes
623585b293SGarrett Wollman.if defined(DESTDIR)
6343fae827SBruce EvansLDDESTDIR+=	-L${DESTDIR}/usr/lib
64afe61c15SRodney W. Grimes.endif
65afe61c15SRodney W. Grimes
66afe61c15SRodney W. Grimes.if defined(PROG)
67afe61c15SRodney W. Grimes.if defined(SRCS)
68afe61c15SRodney W. Grimes
693585b293SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
70ad1565eeSJordan K. Hubbard.if !defined(NOOBJ)
713585b293SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
7262ef7455SJordan K. Hubbard.endif
73afe61c15SRodney W. Grimes
743585b293SGarrett Wollman.if defined(LDONLY)
75afe61c15SRodney W. Grimes
763585b293SGarrett Wollman${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
77a4c39c7aSBruce Evans	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
783585b293SGarrett Wollman		${LDADD}
793585b293SGarrett Wollman
803585b293SGarrett Wollman.else defined(LDONLY)
813585b293SGarrett Wollman
823585b293SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
833585b293SGarrett Wollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
843585b293SGarrett Wollman
853585b293SGarrett Wollman.endif
863585b293SGarrett Wollman
873585b293SGarrett Wollman.else defined(PROG)
88afe61c15SRodney W. Grimes
89afe61c15SRodney W. GrimesSRCS=	${PROG}.c
90afe61c15SRodney W. Grimes
91a4c39c7aSBruce Evans.if 0
923585b293SGarrett Wollman${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
933585b293SGarrett Wollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
943585b293SGarrett Wollman		${LDDESTDIR} ${LDADD}
9514c28f38SBruce Evans
9614c28f38SBruce EvansMKDEP=	-p
97a4c39c7aSBruce Evans.else
98a4c39c7aSBruce Evans# Always make an intermediate object file because:
99a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed
100a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of
101a4c39c7aSBruce Evans#   the name of a variable temporary object.
102a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching.
103a4c39c7aSBruce EvansOBJS=	${PROG}.o
104a4c39c7aSBruce Evans${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
105a4c39c7aSBruce Evans	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
106a4c39c7aSBruce Evans.endif
107afe61c15SRodney W. Grimes
108afe61c15SRodney W. Grimes.endif
109afe61c15SRodney W. Grimes
110afe61c15SRodney W. Grimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
111afe61c15SRodney W. Grimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
112afe61c15SRodney W. Grimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
1133585b293SGarrett WollmanMAN1=	${PROG}.1
114afe61c15SRodney W. Grimes.endif
115afe61c15SRodney W. Grimes.endif
116afe61c15SRodney W. Grimes
117afe61c15SRodney W. Grimes_PROGSUBDIR: .USE
118afe61c15SRodney W. Grimes.if defined(SUBDIR) && !empty(SUBDIR)
119afe61c15SRodney W. Grimes	@for entry in ${SUBDIR}; do \
120af8dd62bSJordan K. Hubbard		(${ECHODIR} "===> ${DIRPRFX}$$entry"; \
121afe61c15SRodney W. Grimes		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
122afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}.${MACHINE}; \
123afe61c15SRodney W. Grimes		else \
124afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}; \
125afe61c15SRodney W. Grimes		fi; \
126af8dd62bSJordan K. Hubbard		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
127afe61c15SRodney W. Grimes	done
128afe61c15SRodney W. Grimes.endif
129afe61c15SRodney W. Grimes
130afe61c15SRodney W. Grimes.MAIN: all
1313585b293SGarrett Wollmanall: ${PROG} _PROGSUBDIR
132afe61c15SRodney W. Grimes
133afe61c15SRodney W. Grimes.if !target(clean)
134afe61c15SRodney W. Grimesclean: _PROGSUBDIR
1353585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
136afe61c15SRodney W. Grimes.endif
137afe61c15SRodney W. Grimes
138afe61c15SRodney W. Grimes.if !target(cleandir)
139afe61c15SRodney W. Grimescleandir: _PROGSUBDIR
1403585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
1413585b293SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
1423585b293SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
143afe61c15SRodney W. Grimes.endif
144afe61c15SRodney W. Grimes
145afe61c15SRodney W. Grimes.if !target(install)
146afe61c15SRodney W. Grimes.if !target(beforeinstall)
147afe61c15SRodney W. Grimesbeforeinstall:
148afe61c15SRodney W. Grimes.endif
149afe61c15SRodney W. Grimes.if !target(afterinstall)
150afe61c15SRodney W. Grimesafterinstall:
151afe61c15SRodney W. Grimes.endif
152afe61c15SRodney W. Grimes
153afe61c15SRodney W. Grimesrealinstall: _PROGSUBDIR
154afe61c15SRodney W. Grimes.if defined(PROG)
1553585b293SGarrett Wollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
15645f7f888SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
157afe61c15SRodney W. Grimes.endif
158afe61c15SRodney W. Grimes.if defined(HIDEGAME)
159afe61c15SRodney W. Grimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
160afe61c15SRodney W. Grimes	    chown games.bin ${PROG})
161afe61c15SRodney W. Grimes.endif
162afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
163afe61c15SRodney W. Grimes	@set ${LINKS}; \
164afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
165afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
166afe61c15SRodney W. Grimes		shift; \
167afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
168afe61c15SRodney W. Grimes		shift; \
169a4c39c7aSBruce Evans		${ECHO} $$t -\> $$l; \
170afe61c15SRodney W. Grimes		rm -f $$t; \
17145f7d107SJordan K. Hubbard		ln ${LN_FLAGS} $$l $$t; \
172afe61c15SRodney W. Grimes	done; true
173afe61c15SRodney W. Grimes.endif
174afe61c15SRodney W. Grimes
1753585b293SGarrett Wollmaninstall: afterinstall
1763585b293SGarrett Wollman.if !defined(NOMAN)
1773585b293SGarrett Wollmanafterinstall: realinstall maninstall
1783585b293SGarrett Wollman.else
179afe61c15SRodney W. Grimesafterinstall: realinstall
1803585b293SGarrett Wollman.endif
181afe61c15SRodney W. Grimesrealinstall: beforeinstall
182afe61c15SRodney W. Grimes.endif
183afe61c15SRodney W. Grimes
184d9584d76SJordan K. HubbardDISTRIBUTION?=	bin
18555ff8fb1SPoul-Henning Kamp.if !target(distribute)
18655ff8fb1SPoul-Henning Kampdistribute:
18755ff8fb1SPoul-Henning Kamp	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${RELEASEDIR}/${DISTRIBUTION} SHARED=copies
18855ff8fb1SPoul-Henning Kamp.endif
18955ff8fb1SPoul-Henning Kamp
190afe61c15SRodney W. Grimes.if !target(lint)
191afe61c15SRodney W. Grimeslint: ${SRCS} _PROGSUBDIR
192afe61c15SRodney W. Grimes.if defined(PROG)
193afe61c15SRodney W. Grimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
194afe61c15SRodney W. Grimes.endif
195afe61c15SRodney W. Grimes.endif
196afe61c15SRodney W. Grimes
197afe61c15SRodney W. Grimes.if !target(obj)
198afe61c15SRodney W. Grimes.if defined(NOOBJ)
199afe61c15SRodney W. Grimesobj: _PROGSUBDIR
200afe61c15SRodney W. Grimes.else
201afe61c15SRodney W. Grimesobj: _PROGSUBDIR
202afe61c15SRodney W. Grimes	@cd ${.CURDIR}; rm -rf obj; \
2033585b293SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
204a4c39c7aSBruce Evans	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
205afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
206afe61c15SRodney W. Grimes		mkdir -p $$dest; \
207afe61c15SRodney W. Grimes	else \
208afe61c15SRodney W. Grimes		true; \
209afe61c15SRodney W. Grimes	fi;
210afe61c15SRodney W. Grimes.endif
211afe61c15SRodney W. Grimes.endif
212afe61c15SRodney W. Grimes
213afe61c15SRodney W. Grimes.if !target(tags)
214afe61c15SRodney W. Grimestags: ${SRCS} _PROGSUBDIR
215afe61c15SRodney W. Grimes.if defined(PROG)
2163585b293SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
2173585b293SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
218afe61c15SRodney W. Grimes.endif
219afe61c15SRodney W. Grimes.endif
220afe61c15SRodney W. Grimes
221afe61c15SRodney W. Grimes.if !defined(NOMAN)
222afe61c15SRodney W. Grimes.include <bsd.man.mk>
2233585b293SGarrett Wollman.elif !target(maninstall)
224afe61c15SRodney W. Grimesmaninstall:
225afe61c15SRodney W. Grimes.endif
2263585b293SGarrett Wollman
2273585b293SGarrett Wollman.include <bsd.dep.mk>
228