bsd.prog.mk revision 100872
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
250476Speter# $FreeBSD: head/share/mk/bsd.prog.mk 100872 2002-07-29 09:40:17Z ru $
31638Srgrimes
494940Sru.include <bsd.init.mk>
51638Srgrimes
695064Sobrien.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .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:
8538655Sjb.if ${OBJFORMAT} == aout
8694410Sru	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} \
8725110Sbde	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
8828945Speter.else
8946541Sbde	echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
9094497Sru.if defined(PROG_CXX)
9194497Sru	echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
9224750Sbde.endif
9328945Speter.endif
9494497Sru.endif
9524750Sbde
961638Srgrimes.if !target(install)
971638Srgrimes
9849328Shoek_INSTALLFLAGS:=	${INSTALLFLAGS}
9949328Shoek.for ie in ${INSTALLFLAGS_EDIT}
10049328Shoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
10149328Shoek.endfor
10249328Shoek
10395734Sru.if !target(realinstall)
10496163Srurealinstall: _proginstall
10599343Sru.ORDER: beforeinstall _proginstall
10696163Sru_proginstall:
1071638Srgrimes.if defined(PROG)
10875083Sru.if defined(PROGNAME)
109100872Sru	${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
11075083Sru	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
11175083Sru.else
112100872Sru	${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
11349328Shoek	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1141638Srgrimes.endif
11575083Sru.endif
1161638Srgrimes.if defined(HIDEGAME)
11778203Sru	(cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \
11878203Sru	    chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
1191638Srgrimes.endif
12095734Sru.endif !target(realinstall)
1211638Srgrimes
12275284Sru.if defined(SCRIPTS) && !empty(SCRIPTS)
12375284Srurealinstall: _scriptsinstall
12499343Sru.ORDER: beforeinstall _scriptsinstall
12575284Sru
12675284SruSCRIPTSDIR?=	${BINDIR}
12775284SruSCRIPTSOWN?=	${BINOWN}
12875284SruSCRIPTSGRP?=	${BINGRP}
12975284SruSCRIPTSMODE?=	${BINMODE}
13075284Sru
13175284Sru.for script in ${SCRIPTS}
13275284Sru.if defined(SCRIPTSNAME)
13375284SruSCRIPTSNAME_${script:T}?=	${SCRIPTSNAME}
13475284Sru.else
13575284SruSCRIPTSNAME_${script:T}?=	${script:T:R}
13675284Sru.endif
13775284SruSCRIPTSDIR_${script:T}?=	${SCRIPTSDIR}
13875284SruSCRIPTSOWN_${script:T}?=	${SCRIPTSOWN}
13975284SruSCRIPTSGRP_${script:T}?=	${SCRIPTSGRP}
14075284SruSCRIPTSMODE_${script:T}?=	${SCRIPTSMODE}
14188055Sru_scriptsinstall: _SCRIPTSINS_${script:T}
14288055Sru_SCRIPTSINS_${script:T}: ${script}
143100872Sru	${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
14475284Sru	    -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
14594954Sru	    ${.ALLSRC} \
14675284Sru	    ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
14775284Sru.endfor
14875284Sru.endif
14975284Sru
15099257SruNLSNAME?=	${PROG}
15199257Sru.include <bsd.nls.mk>
15299257Sru
15397769Sru.include <bsd.files.mk>
15496668Sru.include <bsd.incs.mk>
15599256Sru.include <bsd.links.mk>
15696462Sru
15796163Sru.if !defined(NOMAN)
15896164Srurealinstall: _maninstall
15999343Sru.ORDER: beforeinstall _maninstall
16096163Sru.endif
16196163Sru
1621844Swollman.endif
1631638Srgrimes
1641638Srgrimes.if !target(lint)
16595306Srulint: ${SRCS}
1661638Srgrimes.if defined(PROG)
16787307Sbde	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1
1681638Srgrimes.endif
1691638Srgrimes.endif
1701638Srgrimes
17124861Sjkh.if defined(NOTAGS)
17224861Sjkhtags:
17324861Sjkh.endif
17424861Sjkh
1751638Srgrimes.if !target(tags)
17695306Srutags: ${SRCS}
1771638Srgrimes.if defined(PROG)
17834829Seivind	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
17924861Sjkh.if defined(HTML)
18034829Seivind	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
1811638Srgrimes.endif
1821638Srgrimes.endif
18324861Sjkh.endif
1841638Srgrimes
1851638Srgrimes.if !defined(NOMAN)
1861638Srgrimes.include <bsd.man.mk>
18774842Sru.endif
1881844Swollman
18943055Sjdp.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
19028945Speter.include <bsd.libnames.mk>
19128945Speter.endif
19228945Speter
1931844Swollman.include <bsd.dep.mk>
19434081Sbde
19594113Sru.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
19634087Sbde${OBJS}: ${SRCS:M*.h}
19734081Sbde.endif
19834081Sbde
19916663Sjkh.include <bsd.obj.mk>
20076861Skris
20176861Skris.include <bsd.sys.mk>
202