13585b293SGarrett Wollman# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 27f3dea24SPeter Wemm# $FreeBSD$ 3afe61c15SRodney W. Grimes 42bdaf7e8SRuslan Ermilov.include <bsd.init.mk> 5afe61c15SRodney W. Grimes 65741a42fSMark Murray.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm 7afe61c15SRodney W. Grimes 848aea4daSRuslan Ermilov# XXX The use of COPTS in modern makefiles is discouraged. 941f89315SRuslan Ermilov.if defined(COPTS) 1041f89315SRuslan ErmilovCFLAGS+=${COPTS} 1141f89315SRuslan Ermilov.endif 1241f89315SRuslan Ermilov 134df1f59eSWarner Losh.if ${MK_ASSERT_DEBUG} == "no" 144df1f59eSWarner LoshCFLAGS+= -DNDEBUG 15e2e1ab1cSDavid E. O'BrienNO_WERROR= 164df1f59eSWarner Losh.endif 174df1f59eSWarner Losh 1841f89315SRuslan Ermilov.if defined(DEBUG_FLAGS) 1941f89315SRuslan ErmilovCFLAGS+=${DEBUG_FLAGS} 20770ac3b2SJohn Birrell 21770ac3b2SJohn Birrell.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") 22770ac3b2SJohn BirrellCTFFLAGS+= -g 23770ac3b2SJohn Birrell.endif 2441f89315SRuslan Ermilov.endif 2541f89315SRuslan Ermilov 2641f89315SRuslan Ermilov.if defined(CRUNCH_CFLAGS) 273c9b8563SGordon TetlowCFLAGS+=${CRUNCH_CFLAGS} 2841f89315SRuslan Ermilov.endif 29afe61c15SRodney W. Grimes 30e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 31afe61c15SRodney W. GrimesSTRIP?= -s 32e82b0b99SJordan K. Hubbard.endif 33afe61c15SRodney W. Grimes 3483c7ade9SRuslan Ermilov.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") 353585b293SGarrett WollmanLDFLAGS+= -static 363585b293SGarrett Wollman.endif 37afe61c15SRodney W. Grimes 3847bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 3947bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 4047bf8a5cSRuslan Ermilov.endif 4147bf8a5cSRuslan Ermilov 42afe61c15SRodney W. Grimes.if defined(PROG) 43afe61c15SRodney W. Grimes.if defined(SRCS) 44afe61c15SRodney W. Grimes 4570a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 4665d2bdc6SRuslan Ermilov.if !empty(SRCS:M*.m) 4771ce49aeSRuslan Ermilov.if defined(OBJCLIBS) 4870a6e331SBruce EvansLDADD+= ${OBJCLIBS} 4971ce49aeSRuslan Ermilov.else 5071ce49aeSRuslan ErmilovDPADD+= ${LIBOBJC} ${LIBPTHREAD} 5171ce49aeSRuslan ErmilovLDADD+= -lobjc -lpthread 5271ce49aeSRuslan Ermilov.endif 5370a6e331SBruce Evans.endif 5470a6e331SBruce Evans 553585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 56afe61c15SRodney W. Grimes 575d68012aSRuslan Ermilov${PROG}: ${OBJS} 585d68012aSRuslan Ermilov.if defined(PROG_CXX) 595d68012aSRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 605d68012aSRuslan Ermilov.else 615d68012aSRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 625d68012aSRuslan Ermilov.endif 63770ac3b2SJohn Birrell.if defined(CTFMERGE) 64770ac3b2SJohn Birrell ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} 65770ac3b2SJohn Birrell.endif 665d68012aSRuslan Ermilov 6784aac273SHartmut Brandt.else # !defined(SRCS) 68afe61c15SRodney W. Grimes 695d68012aSRuslan Ermilov.if !target(${PROG}) 7047bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 7147bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 7247bf8a5cSRuslan Ermilov.else 73afe61c15SRodney W. GrimesSRCS= ${PROG}.c 7447bf8a5cSRuslan Ermilov.endif 75afe61c15SRodney W. Grimes 76a4c39c7aSBruce Evans# Always make an intermediate object file because: 77a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 78a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 79a4c39c7aSBruce Evans# the name of a variable temporary object. 80a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 81a4c39c7aSBruce EvansOBJS= ${PROG}.o 82f5c75051SEivind Eklund 83987afe2aSBruce Evans${PROG}: ${OBJS} 84f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 85f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 86f8ba1555SRuslan Ermilov.else 87de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 88afe61c15SRodney W. Grimes.endif 89770ac3b2SJohn Birrell.if defined(CTFMERGE) 90770ac3b2SJohn Birrell ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} 91770ac3b2SJohn Birrell.endif 925d68012aSRuslan Ermilov.endif 93f5c75051SEivind Eklund 946fe6af9fSEivind Eklund.endif 95afe61c15SRodney W. Grimes 96e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" && !defined(MAN) && \ 97862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 98afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 99500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 100862d3deaSRuslan Ermilov !defined(MAN1aout) 10119ea15a1SRuslan ErmilovMAN= ${PROG}.1 10219ea15a1SRuslan ErmilovMAN1= ${MAN} 103afe61c15SRodney W. Grimes.endif 104afe61c15SRodney W. Grimes.endif 105afe61c15SRodney W. Grimes 106af2dc868SRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} 107e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" 108afeaaa84SRuslan Ermilovall: _manpages 109862d3deaSRuslan Ermilov.endif 110afe61c15SRodney W. Grimes 11141f89315SRuslan Ermilov.if defined(PROG) 11241f89315SRuslan ErmilovCLEANFILES+= ${PROG} 11341f89315SRuslan Ermilov.endif 11441f89315SRuslan Ermilov 11541f89315SRuslan Ermilov.if defined(OBJS) 11641f89315SRuslan ErmilovCLEANFILES+= ${OBJS} 11741f89315SRuslan Ermilov.endif 118afe61c15SRodney W. Grimes 11951fa76c4SRuslan Ermilov.include <bsd.libnames.mk> 12051fa76c4SRuslan Ermilov 121218a2cd2SBruce Evans.if defined(PROG) 122663e9677SBruce Evans_EXTRADEPEND: 12351fa76c4SRuslan Ermilov.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) 12451fa76c4SRuslan Ermilov.if defined(DPADD) && !empty(DPADD) 12551fa76c4SRuslan Ermilov echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 12651fa76c4SRuslan Ermilov.endif 12751fa76c4SRuslan Ermilov.else 1286e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 129f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 130f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 131f8ba1555SRuslan Ermilov.endif 1328c05a446SPeter Wemm.endif 13351fa76c4SRuslan Ermilov.endif 134663e9677SBruce Evans 135afe61c15SRodney W. Grimes.if !target(install) 136afe61c15SRodney W. Grimes 137212acbefSRuslan Ermilov.if defined(PRECIOUSPROG) 13800fbd407SRuslan Ermilov.if !defined(NO_FSCHG) 139dee651ebSRuslan ErmilovINSTALLFLAGS+= -fschg 140dee651ebSRuslan Ermilov.endif 141212acbefSRuslan ErmilovINSTALLFLAGS+= -S 142212acbefSRuslan Ermilov.endif 143dee651ebSRuslan Ermilov 144e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 145e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 146e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 147e902c1bbSTim Vanderhoek.endfor 148e902c1bbSTim Vanderhoek 14951fa76c4SRuslan Ermilov.if !target(realinstall) && !defined(INTERNALPROG) 15087829387SRuslan Ermilovrealinstall: _proginstall 151badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 15287829387SRuslan Ermilov_proginstall: 153afe61c15SRodney W. Grimes.if defined(PROG) 15495f8c826SRuslan Ermilov.if defined(PROGNAME) 155d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 15695f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 15795f8c826SRuslan Ermilov.else 158d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 159e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 160afe61c15SRodney W. Grimes.endif 16195f8c826SRuslan Ermilov.endif 16284aac273SHartmut Brandt.endif # !target(realinstall) 163afe61c15SRodney W. Grimes 164f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 165f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 166badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 167f7ee8cfeSRuslan Ermilov 168f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 169f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 170f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 171f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 172f7ee8cfeSRuslan Ermilov 173f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 174f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 175f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 176f7ee8cfeSRuslan Ermilov.else 177f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 178f7ee8cfeSRuslan Ermilov.endif 179f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 180f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 181f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 182f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 183a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 184a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 185d2893b16SRuslan Ermilov ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 186f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1874367bda6SRuslan Ermilov ${.ALLSRC} \ 188f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 189f7ee8cfeSRuslan Ermilov.endfor 190f7ee8cfeSRuslan Ermilov.endif 191f7ee8cfeSRuslan Ermilov 1928479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1938479adc1SRuslan Ermilov.include <bsd.nls.mk> 1948479adc1SRuslan Ermilov 195af2dc868SRuslan Ermilov.include <bsd.files.mk> 1965d862037SRuslan Ermilov.include <bsd.incs.mk> 19784f94a79SRuslan Ermilov.include <bsd.links.mk> 198c7b111cbSRuslan Ermilov 199e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" 200afeaaa84SRuslan Ermilovrealinstall: _maninstall 201badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 20287829387SRuslan Ermilov.endif 20387829387SRuslan Ermilov 204afe61c15SRodney W. Grimes.endif 205afe61c15SRodney W. Grimes 206afe61c15SRodney W. Grimes.if !target(lint) 2075741a42fSMark Murraylint: ${SRCS:M*.c} 208afe61c15SRodney W. Grimes.if defined(PROG) 2095741a42fSMark Murray ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 210afe61c15SRodney W. Grimes.endif 211afe61c15SRodney W. Grimes.endif 212afe61c15SRodney W. Grimes 213e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" 214afe61c15SRodney W. Grimes.include <bsd.man.mk> 21569b87d3eSEivind Eklund.endif 21669b87d3eSEivind Eklund 2173585b293SGarrett Wollman.include <bsd.dep.mk> 218987afe2aSBruce Evans 21988505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 220589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 221987afe2aSBruce Evans.endif 222987afe2aSBruce Evans 223cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 224d510ecb4SKris Kennaway 225d510ecb4SKris Kennaway.include <bsd.sys.mk> 22657e3ff64SPaul Richards 22757e3ff64SPaul Richards.if defined(PORTNAME) 22857e3ff64SPaul Richards.include <bsd.pkg.mk> 22957e3ff64SPaul Richards.endif 230