13585b293SGarrett Wollman# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 2c7cbe79eSDmitrij Tejblum# $Id: bsd.prog.mk,v 1.74 1998/05/15 09:34:48 bde Exp $ 3afe61c15SRodney W. Grimes 43585b293SGarrett Wollman.if exists(${.CURDIR}/../Makefile.inc) 5afe61c15SRodney W. Grimes.include "${.CURDIR}/../Makefile.inc" 6afe61c15SRodney W. Grimes.endif 7afe61c15SRodney W. Grimes 83ec75cc6SPeter Wemm# Default executable format 93ec75cc6SPeter WemmBINFORMAT?= aout 103ec75cc6SPeter Wemm 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 59afe61c15SRodney W. Grimes.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 60afe61c15SRodney W. Grimes !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 61afe61c15SRodney W. Grimes !defined(MAN7) && !defined(MAN8) && !defined(NOMAN) 623585b293SGarrett WollmanMAN1= ${PROG}.1 63afe61c15SRodney W. Grimes.endif 64afe61c15SRodney W. Grimes.endif 65afe61c15SRodney W. Grimes 66afe61c15SRodney W. Grimes.MAIN: all 67b3618bcfSSteven Wallaceall: objwarn ${PROG} all-man _SUBDIR 68afe61c15SRodney W. Grimes 6989d11b8aSBruce EvansCLEANFILES+= ${PROG} ${OBJS} 70afe61c15SRodney W. Grimes 712799473bSSatoshi Asami.if defined(PROG) && !defined(NOEXTRADEPEND) 72663e9677SBruce Evans_EXTRADEPEND: 738c05a446SPeter Wemm.if ${BINFORMAT} == aout 74663e9677SBruce Evans echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ 751c735bb4SBruce Evans ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} 768c05a446SPeter Wemm.else 774e9229baSBruce Evans.if defined(DPADD) && !empty(DPADD) 788c05a446SPeter Wemm echo ${PROG}: ${DPADD} >> ${DEPENDFILE} 798c05a446SPeter Wemm.endif 808c05a446SPeter Wemm.endif 81663e9677SBruce Evans.endif 82663e9677SBruce Evans 83afe61c15SRodney W. Grimes.if !target(install) 84afe61c15SRodney W. Grimes.if !target(beforeinstall) 85afe61c15SRodney W. Grimesbeforeinstall: 86afe61c15SRodney W. Grimes.endif 87afe61c15SRodney W. Grimes 88cd9a2f5cSJordan K. Hubbardrealinstall: beforeinstall 89afe61c15SRodney W. Grimes.if defined(PROG) 903585b293SGarrett Wollman ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 9145f7f888SGarrett Wollman ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} 92afe61c15SRodney W. Grimes.endif 93afe61c15SRodney W. Grimes.if defined(HIDEGAME) 94afe61c15SRodney W. Grimes (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \ 95870d9837SBruce Evans chown games:bin ${PROG}) 96afe61c15SRodney W. Grimes.endif 97afe61c15SRodney W. Grimes.if defined(LINKS) && !empty(LINKS) 98afe61c15SRodney W. Grimes @set ${LINKS}; \ 99afe61c15SRodney W. Grimes while test $$# -ge 2; do \ 100afe61c15SRodney W. Grimes l=${DESTDIR}$$1; \ 101afe61c15SRodney W. Grimes shift; \ 102afe61c15SRodney W. Grimes t=${DESTDIR}$$1; \ 103afe61c15SRodney W. Grimes shift; \ 104a4c39c7aSBruce Evans ${ECHO} $$t -\> $$l; \ 105afe61c15SRodney W. Grimes rm -f $$t; \ 10645f7d107SJordan K. Hubbard ln ${LN_FLAGS} $$l $$t; \ 107afe61c15SRodney W. Grimes done; true 108afe61c15SRodney W. Grimes.endif 109afe61c15SRodney W. Grimes 110cd9a2f5cSJordan K. Hubbardinstall: afterinstall _SUBDIR 1113585b293SGarrett Wollman.if !defined(NOMAN) 1123585b293SGarrett Wollmanafterinstall: realinstall maninstall 1133585b293SGarrett Wollman.else 114afe61c15SRodney W. Grimesafterinstall: realinstall 1153585b293SGarrett Wollman.endif 116afe61c15SRodney W. Grimes.endif 117afe61c15SRodney W. Grimes 118d9584d76SJordan K. HubbardDISTRIBUTION?= bin 11955ff8fb1SPoul-Henning Kamp.if !target(distribute) 120cd9a2f5cSJordan K. Hubbarddistribute: _SUBDIR 121398ac038SJordan K. Hubbard.for dist in ${DISTRIBUTION} 122398ac038SJordan K. Hubbard cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 123398ac038SJordan K. Hubbard.endfor 12455ff8fb1SPoul-Henning Kamp.endif 12555ff8fb1SPoul-Henning Kamp 126afe61c15SRodney W. Grimes.if !target(lint) 127cd9a2f5cSJordan K. Hubbardlint: ${SRCS} _SUBDIR 128afe61c15SRodney W. Grimes.if defined(PROG) 129afe61c15SRodney W. Grimes @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 130afe61c15SRodney W. Grimes.endif 131afe61c15SRodney W. Grimes.endif 132afe61c15SRodney W. Grimes 1336eb5e456SJordan K. Hubbard.if defined(NOTAGS) 1346eb5e456SJordan K. Hubbardtags: 1356eb5e456SJordan K. Hubbard.endif 1366eb5e456SJordan K. Hubbard 137afe61c15SRodney W. Grimes.if !target(tags) 138cd9a2f5cSJordan K. Hubbardtags: ${SRCS} _SUBDIR 139afe61c15SRodney W. Grimes.if defined(PROG) 1401ed9b1c3SEivind Eklund @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 1416eb5e456SJordan K. Hubbard.if defined(HTML) 1421ed9b1c3SEivind Eklund @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 1436eb5e456SJordan K. Hubbard.endif 144afe61c15SRodney W. Grimes.endif 145afe61c15SRodney W. Grimes.endif 146afe61c15SRodney W. Grimes 147afe61c15SRodney W. Grimes.if !defined(NOMAN) 148afe61c15SRodney W. Grimes.include <bsd.man.mk> 1493585b293SGarrett Wollman.elif !target(maninstall) 150afe61c15SRodney W. Grimesmaninstall: 151973f098aSGarrett Wollmanall-man: 152afe61c15SRodney W. Grimes.endif 1533585b293SGarrett Wollman 15469b87d3eSEivind Eklund.if !target(regress) 15569b87d3eSEivind Eklundregress: 15669b87d3eSEivind Eklund.endif 15769b87d3eSEivind Eklund 1584e9229baSBruce Evans.if ${BINFORMAT} != aout || make(checkdpadd) 1598c05a446SPeter Wemm.include <bsd.libnames.mk> 1608c05a446SPeter Wemm.endif 1618c05a446SPeter Wemm 1623585b293SGarrett Wollman.include <bsd.dep.mk> 163987afe2aSBruce Evans 164987afe2aSBruce Evans.if defined(PROG) && !exists(${DEPENDFILE}) 165589d9341SBruce Evans${OBJS}: ${SRCS:M*.h} 166987afe2aSBruce Evans.endif 167987afe2aSBruce Evans 168cd9a2f5cSJordan K. Hubbard.include <bsd.obj.mk> 169