X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/5deb461db2148a6946742b7ce36889c49d696cb6..67be553814c6242d4a801d26dc2f6e5ca4b1aa8a:/share/mk/bsd.dep.mk diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index dfade4601d..9384cdf5eb 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -105,48 +105,92 @@ ${_YC}: ${_YSRC} .if !target(depend) .if defined(SRCS) -depend: beforedepend ${DEPENDFILE} afterdepend +depend: beforedepend _dependincs ${DEPENDFILE} afterdepend # Different types of sources are compiled with slightly different flags. # Split up the sources, and filter out headers and non-applicable flags. -${DEPENDFILE}: ${SRCS} - rm -f ${DEPENDFILE} -.if ${SRCS:M*.[sS]} != "" - ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ +# Separate flag groups out of the sources and treat them differently. +# The special "_" group is for all files not in any group. +__FLAGS= +__FLAGS_FILES= ${SRCS} +.for _FG in ${FLAGS_GROUPS} +.for _FFILE in ${${_FG}_FLAGS_FILES} +__FLAGS_FILES:= ${__FLAGS_FILES:N${_FFILE}} +.endfor +.endfor + +_DEPENDFILES= ${FLAGS_GROUPS:S/^/.depend_/g} +.ORDER: ${_DEPENDFILES} + +${DEPENDFILE}: ${_DEPENDFILES} + +# +# __FLAG_FILES is built from SRCS. That means it will contain +# also .h files and other files that are not direct sources, but which +# might be required to even run mkdep. This is important if those are +# generated as well, like some forwarding headers. +# +# We'll have to pass these "sources" on to the other .depend_ file targets, +# since otherwise they might be run before the generated sources are +# generated. _ALL_DEPENDS captures all files in SRCS that are not handled +# by the mkdep calls, i.e. all sources that are not being used directly +# for the .depend* file. +# +_ALL_DEPENDS=${__FLAGS_FILES:N*.[sS]:N*.c:N*.cc:N*.C:N*.cpp:N*.cpp:N*.cxx:N*.m} + +.for _FG in _ ${FLAGS_GROUPS} +.depend${_FG:S/^/_/:N__}: ${${_FG}_FLAGS_FILES} ${_ALL_DEPENDS} + -rm -f ${.TARGET} + -> ${.TARGET} +.if ${${_FG}_FLAGS_FILES:M*.[sS]} != "" + ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \ + ${${_FG}_FLAGS} \ ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \ ${AINC} \ ${.ALLSRC:M*.[sS]} .endif -.if ${SRCS:M*.c} != "" - ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ +.if ${${_FG}_FLAGS_FILES:M*.c} != "" + ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \ + ${${_FG}_FLAGS} \ ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \ + ${CFLAGS:M-std=*} \ ${.ALLSRC:M*.c} .endif -.if ${SRCS:M*.cc} != "" || ${SRCS:M*.C} != "" || ${SRCS:M*.cpp} != "" || \ - ${SRCS:M*.cxx} != "" - ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ +.if ${${_FG}_FLAGS_FILES:M*.cc} != "" || \ + ${${_FG}_FLAGS_FILES:M*.C} != "" || \ + ${${_FG}_FLAGS_FILES:M*.cpp} != "" || \ + ${${_FG}_FLAGS_FILES:M*.cxx} != "" + ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \ + ${${_FG}_FLAGS} \ ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \ + ${CXXFLAGS:M-std=*} \ ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx} .endif -.if ${SRCS:M*.m} != "" - ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ +.if ${${_FG}_FLAGS_FILES:M*.m} != "" + ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \ + ${${_FG}_FLAGS} \ ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \ ${OBJCFLAGS:M-Wno-import*} \ ${.ALLSRC:M*.m} .endif +.if !empty(${_FG:M_}) && !empty(_DEPENDFILES) + cat ${_DEPENDFILES} >> ${.TARGET} +.endif +.endfor + .if target(_EXTRADEPEND) _EXTRADEPEND: .USE ${DEPENDFILE}: _EXTRADEPEND .endif -.ORDER: ${DEPENDFILE} afterdepend +.ORDER: ${_DEPENDFILES} ${DEPENDFILE} afterdepend .else -depend: beforedepend afterdepend +depend: beforedepend _dependincs afterdepend .endif .if !target(beforedepend) beforedepend: .else -.ORDER: beforedepend ${DEPENDFILE} +.ORDER: beforedepend ${_DEPENDFILES} ${DEPENDFILE} .ORDER: beforedepend afterdepend .endif .if !target(afterdepend) @@ -158,9 +202,9 @@ afterdepend: cleandepend: .if defined(SRCS) .if ${CTAGS:T} == "ctags" - rm -f ${DEPENDFILE} tags + rm -f ${DEPENDFILE} ${_DEPENDFILES} tags .elif ${CTAGS:T} == "gtags" - rm -f ${DEPENDFILE} GPATH GRTAGS GSYMS GTAGS + rm -f ${DEPENDFILE} ${_DEPENDFILES} GPATH GRTAGS GSYMS GTAGS .if defined(HTML) rm -rf HTML .endif @@ -189,3 +233,15 @@ checkdpadd: fi .endif .endif + +.if defined(INCS) && make(depend) + +_dependincs: ${INCS} ${SRCS} + +.ORDER: _dependincs depend + +.else + +_dependincs: + +.endif