bsd.prog.mk revision 139068
1139826Simp# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 253541Sshin# $FreeBSD: head/share/mk/bsd.prog.mk 139068 2004-12-20 15:46:56Z paul $ 353541Sshin 453541Sshin.include <bsd.init.mk> 553541Sshin 653541Sshin.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm 753541Sshin 853541Sshin# XXX The use of COPTS in modern makefiles is discouraged. 953541Sshin.if defined(COPTS) 1053541SshinCFLAGS+=${COPTS} 1153541Sshin.endif 1253541Sshin 1353541Sshin.if defined(DEBUG_FLAGS) 1453541SshinCFLAGS+=${DEBUG_FLAGS} 1553541Sshin.endif 1653541Sshin 1753541Sshin.if defined(CRUNCH_CFLAGS) 1853541SshinCFLAGS+=${CRUNCH_CFLAGS} 1953541Sshin.endif 2053541Sshin 2153541Sshin.if !defined(DEBUG_FLAGS) 2253541SshinSTRIP?= -s 2353541Sshin.endif 2453541Sshin 2553541Sshin.if defined(NOSHARED) && (${NOSHARED} != "no" && ${NOSHARED} != "NO") 2653541SshinLDFLAGS+= -static 2753541Sshin.endif 28174510Sobrien 29174510Sobrien.if defined(PROG_CXX) 3053541SshinPROG= ${PROG_CXX} 3153541Sshin.endif 32174510Sobrien 33174510Sobrien.if defined(PROG) 34174510Sobrien.if defined(SRCS) 3562587Sitojun 3662587Sitojun# If there are Objective C sources, link with Objective C libraries. 3762587Sitojun.if !empty(SRCS:M*.m) 3853541SshinOBJCLIBS?= -lobjc 3953541SshinLDADD+= ${OBJCLIBS} 4053541Sshin.endif 4153541Sshin 4253541SshinOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 4353541Sshin 4453541Sshin${PROG}: ${OBJS} 4578064Sume.if defined(PROG_CXX) 46185751Simp ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 4753541Sshin.else 48185747Skmacy ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 4953541Sshin.endif 5078064Sume 5153541Sshin.else !defined(SRCS) 5253541Sshin 5353541Sshin.if !target(${PROG}) 5453541Sshin.if defined(PROG_CXX) 5553541SshinSRCS= ${PROG}.cc 5653541Sshin.else 57185571SbzSRCS= ${PROG}.c 5853541Sshin.endif 5953541Sshin 60186119Sqingli# Always make an intermediate object file because: 6153541Sshin# - it saves time rebuilding when only the library has changed 6278064Sume# - the name of the object gets put into the executable symbol table instead of 6362587Sitojun# the name of a variable temporary object. 6453541Sshin# - it's useful to keep objects around for crunching. 6553541SshinOBJS= ${PROG}.o 6662587Sitojun 6762587Sitojun${PROG}: ${OBJS} 6853541Sshin.if defined(PROG_CXX) 69175162Sobrien ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 70175162Sobrien.else 71241916Sdelphij ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 72241916Sdelphij.endif 73241916Sdelphij.endif 74241916Sdelphij 75241916Sdelphij.endif 76175162Sobrien 77175162Sobrien.if !defined(NOMAN) && !defined(MAN) && \ 7862587Sitojun !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 79175162Sobrien !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 80175162Sobrien !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 81175162Sobrien !defined(MAN1aout) 8253541SshinMAN= ${PROG}.1 83175162SobrienMAN1= ${MAN} 84241916Sdelphij.endif 85241916Sdelphij.endif 8653541Sshin 87229547Sbzall: objwarn ${PROG} ${SCRIPTS} 88229547Sbz.if !defined(NOMAN) 89229547Sbzall: _manpages 90175162Sobrien.endif 9153541Sshin 92195699Srwatson.if defined(PROG) 93195727SrwatsonCLEANFILES+= ${PROG} 9453541Sshin.endif 95215701Sdim 96207369Sbz.if defined(OBJS) 97195727SrwatsonCLEANFILES+= ${OBJS} 9862587Sitojun.endif 99207369Sbz 100207369Sbz.include <bsd.libnames.mk> 101195699Srwatson 102207369Sbz.if defined(PROG) 103207369Sbz_EXTRADEPEND: 10478064Sume.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) 105207369Sbz.if defined(DPADD) && !empty(DPADD) 106207369Sbz echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 107151539Ssuz.endif 108151539Ssuz.else 109151539Ssuz echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 110151539Ssuz.if defined(PROG_CXX) 111151539Ssuz echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 112151539Ssuz.endif 113151539Ssuz.endif 11478064Sume.endif 11553541Sshin 11653541Sshin.if !target(install) 11753541Sshin 11853541Sshin.if defined(PRECIOUSPROG) 11953541Sshin.if !defined(NOFSCHG) 12053541SshinINSTALLFLAGS+= -fschg 12153541Sshin.endif 122171259SdelphijINSTALLFLAGS+= -S 12353541Sshin.endif 12453541Sshin 12553541Sshin_INSTALLFLAGS:= ${INSTALLFLAGS} 12662587Sitojun.for ie in ${INSTALLFLAGS_EDIT} 12753541Sshin_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 12853541Sshin.endfor 12953541Sshin 13053541Sshin.if !target(realinstall) && !defined(INTERNALPROG) 131165118Sbzrealinstall: _proginstall 13253541Sshin.ORDER: beforeinstall _proginstall 133222728Shrs_proginstall: 134222728Shrs.if defined(PROG) 135222728Shrs.if defined(PROGNAME) 136222728Shrs ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 137222728Shrs ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 13862587Sitojun.else 13953541Sshin ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 14053541Sshin ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 14153541Sshin.endif 14278064Sume.endif 14378064Sume.endif !target(realinstall) 144165118Sbz 145165118Sbz.if defined(SCRIPTS) && !empty(SCRIPTS) 14678064Sumerealinstall: _scriptsinstall 14753541Sshin.ORDER: beforeinstall _scriptsinstall 14853541Sshin 14953541SshinSCRIPTSDIR?= ${BINDIR} 15053541SshinSCRIPTSOWN?= ${BINOWN} 15153541SshinSCRIPTSGRP?= ${BINGRP} 15253541SshinSCRIPTSMODE?= ${BINMODE} 15353541Sshin 15462587Sitojun.for script in ${SCRIPTS} 15562587Sitojun.if defined(SCRIPTSNAME) 15662587SitojunSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 15762587Sitojun.else 15862587SitojunSCRIPTSNAME_${script:T}?= ${script:T:R} 15962587Sitojun.endif 16062587SitojunSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 16162587SitojunSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 162190964SrwatsonSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 16353541SshinSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 16462587Sitojun_scriptsinstall: _SCRIPTSINS_${script:T} 16562587Sitojun_SCRIPTSINS_${script:T}: ${script} 16653541Sshin ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 16753541Sshin -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 16853541Sshin ${.ALLSRC} \ 16953541Sshin ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 17078064Sume.endfor 17178064Sume.endif 17278064Sume 17362587SitojunNLSNAME?= ${PROG} 17453541Sshin.include <bsd.nls.mk> 17553541Sshin 17653541Sshin.include <bsd.files.mk> 17753541Sshin.include <bsd.incs.mk> 17853541Sshin.include <bsd.links.mk> 17953541Sshin 18053541Sshin.if !defined(NOMAN) 18153541Sshinrealinstall: _maninstall 18278064Sume.ORDER: beforeinstall _maninstall 18353541Sshin.endif 18453541Sshin 185165118Sbz.endif 186120941Sume 18778064Sume.if !target(lint) 18853541Sshinlint: ${SRCS:M*.c} 18953541Sshin.if defined(PROG) 19053541Sshin ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 19162587Sitojun.endif 19262587Sitojun.endif 19362587Sitojun 19478064Sume.if !defined(NOMAN) 19578064Sume.include <bsd.man.mk> 19678064Sume.endif 197190964Srwatson 19878064Sume.include <bsd.dep.mk> 19953541Sshin 20053541Sshin.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 20153541Sshin${OBJS}: ${SRCS:M*.h} 20253541Sshin.endif 20353541Sshin 20453541Sshin.include <bsd.obj.mk> 20553541Sshin 20653541Sshin.include <bsd.sys.mk> 20753541Sshin 20853541Sshin.if defined(PORTNAME) 209171259Sdelphij.include <bsd.pkg.mk> 21053541Sshin.endif 21153541Sshin