xref: /freebsd/share/mk/bsd.prog.mk (revision 2b9cd23802bbccf7e48d588b2d33bf3abb88519a)
13585b293SGarrett Wollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
22b9cd238SPoul-Henning Kamp#	$Id: bsd.prog.mk,v 1.31 1996/06/17 12:31:02 jkh 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. Grimes
213585b293SGarrett WollmanLIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
22580ccec4SBruce EvansLIBKZHEAD?=	${DESTDIR}/usr/lib/kzhead.o
23580ccec4SBruce EvansLIBKZTAIL?=	${DESTDIR}/usr/lib/kztail.o
24580ccec4SBruce Evans
253585b293SGarrett WollmanLIBC?=		${DESTDIR}/usr/lib/libc.a
26580ccec4SBruce EvansLIBC_PIC=	${DESTDIR}/usr/lib/libc_pic.a
27580ccec4SBruce EvansLIBCOM_ERR=	${DESTDIR}/usr/lib/libcom_err.a
283585b293SGarrett WollmanLIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
293585b293SGarrett WollmanLIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
303585b293SGarrett WollmanLIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
313ecb4369SBruce EvansLIBDES?=	${DESTDIR}/usr/lib/libdes.a	# XXX doesn't exist
3220bb37a7SAndrey A. ChernovLIBDIALOG?=	${DESTDIR}/usr/lib/libdialog.a
33580ccec4SBruce EvansLIBDISK?=	${DESTDIR}/usr/lib/libdisk.a
343ecb4369SBruce EvansLIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
35580ccec4SBruce EvansLIBF2C?=	${DESTDIR}/usr/lib/libf2c.a
36580ccec4SBruce EvansLIBFL?=		"don't use LIBFL, use LIBL"
37316cd0cfSAndrey A. ChernovLIBFORMS?=	${DESTDIR}/usr/lib/libforms.a
38abf58409SJordan K. HubbardLIBFTPIO?=	${DESTDIR}/usr/lib/libftpio.a
39580ccec4SBruce EvansLIBGPLUSPLUS?=	${DESTDIR}/usr/lib/libg++.a
403ecb4369SBruce EvansLIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
41580ccec4SBruce EvansLIBGCC_PIC?=	${DESTDIR}/usr/lib/libgcc_pic.a
42580ccec4SBruce EvansLIBGMP?=	${DESTDIR}/usr/lib/libgmp.a
433585b293SGarrett WollmanLIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
44580ccec4SBruce EvansLIBIPX?=	${DESTDIR}/usr/lib/libipx.a
453ecb4369SBruce EvansLIBKDB?=	${DESTDIR}/usr/lib/libkdb.a	# XXX doesn't exist
463ecb4369SBruce EvansLIBKRB?=	${DESTDIR}/usr/lib/libkrb.a	# XXX doesn't exist
47580ccec4SBruce EvansLIBKEYCAP?=	${DESTDIR}/usr/lib/libkeycap.a
483ecb4369SBruce EvansLIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
493585b293SGarrett WollmanLIBL?=		${DESTDIR}/usr/lib/libl.a
50580ccec4SBruce EvansLIBLN?=		"don't use, LIBLN, use LIBL"
513585b293SGarrett WollmanLIBM?=		${DESTDIR}/usr/lib/libm.a
521c423e89SPaul TrainaLIBMD?=		${DESTDIR}/usr/lib/libmd.a
53580ccec4SBruce EvansLIBMP?=		${DESTDIR}/usr/lib/libmp.a
5436ee0312SAndrey A. ChernovLIBMYTINFO?=	${DESTDIR}/usr/lib/libmytinfo.a
5536ee0312SAndrey A. ChernovLIBNCURSES?=	${DESTDIR}/usr/lib/libncurses.a
563ecb4369SBruce EvansLIBPC?=		${DESTDIR}/usr/lib/libpc.a	# XXX doesn't exist
571dcbf7afSAndras OlahLIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
583ecb4369SBruce EvansLIBPLOT?=	${DESTDIR}/usr/lib/libplot.a	# XXX doesn't exist
593585b293SGarrett WollmanLIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
603585b293SGarrett WollmanLIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
613585b293SGarrett WollmanLIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
62580ccec4SBruce EvansLIBSCRYPT?=	"don't use LIBSCRYPT, use LIBCRYPT"
63316cd0cfSAndrey A. ChernovLIBSCSI?=	${DESTDIR}/usr/lib/libscsi.a
643585b293SGarrett WollmanLIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
65580ccec4SBruce EvansLIBSS?=		${DESTDIR}/usr/lib/libss.a
663585b293SGarrett WollmanLIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
670e58d919SRodney W. GrimesLIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
68580ccec4SBruce EvansLIBTERMLIB?=	"don't use LIBTERMLIB, use LIBTERMCAP"
693585b293SGarrett WollmanLIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
70580ccec4SBruce EvansLIBXPG4?=	${DESTDIR}/usr/lib/libxpg4.a
713ecb4369SBruce EvansLIBY?=		${DESTDIR}/usr/lib/liby.a
723ecb4369SBruce Evans
733585b293SGarrett Wollman.if defined(NOSHARED)
743585b293SGarrett WollmanLDFLAGS+= -static
753585b293SGarrett Wollman.endif
76afe61c15SRodney W. Grimes
773585b293SGarrett Wollman.if defined(DESTDIR)
7843fae827SBruce EvansLDDESTDIR+=	-L${DESTDIR}/usr/lib
79afe61c15SRodney W. Grimes.endif
80afe61c15SRodney W. Grimes
81afe61c15SRodney W. Grimes.if defined(PROG)
82afe61c15SRodney W. Grimes.if defined(SRCS)
83afe61c15SRodney W. Grimes
843585b293SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
85ad1565eeSJordan K. Hubbard.if !defined(NOOBJ)
863585b293SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
8762ef7455SJordan K. Hubbard.endif
88afe61c15SRodney W. Grimes
893585b293SGarrett Wollman.if defined(LDONLY)
90afe61c15SRodney W. Grimes
913585b293SGarrett Wollman${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
92a4c39c7aSBruce Evans	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
933585b293SGarrett Wollman		${LDADD}
943585b293SGarrett Wollman
953585b293SGarrett Wollman.else defined(LDONLY)
963585b293SGarrett Wollman
973585b293SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
983585b293SGarrett Wollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
993585b293SGarrett Wollman
1003585b293SGarrett Wollman.endif
1013585b293SGarrett Wollman
102fd2e43eaSBruce Evans.else !defined(SRCS)
103afe61c15SRodney W. Grimes
104afe61c15SRodney W. GrimesSRCS=	${PROG}.c
105afe61c15SRodney W. Grimes
106a4c39c7aSBruce Evans.if 0
1073585b293SGarrett Wollman${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
1083585b293SGarrett Wollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
1093585b293SGarrett Wollman		${LDDESTDIR} ${LDADD}
11014c28f38SBruce Evans
11114c28f38SBruce EvansMKDEP=	-p
112a4c39c7aSBruce Evans.else
113a4c39c7aSBruce Evans# Always make an intermediate object file because:
114a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed
115a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of
116a4c39c7aSBruce Evans#   the name of a variable temporary object.
117a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching.
118a4c39c7aSBruce EvansOBJS=	${PROG}.o
119a4c39c7aSBruce Evans${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
120a4c39c7aSBruce Evans	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
121a4c39c7aSBruce Evans.endif
122afe61c15SRodney W. Grimes
123afe61c15SRodney W. Grimes.endif
124afe61c15SRodney W. Grimes
125afe61c15SRodney W. Grimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
126afe61c15SRodney W. Grimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
127afe61c15SRodney W. Grimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
1283585b293SGarrett WollmanMAN1=	${PROG}.1
129afe61c15SRodney W. Grimes.endif
130afe61c15SRodney W. Grimes.endif
131afe61c15SRodney W. Grimes
132afe61c15SRodney W. Grimes_PROGSUBDIR: .USE
133afe61c15SRodney W. Grimes.if defined(SUBDIR) && !empty(SUBDIR)
134afe61c15SRodney W. Grimes	@for entry in ${SUBDIR}; do \
135af8dd62bSJordan K. Hubbard		(${ECHODIR} "===> ${DIRPRFX}$$entry"; \
136afe61c15SRodney W. Grimes		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
137afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}.${MACHINE}; \
138afe61c15SRodney W. Grimes		else \
139afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}; \
140afe61c15SRodney W. Grimes		fi; \
141af8dd62bSJordan K. Hubbard		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
142afe61c15SRodney W. Grimes	done
143afe61c15SRodney W. Grimes.endif
144afe61c15SRodney W. Grimes
145cdaec7b1SBruce Evans# XXX I think MANDEPEND is only used for groff.  It should be named more
146cdaec7b1SBruce Evans# generally and perhaps not be in the maninstall dependencies now it is
147cdaec7b1SBruce Evans# here (or does maninstall always work when nothing is made?),
148cdaec7b1SBruce Evans
149afe61c15SRodney W. Grimes.MAIN: all
150973f098aSGarrett Wollmanall: ${PROG} all-man _PROGSUBDIR
151afe61c15SRodney W. Grimes
152afe61c15SRodney W. Grimes.if !target(clean)
153afe61c15SRodney W. Grimesclean: _PROGSUBDIR
1545c2da789SWolfram Schneider	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES}
1552b9cd238SPoul-Henning Kamp.if defined(CLEANDIRS)
1562b9cd238SPoul-Henning Kamp	rm -rf ${CLEANDIRS}
1572b9cd238SPoul-Henning Kamp.endif
158afe61c15SRodney W. Grimes.endif
159afe61c15SRodney W. Grimes
160afe61c15SRodney W. Grimes.if !target(cleandir)
161afe61c15SRodney W. Grimescleandir: _PROGSUBDIR
1625c2da789SWolfram Schneider	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES}
1633585b293SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
1642b9cd238SPoul-Henning Kamp.if defined(CLEANDIRS)
1652b9cd238SPoul-Henning Kamp	rm -rf ${CLEANDIRS}
1662b9cd238SPoul-Henning Kamp.endif
1673585b293SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
168afe61c15SRodney W. Grimes.endif
169afe61c15SRodney W. Grimes
170afe61c15SRodney W. Grimes.if !target(install)
171afe61c15SRodney W. Grimes.if !target(beforeinstall)
172afe61c15SRodney W. Grimesbeforeinstall:
173afe61c15SRodney W. Grimes.endif
174afe61c15SRodney W. Grimes.if !target(afterinstall)
175afe61c15SRodney W. Grimesafterinstall:
176afe61c15SRodney W. Grimes.endif
177afe61c15SRodney W. Grimes
178afe61c15SRodney W. Grimesrealinstall: _PROGSUBDIR
179afe61c15SRodney W. Grimes.if defined(PROG)
1803585b293SGarrett Wollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
18145f7f888SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
182afe61c15SRodney W. Grimes.endif
183afe61c15SRodney W. Grimes.if defined(HIDEGAME)
184afe61c15SRodney W. Grimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
185afe61c15SRodney W. Grimes	    chown games.bin ${PROG})
186afe61c15SRodney W. Grimes.endif
187afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
188afe61c15SRodney W. Grimes	@set ${LINKS}; \
189afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
190afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
191afe61c15SRodney W. Grimes		shift; \
192afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
193afe61c15SRodney W. Grimes		shift; \
194a4c39c7aSBruce Evans		${ECHO} $$t -\> $$l; \
195afe61c15SRodney W. Grimes		rm -f $$t; \
19645f7d107SJordan K. Hubbard		ln ${LN_FLAGS} $$l $$t; \
197afe61c15SRodney W. Grimes	done; true
198afe61c15SRodney W. Grimes.endif
199afe61c15SRodney W. Grimes
2003585b293SGarrett Wollmaninstall: afterinstall
2013585b293SGarrett Wollman.if !defined(NOMAN)
2023585b293SGarrett Wollmanafterinstall: realinstall maninstall
2033585b293SGarrett Wollman.else
204afe61c15SRodney W. Grimesafterinstall: realinstall
2053585b293SGarrett Wollman.endif
206afe61c15SRodney W. Grimesrealinstall: beforeinstall
207afe61c15SRodney W. Grimes.endif
208afe61c15SRodney W. Grimes
209d9584d76SJordan K. HubbardDISTRIBUTION?=	bin
21055ff8fb1SPoul-Henning Kamp.if !target(distribute)
21155ff8fb1SPoul-Henning Kampdistribute:
212ffd87c07SPoul-Henning Kamp	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
21355ff8fb1SPoul-Henning Kamp.endif
21455ff8fb1SPoul-Henning Kamp
215afe61c15SRodney W. Grimes.if !target(lint)
216afe61c15SRodney W. Grimeslint: ${SRCS} _PROGSUBDIR
217afe61c15SRodney W. Grimes.if defined(PROG)
218afe61c15SRodney W. Grimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
219afe61c15SRodney W. Grimes.endif
220afe61c15SRodney W. Grimes.endif
221afe61c15SRodney W. Grimes
222afe61c15SRodney W. Grimes.if !target(obj)
223afe61c15SRodney W. Grimes.if defined(NOOBJ)
224afe61c15SRodney W. Grimesobj: _PROGSUBDIR
225afe61c15SRodney W. Grimes.else
226afe61c15SRodney W. Grimesobj: _PROGSUBDIR
227afe61c15SRodney W. Grimes	@cd ${.CURDIR}; rm -rf obj; \
2283585b293SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
229a4c39c7aSBruce Evans	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
230afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
231afe61c15SRodney W. Grimes		mkdir -p $$dest; \
232afe61c15SRodney W. Grimes	else \
233afe61c15SRodney W. Grimes		true; \
234afe61c15SRodney W. Grimes	fi;
235afe61c15SRodney W. Grimes.endif
236afe61c15SRodney W. Grimes.endif
237afe61c15SRodney W. Grimes
238afe61c15SRodney W. Grimes.if !target(tags)
239afe61c15SRodney W. Grimestags: ${SRCS} _PROGSUBDIR
240afe61c15SRodney W. Grimes.if defined(PROG)
2413585b293SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
2423585b293SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
243afe61c15SRodney W. Grimes.endif
244afe61c15SRodney W. Grimes.endif
245afe61c15SRodney W. Grimes
246afe61c15SRodney W. Grimes.if !defined(NOMAN)
247afe61c15SRodney W. Grimes.include <bsd.man.mk>
2483585b293SGarrett Wollman.elif !target(maninstall)
249afe61c15SRodney W. Grimesmaninstall:
250973f098aSGarrett Wollmanall-man:
251afe61c15SRodney W. Grimes.endif
2523585b293SGarrett Wollman
253cdaec7b1SBruce Evans_DEPSUBDIR=	_PROGSUBDIR
2543585b293SGarrett Wollman.include <bsd.dep.mk>
255