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