From dc82989dd2747db0384cafb3b310f2e8792d5c24 Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Sun, 28 Jan 2018 00:29:16 +0100 Subject: [PATCH] Makefile: try harder to use correct Python interpreter In a Python 3-only system, there might not be an executable in the PATH to satisfy "python". In configure we attempt to find the "right" python command for the system we happen to be running in. With this patch, we let configure save this command to a temporary file. Subsequently, when make is run, it will find the command in that file and use it (or fall back to "python" if the file doesn't exist for whatever reason). Change-Id: If65f2fc505a924b940b2054882504b8cbe1a53aa Signed-off-by: Nathan Cutler Reviewed-on: https://review.gerrithub.io/397022 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- .gitignore | 1 + Makefile | 4 +++- configure | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b7d5fe968..0a193fea7 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ CONFIG.local .cproject .settings mk/cc.mk +PYTHON_COMMAND diff --git a/Makefile b/Makefile index 51810be89..24ac6ac2b 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,9 @@ mk/cc.mk: rm -f $@.tmp config.h: CONFIG CONFIG.local scripts/genconfig.py - $(Q)python scripts/genconfig.py $(MAKEFLAGS) > $@.tmp; \ + $(Q)PYCMD=$$(cat PYTHON_COMMAND 2>/dev/null) ; \ + test -z "$$PYCMD" && PYCMD=python ; \ + $$PYCMD scripts/genconfig.py $(MAKEFLAGS) > $@.tmp; \ cmp -s $@.tmp $@ || mv $@.tmp $@ ; \ rm -f $@.tmp diff --git a/configure b/configure index 27309cf17..cfae6db8a 100755 --- a/configure +++ b/configure @@ -274,6 +274,8 @@ if [[ -z "$python_command" ]] ; then exit 1 fi +rm -f PYTHON_COMMAND +echo $python_command > PYTHON_COMMAND $python_command scripts/genconfig.py > config.h echo "done."