Makefile: don't assume python is called `python3`
authorSean Cross <sean@xobs.io>
Sat, 19 Oct 2019 06:04:52 +0000 (14:04 +0800)
committerSean Cross <sean@xobs.io>
Sat, 19 Oct 2019 06:04:52 +0000 (14:04 +0800)
On some architectures, notably on Windows, the official name for the
Python binary from python.org is `python`.  The build system assumes
that python is called `python3`, which breaks under this architecture.

There is already infrastructure in place to determine the name of the
Python binary when building PYOSYS.  Since Python is now always required
to build Yosys, enable this check universally which sets the
`PYTHON_EXECUTABLE` variable.

Then, reuse this variable in other Makefiles as necessary, rather than
hardcoding `python3` everywhere.

Signed-off-by: Sean Cross <sean@xobs.io>
Makefile
passes/pmgen/Makefile.inc
techlibs/common/Makefile.inc
techlibs/ecp5/Makefile.inc
techlibs/ice40/Makefile.inc
techlibs/xilinx/Makefile.inc

index a24f19b6a6d31b4316ba571d39a269a1102ce341..845a97b50df3f2a9d75f6cc0f4e07c4b77a1d76f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -147,9 +147,9 @@ $(info $(subst $$--$$,$(newline),$(shell sed 's,^,[Makefile.conf] ,; s,$$,$$--$$
 include Makefile.conf
 endif
 
+PYTHON_EXECUTABLE := $(shell if python3 -c ""; then echo "python3"; else echo "python"; fi)
 ifeq ($(ENABLE_PYOSYS),1)
 PYTHON_VERSION_TESTCODE := "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));print(t)"
-PYTHON_EXECUTABLE := $(shell if python3 -c ""; then echo "python3"; else echo "python"; fi)
 PYTHON_VERSION := $(shell $(PYTHON_EXECUTABLE) -c ""$(PYTHON_VERSION_TESTCODE)"")
 PYTHON_MAJOR_VERSION := $(shell echo $(PYTHON_VERSION) | cut -f1 -d.)
 PYTHON_PREFIX := $(shell $(PYTHON_EXECUTABLE)-config --prefix)
index 366c37943a40b506158dc41ff3a6824225ee6d4c..145d2ebf989a0957f2aa700764c220a40dda2eba 100644 (file)
@@ -1,5 +1,5 @@
 %_pm.h: passes/pmgen/pmgen.py %.pmg
-       $(P) mkdir -p passes/pmgen && python3 $< -o $@ -p $(subst _pm.h,,$(notdir $@)) $(filter-out $<,$^)
+       $(P) mkdir -p passes/pmgen && $(PYTHON_EXECUTABLE) $< -o $@ -p $(subst _pm.h,,$(notdir $@)) $(filter-out $<,$^)
 
 # --------------------------------------
 
@@ -38,7 +38,7 @@ PEEPOPT_PATTERN += passes/pmgen/peepopt_muldiv.pmg
 PEEPOPT_PATTERN += passes/pmgen/peepopt_dffmux.pmg
 
 passes/pmgen/peepopt_pm.h: passes/pmgen/pmgen.py $(PEEPOPT_PATTERN)
-       $(P) mkdir -p passes/pmgen && python3 $< -o $@ -p peepopt $(filter-out $<,$^)
+       $(P) mkdir -p passes/pmgen && $(PYTHON_EXECUTABLE) $< -o $@ -p peepopt $(filter-out $<,$^)
 
 # --------------------------------------
 
index 6c0a4fe66dd1db757c030c7f0ff426fcc7f02728..a42f63128042a766dcf3bc7ed43aeff3fe8bf0d7 100644 (file)
@@ -9,12 +9,12 @@ GENFILES += techlibs/common/simcells_help.inc
 
 techlibs/common/simlib_help.inc: techlibs/common/cellhelp.py techlibs/common/simlib.v
        $(Q) mkdir -p techlibs/common
-       $(P) python3 $^ > $@.new
+       $(P) $(PYTHON_EXECUTABLE) $^ > $@.new
        $(Q) mv $@.new $@
 
 techlibs/common/simcells_help.inc: techlibs/common/cellhelp.py techlibs/common/simcells.v
        $(Q) mkdir -p techlibs/common
-       $(P) python3 $^ > $@.new
+       $(P) $(PYTHON_EXECUTABLE) $^ > $@.new
        $(Q) mv $@.new $@
 
 kernel/register.o: techlibs/common/simlib_help.inc techlibs/common/simcells_help.inc
index 5832d07ee5af1af2102e66952eb4005803cb68e4..46463f51051105ec4c8573e82838d0cf69a283f0 100644 (file)
@@ -27,12 +27,12 @@ EXTRA_OBJS += techlibs/ecp5/brams_init.mk techlibs/ecp5/brams_connect.mk
 
 techlibs/ecp5/brams_init.mk: techlibs/ecp5/brams_init.py
        $(Q) mkdir -p techlibs/ecp5
-       $(P) python3 $<
+       $(P) $(PYTHON_EXECUTABLE) $<
        $(Q) touch $@
 
 techlibs/ecp5/brams_connect.mk: techlibs/ecp5/brams_connect.py
        $(Q) mkdir -p techlibs/ecp5
-       $(P) python3 $<
+       $(P) $(PYTHON_EXECUTABLE) $<
        $(Q) touch $@
 
 
index 3c33fcb06203abafd83f4b68297611b70e2be2e4..31478e80e88198fbdf0441b8c23047ca0ccfd2bb 100644 (file)
@@ -14,7 +14,7 @@ EXTRA_OBJS += techlibs/ice40/brams_init.mk
 
 techlibs/ice40/brams_init.mk: techlibs/ice40/brams_init.py
        $(Q) mkdir -p techlibs/ice40
-       $(P) python3 $<
+       $(P) $(PYTHON_EXECUTABLE) $<
        $(Q) touch techlibs/ice40/brams_init.mk
 
 techlibs/ice40/brams_init1.vh: techlibs/ice40/brams_init.mk
index 0ae67d9e7afa40741fb05296a412854e9ce9651c..1e59f0a1be15374272b97ec909956b6b42b0f085 100644 (file)
@@ -13,7 +13,7 @@ EXTRA_OBJS += techlibs/xilinx/brams_init.mk
 
 techlibs/xilinx/brams_init.mk: techlibs/xilinx/brams_init.py
        $(Q) mkdir -p techlibs/xilinx
-       $(P) python3 $<
+       $(P) $(PYTHON_EXECUTABLE) $<
        $(Q) touch $@
 
 techlibs/xilinx/brams_init_36.vh: techlibs/xilinx/brams_init.mk