1*0a6a1f1dSLionel Sambuc# $NetBSD: bsd.dep.mk,v 1.82 2014/12/01 01:34:30 erh Exp $ 2*0a6a1f1dSLionel Sambuc 3*0a6a1f1dSLionel Sambuc.if defined(__MINIX) 4*0a6a1f1dSLionel Sambuc#LSC: Be a bit smarter about the default compiler 5*0a6a1f1dSLionel Sambuc.if exists(/usr/pkg/bin/clang) || exists(/usr/bin/clang) 6*0a6a1f1dSLionel SambucCC?= clang 7*0a6a1f1dSLionel Sambuc.endif 8*0a6a1f1dSLionel Sambuc 9*0a6a1f1dSLionel Sambuc.if exists(/usr/pkg/bin/gcc) || exists(/usr/bin/gcc) 10*0a6a1f1dSLionel SambucCC?= gcc 11*0a6a1f1dSLionel Sambuc.endif 12*0a6a1f1dSLionel Sambuc 13*0a6a1f1dSLionel SambucMKDEP?= CC=${CC:Q} mkdep 14*0a6a1f1dSLionel SambucMKDEPCXX?= CC=${CXX:Q} mkdep 15*0a6a1f1dSLionel Sambuc.endif # defined(__MINIX) 16e1091647SArun Thomas 17e1091647SArun Thomas##### Basic targets 18e1091647SArun Thomasrealdepend: beforedepend .depend afterdepend 19e1091647SArun Thomas.ORDER: beforedepend .depend afterdepend 20e1091647SArun Thomas 21e1091647SArun Thomasbeforedepend .depend afterdepend: # ensure existence 22e1091647SArun Thomas 23e1091647SArun Thomas##### Default values 24*0a6a1f1dSLionel SambucMKDEP?= mkdep 25*0a6a1f1dSLionel SambucMKDEPCXX?= mkdep 26*0a6a1f1dSLionel SambucMKDEP_SUFFIXES?= .o .d 27e1091647SArun Thomas 28e1091647SArun Thomas##### Build rules 29e1091647SArun Thomas# some of the rules involve .h sources, so remove them from mkdep line 30e1091647SArun Thomas 3184d9c625SLionel Sambuc.if defined(SRCS) && !empty(SRCS) 329152e1c5SLionel Sambuc__acpp_flags= ${_ASM_TRADITIONAL_CPP} 33e1091647SArun Thomas 349152e1c5SLionel Sambuc.if defined(NODPSRCS) 359152e1c5SLionel Sambuc.for f in ${SRCS} ${DPSRCS} 369152e1c5SLionel Sambuc.if "${NODPSRCS:M${f}}" == "" 379152e1c5SLionel Sambuc__DPSRCS.all+= ${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 389152e1c5SLionel Sambuc.endif 399152e1c5SLionel Sambuc.endfor 409152e1c5SLionel Sambucbeforedepend: ${DPSRCS} 419152e1c5SLionel Sambuc.else 429152e1c5SLionel Sambuc__DPSRCS.all+= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ 43e1091647SArun Thomas ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 449152e1c5SLionel Sambuc.endif 45e1091647SArun Thomas__DPSRCS.d= ${__DPSRCS.all:O:u:M*.d} 46e1091647SArun Thomas__DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d} 47e1091647SArun Thomas 482e304675SAnton Kuijsten.if defined(__MINIX) 492e304675SAnton Kuijsten__DPSRCS.bcd= ${"${USE_BITCODE:Uno}" == "yes":? ${SRCS:M*.c:O:u:.c=.bcd}:} 502e304675SAnton Kuijsten__DPSRCS.d+= ${__DPSRCS.bcd} 512e304675SAnton Kuijsten.endif # defined(__MINIX) 522e304675SAnton Kuijsten 53e1091647SArun Thomas.NOPATH: .depend ${__DPSRCS.d} 54e1091647SArun Thomas 55e1091647SArun Thomas.if !empty(__DPSRCS.d) # { 56e1091647SArun Thomas${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} 57e1091647SArun Thomas.endif # } 58e1091647SArun Thomas 5984d9c625SLionel SambucMKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q} 6084d9c625SLionel Sambuc 6184d9c625SLionel Sambuc.if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no" 6284d9c625SLionel Sambuc.STALE: 6384d9c625SLionel Sambuc @echo Rebuilding dependency file: ${.ALLSRC} 6484d9c625SLionel Sambuc @rm -f ${.ALLSRC} 6584d9c625SLionel Sambuc @(cd ${.CURDIR} && ${MAKE} depend) 6684d9c625SLionel Sambuc_MKDEP_MERGEFLAGS=-i 6784d9c625SLionel Sambuc_MKDEP_FILEFLAGS=${MKDEPSUFFLAGS} 6884d9c625SLionel Sambuc.else 6984d9c625SLionel Sambuc_MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS} 7084d9c625SLionel Sambuc_MKDEP_FILEFLAGS= 7184d9c625SLionel Sambuc.endif 7284d9c625SLionel Sambuc 73e1091647SArun Thomas.depend: ${__DPSRCS.d} 74e1091647SArun Thomas ${_MKTARGET_CREATE} 75e1091647SArun Thomas rm -f .depend 7684d9c625SLionel Sambuc ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d} 77e1091647SArun Thomas 7884d9c625SLionel Sambuc.if !defined(__MINIX) 7984d9c625SLionel Sambuc.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m 8084d9c625SLionel Sambuc.else 812e304675SAnton Kuijsten.SUFFIXES: .bcd .d .s .S .c .C .cc .cpp .cxx .m 822e304675SAnton Kuijsten 832e304675SAnton Kuijsten.if ${USE_BITCODE:Uno} == "yes" 842e304675SAnton Kuijsten.c.bcd: 852e304675SAnton Kuijsten ${_MKTARGET_CREATE} 862e304675SAnton Kuijsten ${MKDEP} -f ${.TARGET} -s .bc -- ${MKDEPFLAGS} \ 872e304675SAnton Kuijsten ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 882e304675SAnton Kuijsten ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 8984d9c625SLionel Sambuc.endif # ${USE_BITCODE:Uno} == "yes" 9084d9c625SLionel Sambuc.endif # !defined(__MINIX) 91e1091647SArun Thomas 92e1091647SArun Thomas.c.d: 93e1091647SArun Thomas ${_MKTARGET_CREATE} 9484d9c625SLionel Sambuc ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 95*0a6a1f1dSLionel Sambuc ${CFLAGS:M-std=*} ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 9684d9c625SLionel Sambuc ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 9784d9c625SLionel Sambuc ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ 9884d9c625SLionel Sambuc mv ${.TARGET}.tmp ${.TARGET} 99e1091647SArun Thomas 10006617e7fSArun Thomas.m.d: 10106617e7fSArun Thomas ${_MKTARGET_CREATE} 10284d9c625SLionel Sambuc ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 10306617e7fSArun Thomas ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 10484d9c625SLionel Sambuc ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 10584d9c625SLionel Sambuc ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ 10684d9c625SLionel Sambuc mv ${.TARGET}.tmp ${.TARGET} 107e1091647SArun Thomas 108e1091647SArun Thomas.s.d .S.d: 109e1091647SArun Thomas ${_MKTARGET_CREATE} 11084d9c625SLionel Sambuc ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 11106617e7fSArun Thomas ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 11284d9c625SLionel Sambuc ${CPPFLAGS} ${AFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} \ 11384d9c625SLionel Sambuc ${__acpp_flags} ${.IMPSRC} && \ 11484d9c625SLionel Sambuc mv ${.TARGET}.tmp ${.TARGET} 115e1091647SArun Thomas 11606617e7fSArun Thomas.C.d .cc.d .cpp.d .cxx.d: 11706617e7fSArun Thomas ${_MKTARGET_CREATE} 11884d9c625SLionel Sambuc ${MKDEPCXX} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 119*0a6a1f1dSLionel Sambuc ${CXXFLAGS:M-std=*} ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 12084d9c625SLionel Sambuc ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 12184d9c625SLionel Sambuc ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ 12284d9c625SLionel Sambuc mv ${.TARGET}.tmp ${.TARGET} 123e1091647SArun Thomas 12484d9c625SLionel Sambuc.endif # defined(SRCS) && !empty(SRCS) # } 125e1091647SArun Thomas 126e1091647SArun Thomas##### Clean rules 12784d9c625SLionel Sambuc.if defined(SRCS) && !empty(SRCS) 12884d9c625SLionel SambucCLEANDIRFILES+= .depend ${__DPSRCS.d} ${__DPSRCS.d:.d=.d.tmp} ${.CURDIR}/tags ${CLEANDEPEND} 129e1091647SArun Thomas.endif 130e1091647SArun Thomas 131e1091647SArun Thomas##### Custom rules 13206617e7fSArun Thomas.if !target(tags) 13306617e7fSArun Thomastags: ${SRCS} 13484d9c625SLionel Sambuc.if defined(SRCS) && !empty(SRCS) 135*0a6a1f1dSLionel Sambuc ${_MKTARGET_CREATE} 1369152e1c5SLionel Sambuc -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 13706617e7fSArun Thomas ${TOOL_SED} "s;\${.CURDIR}/;;" > tags 13806617e7fSArun Thomas.endif 13906617e7fSArun Thomas.endif 1409152e1c5SLionel Sambuc 1419152e1c5SLionel Sambuc##### Pull in related .mk logic 1429152e1c5SLionel Sambuc.include <bsd.clean.mk> 143