bsd.dep.mk revision 1.77
1# $NetBSD: bsd.dep.mk,v 1.77 2013/03/05 21:59:01 christos 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 11MKDEP_SUFFIXES?= .o 12 13##### Build rules 14# some of the rules involve .h sources, so remove them from mkdep line 15 16.if defined(SRCS) && !empty(SRCS) 17__acpp_flags= ${_ASM_TRADITIONAL_CPP} 18 19.if defined(NODPSRCS) 20.for f in ${SRCS} ${DPSRCS} 21.if "${NODPSRCS:M${f}}" == "" 22__DPSRCS.all+= ${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 23.endif 24.endfor 25beforedepend: ${DPSRCS} 26.else 27__DPSRCS.all+= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ 28 ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 29.endif 30__DPSRCS.d= ${__DPSRCS.all:O:u:M*.d} 31__DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d} 32 33.NOPATH: .depend ${__DPSRCS.d} 34 35.if !empty(__DPSRCS.d) # { 36${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} 37.endif # } 38 39MKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q} 40 41.if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no" 42.STALE: 43 @echo Rebuilding dependency file: ${.ALLSRC} 44 @rm -f ${.ALLSRC} 45 @(cd ${.CURDIR} && ${MAKE} depend) 46_MKDEP_MERGEFLAGS=-i 47_MKDEP_FILEFLAGS=${MKDEPSUFFLAGS} 48.else 49_MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS} 50_MKDEP_FILEFLAGS= 51.endif 52 53.depend: ${__DPSRCS.d} 54 ${_MKTARGET_CREATE} 55 rm -f .depend 56 ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d} 57 58.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m 59 60.c.d: 61 ${_MKTARGET_CREATE} 62 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 63 ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 64 ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 65 66.m.d: 67 ${_MKTARGET_CREATE} 68 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 69 ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 70 ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 71 72.s.d .S.d: 73 ${_MKTARGET_CREATE} 74 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 75 ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 76 ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${.IMPSRC} 77 78.C.d .cc.d .cpp.d .cxx.d: 79 ${_MKTARGET_CREATE} 80 ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 81 ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 82 ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 83 84.endif # defined(SRCS) && !empty(SRCS) # } 85 86##### Clean rules 87.if defined(SRCS) && !empty(SRCS) 88CLEANDIRFILES+= .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND} 89.endif 90 91##### Custom rules 92.if !target(tags) 93tags: ${SRCS} 94.if defined(SRCS) && !empty(SRCS) 95 -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 96 ${TOOL_SED} "s;\${.CURDIR}/;;" > tags 97.endif 98.endif 99 100##### Pull in related .mk logic 101.include <bsd.clean.mk> 102