Merge remote-tracking branch 'public/master' into vulkan
[mesa.git] / src / compiler / Makefile.am
1 #
2 # Copyright © 2012 Jon TURNEY
3 # Copyright (C) 2015 Intel Corporation
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice (including the next
13 # paragraph) shall be included in all copies or substantial portions of the
14 # Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 # IN THE SOFTWARE.
23
24 include Makefile.sources
25
26 AM_CPPFLAGS = \
27 -I$(top_srcdir)/include \
28 -I$(top_srcdir)/src \
29 -I$(top_srcdir)/src/mapi \
30 -I$(top_srcdir)/src/mesa/ \
31 -I$(top_builddir)/src/compiler/glsl\
32 -I$(top_srcdir)/src/compiler/glsl\
33 -I$(top_srcdir)/src/compiler/glsl/glcpp\
34 -I$(top_srcdir)/src/gallium/include \
35 -I$(top_srcdir)/src/gallium/auxiliary \
36 -I$(top_srcdir)/src/gtest/include \
37 $(DEFINES)
38
39 AM_CFLAGS = \
40 $(VISIBILITY_CFLAGS) \
41 $(MSVC2013_COMPAT_CFLAGS)
42
43 AM_CXXFLAGS = \
44 $(VISIBILITY_CXXFLAGS) \
45 $(MSVC2013_COMPAT_CXXFLAGS)
46
47 noinst_LTLIBRARIES = libcompiler.la
48
49 libcompiler_la_SOURCES = $(LIBCOMPILER_FILES)
50
51 check_PROGRAMS =
52 TESTS =
53 BUILT_SOURCES =
54 CLEANFILES =
55 EXTRA_DIST = SConscript
56
57
58 EXTRA_DIST += glsl/tests glsl/glcpp/tests glsl/README \
59 glsl/TODO glsl/glcpp/README \
60 glsl/glsl_lexer.ll \
61 glsl/glsl_parser.yy \
62 glsl/glcpp/glcpp-lex.l \
63 glsl/glcpp/glcpp-parse.y \
64 glsl/Makefile.sources \
65 glsl/SConscript
66
67 TESTS += glsl/glcpp/tests/glcpp-test \
68 glsl/glcpp/tests/glcpp-test-cr-lf \
69 glsl/tests/blob-test \
70 glsl/tests/general-ir-test \
71 glsl/tests/optimization-test \
72 glsl/tests/sampler-types-test \
73 glsl/tests/uniform-initializer-test
74
75 TESTS_ENVIRONMENT= \
76 export PYTHON2=$(PYTHON2); \
77 export PYTHON_FLAGS=$(PYTHON_FLAGS);
78
79 check_PROGRAMS += \
80 glsl/glcpp/glcpp \
81 glsl/glsl_test \
82 glsl/tests/blob-test \
83 glsl/tests/general-ir-test \
84 glsl/tests/sampler-types-test \
85 glsl/tests/uniform-initializer-test
86
87 noinst_PROGRAMS = glsl_compiler
88
89 glsl_tests_blob_test_SOURCES = \
90 glsl/tests/blob_test.c
91 glsl_tests_blob_test_LDADD = \
92 glsl/libglsl.la
93
94 glsl_tests_general_ir_test_SOURCES = \
95 glsl/standalone_scaffolding.cpp \
96 glsl/tests/builtin_variable_test.cpp \
97 glsl/tests/invalidate_locations_test.cpp \
98 glsl/tests/general_ir_test.cpp \
99 glsl/tests/varyings_test.cpp
100 glsl_tests_general_ir_test_CFLAGS = \
101 $(PTHREAD_CFLAGS)
102 glsl_tests_general_ir_test_LDADD = \
103 $(top_builddir)/src/gtest/libgtest.la \
104 glsl/libglsl.la \
105 $(top_builddir)/src/libglsl_util.la \
106 $(PTHREAD_LIBS)
107
108 glsl_tests_uniform_initializer_test_SOURCES = \
109 glsl/tests/copy_constant_to_storage_tests.cpp \
110 glsl/tests/set_uniform_initializer_tests.cpp \
111 glsl/tests/uniform_initializer_utils.cpp \
112 glsl/tests/uniform_initializer_utils.h
113 glsl_tests_uniform_initializer_test_CFLAGS = \
114 $(PTHREAD_CFLAGS)
115 glsl_tests_uniform_initializer_test_LDADD = \
116 $(top_builddir)/src/gtest/libgtest.la \
117 glsl/libglsl.la \
118 $(top_builddir)/src/libglsl_util.la \
119 $(PTHREAD_LIBS)
120
121 glsl_tests_sampler_types_test_SOURCES = \
122 glsl/tests/sampler_types_test.cpp
123 glsl_tests_sampler_types_test_CFLAGS = \
124 $(PTHREAD_CFLAGS)
125 glsl_tests_sampler_types_test_LDADD = \
126 $(top_builddir)/src/gtest/libgtest.la \
127 glsl/libglsl.la \
128 $(top_builddir)/src/libglsl_util.la \
129 $(PTHREAD_LIBS)
130
131 noinst_LTLIBRARIES += glsl/libglsl.la glsl/libglcpp.la
132
133 glsl_libglcpp_la_LIBADD = \
134 $(top_builddir)/src/util/libmesautil.la
135 glsl_libglcpp_la_SOURCES = \
136 glsl/glcpp/glcpp-lex.c \
137 glsl/glcpp/glcpp-parse.c \
138 glsl/glcpp/glcpp-parse.h \
139 $(LIBGLCPP_FILES)
140
141 glsl_glcpp_glcpp_SOURCES = \
142 glsl/glcpp/glcpp.c
143 glsl_glcpp_glcpp_LDADD = \
144 glsl/libglcpp.la \
145 $(top_builddir)/src/libglsl_util.la \
146 -lm
147
148 glsl_libglsl_la_LIBADD = \
149 nir/libnir.la \
150 glsl/libglcpp.la
151
152 glsl_libglsl_la_SOURCES = \
153 glsl/glsl_lexer.cpp \
154 glsl/glsl_parser.cpp \
155 glsl/glsl_parser.h \
156 $(LIBGLSL_FILES)
157
158
159 glsl_compiler_SOURCES = \
160 $(GLSL_COMPILER_CXX_FILES)
161
162 glsl_compiler_LDADD = \
163 glsl/libglsl.la \
164 $(top_builddir)/src/libglsl_util.la \
165 $(top_builddir)/src/util/libmesautil.la \
166 $(PTHREAD_LIBS)
167
168 glsl_glsl_test_SOURCES = \
169 glsl/standalone_scaffolding.cpp \
170 glsl/test.cpp \
171 glsl/test_optpass.cpp \
172 glsl/test_optpass.h
173
174 glsl_glsl_test_LDADD = \
175 glsl/libglsl.la \
176 $(top_builddir)/src/libglsl_util.la \
177 $(PTHREAD_LIBS)
178
179 # We write our own rules for yacc and lex below. We'd rather use automake,
180 # but automake makes it especially difficult for a number of reasons:
181 #
182 # * < automake-1.12 generates .h files from .yy and .ypp files, but
183 # >=automake-1.12 generates .hh and .hpp files respectively. There's no
184 # good way of making a project that uses C++ yacc files compatible with
185 # both versions of automake. Strong work automake developers.
186 #
187 # * Since we're generating code from .l/.y files in a subdirectory (glcpp/)
188 # we'd like the resulting generated code to also go in glcpp/ for purposes
189 # of distribution. Automake gives no way to do this.
190 #
191 # * Since we're building multiple yacc parsers into one library (and via one
192 # Makefile) we have to use per-target YFLAGS. Using per-target YFLAGS causes
193 # automake to name the resulting generated code as <library-name>_filename.c.
194 # Frankly, that's ugly and we don't want a libglcpp_glcpp_parser.h file.
195
196 # In order to make build output print "LEX" and "YACC", we reproduce the
197 # automake variables below.
198
199 AM_V_LEX = $(am__v_LEX_$(V))
200 am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY))
201 am__v_LEX_0 = @echo " LEX " $@;
202 am__v_LEX_1 =
203
204 AM_V_YACC = $(am__v_YACC_$(V))
205 am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY))
206 am__v_YACC_0 = @echo " YACC " $@;
207 am__v_YACC_1 =
208
209 MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
210 YACC_GEN = $(AM_V_YACC)$(YACC) $(YFLAGS)
211 LEX_GEN = $(AM_V_LEX)$(LEX) $(LFLAGS)
212
213 glsl/glsl_parser.cpp glsl/glsl_parser.h: glsl/glsl_parser.yy
214 $(MKDIR_GEN)
215 $(YACC_GEN) -o $@ -p "_mesa_glsl_" --defines=$(builddir)/glsl/glsl_parser.h $(srcdir)/glsl/glsl_parser.yy
216
217 glsl/glsl_lexer.cpp: glsl/glsl_lexer.ll
218 $(MKDIR_GEN)
219 $(LEX_GEN) -o $@ $(srcdir)/glsl/glsl_lexer.ll
220
221 glsl/glcpp/glcpp-parse.c glsl/glcpp/glcpp-parse.h: glsl/glcpp/glcpp-parse.y
222 $(MKDIR_GEN)
223 $(YACC_GEN) -o $@ -p "glcpp_parser_" --defines=$(builddir)/glsl/glcpp/glcpp-parse.h $(srcdir)/glsl/glcpp/glcpp-parse.y
224
225 glsl/glcpp/glcpp-lex.c: glsl/glcpp/glcpp-lex.l
226 $(MKDIR_GEN)
227 $(LEX_GEN) -o $@ $(srcdir)/glsl/glcpp/glcpp-lex.l
228
229 # Only the parsers (specifically the header files generated at the same time)
230 # need to be in BUILT_SOURCES. Though if we list the parser headers YACC is
231 # called for the .c/.cpp file and the .h files. By listing the .c/.cpp files
232 # YACC is only executed once for each parser. The rest of the generated code
233 # will be created at the appropriate times according to standard automake
234 # dependency rules.
235 BUILT_SOURCES += \
236 glsl/glsl_parser.cpp \
237 glsl/glsl_lexer.cpp \
238 glsl/glcpp/glcpp-parse.c \
239 glsl/glcpp/glcpp-lex.c
240 CLEANFILES += \
241 glsl/glcpp/glcpp-parse.h \
242 glsl/glsl_parser.h \
243 glsl/glsl_parser.cpp \
244 glsl/glsl_lexer.cpp \
245 glsl/glcpp/glcpp-parse.c \
246 glsl/glcpp/glcpp-lex.c
247
248 clean-local:
249 $(RM) -r subtest-cr subtest-cr-lf subtest-lf subtest-lf-cr
250
251 dist-hook:
252 $(RM) glsl/glcpp/tests/*.out
253 $(RM) glsl/glcpp/tests/subtest*/*.out
254
255 noinst_LTLIBRARIES += nir/libnir.la
256
257 nir_libnir_la_CPPFLAGS = \
258 $(AM_CPPFLAGS) \
259 -I$(top_builddir)/src/compiler/nir \
260 -I$(top_srcdir)/src/compiler/nir
261
262 nir_libnir_la_LIBADD = \
263 libcompiler.la
264
265 nir_libnir_la_SOURCES = \
266 $(NIR_FILES) \
267 $(SPIRV_FILES) \
268 $(NIR_GENERATED_FILES)
269
270 PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
271
272 nir/nir_builder_opcodes.h: nir/nir_opcodes.py nir/nir_builder_opcodes_h.py
273 $(MKDIR_GEN)
274 $(PYTHON_GEN) $(srcdir)/nir/nir_builder_opcodes_h.py > $@ || ($(RM) $@; false)
275
276 nir/nir_constant_expressions.c: nir/nir_opcodes.py nir/nir_constant_expressions.py
277 $(MKDIR_GEN)
278 $(PYTHON_GEN) $(srcdir)/nir/nir_constant_expressions.py > $@ || ($(RM) $@; false)
279
280 nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
281 $(MKDIR_GEN)
282 $(PYTHON_GEN) $(srcdir)/nir/nir_opcodes_h.py > $@ || ($(RM) $@; false)
283
284 nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
285 $(MKDIR_GEN)
286 $(PYTHON_GEN) $(srcdir)/nir/nir_opcodes_c.py > $@ || ($(RM) $@; false)
287
288 nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
289 $(MKDIR_GEN)
290 $(PYTHON_GEN) $(srcdir)/nir/nir_opt_algebraic.py > $@ || ($(RM) $@; false)
291
292
293 check_PROGRAMS += nir/tests/control_flow_tests
294
295 nir_tests_control_flow_tests_CPPFLAGS = \
296 $(AM_CPPFLAGS) \
297 -I$(top_builddir)/src/compiler/nir \
298 -I$(top_srcdir)/src/compiler/nir
299
300 nir_tests_control_flow_tests_SOURCES = \
301 nir/tests/control_flow_tests.cpp
302 nir_tests_control_flow_tests_CFLAGS = \
303 $(PTHREAD_CFLAGS)
304 nir_tests_control_flow_tests_LDADD = \
305 $(top_builddir)/src/gtest/libgtest.la \
306 nir/libnir.la \
307 $(top_builddir)/src/util/libmesautil.la \
308 $(PTHREAD_LIBS)
309
310
311 TESTS += nir/tests/control_flow_tests
312
313
314 BUILT_SOURCES += $(NIR_GENERATED_FILES)
315 CLEANFILES += $(NIR_GENERATED_FILES)
316
317 EXTRA_DIST += \
318 nir/nir_algebraic.py \
319 nir/nir_builder_opcodes_h.py \
320 nir/nir_constant_expressions.py \
321 nir/nir_opcodes.py \
322 nir/nir_opcodes_c.py \
323 nir/nir_opcodes_h.py \
324 nir/nir_opt_algebraic.py \
325 nir/tests \
326 nir/Makefile.sources