bsd.prog.mk revision 75284
11844Swollman# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 250476Speter# $FreeBSD: head/share/mk/bsd.prog.mk 75284 2001-04-07 11:13:46Z 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) 6474941SruMAN= ${PROG}.1 6574941SruMAN1= ${MAN} 661638Srgrimes.endif 671638Srgrimes.endif 681638Srgrimes 691638Srgrimes.MAIN: all 7074806Sru.if !defined(NOMAN) 7175284Sruall: objwarn ${PROG} ${SCRIPTS} all-man _SUBDIR 7274806Sru.else 7375284Sruall: objwarn ${PROG} ${SCRIPTS} _SUBDIR 7474806Sru.endif 751638Srgrimes 7633816SbdeCLEANFILES+= ${PROG} ${OBJS} 771638Srgrimes 7855670Sbde.if defined(PROG) 7924750Sbde_EXTRADEPEND: 8038655Sjb.if ${OBJFORMAT} == aout 8124750Sbde echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 8225110Sbde ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 8328945Speter.else 8446541Sbde echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 8524750Sbde.endif 8628945Speter.endif 8724750Sbde 881638Srgrimes.if !target(install) 891638Srgrimes.if !target(beforeinstall) 901638Srgrimesbeforeinstall: 911638Srgrimes.endif 921638Srgrimes 9349328Shoek_INSTALLFLAGS:= ${INSTALLFLAGS} 9449328Shoek.for ie in ${INSTALLFLAGS_EDIT} 9549328Shoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 9649328Shoek.endfor 9749328Shoek 9816663Sjkhrealinstall: beforeinstall 991638Srgrimes.if defined(PROG) 10075083Sru.if defined(PROGNAME) 1011844Swollman ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 10275083Sru ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 10375083Sru.else 10475083Sru ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 10549328Shoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 1061638Srgrimes.endif 10775083Sru.endif 1081638Srgrimes.if defined(HIDEGAME) 10940505Sobrien (cd ${DESTDIR}/${GBINDIR}; rm -f ${PROG}; ln -s dm ${PROG}; \ 11023542Sbde chown games:bin ${PROG}) 1111638Srgrimes.endif 1121638Srgrimes.if defined(LINKS) && !empty(LINKS) 1131638Srgrimes @set ${LINKS}; \ 1141638Srgrimes while test $$# -ge 2; do \ 1151638Srgrimes l=${DESTDIR}$$1; \ 1161638Srgrimes shift; \ 1171638Srgrimes t=${DESTDIR}$$1; \ 1181638Srgrimes shift; \ 1192351Sbde ${ECHO} $$t -\> $$l; \ 12044946Sbde ln -f $$l $$t; \ 1211638Srgrimes done; true 1221638Srgrimes.endif 12344946Sbde.if defined(SYMLINKS) && !empty(SYMLINKS) 12444946Sbde @set ${SYMLINKS}; \ 12544946Sbde while test $$# -ge 2; do \ 12644946Sbde l=$$1; \ 12744946Sbde shift; \ 12844946Sbde t=${DESTDIR}$$1; \ 12944946Sbde shift; \ 13044946Sbde ${ECHO} $$t -\> $$l; \ 13144946Sbde ln -fs $$l $$t; \ 13244946Sbde done; true 13344946Sbde.endif 1341638Srgrimes 13575284Sru.if defined(SCRIPTS) && !empty(SCRIPTS) 13675284Srurealinstall: _scriptsinstall 13775284Sru 13875284SruSCRIPTSDIR?= ${BINDIR} 13975284SruSCRIPTSOWN?= ${BINOWN} 14075284SruSCRIPTSGRP?= ${BINGRP} 14175284SruSCRIPTSMODE?= ${BINMODE} 14275284Sru 14375284Sru.for script in ${SCRIPTS} 14475284Sru.if defined(SCRIPTSNAME) 14575284SruSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 14675284Sru.else 14775284SruSCRIPTSNAME_${script:T}?= ${script:T:R} 14875284Sru.endif 14975284SruSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 15075284SruSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 15175284SruSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 15275284SruSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 15375284Sru_scriptsinstall: SCRIPTSINS_${script:T} 15475284SruSCRIPTSINS_${script:T}: ${script} 15575284Sru ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 15675284Sru -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 15775284Sru ${_INSTALLFLAGS} ${.ALLSRC} \ 15875284Sru ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 15975284Sru.endfor 16075284Sru.endif 16175284Sru 16216663Sjkhinstall: afterinstall _SUBDIR 1631844Swollman.if !defined(NOMAN) 1641844Swollmanafterinstall: realinstall maninstall 1651844Swollman.else 1661638Srgrimesafterinstall: realinstall 1671844Swollman.endif 1681638Srgrimes.endif 1691638Srgrimes 1705585SjkhDISTRIBUTION?= bin 1714442Sphk.if !target(distribute) 17216663Sjkhdistribute: _SUBDIR 17326760Sjkh.for dist in ${DISTRIBUTION} 17426760Sjkh cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 17526760Sjkh.endfor 1764442Sphk.endif 1774442Sphk 1781638Srgrimes.if !target(lint) 17916663Sjkhlint: ${SRCS} _SUBDIR 1801638Srgrimes.if defined(PROG) 1811638Srgrimes @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 1821638Srgrimes.endif 1831638Srgrimes.endif 1841638Srgrimes 18524861Sjkh.if defined(NOTAGS) 18624861Sjkhtags: 18724861Sjkh.endif 18824861Sjkh 1891638Srgrimes.if !target(tags) 19016663Sjkhtags: ${SRCS} _SUBDIR 1911638Srgrimes.if defined(PROG) 19234829Seivind @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 19324861Sjkh.if defined(HTML) 19434829Seivind @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 1951638Srgrimes.endif 1961638Srgrimes.endif 19724861Sjkh.endif 1981638Srgrimes 1991638Srgrimes.if !defined(NOMAN) 2001638Srgrimes.include <bsd.man.mk> 20174842Sru.else 20274842Sru.if !target(all-man) 20374842Sruall-man: 20474842Sru.endif 20574842Sru.if !target(maninstall) 2061638Srgrimesmaninstall: 2071638Srgrimes.endif 20874842Sru.endif 2091844Swollman 21034528Seivind.if !target(regress) 21134528Seivindregress: 21234528Seivind.endif 21334528Seivind 21443055Sjdp.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 21528945Speter.include <bsd.libnames.mk> 21628945Speter.endif 21728945Speter 2181844Swollman.include <bsd.dep.mk> 21934081Sbde 22034081Sbde.if defined(PROG) && !exists(${DEPENDFILE}) 22134087Sbde${OBJS}: ${SRCS:M*.h} 22234081Sbde.endif 22334081Sbde 22416663Sjkh.include <bsd.obj.mk> 225