[Mesa-maintainers] make rules for generated files
Jonathan Gray
jsg at jsg.id.au
Sat Dec 17 05:38:37 UTC 2016
I'm not sure if others encounter this, but a problem I run into with
using the Mesa release tarballs is that if timestamps on files change
rules to regenerate files get called even if python/xxd/bison etc
are not found. In this case the Makefiles overwrite the generated
files in the distfile with empty files causing the build to error out.
The current workaround I am using is the below, I'm not familiar
with autotools though so there is likely a better way to handle this?
commit 1047c4a20634e95cab503aa206af5da47d37c887
Author: Jonathan Gray <jsg at jsg.id.au>
Date: Sun Nov 22 17:58:11 2015 +1100
disable the rules to regen sources if python wasn't found
Disable the bison/lex/python rules to regenerate sources that are
included in tarballs if the files are present and python isn't
found.
Otherwise the rules will create empty files when triggered and
error out when trying to invoke python:
gen_pack_header.py: cannot execute - Permission denied
diff --git a/configure.ac b/configure.ac
index 4d3f1c4730..b0acdf2864 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,6 +153,8 @@ else
fi
fi
+AM_CONDITIONAL(REGEN_SOURCES, test -n "$PYTHON2")
+
AC_PROG_INSTALL
dnl We need a POSIX shell for parts of the build. Assume we have one
diff --git a/src/compiler/Makefile.glsl.am b/src/compiler/Makefile.glsl.am
index 5b1d74e283..4addf6d588 100644
--- a/src/compiler/Makefile.glsl.am
+++ b/src/compiler/Makefile.glsl.am
@@ -190,6 +190,7 @@ am__v_YACC_1 =
YACC_GEN = $(AM_V_YACC)$(YACC) $(YFLAGS)
LEX_GEN = $(AM_V_LEX)$(LEX) $(LFLAGS)
+if REGEN_SOURCES
glsl/glsl_parser.cpp glsl/glsl_parser.h: glsl/glsl_parser.yy
$(MKDIR_GEN)
$(YACC_GEN) -o $@ -p "_mesa_glsl_" --defines=$(builddir)/glsl/glsl_parser.h $(srcdir)/glsl/glsl_parser.yy
@@ -217,6 +218,7 @@ glsl/ir_expression_operation_constant.h: glsl/ir_expression_operation.py
glsl/ir_expression_operation_strings.h: glsl/ir_expression_operation.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/glsl/ir_expression_operation.py strings > $@ || ($(RM) $@; false)
+endif
# Only the parsers (specifically the header files generated at the same time)
# need to be in BUILT_SOURCES. Though if we list the parser headers YACC is
diff --git a/src/compiler/Makefile.nir.am b/src/compiler/Makefile.nir.am
index f4dd8eac9d..69f49f64b5 100644
--- a/src/compiler/Makefile.nir.am
+++ b/src/compiler/Makefile.nir.am
@@ -31,6 +31,7 @@ nir_libnir_la_SOURCES = \
$(SPIRV_FILES) \
$(NIR_GENERATED_FILES)
+if REGEN_SOURCES
nir/nir_builder_opcodes.h: nir/nir_opcodes.py nir/nir_builder_opcodes_h.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/nir/nir_builder_opcodes_h.py > $@ || ($(RM) $@; false)
@@ -50,6 +51,7 @@ nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/nir/nir_opt_algebraic.py > $@ || ($(RM) $@; false)
+endif
noinst_PROGRAMS += spirv2nir
diff --git a/src/gallium/auxiliary/Makefile.am b/src/gallium/auxiliary/Makefile.am
index 0d1aee69ff..b0d5457898 100644
--- a/src/gallium/auxiliary/Makefile.am
+++ b/src/gallium/auxiliary/Makefile.am
@@ -37,6 +37,8 @@ endif
libgallium_la_LDFLAGS = $(LIBSENSORS_LDFLAGS)
MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
+
+if REGEN_SOURCES
PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
indices/u_indices_gen.c: indices/u_indices_gen.py
@@ -53,6 +55,7 @@ util/u_format_table.c: util/u_format_table.py \
util/u_format.csv
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format.csv > $@
+endif
noinst_LTLIBRARIES += libgalliumvl_stub.la
libgalliumvl_stub_la_SOURCES = \
diff --git a/src/gallium/drivers/radeonsi/Makefile.am b/src/gallium/drivers/radeonsi/Makefile.am
index 0ed955db22..f972f20418 100644
--- a/src/gallium/drivers/radeonsi/Makefile.am
+++ b/src/gallium/drivers/radeonsi/Makefile.am
@@ -33,8 +33,10 @@ noinst_LTLIBRARIES = libradeonsi.la
libradeonsi_la_SOURCES = $(C_SOURCES) $(GENERATED_SOURCES)
+if REGEN_SOURCES
sid_tables.h: $(srcdir)/sid_tables.py $(top_srcdir)/src/amd/common/sid.h
$(AM_V_GEN) $(PYTHON2) $(srcdir)/sid_tables.py $(top_srcdir)/src/amd/common/sid.h > $@
+endif
EXTRA_DIST = \
sid_tables.py
diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am
index b22ded0a19..2d8fc41ad7 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -63,6 +63,7 @@ BUILT_SOURCES = \
rasterizer/archrast/gen_ar_eventhandler.h \
rasterizer/archrast/gen_ar_eventhandlerfile.h
+if REGEN_SOURCES
MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
swr_context_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py swr_context.h
@@ -155,6 +156,7 @@ rasterizer/archrast/gen_ar_eventhandlerfile.h: rasterizer/scripts/gen_archrast.p
--proto $(srcdir)/rasterizer/archrast/events.proto \
--output rasterizer/archrast/gen_ar_eventhandlerfile.h \
--gen_eventhandlerfile_h
+endif
COMMON_LIBADD = \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
diff --git a/src/intel/Makefile.genxml.am b/src/intel/Makefile.genxml.am
index 2ed2741e4f..5b59c2ac93 100644
--- a/src/intel/Makefile.genxml.am
+++ b/src/intel/Makefile.genxml.am
@@ -31,9 +31,11 @@ SUFFIXES = _pack.h _xml.h .xml
$(GENXML_GENERATED_FILES): genxml/gen_pack_header.py
+if REGEN_SOURCES
.xml_pack.h:
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/genxml/gen_pack_header.py $< > $@ || ($(RM) $@; false)
+endif
# xxd generates variable names based on the path of the input file. We
# prefer to generate our own name here, so it doesn't vary from
@@ -41,12 +43,14 @@ $(GENXML_GENERATED_FILES): genxml/gen_pack_header.py
$(GENXML_GENERATED_FILES): Makefile
+if REGEN_SOURCES
.xml_xml.h:
$(MKDIR_GEN)
$(AM_V_GEN) echo -n "static const uint8_t " > $@; \
echo "$(@F)_xml[] = {" | sed -e 's,_xml.h,,' >> $@; \
cat $< | $(XXD) -i >> $@; \
echo "};" >> $@
+endif
EXTRA_DIST += \
genxml/gen4.xml \
diff --git a/src/intel/Makefile.isl.am b/src/intel/Makefile.isl.am
index 5a317f522b..fe4d43f605 100644
--- a/src/intel/Makefile.isl.am
+++ b/src/intel/Makefile.isl.am
@@ -57,11 +57,13 @@ isl_libisl_gen9_la_CFLAGS = $(AM_CFLAGS) -DGEN_VERSIONx10=90
BUILT_SOURCES += $(ISL_GENERATED_FILES)
+if REGEN_SOURCES
isl/isl_format_layout.c: isl/gen_format_layout.py \
isl/isl_format_layout.csv
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/isl/gen_format_layout.py \
--csv $(srcdir)/isl/isl_format_layout.csv --out $@
+endif
# ----------------------------------------------------------------------------
# Tests
diff --git a/src/mapi/Makefile.am b/src/mapi/Makefile.am
index 8020b1e766..dd9d256486 100644
--- a/src/mapi/Makefile.am
+++ b/src/mapi/Makefile.am
@@ -92,10 +92,12 @@ shared_glapi_test_LDADD = \
$(top_builddir)/src/gtest/libgtest.la
endif
+if REGEN_SOURCES
shared-glapi/glapi_mapi_tmp.h : glapi/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps)
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/mapi_abi.py --mode lib --printer shared-glapi \
$(srcdir)/glapi/gen/gl_and_es_API.xml > $@
+endif
if HAVE_OPENGL
noinst_LTLIBRARIES = glapi/libglapi.la
@@ -193,10 +195,12 @@ es1api_libGLESv1_CM_la_LIBADD += shared-glapi/libglapi.la
endif
endif
+if REGEN_SOURCES
es1api/glapi_mapi_tmp.h: glapi/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps)
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/mapi_abi.py --mode lib --printer es1api \
$(srcdir)/glapi/gen/gl_and_es_API.xml > $@
+endif
if HAVE_OPENGL_ES2
TESTS += es2api/ABI-check
@@ -240,9 +244,11 @@ es2api_libGLESv2_la_LIBADD += shared-glapi/libglapi.la
endif
endif
+if REGEN_SOURCES
es2api/glapi_mapi_tmp.h: glapi/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps)
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/mapi_abi.py --mode lib --printer es2api \
$(srcdir)/glapi/gen/gl_and_es_API.xml > $@
+endif
include $(top_srcdir)/install-lib-links.mk
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index bd5115798c..28b5b77d93 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -251,6 +251,7 @@ $(XORG_GLAPI_DIR)/%.h: $(MESA_GLAPI_DIR)/%.h
######################################################################
+if REGEN_SOURCES
$(MESA_GLAPI_DIR)/glapi_mapi_tmp.h: $(MESA_MAPI_DIR)/mapi_abi.py $(COMMON)
$(PYTHON_GEN) $(MESA_MAPI_DIR)/mapi_abi.py \
--printer glapi --mode lib $(srcdir)/gl_and_es_API.xml > $@
@@ -348,3 +349,4 @@ $(XORG_GLX_DIR)/indirect_reqsize.c: glX_proto_size.py $(COMMON_GLX)
$(XORG_GLX_DIR)/indirect_table.c: glX_server_table.py gl_and_glX_API.xml $(COMMON_GLX)
$(PYTHON_GEN) $< -f $(srcdir)/gl_and_glX_API.xml \
| $(INDENT) $(XORG_INDENT_FLAGS) > $@
+endif
diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
index 9710c7f094..9b47cccd3e 100644
--- a/src/mesa/Makefile.am
+++ b/src/mesa/Makefile.am
@@ -63,6 +63,7 @@ CLEANFILES = \
$(BUILT_SOURCES) \
program/program_parse.tab.h
+if REGEN_SOURCES
PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \
@@ -81,6 +82,7 @@ main/format_pack.c: main/format_pack.py main/formats.csv \
main/format_unpack.c: main/format_unpack.py main/formats.csv \
main/format_parser.py
$(PYTHON_GEN) $(srcdir)/main/format_unpack.py $(srcdir)/main/formats.csv > $@
+endif
main/formats.c: main/format_info.h
@@ -157,6 +159,8 @@ libmesa_sse41_la_SOURCES = \
libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) $(SSE41_CFLAGS)
MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
+
+if REGEN_SOURCES
YACC_GEN = $(AM_V_GEN)$(YACC) $(YFLAGS)
LEX_GEN = $(AM_V_GEN)$(LEX) $(LFLAGS)
@@ -167,6 +171,7 @@ program/lex.yy.c: program/program_lexer.l
program/program_parse.tab.c program/program_parse.tab.h: program/program_parse.y
$(MKDIR_GEN)
$(YACC_GEN) -o $@ -p "_mesa_program_" --defines=$(builddir)/program/program_parse.tab.h $(srcdir)/program/program_parse.y
+endif
if GEN_ASM_OFFSETS
matypes.h: $(gen_matypes_SOURCES)
diff --git a/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/src/mesa/drivers/dri/common/xmlpool/Makefile.am
index dfd8fb8dc6..da4463e7fe 100644
--- a/src/mesa/drivers/dri/common/xmlpool/Makefile.am
+++ b/src/mesa/drivers/dri/common/xmlpool/Makefile.am
@@ -68,8 +68,10 @@ CLEANFILES = \
# Default target options.h
LOCALEDIR := .
+if REGEN_SOURCES
options.h: t_options.h $(MOS)
$(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/gen_xmlpool.py $(srcdir)/t_options.h $(LOCALEDIR) $(LANGS) > options.h
+endif
# Update .mo files from the corresponding .po files.
%/LC_MESSAGES/options.mo: %.po
diff --git a/src/mesa/drivers/dri/i965/Makefile.am b/src/mesa/drivers/dri/i965/Makefile.am
index 4b009770ab..a09ade3837 100644
--- a/src/mesa/drivers/dri/i965/Makefile.am
+++ b/src/mesa/drivers/dri/i965/Makefile.am
@@ -45,9 +45,11 @@ AM_CFLAGS = \
AM_CXXFLAGS = $(AM_CFLAGS)
+if REGEN_SOURCES
brw_nir_trig_workarounds.c: brw_nir_trig_workarounds.py $(top_srcdir)/src/compiler/nir/nir_algebraic.py
$(MKDIR_GEN)
$(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/brw_nir_trig_workarounds.py > $@ || ($(RM) $@; false)
+endif
I965_PERGEN_LIBS = \
libi965_gen6.la \
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 093589163b..4234f24cc1 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -55,7 +55,9 @@ BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = format_srgb.py SConscript
+if REGEN_SOURCES
PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
format_srgb.c: format_srgb.py
$(PYTHON_GEN) $(srcdir)/format_srgb.py > $@
+endif
More information about the Mesa-maintainers
mailing list