[U-Boot] [PATCH RFC] Makefile: Extend PYTHONPATH rather than overriding it

Tuomas Tynkkynen tuomas.tynkkynen at iki.fi
Tue Nov 7 16:18:55 UTC 2017


Currently, if the user has compiled the libfdt Python module from dtc
upstream to a non-default location, it cannot be used because the
'PYTHONPATH=tools' assignment wipes out the user's PYTHONPATH.
Instead, extend PYTHONPATH in the main Makefile instead of overriding it.

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen at iki.fi>
---
 Makefile             | 10 ++++++++--
 scripts/Makefile.spl |  6 ++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 91f41fea84..58810a4308 100644
--- a/Makefile
+++ b/Makefile
@@ -348,10 +348,16 @@ OBJCOPY		= $(CROSS_COMPILE)objcopy
 OBJDUMP		= $(CROSS_COMPILE)objdump
 AWK		= awk
 PERL		= perl
-PYTHON		?= python
 DTC		?= $(objtree)/scripts/dtc/dtc
 CHECK		= sparse
 
+PYTHON		?= python
+ifeq ($(PYTHONPATH),)
+PYTHONPATH := tools
+else
+PYTHONPATH := $(PYTHONPATH):tools
+endif
+
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
 
@@ -1380,7 +1386,7 @@ $(timestamp_h): $(srctree)/Makefile FORCE
 	$(call filechk,timestamp.h)
 
 checkbinman: tools
-	@if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \
+	@if ! ( echo 'import libfdt' | $(PYTHON) ); then \
 		echo >&2; \
 		echo >&2 '*** binman needs the Python libfdt library.'; \
 		echo >&2 '*** Either install it on your system, or try:'; \
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 49b27ac926..6a370bccf8 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -257,13 +257,11 @@ quiet_cmd_fdtgrep = FDTGREP $@
 $(obj)/$(SPL_BIN).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
 	$(call if_changed,fdtgrep)
 
-pythonpath = PYTHONPATH=tools
-
 quiet_cmd_dtocc = DTOC C  $@
-cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata
+cmd_dtocc = $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata
 
 quiet_cmd_dtoch = DTOC H  $@
-cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct
+cmd_dtoch = $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct
 
 quiet_cmd_plat = PLAT    $@
 cmd_plat = $(CC) $(c_flags) -c $< -o $@
-- 
2.15.0



More information about the U-Boot mailing list