From 3809e30273e03d762595dbc2a62f3a8398281ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 14 Aug 2017 08:59:11 +0200 Subject: [PATCH] Makefile: honor PYTHON configuration properly 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 in other places: 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 libfdt import checks need to be done against Python 2 as well since the Python 2 compiled modules (in this case _libdft.so) can not be imported from Python 3. Note on the libfdt imports: "@if ! PYTHONPATH=tools $(PYTHON) -c 'import libfdt'; then..." is probably simpler than the currently sub-optimal pipe. Reviewed-by: Jonathan Gray --- Makefile | 2 +- scripts/Makefile.spl | 2 +- tools/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2fc4616..a0f3bfd 100644 --- a/Makefile +++ b/Makefile @@ -1379,7 +1379,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/scripts/Makefile.spl b/scripts/Makefile.spl index 3ba0007..dd8065d 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -369,7 +369,7 @@ ifneq ($(cmd_files),) endif checkdtoc: tools - @if ! ( echo 'import libfdt' | ( PYTHONPATH=tools python )); then \ + @if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \ echo '*** dtoc needs the Python libfdt library. Either '; \ echo '*** install it on your system, or try:'; \ echo '***'; \ diff --git a/tools/Makefile b/tools/Makefile index a1790eb..086c533 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),)