bsd.dep.mk revision 1.88 1 1.88 christos # $NetBSD: bsd.dep.mk,v 1.88 2021/12/14 16:22:07 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.78 mrg MKDEPCXX?= mkdep
12 1.82 erh MKDEP_SUFFIXES?= .o .d
13 1.1 mycroft
14 1.33 tv ##### Build rules
15 1.1 mycroft # some of the rules involve .h sources, so remove them from mkdep line
16 1.33 tv
17 1.75 apb .if defined(SRCS) && !empty(SRCS)
18 1.70 joerg __acpp_flags= ${_ASM_TRADITIONAL_CPP}
19 1.48 lukem
20 1.74 matt .if defined(NODPSRCS)
21 1.74 matt .for f in ${SRCS} ${DPSRCS}
22 1.74 matt .if "${NODPSRCS:M${f}}" == ""
23 1.74 matt __DPSRCS.all+= ${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
24 1.74 matt .endif
25 1.74 matt .endfor
26 1.74 matt beforedepend: ${DPSRCS}
27 1.74 matt .else
28 1.74 matt __DPSRCS.all+= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \
29 1.55 lukem ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
30 1.74 matt .endif
31 1.55 lukem __DPSRCS.d= ${__DPSRCS.all:O:u:M*.d}
32 1.55 lukem __DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d}
33 1.48 lukem
34 1.55 lukem .NOPATH: .depend ${__DPSRCS.d}
35 1.53 lukem
36 1.56 martin .if !empty(__DPSRCS.d) # {
37 1.55 lukem ${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
38 1.56 martin .endif # }
39 1.55 lukem
40 1.76 christos MKDEPSUFFLAGS=-s ${MKDEP_SUFFIXES:Q}
41 1.76 christos
42 1.76 christos .if defined(MKDEPINCLUDES) && ${MKDEPINCLUDES} != "no"
43 1.77 christos .STALE:
44 1.77 christos @echo Rebuilding dependency file: ${.ALLSRC}
45 1.77 christos @rm -f ${.ALLSRC}
46 1.77 christos @(cd ${.CURDIR} && ${MAKE} depend)
47 1.76 christos _MKDEP_MERGEFLAGS=-i
48 1.76 christos _MKDEP_FILEFLAGS=${MKDEPSUFFLAGS}
49 1.76 christos .else
50 1.76 christos _MKDEP_MERGEFLAGS=${MKDEPSUFFLAGS}
51 1.76 christos _MKDEP_FILEFLAGS=
52 1.76 christos .endif
53 1.76 christos
54 1.55 lukem .depend: ${__DPSRCS.d}
55 1.60 lukem ${_MKTARGET_CREATE}
56 1.58 lukem rm -f .depend
57 1.76 christos ${MKDEP} ${_MKDEP_MERGEFLAGS} -d -f ${.TARGET} ${__DPSRCS.d}
58 1.39 christos
59 1.57 lukem .SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m
60 1.49 lukem
61 1.51 lukem .c.d:
62 1.60 lukem ${_MKTARGET_CREATE}
63 1.79 mrg ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
64 1.88 christos ${CFLAGS:M-std=*} ${CFLAGS:C/-([IDUW])[ ]*/-\1/Wg:M-[IDUW]*} \
65 1.83 christos ${CPPFLAGS:N-Wp,-iremap,*} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
66 1.79 mrg ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \
67 1.84 christos ${MV} ${.TARGET}.tmp ${.TARGET}
68 1.39 christos
69 1.51 lukem .m.d:
70 1.60 lukem ${_MKTARGET_CREATE}
71 1.79 mrg ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
72 1.88 christos ${OBJCFLAGS:C/-([IDUW])[ ]*/-\1/Wg:M-[IDUW]*} \
73 1.83 christos ${CPPFLAGS:N-Wp,-iremap,*} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
74 1.79 mrg ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \
75 1.84 christos ${MV} ${.TARGET}.tmp ${.TARGET}
76 1.39 christos
77 1.51 lukem .s.d .S.d:
78 1.60 lukem ${_MKTARGET_CREATE}
79 1.79 mrg ${MKDEP} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
80 1.88 christos ${AFLAGS:C/-([IDUW])[ ]*/-\1/Wg:M-[IDUW]*} \
81 1.83 christos ${CPPFLAGS:N-Wp,-iremap,*} ${AFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} \
82 1.79 mrg ${__acpp_flags} ${.IMPSRC} && \
83 1.84 christos ${MV} ${.TARGET}.tmp ${.TARGET}
84 1.39 christos
85 1.51 lukem .C.d .cc.d .cpp.d .cxx.d:
86 1.60 lukem ${_MKTARGET_CREATE}
87 1.79 mrg ${MKDEPCXX} -f ${.TARGET}.tmp ${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
88 1.88 christos ${CXXFLAGS:M-std=*} ${CXXFLAGS:C/-([IDUW])[ ]*/-\1/Wg:M-[IDUW]*} \
89 1.83 christos ${CPPFLAGS:N-Wp,-iremap,*} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} \
90 1.79 mrg ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} && \
91 1.84 christos ${MV} ${.TARGET}.tmp ${.TARGET}
92 1.39 christos
93 1.75 apb .endif # defined(SRCS) && !empty(SRCS) # }
94 1.33 tv
95 1.33 tv ##### Clean rules
96 1.75 apb .if defined(SRCS) && !empty(SRCS)
97 1.87 lukem CLEANDIRFILES+= .depend ${__DPSRCS.d} ${__DPSRCS.d:.d=.d.tmp} tags ${CLEANDEPEND}
98 1.3 mycroft .endif
99 1.2 mycroft
100 1.33 tv ##### Custom rules
101 1.87 lukem .if !commands(tags)
102 1.33 tv tags: ${SRCS}
103 1.75 apb .if defined(SRCS) && !empty(SRCS)
104 1.80 matt ${_MKTARGET_CREATE}
105 1.87 lukem -cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:M*.[cly]} | \
106 1.87 lukem ${TOOL_SED} "s;\${.CURDIR}/;;" > ${.OBJDIR}/tags
107 1.4 mycroft .endif
108 1.4 mycroft .endif
109 1.73 apb
110 1.73 apb ##### Pull in related .mk logic
111 1.73 apb .include <bsd.clean.mk>
112