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# 853996fadSWolfram Schneider# DEPENDFILE dependencies file [.depend] 953996fadSWolfram Schneider# 1053996fadSWolfram Schneider# MKDEP Options for ${MKDEPCMD} [not set] 1153996fadSWolfram Schneider# 1253996fadSWolfram Schneider# MKDEPCMD Makefile dependency list program [mkdep] 1353996fadSWolfram Schneider# 1453996fadSWolfram Schneider# SRCS List of source files (c, c++, assembler) 1553996fadSWolfram Schneider# 1653996fadSWolfram Schneider# 1753996fadSWolfram Schneider# +++ targets +++ 1853996fadSWolfram Schneider# 1953996fadSWolfram Schneider# cleandepend: 2053996fadSWolfram Schneider# Remove depend and tags file 2153996fadSWolfram Schneider# 2253996fadSWolfram Schneider# depend: 2353996fadSWolfram Schneider# Make the dependencies for the source files, and store 2453996fadSWolfram Schneider# them in the file ${DEPENDFILE}. 2553996fadSWolfram Schneider# 2653996fadSWolfram Schneider# tags: 276eb5e456SJordan K. Hubbard# Create a (GLOBAL) gtags file for the source files. 286eb5e456SJordan K. Hubbard# If HTML is defined, htags is also run after gtags. 2953996fadSWolfram Schneider 30b16495e7SWolfram Schneider 31e16529d3SRuslan Ermilov.if ${CC} != "cc" 32afabc4dfSBruce EvansMKDEPCMD?= CC=${CC} mkdep 33e16529d3SRuslan Ermilov.else 34e16529d3SRuslan ErmilovMKDEPCMD?= mkdep 35e16529d3SRuslan Ermilov.endif 36b16495e7SWolfram SchneiderDEPENDFILE?= .depend 37d14f862cSGarrett Wollman 382ec8b6deSBruce Evans.if defined(SRCS) 392ec8b6deSBruce EvansCLEANFILES?= 402ec8b6deSBruce Evans 412ec8b6deSBruce Evans.for _LSRC in ${SRCS:M*.l:N*/*} 422ec8b6deSBruce Evans.for _LC in ${_LSRC:S/.l/.c/} 432ec8b6deSBruce Evans${_LC}: ${_LSRC} 442ec8b6deSBruce Evans ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET} 452ec8b6deSBruce EvansSRCS:= ${SRCS:S/${_LSRC}/${_LC}/} 462ec8b6deSBruce EvansCLEANFILES:= ${CLEANFILES} ${_LC} 472ec8b6deSBruce Evans.endfor 482ec8b6deSBruce Evans.endfor 492ec8b6deSBruce Evans 502ec8b6deSBruce Evans.for _YSRC in ${SRCS:M*.y:N*/*} 512ec8b6deSBruce Evans.for _YC in ${_YSRC:S/.y/.c/} 522ec8b6deSBruce EvansSRCS:= ${SRCS:S/${_YSRC}/${_YC}/} 532ec8b6deSBruce EvansCLEANFILES:= ${CLEANFILES} ${_YC} 542ec8b6deSBruce Evans.if ${YFLAGS:M-d} != "" && ${SRCS:My.tab.h} 552ec8b6deSBruce Evans.ORDER: ${_YC} y.tab.h 562ec8b6deSBruce Evans${_YC} y.tab.h: ${_YSRC} 572ec8b6deSBruce Evans ${YACC} ${YFLAGS} ${.ALLSRC} 582ec8b6deSBruce Evans cp y.tab.c ${_YC} 592ec8b6deSBruce EvansSRCS:= ${SRCS} y.tab.h 602ec8b6deSBruce EvansCLEANFILES:= ${CLEANFILES} y.tab.c y.tab.h 612ec8b6deSBruce Evans.elif ${YFLAGS:M-d} != "" 622ec8b6deSBruce Evans.for _YH in ${_YC:S/.c/.h/} 632ec8b6deSBruce Evans.ORDER: ${_YC} ${_YH} 642ec8b6deSBruce Evans${_YC} ${_YH}: ${_YSRC} 652ec8b6deSBruce Evans ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} 662ec8b6deSBruce EvansSRCS:= ${SRCS} ${_YH} 672ec8b6deSBruce EvansCLEANFILES:= ${CLEANFILES} ${_YH} 682ec8b6deSBruce Evans.endfor 692ec8b6deSBruce Evans.else 702ec8b6deSBruce Evans${_YC}: ${_YSRC} 712ec8b6deSBruce Evans ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} 722ec8b6deSBruce Evans.endif 732ec8b6deSBruce Evans.endfor 742ec8b6deSBruce Evans.endfor 752ec8b6deSBruce Evans.endif 762ec8b6deSBruce Evans 77d14f862cSGarrett Wollman.if !target(depend) 78d14f862cSGarrett Wollman.if defined(SRCS) 7997fe7f47SJordan K. Hubbarddepend: beforedepend ${DEPENDFILE} afterdepend _SUBDIR 80b16495e7SWolfram Schneider 81a813856eSBruce Evans# Different types of sources are compiled with slightly different flags. 82a813856eSBruce Evans# Split up the sources, and filter out headers and non-applicable flags. 830cfacc86SRuslan Ermilov${DEPENDFILE}: _MKDEP 840cfacc86SRuslan Ermilov_MKDEP: ${SRCS} 85b16495e7SWolfram Schneider rm -f ${DEPENDFILE} 86a813856eSBruce Evans.if ${SRCS:M*.[sS]} != "" 87a813856eSBruce Evans ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 88a813856eSBruce Evans ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \ 89a813856eSBruce Evans ${AINC} \ 90b16495e7SWolfram Schneider ${.ALLSRC:M*.[sS]} 91b16495e7SWolfram Schneider.endif 92a813856eSBruce Evans.if ${SRCS:M*.c} != "" 93a813856eSBruce Evans ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 94a813856eSBruce Evans ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \ 95b16495e7SWolfram Schneider ${.ALLSRC:M*.c} 96b16495e7SWolfram Schneider.endif 97c7cbe79eSDmitrij Tejblum.if ${SRCS:M*.cc} != "" || ${SRCS:M*.C} != "" || ${SRCS:M*.cpp} != "" || \ 98c7cbe79eSDmitrij Tejblum ${SRCS:M*.cxx} != "" 99b16495e7SWolfram Schneider ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 100a813856eSBruce Evans ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \ 101c7cbe79eSDmitrij Tejblum ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx} 102b16495e7SWolfram Schneider.endif 10370a6e331SBruce Evans.if ${SRCS:M*.m} != "" 10470a6e331SBruce Evans ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ 10570a6e331SBruce Evans ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \ 10670a6e331SBruce Evans ${OBJCFLAGS:M-Wno-import*} \ 10770a6e331SBruce Evans ${.ALLSRC:M*.m} 10870a6e331SBruce Evans.endif 109663e9677SBruce Evans.if target(_EXTRADEPEND) 1100cfacc86SRuslan Ermilov${DEPENDFILE}: _EXTRADEPEND 1110cfacc86SRuslan Ermilov.ORDER: _MKDEP _EXTRADEPEND 112663e9677SBruce Evans.endif 113b16495e7SWolfram Schneider 11497fe7f47SJordan K. Hubbard.ORDER: ${DEPENDFILE} afterdepend 115d14f862cSGarrett Wollman.else 11697fe7f47SJordan K. Hubbarddepend: beforedepend afterdepend _SUBDIR 117d14f862cSGarrett Wollman.endif 118d14f862cSGarrett Wollman.if !target(beforedepend) 119d14f862cSGarrett Wollmanbeforedepend: 12097fe7f47SJordan K. Hubbard.else 12197fe7f47SJordan K. Hubbard.ORDER: beforedepend ${DEPENDFILE} 12297fe7f47SJordan K. Hubbard.ORDER: beforedepend afterdepend 123d14f862cSGarrett Wollman.endif 124d14f862cSGarrett Wollman.if !target(afterdepend) 125d14f862cSGarrett Wollmanafterdepend: 126d14f862cSGarrett Wollman.endif 127d14f862cSGarrett Wollman.endif 128d14f862cSGarrett Wollman 1296eb5e456SJordan K. Hubbard.if defined(NOTAGS) 1306eb5e456SJordan K. Hubbardtags: 1316eb5e456SJordan K. Hubbard.endif 1326eb5e456SJordan K. Hubbard 133d14f862cSGarrett Wollman.if !target(tags) 134cd9a2f5cSJordan K. Hubbardtags: ${SRCS} _SUBDIR 1351ed9b1c3SEivind Eklund @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR} 1366eb5e456SJordan K. Hubbard.if defined(HTML) 1371ed9b1c3SEivind Eklund @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} 138d14f862cSGarrett Wollman.endif 139d14f862cSGarrett Wollman.endif 140d14f862cSGarrett Wollman 141cd9a2f5cSJordan K. Hubbard.if !target(cleandepend) 142cd9a2f5cSJordan K. Hubbardcleandepend: _SUBDIR 143662773e2SBruce Evans.if defined(SRCS) 144f9ed7e77SHidetoshi Shimokawa rm -f ${DEPENDFILE} ${.OBJDIR}/GPATH ${.OBJDIR}/GRTAGS \ 145f9ed7e77SHidetoshi Shimokawa ${.OBJDIR}/GSYMS ${.OBJDIR}/GTAGS 1466eb5e456SJordan K. Hubbard.if defined(HTML) 1471ed9b1c3SEivind Eklund rm -rf ${.OBJDIR}/HTML 1486eb5e456SJordan K. Hubbard.endif 149cd9a2f5cSJordan K. Hubbard.endif 150cd9a2f5cSJordan K. Hubbard.endif 151