bridge(4): document net.link.bridge.pfil_onlyip
[dragonfly.git] / share / mk / bsd.dep.mk
blobf451f232c5bf5d0f94a642121a514d9d50a0b5b8
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 # MKDEPCC CC to be used in ${MKDEPCMD} script [cc]
22 # MKDEPCMD Makefile dependency list program [mkdep]
24 # MKDEPINTDEPS Extra internal dependencies for intermediates [not set]
26 # SRCS List of source files (c, c++, assembler)
29 # +++ targets +++
31 # cleandepend:
32 # Remove depend and tags file
34 # depend:
35 # Make the dependencies for the source files, and store
36 # them in the file ${DEPENDFILE}.
38 # tags:
39 # In "ctags" mode, create a tags file for the source files.
40 # In "gtags" mode, create a (GLOBAL) gtags file for the
41 # source files. If HTML is defined, htags(1) is also run
42 # after gtags(1).
44 .if !target(__<bsd.init.mk>__)
45 .error bsd.dep.mk cannot be included directly.
46 .endif
48 CTAGS?= gtags
49 CTAGSFLAGS?=
50 GTAGSFLAGS?= -o
51 HTAGSFLAGS?=
53 MKDEPCMD?= mkdep
54 MKDEPCC?= ${CC}
55 DEPENDFILE?= .depend
57 # Support better dependencies tracking for both host cc and target cc.
58 .if defined(__USE_HOST_CCVER)
59 _MKDEPENV= ${NXENV:NPATH=*}
60 .else
61 _MKDEPENV= CCVER=${CCVER}
62 .endif
64 # Keep `tags' here, before SRCS are mangled below for `depend'.
65 .if !target(tags) && defined(SRCS) && !defined(NOTAGS)
66 tags: ${SRCS}
67 .if ${CTAGS:T} == "ctags"
68 @${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \
69 ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET}
70 .elif ${CTAGS:T} == "gtags"
71 @cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR}
72 .if defined(HTML)
73 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
74 .endif
75 .endif
76 .endif
78 .if defined(SRCS)
79 CLEANFILES?=
81 .for _LSRC in ${SRCS:M*.l:N*/*}
82 .for _LC in ${_LSRC:R}.c
83 ${_LC}: ${_LSRC}
84 ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
85 SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
86 CLEANFILES+= ${_LC}
87 .endfor
88 .endfor
90 .for _YSRC in ${SRCS:M*.y:N*/*}
91 .for _YC in ${_YSRC:R}.c
92 SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
93 CLEANFILES+= ${_YC}
94 .if !empty(YFLAGS:M-d) && !empty(SRCS:My.tab.h)
95 .ORDER: ${_YC} y.tab.h
96 ${_YC} y.tab.h: ${_YSRC}
97 ${YACC} ${YFLAGS} ${.ALLSRC}
98 cp y.tab.c ${_YC}
99 CLEANFILES+= y.tab.c y.tab.h
100 .elif !empty(YFLAGS:M-d)
101 .for _YH in ${_YC:S/.c/.h/}
102 ${_YH}: ${_YC}
103 ${_YC}: ${_YSRC}
104 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
105 SRCS+= ${_YH}
106 CLEANFILES+= ${_YH}
107 .endfor
108 .else
109 ${_YC}: ${_YSRC}
110 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
111 .endif
112 .endfor
113 .endfor
114 .endif
116 .if !target(depend)
117 .if defined(SRCS)
118 depend: beforedepend _dependincs ${DEPENDFILE} afterdepend
120 # Tell bmake not to look for generated files via .PATH
121 .NOPATH: ${DEPENDFILE}
123 # Different types of sources are compiled with slightly different flags.
124 # Split up the sources, and filter out headers and non-applicable flags.
125 # Separate flag groups out of the sources and treat them differently.
126 # The special "_" group is for all files not in any group.
127 __FLAGS=
128 __FLAGS_FILES= ${SRCS}
129 .for _FG in ${FLAGS_GROUPS}
130 .for _FFILE in ${${_FG}_FLAGS_FILES}
131 __FLAGS_FILES:= ${__FLAGS_FILES:N${_FFILE}}
132 .endfor
133 .endfor
135 _DEPENDFILES= ${FLAGS_GROUPS:S/^/.depend_/g}
137 ${DEPENDFILE}: ${_DEPENDFILES}
140 # __FLAG_FILES is built from SRCS. That means it will contain
141 # also .h files and other files that are not direct sources, but which
142 # might be required to even run mkdep. This is important if those are
143 # generated as well, like some forwarding headers.
145 # We'll have to pass these "sources" on to the other .depend_ file targets,
146 # since otherwise they might be run before the generated sources are
147 # generated. _ALL_DEPENDS captures all files in SRCS that are not handled
148 # by the mkdep calls, i.e. all sources that are not being used directly
149 # for the .depend* file.
151 _ALL_DEPENDS=${__FLAGS_FILES:N*.[sS]:N*.c:N*.cc:N*.C:N*.cpp:N*.cpp:N*.cxx:N*.m}
153 .for _FG in _ ${FLAGS_GROUPS}
154 .depend${_FG:S/^/_/:N__}: ${${_FG}_FLAGS_FILES} ${_ALL_DEPENDS}
155 -rm -f ${.TARGET}
156 -> ${.TARGET}
157 .if ${${_FG}_FLAGS_FILES:M*.[csS]} != ""
158 ${_MKDEPENV} CC=${MKDEPCC} ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
159 ${${_FG}_FLAGS} \
160 ${CFLAGS:M--sysroot=*} \
161 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
162 ${CFLAGS:M-std=*} \
163 ${.ALLSRC:M*.[csS]}
164 .endif
165 .if ${${_FG}_FLAGS_FILES:M*.cc} != "" || \
166 ${${_FG}_FLAGS_FILES:M*.C} != "" || \
167 ${${_FG}_FLAGS_FILES:M*.cpp} != "" || \
168 ${${_FG}_FLAGS_FILES:M*.cxx} != ""
169 ${_MKDEPENV} CC=${CXX} ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
170 ${${_FG}_FLAGS} \
171 ${CXXFLAGS:M--sysroot=*} \
172 ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
173 ${CXXFLAGS:M-std=*} \
174 ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
175 .endif
176 .if ${${_FG}_FLAGS_FILES:M*.m} != ""
177 ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
178 ${${_FG}_FLAGS} \
179 ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
180 ${OBJCFLAGS:M-Wno-import*} \
181 ${.ALLSRC:M*.m}
182 .endif
183 .if !empty(${_FG:M_}) && !empty(_DEPENDFILES)
184 cat ${_DEPENDFILES} >> ${.TARGET}
185 .endif
186 .if defined(MKDEPINTDEPS) && !empty(MKDEPINTDEPS)
187 . for _ITD in ${MKDEPINTDEPS:O:u}
188 TMP=_depend$$$$; \
189 sed -e "s,${_ITD:C/^(.*:)(.*)/\1,\2 \1/},g" < ${.TARGET} > $$TMP; \
190 mv $$TMP ${.TARGET}
191 . endfor
192 .endif
193 .endfor
195 .if target(_EXTRADEPEND)
196 _EXTRADEPEND: .USE
197 ${DEPENDFILE}: _EXTRADEPEND
198 .endif
200 .else
201 depend: beforedepend _dependincs afterdepend
202 .endif
203 .if !target(beforedepend)
204 beforedepend:
205 .endif
206 .if !target(afterdepend)
207 afterdepend:
208 .endif
209 .endif
211 .if !target(cleandepend)
212 cleandepend:
213 .if defined(SRCS)
214 .if ${CTAGS:T} == "ctags"
215 rm -f ${DEPENDFILE} ${_DEPENDFILES} tags
216 .elif ${CTAGS:T} == "gtags"
217 rm -f ${DEPENDFILE} ${_DEPENDFILES} GPATH GRTAGS GSYMS GTAGS
218 .if defined(HTML)
219 rm -rf HTML
220 .endif
221 .endif
222 .endif
223 .endif
225 .if !target(checkdpadd) && (defined(DPADD) || defined(LDADD))
226 checkdpadd:
227 .if ${OBJFORMAT} != aout
228 @ldadd=`echo \`for lib in ${DPADD} ; do \
229 echo $$lib | sed 's;^/usr/lib/lib\(.*\)\.a;-l\1;' ; \
230 done \`` ; \
231 ldadd1=`echo ${LDADD}` ; \
232 if [ "$$ldadd" != "$$ldadd1" ] ; then \
233 echo ${.CURDIR} ; \
234 echo "DPADD -> $$ldadd" ; \
235 echo "LDADD -> $$ldadd1" ; \
237 .else
238 @dpadd=`echo \`ld -Bstatic -f ${LDADD}\`` ; \
239 if [ "$$dpadd" != "${DPADD}" ] ; then \
240 echo ${.CURDIR} ; \
241 echo "LDADD -> $$dpadd" ; \
242 echo "DPADD = ${DPADD}" ; \
244 .endif
245 .endif
247 .if defined(INCS) && make(depend)
248 _dependincs: buildincludes .WAIT installincludes
249 .else
250 _dependincs:
251 .endif
253 .ORDER: beforedepend _dependincs ${DEPENDFILE} afterdepend