bsd.prog.mk revision 18340
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
218340Sswallace#	$Id: bsd.prog.mk,v 1.39 1996/09/05 18:05: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)
253860SbdeLDDESTDIR+=	-L${DESTDIR}/usr/lib
261844Swollman.endif
271844Swollman
281638Srgrimes.if defined(PROG)
291638Srgrimes.if defined(SRCS)
301638Srgrimes
311844SwollmanDPSRCS+= ${SRCS:M*.h}
325859Sjkh.if !defined(NOOBJ)
331844SwollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
345856Sjkh.endif
351638Srgrimes
361844Swollman.if defined(LDONLY)
371638Srgrimes
381844Swollman${PROG}: ${LIBCRT0} ${LIBC} ${DPSRCS} ${OBJS} ${DPADD} 
392351Sbde	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDDESTDIR} \
401844Swollman		${LDADD}
411638Srgrimes
421844Swollman.else defined(LDONLY)
431844Swollman
441844Swollman${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
451844Swollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
461844Swollman
471844Swollman.endif
481844Swollman
498321Sbde.else !defined(SRCS)
501844Swollman
512351SbdeSRCS=	${PROG}.c
521638Srgrimes
532351Sbde.if 0
541844Swollman${PROG}: ${DPSRCS} ${SRCS} ${LIBC} ${DPADD}
551844Swollman	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} \
561844Swollman		${LDDESTDIR} ${LDADD}
575188Sbde
585188SbdeMKDEP=	-p
592351Sbde.else
602351Sbde# Always make an intermediate object file because:
612351Sbde# - it saves time rebuilding when only the library has changed
622351Sbde# - the name of the object gets put into the executable symbol table instead of
632351Sbde#   the name of a variable temporary object.
642351Sbde# - it's useful to keep objects around for crunching.
652351SbdeOBJS=	${PROG}.o
662351Sbde${PROG}: ${DPSRCS} ${OBJS} ${LIBC} ${DPADD}
672351Sbde	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
682351Sbde.endif
691638Srgrimes
701638Srgrimes.endif
711638Srgrimes
721638Srgrimes.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
731638Srgrimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
741638Srgrimes	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
751844SwollmanMAN1=	${PROG}.1
761638Srgrimes.endif
771638Srgrimes.endif
781638Srgrimes
796252Sbde# XXX I think MANDEPEND is only used for groff.  It should be named more
806252Sbde# generally and perhaps not be in the maninstall dependencies now it is
816252Sbde# here (or does maninstall always work when nothing is made?),
826252Sbde
831638Srgrimes.MAIN: all
8418340Sswallaceall: objwarn ${PROG} all-man _SUBDIR
851638Srgrimes
861638Srgrimes.if !target(clean)
8716663Sjkhclean: _SUBDIR
8814444Swosch	rm -f a.out Errs errs mklog ${PROG} ${OBJS} ${CLEANFILES} 
8916826Sphk.if defined(CLEANDIRS) && !empty(CLEANDIRS)
9016437Sphk	rm -rf ${CLEANDIRS}
911638Srgrimes.endif
9216437Sphk.endif
931638Srgrimes
941638Srgrimes.if !target(install)
951638Srgrimes.if !target(beforeinstall)
961638Srgrimesbeforeinstall:
971638Srgrimes.endif
981638Srgrimes
9916663Sjkhrealinstall: beforeinstall
1001638Srgrimes.if defined(PROG)
1011844Swollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1021996Swollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1031638Srgrimes.endif
1041638Srgrimes.if defined(HIDEGAME)
1051638Srgrimes	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
1061638Srgrimes	    chown games.bin ${PROG})
1071638Srgrimes.endif
1081638Srgrimes.if defined(LINKS) && !empty(LINKS)
1091638Srgrimes	@set ${LINKS}; \
1101638Srgrimes	while test $$# -ge 2; do \
1111638Srgrimes		l=${DESTDIR}$$1; \
1121638Srgrimes		shift; \
1131638Srgrimes		t=${DESTDIR}$$1; \
1141638Srgrimes		shift; \
1152351Sbde		${ECHO} $$t -\> $$l; \
1161638Srgrimes		rm -f $$t; \
1176031Sjkh		ln ${LN_FLAGS} $$l $$t; \
1181638Srgrimes	done; true
1191638Srgrimes.endif
1201638Srgrimes
12116663Sjkhinstall: afterinstall _SUBDIR
1221844Swollman.if !defined(NOMAN)
1231844Swollmanafterinstall: realinstall maninstall
1241844Swollman.else
1251638Srgrimesafterinstall: realinstall
1261844Swollman.endif
1271638Srgrimes.endif
1281638Srgrimes
1295585SjkhDISTRIBUTION?=	bin
1304442Sphk.if !target(distribute)
13116663Sjkhdistribute: _SUBDIR
1326716Sphk	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
1334442Sphk.endif
1344442Sphk
1351638Srgrimes.if !target(lint)
13616663Sjkhlint: ${SRCS} _SUBDIR
1371638Srgrimes.if defined(PROG)
1381638Srgrimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
1391638Srgrimes.endif
1401638Srgrimes.endif
1411638Srgrimes
1421638Srgrimes.if !target(tags)
14316663Sjkhtags: ${SRCS} _SUBDIR
1441638Srgrimes.if defined(PROG)
1451844Swollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
1461844Swollman	    sed "s;\${.CURDIR}/;;" > tags
1471638Srgrimes.endif
1481638Srgrimes.endif
1491638Srgrimes
1501638Srgrimes.if !defined(NOMAN)
1511638Srgrimes.include <bsd.man.mk>
1521844Swollman.elif !target(maninstall)
1531638Srgrimesmaninstall:
15411136Swollmanall-man:
1551638Srgrimes.endif
1561844Swollman
1571844Swollman.include <bsd.dep.mk>
15818052Sbde.include <bsd.libnames.mk>
15916663Sjkh.include <bsd.obj.mk>
160