
On 19/10/2023 15.04, Richard Marko wrote:
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`.
I think this patch is very hard to read because of the initial check that moves all the other checks a level down and increases the indent.
I was more thinking you could let make do the work instead of doing it in embedded shell script. Something like
diff --git a/Makefile b/Makefile index aeaa6987360..f313e9dba66 100644 --- a/Makefile +++ b/Makefile @@ -419,6 +419,11 @@ PYTHON3 ?= python3 DTC_INTREE := $(objtree)/scripts/dtc/dtc DTC ?= $(DTC_INTREE) DTC_MIN_VERSION := 010406 +ifneq ($(DTC),$(DTC_INTREE)) +ifneq ($(patsubst /%,,$(DTC)),) +$(error "$$(DTC) must be an absolute path") +endif +endif
CHECK = sparse
seems to work (though I have only tested it very lightly). One could also add
ifeq ($(wildcard $(DTC)),) $(error "$$(DTC) = $(DTC) does not exist") endif
inside the outer ifneq to make the failure very explicit.
Rasmus