bfb31613f3315446ab5a3d88a1f81e309ea15ba3
[mesa.git] / src / compiler / Makefile.glsl.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 EXTRA_DIST += glsl/tests glsl/glcpp/tests glsl/README \
25 glsl/TODO glsl/glcpp/README \
26 glsl/glsl_lexer.ll \
27 glsl/glsl_parser.yy \
28 glsl/glcpp/glcpp-lex.l \
29 glsl/glcpp/glcpp-parse.y \
30 SConscript.glsl
31
32 TESTS += glsl/glcpp/tests/glcpp-test \
33 glsl/glcpp/tests/glcpp-test-cr-lf \
34 glsl/tests/blob-test \
35 glsl/tests/general-ir-test \
36 glsl/tests/optimization-test \
37 glsl/tests/sampler-types-test \
38 glsl/tests/uniform-initializer-test \
39 glsl/tests/warnings-test
40
41 TESTS_ENVIRONMENT= \
42 export PYTHON2=$(PYTHON2); \
43 export PYTHON_FLAGS=$(PYTHON_FLAGS);
44
45 check_PROGRAMS += \
46 glsl/glcpp/glcpp \
47 glsl/glsl_test \
48 glsl/tests/blob-test \
49 glsl/tests/general-ir-test \
50 glsl/tests/sampler-types-test \
51 glsl/tests/uniform-initializer-test
52
53 noinst_PROGRAMS = glsl_compiler
54
55 glsl_tests_blob_test_SOURCES = \
56 glsl/tests/blob_test.c
57 glsl_tests_blob_test_LDADD = \
58 glsl/libglsl.la
59
60 glsl_tests_general_ir_test_SOURCES = \
61 glsl/tests/builtin_variable_test.cpp \
62 glsl/tests/invalidate_locations_test.cpp \
63 glsl/tests/general_ir_test.cpp \
64 glsl/tests/varyings_test.cpp
65 glsl_tests_general_ir_test_CFLAGS = \
66 $(PTHREAD_CFLAGS)
67 glsl_tests_general_ir_test_LDADD = \
68 $(top_builddir)/src/gtest/libgtest.la \
69 glsl/libglsl.la \
70 glsl/libstandalone.la \
71 $(top_builddir)/src/libglsl_util.la \
72 $(PTHREAD_LIBS)
73
74 glsl_tests_uniform_initializer_test_SOURCES = \
75 glsl/tests/copy_constant_to_storage_tests.cpp \
76 glsl/tests/set_uniform_initializer_tests.cpp \
77 glsl/tests/uniform_initializer_utils.cpp \
78 glsl/tests/uniform_initializer_utils.h
79 glsl_tests_uniform_initializer_test_CFLAGS = \
80 $(PTHREAD_CFLAGS)
81 glsl_tests_uniform_initializer_test_LDADD = \
82 $(top_builddir)/src/gtest/libgtest.la \
83 glsl/libglsl.la \
84 $(top_builddir)/src/libglsl_util.la \
85 $(PTHREAD_LIBS)
86
87 glsl_tests_sampler_types_test_SOURCES = \
88 glsl/tests/sampler_types_test.cpp
89 glsl_tests_sampler_types_test_CFLAGS = \
90 $(PTHREAD_CFLAGS)
91 glsl_tests_sampler_types_test_LDADD = \
92 $(top_builddir)/src/gtest/libgtest.la \
93 glsl/libglsl.la \
94 $(top_builddir)/src/libglsl_util.la \
95 $(PTHREAD_LIBS)
96
97 noinst_LTLIBRARIES += glsl/libglsl.la glsl/libglcpp.la glsl/libstandalone.la
98
99 glsl_libglcpp_la_LIBADD = \
100 $(top_builddir)/src/util/libmesautil.la
101 glsl_libglcpp_la_SOURCES = \
102 glsl/glcpp/glcpp-lex.c \
103 glsl/glcpp/glcpp-parse.c \
104 glsl/glcpp/glcpp-parse.h \
105 $(LIBGLCPP_FILES)
106
107 glsl_glcpp_glcpp_SOURCES = \
108 glsl/glcpp/glcpp.c
109 glsl_glcpp_glcpp_LDADD = \
110 glsl/libglcpp.la \
111 $(top_builddir)/src/libglsl_util.la \
112 -lm
113
114 glsl_libglsl_la_LIBADD = \
115 nir/libnir.la \
116 glsl/libglcpp.la
117
118 glsl_libglsl_la_SOURCES = \
119 $(LIBGLSL_GENERATED_FILES) \
120 $(LIBGLSL_FILES)
121
122
123 glsl_libstandalone_la_SOURCES = \
124 $(GLSL_COMPILER_CXX_FILES)
125
126 glsl_libstandalone_la_LIBADD = \
127 glsl/libglsl.la \
128 $(top_builddir)/src/libglsl_util.la \
129 $(top_builddir)/src/util/libmesautil.la \
130 $(PTHREAD_LIBS)
131
132 glsl_compiler_SOURCES = \
133 glsl/main.cpp
134
135 glsl_compiler_LDADD = \
136 glsl/libstandalone.la
137
138 glsl_glsl_test_SOURCES = \
139 glsl/test.cpp \
140 glsl/test_optpass.cpp \
141 glsl/test_optpass.h
142
143 glsl_glsl_test_LDADD = \
144 glsl/libglsl.la \
145 glsl/libstandalone.la \
146 $(top_builddir)/src/libglsl_util.la \
147 $(PTHREAD_LIBS)
148
149 # We write our own rules for yacc and lex below. We'd rather use automake,
150 # but automake makes it especially difficult for a number of reasons:
151 #
152 # * < automake-1.12 generates .h files from .yy and .ypp files, but
153 # >=automake-1.12 generates .hh and .hpp files respectively. There's no
154 # good way of making a project that uses C++ yacc files compatible with
155 # both versions of automake. Strong work automake developers.
156 #
157 # * Since we're generating code from .l/.y files in a subdirectory (glcpp/)
158 # we'd like the resulting generated code to also go in glcpp/ for purposes
159 # of distribution. Automake gives no way to do this.
160 #
161 # * Since we're building multiple yacc parsers into one library (and via one
162 # Makefile) we have to use per-target YFLAGS. Using per-target YFLAGS causes
163 # automake to name the resulting generated code as <library-name>_filename.c.
164 # Frankly, that's ugly and we don't want a libglcpp_glcpp_parser.h file.
165
166 # In order to make build output print "LEX" and "YACC", we reproduce the
167 # automake variables below.
168
169 AM_V_LEX = $(am__v_LEX_$(V))
170 am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY))
171 am__v_LEX_0 = @echo " LEX " $@;
172 am__v_LEX_1 =
173
174 AM_V_YACC = $(am__v_YACC_$(V))
175 am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY))
176 am__v_YACC_0 = @echo " YACC " $@;
177 am__v_YACC_1 =
178
179 YACC_GEN = $(AM_V_YACC)$(YACC) $(YFLAGS)
180 LEX_GEN = $(AM_V_LEX)$(LEX) $(LFLAGS)
181
182 glsl/glsl_parser.cpp glsl/glsl_parser.h: glsl/glsl_parser.yy
183 $(MKDIR_GEN)
184 $(YACC_GEN) -o $@ -p "_mesa_glsl_" --defines=$(builddir)/glsl/glsl_parser.h $(srcdir)/glsl/glsl_parser.yy
185
186 glsl/glsl_lexer.cpp: glsl/glsl_lexer.ll
187 $(MKDIR_GEN)
188 $(LEX_GEN) -o $@ $(srcdir)/glsl/glsl_lexer.ll
189
190 glsl/glcpp/glcpp-parse.c glsl/glcpp/glcpp-parse.h: glsl/glcpp/glcpp-parse.y
191 $(MKDIR_GEN)
192 $(YACC_GEN) -o $@ -p "glcpp_parser_" --defines=$(builddir)/glsl/glcpp/glcpp-parse.h $(srcdir)/glsl/glcpp/glcpp-parse.y
193
194 glsl/glcpp/glcpp-lex.c: glsl/glcpp/glcpp-lex.l
195 $(MKDIR_GEN)
196 $(LEX_GEN) -o $@ $(srcdir)/glsl/glcpp/glcpp-lex.l
197
198 # Only the parsers (specifically the header files generated at the same time)
199 # need to be in BUILT_SOURCES. Though if we list the parser headers YACC is
200 # called for the .c/.cpp file and the .h files. By listing the .c/.cpp files
201 # YACC is only executed once for each parser. The rest of the generated code
202 # will be created at the appropriate times according to standard automake
203 # dependency rules.
204 BUILT_SOURCES += \
205 glsl/glsl_parser.cpp \
206 glsl/glsl_lexer.cpp \
207 glsl/glcpp/glcpp-parse.c \
208 glsl/glcpp/glcpp-lex.c
209 CLEANFILES += \
210 glsl/glcpp/glcpp-parse.h \
211 glsl/glsl_parser.h \
212 glsl/glsl_parser.cpp \
213 glsl/glsl_lexer.cpp \
214 glsl/glcpp/glcpp-parse.c \
215 glsl/glcpp/glcpp-lex.c
216
217 clean-local:
218 $(RM) -r subtest-cr subtest-cr-lf subtest-lf subtest-lf-cr
219
220 dist-hook:
221 $(RM) glsl/glcpp/tests/*.out
222 $(RM) glsl/glcpp/tests/subtest*/*.out