From 8b427c851e6e0979c598b95d2c04d5deab10352d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 13 Jul 2021 18:14:25 +0200 Subject: [PATCH] Use python3 when building on non-Windows for Windows The makefiles look for python3 on Unix-like systems where python is often Python 2. This uses sh code so it doesn't work on Windows. On Windows, the makefiles just assume that python is Python 3. The code was incorrectly deciding not to try python3 based on WINDOWS_BUILD, which indicates that the build is *for* Windows. Switch to checking WINDOWS, which indicates that the build is *on* Windows. Fix #4774 Signed-off-by: Gilles Peskine --- ChangeLog.d/makefile-python-windows.txt | 4 ++++ programs/Makefile | 6 +++++- tests/Makefile | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 ChangeLog.d/makefile-python-windows.txt diff --git a/ChangeLog.d/makefile-python-windows.txt b/ChangeLog.d/makefile-python-windows.txt new file mode 100644 index 000000000000..57ccc1a39a55 --- /dev/null +++ b/ChangeLog.d/makefile-python-windows.txt @@ -0,0 +1,4 @@ +Bugfix + * The GNU makefiles invoke python3 in preference to python except on Windows. + The check was accidentally not performed when cross-compiling for Windows + on Linux. Fix this. Fixes #4774. diff --git a/programs/Makefile b/programs/Makefile index 997c198716ab..55ebd601a9cc 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -43,11 +43,15 @@ LOCAL_LDFLAGS += -lws2_32 ifdef SHARED SHARED_SUFFIX=.$(DLEXT) endif -PYTHON ?= python else DLEXT ?= so EXEXT= SHARED_SUFFIX= +endif + +ifdef WINDOWS +PYTHON ?= python +else PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi) endif diff --git a/tests/Makefile b/tests/Makefile index 6695437bf252..251a9c6fc90e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -50,11 +50,15 @@ LOCAL_LDFLAGS += -lws2_32 ifdef SHARED SHARED_SUFFIX=.$(DLEXT) endif -PYTHON ?= python else DLEXT ?= so EXEXT= SHARED_SUFFIX= +endif + +ifdef WINDOWS +PYTHON ?= python +else PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi) endif