13585b293SGarrett Wollman# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2cdaa52cfSJohn Birrell# $Id: bsd.prog.mk,v 1.76 1998/08/08 07:02:08 peter Exp $ 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 113ec75cc6SPeter Wemm# Default executable format 12cdaa52cfSJohn BirrellOBJFORMAT?= aout 133ec75cc6SPeter Wemm 14c7cbe79eSDmitrij Tejblum.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .s .S 15afe61c15SRodney W. Grimes 16e82b0b99SJordan K. HubbardCFLAGS+=${COPTS} ${DEBUG_FLAGS} 173585b293SGarrett Wollman.if defined(DESTDIR) 183585b293SGarrett WollmanCFLAGS+= -I${DESTDIR}/usr/include 1915db27b8SSatoshi AsamiCXXINCLUDES+= -I${DESTDIR}/usr/include/g++ 203585b293SGarrett Wollman.endif 21afe61c15SRodney W. Grimes 22e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 23afe61c15SRodney W. GrimesSTRIP?= -s 24e82b0b99SJordan K. Hubbard.endif 25afe61c15SRodney W. Grimes 263d8cd70cSPaul Traina.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 273585b293SGarrett WollmanLDFLAGS+= -static 283585b293SGarrett Wollman.endif 29afe61c15SRodney W. Grimes 30afe61c15SRodney W. Grimes.if defined(PROG) 31afe61c15SRodney W. Grimes.if defined(SRCS) 32afe61c15SRodney W. Grimes 3370a6e331SBruce Evans# If there are Objective C sources, link with Objective C libraries. 3470a6e331SBruce Evans.if ${SRCS:M*.m} != "" 3570a6e331SBruce EvansOBJCLIBS?= -lobjc 3670a6e331SBruce EvansLDADD+= ${OBJCLIBS} 3770a6e331SBruce Evans.endif 3870a6e331SBruce Evans 393585b293SGarrett WollmanOBJS+= ${SRCS:N*.h:R:S/$/.o/g} 40afe61c15SRodney W. Grimes 41987afe2aSBruce Evans${PROG}: ${OBJS} 423585b293SGarrett Wollman ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 433585b293SGarrett Wollman 44fd2e43eaSBruce Evans.else !defined(SRCS) 45afe61c15SRodney W. Grimes 46f5c75051SEivind Eklund.if !target(${PROG}) 47afe61c15SRodney W. GrimesSRCS= ${PROG}.c 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} 57a4c39c7aSBruce Evans ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 58afe61c15SRodney W. Grimes.endif 59f5c75051SEivind Eklund 606fe6af9fSEivind Eklund.endif 61afe61c15SRodney W. Grimes 62afe61c15SRodney W. Grimes.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 63afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 64afe61c15SRodney W. Grimes !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 653585b293SGarrett WollmanMAN1= ${PROG}.1 66afe61c15SRodney W. Grimes.endif 67afe61c15SRodney W. Grimes.endif 68afe61c15SRodney W. Grimes 69afe61c15SRodney W. Grimes.MAIN: all 70b3618bcfSSteven Wallaceall: objwarn ${PROG} all-man _SUBDIR 71afe61c15SRodney W. Grimes 7289d11b8aSBruce EvansCLEANFILES+= ${PROG} ${OBJS} 73afe61c15SRodney W. Grimes 742799473bSSatoshi Asami.if defined(PROG) && !defined(NOEXTRADEPEND) 75663e9677SBruce Evans_EXTRADEPEND: 76cdaa52cfSJohn Birrell.if ${OBJFORMAT} == aout 77663e9677SBruce Evans echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 781c735bb4SBruce Evans ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 798c05a446SPeter Wemm.else 804e9229baSBruce Evans.if defined(DPADD) && !empty(DPADD) 818c05a446SPeter Wemm echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 828c05a446SPeter Wemm.endif 838c05a446SPeter Wemm.endif 84663e9677SBruce Evans.endif 85663e9677SBruce Evans 86afe61c15SRodney W. Grimes.if !target(install) 87afe61c15SRodney W. Grimes.if !target(beforeinstall) 88afe61c15SRodney W. Grimesbeforeinstall: 89afe61c15SRodney W. Grimes.endif 90afe61c15SRodney W. Grimes 91cd9a2f5cSJordan K. Hubbardrealinstall: beforeinstall 92afe61c15SRodney W. Grimes.if defined(PROG) 933585b293SGarrett Wollman ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 9445f7f888SGarrett Wollman ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 95afe61c15SRodney W. Grimes.endif 96afe61c15SRodney W. Grimes.if defined(HIDEGAME) 97afe61c15SRodney W. Grimes (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 98870d9837SBruce Evans chown games:bin ${PROG}) 99afe61c15SRodney W. Grimes.endif 100afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS) 101afe61c15SRodney W. Grimes @set ${LINKS}; \ 102afe61c15SRodney W. Grimes while test $$# -ge 2; do \ 103afe61c15SRodney W. Grimes l=${DESTDIR}$$1; \ 104afe61c15SRodney W. Grimes shift; \ 105afe61c15SRodney W. Grimes t=${DESTDIR}$$1; \ 106afe61c15SRodney W. Grimes shift; \ 107a4c39c7aSBruce Evans ${ECHO} $$t -\> $$l; \ 108afe61c15SRodney W. Grimes rm -f $$t; \ 10945f7d107SJordan K. Hubbard ln ${LN_FLAGS} $$l $$t; \ 110afe61c15SRodney W. Grimes done; true 111afe61c15SRodney W. Grimes.endif 112afe61c15SRodney W. Grimes 113cd9a2f5cSJordan K. Hubbardinstall: afterinstall _SUBDIR 1143585b293SGarrett Wollman.if !defined(NOMAN) 1153585b293SGarrett Wollmanafterinstall: realinstall maninstall 1163585b293SGarrett Wollman.else 117afe61c15SRodney W. Grimesafterinstall: realinstall 1183585b293SGarrett Wollman.endif 119afe61c15SRodney W. Grimes.endif 120afe61c15SRodney W. Grimes 121d9584d76SJordan K. HubbardDISTRIBUTION?= bin 12255ff8fb1SPoul-Henning Kamp.if !target(distribute) 123cd9a2f5cSJordan K. Hubbarddistribute: _SUBDIR 124398ac038SJordan K. Hubbard.for dist in ${DISTRIBUTION} 125398ac038SJordan K. Hubbard cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 126398ac038SJordan K. Hubbard.endfor 12755ff8fb1SPoul-Henning Kamp.endif 12855ff8fb1SPoul-Henning Kamp 129afe61c15SRodney W. Grimes.if !target(lint) 130cd9a2f5cSJordan K. Hubbardlint: ${SRCS} _SUBDIR 131afe61c15SRodney W. Grimes.if defined(PROG) 132afe61c15SRodney W. Grimes @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 133afe61c15SRodney W. Grimes.endif 134afe61c15SRodney W. Grimes.endif 135afe61c15SRodney W. Grimes 1366eb5e456SJordan K. Hubbard.if defined(NOTAGS) 1376eb5e456SJordan K. Hubbardtags: 1386eb5e456SJordan K. Hubbard.endif 1396eb5e456SJordan K. Hubbard 140afe61c15SRodney W. Grimes.if !target(tags) 141cd9a2f5cSJordan K. Hubbardtags: ${SRCS} _SUBDIR 142afe61c15SRodney W. Grimes.if defined(PROG) 1431ed9b1c3SEivind Eklund @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 1446eb5e456SJordan K. Hubbard.if defined(HTML) 1451ed9b1c3SEivind Eklund @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 1466eb5e456SJordan K. Hubbard.endif 147afe61c15SRodney W. Grimes.endif 148afe61c15SRodney W. Grimes.endif 149afe61c15SRodney W. Grimes 150afe61c15SRodney W. Grimes.if !defined(NOMAN) 151afe61c15SRodney W. Grimes.include <bsd.man.mk> 1523585b293SGarrett Wollman.elif !target(maninstall) 153afe61c15SRodney W. Grimesmaninstall: 154973f098aSGarrett Wollmanall-man: 155afe61c15SRodney W. Grimes.endif 1563585b293SGarrett Wollman 15769b87d3eSEivind Eklund.if !target(regress) 15869b87d3eSEivind Eklundregress: 15969b87d3eSEivind Eklund.endif 16069b87d3eSEivind Eklund 161cdaa52cfSJohn Birrell.if ${OBJFORMAT} != aout || make(checkdpadd) 1628c05a446SPeter Wemm.include <bsd.libnames.mk> 1638c05a446SPeter Wemm.endif 1648c05a446SPeter Wemm 1653585b293SGarrett Wollman.include <bsd.dep.mk> 166987afe2aSBruce Evans 167987afe2aSBruce Evans.if defined(PROG) && !exists(${DEPENDFILE}) 168589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 169987afe2aSBruce Evans.endif 170987afe2aSBruce Evans 171cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 172