bsd.prog.mk revision 103713
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
250476Speter# $FreeBSD: head/share/mk/bsd.prog.mk 103713 2002-09-20 19:32:51Z markm $
31638Srgrimes
494940Sru.include <bsd.init.mk>
51638Srgrimes
6103713Smarkm.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm
71638Srgrimes
82827SjkhCFLAGS+=${COPTS} ${DEBUG_FLAGS}
91638Srgrimes
102827Sjkh.if !defined(DEBUG_FLAGS)
111638SrgrimesSTRIP?=	-s
122827Sjkh.endif
131638Srgrimes
1427028Spst.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
151844SwollmanLDFLAGS+= -static
161844Swollman.endif
171638Srgrimes
1894424Sru.if defined(PROG_CXX)
1994424SruPROG=	${PROG_CXX}
2094424Sru.endif
2194424Sru
221638Srgrimes.if defined(PROG)
231638Srgrimes.if defined(SRCS)
241638Srgrimes
2536054Sbde# If there are Objective C sources, link with Objective C libraries.
2636054Sbde.if ${SRCS:M*.m} != ""
2736054SbdeOBJCLIBS?= -lobjc
2836054SbdeLDADD+=	${OBJCLIBS}
2936054Sbde.endif
3036054Sbde
311844SwollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
321638Srgrimes
3394518Sru${PROG}: ${OBJS}
3494518Sru.if defined(PROG_CXX)
3594518Sru	${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
3694518Sru.else
3794518Sru	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
3894518Sru.endif
3994518Sru
408321Sbde.else !defined(SRCS)
411844Swollman
4294518Sru.if !target(${PROG})
4394424Sru.if defined(PROG_CXX)
4494424SruSRCS=	${PROG}.cc
4594424Sru.else
462351SbdeSRCS=	${PROG}.c
4794424Sru.endif
481638Srgrimes
492351Sbde# Always make an intermediate object file because:
502351Sbde# - it saves time rebuilding when only the library has changed
512351Sbde# - the name of the object gets put into the executable symbol table instead of
522351Sbde#   the name of a variable temporary object.
532351Sbde# - it's useful to keep objects around for crunching.
542351SbdeOBJS=	${PROG}.o
5533624Seivind
5634081Sbde${PROG}: ${OBJS}
5794497Sru.if defined(PROG_CXX)
5894497Sru	${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
5994497Sru.else
6094410Sru	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
6133624Seivind.endif
6294518Sru.endif
631638Srgrimes
641638Srgrimes.endif
651638Srgrimes
6674806Sru.if	!defined(NOMAN) && !defined(MAN) && \
6774806Sru	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
681638Srgrimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
6958493Sru	!defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
7074806Sru	!defined(MAN1aout)
7174941SruMAN=	${PROG}.1
7274941SruMAN1=	${MAN}
731638Srgrimes.endif
741638Srgrimes.endif
751638Srgrimes
7697769Sruall: objwarn ${PROG} ${SCRIPTS}
7774806Sru.if !defined(NOMAN)
7896164Sruall: _manpages
7974806Sru.endif
801638Srgrimes
8133816SbdeCLEANFILES+= ${PROG} ${OBJS}
821638Srgrimes
8355670Sbde.if defined(PROG)
8424750Sbde_EXTRADEPEND:
8546541Sbde	echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
8694497Sru.if defined(PROG_CXX)
8794497Sru	echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
8824750Sbde.endif
8928945Speter.endif
9024750Sbde
911638Srgrimes.if !target(install)
921638Srgrimes
9349328Shoek_INSTALLFLAGS:=	${INSTALLFLAGS}
9449328Shoek.for ie in ${INSTALLFLAGS_EDIT}
9549328Shoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
9649328Shoek.endfor
9749328Shoek
9895734Sru.if !target(realinstall)
9996163Srurealinstall: _proginstall
10099343Sru.ORDER: beforeinstall _proginstall
10196163Sru_proginstall:
1021638Srgrimes.if defined(PROG)
10375083Sru.if defined(PROGNAME)
104100872Sru	${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
10575083Sru	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
10675083Sru.else
107100872Sru	${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
10849328Shoek	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1091638Srgrimes.endif
11075083Sru.endif
1111638Srgrimes.if defined(HIDEGAME)
11278203Sru	(cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \
11378203Sru	    chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
1141638Srgrimes.endif
11595734Sru.endif !target(realinstall)
1161638Srgrimes
11775284Sru.if defined(SCRIPTS) && !empty(SCRIPTS)
11875284Srurealinstall: _scriptsinstall
11999343Sru.ORDER: beforeinstall _scriptsinstall
12075284Sru
12175284SruSCRIPTSDIR?=	${BINDIR}
12275284SruSCRIPTSOWN?=	${BINOWN}
12375284SruSCRIPTSGRP?=	${BINGRP}
12475284SruSCRIPTSMODE?=	${BINMODE}
12575284Sru
12675284Sru.for script in ${SCRIPTS}
12775284Sru.if defined(SCRIPTSNAME)
12875284SruSCRIPTSNAME_${script:T}?=	${SCRIPTSNAME}
12975284Sru.else
13075284SruSCRIPTSNAME_${script:T}?=	${script:T:R}
13175284Sru.endif
13275284SruSCRIPTSDIR_${script:T}?=	${SCRIPTSDIR}
13375284SruSCRIPTSOWN_${script:T}?=	${SCRIPTSOWN}
13475284SruSCRIPTSGRP_${script:T}?=	${SCRIPTSGRP}
13575284SruSCRIPTSMODE_${script:T}?=	${SCRIPTSMODE}
13688055Sru_scriptsinstall: _SCRIPTSINS_${script:T}
13788055Sru_SCRIPTSINS_${script:T}: ${script}
138100872Sru	${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
13975284Sru	    -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
14094954Sru	    ${.ALLSRC} \
14175284Sru	    ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
14275284Sru.endfor
14375284Sru.endif
14475284Sru
14599257SruNLSNAME?=	${PROG}
14699257Sru.include <bsd.nls.mk>
14799257Sru
14897769Sru.include <bsd.files.mk>
14996668Sru.include <bsd.incs.mk>
15099256Sru.include <bsd.links.mk>
15196462Sru
15296163Sru.if !defined(NOMAN)
15396164Srurealinstall: _maninstall
15499343Sru.ORDER: beforeinstall _maninstall
15596163Sru.endif
15696163Sru
1571844Swollman.endif
1581638Srgrimes
1591638Srgrimes.if !target(lint)
160103713Smarkmlint: ${SRCS:M*.c}
1611638Srgrimes.if defined(PROG)
162103713Smarkm	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC}
1631638Srgrimes.endif
1641638Srgrimes.endif
1651638Srgrimes
16624861Sjkh.if defined(NOTAGS)
16724861Sjkhtags:
16824861Sjkh.endif
16924861Sjkh
1701638Srgrimes.if !target(tags)
17195306Srutags: ${SRCS}
1721638Srgrimes.if defined(PROG)
17334829Seivind	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
17424861Sjkh.if defined(HTML)
17534829Seivind	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
1761638Srgrimes.endif
1771638Srgrimes.endif
17824861Sjkh.endif
1791638Srgrimes
1801638Srgrimes.if !defined(NOMAN)
1811638Srgrimes.include <bsd.man.mk>
18274842Sru.endif
1831844Swollman
18428945Speter.include <bsd.libnames.mk>
18528945Speter
1861844Swollman.include <bsd.dep.mk>
18734081Sbde
18894113Sru.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
18934087Sbde${OBJS}: ${SRCS:M*.h}
19034081Sbde.endif
19134081Sbde
19216663Sjkh.include <bsd.obj.mk>
19376861Skris
19476861Skris.include <bsd.sys.mk>
195