[Mesa-dev] [PATCH] Fix usage of Python in Makefiles

Matthew William Cox matt at mattcox.ca
Mon Oct 25 12:10:34 PDT 2010


Hello list,

There are still some places in the build system which directly call
python. This is an issue now that python3 has started to become the
default version, this is true on at least Arch Linux. The attached patch
fixes the build system to always use the PYTHON2 make variable together
with the PYTHON_FLAGS variables.

Unfortunately, the autoconf side of things doesn't actually set these
variables to anything useful. config/autoconf.in sets PYTHON2=python
rather than having it be set as a result of running the configuration
script. At least having the Makefiles correctly use PYTHON2 means that
we can work around this by manually setting PYTHON2=python2 at the make
command invocation.

Matt
-------------- next part --------------
From a4f0f029d3936a2241a4ba30bf57450356e3a8a4 Mon Sep 17 00:00:00 2001
From: Matthew William Cox <matt at mattcox.ca>
Date: Mon, 25 Oct 2010 14:32:48 -0400
Subject: [PATCH] fix usage of python in Makefiles

Some Makefiles directly call python, they should be using the PYTHON2
variable with PYTHON_FLAGS.

Remove second -O flag from PYTHON_FLAGS, this triggers docstring
stripping which breaks src/gallium/auxiliary/util/u_format_srgb.py
---
 configs/autoconf.in                          |    2 +-
 src/gallium/auxiliary/Makefile               |   10 +++++-----
 src/gallium/drivers/llvmpipe/Makefile        |    2 +-
 src/mesa/drivers/dri/common/xmlpool/Makefile |    2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/configs/autoconf.in b/configs/autoconf.in
index 9bdbefe..cbd3cc4 100644
--- a/configs/autoconf.in
+++ b/configs/autoconf.in
@@ -54,7 +54,7 @@ INSTALL = @INSTALL@
 
 # Python and flags (generally only needed by the developers)
 PYTHON2 = python
-PYTHON_FLAGS = -t -O -O
+PYTHON_FLAGS = -t -O
 
 # Library names (base name)
 GL_LIB = GL
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index abd33f6..c7ec191 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -211,16 +211,16 @@ include ../Makefile.template
 
 
 indices/u_indices_gen.c: indices/u_indices_gen.py
-	python $< > $@
+	$(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
 indices/u_unfilled_gen.c: indices/u_unfilled_gen.py
-	python $< > $@
+	$(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
 util/u_format_srgb.c: util/u_format_srgb.py
-	python $< > $@
+	$(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
 util/u_format_table.c: util/u_format_table.py util/u_format_pack.py util/u_format_parse.py util/u_format.csv
-	python util/u_format_table.py util/u_format.csv > $@
+	$(PYTHON2) $(PYTHON_FLAGS) util/u_format_table.py util/u_format.csv > $@
 
 util/u_half.c: util/u_half.py
-	python util/u_half.py > $@
+	$(PYTHON2) $(PYTHON_FLAGS) util/u_half.py > $@
diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile
index 08da228..669e42e 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -69,7 +69,7 @@ lp_test_sincos.o : sse_mathfun.h
 PROGS_DEPS := ../../auxiliary/libgallium.a
 
 lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_pack.py ../../auxiliary/util/u_format.csv
-	python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
+	$(PYTHON2) $(PYTHON_FLAGS) lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
 
 LDFLAGS += $(LLVM_LDFLAGS)
 LIBS += -L../../auxiliary/ -lgallium libllvmpipe.a $(LLVM_LIBS) $(GL_LIB_DEPS)
diff --git a/src/mesa/drivers/dri/common/xmlpool/Makefile b/src/mesa/drivers/dri/common/xmlpool/Makefile
index 62ec919..b71629e 100644
--- a/src/mesa/drivers/dri/common/xmlpool/Makefile
+++ b/src/mesa/drivers/dri/common/xmlpool/Makefile
@@ -62,7 +62,7 @@ clean:
 
 # Default target options.h
 options.h: t_options.h mo
-	python gen_xmlpool.py $(LANGS) > options.h
+	$(PYTHON2) $(PYTHON_FLAGS) gen_xmlpool.py $(LANGS) > options.h
 
 # Update .mo files from the corresponding .po files.
 mo:
-- 
1.7.3.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20101025/e41a97bb/attachment.pgp>


More information about the mesa-dev mailing list