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