xref: /freebsd/share/mk/bsd.prog.mk (revision 973f098aab96c9e24ed508fa75a64c503e2fd8d0)
13585b293SGarrett Wollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2973f098aSGarrett Wollman#	$Id: bsd.prog.mk,v 1.26 1995/05/07 06:39:30 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 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
336dbad786SJordan K. HubbardLIBFTP?=	${DESTDIR}/usr/lib/libftp.a
343ecb4369SBruce EvansLIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
353585b293SGarrett WollmanLIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
363585b293SGarrett WollmanLIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
373ecb4369SBruce EvansLIBKDB?=	${DESTDIR}/usr/lib/libkdb.a	# XXX doesn't exist
383ecb4369SBruce EvansLIBKRB?=	${DESTDIR}/usr/lib/libkrb.a	# XXX doesn't exist
393ecb4369SBruce EvansLIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
403585b293SGarrett WollmanLIBL?=		${DESTDIR}/usr/lib/libl.a
413585b293SGarrett WollmanLIBM?=		${DESTDIR}/usr/lib/libm.a
421c423e89SPaul TrainaLIBMD?=		${DESTDIR}/usr/lib/libmd.a
433ecb4369SBruce EvansLIBMP?=		${DESTDIR}/usr/lib/libmp.a	# XXX doesn't exist
4436ee0312SAndrey A. ChernovLIBMYTINFO?=	${DESTDIR}/usr/lib/libmytinfo.a
4536ee0312SAndrey A. ChernovLIBNCURSES?=	${DESTDIR}/usr/lib/libncurses.a
463ecb4369SBruce EvansLIBPC?=		${DESTDIR}/usr/lib/libpc.a	# XXX doesn't exist
471dcbf7afSAndras OlahLIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
483ecb4369SBruce EvansLIBPLOT?=	${DESTDIR}/usr/lib/libplot.a	# XXX doesn't exist
493585b293SGarrett WollmanLIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
503585b293SGarrett WollmanLIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
513585b293SGarrett WollmanLIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
523ecb4369SBruce EvansLIBSCRYPT?=	${DESTDIR}/usr/lib/libscrypt.a	# XXX don't use, use LIBCRYPT
53316cd0cfSAndrey A. ChernovLIBSCSI?=	${DESTDIR}/usr/lib/libscsi.a
543585b293SGarrett WollmanLIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
553585b293SGarrett WollmanLIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
560e58d919SRodney W. GrimesLIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
573585b293SGarrett WollmanLIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
583ecb4369SBruce EvansLIBY?=		${DESTDIR}/usr/lib/liby.a
593ecb4369SBruce Evans
603585b293SGarrett Wollman.if defined(NOSHARED)
613585b293SGarrett WollmanLDFLAGS+= -static
623585b293SGarrett Wollman.endif
63afe61c15SRodney W. Grimes
643585b293SGarrett Wollman.if defined(DESTDIR)
6543fae827SBruce EvansLDDESTDIR+=	-L${DESTDIR}/usr/lib
66afe61c15SRodney W. Grimes.endif
67afe61c15SRodney W. Grimes
68afe61c15SRodney W. Grimes.if defined(PROG)
69afe61c15SRodney W. Grimes.if defined(SRCS)
70afe61c15SRodney W. Grimes
713585b293SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
72ad1565eeSJordan K. Hubbard.if !defined(NOOBJ)
733585b293SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
7462ef7455SJordan K. Hubbard.endif
75afe61c15SRodney W. Grimes
763585b293SGarrett Wollman.if defined(LDONLY)
77afe61c15SRodney W. Grimes
783585b293SGarrett Wollman${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
79a4c39c7aSBruce Evans	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
803585b293SGarrett Wollman		${LDADD}
813585b293SGarrett Wollman
823585b293SGarrett Wollman.else defined(LDONLY)
833585b293SGarrett Wollman
843585b293SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
853585b293SGarrett Wollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
863585b293SGarrett Wollman
873585b293SGarrett Wollman.endif
883585b293SGarrett Wollman
89fd2e43eaSBruce Evans.else !defined(SRCS)
90afe61c15SRodney W. Grimes
91afe61c15SRodney W. GrimesSRCS=	${PROG}.c
92afe61c15SRodney W. Grimes
93a4c39c7aSBruce Evans.if 0
943585b293SGarrett Wollman${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
953585b293SGarrett Wollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
963585b293SGarrett Wollman		${LDDESTDIR} ${LDADD}
9714c28f38SBruce Evans
9814c28f38SBruce EvansMKDEP=	-p
99a4c39c7aSBruce Evans.else
100a4c39c7aSBruce Evans# Always make an intermediate object file because:
101a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed
102a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of
103a4c39c7aSBruce Evans#   the name of a variable temporary object.
104a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching.
105a4c39c7aSBruce EvansOBJS=	${PROG}.o
106a4c39c7aSBruce Evans${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
107a4c39c7aSBruce Evans	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
108a4c39c7aSBruce Evans.endif
109afe61c15SRodney W. Grimes
110afe61c15SRodney W. Grimes.endif
111afe61c15SRodney W. Grimes
112afe61c15SRodney W. Grimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
113afe61c15SRodney W. Grimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
114afe61c15SRodney W. Grimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
1153585b293SGarrett WollmanMAN1=	${PROG}.1
116afe61c15SRodney W. Grimes.endif
117afe61c15SRodney W. Grimes.endif
118afe61c15SRodney W. Grimes
119afe61c15SRodney W. Grimes_PROGSUBDIR: .USE
120afe61c15SRodney W. Grimes.if defined(SUBDIR) && !empty(SUBDIR)
121afe61c15SRodney W. Grimes	@for entry in ${SUBDIR}; do \
122af8dd62bSJordan K. Hubbard		(${ECHODIR} "===> ${DIRPRFX}$$entry"; \
123afe61c15SRodney W. Grimes		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
124afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}.${MACHINE}; \
125afe61c15SRodney W. Grimes		else \
126afe61c15SRodney W. Grimes			cd ${.CURDIR}/$${entry}; \
127afe61c15SRodney W. Grimes		fi; \
128af8dd62bSJordan K. Hubbard		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/} DIRPRFX=${DIRPRFX}$$entry/); \
129afe61c15SRodney W. Grimes	done
130afe61c15SRodney W. Grimes.endif
131afe61c15SRodney W. Grimes
132cdaec7b1SBruce Evans# XXX I think MANDEPEND is only used for groff.  It should be named more
133cdaec7b1SBruce Evans# generally and perhaps not be in the maninstall dependencies now it is
134cdaec7b1SBruce Evans# here (or does maninstall always work when nothing is made?),
135cdaec7b1SBruce Evans
136afe61c15SRodney W. Grimes.MAIN: all
137973f098aSGarrett Wollmanall: ${PROG} all-man _PROGSUBDIR
138afe61c15SRodney W. Grimes
139afe61c15SRodney W. Grimes.if !target(clean)
140afe61c15SRodney W. Grimesclean: _PROGSUBDIR
1413585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
142afe61c15SRodney W. Grimes.endif
143afe61c15SRodney W. Grimes
144afe61c15SRodney W. Grimes.if !target(cleandir)
145afe61c15SRodney W. Grimescleandir: _PROGSUBDIR
1463585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
1473585b293SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
1483585b293SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
149afe61c15SRodney W. Grimes.endif
150afe61c15SRodney W. Grimes
151afe61c15SRodney W. Grimes.if !target(install)
152afe61c15SRodney W. Grimes.if !target(beforeinstall)
153afe61c15SRodney W. Grimesbeforeinstall:
154afe61c15SRodney W. Grimes.endif
155afe61c15SRodney W. Grimes.if !target(afterinstall)
156afe61c15SRodney W. Grimesafterinstall:
157afe61c15SRodney W. Grimes.endif
158afe61c15SRodney W. Grimes
159afe61c15SRodney W. Grimesrealinstall: _PROGSUBDIR
160afe61c15SRodney W. Grimes.if defined(PROG)
1613585b293SGarrett Wollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
16245f7f888SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
163afe61c15SRodney W. Grimes.endif
164afe61c15SRodney W. Grimes.if defined(HIDEGAME)
165afe61c15SRodney W. Grimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
166afe61c15SRodney W. Grimes	    chown games.bin ${PROG})
167afe61c15SRodney W. Grimes.endif
168afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
169afe61c15SRodney W. Grimes	@set ${LINKS}; \
170afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
171afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
172afe61c15SRodney W. Grimes		shift; \
173afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
174afe61c15SRodney W. Grimes		shift; \
175a4c39c7aSBruce Evans		${ECHO} $$t -\> $$l; \
176afe61c15SRodney W. Grimes		rm -f $$t; \
17745f7d107SJordan K. Hubbard		ln ${LN_FLAGS} $$l $$t; \
178afe61c15SRodney W. Grimes	done; true
179afe61c15SRodney W. Grimes.endif
180afe61c15SRodney W. Grimes
1813585b293SGarrett Wollmaninstall: afterinstall
1823585b293SGarrett Wollman.if !defined(NOMAN)
1833585b293SGarrett Wollmanafterinstall: realinstall maninstall
1843585b293SGarrett Wollman.else
185afe61c15SRodney W. Grimesafterinstall: realinstall
1863585b293SGarrett Wollman.endif
187afe61c15SRodney W. Grimesrealinstall: beforeinstall
188afe61c15SRodney W. Grimes.endif
189afe61c15SRodney W. Grimes
190d9584d76SJordan K. HubbardDISTRIBUTION?=	bin
19155ff8fb1SPoul-Henning Kamp.if !target(distribute)
19255ff8fb1SPoul-Henning Kampdistribute:
193ffd87c07SPoul-Henning Kamp	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
19455ff8fb1SPoul-Henning Kamp.endif
19555ff8fb1SPoul-Henning Kamp
196afe61c15SRodney W. Grimes.if !target(lint)
197afe61c15SRodney W. Grimeslint: ${SRCS} _PROGSUBDIR
198afe61c15SRodney W. Grimes.if defined(PROG)
199afe61c15SRodney W. Grimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
200afe61c15SRodney W. Grimes.endif
201afe61c15SRodney W. Grimes.endif
202afe61c15SRodney W. Grimes
203afe61c15SRodney W. Grimes.if !target(obj)
204afe61c15SRodney W. Grimes.if defined(NOOBJ)
205afe61c15SRodney W. Grimesobj: _PROGSUBDIR
206afe61c15SRodney W. Grimes.else
207afe61c15SRodney W. Grimesobj: _PROGSUBDIR
208afe61c15SRodney W. Grimes	@cd ${.CURDIR}; rm -rf obj; \
2093585b293SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
210a4c39c7aSBruce Evans	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
211afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
212afe61c15SRodney W. Grimes		mkdir -p $$dest; \
213afe61c15SRodney W. Grimes	else \
214afe61c15SRodney W. Grimes		true; \
215afe61c15SRodney W. Grimes	fi;
216afe61c15SRodney W. Grimes.endif
217afe61c15SRodney W. Grimes.endif
218afe61c15SRodney W. Grimes
219afe61c15SRodney W. Grimes.if !target(tags)
220afe61c15SRodney W. Grimestags: ${SRCS} _PROGSUBDIR
221afe61c15SRodney W. Grimes.if defined(PROG)
2223585b293SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
2233585b293SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
224afe61c15SRodney W. Grimes.endif
225afe61c15SRodney W. Grimes.endif
226afe61c15SRodney W. Grimes
227afe61c15SRodney W. Grimes.if !defined(NOMAN)
228afe61c15SRodney W. Grimes.include <bsd.man.mk>
2293585b293SGarrett Wollman.elif !target(maninstall)
230afe61c15SRodney W. Grimesmaninstall:
231973f098aSGarrett Wollmanall-man:
232afe61c15SRodney W. Grimes.endif
2333585b293SGarrett Wollman
234cdaec7b1SBruce Evans_DEPSUBDIR=	_PROGSUBDIR
2353585b293SGarrett Wollman.include <bsd.dep.mk>
236