]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
xen/build: Automatically locate a suitable python interpreter
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 7 Dec 2019 15:50:22 +0000 (15:50 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 Dec 2019 17:23:39 +0000 (17:23 +0000)
Needing to pass PYTHON=python3 into hypervisor builds is irritating and
unnecessary.  Locate a suitable interpreter automatically, defaulting to Py3
if it is available.

Reported-by: Steven Haigh <netwiz@crc.id.au>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/Makefile

index 949ca6eb035392fac4deb069cb854b0e48cbacf8..f36a5bc6c06e6f82cb4ab74868337e6fbb0f2a52 100644 (file)
@@ -13,6 +13,11 @@ export XEN_BUILD_TIME        ?= $(shell LC_ALL=C date +%T)
 export XEN_BUILD_HOST  ?= $(shell hostname)
 export XEN_CONFIG_EXPERT ?= n
 
+# Best effort attempt to find a python interpreter, defaulting to Python 3 if
+# available.  Fall back to just `python` if `which` is nowhere to be found.
+PYTHON_INTERPRETER     := $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+export PYTHON          ?= $(PYTHON_INTERPRETER)
+
 export BASEDIR := $(CURDIR)
 export XEN_ROOT := $(BASEDIR)/..