Hi TIAN, On Thu, 15 Aug 2024 at 12:01, TIAN Yuanhao <tianyuanhao3@xxxxxxx> wrote: > > At present Linux always builds dtc if CONFIG_DTC is defined, even when > DTC is provided. The built dtc is not actually used, so this is a waste > of time. > > Update the Makefile logic to build dtc and fdtoverlay only if DTC or > FDTOVERLAY is not provided. > > Also, add an fdtoverlay wrapper to hide the actual path differences of > fdtoverlay from the make_fit.py script. > > Refs: > https://github.com/u-boot/u-boot/commit/93b196532254366f653b4d763f69e49ff193f06c > https://github.com/torvalds/linux/commit/6b22b3d1614af1a775f2ef006009f15077592c9c > > Signed-off-by: TIAN Yuanhao <tianyuanhao3@xxxxxxx> > Cc: Chen-Yu Tsai <wenst@xxxxxxxxxxxx> > Cc: Rob Herring (Arm) <robh@xxxxxxxxxx> > Cc: Simon Glass <sjg@xxxxxxxxxxxx> > Cc: Viresh Kumar <viresh.kumar@xxxxxxxxxx> > Cc: linux-kbuild@xxxxxxxxxxxxxxx > --- > Makefile | 13 ++++++++++++- > scripts/Makefile.lib | 5 ++--- > scripts/fdtoverlay.sh | 7 +++++++ > scripts/make_fit.py | 2 +- > 4 files changed, 22 insertions(+), 5 deletions(-) > create mode 100755 scripts/fdtoverlay.sh > Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx> > diff --git a/Makefile b/Makefile > index 0a364e34f50b..6e56696e85a1 100644 > --- a/Makefile > +++ b/Makefile > @@ -1419,9 +1419,20 @@ endif > > endif > > +# The dtc and fdtoverlay are automatically built unless DTC or FDTOVERLAY is > +# provided. > +DTC_INTREE := $(objtree)/scripts/dtc/dtc > +DTC ?= $(DTC_INTREE) > + > +FDTOVERLAY_INTREE := $(objtree)/scripts/dtc/fdtoverlay > +FDTOVERLAY ?= $(FDTOVERLAY_INTREE) > + > PHONY += scripts_dtc > scripts_dtc: scripts_basic > - $(Q)$(MAKE) $(build)=scripts/dtc > + $(Q)if [ "$(DTC)" = "$(DTC_INTREE)" ] || \ > + [ "$(FDTOVERLAY)" = "$(FDTOVERLAY_INTREE)" ]; then \ > + $(MAKE) $(build)=scripts/dtc; \ > + fi > > ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),) > export CHECK_DTBS=y > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index fe3668dc4954..04ba30dadc8f 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -352,7 +352,6 @@ quiet_cmd_gzip = GZIP $@ > > # DTC > # --------------------------------------------------------------------------- > -DTC ?= $(objtree)/scripts/dtc/dtc > DTC_FLAGS += \ > -Wno-unique_unit_address > > @@ -415,10 +414,10 @@ DT_CHECK_CMD = $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) > # recorded in the .*.cmd file. > ifneq ($(CHECK_DTBS),) > quiet_cmd_fdtoverlay = DTOVLCH $@ > - cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) ; $(DT_CHECK_CMD) $@ || true > + cmd_fdtoverlay = $(objtree)/scripts/fdtoverlay.sh -o $@ -i $(filter %.dtb %.dtbo, $^) ; $(DT_CHECK_CMD) $@ || true > else > quiet_cmd_fdtoverlay = DTOVL $@ > - cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) > + cmd_fdtoverlay = $(objtree)/scripts/fdtoverlay.sh -o $@ -i $(filter %.dtb %.dtbo, $^) > endif > > $(multi-dtb-y): FORCE > diff --git a/scripts/fdtoverlay.sh b/scripts/fdtoverlay.sh > new file mode 100755 > index 000000000000..5bd07c47c22a > --- /dev/null > +++ b/scripts/fdtoverlay.sh > @@ -0,0 +1,7 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > +# > +# An fdtoverlay wrapper > +# scripts/make_fit.py uses the name of this script as a special marker. > + > +exec "${FDTOVERLAY}" "$@" > diff --git a/scripts/make_fit.py b/scripts/make_fit.py > index 4a1bb2f55861..37c4e1c8d5c6 100755 > --- a/scripts/make_fit.py > +++ b/scripts/make_fit.py > @@ -238,7 +238,7 @@ def process_dtb(fname, args): > with open(cmd_fname, 'r', encoding='ascii') as inf: > cmd = inf.read() > > - if 'scripts/dtc/fdtoverlay' in cmd: > + if '/scripts/fdtoverlay.sh ' in cmd: > # This depends on the structure of the composite DTB command > files = cmd.split() > files = files[files.index('-i') + 1:] > > base-commit: 6b0f8db921abf0520081d779876d3a41069dab95 > -- > 2.45.1 >