bsd.prog.mk revision 24750
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
224750Sbde#	$Id: bsd.prog.mk,v 1.45 1997/03/08 19:47:08 bde Exp $
31638Srgrimes
41844Swollman.if exists(${.CURDIR}/../Makefile.inc)
51638Srgrimes.include "${.CURDIR}/../Makefile.inc"
61638Srgrimes.endif
71638Srgrimes
81844Swollman.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
91638Srgrimes
102827SjkhCFLAGS+=${COPTS} ${DEBUG_FLAGS}
111844Swollman.if defined(DESTDIR)
121844SwollmanCFLAGS+= -I${DESTDIR}/usr/include
131844SwollmanCXXINCLUDES+= -I${DESTDIR}/usr/include/${CXX}
141844Swollman.endif
151638Srgrimes
162827Sjkh.if !defined(DEBUG_FLAGS)
171638SrgrimesSTRIP?=	-s
182827Sjkh.endif
191638Srgrimes
201844Swollman.if defined(NOSHARED)
211844SwollmanLDFLAGS+= -static
221844Swollman.endif
231638Srgrimes
241844Swollman.if defined(DESTDIR)
2524750SbdeLDDESTDIR?=	-L${DESTDIR}${SHLIBDIR} -L${DESTDIR}/usr/lib
2624750Sbde# LDDESTDIR+=	-nostdlib
271844Swollman.endif
281844Swollman
2924750Sbde# XXX obsolescent.
3018529Sbde.include <bsd.libnames.mk>
3118529Sbde
321638Srgrimes.if defined(PROG)
331638Srgrimes.if defined(SRCS)
341638Srgrimes
351844SwollmanDPSRCS+= ${SRCS:M*.h}
361844SwollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
371638Srgrimes
381844Swollman.if defined(LDONLY)
391638Srgrimes
4024750Sbde# XXX is this used?  -static in ${LDFLAGS} can't be passed here.
4124750Sbde${PROG}: ${DPSRCS} ${OBJS}
422351Sbde	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
431844Swollman		${LDADD}
441638Srgrimes
451844Swollman.else defined(LDONLY)
461844Swollman
4724750Sbde${PROG}: ${DPSRCS} ${OBJS}
481844Swollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
491844Swollman
501844Swollman.endif
511844Swollman
528321Sbde.else !defined(SRCS)
531844Swollman
542351SbdeSRCS=	${PROG}.c
551638Srgrimes
562351Sbde.if 0
5724750Sbde${PROG}: ${DPSRCS} ${SRCS}
581844Swollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
591844Swollman		${LDDESTDIR} ${LDADD}
605188Sbde
615188SbdeMKDEP=	-p
622351Sbde.else
632351Sbde# Always make an intermediate object file because:
642351Sbde# - it saves time rebuilding when only the library has changed
652351Sbde# - the name of the object gets put into the executable symbol table instead of
662351Sbde#   the name of a variable temporary object.
672351Sbde# - it's useful to keep objects around for crunching.
682351SbdeOBJS=	${PROG}.o
6924750Sbde${PROG}: ${DPSRCS} ${OBJS}
702351Sbde	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
712351Sbde.endif
721638Srgrimes
731638Srgrimes.endif
741638Srgrimes
751638Srgrimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
761638Srgrimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
771638Srgrimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
781844SwollmanMAN1=	${PROG}.1
791638Srgrimes.endif
801638Srgrimes.endif
811638Srgrimes
826252Sbde# XXX I think MANDEPEND is only used for groff.  It should be named more
836252Sbde# generally and perhaps not be in the maninstall dependencies now it is
846252Sbde# here (or does maninstall always work when nothing is made?),
856252Sbde
861638Srgrimes.MAIN: all
8718340Sswallaceall: objwarn ${PROG} all-man _SUBDIR
881638Srgrimes
891638Srgrimes.if !target(clean)
9016663Sjkhclean: _SUBDIR
9114444Swosch	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 
9216826Sphk.if defined(CLEANDIRS) && !empty(CLEANDIRS)
9316437Sphk	rm -rf ${CLEANDIRS}
941638Srgrimes.endif
9516437Sphk.endif
961638Srgrimes
9724750Sbde.if defined(PROG)
9824750Sbde_EXTRADEPEND:
9924750Sbde	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
10024750Sbde	    ${LDADD}` >> ${DEPENDFILE}
10124750Sbde.endif
10224750Sbde
1031638Srgrimes.if !target(install)
1041638Srgrimes.if !target(beforeinstall)
1051638Srgrimesbeforeinstall:
1061638Srgrimes.endif
1071638Srgrimes
10816663Sjkhrealinstall: beforeinstall
1091638Srgrimes.if defined(PROG)
1101844Swollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1111996Swollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1121638Srgrimes.endif
1131638Srgrimes.if defined(HIDEGAME)
1141638Srgrimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
11523542Sbde	    chown games:bin ${PROG})
1161638Srgrimes.endif
1171638Srgrimes.if defined(LINKS) && !empty(LINKS)
1181638Srgrimes	@set ${LINKS}; \
1191638Srgrimes	while test $$# -ge 2; do \
1201638Srgrimes		l=${DESTDIR}$$1; \
1211638Srgrimes		shift; \
1221638Srgrimes		t=${DESTDIR}$$1; \
1231638Srgrimes		shift; \
1242351Sbde		${ECHO} $$t -\> $$l; \
1251638Srgrimes		rm -f $$t; \
1266031Sjkh		ln ${LN_FLAGS} $$l $$t; \
1271638Srgrimes	done; true
1281638Srgrimes.endif
1291638Srgrimes
13016663Sjkhinstall: afterinstall _SUBDIR
1311844Swollman.if !defined(NOMAN)
1321844Swollmanafterinstall: realinstall maninstall
1331844Swollman.else
1341638Srgrimesafterinstall: realinstall
1351844Swollman.endif
1361638Srgrimes.endif
1371638Srgrimes
1385585SjkhDISTRIBUTION?=	bin
1394442Sphk.if !target(distribute)
14016663Sjkhdistribute: _SUBDIR
1416716Sphk	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
1424442Sphk.endif
1434442Sphk
1441638Srgrimes.if !target(lint)
14516663Sjkhlint: ${SRCS} _SUBDIR
1461638Srgrimes.if defined(PROG)
1471638Srgrimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
1481638Srgrimes.endif
1491638Srgrimes.endif
1501638Srgrimes
1511638Srgrimes.if !target(tags)
15216663Sjkhtags: ${SRCS} _SUBDIR
1531638Srgrimes.if defined(PROG)
1541844Swollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
1551844Swollman	    sed "s;\${.CURDIR}/;;" > tags
1561638Srgrimes.endif
1571638Srgrimes.endif
1581638Srgrimes
1591638Srgrimes.if !defined(NOMAN)
1601638Srgrimes.include <bsd.man.mk>
1611844Swollman.elif !target(maninstall)
1621638Srgrimesmaninstall:
16311136Swollmanall-man:
1641638Srgrimes.endif
1651844Swollman
1661844Swollman.include <bsd.dep.mk>
16716663Sjkh.include <bsd.obj.mk>
168