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 841f89315SRuslan Ermilov.if defined(COPTS) 941f89315SRuslan ErmilovCFLAGS+=${COPTS} 1041f89315SRuslan Ermilov.endif 1141f89315SRuslan Ermilov 1241f89315SRuslan Ermilov.if defined(DEBUG_FLAGS) 1341f89315SRuslan ErmilovCFLAGS+=${DEBUG_FLAGS} 1441f89315SRuslan Ermilov.endif 1541f89315SRuslan Ermilov 1641f89315SRuslan Ermilov.if defined(CRUNCH_CFLAGS) 173c9b8563SGordon TetlowCFLAGS+=${CRUNCH_CFLAGS} 1841f89315SRuslan Ermilov.endif 19afe61c15SRodney W. Grimes 20e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 21afe61c15SRodney W. GrimesSTRIP?= -s 22e82b0b99SJordan K. Hubbard.endif 23afe61c15SRodney W. Grimes 243d8cd70cSPaul Traina.if defined(NOSHARED) && (${NOSHARED} != "no" && ${NOSHARED} != "NO") 253585b293SGarrett WollmanLDFLAGS+= -static 263585b293SGarrett Wollman.endif 27afe61c15SRodney W. Grimes 2847bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 2947bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 3047bf8a5cSRuslan Ermilov.endif 3147bf8a5cSRuslan Ermilov 32afe61c15SRodney W. Grimes.if defined(PROG) 33afe61c15SRodney W. Grimes.if defined(SRCS) 34afe61c15SRodney W. Grimes 3570a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 3665d2bdc6SRuslan Ermilov.if !empty(SRCS:M*.m) 3770a6e331SBruce EvansOBJCLIBS?= -lobjc 3870a6e331SBruce EvansLDADD+= ${OBJCLIBS} 3970a6e331SBruce Evans.endif 4070a6e331SBruce Evans 413585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 42afe61c15SRodney W. Grimes 435d68012aSRuslan Ermilov${PROG}: ${OBJS} 445d68012aSRuslan Ermilov.if defined(PROG_CXX) 455d68012aSRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 465d68012aSRuslan Ermilov.else 475d68012aSRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 485d68012aSRuslan Ermilov.endif 495d68012aSRuslan Ermilov 50fd2e43eaSBruce Evans.else !defined(SRCS) 51afe61c15SRodney W. Grimes 525d68012aSRuslan Ermilov.if !target(${PROG}) 5347bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 5447bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 5547bf8a5cSRuslan Ermilov.else 56afe61c15SRodney W. GrimesSRCS= ${PROG}.c 5747bf8a5cSRuslan Ermilov.endif 58afe61c15SRodney W. Grimes 59a4c39c7aSBruce Evans# Always make an intermediate object file because: 60a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 61a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 62a4c39c7aSBruce Evans# the name of a variable temporary object. 63a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 64a4c39c7aSBruce EvansOBJS= ${PROG}.o 65f5c75051SEivind Eklund 66987afe2aSBruce Evans${PROG}: ${OBJS} 67f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 68f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 69f8ba1555SRuslan Ermilov.else 70de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 71afe61c15SRodney W. Grimes.endif 725d68012aSRuslan Ermilov.endif 73f5c75051SEivind Eklund 746fe6af9fSEivind Eklund.endif 75afe61c15SRodney W. Grimes 76862d3deaSRuslan Ermilov.if !defined(NOMAN) && !defined(MAN) && \ 77862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 78afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 79500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 80862d3deaSRuslan Ermilov !defined(MAN1aout) 8119ea15a1SRuslan ErmilovMAN= ${PROG}.1 8219ea15a1SRuslan ErmilovMAN1= ${MAN} 83afe61c15SRodney W. Grimes.endif 84afe61c15SRodney W. Grimes.endif 85afe61c15SRodney W. Grimes 86af2dc868SRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} 87862d3deaSRuslan Ermilov.if !defined(NOMAN) 88afeaaa84SRuslan Ermilovall: _manpages 89862d3deaSRuslan Ermilov.endif 90afe61c15SRodney W. Grimes 9141f89315SRuslan Ermilov.if defined(PROG) 9241f89315SRuslan ErmilovCLEANFILES+= ${PROG} 9341f89315SRuslan Ermilov.endif 9441f89315SRuslan Ermilov 9541f89315SRuslan Ermilov.if defined(OBJS) 9641f89315SRuslan ErmilovCLEANFILES+= ${OBJS} 9741f89315SRuslan Ermilov.endif 98afe61c15SRodney W. Grimes 9951fa76c4SRuslan Ermilov.include <bsd.libnames.mk> 10051fa76c4SRuslan Ermilov 101218a2cd2SBruce Evans.if defined(PROG) 102663e9677SBruce Evans_EXTRADEPEND: 10351fa76c4SRuslan Ermilov.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) 10451fa76c4SRuslan Ermilov.if defined(DPADD) && !empty(DPADD) 10551fa76c4SRuslan Ermilov echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 10651fa76c4SRuslan Ermilov.endif 10751fa76c4SRuslan Ermilov.else 1086e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 109f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 110f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 111f8ba1555SRuslan Ermilov.endif 1128c05a446SPeter Wemm.endif 11351fa76c4SRuslan Ermilov.endif 114663e9677SBruce Evans 115afe61c15SRodney W. Grimes.if !target(install) 116afe61c15SRodney W. Grimes 117e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 118e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 119e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 120e902c1bbSTim Vanderhoek.endfor 121e902c1bbSTim Vanderhoek 12251fa76c4SRuslan Ermilov.if !target(realinstall) && !defined(INTERNALPROG) 12387829387SRuslan Ermilovrealinstall: _proginstall 124badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 12587829387SRuslan Ermilov_proginstall: 126afe61c15SRodney W. Grimes.if defined(PROG) 12795f8c826SRuslan Ermilov.if defined(PROGNAME) 128d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 12995f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 13095f8c826SRuslan Ermilov.else 131d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 132e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 133afe61c15SRodney W. Grimes.endif 13495f8c826SRuslan Ermilov.endif 1359e84c09cSRuslan Ermilov.endif !target(realinstall) 136afe61c15SRodney W. Grimes 137f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 138f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 139badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 140f7ee8cfeSRuslan Ermilov 141f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 142f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 143f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 144f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 145f7ee8cfeSRuslan Ermilov 146f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 147f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 148f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 149f7ee8cfeSRuslan Ermilov.else 150f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 151f7ee8cfeSRuslan Ermilov.endif 152f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 153f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 154f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 155f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 156a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 157a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 158d2893b16SRuslan Ermilov ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 159f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1604367bda6SRuslan Ermilov ${.ALLSRC} \ 161f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 162f7ee8cfeSRuslan Ermilov.endfor 163f7ee8cfeSRuslan Ermilov.endif 164f7ee8cfeSRuslan Ermilov 1658479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1668479adc1SRuslan Ermilov.include <bsd.nls.mk> 1678479adc1SRuslan Ermilov 168af2dc868SRuslan Ermilov.include <bsd.files.mk> 1695d862037SRuslan Ermilov.include <bsd.incs.mk> 17084f94a79SRuslan Ermilov.include <bsd.links.mk> 171c7b111cbSRuslan Ermilov 17287829387SRuslan Ermilov.if !defined(NOMAN) 173afeaaa84SRuslan Ermilovrealinstall: _maninstall 174badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 17587829387SRuslan Ermilov.endif 17687829387SRuslan Ermilov 177afe61c15SRodney W. Grimes.endif 178afe61c15SRodney W. Grimes 179afe61c15SRodney W. Grimes.if !target(lint) 1805741a42fSMark Murraylint: ${SRCS:M*.c} 181afe61c15SRodney W. Grimes.if defined(PROG) 1825741a42fSMark Murray ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 183afe61c15SRodney W. Grimes.endif 184afe61c15SRodney W. Grimes.endif 185afe61c15SRodney W. Grimes 186afe61c15SRodney W. Grimes.if !defined(NOMAN) 187afe61c15SRodney W. Grimes.include <bsd.man.mk> 18869b87d3eSEivind Eklund.endif 18969b87d3eSEivind Eklund 1903585b293SGarrett Wollman.include <bsd.dep.mk> 191987afe2aSBruce Evans 19288505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 193589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 194987afe2aSBruce Evans.endif 195987afe2aSBruce Evans 196cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 197d510ecb4SKris Kennaway 198d510ecb4SKris Kennaway.include <bsd.sys.mk> 199