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 6e517d11eSDavid E. O'Brien.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S .asm 7afe61c15SRodney W. Grimes 8e82b0b99SJordan K. HubbardCFLAGS+=${COPTS} ${DEBUG_FLAGS} 9afe61c15SRodney W. Grimes 10e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 11afe61c15SRodney W. GrimesSTRIP?= -s 12e82b0b99SJordan K. Hubbard.endif 13afe61c15SRodney W. Grimes 143d8cd70cSPaul Traina.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 153585b293SGarrett WollmanLDFLAGS+= -static 163585b293SGarrett Wollman.endif 17afe61c15SRodney W. Grimes 1847bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 1947bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 2047bf8a5cSRuslan Ermilov.endif 2147bf8a5cSRuslan Ermilov 22afe61c15SRodney W. Grimes.if defined(PROG) 23afe61c15SRodney W. Grimes.if defined(SRCS) 24afe61c15SRodney W. Grimes 2570a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 2670a6e331SBruce Evans.if ${SRCS:M*.m} != "" 2770a6e331SBruce EvansOBJCLIBS?= -lobjc 2870a6e331SBruce EvansLDADD+= ${OBJCLIBS} 2970a6e331SBruce Evans.endif 3070a6e331SBruce Evans 313585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 32afe61c15SRodney W. Grimes 335d68012aSRuslan Ermilov${PROG}: ${OBJS} 345d68012aSRuslan Ermilov.if defined(PROG_CXX) 355d68012aSRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 365d68012aSRuslan Ermilov.else 375d68012aSRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 385d68012aSRuslan Ermilov.endif 395d68012aSRuslan Ermilov 40fd2e43eaSBruce Evans.else !defined(SRCS) 41afe61c15SRodney W. Grimes 425d68012aSRuslan Ermilov.if !target(${PROG}) 4347bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 4447bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 4547bf8a5cSRuslan Ermilov.else 46afe61c15SRodney W. GrimesSRCS= ${PROG}.c 4747bf8a5cSRuslan Ermilov.endif 48afe61c15SRodney W. Grimes 49a4c39c7aSBruce Evans# Always make an intermediate object file because: 50a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 51a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 52a4c39c7aSBruce Evans# the name of a variable temporary object. 53a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 54a4c39c7aSBruce EvansOBJS= ${PROG}.o 55f5c75051SEivind Eklund 56987afe2aSBruce Evans${PROG}: ${OBJS} 57f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 58f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 59f8ba1555SRuslan Ermilov.else 60de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 61afe61c15SRodney W. Grimes.endif 625d68012aSRuslan Ermilov.endif 63f5c75051SEivind Eklund 646fe6af9fSEivind Eklund.endif 65afe61c15SRodney W. Grimes 66862d3deaSRuslan Ermilov.if !defined(NOMAN) && !defined(MAN) && \ 67862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 68afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 69500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 70862d3deaSRuslan Ermilov !defined(MAN1aout) 7119ea15a1SRuslan ErmilovMAN= ${PROG}.1 7219ea15a1SRuslan ErmilovMAN1= ${MAN} 73afe61c15SRodney W. Grimes.endif 74afe61c15SRodney W. Grimes.endif 75afe61c15SRodney W. Grimes 76af2dc868SRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} 77862d3deaSRuslan Ermilov.if !defined(NOMAN) 78afeaaa84SRuslan Ermilovall: _manpages 79862d3deaSRuslan Ermilov.endif 80afe61c15SRodney W. Grimes 8189d11b8aSBruce EvansCLEANFILES+= ${PROG} ${OBJS} 82afe61c15SRodney W. Grimes 83218a2cd2SBruce Evans.if defined(PROG) 84663e9677SBruce Evans_EXTRADEPEND: 85cdaa52cfSJohn Birrell.if ${OBJFORMAT} == aout 86de0d6977SRuslan Ermilov echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} \ 871c735bb4SBruce Evans ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 888c05a446SPeter Wemm.else 896e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 90f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 91f8ba1555SRuslan Ermilov echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} 92f8ba1555SRuslan Ermilov.endif 938c05a446SPeter Wemm.endif 94663e9677SBruce Evans.endif 95663e9677SBruce Evans 96afe61c15SRodney W. Grimes.if !target(install) 97afe61c15SRodney W. Grimes 98e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 99e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 100e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 101e902c1bbSTim Vanderhoek.endfor 102e902c1bbSTim Vanderhoek 1039e84c09cSRuslan Ermilov.if !target(realinstall) 10487829387SRuslan Ermilovrealinstall: _proginstall 105badb7c1cSRuslan Ermilov.ORDER: beforeinstall _proginstall 10687829387SRuslan Ermilov_proginstall: 107afe61c15SRodney W. Grimes.if defined(PROG) 10895f8c826SRuslan Ermilov.if defined(PROGNAME) 10995f8c826SRuslan Ermilov ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 11095f8c826SRuslan Ermilov ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} 11195f8c826SRuslan Ermilov.else 1123585b293SGarrett Wollman ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 113e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 114afe61c15SRodney W. Grimes.endif 11595f8c826SRuslan Ermilov.endif 116afe61c15SRodney W. Grimes.if defined(HIDEGAME) 117dfcf88a3SRuslan Ermilov (cd ${DESTDIR}${ORIGBINDIR}; ln -fs dm ${PROG}; \ 118dfcf88a3SRuslan Ermilov chown -h ${BINOWN}:${ORIGBINGRP} ${PROG}) 119afe61c15SRodney W. Grimes.endif 1209e84c09cSRuslan Ermilov.endif !target(realinstall) 121afe61c15SRodney W. Grimes 122f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 123f7ee8cfeSRuslan Ermilovrealinstall: _scriptsinstall 124badb7c1cSRuslan Ermilov.ORDER: beforeinstall _scriptsinstall 125f7ee8cfeSRuslan Ermilov 126f7ee8cfeSRuslan ErmilovSCRIPTSDIR?= ${BINDIR} 127f7ee8cfeSRuslan ErmilovSCRIPTSOWN?= ${BINOWN} 128f7ee8cfeSRuslan ErmilovSCRIPTSGRP?= ${BINGRP} 129f7ee8cfeSRuslan ErmilovSCRIPTSMODE?= ${BINMODE} 130f7ee8cfeSRuslan Ermilov 131f7ee8cfeSRuslan Ermilov.for script in ${SCRIPTS} 132f7ee8cfeSRuslan Ermilov.if defined(SCRIPTSNAME) 133f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} 134f7ee8cfeSRuslan Ermilov.else 135f7ee8cfeSRuslan ErmilovSCRIPTSNAME_${script:T}?= ${script:T:R} 136f7ee8cfeSRuslan Ermilov.endif 137f7ee8cfeSRuslan ErmilovSCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} 138f7ee8cfeSRuslan ErmilovSCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} 139f7ee8cfeSRuslan ErmilovSCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} 140f7ee8cfeSRuslan ErmilovSCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} 141a7aaf57eSRuslan Ermilov_scriptsinstall: _SCRIPTSINS_${script:T} 142a7aaf57eSRuslan Ermilov_SCRIPTSINS_${script:T}: ${script} 143f7ee8cfeSRuslan Ermilov ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 144f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 1454367bda6SRuslan Ermilov ${.ALLSRC} \ 146f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 147f7ee8cfeSRuslan Ermilov.endfor 148f7ee8cfeSRuslan Ermilov.endif 149f7ee8cfeSRuslan Ermilov 1508479adc1SRuslan ErmilovNLSNAME?= ${PROG} 1518479adc1SRuslan Ermilov.include <bsd.nls.mk> 1528479adc1SRuslan Ermilov 153af2dc868SRuslan Ermilov.include <bsd.files.mk> 1545d862037SRuslan Ermilov.include <bsd.incs.mk> 15584f94a79SRuslan Ermilov.include <bsd.links.mk> 156c7b111cbSRuslan Ermilov 15787829387SRuslan Ermilov.if !defined(NOMAN) 158afeaaa84SRuslan Ermilovrealinstall: _maninstall 159badb7c1cSRuslan Ermilov.ORDER: beforeinstall _maninstall 16087829387SRuslan Ermilov.endif 16187829387SRuslan Ermilov 162afe61c15SRodney W. Grimes.endif 163afe61c15SRodney W. Grimes 164afe61c15SRodney W. Grimes.if !target(lint) 165b25a566dSRuslan Ermilovlint: ${SRCS} 166afe61c15SRodney W. Grimes.if defined(PROG) 16708b44302SBruce Evans ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1 168afe61c15SRodney W. Grimes.endif 169afe61c15SRodney W. Grimes.endif 170afe61c15SRodney W. Grimes 1716eb5e456SJordan K. Hubbard.if defined(NOTAGS) 1726eb5e456SJordan K. Hubbardtags: 1736eb5e456SJordan K. Hubbard.endif 1746eb5e456SJordan K. Hubbard 175afe61c15SRodney W. Grimes.if !target(tags) 176b25a566dSRuslan Ermilovtags: ${SRCS} 177afe61c15SRodney W. Grimes.if defined(PROG) 1781ed9b1c3SEivind Eklund @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 1796eb5e456SJordan K. Hubbard.if defined(HTML) 1801ed9b1c3SEivind Eklund @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 1816eb5e456SJordan K. Hubbard.endif 182afe61c15SRodney W. Grimes.endif 183afe61c15SRodney W. Grimes.endif 184afe61c15SRodney W. Grimes 185afe61c15SRodney W. Grimes.if !defined(NOMAN) 186afe61c15SRodney W. Grimes.include <bsd.man.mk> 18769b87d3eSEivind Eklund.endif 18869b87d3eSEivind Eklund 189368c8de4SJohn Polstra.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 1908c05a446SPeter Wemm.include <bsd.libnames.mk> 1918c05a446SPeter Wemm.endif 1928c05a446SPeter Wemm 1933585b293SGarrett Wollman.include <bsd.dep.mk> 194987afe2aSBruce Evans 19588505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 196589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 197987afe2aSBruce Evans.endif 198987afe2aSBruce Evans 199cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 200d510ecb4SKris Kennaway 201d510ecb4SKris Kennaway.include <bsd.sys.mk> 202