13585b293SGarrett Wollman# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 27f3dea24SPeter Wemm# $FreeBSD$ 3afe61c15SRodney W. Grimes 4e0301e5dSPeter Wemm.if !target(__initialized__) 5e0301e5dSPeter Wemm__initialized__: 63585b293SGarrett Wollman.if exists(${.CURDIR}/../Makefile.inc) 7afe61c15SRodney W. Grimes.include "${.CURDIR}/../Makefile.inc" 8afe61c15SRodney W. Grimes.endif 9e0301e5dSPeter Wemm.endif 10afe61c15SRodney W. Grimes 11c7cbe79eSDmitrij Tejblum.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S 12afe61c15SRodney W. Grimes 13e82b0b99SJordan K. HubbardCFLAGS+=${COPTS} ${DEBUG_FLAGS} 14afe61c15SRodney W. Grimes 15e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 16afe61c15SRodney W. GrimesSTRIP?= -s 17e82b0b99SJordan K. Hubbard.endif 18afe61c15SRodney W. Grimes 193d8cd70cSPaul Traina.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 203585b293SGarrett WollmanLDFLAGS+= -static 213585b293SGarrett Wollman.endif 22afe61c15SRodney W. Grimes 2347bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 2447bf8a5cSRuslan ErmilovPROG= ${PROG_CXX} 2547bf8a5cSRuslan Ermilov.endif 2647bf8a5cSRuslan Ermilov 27afe61c15SRodney W. Grimes.if defined(PROG) 28afe61c15SRodney W. Grimes.if defined(SRCS) 29afe61c15SRodney W. Grimes 3070a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 3170a6e331SBruce Evans.if ${SRCS:M*.m} != "" 3270a6e331SBruce EvansOBJCLIBS?= -lobjc 3370a6e331SBruce EvansLDADD+= ${OBJCLIBS} 3470a6e331SBruce Evans.endif 3570a6e331SBruce Evans 363585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 37afe61c15SRodney W. Grimes 38fd2e43eaSBruce Evans.else !defined(SRCS) 39afe61c15SRodney W. Grimes 40f5c75051SEivind Eklund.if !target(${PROG}) 4147bf8a5cSRuslan Ermilov.if defined(PROG_CXX) 4247bf8a5cSRuslan ErmilovSRCS= ${PROG}.cc 4347bf8a5cSRuslan Ermilov.else 44afe61c15SRodney W. GrimesSRCS= ${PROG}.c 4547bf8a5cSRuslan Ermilov.endif 46afe61c15SRodney W. Grimes 47a4c39c7aSBruce Evans# Always make an intermediate object file because: 48a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 49a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 50a4c39c7aSBruce Evans# the name of a variable temporary object. 51a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 52a4c39c7aSBruce EvansOBJS= ${PROG}.o 53f8ba1555SRuslan Ermilov.endif 54f5c75051SEivind Eklund 55987afe2aSBruce Evans${PROG}: ${OBJS} 56f8ba1555SRuslan Ermilov.if defined(PROG_CXX) 57f8ba1555SRuslan Ermilov ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 58f8ba1555SRuslan Ermilov.else 59de0d6977SRuslan Ermilov ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 60afe61c15SRodney W. Grimes.endif 61f5c75051SEivind Eklund 626fe6af9fSEivind Eklund.endif 63afe61c15SRodney W. Grimes 64862d3deaSRuslan Ermilov.if !defined(NOMAN) && !defined(MAN) && \ 65862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 66afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 67500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 68862d3deaSRuslan Ermilov !defined(MAN1aout) 6919ea15a1SRuslan ErmilovMAN= ${PROG}.1 7019ea15a1SRuslan ErmilovMAN1= ${MAN} 71afe61c15SRodney W. Grimes.endif 72afe61c15SRodney W. Grimes.endif 73afe61c15SRodney W. Grimes 74afe61c15SRodney W. Grimes.MAIN: all 75a7aaf57eSRuslan Ermilovall: objwarn ${PROG} ${SCRIPTS} ${FILES} 76862d3deaSRuslan Ermilov.if !defined(NOMAN) 77a7aaf57eSRuslan Ermilovall: all-man 78862d3deaSRuslan Ermilov.endif 79a7aaf57eSRuslan Ermilovall: _SUBDIR 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.if !target(beforeinstall) 98afe61c15SRodney W. Grimesbeforeinstall: 99afe61c15SRodney W. Grimes.endif 100afe61c15SRodney W. Grimes 101e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 102e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 103e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 104e902c1bbSTim Vanderhoek.endfor 105e902c1bbSTim Vanderhoek 106cd9a2f5cSJordan K. Hubbardrealinstall: beforeinstall 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 120afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS) 121afe61c15SRodney W. Grimes @set ${LINKS}; \ 122afe61c15SRodney W. Grimes while test $$# -ge 2; do \ 123afe61c15SRodney W. Grimes l=${DESTDIR}$$1; \ 124afe61c15SRodney W. Grimes shift; \ 125afe61c15SRodney W. Grimes t=${DESTDIR}$$1; \ 126afe61c15SRodney W. Grimes shift; \ 127a4c39c7aSBruce Evans ${ECHO} $$t -\> $$l; \ 1282336a7eaSBruce Evans ln -f $$l $$t; \ 1292336a7eaSBruce Evans done; true 1302336a7eaSBruce Evans.endif 1312336a7eaSBruce Evans.if defined(SYMLINKS) && !empty(SYMLINKS) 1322336a7eaSBruce Evans @set ${SYMLINKS}; \ 1332336a7eaSBruce Evans while test $$# -ge 2; do \ 1342336a7eaSBruce Evans l=$$1; \ 1352336a7eaSBruce Evans shift; \ 1362336a7eaSBruce Evans t=${DESTDIR}$$1; \ 1372336a7eaSBruce Evans shift; \ 1382336a7eaSBruce Evans ${ECHO} $$t -\> $$l; \ 1392336a7eaSBruce Evans ln -fs $$l $$t; \ 140afe61c15SRodney W. Grimes done; true 141afe61c15SRodney W. Grimes.endif 142afe61c15SRodney W. Grimes 143f7ee8cfeSRuslan Ermilov.if defined(SCRIPTS) && !empty(SCRIPTS) 144f7ee8cfeSRuslan Ermilovrealinstall: _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} 163f7ee8cfeSRuslan Ermilov ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ 164f7ee8cfeSRuslan Ermilov -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ 165f7ee8cfeSRuslan Ermilov ${_INSTALLFLAGS} ${.ALLSRC} \ 166f7ee8cfeSRuslan Ermilov ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} 167f7ee8cfeSRuslan Ermilov.endfor 168f7ee8cfeSRuslan Ermilov.endif 169f7ee8cfeSRuslan Ermilov 170a7aaf57eSRuslan Ermilov.if defined(FILES) && !empty(FILES) 171a7aaf57eSRuslan Ermilovrealinstall: _filesinstall 172a7aaf57eSRuslan Ermilov 173a7aaf57eSRuslan ErmilovFILESDIR?= ${BINDIR} 174a7aaf57eSRuslan ErmilovFILESOWN?= ${SHAREOWN} 175a7aaf57eSRuslan ErmilovFILESGRP?= ${SHAREGRP} 176a7aaf57eSRuslan ErmilovFILESMODE?= ${SHAREMODE} 177a7aaf57eSRuslan Ermilov 178a7aaf57eSRuslan Ermilov.for file in ${FILES} 179a7aaf57eSRuslan Ermilov.if defined(FILESNAME) 180a7aaf57eSRuslan ErmilovFILESNAME_${file:T}?= ${FILESNAME} 181a7aaf57eSRuslan Ermilov.else 182a7aaf57eSRuslan ErmilovFILESNAME_${file:T}?= ${file:T} 183a7aaf57eSRuslan Ermilov.endif 184a7aaf57eSRuslan ErmilovFILESDIR_${file:T}?= ${FILESDIR} 185a7aaf57eSRuslan ErmilovFILESOWN_${file:T}?= ${FILESOWN} 186a7aaf57eSRuslan ErmilovFILESGRP_${file:T}?= ${FILESGRP} 187a7aaf57eSRuslan ErmilovFILESMODE_${file:T}?= ${FILESMODE} 188a7aaf57eSRuslan Ermilov_filesinstall: _FILESINS_${file:T} 189a7aaf57eSRuslan Ermilov_FILESINS_${file:T}: ${file} 190a7aaf57eSRuslan Ermilov ${INSTALL} ${COPY} -o ${FILESOWN_${.ALLSRC:T}} \ 191a7aaf57eSRuslan Ermilov -g ${FILESGRP_${.ALLSRC:T}} -m ${FILESMODE_${.ALLSRC:T}} \ 192a7aaf57eSRuslan Ermilov ${_INSTALLFLAGS} ${.ALLSRC} \ 193a7aaf57eSRuslan Ermilov ${DESTDIR}${FILESDIR_${.ALLSRC:T}}/${FILESNAME_${.ALLSRC:T}} 194a7aaf57eSRuslan Ermilov.endfor 195a7aaf57eSRuslan Ermilov.endif 196a7aaf57eSRuslan Ermilov 197cd9a2f5cSJordan K. Hubbardinstall: afterinstall _SUBDIR 1983585b293SGarrett Wollman.if !defined(NOMAN) 1993585b293SGarrett Wollmanafterinstall: realinstall maninstall 2003585b293SGarrett Wollman.else 201afe61c15SRodney W. Grimesafterinstall: realinstall 2023585b293SGarrett Wollman.endif 203afe61c15SRodney W. Grimes.endif 204afe61c15SRodney W. Grimes 205d9584d76SJordan K. HubbardDISTRIBUTION?= bin 20655ff8fb1SPoul-Henning Kamp.if !target(distribute) 207cd9a2f5cSJordan K. Hubbarddistribute: _SUBDIR 208398ac038SJordan K. Hubbard.for dist in ${DISTRIBUTION} 209398ac038SJordan K. Hubbard cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 210398ac038SJordan K. Hubbard.endfor 21155ff8fb1SPoul-Henning Kamp.endif 21255ff8fb1SPoul-Henning Kamp 213afe61c15SRodney W. Grimes.if !target(lint) 214cd9a2f5cSJordan K. Hubbardlint: ${SRCS} _SUBDIR 215afe61c15SRodney W. Grimes.if defined(PROG) 21608b44302SBruce Evans ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} | more 2>&1 217afe61c15SRodney W. Grimes.endif 218afe61c15SRodney W. Grimes.endif 219afe61c15SRodney W. Grimes 2206eb5e456SJordan K. Hubbard.if defined(NOTAGS) 2216eb5e456SJordan K. Hubbardtags: 2226eb5e456SJordan K. Hubbard.endif 2236eb5e456SJordan K. Hubbard 224afe61c15SRodney W. Grimes.if !target(tags) 225cd9a2f5cSJordan K. Hubbardtags: ${SRCS} _SUBDIR 226afe61c15SRodney W. Grimes.if defined(PROG) 2271ed9b1c3SEivind Eklund @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 2286eb5e456SJordan K. Hubbard.if defined(HTML) 2291ed9b1c3SEivind Eklund @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 2306eb5e456SJordan K. Hubbard.endif 231afe61c15SRodney W. Grimes.endif 232afe61c15SRodney W. Grimes.endif 233afe61c15SRodney W. Grimes 234afe61c15SRodney W. Grimes.if !defined(NOMAN) 235afe61c15SRodney W. Grimes.include <bsd.man.mk> 236918fb560SRuslan Ermilov.else 237918fb560SRuslan Ermilov.if !target(all-man) 238918fb560SRuslan Ermilovall-man: 239918fb560SRuslan Ermilov.endif 240918fb560SRuslan Ermilov.if !target(maninstall) 241afe61c15SRodney W. Grimesmaninstall: 242afe61c15SRodney W. Grimes.endif 243918fb560SRuslan Ermilov.endif 2443585b293SGarrett Wollman 24569b87d3eSEivind Eklund.if !target(regress) 24669b87d3eSEivind Eklundregress: 24769b87d3eSEivind Eklund.endif 24869b87d3eSEivind Eklund 249368c8de4SJohn Polstra.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 2508c05a446SPeter Wemm.include <bsd.libnames.mk> 2518c05a446SPeter Wemm.endif 2528c05a446SPeter Wemm 2533585b293SGarrett Wollman.include <bsd.dep.mk> 254987afe2aSBruce Evans 25588505e11SRuslan Ermilov.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) 256589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 257987afe2aSBruce Evans.endif 258987afe2aSBruce Evans 259cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 260d510ecb4SKris Kennaway 261d510ecb4SKris Kennaway.include <bsd.sys.mk> 262