# # $FreeBSD$ # # This list of include makefiles is passed to jdirdep for it to use when # deciding where in a Buildfile to write the DIRDEP= and SRCDIRDEP= lines. INCMK= \ bsd.buildlib.mk \ bsd.buildtools.mk \ bsd.headers.mk \ bsd.kernconf.mk \ bsd.kernel.mk \ bsd.lib.mk \ bsd.objs.mk \ bsd.package.mk \ bsd.prog.mk \ bsd.scripts.mk \ jnx.errmsg.mk \ jnx.rrdl.mk \ pfe.common.mk \ pfe.lib.mk \ pfe.pm.mk \ pfe.mk .if exists(${.CURDIR}/Buildfile.dep) .include "${.CURDIR}/Buildfile.dep" .endif JDIRDEP ?= jdirdep ENV_JDIRDEP= CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} SRCTOP=${.SRCTOP} SUPMAC=${MACHINE_LIST:Q} .for t in ${MACHINE_LIST} ENV_JDIRDEP+= MACHINE_ARCH_${t:S/-/_/g}=${MACHINE_ARCH.${t}} .endfor ENV_JDIRDEP+= INCMK=${INCMK:Q} _ONE_MACHINE = no .if defined(HOSTPROG) _ONE_MACHINE= yes ONE_MACHINE = host .endif .if defined(COMMONDIR) _ONE_MACHINE= yes ONE_MACHINE = common .endif .if defined(TARGET_MACHINE) _ONE_MACHINE= yes ONE_MACHINE = ${TARGET_MACHINE} .endif # Generate Buildfile.dirdep for the current directory. # Note: This writes to the source tree! .if make(gendirdep) .if ${.SRCREL} == stage DIRDEP = .elif !defined(DIRDEP) DIRDEP = stage .endif PARINC= .if exists(${.CURDIR}/../Buildfile.inc) PARINC= ${.CURDIR}/../Buildfile.inc .endif _DIRDEP= _XDIRDEP= .for d in ${DIRDEP} _d=${d:M*MACHINE_ARCH*} .if !empty(_d) _XDIRDEP+= ${d} .else _DIRDEP+= ${d} .endif .endfor .for t in ${MACHINE_LIST} DIRDEP.${t}?= .endfor BUILDFILE_DIRDEP= ${.CURDIR}/Buildfile.dirdep gendirdep : .PHONY rm -f ${BUILDFILE_DIRDEP} echo "# This file is automatically generated. DO NOT EDIT!" >> ${BUILDFILE_DIRDEP} echo ".if !defined(NODIRDEP)" >> ${BUILDFILE_DIRDEP} .for t in ${MACHINE_LIST} .if !empty(DIRDEP.${t}) { for _d in ${DIRDEP.${t}}; \ do \ echo -n "dirdep := $$"; \ echo "{.SRCTOP}/$${_d}/Buildfile.dirdep"; \ echo -n ".if empty(.MAKEFILE_LIST:M$$"; \ echo "{dirdep})"; \ echo -n ".if exists($$"; \ echo "{dirdep})"; \ echo -n ".include \"$$"; \ echo "{dirdep}\""; \ echo ".endif"; \ echo ".endif"; \ echo ""; \ done; \ } >> ${BUILDFILE_DIRDEP} .endif .endfor .if defined(DIRDEP) && !empty(DIRDEP) { for _d in ${_DIRDEP}; \ do \ echo -n "dirdep := $$"; \ echo "{.SRCTOP}/$${_d}/Buildfile.dirdep"; \ echo -n ".if empty(.MAKEFILE_LIST:M$$"; \ echo "{dirdep})"; \ echo -n ".if exists($$"; \ echo "{dirdep})"; \ echo -n ".include \"$$"; \ echo "{dirdep}\""; \ echo ".endif"; \ echo ".endif"; \ echo ""; \ done; \ for _d in ${_XDIRDEP}; \ do \ echo -n ".for t in $$"; \ echo "{MACHINE_LIST}"; \ echo "_d=$$_d"; \ echo -n "dirdep := $$"; \ echo -n "{.SRCTOP}/$$"; \ echo -n "{_d:S,MACHINE_ARCH,$$"; \ echo -n "{MACHINE_ARCH.$$"; \ echo "{t}},g}/Buildfile.dirdep"; \ echo -n ".if empty(.MAKEFILE_LIST:M$$"; \ echo "{dirdep})"; \ echo -n ".if exists($$"; \ echo "{dirdep})"; \ echo -n ".include \"$$"; \ echo "{dirdep}\""; \ echo ".endif"; \ echo ".endif"; \ echo ""; \ echo ".endfor"; \ done; \ } >> ${BUILDFILE_DIRDEP} .endif echo ".endif" >> ${BUILDFILE_DIRDEP} { echo ""; \ echo -n ".for t in $$"; \ echo "{MACHINE_LIST}"; \ echo -n "D_TGTS_$$"; \ echo "{t}="; \ echo ".endfor"; \ echo ""; \ } >> ${BUILDFILE_DIRDEP} echo ".if !defined(NODIRDEP)" >> ${BUILDFILE_DIRDEP} .for t in ${MACHINE_LIST} .if !empty(DIRDEP.${t}) { for _d in ${DIRDEP.${t}}; \ do \ echo -n ".if exists($$"; \ echo "{.SRCTOP}/$${_d}/Buildfile.dirdep)"; \ echo -n "D_TGTS_${t}+="; \ echo -n " $$"; \ echo "{.OBJROOT}/${t}/$${_d}/all"; \ echo -n "D_TGTS_${t}:= $$"; \ echo "{D_TGTS_${t}}"; \ echo ".endif"; \ echo ""; \ done; \ } >> ${BUILDFILE_DIRDEP} .endif .endfor .if defined(ONLY_MACHINE) echo "_MACHINE_LIST:= ${ONLY_MACHINE}" >> ${BUILDFILE_DIRDEP} .else { echo -n "_MACHINE_LIST:= $$"; \ echo "{MACHINE_LIST}"; } >> ${BUILDFILE_DIRDEP} .endif .if defined(DIRDEP) && !empty(DIRDEP) { for _d in ${_DIRDEP}; \ do \ echo -n ".if exists($$"; \ echo "{.SRCTOP}/$${_d}/Buildfile.dirdep)"; \ echo -n ".for _t in $$"; \ echo "{_MACHINE_LIST}"; \ echo -n "D_TGTS_$$"; \ echo -n "{_t}+="; \ echo -n " $$"; \ echo -n "{.OBJROOT}/$$"; \ echo "{_t}/$${_d}/all"; \ echo -n "D_TGTS_$$"; \ echo -n "{_t}:= $$"; \ echo -n "{D_TGTS_$$"; \ echo "{_t}}"; \ echo ".endfor"; \ echo ".endif"; \ echo ""; \ done; \ for _d in ${_XDIRDEP}; \ do \ echo -n ".for t in $$"; \ echo "{_MACHINE_LIST}"; \ echo "_d=$$_d"; \ echo -n ".if exists($$"; \ echo -n "{.SRCTOP}/$$"; \ echo -n "{_d:S,MACHINE_ARCH,$$"; \ echo -n "{MACHINE_ARCH.$$"; \ echo "{t}},g}/Buildfile.dirdep)"; \ echo -n "D_TGTS_$$"; \ echo -n "{t}+="; \ echo -n " $$"; \ echo -n "{.OBJROOT}/$$"; \ echo -n "{t}/$$"; \ echo -n "{_d:S,MACHINE_ARCH,$$"; \ echo -n "{MACHINE_ARCH.$$"; \ echo "{t}},g}/all"; \ echo -n "D_TGTS_$$"; \ echo -n "{t}:= $$"; \ echo -n "{D_TGTS_$$"; \ echo "{t}}"; \ echo ".endif"; \ echo ""; \ echo ".endfor"; \ done; \ echo ""; \ } >> ${BUILDFILE_DIRDEP} .endif echo ".endif" >> ${BUILDFILE_DIRDEP} { \ if [ ${_ONE_MACHINE} = yes ]; \ then \ echo -n ".for t in $$"; \ echo "{MACHINE_LIST:N${ONE_MACHINE}}"; \ echo -n "$$"; \ echo -n "{.OBJROOT}/$$"; \ echo -n "{t}/${.SRCREL}/all : $$"; \ echo "{.OBJROOT}/${ONE_MACHINE}/${.SRCREL}/all .PHONY"; \ echo ".endfor"; \ echo -n "$$"; \ echo -n "{.OBJROOT}/${ONE_MACHINE}/${.SRCREL}/all : $$"; \ echo "{D_TGTS_${ONE_MACHINE}} .PHONY"; \ echo -n " echo Checking $$"; \ echo "{.OBJROOT}/${ONE_MACHINE}/${.SRCREL}"; \ echo -n " cd $$"; \ echo -n "{.SRCTOP}/${.SRCREL} && MACHINE=${ONE_MACHINE} $$"; \ echo -n "{MAKE} $$"; \ echo "{.MAKEFLAGS:NMACHINE=*:N-DALLMACHINES} all"; \ else \ echo -n ".for t in $$"; \ echo "{MACHINE_LIST}"; \ echo -n "$$"; \ echo -n "{.OBJROOT}/$$"; \ echo -n "{t}/${.SRCREL}/all : $$"; \ echo -n "{D_TGTS_$$"; \ echo "{t}} .PHONY"; \ echo -n " echo Checking $$"; \ echo -n "{.OBJROOT}/$$"; \ echo "{t}/${.SRCREL}"; \ echo -n " cd $$"; \ echo -n "{.SRCTOP}/${.SRCREL} && MACHINE=$$"; \ echo -n "{t} $$"; \ echo -n "{MAKE} $$"; \ echo "{.MAKEFLAGS:NMACHINE=*:N-DALLMACHINES} all"; \ echo ".endfor"; \ fi; \ } >> ${BUILDFILE_DIRDEP} # Figure out what DIRDEP= should be .elif make(getdirdep) getdirdep : .PHONY echo "Reading the meta data files to determine the directory dependencies..." ${ENV_JDIRDEP} ${JDIRDEP} # Generate a graph of directory dependencies .elif make(graphdirdep) graphdirdep : .PHONY ${ENV_JDIRDEP} ${JDIRDEP} -g unflatten -l 4 -f 4 ${.OBJDIR}/dirdep.gv | dot -Tps2 -o ${.OBJDIR}/dirdep.ps ps2pdf ${.OBJDIR}/dirdep.ps ${.OBJDIR}/dirdep.pdf # Do a recursive update of DIRDEP= in the Buildfiles .elif make(regendirdep) regendirdep : .PHONY echo "Updating Buildfile.dirdep ..." ${ENV_JDIRDEP} ${JDIRDEP} -rf # Do a recursive parse of meta data to check for source usage .elif make(rsrcdirdep) rsrcdirdep : .PHONY echo "Parsing meta data for source usage..." ${ENV_JDIRDEP} ${JDIRDEP} -rs # Do a parse of meta data to check for source usage .elif make(srcdirdep) srcdirdep : .PHONY echo "Parsing meta data for source usage..." ${ENV_JDIRDEP} ${JDIRDEP} -s # Do a recursive update of DIRDEP= in the Buildfiles .elif make(rupdatedirdep) rupdatedirdep : .PHONY echo "Updating DIRDEP in Buildfile..." ${ENV_JDIRDEP} ${JDIRDEP} -rsu # Update of DIRDEP= in the current Buildfile .elif make(updatedirdep) updatedirdep : .PHONY echo "Updating DIRDEP in Buildfiles..." ${ENV_JDIRDEP} ${JDIRDEP} -su .elif make(filedep) filedep : .PHONY ${ENV_JDIRDEP} ${JDIRDEP} -d ${.SRCTOP} .elif make(rfiledep) rfiledep : .PHONY ${ENV_JDIRDEP} ${JDIRDEP} -rd ${.SRCTOP} .else # Only include dependencies in the top-level build .if ${__MKLVL__} == 1 # Generate the initial Buildfile.dirdep if there isn't one yet. .if !exists(${.CURDIR}/Buildfile.dirdep) __X!= cd ${.CURDIR} && ${MAKE} gendirdep .endif # Include the dependencies for the things that this directory depends on. # This will recursively include all other dependencies until we have a # complete set starting with this directory. .include "${.CURDIR}/Buildfile.dirdep" .if target(all) .error "The top level 'all' target is defined only in bsd.dirdep.mk!" .else # This is the main target for _all_ top level builds. It is used only to # do builds on a directory by directory basis, including this directory. all : dirdep .PHONY D_TGTS= .if ${_ONE_MACHINE} == yes D_TGTS+= ${.OBJROOT}/${ONE_MACHINE}/${.SRCREL}/all .else .if defined(ONLY_MACHINE) _MACHINES= .for m in ${ONLY_MACHINE} .if !empty(MACHINES:M${m}) _MACHINES+= ${m} _MACHINES:= ${_MACHINES} .endif .endfor MACHINES:= ${_MACHINES} .endif .for t in ${MACHINES} D_TGTS+= ${D_TGTS_${t}} D_TGTS+= ${.OBJROOT}/${t}/${.SRCREL}/all .endfor .endif dirdep : ${D_TGTS} .PHONY .endif .else .if !target(all) # We do everything by dependencies. all : .PHONY .endif .endif .endif