1# $NetBSD: bsd.dep.mk,v 1.79 2013/10/31 01:55:03 mrg Exp $ 2 3##### Basic targets 4realdepend: beforedepend .depend afterdepend 5.ORDER: beforedepend .depend afterdepend 6 7beforedepend .depend afterdepend: # ensure existence 8 9##### Default values 10MKDEP?= CC=${CC:Q} mkdep 11MKDEPCXX?= CC=${CXX:Q} mkdep 12MKDEP_SUFFIXES?= .o 13 14##### Build rules 15# some of the rules involve .h sources, so remove them from mkdep line 16 17.if defined(SRCS) && !empty(SRCS) 18__acpp_flags= ${_ASM_TRADITIONAL_CPP} 19 20.if defined(NODPSRCS) 21.for f in ${SRCS} ${DPSRCS} 22.if "${NODPSRCS:M${f}}" == "" 23__DPSRCS.all+= ${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 24.endif 25.endfor 26beforedepend: ${DPSRCS} 27.else 28__DPSRCS.all+= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ 29 ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 30.endif 31__DPSRCS.d= ${__DPSRCS.all:O:u:M*.d} 32__DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d} 33 34.if defined(__MINIX) 35__DPSRCS.bcd= ${"${USE_BITCODE:Uno}" == "yes":? ${SRCS:M*.c:O:u:.c=.bcd}:} 36__DPSRCS.d+= ${__DPSRCS.bcd} 37.endif # defined(__MINIX) 38 39.NOPATH: .depend ${__DPSRCS.d} 40 41.if !empty(__DPSRCS.d) # { 42${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} 43.endif # } 44 45MKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q} 46 47.if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no" 48.STALE: 49 @echo Rebuilding dependency file: ${.ALLSRC} 50 @rm -f ${.ALLSRC} 51 @(cd ${.CURDIR} && ${MAKE} depend) 52_MKDEP_MERGEFLAGS=-i 53_MKDEP_FILEFLAGS=${MKDEPSUFFLAGS} 54.else 55_MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS} 56_MKDEP_FILEFLAGS= 57.endif 58 59.depend: ${__DPSRCS.d} 60 ${_MKTARGET_CREATE} 61 rm -f .depend 62 ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d} 63 64.if !defined(__MINIX) 65.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m 66.else 67.SUFFIXES: .bcd .d .s .S .c .C .cc .cpp .cxx .m 68 69.if ${USE_BITCODE:Uno} == "yes" 70.c.bcd: 71 ${_MKTARGET_CREATE} 72 ${MKDEP} -f ${.TARGET} -s .bc -- ${MKDEPFLAGS} \ 73 ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 74 ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 75.endif # ${USE_BITCODE:Uno} == "yes" 76.endif # !defined(__MINIX) 77 78.c.d: 79 ${_MKTARGET_CREATE} 80 ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 81 ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 82 ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 83 ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ 84 mv ${.TARGET}.tmp ${.TARGET} 85 86.m.d: 87 ${_MKTARGET_CREATE} 88 ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 89 ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 90 ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 91 ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ 92 mv ${.TARGET}.tmp ${.TARGET} 93 94.s.d .S.d: 95 ${_MKTARGET_CREATE} 96 ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 97 ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 98 ${CPPFLAGS} ${AFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} \ 99 ${__acpp_flags} ${.IMPSRC} && \ 100 mv ${.TARGET}.tmp ${.TARGET} 101 102.C.d .cc.d .cpp.d .cxx.d: 103 ${_MKTARGET_CREATE} 104 ${MKDEPCXX} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 105 ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 106 ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 107 ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \ 108 mv ${.TARGET}.tmp ${.TARGET} 109 110.endif # defined(SRCS) && !empty(SRCS) # } 111 112##### Clean rules 113.if defined(SRCS) && !empty(SRCS) 114CLEANDIRFILES+= .depend ${__DPSRCS.d} ${__DPSRCS.d:.d=.d.tmp} ${.CURDIR}/tags ${CLEANDEPEND} 115.endif 116 117##### Custom rules 118.if !target(tags) 119tags: ${SRCS} 120.if defined(SRCS) && !empty(SRCS) 121 -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 122 ${TOOL_SED} "s;\${.CURDIR}/;;" > tags 123.endif 124.endif 125 126##### Pull in related .mk logic 127.include <bsd.clean.mk> 128