Merge remote-tracking branch 'mesa-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 spirv2nir
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 spirv2nir_SOURCES = \
180 nir/spirv2nir.c
181
182 spirv2nir_LDADD = \
183 nir/libnir.la \
184 $(top_builddir)/src/util/libmesautil.la \
185 -lm -lstdc++ \
186 $(PTHREAD_LIBS)
187
188 # We write our own rules for yacc and lex below. We'd rather use automake,
189 # but automake makes it especially difficult for a number of reasons:
190 #
191 # * < automake-1.12 generates .h files from .yy and .ypp files, but
192 # >=automake-1.12 generates .hh and .hpp files respectively. There's no
193 # good way of making a project that uses C++ yacc files compatible with
194 # both versions of automake. Strong work automake developers.
195 #
196 # * Since we're generating code from .l/.y files in a subdirectory (glcpp/)
197 # we'd like the resulting generated code to also go in glcpp/ for purposes
198 # of distribution. Automake gives no way to do this.
199 #
200 # * Since we're building multiple yacc parsers into one library (and via one
201 # Makefile) we have to use per-target YFLAGS. Using per-target YFLAGS causes
202 # automake to name the resulting generated code as <library-name>_filename.c.
203 # Frankly, that's ugly and we don't want a libglcpp_glcpp_parser.h file.
204
205 # In order to make build output print "LEX" and "YACC", we reproduce the
206 # automake variables below.
207
208 AM_V_LEX = $(am__v_LEX_$(V))
209 am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY))
210 am__v_LEX_0 = @echo " LEX " $@;
211 am__v_LEX_1 =
212
213 AM_V_YACC = $(am__v_YACC_$(V))
214 am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY))
215 am__v_YACC_0 = @echo " YACC " $@;
216 am__v_YACC_1 =
217
218 MKDIR_GEN = $(AM_V_at)$(MKDIR_P) $(@D)
219 YACC_GEN = $(AM_V_YACC)$(YACC) $(YFLAGS)
220 LEX_GEN = $(AM_V_LEX)$(LEX) $(LFLAGS)
221
222 glsl/glsl_parser.cpp glsl/glsl_parser.h: glsl/glsl_parser.yy
223 $(MKDIR_GEN)
224 $(YACC_GEN) -o $@ -p "_mesa_glsl_" --defines=$(builddir)/glsl/glsl_parser.h $(srcdir)/glsl/glsl_parser.yy
225
226 glsl/glsl_lexer.cpp: glsl/glsl_lexer.ll
227 $(MKDIR_GEN)
228 $(LEX_GEN) -o $@ $(srcdir)/glsl/glsl_lexer.ll
229
230 glsl/glcpp/glcpp-parse.c glsl/glcpp/glcpp-parse.h: glsl/glcpp/glcpp-parse.y
231 $(MKDIR_GEN)
232 $(YACC_GEN) -o $@ -p "glcpp_parser_" --defines=$(builddir)/glsl/glcpp/glcpp-parse.h $(srcdir)/glsl/glcpp/glcpp-parse.y
233
234 glsl/glcpp/glcpp-lex.c: glsl/glcpp/glcpp-lex.l
235 $(MKDIR_GEN)
236 $(LEX_GEN) -o $@ $(srcdir)/glsl/glcpp/glcpp-lex.l
237
238 # Only the parsers (specifically the header files generated at the same time)
239 # need to be in BUILT_SOURCES. Though if we list the parser headers YACC is
240 # called for the .c/.cpp file and the .h files. By listing the .c/.cpp files
241 # YACC is only executed once for each parser. The rest of the generated code
242 # will be created at the appropriate times according to standard automake
243 # dependency rules.
244 BUILT_SOURCES += \
245 glsl/glsl_parser.cpp \
246 glsl/glsl_lexer.cpp \
247 glsl/glcpp/glcpp-parse.c \
248 glsl/glcpp/glcpp-lex.c
249 CLEANFILES += \
250 glsl/glcpp/glcpp-parse.h \
251 glsl/glsl_parser.h \
252 glsl/glsl_parser.cpp \
253 glsl/glsl_lexer.cpp \
254 glsl/glcpp/glcpp-parse.c \
255 glsl/glcpp/glcpp-lex.c
256
257 clean-local:
258 $(RM) -r subtest-cr subtest-cr-lf subtest-lf subtest-lf-cr
259
260 dist-hook:
261 $(RM) glsl/glcpp/tests/*.out
262 $(RM) glsl/glcpp/tests/subtest*/*.out
263
264 noinst_LTLIBRARIES += nir/libnir.la
265
266 nir_libnir_la_CPPFLAGS = \
267 $(AM_CPPFLAGS) \
268 -I$(top_builddir)/src/compiler/nir \
269 -I$(top_srcdir)/src/compiler/nir
270
271 nir_libnir_la_LIBADD = \
272 libcompiler.la
273
274 nir_libnir_la_SOURCES = \
275 $(NIR_FILES) \
276 $(SPIRV_FILES) \
277 $(NIR_GENERATED_FILES)
278
279 PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
280
281 nir/nir_builder_opcodes.h: nir/nir_opcodes.py nir/nir_builder_opcodes_h.py
282 $(MKDIR_GEN)
283 $(PYTHON_GEN) $(srcdir)/nir/nir_builder_opcodes_h.py > $@ || ($(RM) $@; false)
284
285 nir/nir_constant_expressions.c: nir/nir_opcodes.py nir/nir_constant_expressions.py
286 $(MKDIR_GEN)
287 $(PYTHON_GEN) $(srcdir)/nir/nir_constant_expressions.py > $@ || ($(RM) $@; false)
288
289 nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
290 $(MKDIR_GEN)
291 $(PYTHON_GEN) $(srcdir)/nir/nir_opcodes_h.py > $@ || ($(RM) $@; false)
292
293 nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
294 $(MKDIR_GEN)
295 $(PYTHON_GEN) $(srcdir)/nir/nir_opcodes_c.py > $@ || ($(RM) $@; false)
296
297 nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
298 $(MKDIR_GEN)
299 $(PYTHON_GEN) $(srcdir)/nir/nir_opt_algebraic.py > $@ || ($(RM) $@; false)
300
301
302 check_PROGRAMS += nir/tests/control_flow_tests
303
304 nir_tests_control_flow_tests_CPPFLAGS = \
305 $(AM_CPPFLAGS) \
306 -I$(top_builddir)/src/compiler/nir \
307 -I$(top_srcdir)/src/compiler/nir
308
309 nir_tests_control_flow_tests_SOURCES = \
310 nir/tests/control_flow_tests.cpp
311 nir_tests_control_flow_tests_CFLAGS = \
312 $(PTHREAD_CFLAGS)
313 nir_tests_control_flow_tests_LDADD = \
314 $(top_builddir)/src/gtest/libgtest.la \
315 nir/libnir.la \
316 $(top_builddir)/src/util/libmesautil.la \
317 $(PTHREAD_LIBS)
318
319
320 TESTS += nir/tests/control_flow_tests
321
322
323 BUILT_SOURCES += $(NIR_GENERATED_FILES)
324 CLEANFILES += $(NIR_GENERATED_FILES)
325
326 EXTRA_DIST += \
327 nir/nir_algebraic.py \
328 nir/nir_builder_opcodes_h.py \
329 nir/nir_constant_expressions.py \
330 nir/nir_opcodes.py \
331 nir/nir_opcodes_c.py \
332 nir/nir_opcodes_h.py \
333 nir/nir_opt_algebraic.py \
334 nir/tests \
335 nir/Makefile.sources