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 99218a2cd2SBruce Evans.if defined(PROG) 100663e9677SBruce Evans_EXTRADEPEND: 1016e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 102f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 103f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 104f8ba1555SRuslan Ermilov.endif 1058c05a446SPeter Wemm.endif 106663e9677SBruce Evans 107afe61c15SRodney W. Grimes.if !target(install) 108afe61c15SRodney W. Grimes 109e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 110e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 111e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 112e902c1bbSTim Vanderhoek.endfor 113e902c1bbSTim Vanderhoek 1149e84c09cSRuslan Ermilov.if !target(realinstall) 11587829387SRuslan Ermilovrealinstall: _proginstall 116badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 11787829387SRuslan Ermilov_proginstall: 118afe61c15SRodney W. Grimes.if defined(PROG) 11995f8c826SRuslan Ermilov.if defined(PROGNAME) 120d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 12195f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 12295f8c826SRuslan Ermilov.else 123d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 124e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 125afe61c15SRodney W. Grimes.endif 12695f8c826SRuslan Ermilov.endif 1279e84c09cSRuslan Ermilov.endif !target(realinstall) 128afe61c15SRodney W. Grimes 129f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 130f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 131badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 132f7ee8cfeSRuslan Ermilov 133f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 134f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 135f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 136f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 137f7ee8cfeSRuslan Ermilov 138f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 139f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 140f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 141f7ee8cfeSRuslan Ermilov.else 142f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 143f7ee8cfeSRuslan Ermilov.endif 144f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 145f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 146f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 147f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 148a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 149a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 150d2893b16SRuslan Ermilov ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 151f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1524367bda6SRuslan Ermilov ${.ALLSRC} \ 153f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 154f7ee8cfeSRuslan Ermilov.endfor 155f7ee8cfeSRuslan Ermilov.endif 156f7ee8cfeSRuslan Ermilov 1578479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1588479adc1SRuslan Ermilov.include <bsd.nls.mk> 1598479adc1SRuslan Ermilov 160af2dc868SRuslan Ermilov.include <bsd.files.mk> 1615d862037SRuslan Ermilov.include <bsd.incs.mk> 16284f94a79SRuslan Ermilov.include <bsd.links.mk> 163c7b111cbSRuslan Ermilov 16487829387SRuslan Ermilov.if !defined(NOMAN) 165afeaaa84SRuslan Ermilovrealinstall: _maninstall 166badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 16787829387SRuslan Ermilov.endif 16887829387SRuslan Ermilov 169afe61c15SRodney W. Grimes.endif 170afe61c15SRodney W. Grimes 171afe61c15SRodney W. Grimes.if !target(lint) 1725741a42fSMark Murraylint: ${SRCS:M*.c} 173afe61c15SRodney W. Grimes.if defined(PROG) 1745741a42fSMark Murray ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 175afe61c15SRodney W. Grimes.endif 176afe61c15SRodney W. Grimes.endif 177afe61c15SRodney W. Grimes 178afe61c15SRodney W. Grimes.if !defined(NOMAN) 179afe61c15SRodney W. Grimes.include <bsd.man.mk> 18069b87d3eSEivind Eklund.endif 18169b87d3eSEivind Eklund 1828c05a446SPeter Wemm.include <bsd.libnames.mk> 1838c05a446SPeter Wemm 1843585b293SGarrett Wollman.include <bsd.dep.mk> 185987afe2aSBruce Evans 18688505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 187589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 188987afe2aSBruce Evans.endif 189987afe2aSBruce Evans 190cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 191d510ecb4SKris Kennaway 192d510ecb4SKris Kennaway.include <bsd.sys.mk> 193