bsd.prog.mk revision 94497
11844Swollman#	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
250476Speter# $FreeBSD: head/share/mk/bsd.prog.mk 94497 2002-04-12 08:17:24Z 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}
141638Srgrimes
152827Sjkh.if !defined(DEBUG_FLAGS)
161638SrgrimesSTRIP?=	-s
172827Sjkh.endif
181638Srgrimes
1927028Spst.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" )
201844SwollmanLDFLAGS+= -static
211844Swollman.endif
221638Srgrimes
2394424Sru.if defined(PROG_CXX)
2494424SruPROG=	${PROG_CXX}
2594424Sru.endif
2694424Sru
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
388321Sbde.else !defined(SRCS)
391844Swollman
4033624Seivind.if !target(${PROG})
4194424Sru.if defined(PROG_CXX)
4294424SruSRCS=	${PROG}.cc
4394424Sru.else
442351SbdeSRCS=	${PROG}.c
4594424Sru.endif
461638Srgrimes
472351Sbde# Always make an intermediate object file because:
482351Sbde# - it saves time rebuilding when only the library has changed
492351Sbde# - the name of the object gets put into the executable symbol table instead of
502351Sbde#   the name of a variable temporary object.
512351Sbde# - it's useful to keep objects around for crunching.
522351SbdeOBJS=	${PROG}.o
5394497Sru.endif
5433624Seivind
5534081Sbde${PROG}: ${OBJS}
5694497Sru.if defined(PROG_CXX)
5794497Sru	${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
5894497Sru.else
5994410Sru	${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
6033624Seivind.endif
611638Srgrimes
621638Srgrimes.endif
631638Srgrimes
6474806Sru.if	!defined(NOMAN) && !defined(MAN) && \
6574806Sru	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
661638Srgrimes	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
6758493Sru	!defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \
6874806Sru	!defined(MAN1aout)
6974941SruMAN=	${PROG}.1
7074941SruMAN1=	${MAN}
711638Srgrimes.endif
721638Srgrimes.endif
731638Srgrimes
741638Srgrimes.MAIN: all
7588055Sruall: objwarn ${PROG} ${SCRIPTS} ${FILES}
7674806Sru.if !defined(NOMAN)
7788055Sruall: all-man 
7874806Sru.endif
7988055Sruall: _SUBDIR
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.if !target(beforeinstall)
981638Srgrimesbeforeinstall:
991638Srgrimes.endif
1001638Srgrimes
10149328Shoek_INSTALLFLAGS:=	${INSTALLFLAGS}
10249328Shoek.for ie in ${INSTALLFLAGS_EDIT}
10349328Shoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
10449328Shoek.endfor
10549328Shoek
10616663Sjkhrealinstall: beforeinstall
1071638Srgrimes.if defined(PROG)
10875083Sru.if defined(PROGNAME)
1091844Swollman	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
11075083Sru	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
11175083Sru.else
11275083Sru	${INSTALL} ${COPY} ${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
1201638Srgrimes.if defined(LINKS) && !empty(LINKS)
1211638Srgrimes	@set ${LINKS}; \
1221638Srgrimes	while test $$# -ge 2; do \
1231638Srgrimes		l=${DESTDIR}$$1; \
1241638Srgrimes		shift; \
1251638Srgrimes		t=${DESTDIR}$$1; \
1261638Srgrimes		shift; \
1272351Sbde		${ECHO} $$t -\> $$l; \
12844946Sbde		ln -f $$l $$t; \
1291638Srgrimes	done; true
1301638Srgrimes.endif
13144946Sbde.if defined(SYMLINKS) && !empty(SYMLINKS)
13244946Sbde	@set ${SYMLINKS}; \
13344946Sbde	while test $$# -ge 2; do \
13444946Sbde		l=$$1; \
13544946Sbde		shift; \
13644946Sbde		t=${DESTDIR}$$1; \
13744946Sbde		shift; \
13844946Sbde		${ECHO} $$t -\> $$l; \
13944946Sbde		ln -fs $$l $$t; \
14044946Sbde	done; true
14144946Sbde.endif
1421638Srgrimes
14375284Sru.if defined(SCRIPTS) && !empty(SCRIPTS)
14475284Srurealinstall: _scriptsinstall
14575284Sru
14675284SruSCRIPTSDIR?=	${BINDIR}
14775284SruSCRIPTSOWN?=	${BINOWN}
14875284SruSCRIPTSGRP?=	${BINGRP}
14975284SruSCRIPTSMODE?=	${BINMODE}
15075284Sru
15175284Sru.for script in ${SCRIPTS}
15275284Sru.if defined(SCRIPTSNAME)
15375284SruSCRIPTSNAME_${script:T}?=	${SCRIPTSNAME}
15475284Sru.else
15575284SruSCRIPTSNAME_${script:T}?=	${script:T:R}
15675284Sru.endif
15775284SruSCRIPTSDIR_${script:T}?=	${SCRIPTSDIR}
15875284SruSCRIPTSOWN_${script:T}?=	${SCRIPTSOWN}
15975284SruSCRIPTSGRP_${script:T}?=	${SCRIPTSGRP}
16075284SruSCRIPTSMODE_${script:T}?=	${SCRIPTSMODE}
16188055Sru_scriptsinstall: _SCRIPTSINS_${script:T}
16288055Sru_SCRIPTSINS_${script:T}: ${script}
16375284Sru	${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
16475284Sru	    -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
16575284Sru	    ${_INSTALLFLAGS} ${.ALLSRC} \
16675284Sru	    ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}}
16775284Sru.endfor
16875284Sru.endif
16975284Sru
17088055Sru.if defined(FILES) && !empty(FILES)
17188055Srurealinstall: _filesinstall
17288055Sru
17388055SruFILESDIR?=	${BINDIR}
17488055SruFILESOWN?=	${SHAREOWN}
17588055SruFILESGRP?=	${SHAREGRP}
17688055SruFILESMODE?=	${SHAREMODE}
17788055Sru
17888055Sru.for file in ${FILES}
17988055Sru.if defined(FILESNAME)
18088055SruFILESNAME_${file:T}?=	${FILESNAME}
18188055Sru.else
18288055SruFILESNAME_${file:T}?=	${file:T}
18388055Sru.endif
18488055SruFILESDIR_${file:T}?=	${FILESDIR}
18588055SruFILESOWN_${file:T}?=	${FILESOWN}
18688055SruFILESGRP_${file:T}?=	${FILESGRP}
18788055SruFILESMODE_${file:T}?=	${FILESMODE}
18888055Sru_filesinstall: _FILESINS_${file:T}
18988055Sru_FILESINS_${file:T}: ${file}
19088055Sru	${INSTALL} ${COPY} -o ${FILESOWN_${.ALLSRC:T}} \
19188055Sru	    -g ${FILESGRP_${.ALLSRC:T}} -m ${FILESMODE_${.ALLSRC:T}} \
19288055Sru	    ${_INSTALLFLAGS} ${.ALLSRC} \
19388055Sru	    ${DESTDIR}${FILESDIR_${.ALLSRC:T}}/${FILESNAME_${.ALLSRC:T}}
19488055Sru.endfor
19588055Sru.endif
19688055Sru
19716663Sjkhinstall: afterinstall _SUBDIR
1981844Swollman.if !defined(NOMAN)
1991844Swollmanafterinstall: realinstall maninstall
2001844Swollman.else
2011638Srgrimesafterinstall: realinstall
2021844Swollman.endif
2031638Srgrimes.endif
2041638Srgrimes
2055585SjkhDISTRIBUTION?=	bin
2064442Sphk.if !target(distribute)
20716663Sjkhdistribute: _SUBDIR
20826760Sjkh.for dist in ${DISTRIBUTION}
20926760Sjkh	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
21026760Sjkh.endfor
2114442Sphk.endif
2124442Sphk
2131638Srgrimes.if !target(lint)
21416663Sjkhlint: ${SRCS} _SUBDIR
2151638Srgrimes.if defined(PROG)
21687307Sbde	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1
2171638Srgrimes.endif
2181638Srgrimes.endif
2191638Srgrimes
22024861Sjkh.if defined(NOTAGS)
22124861Sjkhtags:
22224861Sjkh.endif
22324861Sjkh
2241638Srgrimes.if !target(tags)
22516663Sjkhtags: ${SRCS} _SUBDIR
2261638Srgrimes.if defined(PROG)
22734829Seivind	@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
22824861Sjkh.if defined(HTML)
22934829Seivind	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
2301638Srgrimes.endif
2311638Srgrimes.endif
23224861Sjkh.endif
2331638Srgrimes
2341638Srgrimes.if !defined(NOMAN)
2351638Srgrimes.include <bsd.man.mk>
23674842Sru.else
23774842Sru.if !target(all-man)
23874842Sruall-man:
23974842Sru.endif
24074842Sru.if !target(maninstall)
2411638Srgrimesmaninstall:
2421638Srgrimes.endif
24374842Sru.endif
2441844Swollman
24534528Seivind.if !target(regress)
24634528Seivindregress:
24734528Seivind.endif
24834528Seivind
24943055Sjdp.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES)
25028945Speter.include <bsd.libnames.mk>
25128945Speter.endif
25228945Speter
2531844Swollman.include <bsd.dep.mk>
25434081Sbde
25594113Sru.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
25634087Sbde${OBJS}: ${SRCS:M*.h}
25734081Sbde.endif
25834081Sbde
25916663Sjkh.include <bsd.obj.mk>
26076861Skris
26176861Skris.include <bsd.sys.mk>
262