xref: /freebsd/share/mk/bsd.dep.mk (revision 3d04f5a9c4afad32a9972693928ccc63f4b7441f)
17f3dea24SPeter Wemm# $FreeBSD$
253996fadSWolfram Schneider#
353996fadSWolfram Schneider# The include file <bsd.dep.mk> handles Makefile dependencies.
453996fadSWolfram Schneider#
553996fadSWolfram Schneider#
653996fadSWolfram Schneider# +++ variables +++
753996fadSWolfram Schneider#
8ae038fc3SBryan Drewery# CLEANDEPENDDIRS	Additional directories to remove for the cleandepend
9ae038fc3SBryan Drewery# 			target.
10ae038fc3SBryan Drewery#
11ae038fc3SBryan Drewery# CLEANDEPENDFILES	Additional files to remove for the cleandepend target.
12ae038fc3SBryan Drewery#
13ccc4bab1SRuslan Ermilov# CTAGS		A tags file generation program [gtags]
14ccc4bab1SRuslan Ermilov#
15ccc4bab1SRuslan Ermilov# CTAGSFLAGS	Options for ctags(1) [not set]
16ccc4bab1SRuslan Ermilov#
1753996fadSWolfram Schneider# DEPENDFILE	dependencies file [.depend]
1853996fadSWolfram Schneider#
19ccc4bab1SRuslan Ermilov# GTAGSFLAGS	Options for gtags(1) [-o]
20ccc4bab1SRuslan Ermilov#
21ccc4bab1SRuslan Ermilov# HTAGSFLAGS	Options for htags(1) [not set]
22ccc4bab1SRuslan Ermilov#
2353996fadSWolfram Schneider# SRCS          List of source files (c, c++, assembler)
2453996fadSWolfram Schneider#
2511dc9298SRuslan Ermilov# DPSRCS	List of source files which are needed for generating
2611dc9298SRuslan Ermilov#		dependencies, ${SRCS} are always part of it.
2753996fadSWolfram Schneider#
2853996fadSWolfram Schneider# +++ targets +++
2953996fadSWolfram Schneider#
3053996fadSWolfram Schneider#	cleandepend:
31ae038fc3SBryan Drewery#		remove ${CLEANDEPENDFILES}; remove ${CLEANDEPENDDIRS} and all
32ae038fc3SBryan Drewery#		contents.
3353996fadSWolfram Schneider#
3453996fadSWolfram Schneider#	depend:
3553996fadSWolfram Schneider#		Make the dependencies for the source files, and store
3653996fadSWolfram Schneider#		them in the file ${DEPENDFILE}.
3753996fadSWolfram Schneider#
3853996fadSWolfram Schneider#	tags:
39ccc4bab1SRuslan Ermilov#		In "ctags" mode, create a tags file for the source files.
40ccc4bab1SRuslan Ermilov#		In "gtags" mode, create a (GLOBAL) gtags file for the
41ccc4bab1SRuslan Ermilov#		source files.  If HTML is defined, htags(1) is also run
42ccc4bab1SRuslan Ermilov#		after gtags(1).
4353996fadSWolfram Schneider
445ffdf361SRuslan Ermilov.if !target(__<bsd.init.mk>__)
455ffdf361SRuslan Ermilov.error bsd.dep.mk cannot be included directly.
465ffdf361SRuslan Ermilov.endif
47b16495e7SWolfram Schneider
48ccc4bab1SRuslan ErmilovCTAGS?=		gtags
49ccc4bab1SRuslan ErmilovCTAGSFLAGS?=
50ccc4bab1SRuslan ErmilovGTAGSFLAGS?=	-o
51ccc4bab1SRuslan ErmilovHTAGSFLAGS?=
52ccc4bab1SRuslan Ermilov
53369737d7SBryan Drewery.if ${MK_DIRDEPS_BUILD} == "no"
54fc2c2cd9SBryan Drewery.MAKE.DEPENDFILE= ${DEPENDFILE}
55369737d7SBryan Drewery.endif
56caf1fb32SBryan DreweryCLEANDEPENDFILES+=	${DEPENDFILE} ${DEPENDFILE}.*
57b964b943SBryan Drewery.if ${MK_META_MODE} == "yes"
58b964b943SBryan DreweryCLEANDEPENDFILES+=	*.meta
59b964b943SBryan Drewery.endif
60d14f862cSGarrett Wollman
61ccc4bab1SRuslan Ermilov# Keep `tags' here, before SRCS are mangled below for `depend'.
626260f1d8SRuslan Ermilov.if !target(tags) && defined(SRCS) && !defined(NO_TAGS)
63ccc4bab1SRuslan Ermilovtags: ${SRCS}
64213a4447SRuslan Ermilov.if ${CTAGS:T} == "gtags"
65ccc4bab1SRuslan Ermilov	@cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR}
66ccc4bab1SRuslan Ermilov.if defined(HTML)
67ccc4bab1SRuslan Ermilov	@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
68ccc4bab1SRuslan Ermilov.endif
69213a4447SRuslan Ermilov.else
70213a4447SRuslan Ermilov	@${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \
71213a4447SRuslan Ermilov	    ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET}
72ccc4bab1SRuslan Ermilov.endif
73ccc4bab1SRuslan Ermilov.endif
74ccc4bab1SRuslan Ermilov
75799483e4SBryan Drewery.if !empty(.MAKE.MODE:Mmeta) && empty(.MAKE.MODE:Mnofilemon)
76799483e4SBryan Drewery_meta_filemon=	1
77799483e4SBryan Drewery.endif
78396561c9SBryan Drewery# By default META_MODE is disabled in bmake if there is no OBJDIR
79396561c9SBryan Drewery# unless .MAKE.MODE contains "curdirOk=[^0nNfF]"
80396561c9SBryan Drewery.if defined(_meta_filemon) && ${.OBJDIR} == ${.CURDIR} && \
81396561c9SBryan Drewery    (empty(.MAKE.MODE:tl:Mcurdirok=*) || \
82396561c9SBryan Drewery    !empty(.MAKE.MODE:tl:Mcurdirok=[0NnFf]*))
83396561c9SBryan Drewery.undef _meta_filemon
84396561c9SBryan Drewery.endif
85799483e4SBryan Drewery
86c30c436aSBryan Drewery# Skip reading .depend when not needed to speed up tree-walks and simple
87d7173250SBryan Drewery# lookups.  See _SKIP_BUILD logic in bsd.init.mk for more details.
88799483e4SBryan Drewery# Also skip generating or including .depend.* files if in meta+filemon mode
89210ecc00SBryan Drewery# since it will track dependencies itself.  OBJS_DEPEND_GUESS is still used
90210ecc00SBryan Drewery# for _meta_filemon but not for _SKIP_DEPEND.
91ecc39238SBryan Drewery.if !defined(NO_SKIP_DEPEND) && defined(_SKIP_BUILD)
92210ecc00SBryan Drewery_SKIP_DEPEND=	1
93210ecc00SBryan Drewery.endif
94e65dd92bSBryan Drewery.if ${MK_DIRDEPS_BUILD} == "no"
95210ecc00SBryan Drewery.if defined(_SKIP_DEPEND) || defined(_meta_filemon)
969fb02a70SBryan Drewery.MAKE.DEPENDFILE=	/dev/null
979fb02a70SBryan Drewery.endif
989fb02a70SBryan Drewery.endif
999fb02a70SBryan Drewery
1002ec8b6deSBruce Evans.if defined(SRCS)
1012ec8b6deSBruce EvansCLEANFILES?=
1022ec8b6deSBruce Evans
1038a152f97SRui Paulo.for _S in ${SRCS:N*.[dhly]}
1042506d700SSimon J. GerratyOBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.o+=	${_S}
105d7beff08SBryan Drewery.endfor
1066b14fdfaSRuslan Ermilov
1079f65e34fSRui Paulo# Lexical analyzers
1082ec8b6deSBruce Evans.for _LSRC in ${SRCS:M*.l:N*/*}
109484933a9SRuslan Ermilov.for _LC in ${_LSRC:R}.c
1105852ae2dSBryan Drewery${_LC}: ${_LSRC}
1118f812fecSDag-Erling Smørgrav	${LEX} ${LFLAGS} -o${.TARGET} ${.ALLSRC}
112919154d9SBryan DreweryOBJS_DEPEND_GUESS.${_LC:R}.o+=	${_LC}
1132ec8b6deSBruce EvansSRCS:=	${SRCS:S/${_LSRC}/${_LC}/}
114484933a9SRuslan ErmilovCLEANFILES+= ${_LC}
1152ec8b6deSBruce Evans.endfor
1162ec8b6deSBruce Evans.endfor
1172ec8b6deSBruce Evans
1189f65e34fSRui Paulo# Yacc grammars
1192ec8b6deSBruce Evans.for _YSRC in ${SRCS:M*.y:N*/*}
120484933a9SRuslan Ermilov.for _YC in ${_YSRC:R}.c
1212ec8b6deSBruce EvansSRCS:=	${SRCS:S/${_YSRC}/${_YC}/}
122484933a9SRuslan ErmilovCLEANFILES+= ${_YC}
12365d2bdc6SRuslan Ermilov.if !empty(YFLAGS:M-d) && !empty(SRCS:My.tab.h)
1242ec8b6deSBruce Evans.ORDER: ${_YC} y.tab.h
12592edc966SBryan Dreweryy.tab.h: .NOMETA
1262ec8b6deSBruce Evans${_YC} y.tab.h: ${_YSRC}
1272ec8b6deSBruce Evans	${YACC} ${YFLAGS} ${.ALLSRC}
1282ec8b6deSBruce Evans	cp y.tab.c ${_YC}
129484933a9SRuslan ErmilovCLEANFILES+= y.tab.c y.tab.h
13065d2bdc6SRuslan Ermilov.elif !empty(YFLAGS:M-d)
131484933a9SRuslan Ermilov.for _YH in ${_YC:R}.h
1325444d429SBryan Drewery.ORDER: ${_YC} ${_YH}
13392edc966SBryan Drewery${_YH}: .NOMETA
1345444d429SBryan Drewery${_YC} ${_YH}: ${_YSRC}
1352ec8b6deSBruce Evans	${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
136484933a9SRuslan ErmilovSRCS+=	${_YH}
137484933a9SRuslan ErmilovCLEANFILES+= ${_YH}
1382ec8b6deSBruce Evans.endfor
1392ec8b6deSBruce Evans.else
1405852ae2dSBryan Drewery${_YC}: ${_YSRC}
1412ec8b6deSBruce Evans	${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
1422ec8b6deSBruce Evans.endif
143919154d9SBryan DreweryOBJS_DEPEND_GUESS.${_YC:R}.o+=	${_YC}
1442ec8b6deSBruce Evans.endfor
1452ec8b6deSBruce Evans.endfor
1469f65e34fSRui Paulo
1479f65e34fSRui Paulo# DTrace probe definitions
148ff0f36e7SRui Paulo.if ${SRCS:M*.d}
1495439a715SMark JohnstonCFLAGS+=	-I${.OBJDIR}
150ff0f36e7SRui Paulo.endif
1519f65e34fSRui Paulo.for _DSRC in ${SRCS:M*.d:N*/*}
152ff0f36e7SRui Paulo.for _D in ${_DSRC:R}
153cfa5f2beSBryan DrewerySRCS+=	${_D}.h
1545852ae2dSBryan Drewery${_D}.h: ${_DSRC}
1550c76c8aaSMark Johnston	${DTRACE} ${DTRACEFLAGS} -h -s ${.ALLSRC}
156e9083b2dSMark JohnstonSRCS:=	${SRCS:S/^${_DSRC}$//}
157d8b63155SRui PauloOBJS+=	${_D}.o
1589b646f25SRui PauloCLEANFILES+= ${_D}.h ${_D}.o
1595852ae2dSBryan Drewery${_D}.o: ${_DSRC} ${OBJS:S/^${_D}.o$//}
160a298c279SBryan Drewery	@rm -f ${.TARGET}
161cfa5f2beSBryan Drewery	${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
1629b646f25SRui Paulo.if defined(LIB)
163db08bfceSKonstantin BelousovCLEANFILES+= ${_D}.pico ${_D}.po ${_D}.nossppico
1642b4da8aaSMarcel Moolenaar${_D}.pico: ${_DSRC} ${SOBJS:S/^${_D}.pico$//}
165a298c279SBryan Drewery	@rm -f ${.TARGET}
166cfa5f2beSBryan Drewery	${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
1675852ae2dSBryan Drewery${_D}.po: ${_DSRC} ${POBJS:S/^${_D}.po$//}
168a298c279SBryan Drewery	@rm -f ${.TARGET}
169cfa5f2beSBryan Drewery	${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
170db08bfceSKonstantin Belousov${_D}.nossppico: ${_DSRC} ${SOBJS:S/^${_D}.nossppico$//}
171db08bfceSKonstantin Belousov	@rm -f ${.TARGET}
172db08bfceSKonstantin Belousov	${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
173ff0f36e7SRui Paulo.endif
1749f65e34fSRui Paulo.endfor
1759f65e34fSRui Paulo.endfor
176b9964333SBryan Drewery
177b9964333SBryan Drewery
178e32a2cbeSBryan Drewery.if ${MAKE_VERSION} < 20160220
179b9964333SBryan DreweryDEPEND_MP?=	-MP
180e32a2cbeSBryan Drewery.endif
181b9964333SBryan Drewery# Handle OBJS=../somefile.o hacks.  Just replace '/' rather than use :T to
182b9964333SBryan Drewery# avoid collisions.
183b9964333SBryan DreweryDEPEND_FILTER=	C,/,_,g
184649fed8eSBryan DreweryDEPENDSRCS+=	${SRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc}
185a854949fSBryan DreweryDEPENDSRCS+=	${DPSRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc}
18670ca9ec4SBryan Drewery.if !empty(DEPENDSRCS)
1872506d700SSimon J. GerratyDEPENDOBJS+=	${DEPENDSRCS:${OBJS_SRCS_FILTER:ts:}:S,$,.o,}
18870ca9ec4SBryan Drewery.endif
189*3d04f5a9SBryan Drewery.if !empty(DEPENDOBJS)
190068306e9SBryan DreweryDEPENDFILES+=	${DEPENDOBJS:O:u:${DEPEND_FILTER}:C/^/${DEPENDFILE}./}
191*3d04f5a9SBryan Drewery.endif
192210ecc00SBryan Drewery.if defined(_SKIP_DEPEND)
193210ecc00SBryan Drewery# Don't bother statting any .meta files for .depend*
194210ecc00SBryan Drewery${DEPENDOBJS}:	.NOMETA
195210ecc00SBryan Drewery${DEPENDFILE}:	.NOMETA
196210ecc00SBryan Drewery# Unset these to avoid looping/statting on them later.
197210ecc00SBryan Drewery.undef DEPENDSRCS
198210ecc00SBryan Drewery.undef DEPENDOBJS
199068306e9SBryan Drewery.undef DEPENDFILES
200210ecc00SBryan Drewery.endif	# defined(_SKIP_DEPEND)
201b9964333SBryan DreweryDEPEND_CFLAGS+=	-MD ${DEPEND_MP} -MF${DEPENDFILE}.${.TARGET:${DEPEND_FILTER}}
202b9964333SBryan DreweryDEPEND_CFLAGS+=	-MT${.TARGET}
20370ca9ec4SBryan Drewery.if !defined(_meta_filemon)
204c2fd1d01SBryan Drewery.if !empty(DEPEND_CFLAGS)
20510f696a5SBryan Drewery# Only add in DEPEND_CFLAGS for CFLAGS on files we expect from DEPENDOBJS
20610f696a5SBryan Drewery# as those are the only ones we will include.
2077c0c104bSBryan DreweryDEPEND_CFLAGS_CONDITION= "${DEPENDOBJS:${DEPEND_FILTER}:M${.TARGET:${DEPEND_FILTER}}}" != ""
20810f696a5SBryan DreweryCFLAGS+=	${${DEPEND_CFLAGS_CONDITION}:?${DEPEND_CFLAGS}:}
20910f696a5SBryan Drewery.endif
210068306e9SBryan Drewery.for __depend_obj in ${DEPENDFILES}
211e32a2cbeSBryan Drewery.if ${MAKE_VERSION} < 20160220
212e9508dc2SBryan Drewery.sinclude "${.OBJDIR}/${__depend_obj}"
213e32a2cbeSBryan Drewery.else
214e32a2cbeSBryan Drewery.dinclude "${.OBJDIR}/${__depend_obj}"
215e32a2cbeSBryan Drewery.endif
216b9964333SBryan Drewery.endfor
21770ca9ec4SBryan Drewery.endif	# !defined(_meta_filemon)
218b9964333SBryan Drewery.endif	# defined(SRCS)
2192ec8b6deSBruce Evans
22034d39d2cSBryan Drewery.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.DEPENDFILE} != "/dev/null"
221b9cd412eSBryan Drewery# Prevent meta.autodep.mk from tracking "local dependencies".
222b9cd412eSBryan Drewery.depend:
2237750ad47SMarcel Moolenaar.include <meta.autodep.mk>
22470ca9ec4SBryan Drewery# If using filemon then _EXTRADEPEND is skipped since it is not needed.
225799483e4SBryan Drewery.if defined(_meta_filemon)
2267750ad47SMarcel Moolenaar# this depend: bypasses that below
2277750ad47SMarcel Moolenaar# the dependency helps when bootstrapping
2287750ad47SMarcel Moolenaardepend: beforedepend ${DPSRCS} ${SRCS} afterdepend
2297750ad47SMarcel Moolenaarbeforedepend:
2307750ad47SMarcel Moolenaarafterdepend: beforedepend
2317750ad47SMarcel Moolenaar.endif
23270ca9ec4SBryan Drewery.endif
2337750ad47SMarcel Moolenaar
234d7beff08SBryan Drewery# Guess some dependencies for when no ${DEPENDFILE}.OBJ is generated yet.
23570ca9ec4SBryan Drewery# For meta+filemon the .meta file is checked for since it is the dependency
23670ca9ec4SBryan Drewery# file used.
237d7beff08SBryan Drewery.for __obj in ${DEPENDOBJS:O:u}
2387c0c104bSBryan Drewery# If the obj has any '/', then replace with '_'.  For meta files, this is
2397c0c104bSBryan Drewery# mimicing what bmake's meta_name() does and adding in the full path
2407c0c104bSBryan Drewery# as well to ensure that the expected meta file is read.
2417c0c104bSBryan Drewery.if ${__obj:M*/*}
2422a8176cbSBryan Drewery.if ${MAKE_VERSION} < 20171028
2437c0c104bSBryan Drewery_meta_obj=	${.OBJDIR:C,/,_,g}_${__obj:C,/,_,g}.meta
2447c0c104bSBryan Drewery.else
2452a8176cbSBryan Drewery_meta_obj=	${__obj:C,/,_,g}.meta
2462a8176cbSBryan Drewery.endif	# ${MAKE_VERSION} < 20171028
2472a8176cbSBryan Drewery.else
2487c0c104bSBryan Drewery_meta_obj=	${__obj}.meta
2492a8176cbSBryan Drewery.endif	# ${__obj:M*/*}
2507c0c104bSBryan Drewery_dep_obj=	${DEPENDFILE}.${__obj:${DEPEND_FILTER}}
251711019f7SBryan Drewery.if defined(_meta_filemon)
252711019f7SBryan Drewery_depfile=	${.OBJDIR}/${_meta_obj}
253711019f7SBryan Drewery.else
254711019f7SBryan Drewery_depfile=	${.OBJDIR}/${_dep_obj}
255711019f7SBryan Drewery.endif
256f39f6a56SBryan Drewery.if !exists(${_depfile}) || defined(_meta_filemon)
257f39f6a56SBryan Drewery# - Headers are normally built in beforebuild when included in DPSRCS or SRCS.
258f39f6a56SBryan Drewery#   So we don't need it as a guessed dependency (it may lead to cyclic problems
259f39f6a56SBryan Drewery#   if custom rules are defined).  The only time this causes a problem is when
260f39f6a56SBryan Drewery#   'make foo.o' is ran.
261f39f6a56SBryan Drewery# - For meta mode we still need to know which file to depend on to avoid
2623b828e44SBryan Drewery#   ambiguous suffix transformation rules from .PATH.  Meta mode does not
263f39f6a56SBryan Drewery#   use .depend files when filemon is in use.
2643b828e44SBryan Drewery${__obj}: ${OBJS_DEPEND_GUESS:N*.h}
265c155deccSBryan Drewery${__obj}: ${OBJS_DEPEND_GUESS.${__obj}}
266f39f6a56SBryan Drewery.endif	# !exists(${_depfile}) || defined(_meta_filemon)
267d7beff08SBryan Drewery.endfor
268b9cd412eSBryan Drewery
269b9cd412eSBryan Drewery# Always run 'make depend' to generate dependencies early and to avoid the
270b9cd412eSBryan Drewery# need for manually running it.  The dirdeps build should only do this in
271b9cd412eSBryan Drewery# sub-makes though since MAKELEVEL0 is for dirdeps calculations.
272b9cd412eSBryan Drewery.if ${MK_DIRDEPS_BUILD} == "no" || ${.MAKE.LEVEL} > 0
273b9cd412eSBryan Drewerybeforebuild: depend
274d7beff08SBryan Drewery.endif
275d7beff08SBryan Drewery
276d14f862cSGarrett Wollman.if !target(depend)
277d14f862cSGarrett Wollman.if defined(SRCS)
278b25a566dSRuslan Ermilovdepend: beforedepend ${DEPENDFILE} afterdepend
279b16495e7SWolfram Schneider
2807750ad47SMarcel Moolenaar# Tell bmake not to look for generated files via .PATH
281068306e9SBryan Drewery.NOPATH: ${DEPENDFILE} ${DEPENDFILES}
2827750ad47SMarcel Moolenaar
283497e8091SBryan Drewery# A .depend file will only be generated if there are commands in
284799483e4SBryan Drewery# beforedepend/_EXTRADEPEND/afterdepend  The _EXTRADEPEND target is
285799483e4SBryan Drewery# ignored if using meta+filemon since it handles all dependencies.  The other
286799483e4SBryan Drewery# targets are kept as they be used for generating something.  The target is
287799483e4SBryan Drewery# kept to allow 'make depend' to generate files.
288a854949fSBryan Drewery${DEPENDFILE}: ${SRCS} ${DPSRCS}
289210ecc00SBryan Drewery.if !defined(_SKIP_DEPEND)
290987c375fSBryan Drewery.if exists(${.OBJDIR}/${DEPENDFILE}) || \
291799483e4SBryan Drewery    ((commands(beforedepend) || \
292799483e4SBryan Drewery    (!defined(_meta_filemon) && commands(_EXTRADEPEND)) || \
293987c375fSBryan Drewery    commands(afterdepend)) && !empty(.MAKE.MODE:Mmeta))
294b16495e7SWolfram Schneider	rm -f ${DEPENDFILE}
29580f9a973SBryan Drewery.endif
296210ecc00SBryan Drewery.endif
297799483e4SBryan Drewery.if !defined(_meta_filemon) && target(_EXTRADEPEND)
29870e82473SRuslan Ermilov_EXTRADEPEND: .USE
2990cfacc86SRuslan Ermilov${DEPENDFILE}: _EXTRADEPEND
300663e9677SBruce Evans.endif
301b16495e7SWolfram Schneider
30297fe7f47SJordan K. Hubbard.ORDER: ${DEPENDFILE} afterdepend
303d14f862cSGarrett Wollman.else
304b25a566dSRuslan Ermilovdepend: beforedepend afterdepend
305d14f862cSGarrett Wollman.endif
306d14f862cSGarrett Wollman.if !target(beforedepend)
307d14f862cSGarrett Wollmanbeforedepend:
30897fe7f47SJordan K. Hubbard.else
30997fe7f47SJordan K. Hubbard.ORDER: beforedepend ${DEPENDFILE}
31097fe7f47SJordan K. Hubbard.ORDER: beforedepend afterdepend
311d14f862cSGarrett Wollman.endif
312d14f862cSGarrett Wollman.if !target(afterdepend)
313d14f862cSGarrett Wollmanafterdepend:
314d14f862cSGarrett Wollman.endif
315d14f862cSGarrett Wollman.endif
316d14f862cSGarrett Wollman
3173d437ee2SBryan Drewery.if defined(SRCS)
318ae038fc3SBryan Drewery.if ${CTAGS:T} == "gtags"
319ae038fc3SBryan DreweryCLEANDEPENDFILES+=	GPATH GRTAGS GSYMS GTAGS
320ae038fc3SBryan Drewery.if defined(HTML)
321ae038fc3SBryan DreweryCLEANDEPENDDIRS+=	HTML
322ae038fc3SBryan Drewery.endif
323ae038fc3SBryan Drewery.else
324ae038fc3SBryan DreweryCLEANDEPENDFILES+=	tags
325ae038fc3SBryan Drewery.endif
3263d437ee2SBryan Drewery.endif
327cd9a2f5cSJordan K. Hubbard.if !target(cleandepend)
328b25a566dSRuslan Ermilovcleandepend:
3293d437ee2SBryan Drewery.if !empty(CLEANDEPENDFILES)
330ae038fc3SBryan Drewery	rm -f ${CLEANDEPENDFILES}
3313d437ee2SBryan Drewery.endif
332ae038fc3SBryan Drewery.if !empty(CLEANDEPENDDIRS)
333ae038fc3SBryan Drewery	rm -rf ${CLEANDEPENDDIRS}
3346eb5e456SJordan K. Hubbard.endif
335cd9a2f5cSJordan K. Hubbard.endif
336190348aeSBryan Drewery.ORDER: cleandepend all
337190348aeSBryan Drewery.ORDER: cleandepend depend
338b284f322SBryan Drewery.if ${MK_AUTO_OBJ} == "yes"
339b284f322SBryan Drewery.ORDER: cleanobj depend
340b284f322SBryan Drewery.ORDER: cleandir depend
341b284f322SBryan Drewery.endif
3426e02167bSRuslan Ermilov
3436e02167bSRuslan Ermilov.if !target(checkdpadd) && (defined(DPADD) || defined(LDADD))
34441ae64f3SEnji Cooper_LDADD_FROM_DPADD=	${DPADD:R:T:C;^lib(.*)$;-l\1;g}
34541ae64f3SEnji Cooper# Ignore -Wl,--start-group/-Wl,--end-group as it might be required in the
34641ae64f3SEnji Cooper# LDADD list due to unresolved symbols
34741ae64f3SEnji Cooper_LDADD_CANONICALIZED=	${LDADD:N:R:T:C;^lib(.*)$;-l\1;g:N-Wl,--[es]*-group}
3486e02167bSRuslan Ermilovcheckdpadd:
3492e3c6179SBruce Evans.if ${_LDADD_FROM_DPADD} != ${_LDADD_CANONICALIZED}
3502e3c6179SBruce Evans	@echo ${.CURDIR}
3512e3c6179SBruce Evans	@echo "DPADD -> ${_LDADD_FROM_DPADD}"
3522e3c6179SBruce Evans	@echo "LDADD -> ${_LDADD_CANONICALIZED}"
3532e3c6179SBruce Evans.endif
3546e02167bSRuslan Ermilov.endif
355