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} 1115a2899acSBjoern A. Zeeb ${LEX} ${LFLAGS} ${LFLAGS.${_LSRC}} -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) 124000a2e70SBryan Drewery# Multi-output targets both expect a .meta file and will fight over it. Only 125000a2e70SBryan Drewery# allow it on the .c file instead. 126000a2e70SBryan Dreweryy.tab.h: ${_YC} .NOMETA 127000a2e70SBryan Drewery# Force rebuild the .c file if any of its other outputs are missing. 128000a2e70SBryan Drewery.if !exists(y.tab.h) 129000a2e70SBryan Drewery${_YC}: .PHONY .META 130000a2e70SBryan Drewery.endif 131000a2e70SBryan Drewery${_YC}: ${_YSRC} 1325a2899acSBjoern A. Zeeb ${YACC} ${YFLAGS} ${YFLAGS.${_YSRC}} ${.ALLSRC} 1332ec8b6deSBruce Evans cp y.tab.c ${_YC} 134484933a9SRuslan ErmilovCLEANFILES+= y.tab.c y.tab.h 13565d2bdc6SRuslan Ermilov.elif !empty(YFLAGS:M-d) 136484933a9SRuslan Ermilov.for _YH in ${_YC:R}.h 137000a2e70SBryan Drewery# Multi-output targets both expect a .meta file and will fight over it. Only 138000a2e70SBryan Drewery# allow it on the .c file instead. 139000a2e70SBryan Drewery${_YH}: ${_YC} .NOMETA 140000a2e70SBryan Drewery# Force rebuild the .c file if any of its other outputs are missing. 141000a2e70SBryan Drewery.if !exists(${_YH}) 142000a2e70SBryan Drewery${_YC}: .PHONY .META 143000a2e70SBryan Drewery.endif 144000a2e70SBryan Drewery${_YC}: ${_YSRC} 1455a2899acSBjoern A. Zeeb ${YACC} ${YFLAGS} ${YFLAGS.${_YSRC}} -o ${_YC} ${.ALLSRC} 146484933a9SRuslan ErmilovSRCS+= ${_YH} 147484933a9SRuslan ErmilovCLEANFILES+= ${_YH} 1482ec8b6deSBruce Evans.endfor 1492ec8b6deSBruce Evans.else 1505852ae2dSBryan Drewery${_YC}: ${_YSRC} 1515a2899acSBjoern A. Zeeb ${YACC} ${YFLAGS} ${YFLAGS.${_YSRC}} -o ${_YC} ${.ALLSRC} 1522ec8b6deSBruce Evans.endif 153919154d9SBryan DreweryOBJS_DEPEND_GUESS.${_YC:R}.o+= ${_YC} 1542ec8b6deSBruce Evans.endfor 1552ec8b6deSBruce Evans.endfor 1569f65e34fSRui Paulo 1579f65e34fSRui Paulo# DTrace probe definitions 158ff0f36e7SRui Paulo.if ${SRCS:M*.d} 1595439a715SMark JohnstonCFLAGS+= -I${.OBJDIR} 160ff0f36e7SRui Paulo.endif 1619f65e34fSRui Paulo.for _DSRC in ${SRCS:M*.d:N*/*} 162ff0f36e7SRui Paulo.for _D in ${_DSRC:R} 163cfa5f2beSBryan DrewerySRCS+= ${_D}.h 1645852ae2dSBryan Drewery${_D}.h: ${_DSRC} 1650c76c8aaSMark Johnston ${DTRACE} ${DTRACEFLAGS} -h -s ${.ALLSRC} 166e9083b2dSMark JohnstonSRCS:= ${SRCS:S/^${_DSRC}$//} 167d8b63155SRui PauloOBJS+= ${_D}.o 1689b646f25SRui PauloCLEANFILES+= ${_D}.h ${_D}.o 1695852ae2dSBryan Drewery${_D}.o: ${_DSRC} ${OBJS:S/^${_D}.o$//} 170a298c279SBryan Drewery @rm -f ${.TARGET} 171cfa5f2beSBryan Drewery ${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h} 1729b646f25SRui Paulo.if defined(LIB) 173db08bfceSKonstantin BelousovCLEANFILES+= ${_D}.pico ${_D}.po ${_D}.nossppico 1742b4da8aaSMarcel Moolenaar${_D}.pico: ${_DSRC} ${SOBJS:S/^${_D}.pico$//} 175a298c279SBryan Drewery @rm -f ${.TARGET} 176cfa5f2beSBryan Drewery ${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h} 1775852ae2dSBryan Drewery${_D}.po: ${_DSRC} ${POBJS:S/^${_D}.po$//} 178a298c279SBryan Drewery @rm -f ${.TARGET} 179cfa5f2beSBryan Drewery ${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h} 180db08bfceSKonstantin Belousov${_D}.nossppico: ${_DSRC} ${SOBJS:S/^${_D}.nossppico$//} 181db08bfceSKonstantin Belousov @rm -f ${.TARGET} 182db08bfceSKonstantin Belousov ${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h} 183ff0f36e7SRui Paulo.endif 1849f65e34fSRui Paulo.endfor 1859f65e34fSRui Paulo.endfor 186ee4eeb32SBryan Drewery.endif # defined(SRCS) 187b9964333SBryan Drewery 188e32a2cbeSBryan Drewery.if ${MAKE_VERSION} < 20160220 189b9964333SBryan DreweryDEPEND_MP?= -MP 190e32a2cbeSBryan Drewery.endif 191b9964333SBryan Drewery# Handle OBJS=../somefile.o hacks. Just replace '/' rather than use :T to 192b9964333SBryan Drewery# avoid collisions. 193b9964333SBryan DreweryDEPEND_FILTER= C,/,_,g 194ee4eeb32SBryan Drewery.if !empty(OBJS) 195*ab0c68baSAlex Richardson.if !defined(_ALLOW_ABSOLUTE_OBJ_PATH) && ${OBJS:M/*} 196*ab0c68baSAlex Richardson# Absolute paths to OBJS should be an error inside ${SRCTOP}, but some users 197*ab0c68baSAlex Richardson# might be relying on this feature, so add an opt-out mechanism. 198*ab0c68baSAlex Richardson.if defined(SRCTOP) && ${OBJS:M${SRCTOP}*} 199*ab0c68baSAlex Richardson.error "$$OBJS inside $$SRCTOP not allowed: ${OBJS:M${SRCTOP}*}" 200*ab0c68baSAlex Richardson.elif ${OBJS:N${_ABSOLUTE_PATH_OBJS}:M/*} 201*ab0c68baSAlex Richardson.error "$$OBJS absolute path not allowed: ${OBJS:N${_ABSOLUTE_PATH_OBJS}:M/*}. \ 202*ab0c68baSAlex Richardson If this is intended, add them to _ABSOLUTE_PATH_OBJS to silence this error\ 203*ab0c68baSAlex Richardson or define _ALLOW_ABSOLUTE_OBJ_PATH to disable this diagnostic." 204*ab0c68baSAlex Richardson.endif 205*ab0c68baSAlex Richardson.endif 206ee4eeb32SBryan DreweryDEPENDOBJS+= ${OBJS} 207ee4eeb32SBryan Drewery.else 208649fed8eSBryan DreweryDEPENDSRCS+= ${SRCS:M*.[cSC]} ${SRCS:M*.cxx} ${SRCS:M*.cpp} ${SRCS:M*.cc} 20949ccbde1SBryan DreweryDEPENDSRCS+= ${DPSRCS:M*.[cSC]} ${DPSRCS:M*.cxx} ${DPSRCS:M*.cpp} ${DPSRCS:M*.cc} 21070ca9ec4SBryan Drewery.if !empty(DEPENDSRCS) 2112506d700SSimon J. GerratyDEPENDOBJS+= ${DEPENDSRCS:${OBJS_SRCS_FILTER:ts:}:S,$,.o,} 21270ca9ec4SBryan Drewery.endif 213ee4eeb32SBryan Drewery.endif # !empty(OBJS) 2143d04f5a9SBryan Drewery.if !empty(DEPENDOBJS) 215068306e9SBryan DreweryDEPENDFILES+= ${DEPENDOBJS:O:u:${DEPEND_FILTER}:C/^/${DEPENDFILE}./} 2163d04f5a9SBryan Drewery.endif 217210ecc00SBryan Drewery.if defined(_SKIP_DEPEND) 218210ecc00SBryan Drewery# Don't bother statting any .meta files for .depend* 219210ecc00SBryan Drewery${DEPENDOBJS}: .NOMETA 220210ecc00SBryan Drewery${DEPENDFILE}: .NOMETA 221210ecc00SBryan Drewery# Unset these to avoid looping/statting on them later. 222210ecc00SBryan Drewery.undef DEPENDSRCS 223210ecc00SBryan Drewery.undef DEPENDOBJS 224068306e9SBryan Drewery.undef DEPENDFILES 225210ecc00SBryan Drewery.endif # defined(_SKIP_DEPEND) 226b9964333SBryan DreweryDEPEND_CFLAGS+= -MD ${DEPEND_MP} -MF${DEPENDFILE}.${.TARGET:${DEPEND_FILTER}} 227b9964333SBryan DreweryDEPEND_CFLAGS+= -MT${.TARGET} 22870ca9ec4SBryan Drewery.if !defined(_meta_filemon) 229c2fd1d01SBryan Drewery.if !empty(DEPEND_CFLAGS) 23010f696a5SBryan Drewery# Only add in DEPEND_CFLAGS for CFLAGS on files we expect from DEPENDOBJS 23110f696a5SBryan Drewery# as those are the only ones we will include. 2327c0c104bSBryan DreweryDEPEND_CFLAGS_CONDITION= "${DEPENDOBJS:${DEPEND_FILTER}:M${.TARGET:${DEPEND_FILTER}}}" != "" 23310f696a5SBryan DreweryCFLAGS+= ${${DEPEND_CFLAGS_CONDITION}:?${DEPEND_CFLAGS}:} 23410f696a5SBryan Drewery.endif 235068306e9SBryan Drewery.for __depend_obj in ${DEPENDFILES} 236e32a2cbeSBryan Drewery.if ${MAKE_VERSION} < 20160220 237e9508dc2SBryan Drewery.sinclude "${.OBJDIR}/${__depend_obj}" 238e32a2cbeSBryan Drewery.else 239e32a2cbeSBryan Drewery.dinclude "${.OBJDIR}/${__depend_obj}" 240e32a2cbeSBryan Drewery.endif 241b9964333SBryan Drewery.endfor 24270ca9ec4SBryan Drewery.endif # !defined(_meta_filemon) 2432ec8b6deSBruce Evans 24434d39d2cSBryan Drewery.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.DEPENDFILE} != "/dev/null" 245b9cd412eSBryan Drewery# Prevent meta.autodep.mk from tracking "local dependencies". 246b9cd412eSBryan Drewery.depend: 2477750ad47SMarcel Moolenaar.include <meta.autodep.mk> 24870ca9ec4SBryan Drewery# If using filemon then _EXTRADEPEND is skipped since it is not needed. 249799483e4SBryan Drewery.if defined(_meta_filemon) 2507750ad47SMarcel Moolenaar# this depend: bypasses that below 2517750ad47SMarcel Moolenaar# the dependency helps when bootstrapping 2527750ad47SMarcel Moolenaardepend: beforedepend ${DPSRCS} ${SRCS} afterdepend 2537750ad47SMarcel Moolenaarbeforedepend: 2547750ad47SMarcel Moolenaarafterdepend: beforedepend 2557750ad47SMarcel Moolenaar.endif 25670ca9ec4SBryan Drewery.endif 2577750ad47SMarcel Moolenaar 258d7beff08SBryan Drewery# Guess some dependencies for when no ${DEPENDFILE}.OBJ is generated yet. 25970ca9ec4SBryan Drewery# For meta+filemon the .meta file is checked for since it is the dependency 26070ca9ec4SBryan Drewery# file used. 261d7beff08SBryan Drewery.for __obj in ${DEPENDOBJS:O:u} 2627c0c104bSBryan Drewery# If the obj has any '/', then replace with '_'. For meta files, this is 2637c0c104bSBryan Drewery# mimicing what bmake's meta_name() does and adding in the full path 2647c0c104bSBryan Drewery# as well to ensure that the expected meta file is read. 2657c0c104bSBryan Drewery.if ${__obj:M*/*} 2662a8176cbSBryan Drewery.if ${MAKE_VERSION} < 20171028 2677c0c104bSBryan Drewery_meta_obj= ${.OBJDIR:C,/,_,g}_${__obj:C,/,_,g}.meta 2687c0c104bSBryan Drewery.else 2692a8176cbSBryan Drewery_meta_obj= ${__obj:C,/,_,g}.meta 2702a8176cbSBryan Drewery.endif # ${MAKE_VERSION} < 20171028 2712a8176cbSBryan Drewery.else 2727c0c104bSBryan Drewery_meta_obj= ${__obj}.meta 2732a8176cbSBryan Drewery.endif # ${__obj:M*/*} 2747c0c104bSBryan Drewery_dep_obj= ${DEPENDFILE}.${__obj:${DEPEND_FILTER}} 275711019f7SBryan Drewery.if defined(_meta_filemon) 276711019f7SBryan Drewery_depfile= ${.OBJDIR}/${_meta_obj} 277711019f7SBryan Drewery.else 278711019f7SBryan Drewery_depfile= ${.OBJDIR}/${_dep_obj} 279711019f7SBryan Drewery.endif 280f39f6a56SBryan Drewery.if !exists(${_depfile}) || defined(_meta_filemon) 281f39f6a56SBryan Drewery# - Headers are normally built in beforebuild when included in DPSRCS or SRCS. 282f39f6a56SBryan Drewery# So we don't need it as a guessed dependency (it may lead to cyclic problems 283f39f6a56SBryan Drewery# if custom rules are defined). The only time this causes a problem is when 284f39f6a56SBryan Drewery# 'make foo.o' is ran. 285f39f6a56SBryan Drewery# - For meta mode we still need to know which file to depend on to avoid 2863b828e44SBryan Drewery# ambiguous suffix transformation rules from .PATH. Meta mode does not 287f39f6a56SBryan Drewery# use .depend files when filemon is in use. 28846dea205SBryan Drewery.if !target(${__obj}) 28946dea205SBryan Drewery${__obj}: ${OBJS_DEPEND_GUESS} 29046dea205SBryan Drewery.endif 291c155deccSBryan Drewery${__obj}: ${OBJS_DEPEND_GUESS.${__obj}} 292f39f6a56SBryan Drewery.endif # !exists(${_depfile}) || defined(_meta_filemon) 293d7beff08SBryan Drewery.endfor 294b9cd412eSBryan Drewery 295b9cd412eSBryan Drewery# Always run 'make depend' to generate dependencies early and to avoid the 296b9cd412eSBryan Drewery# need for manually running it. The dirdeps build should only do this in 297b9cd412eSBryan Drewery# sub-makes though since MAKELEVEL0 is for dirdeps calculations. 298b9cd412eSBryan Drewery.if ${MK_DIRDEPS_BUILD} == "no" || ${.MAKE.LEVEL} > 0 299b9cd412eSBryan Drewerybeforebuild: depend 300d7beff08SBryan Drewery.endif 301d7beff08SBryan Drewery 302d14f862cSGarrett Wollman.if !target(depend) 303d14f862cSGarrett Wollman.if defined(SRCS) 304b25a566dSRuslan Ermilovdepend: beforedepend ${DEPENDFILE} afterdepend 305b16495e7SWolfram Schneider 3067750ad47SMarcel Moolenaar# Tell bmake not to look for generated files via .PATH 307068306e9SBryan Drewery.NOPATH: ${DEPENDFILE} ${DEPENDFILES} 3087750ad47SMarcel Moolenaar 309497e8091SBryan Drewery# A .depend file will only be generated if there are commands in 310799483e4SBryan Drewery# beforedepend/_EXTRADEPEND/afterdepend The _EXTRADEPEND target is 311799483e4SBryan Drewery# ignored if using meta+filemon since it handles all dependencies. The other 312799483e4SBryan Drewery# targets are kept as they be used for generating something. The target is 313799483e4SBryan Drewery# kept to allow 'make depend' to generate files. 314a854949fSBryan Drewery${DEPENDFILE}: ${SRCS} ${DPSRCS} 315210ecc00SBryan Drewery.if !defined(_SKIP_DEPEND) 316987c375fSBryan Drewery.if exists(${.OBJDIR}/${DEPENDFILE}) || \ 317799483e4SBryan Drewery ((commands(beforedepend) || \ 318799483e4SBryan Drewery (!defined(_meta_filemon) && commands(_EXTRADEPEND)) || \ 319987c375fSBryan Drewery commands(afterdepend)) && !empty(.MAKE.MODE:Mmeta)) 320b16495e7SWolfram Schneider rm -f ${DEPENDFILE} 32180f9a973SBryan Drewery.endif 322210ecc00SBryan Drewery.endif 323799483e4SBryan Drewery.if !defined(_meta_filemon) && target(_EXTRADEPEND) 32470e82473SRuslan Ermilov_EXTRADEPEND: .USE 3250cfacc86SRuslan Ermilov${DEPENDFILE}: _EXTRADEPEND 326663e9677SBruce Evans.endif 327b16495e7SWolfram Schneider 32897fe7f47SJordan K. Hubbard.ORDER: ${DEPENDFILE} afterdepend 329d14f862cSGarrett Wollman.else 330b25a566dSRuslan Ermilovdepend: beforedepend afterdepend 331d14f862cSGarrett Wollman.endif 332d14f862cSGarrett Wollman.if !target(beforedepend) 333d14f862cSGarrett Wollmanbeforedepend: 33497fe7f47SJordan K. Hubbard.else 33597fe7f47SJordan K. Hubbard.ORDER: beforedepend ${DEPENDFILE} 33697fe7f47SJordan K. Hubbard.ORDER: beforedepend afterdepend 337d14f862cSGarrett Wollman.endif 338d14f862cSGarrett Wollman.if !target(afterdepend) 339d14f862cSGarrett Wollmanafterdepend: 340d14f862cSGarrett Wollman.endif 341d14f862cSGarrett Wollman.endif 342d14f862cSGarrett Wollman 3433d437ee2SBryan Drewery.if defined(SRCS) 344ae038fc3SBryan Drewery.if ${CTAGS:T} == "gtags" 345ae038fc3SBryan DreweryCLEANDEPENDFILES+= GPATH GRTAGS GSYMS GTAGS 346ae038fc3SBryan Drewery.if defined(HTML) 347ae038fc3SBryan DreweryCLEANDEPENDDIRS+= HTML 348ae038fc3SBryan Drewery.endif 349ae038fc3SBryan Drewery.else 350ae038fc3SBryan DreweryCLEANDEPENDFILES+= tags 351ae038fc3SBryan Drewery.endif 3523d437ee2SBryan Drewery.endif 353cd9a2f5cSJordan K. Hubbard.if !target(cleandepend) 354b25a566dSRuslan Ermilovcleandepend: 3553d437ee2SBryan Drewery.if !empty(CLEANDEPENDFILES) 356ae038fc3SBryan Drewery rm -f ${CLEANDEPENDFILES} 3573d437ee2SBryan Drewery.endif 358ae038fc3SBryan Drewery.if !empty(CLEANDEPENDDIRS) 359ae038fc3SBryan Drewery rm -rf ${CLEANDEPENDDIRS} 3606eb5e456SJordan K. Hubbard.endif 361cd9a2f5cSJordan K. Hubbard.endif 362190348aeSBryan Drewery.ORDER: cleandepend all 363190348aeSBryan Drewery.ORDER: cleandepend depend 364b284f322SBryan Drewery.if ${MK_AUTO_OBJ} == "yes" 365b284f322SBryan Drewery.ORDER: cleanobj depend 366b284f322SBryan Drewery.ORDER: cleandir depend 367b284f322SBryan Drewery.endif 3686e02167bSRuslan Ermilov 3696e02167bSRuslan Ermilov.if !target(checkdpadd) && (defined(DPADD) || defined(LDADD)) 37041ae64f3SEnji Cooper_LDADD_FROM_DPADD= ${DPADD:R:T:C;^lib(.*)$;-l\1;g} 37141ae64f3SEnji Cooper# Ignore -Wl,--start-group/-Wl,--end-group as it might be required in the 37241ae64f3SEnji Cooper# LDADD list due to unresolved symbols 37341ae64f3SEnji Cooper_LDADD_CANONICALIZED= ${LDADD:N:R:T:C;^lib(.*)$;-l\1;g:N-Wl,--[es]*-group} 3746e02167bSRuslan Ermilovcheckdpadd: 3752e3c6179SBruce Evans.if ${_LDADD_FROM_DPADD} != ${_LDADD_CANONICALIZED} 3762e3c6179SBruce Evans @echo ${.CURDIR} 3772e3c6179SBruce Evans @echo "DPADD -> ${_LDADD_FROM_DPADD}" 3782e3c6179SBruce Evans @echo "LDADD -> ${_LDADD_CANONICALIZED}" 3792e3c6179SBruce Evans.endif 3806e02167bSRuslan Ermilov.endif 381