bsd.prog.mk revision 74842
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
250476Speter# $FreeBSD: head/share/mk/bsd.prog.mk 74842 2001-03-27 08:43:28Z ru $
31638Srgrimes
438183Speter.if !target(__initialized__)
538183Speter__initialized__:
61844Swollman.if exists(${.CURDIR}/../Makefile.inc)
71638Srgrimes.include "${.CURDIR}/../Makefile.inc"
81638Srgrimes.endif
938183Speter.endif
101638Srgrimes
1136673Sdt.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
121638Srgrimes
132827SjkhCFLAGS+=${COPTS} ${DEBUG_FLAGS}
141844Swollman.if defined(DESTDIR)
151844SwollmanCFLAGS+= -I${DESTDIR}/usr/include
1626051SasamiCXXINCLUDES+= -I${DESTDIR}/usr/include/g++
171844Swollman.endif
181638Srgrimes
192827Sjkh.if !defined(DEBUG_FLAGS)
201638SrgrimesSTRIP?=	-s
212827Sjkh.endif
221638Srgrimes
2327028Spst.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
241844SwollmanLDFLAGS+= -static
251844Swollman.endif
261638Srgrimes
271638Srgrimes.if defined(PROG)
281638Srgrimes.if defined(SRCS)
291638Srgrimes
3036054Sbde# If there are Objective C sources, link with Objective C libraries.
3136054Sbde.if ${SRCS:M*.m} != ""
3236054SbdeOBJCLIBS?= -lobjc
3336054SbdeLDADD+=	${OBJCLIBS}
3436054Sbde.endif
3536054Sbde
361844SwollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
371638Srgrimes
3834081Sbde${PROG}: ${OBJS}
391844Swollman	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
401844Swollman
418321Sbde.else !defined(SRCS)
421844Swollman
4333624Seivind.if !target(${PROG})
442351SbdeSRCS=	${PROG}.c
451638Srgrimes
462351Sbde# Always make an intermediate object file because:
472351Sbde# - it saves time rebuilding when only the library has changed
482351Sbde# - the name of the object gets put into the executable symbol table instead of
492351Sbde#   the name of a variable temporary object.
502351Sbde# - it's useful to keep objects around for crunching.
512351SbdeOBJS=	${PROG}.o
5233624Seivind
5334081Sbde${PROG}: ${OBJS}
542351Sbde	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD}
5533624Seivind.endif
561638Srgrimes
571638Srgrimes.endif
581638Srgrimes
5974806Sru.if	!defined(NOMAN) && !defined(MAN) && \
6074806Sru	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
611638Srgrimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
6258493Sru	!defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
6374806Sru	!defined(MAN1aout)
6474817SruMAN1=	${PROG}.1
651638Srgrimes.endif
661638Srgrimes.endif
671638Srgrimes
681638Srgrimes.MAIN: all
6974806Sru.if !defined(NOMAN)
7018340Sswallaceall: objwarn ${PROG} all-man _SUBDIR
7174806Sru.else
7274806Sruall: objwarn ${PROG} _SUBDIR
7374806Sru.endif
741638Srgrimes
7533816SbdeCLEANFILES+= ${PROG} ${OBJS}
761638Srgrimes
7755670Sbde.if defined(PROG)
7824750Sbde_EXTRADEPEND:
7938655Sjb.if ${OBJFORMAT} == aout
8024750Sbde	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \
8125110Sbde	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
8228945Speter.else
8346541Sbde	echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
8424750Sbde.endif
8528945Speter.endif
8624750Sbde
871638Srgrimes.if !target(install)
881638Srgrimes.if !target(beforeinstall)
891638Srgrimesbeforeinstall:
901638Srgrimes.endif
911638Srgrimes
9249328Shoek_INSTALLFLAGS:=	${INSTALLFLAGS}
9349328Shoek.for ie in ${INSTALLFLAGS_EDIT}
9449328Shoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
9549328Shoek.endfor
9649328Shoek
9716663Sjkhrealinstall: beforeinstall
981638Srgrimes.if defined(PROG)
991844Swollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
10049328Shoek	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1011638Srgrimes.endif
1021638Srgrimes.if defined(HIDEGAME)
10340505Sobrien	(cd ${DESTDIR}/${GBINDIR}; rm -f ${PROG}; ln -s dm ${PROG}; \
10423542Sbde	    chown games:bin ${PROG})
1051638Srgrimes.endif
1061638Srgrimes.if defined(LINKS) && !empty(LINKS)
1071638Srgrimes	@set ${LINKS}; \
1081638Srgrimes	while test $$# -ge 2; do \
1091638Srgrimes		l=${DESTDIR}$$1; \
1101638Srgrimes		shift; \
1111638Srgrimes		t=${DESTDIR}$$1; \
1121638Srgrimes		shift; \
1132351Sbde		${ECHO} $$t -\> $$l; \
11444946Sbde		ln -f $$l $$t; \
1151638Srgrimes	done; true
1161638Srgrimes.endif
11744946Sbde.if defined(SYMLINKS) && !empty(SYMLINKS)
11844946Sbde	@set ${SYMLINKS}; \
11944946Sbde	while test $$# -ge 2; do \
12044946Sbde		l=$$1; \
12144946Sbde		shift; \
12244946Sbde		t=${DESTDIR}$$1; \
12344946Sbde		shift; \
12444946Sbde		${ECHO} $$t -\> $$l; \
12544946Sbde		ln -fs $$l $$t; \
12644946Sbde	done; true
12744946Sbde.endif
1281638Srgrimes
12916663Sjkhinstall: afterinstall _SUBDIR
1301844Swollman.if !defined(NOMAN)
1311844Swollmanafterinstall: realinstall maninstall
1321844Swollman.else
1331638Srgrimesafterinstall: realinstall
1341844Swollman.endif
1351638Srgrimes.endif
1361638Srgrimes
1375585SjkhDISTRIBUTION?=	bin
1384442Sphk.if !target(distribute)
13916663Sjkhdistribute: _SUBDIR
14026760Sjkh.for dist in ${DISTRIBUTION}
14126760Sjkh	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
14226760Sjkh.endfor
1434442Sphk.endif
1444442Sphk
1451638Srgrimes.if !target(lint)
14616663Sjkhlint: ${SRCS} _SUBDIR
1471638Srgrimes.if defined(PROG)
1481638Srgrimes	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
1491638Srgrimes.endif
1501638Srgrimes.endif
1511638Srgrimes
15224861Sjkh.if defined(NOTAGS)
15324861Sjkhtags:
15424861Sjkh.endif
15524861Sjkh
1561638Srgrimes.if !target(tags)
15716663Sjkhtags: ${SRCS} _SUBDIR
1581638Srgrimes.if defined(PROG)
15934829Seivind	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
16024861Sjkh.if defined(HTML)
16134829Seivind	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
1621638Srgrimes.endif
1631638Srgrimes.endif
16424861Sjkh.endif
1651638Srgrimes
1661638Srgrimes.if !defined(NOMAN)
1671638Srgrimes.include <bsd.man.mk>
16874842Sru.else
16974842Sru.if !target(all-man)
17074842Sruall-man:
17174842Sru.endif
17274842Sru.if !target(maninstall)
1731638Srgrimesmaninstall:
1741638Srgrimes.endif
17574842Sru.endif
1761844Swollman
17734528Seivind.if !target(regress)
17834528Seivindregress:
17934528Seivind.endif
18034528Seivind
18143055Sjdp.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
18228945Speter.include <bsd.libnames.mk>
18328945Speter.endif
18428945Speter
1851844Swollman.include <bsd.dep.mk>
18634081Sbde
18734081Sbde.if defined(PROG) && !exists(${DEPENDFILE})
18834087Sbde${OBJS}: ${SRCS:M*.h}
18934081Sbde.endif
19034081Sbde
19116663Sjkh.include <bsd.obj.mk>
192