Changeset View
Changeset View
Standalone View
Standalone View
head/share/mk/dirdeps.mk
# $FreeBSD$ | # $FreeBSD$ | ||||
# $Id: dirdeps.mk,v 1.96 2018/06/20 22:26:39 sjg Exp $ | # $Id: dirdeps.mk,v 1.100 2019/11/12 06:47:58 sjg Exp $ | ||||
# Copyright (c) 2010-2013, Juniper Networks, Inc. | # Copyright (c) 2010-2013, Juniper Networks, Inc. | ||||
# All rights reserved. | # All rights reserved. | ||||
# | # | ||||
# Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | ||||
# modification, are permitted provided that the following conditions | # modification, are permitted provided that the following conditions | ||||
# are met: | # are met: | ||||
# 1. Redistributions of source code must retain the above copyright | # 1. Redistributions of source code must retain the above copyright | ||||
▲ Show 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | |||||
.if defined(NO_DIRDEPS) | .if defined(NO_DIRDEPS) | ||||
# confine ourselves to the original dir and below. | # confine ourselves to the original dir and below. | ||||
DIRDEPS_FILTER += M${_DEP_RELDIR}* | DIRDEPS_FILTER += M${_DEP_RELDIR}* | ||||
.elif defined(NO_DIRDEPS_BELOW) | .elif defined(NO_DIRDEPS_BELOW) | ||||
DIRDEPS_FILTER += M${_DEP_RELDIR} | DIRDEPS_FILTER += M${_DEP_RELDIR} | ||||
.endif | .endif | ||||
# this is what we run below | # this is what we run below | ||||
DIRDEP_MAKE?= ${.MAKE} | DIRDEP_MAKE ?= ${.MAKE} | ||||
DIRDEP_DIR ?= ${.TARGET:R} | |||||
# we suppress SUBDIR when visiting the leaves | # we suppress SUBDIR when visiting the leaves | ||||
# we assume sys.mk will set MACHINE_ARCH | # we assume sys.mk will set MACHINE_ARCH | ||||
# you can add extras to DIRDEP_USE_ENV | # you can add extras to DIRDEP_USE_ENV | ||||
# if there is no makefile in the target directory, we skip it. | # if there is no makefile in the target directory, we skip it. | ||||
_DIRDEP_USE: .USE .MAKE | _DIRDEP_USE: .USE .MAKE | ||||
@for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \ | @for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \ | ||||
test -s ${.TARGET:R}/$$m || continue; \ | test -s ${.TARGET:R}/$$m || continue; \ | ||||
echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \ | echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \ | ||||
${DIRDEP_USE_PRELUDE} \ | |||||
MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \ | MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \ | ||||
TARGET_SPEC=${.TARGET:E} \ | TARGET_SPEC=${.TARGET:E} \ | ||||
MACHINE=${.TARGET:E} \ | MACHINE=${.TARGET:E} \ | ||||
${DIRDEP_MAKE} -C ${.TARGET:R} || exit 1; \ | ${DIRDEP_MAKE} -C ${DIRDEP_DIR} || exit 1; \ | ||||
break; \ | break; \ | ||||
done | done | ||||
.ifdef ALL_MACHINES | .ifdef ALL_MACHINES | ||||
# this is how you limit it to only the machines we have been built for | # this is how you limit it to only the machines we have been built for | ||||
# previously. | # previously. | ||||
.if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST) | .if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST) | ||||
.if !empty(ALL_MACHINE_LIST) | .if !empty(ALL_MACHINE_LIST) | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
BUILD_DIRDEPS_TARGETS ?= ${.TARGETS} | BUILD_DIRDEPS_TARGETS ?= ${.TARGETS} | ||||
# we need the .meta file to ensure we update if | # we need the .meta file to ensure we update if | ||||
# any of the Makefile.depend* changed. | # any of the Makefile.depend* changed. | ||||
# We do not want to compare the command line though. | # We do not want to compare the command line though. | ||||
${DIRDEPS_CACHE}: .META .NOMETA_CMP | ${DIRDEPS_CACHE}: .META .NOMETA_CMP | ||||
+@{ echo '# Autogenerated - do NOT edit!'; echo; \ | +@{ echo '# Autogenerated - do NOT edit!'; echo; \ | ||||
echo 'BUILD_DIRDEPS=no'; echo; \ | echo 'BUILD_DIRDEPS=no'; echo; \ | ||||
echo '.include <dirdeps.mk>'; \ | echo '.include <dirdeps.mk>'; echo; \ | ||||
} > ${.TARGET}.new | } > ${.TARGET}.new | ||||
+@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \ | +@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \ | ||||
DIRDEPS="${DIRDEPS}" \ | DIRDEPS="${DIRDEPS}" \ | ||||
TARGET_SPEC=${TARGET_SPEC} \ | TARGET_SPEC=${TARGET_SPEC} \ | ||||
MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \ | MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \ | ||||
${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \ | ${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \ | ||||
.MAKE.DEPENDFILE=.none \ | .MAKE.DEPENDFILE=.none \ | ||||
${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \ | ${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \ | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | |||||
_build_all_dirs := ${_build_all_dirs:O:u} | _build_all_dirs := ${_build_all_dirs:O:u} | ||||
# Normally if doing make -V something, | # Normally if doing make -V something, | ||||
# we do not want to waste time chasing DIRDEPS | # we do not want to waste time chasing DIRDEPS | ||||
# but if we want to count the number of Makefile.depend* read, we do. | # but if we want to count the number of Makefile.depend* read, we do. | ||||
.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == "" | .if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == "" | ||||
.if !empty(_build_all_dirs) | .if !empty(_build_all_dirs) | ||||
.if ${BUILD_DIRDEPS_CACHE} == "yes" | .if ${BUILD_DIRDEPS_CACHE} == "yes" | ||||
x!= { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \ | # guard against _build_all_dirs being too big for a single command line | ||||
echo 'dirdeps: ${_build_all_dirs:${M_oneperline}}'; echo; } >&3; echo | # first get list of dirs that need _DIRDEP_USE | ||||
x!= { ${_build_all_dirs:@x@${target($x):?:echo '$x: _DIRDEP_USE';}@} echo; } >&3; echo | # then export that and _build_all_dirs | ||||
_new_dirdeps := ${_build_all_dirs:@x@${target($x):?:$x}@} | |||||
.export _new_dirdeps _build_all_dirs | |||||
x!= echo; { echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \ | |||||
echo "dirdeps: \\"; \ | |||||
for x in $$_build_all_dirs; do echo " $$x \\"; done; echo; \ | |||||
for x in $$_new_dirdeps; do echo "$$x: _DIRDEP_USE"; done; echo; } >&3 | |||||
.if !empty(DEP_EXPORT_VARS) | .if !empty(DEP_EXPORT_VARS) | ||||
# Discouraged, but there are always exceptions. | # Discouraged, but there are always exceptions. | ||||
# Handle it here rather than explain how. | # Handle it here rather than explain how. | ||||
x!= { echo; ${DEP_EXPORT_VARS:@v@echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3; echo | x!= { echo; ${DEP_EXPORT_VARS:@v@echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3; echo | ||||
.endif | .endif | ||||
.else | .else | ||||
# this makes it all happen | # this makes it all happen | ||||
dirdeps: ${_build_all_dirs} | dirdeps: ${_build_all_dirs} | ||||
Show All 13 Lines | |||||
.for m in ${_machines} | .for m in ${_machines} | ||||
# it would be nice to do :N${.TARGET} | # it would be nice to do :N${.TARGET} | ||||
.if !empty(__qual_depdirs) | .if !empty(__qual_depdirs) | ||||
.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m} | .for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m} | ||||
.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != "" | .if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != "" | ||||
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q} | .info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q} | ||||
.endif | .endif | ||||
.if ${BUILD_DIRDEPS_CACHE} == "yes" | .if ${BUILD_DIRDEPS_CACHE} == "yes" | ||||
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$q:${M_oneperline}}'; echo; } >&3; echo | _cache_deps := ${_build_dirs:M*.$q} | ||||
.export _cache_deps | |||||
x!= echo; { echo "${_this_dir}.$m: \\"; \ | |||||
for x in $$_cache_deps; do echo " $$x \\"; done; echo; } >&3 | |||||
.else | .else | ||||
${_this_dir}.$m: ${_build_dirs:M*.$q} | ${_this_dir}.$m: ${_build_dirs:M*.$q} | ||||
.endif | .endif | ||||
.endfor | .endfor | ||||
.endif | .endif | ||||
.if ${_debug_reldir} | .if ${_debug_reldir} | ||||
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m} | .info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m} | ||||
.endif | .endif | ||||
.if ${BUILD_DIRDEPS_CACHE} == "yes" | .if ${BUILD_DIRDEPS_CACHE} == "yes" | ||||
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m:${M_oneperline}}'; echo; } >&3; echo | _cache_deps := ${_build_dirs:M*.$m:N${_this_dir}.$m} | ||||
.export _cache_deps | |||||
x!= echo; { echo "${_this_dir}.$m: \\"; \ | |||||
for x in $$_cache_deps; do echo " $$x \\"; done; echo; } >&3 | |||||
.else | .else | ||||
${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m} | ${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m} | ||||
.endif | .endif | ||||
.endfor | .endfor | ||||
.endif | .endif | ||||
# Now find more dependencies - and recurse. | # Now find more dependencies - and recurse. | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |