xref: /freebsd/share/mk/bsd.prog.mk (revision 45f7f888bbb77804f7dd3b2f1107adcb37137814)
13585b293SGarrett Wollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
245f7f888SGarrett Wollman#	$Id: bsd.prog.mk,v 1.2 1994/08/04 21:09:25 wollman 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
10afe61c15SRodney W. GrimesCFLAGS+=${COPTS}
113585b293SGarrett Wollman.if defined(DESTDIR)
123585b293SGarrett WollmanCFLAGS+= -I${DESTDIR}/usr/include
133585b293SGarrett WollmanCXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
143585b293SGarrett Wollman.endif
15afe61c15SRodney W. Grimes
16afe61c15SRodney W. GrimesSTRIP?=	-s
17afe61c15SRodney W. Grimes
18afe61c15SRodney W. GrimesBINGRP?=	bin
19afe61c15SRodney W. GrimesBINOWN?=	bin
20afe61c15SRodney W. GrimesBINMODE?=	555
21afe61c15SRodney W. Grimes
223585b293SGarrett WollmanINSTALL?=	install
233585b293SGarrett Wollman.if !defined(DESTDIR)
243585b293SGarrett WollmanLIBCRT0?=	/usr/lib/crt0.o
25afe61c15SRodney W. GrimesLIBC?=		/usr/lib/libc.a
26afe61c15SRodney W. GrimesLIBCOMPAT?=	/usr/lib/libcompat.a
273585b293SGarrett WollmanLIBCRYPT?=	/usr/lib/libcrypt.a
28afe61c15SRodney W. GrimesLIBCURSES?=	/usr/lib/libcurses.a
29afe61c15SRodney W. GrimesLIBDBM?=	/usr/lib/libdbm.a
30afe61c15SRodney W. GrimesLIBDES?=	/usr/lib/libdes.a
313585b293SGarrett WollmanLIBGNUMALLOC?=	/usr/lib/libgnumalloc.a
323585b293SGarrett WollmanLIBGNUREGEX?=	/usr/lib/libgnuregex.a
33afe61c15SRodney W. GrimesLIBL?=		/usr/lib/libl.a
34afe61c15SRodney W. GrimesLIBKDB?=	/usr/lib/libkdb.a
35afe61c15SRodney W. GrimesLIBKRB?=	/usr/lib/libkrb.a
36afe61c15SRodney W. GrimesLIBM?=		/usr/lib/libm.a
37afe61c15SRodney W. GrimesLIBMP?=		/usr/lib/libmp.a
38afe61c15SRodney W. GrimesLIBPC?=		/usr/lib/libpc.a
39afe61c15SRodney W. GrimesLIBPLOT?=	/usr/lib/libplot.a
403585b293SGarrett WollmanLIBREADLINE?=	/usr/lib/libreadline.a
41afe61c15SRodney W. GrimesLIBRESOLV?=	/usr/lib/libresolv.a
423585b293SGarrett WollmanLIBRPCSVC?=	/usr/lib/librpcsvc.a
433585b293SGarrett WollmanLIBSKEY?=	/usr/lib/libskey.a
443585b293SGarrett WollmanLIBTELNET?=	/usr/lib/libtelnet.a
453585b293SGarrett WollmanLIBTERM?=       /usr/lib/libtermcap.a
46afe61c15SRodney W. GrimesLIBUTIL?=	/usr/lib/libutil.a
473585b293SGarrett Wollman.else
483585b293SGarrett WollmanLIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
493585b293SGarrett WollmanLIBC?=		${DESTDIR}/usr/lib/libc.a
503585b293SGarrett WollmanLIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
513585b293SGarrett WollmanLIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
523585b293SGarrett WollmanLIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
533585b293SGarrett WollmanLIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
543585b293SGarrett WollmanLIBDES?=	${DESTDIR}/usr/lib/libdes.a
553585b293SGarrett WollmanLIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
563585b293SGarrett WollmanLIBGNUREGEX?=	${DESTDIR}/usr/lib/libgnuregex.a
573585b293SGarrett WollmanLIBL?=		${DESTDIR}/usr/lib/libl.a
583585b293SGarrett WollmanLIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
593585b293SGarrett WollmanLIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
603585b293SGarrett WollmanLIBM?=		${DESTDIR}/usr/lib/libm.a
613585b293SGarrett WollmanLIBMP?=		${DESTDIR}/usr/lib/libmp.a
623585b293SGarrett WollmanLIBPC?=		${DESTDIR}/usr/lib/libpc.a
633585b293SGarrett WollmanLIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
643585b293SGarrett WollmanLIBREADLINE?=	${DESTDIR}/usr/lib/libreadline.a
653585b293SGarrett WollmanLIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
663585b293SGarrett WollmanLIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
673585b293SGarrett WollmanLIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
683585b293SGarrett WollmanLIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
693585b293SGarrett WollmanLIBTERM?=       ${DESTDIR}/usr/lib/libtermcap.a
703585b293SGarrett WollmanLIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
713585b293SGarrett Wollman.endif
723585b293SGarrett Wollman.if defined(NOSHARED)
733585b293SGarrett WollmanLDFLAGS+= -static
743585b293SGarrett Wollman.endif
75afe61c15SRodney W. Grimes
76afe61c15SRodney W. Grimes.if defined(SHAREDSTRINGS)
77afe61c15SRodney W. GrimesCLEANFILES+=strings
78afe61c15SRodney W. Grimes.c.o:
79afe61c15SRodney W. Grimes	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
80afe61c15SRodney W. Grimes	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
81afe61c15SRodney W. Grimes	@rm -f x.c
823585b293SGarrett Wollman
833585b293SGarrett Wollman.cc.o .cxx.o .C.o:
843585b293SGarrett Wollman	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
853585b293SGarrett Wollman	@mv -f x.c x.cc
863585b293SGarrett Wollman	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
873585b293SGarrett Wollman
883585b293SGarrett Wollman.endif
893585b293SGarrett Wollman
903585b293SGarrett Wollman.if defined(DESTDIR)
913585b293SGarrett WollmanLDDESTDIR?=	-L${DESTDIR}/usr/lib
92afe61c15SRodney W. Grimes.endif
93afe61c15SRodney W. Grimes
94afe61c15SRodney W. Grimes.if defined(PROG)
95afe61c15SRodney W. Grimes.if defined(SRCS)
96afe61c15SRodney W. Grimes
973585b293SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
983585b293SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
99afe61c15SRodney W. Grimes
1003585b293SGarrett Wollman.if defined(LDONLY)
101afe61c15SRodney W. Grimes
1023585b293SGarrett Wollman${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD}
1033585b293SGarrett Wollman	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDR} \
1043585b293SGarrett Wollman		${LDADD}
1053585b293SGarrett Wollman
1063585b293SGarrett Wollman.else defined(LDONLY)
1073585b293SGarrett Wollman
1083585b293SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
1093585b293SGarrett Wollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
1103585b293SGarrett Wollman
1113585b293SGarrett Wollman.endif
1123585b293SGarrett Wollman
1133585b293SGarrett Wollman.else defined(PROG)
114afe61c15SRodney W. Grimes
115afe61c15SRodney W. GrimesSRCS= ${PROG}.c
116afe61c15SRodney W. Grimes
1173585b293SGarrett Wollman${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
1183585b293SGarrett Wollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
1193585b293SGarrett Wollman		${LDDESTDIR} ${LDADD}
120afe61c15SRodney W. Grimes
121afe61c15SRodney W. GrimesMKDEP=	-p
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 \
135afe61c15SRodney W. Grimes		(echo "===> $$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; \
141afe61c15SRodney W. Grimes		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
142afe61c15SRodney W. Grimes	done
143afe61c15SRodney W. Grimes.endif
144afe61c15SRodney W. Grimes
145afe61c15SRodney W. Grimes.MAIN: all
1463585b293SGarrett Wollmanall: ${PROG} _PROGSUBDIR
147afe61c15SRodney W. Grimes
148afe61c15SRodney W. Grimes.if !target(clean)
149afe61c15SRodney W. Grimesclean: _PROGSUBDIR
1503585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
151afe61c15SRodney W. Grimes.endif
152afe61c15SRodney W. Grimes
153afe61c15SRodney W. Grimes.if !target(cleandir)
154afe61c15SRodney W. Grimescleandir: _PROGSUBDIR
1553585b293SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
1563585b293SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
1573585b293SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
158afe61c15SRodney W. Grimes.endif
159afe61c15SRodney W. Grimes
160afe61c15SRodney W. Grimes.if !target(install)
161afe61c15SRodney W. Grimes.if !target(beforeinstall)
162afe61c15SRodney W. Grimesbeforeinstall:
163afe61c15SRodney W. Grimes.endif
164afe61c15SRodney W. Grimes.if !target(afterinstall)
165afe61c15SRodney W. Grimesafterinstall:
166afe61c15SRodney W. Grimes.endif
167afe61c15SRodney W. Grimes
168afe61c15SRodney W. Grimesrealinstall: _PROGSUBDIR
169afe61c15SRodney W. Grimes.if defined(PROG)
1703585b293SGarrett Wollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
17145f7f888SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
172afe61c15SRodney W. Grimes.endif
173afe61c15SRodney W. Grimes.if defined(HIDEGAME)
174afe61c15SRodney W. Grimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
175afe61c15SRodney W. Grimes	    chown games.bin ${PROG})
176afe61c15SRodney W. Grimes.endif
177afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS)
178afe61c15SRodney W. Grimes	@set ${LINKS}; \
179afe61c15SRodney W. Grimes	while test $$# -ge 2; do \
180afe61c15SRodney W. Grimes		l=${DESTDIR}$$1; \
181afe61c15SRodney W. Grimes		shift; \
182afe61c15SRodney W. Grimes		t=${DESTDIR}$$1; \
183afe61c15SRodney W. Grimes		shift; \
184afe61c15SRodney W. Grimes		echo $$t -\> $$l; \
185afe61c15SRodney W. Grimes		rm -f $$t; \
186afe61c15SRodney W. Grimes		ln $$l $$t; \
187afe61c15SRodney W. Grimes	done; true
188afe61c15SRodney W. Grimes.endif
189afe61c15SRodney W. Grimes
1903585b293SGarrett Wollmaninstall: afterinstall
1913585b293SGarrett Wollman.if !defined(NOMAN)
1923585b293SGarrett Wollmanafterinstall: realinstall maninstall
1933585b293SGarrett Wollman.else
194afe61c15SRodney W. Grimesafterinstall: realinstall
1953585b293SGarrett Wollman.endif
196afe61c15SRodney W. Grimesrealinstall: beforeinstall
197afe61c15SRodney W. Grimes.endif
198afe61c15SRodney W. Grimes
199afe61c15SRodney W. Grimes.if !target(lint)
200afe61c15SRodney W. Grimeslint: ${SRCS} _PROGSUBDIR
201afe61c15SRodney W. Grimes.if defined(PROG)
202afe61c15SRodney W. Grimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
203afe61c15SRodney W. Grimes.endif
204afe61c15SRodney W. Grimes.endif
205afe61c15SRodney W. Grimes
206afe61c15SRodney W. Grimes.if !target(obj)
207afe61c15SRodney W. Grimes.if defined(NOOBJ)
208afe61c15SRodney W. Grimesobj: _PROGSUBDIR
209afe61c15SRodney W. Grimes.else
210afe61c15SRodney W. Grimesobj: _PROGSUBDIR
211afe61c15SRodney W. Grimes	@cd ${.CURDIR}; rm -rf obj; \
2123585b293SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
213afe61c15SRodney W. Grimes	echo "$$here -> $$dest"; ln -s $$dest obj; \
214afe61c15SRodney W. Grimes	if test -d /usr/obj -a ! -d $$dest; then \
215afe61c15SRodney W. Grimes		mkdir -p $$dest; \
216afe61c15SRodney W. Grimes	else \
217afe61c15SRodney W. Grimes		true; \
218afe61c15SRodney W. Grimes	fi;
219afe61c15SRodney W. Grimes.endif
220afe61c15SRodney W. Grimes.endif
221afe61c15SRodney W. Grimes
222afe61c15SRodney W. Grimes.if !target(tags)
223afe61c15SRodney W. Grimestags: ${SRCS} _PROGSUBDIR
224afe61c15SRodney W. Grimes.if defined(PROG)
2253585b293SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
2263585b293SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
227afe61c15SRodney W. Grimes.endif
228afe61c15SRodney W. Grimes.endif
229afe61c15SRodney W. Grimes
230afe61c15SRodney W. Grimes.if !defined(NOMAN)
231afe61c15SRodney W. Grimes.include <bsd.man.mk>
2323585b293SGarrett Wollman.elif !target(maninstall)
233afe61c15SRodney W. Grimesmaninstall:
234afe61c15SRodney W. Grimes.endif
2353585b293SGarrett Wollman
2363585b293SGarrett Wollman.include <bsd.dep.mk>
237