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 8e82b0b99SJordan K. HubbardCFLAGS+=${COPTS} ${DEBUG_FLAGS} 93c9b8563SGordon TetlowCFLAGS+=${CRUNCH_CFLAGS} 10afe61c15SRodney W. Grimes 11e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 12afe61c15SRodney W. GrimesSTRIP?= -s 13e82b0b99SJordan K. Hubbard.endif 14afe61c15SRodney W. Grimes 153d8cd70cSPaul Traina.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 163585b293SGarrett WollmanLDFLAGS+= -static 173585b293SGarrett Wollman.endif 18afe61c15SRodney W. Grimes 1947bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 2047bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 2147bf8a5cSRuslan Ermilov.endif 2247bf8a5cSRuslan Ermilov 23afe61c15SRodney W. Grimes.if defined(PROG) 24afe61c15SRodney W. Grimes.if defined(SRCS) 25afe61c15SRodney W. Grimes 2670a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 2770a6e331SBruce Evans.if ${SRCS:M*.m} != "" 2870a6e331SBruce EvansOBJCLIBS?= -lobjc 2970a6e331SBruce EvansLDADD+= ${OBJCLIBS} 3070a6e331SBruce Evans.endif 3170a6e331SBruce Evans 323585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 33afe61c15SRodney W. Grimes 345d68012aSRuslan Ermilov${PROG}: ${OBJS} 355d68012aSRuslan Ermilov.if defined(PROG_CXX) 365d68012aSRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 375d68012aSRuslan Ermilov.else 385d68012aSRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 395d68012aSRuslan Ermilov.endif 405d68012aSRuslan Ermilov 41fd2e43eaSBruce Evans.else !defined(SRCS) 42afe61c15SRodney W. Grimes 435d68012aSRuslan Ermilov.if !target(${PROG}) 4447bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 4547bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 4647bf8a5cSRuslan Ermilov.else 47afe61c15SRodney W. GrimesSRCS= ${PROG}.c 4847bf8a5cSRuslan Ermilov.endif 49afe61c15SRodney W. Grimes 50a4c39c7aSBruce Evans# Always make an intermediate object file because: 51a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 52a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 53a4c39c7aSBruce Evans# the name of a variable temporary object. 54a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 55a4c39c7aSBruce EvansOBJS= ${PROG}.o 56f5c75051SEivind Eklund 57987afe2aSBruce Evans${PROG}: ${OBJS} 58f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 59f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 60f8ba1555SRuslan Ermilov.else 61de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 62afe61c15SRodney W. Grimes.endif 635d68012aSRuslan Ermilov.endif 64f5c75051SEivind Eklund 656fe6af9fSEivind Eklund.endif 66afe61c15SRodney W. Grimes 67862d3deaSRuslan Ermilov.if !defined(NOMAN) && !defined(MAN) && \ 68862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 69afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 70500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 71862d3deaSRuslan Ermilov !defined(MAN1aout) 7219ea15a1SRuslan ErmilovMAN= ${PROG}.1 7319ea15a1SRuslan ErmilovMAN1= ${MAN} 74afe61c15SRodney W. Grimes.endif 75afe61c15SRodney W. Grimes.endif 76afe61c15SRodney W. Grimes 77af2dc868SRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} 78862d3deaSRuslan Ermilov.if !defined(NOMAN) 79afeaaa84SRuslan Ermilovall: _manpages 80862d3deaSRuslan Ermilov.endif 81afe61c15SRodney W. Grimes 8289d11b8aSBruce EvansCLEANFILES+= ${PROG} ${OBJS} 83afe61c15SRodney W. Grimes 84218a2cd2SBruce Evans.if defined(PROG) 85663e9677SBruce Evans_EXTRADEPEND: 866e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 87f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 88f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 89f8ba1555SRuslan Ermilov.endif 908c05a446SPeter Wemm.endif 91663e9677SBruce Evans 92afe61c15SRodney W. Grimes.if !target(install) 93afe61c15SRodney W. Grimes 94e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 95e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 96e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 97e902c1bbSTim Vanderhoek.endfor 98e902c1bbSTim Vanderhoek 999e84c09cSRuslan Ermilov.if !target(realinstall) 10087829387SRuslan Ermilovrealinstall: _proginstall 101badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 10287829387SRuslan Ermilov_proginstall: 103afe61c15SRodney W. Grimes.if defined(PROG) 10495f8c826SRuslan Ermilov.if defined(PROGNAME) 105d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 10695f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 10795f8c826SRuslan Ermilov.else 108d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 109e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 110afe61c15SRodney W. Grimes.endif 11195f8c826SRuslan Ermilov.endif 1129e84c09cSRuslan Ermilov.endif !target(realinstall) 113afe61c15SRodney W. Grimes 114f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 115f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 116badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 117f7ee8cfeSRuslan Ermilov 118f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 119f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 120f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 121f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 122f7ee8cfeSRuslan Ermilov 123f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 124f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 125f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 126f7ee8cfeSRuslan Ermilov.else 127f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 128f7ee8cfeSRuslan Ermilov.endif 129f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 130f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 131f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 132f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 133a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 134a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 135d2893b16SRuslan Ermilov ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 136f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1374367bda6SRuslan Ermilov ${.ALLSRC} \ 138f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 139f7ee8cfeSRuslan Ermilov.endfor 140f7ee8cfeSRuslan Ermilov.endif 141f7ee8cfeSRuslan Ermilov 1428479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1438479adc1SRuslan Ermilov.include <bsd.nls.mk> 1448479adc1SRuslan Ermilov 145af2dc868SRuslan Ermilov.include <bsd.files.mk> 1465d862037SRuslan Ermilov.include <bsd.incs.mk> 14784f94a79SRuslan Ermilov.include <bsd.links.mk> 148c7b111cbSRuslan Ermilov 14987829387SRuslan Ermilov.if !defined(NOMAN) 150afeaaa84SRuslan Ermilovrealinstall: _maninstall 151badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 15287829387SRuslan Ermilov.endif 15387829387SRuslan Ermilov 154afe61c15SRodney W. Grimes.endif 155afe61c15SRodney W. Grimes 156afe61c15SRodney W. Grimes.if !target(lint) 1575741a42fSMark Murraylint: ${SRCS:M*.c} 158afe61c15SRodney W. Grimes.if defined(PROG) 1595741a42fSMark Murray ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 160afe61c15SRodney W. Grimes.endif 161afe61c15SRodney W. Grimes.endif 162afe61c15SRodney W. Grimes 163afe61c15SRodney W. Grimes.if !defined(NOMAN) 164afe61c15SRodney W. Grimes.include <bsd.man.mk> 16569b87d3eSEivind Eklund.endif 16669b87d3eSEivind Eklund 1678c05a446SPeter Wemm.include <bsd.libnames.mk> 1688c05a446SPeter Wemm 1693585b293SGarrett Wollman.include <bsd.dep.mk> 170987afe2aSBruce Evans 17188505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 172589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 173987afe2aSBruce Evans.endif 174987afe2aSBruce Evans 175cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 176d510ecb4SKris Kennaway 177d510ecb4SKris Kennaway.include <bsd.sys.mk> 178