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} 208eba8cd8SMarcel MoolenaarCXXFLAGS+=${DEBUG_FLAGS} 21770ac3b2SJohn Birrell 22770ac3b2SJohn Birrell.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") 23770ac3b2SJohn BirrellCTFFLAGS+= -g 24770ac3b2SJohn Birrell.endif 2541f89315SRuslan Ermilov.endif 2641f89315SRuslan Ermilov 2741f89315SRuslan Ermilov.if defined(CRUNCH_CFLAGS) 283c9b8563SGordon TetlowCFLAGS+=${CRUNCH_CFLAGS} 2941f89315SRuslan Ermilov.endif 30afe61c15SRodney W. Grimes 31e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 32afe61c15SRodney W. GrimesSTRIP?= -s 33e82b0b99SJordan K. Hubbard.endif 34afe61c15SRodney W. Grimes 3583c7ade9SRuslan Ermilov.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") 363585b293SGarrett WollmanLDFLAGS+= -static 373585b293SGarrett Wollman.endif 38afe61c15SRodney W. Grimes 3947bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 4047bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 4147bf8a5cSRuslan Ermilov.endif 4247bf8a5cSRuslan Ermilov 43afe61c15SRodney W. Grimes.if defined(PROG) 44afe61c15SRodney W. Grimes.if defined(SRCS) 45afe61c15SRodney W. Grimes 4670a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 4765d2bdc6SRuslan Ermilov.if !empty(SRCS:M*.m) 4871ce49aeSRuslan Ermilov.if defined(OBJCLIBS) 4970a6e331SBruce EvansLDADD+= ${OBJCLIBS} 5071ce49aeSRuslan Ermilov.else 5171ce49aeSRuslan ErmilovDPADD+= ${LIBOBJC} ${LIBPTHREAD} 5271ce49aeSRuslan ErmilovLDADD+= -lobjc -lpthread 5371ce49aeSRuslan Ermilov.endif 5470a6e331SBruce Evans.endif 5570a6e331SBruce Evans 563585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 57afe61c15SRodney W. Grimes 585d68012aSRuslan Ermilov${PROG}: ${OBJS} 595d68012aSRuslan Ermilov.if defined(PROG_CXX) 605d68012aSRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 615d68012aSRuslan Ermilov.else 625d68012aSRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 635d68012aSRuslan Ermilov.endif 64770ac3b2SJohn Birrell.if defined(CTFMERGE) 65770ac3b2SJohn Birrell ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} 66770ac3b2SJohn Birrell.endif 675d68012aSRuslan Ermilov 6884aac273SHartmut Brandt.else # !defined(SRCS) 69afe61c15SRodney W. Grimes 705d68012aSRuslan Ermilov.if !target(${PROG}) 7147bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 7247bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 7347bf8a5cSRuslan Ermilov.else 74afe61c15SRodney W. GrimesSRCS= ${PROG}.c 7547bf8a5cSRuslan Ermilov.endif 76afe61c15SRodney W. Grimes 77a4c39c7aSBruce Evans# Always make an intermediate object file because: 78a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 79a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 80a4c39c7aSBruce Evans# the name of a variable temporary object. 81a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 82a4c39c7aSBruce EvansOBJS= ${PROG}.o 83f5c75051SEivind Eklund 84987afe2aSBruce Evans${PROG}: ${OBJS} 85f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 86f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 87f8ba1555SRuslan Ermilov.else 88de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 89afe61c15SRodney W. Grimes.endif 90770ac3b2SJohn Birrell.if defined(CTFMERGE) 91770ac3b2SJohn Birrell ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} 92770ac3b2SJohn Birrell.endif 935d68012aSRuslan Ermilov.endif 94f5c75051SEivind Eklund 956fe6af9fSEivind Eklund.endif 96afe61c15SRodney W. Grimes 97e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" && !defined(MAN) && \ 98862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 99afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 100500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 101862d3deaSRuslan Ermilov !defined(MAN1aout) 10219ea15a1SRuslan ErmilovMAN= ${PROG}.1 10319ea15a1SRuslan ErmilovMAN1= ${MAN} 104afe61c15SRodney W. Grimes.endif 105afe61c15SRodney W. Grimes.endif 106afe61c15SRodney W. Grimes 107af2dc868SRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} 108e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" 109afeaaa84SRuslan Ermilovall: _manpages 110862d3deaSRuslan Ermilov.endif 111afe61c15SRodney W. Grimes 11241f89315SRuslan Ermilov.if defined(PROG) 11341f89315SRuslan ErmilovCLEANFILES+= ${PROG} 11441f89315SRuslan Ermilov.endif 11541f89315SRuslan Ermilov 11641f89315SRuslan Ermilov.if defined(OBJS) 11741f89315SRuslan ErmilovCLEANFILES+= ${OBJS} 11841f89315SRuslan Ermilov.endif 119afe61c15SRodney W. Grimes 12051fa76c4SRuslan Ermilov.include <bsd.libnames.mk> 12151fa76c4SRuslan Ermilov 122218a2cd2SBruce Evans.if defined(PROG) 123663e9677SBruce Evans_EXTRADEPEND: 12451fa76c4SRuslan Ermilov.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) 12551fa76c4SRuslan Ermilov.if defined(DPADD) && !empty(DPADD) 12651fa76c4SRuslan Ermilov echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 12751fa76c4SRuslan Ermilov.endif 12851fa76c4SRuslan Ermilov.else 1296e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 130f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 131f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 132f8ba1555SRuslan Ermilov.endif 1338c05a446SPeter Wemm.endif 13451fa76c4SRuslan Ermilov.endif 135663e9677SBruce Evans 136afe61c15SRodney W. Grimes.if !target(install) 137afe61c15SRodney W. Grimes 138212acbefSRuslan Ermilov.if defined(PRECIOUSPROG) 13900fbd407SRuslan Ermilov.if !defined(NO_FSCHG) 140dee651ebSRuslan ErmilovINSTALLFLAGS+= -fschg 141dee651ebSRuslan Ermilov.endif 142212acbefSRuslan ErmilovINSTALLFLAGS+= -S 143212acbefSRuslan Ermilov.endif 144dee651ebSRuslan Ermilov 145e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 146e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 147e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 148e902c1bbSTim Vanderhoek.endfor 149e902c1bbSTim Vanderhoek 15051fa76c4SRuslan Ermilov.if !target(realinstall) && !defined(INTERNALPROG) 15187829387SRuslan Ermilovrealinstall: _proginstall 152badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 15387829387SRuslan Ermilov_proginstall: 154afe61c15SRodney W. Grimes.if defined(PROG) 15595f8c826SRuslan Ermilov.if defined(PROGNAME) 156d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 15795f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 15895f8c826SRuslan Ermilov.else 159d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 160e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 161afe61c15SRodney W. Grimes.endif 16295f8c826SRuslan Ermilov.endif 16384aac273SHartmut Brandt.endif # !target(realinstall) 164afe61c15SRodney W. Grimes 165f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 166f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 167badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 168f7ee8cfeSRuslan Ermilov 169f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 170f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 171f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 172f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 173f7ee8cfeSRuslan Ermilov 174f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 175f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 176f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 177f7ee8cfeSRuslan Ermilov.else 178f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 179f7ee8cfeSRuslan Ermilov.endif 180f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 181f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 182f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 183f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 184a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 185a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 186d2893b16SRuslan Ermilov ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 187f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1884367bda6SRuslan Ermilov ${.ALLSRC} \ 189f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 190f7ee8cfeSRuslan Ermilov.endfor 191f7ee8cfeSRuslan Ermilov.endif 192f7ee8cfeSRuslan Ermilov 1938479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1948479adc1SRuslan Ermilov.include <bsd.nls.mk> 1958479adc1SRuslan Ermilov 196af2dc868SRuslan Ermilov.include <bsd.files.mk> 1975d862037SRuslan Ermilov.include <bsd.incs.mk> 19884f94a79SRuslan Ermilov.include <bsd.links.mk> 199c7b111cbSRuslan Ermilov 200e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" 201afeaaa84SRuslan Ermilovrealinstall: _maninstall 202badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 20387829387SRuslan Ermilov.endif 20487829387SRuslan Ermilov 205afe61c15SRodney W. Grimes.endif 206afe61c15SRodney W. Grimes 207afe61c15SRodney W. Grimes.if !target(lint) 2085741a42fSMark Murraylint: ${SRCS:M*.c} 209afe61c15SRodney W. Grimes.if defined(PROG) 2105741a42fSMark Murray ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 211afe61c15SRodney W. Grimes.endif 212afe61c15SRodney W. Grimes.endif 213afe61c15SRodney W. Grimes 214e1fe3dbaSRuslan Ermilov.if ${MK_MAN} != "no" 215afe61c15SRodney W. Grimes.include <bsd.man.mk> 21669b87d3eSEivind Eklund.endif 21769b87d3eSEivind Eklund 2183585b293SGarrett Wollman.include <bsd.dep.mk> 219987afe2aSBruce Evans 22088505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 221589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 222987afe2aSBruce Evans.endif 223987afe2aSBruce Evans 224cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 225d510ecb4SKris Kennaway 226d510ecb4SKris Kennaway.include <bsd.sys.mk> 22757e3ff64SPaul Richards 22857e3ff64SPaul Richards.if defined(PORTNAME) 22957e3ff64SPaul Richards.include <bsd.pkg.mk> 23057e3ff64SPaul Richards.endif 231