[PATCH v2] make: check if DTC variable is an absolute path
Richard Marko
srk at 48.io
Thu Oct 19 15:04:12 CEST 2023
If we try to build using external dtc using
> make DTC=dtc
we get a confusing error like
> make[2]: *** No rule to make target 'arch/x86/dts/bayleybay.dtb',
> needed by 'dtbs'. Stop.
Workaround is to use
> make DTC=$( which dtc )
which gives make a full path, so the dependency
is satisfied.
This was introduced by commit d50af66
kbuild: add dtc as dependency on .dtb file
This patch checks that DTC is an absolute path
and fails early if not.
We also replace `which` in `scripts/dtc-version.sh`
with POSIXy `command -v`.
Signed-off-by: Richard Marko <srk at 48.io>
---
Makefile | 21 +++++++++++++--------
scripts/dtc-version.sh | 2 +-
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index b204a50043..9649f88722 100644
--- a/Makefile
+++ b/Makefile
@@ -2014,18 +2014,23 @@ scripts_dtc: scripts_basic
$(Q)if test "$(DTC)" = "$(DTC_INTREE)"; then \
$(MAKE) $(build)=scripts/dtc; \
else \
- if ! $(DTC) -v >/dev/null; then \
- echo '*** Failed to check dtc version: $(DTC)'; \
+ if [ ! "$(DTC)" = "$(wildcard $(DTC))" ]; then \
+ echo "*** DTC is not an absolute path"; \
false; \
else \
- if test "$(call dtc-version)" -lt $(DTC_MIN_VERSION); then \
- echo '*** Your dtc is too old, please upgrade to dtc $(DTC_MIN_VERSION) or newer'; \
+ if ! $(DTC) -v >/dev/null; then \
+ echo '*** Failed to check dtc version: $(DTC)'; \
false; \
else \
- if [ -n "$(CONFIG_PYLIBFDT)" ]; then \
- if ! echo "import libfdt" | $(PYTHON3) 2>/dev/null; then \
- echo '*** pylibfdt does not seem to be available with $(PYTHON3)'; \
- false; \
+ if test "$(call dtc-version)" -lt $(DTC_MIN_VERSION); then \
+ echo '*** Your dtc is too old, please upgrade to dtc $(DTC_MIN_VERSION) or newer'; \
+ false; \
+ else \
+ if [ -n "$(CONFIG_PYLIBFDT)" ]; then \
+ if ! echo "import libfdt" | $(PYTHON3) 2>/dev/null; then \
+ echo '*** pylibfdt does not seem to be available with $(PYTHON3)'; \
+ false; \
+ fi; \
fi; \
fi; \
fi; \
diff --git a/scripts/dtc-version.sh b/scripts/dtc-version.sh
index 53ff868bcd..1e2f0c8a8b 100755
--- a/scripts/dtc-version.sh
+++ b/scripts/dtc-version.sh
@@ -15,7 +15,7 @@ if [ ${#dtc} -eq 0 ]; then
exit 1
fi
-if ! which $dtc >/dev/null ; then
+if ! command -v $dtc >/dev/null ; then
echo "Error: Cannot find dtc: $dtc"
exit 1
fi
--
2.42.0
More information about the U-Boot
mailing list