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 1341f89315SRuslan Ermilov.if defined(DEBUG_FLAGS) 1441f89315SRuslan ErmilovCFLAGS+=${DEBUG_FLAGS} 1541f89315SRuslan Ermilov.endif 1641f89315SRuslan Ermilov 1741f89315SRuslan Ermilov.if defined(CRUNCH_CFLAGS) 183c9b8563SGordon TetlowCFLAGS+=${CRUNCH_CFLAGS} 1941f89315SRuslan Ermilov.endif 20afe61c15SRodney W. Grimes 21e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 22afe61c15SRodney W. GrimesSTRIP?= -s 23e82b0b99SJordan K. Hubbard.endif 24afe61c15SRodney W. Grimes 253d8cd70cSPaul Traina.if defined(NOSHARED) && (${NOSHARED} != "no" && ${NOSHARED} != "NO") 263585b293SGarrett WollmanLDFLAGS+= -static 273585b293SGarrett Wollman.endif 28afe61c15SRodney W. Grimes 2947bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 3047bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 3147bf8a5cSRuslan Ermilov.endif 3247bf8a5cSRuslan Ermilov 33afe61c15SRodney W. Grimes.if defined(PROG) 34afe61c15SRodney W. Grimes.if defined(SRCS) 35afe61c15SRodney W. Grimes 3670a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 3765d2bdc6SRuslan Ermilov.if !empty(SRCS:M*.m) 3870a6e331SBruce EvansOBJCLIBS?= -lobjc 3970a6e331SBruce EvansLDADD+= ${OBJCLIBS} 4070a6e331SBruce Evans.endif 4170a6e331SBruce Evans 423585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 43afe61c15SRodney W. Grimes 445d68012aSRuslan Ermilov${PROG}: ${OBJS} 455d68012aSRuslan Ermilov.if defined(PROG_CXX) 465d68012aSRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 475d68012aSRuslan Ermilov.else 485d68012aSRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 495d68012aSRuslan Ermilov.endif 505d68012aSRuslan Ermilov 51fd2e43eaSBruce Evans.else !defined(SRCS) 52afe61c15SRodney W. Grimes 535d68012aSRuslan Ermilov.if !target(${PROG}) 5447bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 5547bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 5647bf8a5cSRuslan Ermilov.else 57afe61c15SRodney W. GrimesSRCS= ${PROG}.c 5847bf8a5cSRuslan Ermilov.endif 59afe61c15SRodney W. Grimes 60a4c39c7aSBruce Evans# Always make an intermediate object file because: 61a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 62a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 63a4c39c7aSBruce Evans# the name of a variable temporary object. 64a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 65a4c39c7aSBruce EvansOBJS= ${PROG}.o 66f5c75051SEivind Eklund 67987afe2aSBruce Evans${PROG}: ${OBJS} 68f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 69f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 70f8ba1555SRuslan Ermilov.else 71de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 72afe61c15SRodney W. Grimes.endif 735d68012aSRuslan Ermilov.endif 74f5c75051SEivind Eklund 756fe6af9fSEivind Eklund.endif 76afe61c15SRodney W. Grimes 77862d3deaSRuslan Ermilov.if !defined(NOMAN) && !defined(MAN) && \ 78862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 79afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 80500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 81862d3deaSRuslan Ermilov !defined(MAN1aout) 8219ea15a1SRuslan ErmilovMAN= ${PROG}.1 8319ea15a1SRuslan ErmilovMAN1= ${MAN} 84afe61c15SRodney W. Grimes.endif 85afe61c15SRodney W. Grimes.endif 86afe61c15SRodney W. Grimes 87af2dc868SRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} 88862d3deaSRuslan Ermilov.if !defined(NOMAN) 89afeaaa84SRuslan Ermilovall: _manpages 90862d3deaSRuslan Ermilov.endif 91afe61c15SRodney W. Grimes 9241f89315SRuslan Ermilov.if defined(PROG) 9341f89315SRuslan ErmilovCLEANFILES+= ${PROG} 9441f89315SRuslan Ermilov.endif 9541f89315SRuslan Ermilov 9641f89315SRuslan Ermilov.if defined(OBJS) 9741f89315SRuslan ErmilovCLEANFILES+= ${OBJS} 9841f89315SRuslan Ermilov.endif 99afe61c15SRodney W. Grimes 10051fa76c4SRuslan Ermilov.include <bsd.libnames.mk> 10151fa76c4SRuslan Ermilov 102218a2cd2SBruce Evans.if defined(PROG) 103663e9677SBruce Evans_EXTRADEPEND: 10451fa76c4SRuslan Ermilov.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) 10551fa76c4SRuslan Ermilov.if defined(DPADD) && !empty(DPADD) 10651fa76c4SRuslan Ermilov echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 10751fa76c4SRuslan Ermilov.endif 10851fa76c4SRuslan Ermilov.else 1096e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 110f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 111f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 112f8ba1555SRuslan Ermilov.endif 1138c05a446SPeter Wemm.endif 11451fa76c4SRuslan Ermilov.endif 115663e9677SBruce Evans 116afe61c15SRodney W. Grimes.if !target(install) 117afe61c15SRodney W. Grimes 118dee651ebSRuslan Ermilov.if defined(PRECIOUSPROG) && !defined(NOFSCHG) 119dee651ebSRuslan ErmilovINSTALLFLAGS+= -fschg 120dee651ebSRuslan Ermilov.endif 121dee651ebSRuslan Ermilov 122e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 123e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 124e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 125e902c1bbSTim Vanderhoek.endfor 126e902c1bbSTim Vanderhoek 12751fa76c4SRuslan Ermilov.if !target(realinstall) && !defined(INTERNALPROG) 12887829387SRuslan Ermilovrealinstall: _proginstall 129badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 13087829387SRuslan Ermilov_proginstall: 131afe61c15SRodney W. Grimes.if defined(PROG) 13295f8c826SRuslan Ermilov.if defined(PROGNAME) 133d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 13495f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 13595f8c826SRuslan Ermilov.else 136d2893b16SRuslan Ermilov ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 137e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 138afe61c15SRodney W. Grimes.endif 13995f8c826SRuslan Ermilov.endif 1409e84c09cSRuslan Ermilov.endif !target(realinstall) 141afe61c15SRodney W. Grimes 142f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 143f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 144badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 145f7ee8cfeSRuslan Ermilov 146f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 147f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 148f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 149f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 150f7ee8cfeSRuslan Ermilov 151f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 152f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 153f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 154f7ee8cfeSRuslan Ermilov.else 155f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 156f7ee8cfeSRuslan Ermilov.endif 157f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 158f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 159f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 160f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 161a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 162a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 163d2893b16SRuslan Ermilov ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 164f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1654367bda6SRuslan Ermilov ${.ALLSRC} \ 166f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 167f7ee8cfeSRuslan Ermilov.endfor 168f7ee8cfeSRuslan Ermilov.endif 169f7ee8cfeSRuslan Ermilov 1708479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1718479adc1SRuslan Ermilov.include <bsd.nls.mk> 1728479adc1SRuslan Ermilov 173af2dc868SRuslan Ermilov.include <bsd.files.mk> 1745d862037SRuslan Ermilov.include <bsd.incs.mk> 17584f94a79SRuslan Ermilov.include <bsd.links.mk> 176c7b111cbSRuslan Ermilov 17787829387SRuslan Ermilov.if !defined(NOMAN) 178afeaaa84SRuslan Ermilovrealinstall: _maninstall 179badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 18087829387SRuslan Ermilov.endif 18187829387SRuslan Ermilov 182afe61c15SRodney W. Grimes.endif 183afe61c15SRodney W. Grimes 184afe61c15SRodney W. Grimes.if !target(lint) 1855741a42fSMark Murraylint: ${SRCS:M*.c} 186afe61c15SRodney W. Grimes.if defined(PROG) 1875741a42fSMark Murray ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} 188afe61c15SRodney W. Grimes.endif 189afe61c15SRodney W. Grimes.endif 190afe61c15SRodney W. Grimes 191afe61c15SRodney W. Grimes.if !defined(NOMAN) 192afe61c15SRodney W. Grimes.include <bsd.man.mk> 19369b87d3eSEivind Eklund.endif 19469b87d3eSEivind Eklund 1953585b293SGarrett Wollman.include <bsd.dep.mk> 196987afe2aSBruce Evans 19788505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 198589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 199987afe2aSBruce Evans.endif 200987afe2aSBruce Evans 201cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 202d510ecb4SKris Kennaway 203d510ecb4SKris Kennaway.include <bsd.sys.mk> 204