debug - Update kmapinfo, zallocinfo, slabinfo
[dragonfly.git] / share / mk / bsd.dep.mk
blob7b191e2840ae945d444b86d9f08951cbc00e2ea2
1 # $FreeBSD: src/share/mk/bsd.dep.mk,v 1.27.2.3 2002/12/23 16:33:37 ru Exp $
3 # The include file <bsd.dep.mk> handles Makefile dependencies.
6 # +++ variables +++
8 # CTAGS A tags file generation program [gtags]
10 # CTAGSFLAGS Options for ctags(1) [not set]
12 # DEPENDFILE dependencies file [.depend]
14 # GTAGSFLAGS Options for gtags(1) [-o]
16 # HTAGSFLAGS Options for htags(1) [not set]
18 # MKDEP Options for ${MKDEPCMD} [not set]
20 # MKDEPCMD Makefile dependency list program [mkdep]
22 # SRCS List of source files (c, c++, assembler)
25 # +++ targets +++
27 # cleandepend:
28 # Remove depend and tags file
30 # depend:
31 # Make the dependencies for the source files, and store
32 # them in the file ${DEPENDFILE}.
34 # tags:
35 # In "ctags" mode, create a tags file for the source files.
36 # In "gtags" mode, create a (GLOBAL) gtags file for the
37 # source files. If HTML is defined, htags(1) is also run
38 # after gtags(1).
40 .if !target(__<bsd.init.mk>__)
41 .error bsd.dep.mk cannot be included directly.
42 .endif
44 CTAGS?= gtags
45 CTAGSFLAGS?=
46 GTAGSFLAGS?= -o
47 HTAGSFLAGS?=
49 MKDEPCMD?= mkdep
50 DEPENDFILE?= .depend
52 # Keep `tags' here, before SRCS are mangled below for `depend'.
53 .if !target(tags) && defined(SRCS) && !defined(NOTAGS)
54 tags: ${SRCS}
55 .if ${CTAGS:T} == "ctags"
56 @${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \
57 ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET}
58 .elif ${CTAGS:T} == "gtags"
59 @cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR}
60 .if defined(HTML)
61 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
62 .endif
63 .endif
64 .endif
66 .if defined(SRCS)
67 CLEANFILES?=
69 .for _LSRC in ${SRCS:M*.l:N*/*}
70 .for _LC in ${_LSRC:R}.c
71 ${_LC}: ${_LSRC}
72 ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
73 SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
74 CLEANFILES+= ${_LC}
75 .endfor
76 .endfor
78 .for _YSRC in ${SRCS:M*.y:N*/*}
79 .for _YC in ${_YSRC:R}.c
80 SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
81 CLEANFILES+= ${_YC}
82 .if !empty(YFLAGS:M-d) && !empty(SRCS:My.tab.h)
83 .ORDER: ${_YC} y.tab.h
84 ${_YC} y.tab.h: ${_YSRC}
85 ${YACC} ${YFLAGS} ${.ALLSRC}
86 cp y.tab.c ${_YC}
87 CLEANFILES+= y.tab.c y.tab.h
88 .elif !empty(YFLAGS:M-d)
89 .for _YH in ${_YC:S/.c/.h/}
90 ${_YH}: ${_YC}
91 ${_YC}: ${_YSRC}
92 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
93 SRCS+= ${_YH}
94 CLEANFILES+= ${_YH}
95 .endfor
96 .else
97 ${_YC}: ${_YSRC}
98 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
99 .endif
100 .endfor
101 .endfor
102 .endif
104 .if !target(depend)
105 .if defined(SRCS)
106 depend: beforedepend _dependincs ${DEPENDFILE} afterdepend
108 # Tell bmake not to look for generated files via .PATH
109 .NOPATH: ${DEPENDFILE}
111 # Different types of sources are compiled with slightly different flags.
112 # Split up the sources, and filter out headers and non-applicable flags.
113 # Separate flag groups out of the sources and treat them differently.
114 # The special "_" group is for all files not in any group.
115 __FLAGS=
116 __FLAGS_FILES= ${SRCS}
117 .for _FG in ${FLAGS_GROUPS}
118 .for _FFILE in ${${_FG}_FLAGS_FILES}
119 __FLAGS_FILES:= ${__FLAGS_FILES:N${_FFILE}}
120 .endfor
121 .endfor
123 _DEPENDFILES= ${FLAGS_GROUPS:S/^/.depend_/g}
125 ${DEPENDFILE}: ${_DEPENDFILES}
128 # __FLAG_FILES is built from SRCS. That means it will contain
129 # also .h files and other files that are not direct sources, but which
130 # might be required to even run mkdep. This is important if those are
131 # generated as well, like some forwarding headers.
133 # We'll have to pass these "sources" on to the other .depend_ file targets,
134 # since otherwise they might be run before the generated sources are
135 # generated. _ALL_DEPENDS captures all files in SRCS that are not handled
136 # by the mkdep calls, i.e. all sources that are not being used directly
137 # for the .depend* file.
139 _ALL_DEPENDS=${__FLAGS_FILES:N*.[sS]:N*.c:N*.cc:N*.C:N*.cpp:N*.cpp:N*.cxx:N*.m}
141 .for _FG in _ ${FLAGS_GROUPS}
142 .depend${_FG:S/^/_/:N__}: ${${_FG}_FLAGS_FILES} ${_ALL_DEPENDS}
143 -rm -f ${.TARGET}
144 -> ${.TARGET}
145 .if ${${_FG}_FLAGS_FILES:M*.[csS]} != ""
146 ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
147 ${${_FG}_FLAGS} \
148 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
149 ${CFLAGS:M-std=*} \
150 ${.ALLSRC:M*.[csS]}
151 .endif
152 .if ${${_FG}_FLAGS_FILES:M*.cc} != "" || \
153 ${${_FG}_FLAGS_FILES:M*.C} != "" || \
154 ${${_FG}_FLAGS_FILES:M*.cpp} != "" || \
155 ${${_FG}_FLAGS_FILES:M*.cxx} != ""
156 ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
157 ${${_FG}_FLAGS} \
158 ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
159 ${CXXFLAGS:M-std=*} \
160 ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
161 .endif
162 .if ${${_FG}_FLAGS_FILES:M*.m} != ""
163 ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
164 ${${_FG}_FLAGS} \
165 ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
166 ${OBJCFLAGS:M-Wno-import*} \
167 ${.ALLSRC:M*.m}
168 .endif
169 .if !empty(${_FG:M_}) && !empty(_DEPENDFILES)
170 cat ${_DEPENDFILES} >> ${.TARGET}
171 .endif
172 .endfor
174 .if target(_EXTRADEPEND)
175 _EXTRADEPEND: .USE
176 ${DEPENDFILE}: _EXTRADEPEND
177 .endif
179 .else
180 depend: beforedepend _dependincs afterdepend
181 .endif
182 .if !target(beforedepend)
183 beforedepend:
184 .endif
185 .if !target(afterdepend)
186 afterdepend:
187 .endif
188 .endif
190 .if !target(cleandepend)
191 cleandepend:
192 .if defined(SRCS)
193 .if ${CTAGS:T} == "ctags"
194 rm -f ${DEPENDFILE} ${_DEPENDFILES} tags
195 .elif ${CTAGS:T} == "gtags"
196 rm -f ${DEPENDFILE} ${_DEPENDFILES} GPATH GRTAGS GSYMS GTAGS
197 .if defined(HTML)
198 rm -rf HTML
199 .endif
200 .endif
201 .endif
202 .endif
204 .if !target(checkdpadd) && (defined(DPADD) || defined(LDADD))
205 checkdpadd:
206 .if ${OBJFORMAT} != aout
207 @ldadd=`echo \`for lib in ${DPADD} ; do \
208 echo $$lib | sed 's;^/usr/lib/lib\(.*\)\.a;-l\1;' ; \
209 done \`` ; \
210 ldadd1=`echo ${LDADD}` ; \
211 if [ "$$ldadd" != "$$ldadd1" ] ; then \
212 echo ${.CURDIR} ; \
213 echo "DPADD -> $$ldadd" ; \
214 echo "LDADD -> $$ldadd1" ; \
216 .else
217 @dpadd=`echo \`ld -Bstatic -f ${LDADD}\`` ; \
218 if [ "$$dpadd" != "${DPADD}" ] ; then \
219 echo ${.CURDIR} ; \
220 echo "LDADD -> $$dpadd" ; \
221 echo "DPADD = ${DPADD}" ; \
223 .endif
224 .endif
226 .if defined(INCS) && make(depend)
227 _dependincs: buildincludes .WAIT installincludes
228 .else
229 _dependincs:
230 .endif
232 .ORDER: beforedepend _dependincs ${DEPENDFILE} afterdepend