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} 143585b293SGarrett Wollman.if defined(DESTDIR) 153585b293SGarrett WollmanCFLAGS+= -I${DESTDIR}/usr/include 1615db27b8SSatoshi AsamiCXXINCLUDES+= -I${DESTDIR}/usr/include/g++ 173585b293SGarrett Wollman.endif 18afe61c15SRodney W. Grimes 19e82b0b99SJordan K. Hubbard.if !defined(DEBUG_FLAGS) 20afe61c15SRodney W. GrimesSTRIP?= -s 21e82b0b99SJordan K. Hubbard.endif 22afe61c15SRodney W. Grimes 233d8cd70cSPaul Traina.if defined(NOSHARED) && ( ${NOSHARED} != "no" && ${NOSHARED} != "NO" ) 243585b293SGarrett WollmanLDFLAGS+= -static 253585b293SGarrett Wollman.endif 26afe61c15SRodney W. Grimes 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 38987afe2aSBruce Evans${PROG}: ${OBJS} 393585b293SGarrett Wollman ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 403585b293SGarrett Wollman 41fd2e43eaSBruce Evans.else !defined(SRCS) 42afe61c15SRodney W. Grimes 43f5c75051SEivind Eklund.if !target(${PROG}) 44afe61c15SRodney W. GrimesSRCS= ${PROG}.c 45afe61c15SRodney W. Grimes 46a4c39c7aSBruce Evans# Always make an intermediate object file because: 47a4c39c7aSBruce Evans# - it saves time rebuilding when only the library has changed 48a4c39c7aSBruce Evans# - the name of the object gets put into the executable symbol table instead of 49a4c39c7aSBruce Evans# the name of a variable temporary object. 50a4c39c7aSBruce Evans# - it's useful to keep objects around for crunching. 51a4c39c7aSBruce EvansOBJS= ${PROG}.o 52f5c75051SEivind Eklund 53987afe2aSBruce Evans${PROG}: ${OBJS} 54a4c39c7aSBruce Evans ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDDESTDIR} ${LDADD} 55afe61c15SRodney W. Grimes.endif 56f5c75051SEivind Eklund 576fe6af9fSEivind Eklund.endif 58afe61c15SRodney W. Grimes 59862d3deaSRuslan Ermilov.if !defined(NOMAN) && !defined(MAN) && \ 60862d3deaSRuslan Ermilov !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 61afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 62500d8265SRuslan Ermilov !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 63862d3deaSRuslan Ermilov !defined(MAN1aout) 646b10ad22SRuslan ErmilovMANSECT?= 1 656b10ad22SRuslan Ermilov.for sect in ${MANSECT} 666b10ad22SRuslan ErmilovMAN${sect}= ${PROG}.${sect} 676b10ad22SRuslan Ermilov.endfor 68afe61c15SRodney W. Grimes.endif 69afe61c15SRodney W. Grimes.endif 70afe61c15SRodney W. Grimes 71afe61c15SRodney W. Grimes.MAIN: all 72862d3deaSRuslan Ermilov.if !defined(NOMAN) 73b3618bcfSSteven Wallaceall: objwarn ${PROG} all-man _SUBDIR 74862d3deaSRuslan Ermilov.else 75862d3deaSRuslan Ermilovall: objwarn ${PROG} _SUBDIR 76862d3deaSRuslan Ermilov.endif 77afe61c15SRodney W. Grimes 7889d11b8aSBruce EvansCLEANFILES+= ${PROG} ${OBJS} 79afe61c15SRodney W. Grimes 80218a2cd2SBruce Evans.if defined(PROG) 81663e9677SBruce Evans_EXTRADEPEND: 82cdaa52cfSJohn Birrell.if ${OBJFORMAT} == aout 83663e9677SBruce Evans echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 841c735bb4SBruce Evans ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 858c05a446SPeter Wemm.else 866e19760bSBruce Evans echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} 878c05a446SPeter Wemm.endif 88663e9677SBruce Evans.endif 89663e9677SBruce Evans 90afe61c15SRodney W. Grimes.if !target(install) 91afe61c15SRodney W. Grimes.if !target(beforeinstall) 92afe61c15SRodney W. Grimesbeforeinstall: 93afe61c15SRodney W. Grimes.endif 94afe61c15SRodney W. Grimes 95e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${INSTALLFLAGS} 96e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT} 97e902c1bbSTim Vanderhoek_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 98e902c1bbSTim Vanderhoek.endfor 99e902c1bbSTim Vanderhoek 100cd9a2f5cSJordan K. Hubbardrealinstall: beforeinstall 101afe61c15SRodney W. Grimes.if defined(PROG) 1023585b293SGarrett Wollman ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 103e902c1bbSTim Vanderhoek ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 104afe61c15SRodney W. Grimes.endif 105afe61c15SRodney W. Grimes.if defined(HIDEGAME) 1067b81086bSDavid E. O'Brien (cd ${DESTDIR}/${GBINDIR}; rm -f ${PROG}; ln -s dm ${PROG}; \ 107870d9837SBruce Evans chown games:bin ${PROG}) 108afe61c15SRodney W. Grimes.endif 109afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS) 110afe61c15SRodney W. Grimes @set ${LINKS}; \ 111afe61c15SRodney W. Grimes while test $$# -ge 2; do \ 112afe61c15SRodney W. Grimes l=${DESTDIR}$$1; \ 113afe61c15SRodney W. Grimes shift; \ 114afe61c15SRodney W. Grimes t=${DESTDIR}$$1; \ 115afe61c15SRodney W. Grimes shift; \ 116a4c39c7aSBruce Evans ${ECHO} $$t -\> $$l; \ 1172336a7eaSBruce Evans ln -f $$l $$t; \ 1182336a7eaSBruce Evans done; true 1192336a7eaSBruce Evans.endif 1202336a7eaSBruce Evans.if defined(SYMLINKS) && !empty(SYMLINKS) 1212336a7eaSBruce Evans @set ${SYMLINKS}; \ 1222336a7eaSBruce Evans while test $$# -ge 2; do \ 1232336a7eaSBruce Evans l=$$1; \ 1242336a7eaSBruce Evans shift; \ 1252336a7eaSBruce Evans t=${DESTDIR}$$1; \ 1262336a7eaSBruce Evans shift; \ 1272336a7eaSBruce Evans ${ECHO} $$t -\> $$l; \ 1282336a7eaSBruce Evans ln -fs $$l $$t; \ 129afe61c15SRodney W. Grimes done; true 130afe61c15SRodney W. Grimes.endif 131afe61c15SRodney W. Grimes 132cd9a2f5cSJordan K. Hubbardinstall: afterinstall _SUBDIR 1333585b293SGarrett Wollman.if !defined(NOMAN) 1343585b293SGarrett Wollmanafterinstall: realinstall maninstall 1353585b293SGarrett Wollman.else 136afe61c15SRodney W. Grimesafterinstall: realinstall 1373585b293SGarrett Wollman.endif 138afe61c15SRodney W. Grimes.endif 139afe61c15SRodney W. Grimes 140d9584d76SJordan K. HubbardDISTRIBUTION?= bin 14155ff8fb1SPoul-Henning Kamp.if !target(distribute) 142cd9a2f5cSJordan K. Hubbarddistribute: _SUBDIR 143398ac038SJordan K. Hubbard.for dist in ${DISTRIBUTION} 144398ac038SJordan K. Hubbard cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 145398ac038SJordan K. Hubbard.endfor 14655ff8fb1SPoul-Henning Kamp.endif 14755ff8fb1SPoul-Henning Kamp 148afe61c15SRodney W. Grimes.if !target(lint) 149cd9a2f5cSJordan K. Hubbardlint: ${SRCS} _SUBDIR 150afe61c15SRodney W. Grimes.if defined(PROG) 151afe61c15SRodney W. Grimes @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 152afe61c15SRodney W. Grimes.endif 153afe61c15SRodney W. Grimes.endif 154afe61c15SRodney W. Grimes 1556eb5e456SJordan K. Hubbard.if defined(NOTAGS) 1566eb5e456SJordan K. Hubbardtags: 1576eb5e456SJordan K. Hubbard.endif 1586eb5e456SJordan K. Hubbard 159afe61c15SRodney W. Grimes.if !target(tags) 160cd9a2f5cSJordan K. Hubbardtags: ${SRCS} _SUBDIR 161afe61c15SRodney W. Grimes.if defined(PROG) 1621ed9b1c3SEivind Eklund @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 1636eb5e456SJordan K. Hubbard.if defined(HTML) 1641ed9b1c3SEivind Eklund @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 1656eb5e456SJordan K. Hubbard.endif 166afe61c15SRodney W. Grimes.endif 167afe61c15SRodney W. Grimes.endif 168afe61c15SRodney W. Grimes 169afe61c15SRodney W. Grimes.if !defined(NOMAN) 170afe61c15SRodney W. Grimes.include <bsd.man.mk> 1713585b293SGarrett Wollman.elif !target(maninstall) 172afe61c15SRodney W. Grimesmaninstall: 173afe61c15SRodney W. Grimes.endif 1743585b293SGarrett Wollman 17569b87d3eSEivind Eklund.if !target(regress) 17669b87d3eSEivind Eklundregress: 17769b87d3eSEivind Eklund.endif 17869b87d3eSEivind Eklund 179368c8de4SJohn Polstra.if ${OBJFORMAT} != aout || make(checkdpadd) || defined(NEED_LIBNAMES) 1808c05a446SPeter Wemm.include <bsd.libnames.mk> 1818c05a446SPeter Wemm.endif 1828c05a446SPeter Wemm 1833585b293SGarrett Wollman.include <bsd.dep.mk> 184987afe2aSBruce Evans 185987afe2aSBruce Evans.if defined(PROG) && !exists(${DEPENDFILE}) 186589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 187987afe2aSBruce Evans.endif 188987afe2aSBruce Evans 189cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 190