[U-Boot] [PATCH] Makefile: honor PYTHON configuration properly

Clément Bœsch u at pkh.me
Sun Aug 13 22:36:09 UTC 2017


On some systems `python` is `python3` (for instance, Archlinux). The `PYTHON`
variable can be used to point to `python2` to have a successful build.

The use of `PYTHON` is currently limited in the Makefile and needs to be
extended to at 2 other cases:

First, pylibfdt is required to be a Python 2 binding (binman imports pylibfdt
and is only compatible Python 2), so its setup.py needs to be called
accordingly. An alternative would be to change the libfdt setup.py shebang to
python2, but the binding is actually portable. Also, it would break on system
where there is no such thing as `python2`.

Secondly, the check of the libfdt import needs to be check against specificed
Python 2 path since the Python 2 compiled modules (in this case _libdft.so) are
not compatible with Python 3.

Note on the libfdt import: "@if $(PYTHON) -c 'import libfdt'; then..." is
probably simpler than the currently overkill sub-shells.
---
 Makefile       | 2 +-
 tools/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 50a002e72f..1f70144e0a 100644
--- a/Makefile
+++ b/Makefile
@@ -1378,7 +1378,7 @@ $(timestamp_h): $(srctree)/Makefile FORCE
 	$(call filechk,timestamp.h)
 
 checkbinman: tools
-	@if ! ( echo 'import libfdt' | ( PYTHONPATH=tools python )); then \
+	@if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(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/tools/Makefile b/tools/Makefile
index 0743677dc8..1940cdad1f 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -138,7 +138,7 @@ tools/_libfdt.so: $(LIBFDT_SRCS) $(LIBFDT_SWIG)
 		CPPFLAGS="$(_hostc_flags)" OBJDIR=tools \
 		SOURCES="$(LIBFDT_SRCS) tools/libfdt.i" \
 		SWIG_OPTS="-I$(srctree)/lib/libfdt -I$(srctree)/lib" \
-		$(libfdt_tree)/pylibfdt/setup.py --quiet build_ext \
+		$(PYTHON) $(libfdt_tree)/pylibfdt/setup.py build_ext \
 			--build-lib tools
 
 ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
-- 
2.14.0



More information about the U-Boot mailing list