1 1.77 christos # $NetBSD: bsd.dep.mk,v 1.77 2013/03/05 21:59:01 christos Exp $ 2 1.13 gwr 3 1.33 tv ##### Basic targets 4 1.33 tv realdepend: beforedepend .depend afterdepend 5 1.33 tv .ORDER: beforedepend .depend afterdepend 6 1.14 mycroft 7 1.33 tv beforedepend .depend afterdepend: # ensure existence 8 1.33 tv 9 1.33 tv ##### Default values 10 1.63 dsl MKDEP?= mkdep 11 1.63 dsl MKDEP_SUFFIXES?= .o 12 1.1 mycroft 13 1.33 tv ##### Build rules 14 1.1 mycroft # some of the rules involve .h sources, so remove them from mkdep line 15 1.33 tv 16 1.75 apb .if defined(SRCS) && !empty(SRCS) 17 1.70 joerg __acpp_flags= ${_ASM_TRADITIONAL_CPP} 18 1.48 lukem 19 1.74 matt .if defined(NODPSRCS) 20 1.74 matt .for f in ${SRCS} ${DPSRCS} 21 1.74 matt .if "${NODPSRCS:M${f}}" == "" 22 1.74 matt __DPSRCS.all+= ${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 23 1.74 matt .endif 24 1.74 matt .endfor 25 1.74 matt beforedepend: ${DPSRCS} 26 1.74 matt .else 27 1.74 matt __DPSRCS.all+= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ 28 1.55 lukem ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} 29 1.74 matt .endif 30 1.55 lukem __DPSRCS.d= ${__DPSRCS.all:O:u:M*.d} 31 1.55 lukem __DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d} 32 1.48 lukem 33 1.55 lukem .NOPATH: .depend ${__DPSRCS.d} 34 1.53 lukem 35 1.56 martin .if !empty(__DPSRCS.d) # { 36 1.55 lukem ${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} 37 1.56 martin .endif # } 38 1.55 lukem 39 1.76 christos MKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q} 40 1.76 christos 41 1.76 christos .if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no" 42 1.77 christos .STALE: 43 1.77 christos @echo Rebuilding dependency file: ${.ALLSRC} 44 1.77 christos @rm -f ${.ALLSRC} 45 1.77 christos @(cd ${.CURDIR} && ${MAKE} depend) 46 1.76 christos _MKDEP_MERGEFLAGS=-i 47 1.76 christos _MKDEP_FILEFLAGS=${MKDEPSUFFLAGS} 48 1.76 christos .else 49 1.76 christos _MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS} 50 1.76 christos _MKDEP_FILEFLAGS= 51 1.76 christos .endif 52 1.76 christos 53 1.55 lukem .depend: ${__DPSRCS.d} 54 1.60 lukem ${_MKTARGET_CREATE} 55 1.58 lukem rm -f .depend 56 1.76 christos ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d} 57 1.39 christos 58 1.57 lukem .SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m 59 1.49 lukem 60 1.51 lukem .c.d: 61 1.60 lukem ${_MKTARGET_CREATE} 62 1.76 christos ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 63 1.65 lukem ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 64 1.65 lukem ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 65 1.39 christos 66 1.51 lukem .m.d: 67 1.60 lukem ${_MKTARGET_CREATE} 68 1.76 christos ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 69 1.65 lukem ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 70 1.49 lukem ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 71 1.39 christos 72 1.51 lukem .s.d .S.d: 73 1.60 lukem ${_MKTARGET_CREATE} 74 1.76 christos ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 75 1.65 lukem ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 76 1.67 lukem ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${.IMPSRC} 77 1.39 christos 78 1.51 lukem .C.d .cc.d .cpp.d .cxx.d: 79 1.60 lukem ${_MKTARGET_CREATE} 80 1.76 christos ${MKDEP} -f ${.TARGET} ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \ 81 1.65 lukem ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ 82 1.49 lukem ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 83 1.39 christos 84 1.75 apb .endif # defined(SRCS) && !empty(SRCS) # } 85 1.33 tv 86 1.33 tv ##### Clean rules 87 1.75 apb .if defined(SRCS) && !empty(SRCS) 88 1.73 apb CLEANDIRFILES+= .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND} 89 1.3 mycroft .endif 90 1.2 mycroft 91 1.33 tv ##### Custom rules 92 1.2 mycroft .if !target(tags) 93 1.33 tv tags: ${SRCS} 94 1.75 apb .if defined(SRCS) && !empty(SRCS) 95 1.69 christos -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 96 1.68 apb ${TOOL_SED} "s;\${.CURDIR}/;;" > tags 97 1.4 mycroft .endif 98 1.4 mycroft .endif 99 1.73 apb 100 1.73 apb ##### Pull in related .mk logic 101 1.73 apb .include <bsd.clean.mk> 102