bsd.prog.mk revision 94954
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
250476Speter# $FreeBSD: head/share/mk/bsd.prog.mk 94954 2002-04-17 16:29:02Z ru $
31638Srgrimes
494940Sru.include <bsd.init.mk>
51638Srgrimes
636673Sdt.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S
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
7688055Sruall: objwarn ${PROG} ${SCRIPTS} ${FILES}
7774806Sru.if !defined(NOMAN)
7888055Sruall: all-man 
7974806Sru.endif
8088055Sruall: _SUBDIR
811638Srgrimes
8233816SbdeCLEANFILES+= ${PROG} ${OBJS}
831638Srgrimes
8455670Sbde.if defined(PROG)
8524750Sbde_EXTRADEPEND:
8638655Sjb.if ${OBJFORMAT} == aout
8794410Sru	echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} \
8825110Sbde	    ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE}
8928945Speter.else
9046541Sbde	echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
9194497Sru.if defined(PROG_CXX)
9294497Sru	echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
9324750Sbde.endif
9428945Speter.endif
9594497Sru.endif
9624750Sbde
971638Srgrimes.if !target(install)
981638Srgrimes.if !target(beforeinstall)
991638Srgrimesbeforeinstall:
1001638Srgrimes.endif
1011638Srgrimes
10249328Shoek_INSTALLFLAGS:=	${INSTALLFLAGS}
10349328Shoek.for ie in ${INSTALLFLAGS_EDIT}
10449328Shoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
10549328Shoek.endfor
10649328Shoek
10716663Sjkhrealinstall: beforeinstall
1081638Srgrimes.if defined(PROG)
10975083Sru.if defined(PROGNAME)
1101844Swollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
11175083Sru	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
11275083Sru.else
11375083Sru	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
11449328Shoek	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
1151638Srgrimes.endif
11675083Sru.endif
1171638Srgrimes.if defined(HIDEGAME)
11878203Sru	(cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \
11978203Sru	    chown -h ${BINOWN}:${ORIGBINGRP} ${PROG})
1201638Srgrimes.endif
1211638Srgrimes.if defined(LINKS) && !empty(LINKS)
1221638Srgrimes	@set ${LINKS}; \
1231638Srgrimes	while test $$# -ge 2; do \
1241638Srgrimes		l=${DESTDIR}$$1; \
1251638Srgrimes		shift; \
1261638Srgrimes		t=${DESTDIR}$$1; \
1271638Srgrimes		shift; \
1282351Sbde		${ECHO} $$t -\> $$l; \
12944946Sbde		ln -f $$l $$t; \
1301638Srgrimes	done; true
1311638Srgrimes.endif
13244946Sbde.if defined(SYMLINKS) && !empty(SYMLINKS)
13344946Sbde	@set ${SYMLINKS}; \
13444946Sbde	while test $$# -ge 2; do \
13544946Sbde		l=$$1; \
13644946Sbde		shift; \
13744946Sbde		t=${DESTDIR}$$1; \
13844946Sbde		shift; \
13944946Sbde		${ECHO} $$t -\> $$l; \
14044946Sbde		ln -fs $$l $$t; \
14144946Sbde	done; true
14244946Sbde.endif
1431638Srgrimes
14475284Sru.if defined(SCRIPTS) && !empty(SCRIPTS)
14575284Srurealinstall: _scriptsinstall
14675284Sru
14775284SruSCRIPTSDIR?=	${BINDIR}
14875284SruSCRIPTSOWN?=	${BINOWN}
14975284SruSCRIPTSGRP?=	${BINGRP}
15075284SruSCRIPTSMODE?=	${BINMODE}
15175284Sru
15275284Sru.for script in ${SCRIPTS}
15375284Sru.if defined(SCRIPTSNAME)
15475284SruSCRIPTSNAME_${script:T}?=	${SCRIPTSNAME}
15575284Sru.else
15675284SruSCRIPTSNAME_${script:T}?=	${script:T:R}
15775284Sru.endif
15875284SruSCRIPTSDIR_${script:T}?=	${SCRIPTSDIR}
15975284SruSCRIPTSOWN_${script:T}?=	${SCRIPTSOWN}
16075284SruSCRIPTSGRP_${script:T}?=	${SCRIPTSGRP}
16175284SruSCRIPTSMODE_${script:T}?=	${SCRIPTSMODE}
16288055Sru_scriptsinstall: _SCRIPTSINS_${script:T}
16388055Sru_SCRIPTSINS_${script:T}: ${script}
16475284Sru	${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
16575284Sru	    -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
16694954Sru	    ${.ALLSRC} \
16775284Sru	    ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
16875284Sru.endfor
16975284Sru.endif
17075284Sru
17188055Sru.if defined(FILES) && !empty(FILES)
17288055Srurealinstall: _filesinstall
17388055Sru
17488055SruFILESDIR?=	${BINDIR}
17588055SruFILESOWN?=	${SHAREOWN}
17688055SruFILESGRP?=	${SHAREGRP}
17788055SruFILESMODE?=	${SHAREMODE}
17888055Sru
17988055Sru.for file in ${FILES}
18088055Sru.if defined(FILESNAME)
18188055SruFILESNAME_${file:T}?=	${FILESNAME}
18288055Sru.else
18388055SruFILESNAME_${file:T}?=	${file:T}
18488055Sru.endif
18588055SruFILESDIR_${file:T}?=	${FILESDIR}
18688055SruFILESOWN_${file:T}?=	${FILESOWN}
18788055SruFILESGRP_${file:T}?=	${FILESGRP}
18888055SruFILESMODE_${file:T}?=	${FILESMODE}
18988055Sru_filesinstall: _FILESINS_${file:T}
19088055Sru_FILESINS_${file:T}: ${file}
19188055Sru	${INSTALL} ${COPY} -o ${FILESOWN_${.ALLSRC:T}} \
19288055Sru	    -g ${FILESGRP_${.ALLSRC:T}} -m ${FILESMODE_${.ALLSRC:T}} \
19394954Sru	    ${.ALLSRC} \
19488055Sru	    ${DESTDIR}${FILESDIR_${.ALLSRC:T}}/${FILESNAME_${.ALLSRC:T}}
19588055Sru.endfor
19688055Sru.endif
19788055Sru
19816663Sjkhinstall: afterinstall _SUBDIR
1991844Swollman.if !defined(NOMAN)
2001844Swollmanafterinstall: realinstall maninstall
2011844Swollman.else
2021638Srgrimesafterinstall: realinstall
2031844Swollman.endif
2041638Srgrimes.endif
2051638Srgrimes
2065585SjkhDISTRIBUTION?=	bin
2074442Sphk.if !target(distribute)
20816663Sjkhdistribute: _SUBDIR
20926760Sjkh.for dist in ${DISTRIBUTION}
21026760Sjkh	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
21126760Sjkh.endfor
2124442Sphk.endif
2134442Sphk
2141638Srgrimes.if !target(lint)
21516663Sjkhlint: ${SRCS} _SUBDIR
2161638Srgrimes.if defined(PROG)
21787307Sbde	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1
2181638Srgrimes.endif
2191638Srgrimes.endif
2201638Srgrimes
22124861Sjkh.if defined(NOTAGS)
22224861Sjkhtags:
22324861Sjkh.endif
22424861Sjkh
2251638Srgrimes.if !target(tags)
22616663Sjkhtags: ${SRCS} _SUBDIR
2271638Srgrimes.if defined(PROG)
22834829Seivind	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
22924861Sjkh.if defined(HTML)
23034829Seivind	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
2311638Srgrimes.endif
2321638Srgrimes.endif
23324861Sjkh.endif
2341638Srgrimes
2351638Srgrimes.if !defined(NOMAN)
2361638Srgrimes.include <bsd.man.mk>
23774842Sru.else
23874842Sru.if !target(all-man)
23974842Sruall-man:
24074842Sru.endif
24174842Sru.if !target(maninstall)
2421638Srgrimesmaninstall:
2431638Srgrimes.endif
24474842Sru.endif
2451844Swollman
24634528Seivind.if !target(regress)
24734528Seivindregress:
24834528Seivind.endif
24934528Seivind
25043055Sjdp.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
25128945Speter.include <bsd.libnames.mk>
25228945Speter.endif
25328945Speter
2541844Swollman.include <bsd.dep.mk>
25534081Sbde
25694113Sru.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
25734087Sbde${OBJS}: ${SRCS:M*.h}
25834081Sbde.endif
25934081Sbde
26016663Sjkh.include <bsd.obj.mk>
26176861Skris
26276861Skris.include <bsd.sys.mk>
263