bsd.dep.mk revision 1.78
1# $NetBSD: bsd.dep.mk,v 1.78 2013/10/28 01:47:13 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?= mkdep 11MKDEPCXX?= 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.NOPATH: .depend ${__DPSRCS.d} 35 36.if !empty(__DPSRCS.d) # { 37${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} 38.endif # } 39 40MKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q} 41 42.if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no" 43.STALE: 44 @echo Rebuilding dependency file: ${.ALLSRC} 45 @rm -f ${.ALLSRC} 46 @(cd ${.CURDIR} && ${MAKE} depend) 47_MKDEP_MERGEFLAGS=-i 48_MKDEP_FILEFLAGS=${MKDEPSUFFLAGS} 49.else 50_MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS} 51_MKDEP_FILEFLAGS= 52.endif 53 54.depend: ${__DPSRCS.d} 55 ${_MKTARGET_CREATE} 56 rm -f .depend 57 ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d} 58 59.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m 60 61.c.d: 62 ${_MKTARGET_CREATE} 63 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 64 ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 65 ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 66 ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 67 68.m.d: 69 ${_MKTARGET_CREATE} 70 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 71 ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 72 ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 73 ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 74 75.s.d .S.d: 76 ${_MKTARGET_CREATE} 77 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 78 ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 79 ${CPPFLAGS} ${AFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} \ 80 ${__acpp_flags} ${.IMPSRC} 81 82.C.d .cc.d .cpp.d .cxx.d: 83 ${_MKTARGET_CREATE} 84 ${MKDEPCXX} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 85 ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 86 ${CPPFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \ 87 ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 88 89.endif # defined(SRCS) && !empty(SRCS) # } 90 91##### Clean rules 92.if defined(SRCS) && !empty(SRCS) 93CLEANDIRFILES+= .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND} 94.endif 95 96##### Custom rules 97.if !target(tags) 98tags: ${SRCS} 99.if defined(SRCS) && !empty(SRCS) 100 -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 101 ${TOOL_SED} "s;\${.CURDIR}/;;" > tags 102.endif 103.endif 104 105##### Pull in related .mk logic 106.include <bsd.clean.mk> 107