OSDN Git Service

glsl: Build with subdir-objects.
[android-x86/external-mesa.git] / src / glsl / Makefile.am
1 # Copyright © 2012 Jon TURNEY
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the "Software"),
5 # to deal in the Software without restriction, including without limitation
6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 # and/or sell copies of the Software, and to permit persons to whom the
8 # Software is furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice (including the next
11 # paragraph) shall be included in all copies or substantial portions of the
12 # Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE.
21
22 AUTOMAKE_OPTIONS = subdir-objects
23
24 AM_CPPFLAGS = \
25         -I$(top_srcdir)/include \
26         -I$(top_srcdir)/src \
27         -I$(top_srcdir)/src/mapi \
28         -I$(top_srcdir)/src/mesa/ \
29         -I$(top_srcdir)/src/glsl/glcpp \
30         -I$(top_srcdir)/src/glsl/nir \
31         -I$(top_srcdir)/src/gtest/include \
32         $(DEFINES)
33 AM_CFLAGS = $(VISIBILITY_CFLAGS)
34 AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
35
36 EXTRA_DIST = tests glcpp/tests README TODO glcpp/README \
37         glsl_lexer.ll                                   \
38         glsl_parser.yy                                  \
39         glcpp/glcpp-lex.l                               \
40         glcpp/glcpp-parse.y                             \
41         nir/nir_algebraic.py                            \
42         nir/nir_opt_algebraic.py                        \
43         SConscript
44
45 include Makefile.sources
46
47 TESTS = glcpp/tests/glcpp-test                          \
48         glcpp/tests/glcpp-test-cr-lf                    \
49         tests/blob-test                                 \
50         tests/general-ir-test                           \
51         tests/optimization-test                         \
52         tests/sampler-types-test                        \
53         tests/uniform-initializer-test
54
55 TESTS_ENVIRONMENT= \
56         export PYTHON2=$(PYTHON2); \
57         export PYTHON_FLAGS=$(PYTHON_FLAGS);
58
59 noinst_LTLIBRARIES = libglsl.la libglcpp.la
60 check_PROGRAMS =                                        \
61         glcpp/glcpp                                     \
62         glsl_test                                       \
63         tests/blob-test                                 \
64         tests/general-ir-test                           \
65         tests/sampler-types-test                        \
66         tests/uniform-initializer-test
67
68 noinst_PROGRAMS = glsl_compiler
69
70 tests_blob_test_SOURCES =                               \
71         tests/blob_test.c
72 tests_blob_test_LDADD =                                 \
73         $(top_builddir)/src/glsl/libglsl.la
74
75 tests_general_ir_test_SOURCES =         \
76         ../mesa/main/imports.c                  \
77         ../mesa/program/prog_hash_table.c               \
78         ../mesa/program/symbol_table.c          \
79         standalone_scaffolding.cpp                      \
80         tests/builtin_variable_test.cpp                 \
81         tests/invalidate_locations_test.cpp             \
82         tests/general_ir_test.cpp                       \
83         tests/varyings_test.cpp                         \
84         tests/common.c
85 tests_general_ir_test_CFLAGS =                          \
86         $(PTHREAD_CFLAGS)
87 tests_general_ir_test_LDADD =                           \
88         $(top_builddir)/src/gtest/libgtest.la           \
89         $(top_builddir)/src/glsl/libglsl.la             \
90         $(PTHREAD_LIBS)
91
92 tests_uniform_initializer_test_SOURCES =                \
93         ../mesa/main/imports.c          \
94         ../mesa/program/prog_hash_table.c\
95         ../mesa/program/symbol_table.c  \
96         tests/copy_constant_to_storage_tests.cpp        \
97         tests/set_uniform_initializer_tests.cpp         \
98         tests/uniform_initializer_utils.cpp             \
99         tests/uniform_initializer_utils.h               \
100         tests/common.c
101 tests_uniform_initializer_test_CFLAGS =                 \
102         $(PTHREAD_CFLAGS)
103 tests_uniform_initializer_test_LDADD =                  \
104         $(top_builddir)/src/gtest/libgtest.la           \
105         $(top_builddir)/src/glsl/libglsl.la             \
106         $(PTHREAD_LIBS)
107
108 tests_sampler_types_test_SOURCES =                      \
109         ../mesa/program/prog_hash_table.c\
110         ../mesa/program/symbol_table.c  \
111         tests/sampler_types_test.cpp                    \
112         tests/common.c
113 tests_sampler_types_test_CFLAGS =                       \
114         $(PTHREAD_CFLAGS)
115 tests_sampler_types_test_LDADD =                        \
116         $(top_builddir)/src/gtest/libgtest.la           \
117         $(top_builddir)/src/glsl/libglsl.la             \
118         $(PTHREAD_LIBS)
119
120 libglcpp_la_LIBADD =                                    \
121         $(top_builddir)/src/util/libmesautil.la
122 libglcpp_la_SOURCES =                                   \
123         glcpp/glcpp-lex.c                               \
124         glcpp/glcpp-parse.c                             \
125         glcpp/glcpp-parse.h                             \
126         $(LIBGLCPP_FILES)
127
128 glcpp_glcpp_SOURCES =                                   \
129         glcpp/glcpp.c                                   \
130         tests/common.c                                  \
131         ../mesa/program/prog_hash_table.c
132 glcpp_glcpp_LDADD =                                     \
133         libglcpp.la                                     \
134         -lm
135
136 libglsl_la_LIBADD = libglcpp.la
137 libglsl_la_SOURCES =                                    \
138         glsl_lexer.cpp                                  \
139         glsl_parser.cpp                                 \
140         glsl_parser.h                                   \
141         $(LIBGLSL_FILES)                                \
142         $(NIR_FILES)
143
144 glsl_compiler_SOURCES = \
145         ../mesa/main/imports.c \
146         ../mesa/program/prog_hash_table.c \
147         ../mesa/program/symbol_table.c \
148         $(GLSL_COMPILER_CXX_FILES)
149
150 glsl_compiler_LDADD =                                   \
151         libglsl.la                                      \
152         $(PTHREAD_LIBS)
153
154 glsl_test_SOURCES = \
155         ../mesa/main/imports.c \
156         ../mesa/program/prog_hash_table.c \
157         ../mesa/program/symbol_table.c \
158         standalone_scaffolding.cpp \
159         tests/common.c \
160         test.cpp \
161         test_optpass.cpp \
162         test_optpass.h
163
164 glsl_test_LDADD =                                       \
165         libglsl.la                                      \
166         $(PTHREAD_LIBS)
167
168 # We write our own rules for yacc and lex below. We'd rather use automake,
169 # but automake makes it especially difficult for a number of reasons:
170 #
171 #  * < automake-1.12 generates .h files from .yy and .ypp files, but
172 #    >=automake-1.12 generates .hh and .hpp files respectively. There's no
173 #    good way of making a project that uses C++ yacc files compatible with
174 #    both versions of automake. Strong work automake developers.
175 #
176 #  * Since we're generating code from .l/.y files in a subdirectory (glcpp/)
177 #    we'd like the resulting generated code to also go in glcpp/ for purposes
178 #    of distribution. Automake gives no way to do this.
179 #
180 #  * Since we're building multiple yacc parsers into one library (and via one
181 #    Makefile) we have to use per-target YFLAGS. Using per-target YFLAGS causes
182 #    automake to name the resulting generated code as <library-name>_filename.c.
183 #    Frankly, that's ugly and we don't want a libglcpp_glcpp_parser.h file.
184
185 # In order to make build output print "LEX" and "YACC", we reproduce the
186 # automake variables below.
187
188 AM_V_LEX = $(am__v_LEX_$(V))
189 am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY))
190 am__v_LEX_0 = @echo "  LEX     " $@;
191 am__v_LEX_1 =
192
193 AM_V_YACC = $(am__v_YACC_$(V))
194 am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY))
195 am__v_YACC_0 = @echo "  YACC    " $@;
196 am__v_YACC_1 =
197
198 glsl_parser.cpp glsl_parser.h: glsl_parser.yy
199         $(AM_V_YACC) $(YACC) $(YFLAGS) -o $@ -p "_mesa_glsl_" --defines=$(builddir)/glsl_parser.h $<
200
201 glsl_lexer.cpp: glsl_lexer.ll
202         $(AM_V_LEX) $(LEX) $(LFLAGS) -o $@ $<
203
204 glcpp/glcpp-parse.c glcpp/glcpp-parse.h: glcpp/glcpp-parse.y
205         $(AM_V_at)$(MKDIR_P) glcpp
206         $(AM_V_YACC) $(YACC) $(YFLAGS) -o $@ -p "glcpp_parser_" --defines=$(builddir)/glcpp/glcpp-parse.h $<
207
208 glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
209         $(AM_V_at)$(MKDIR_P) glcpp
210         $(AM_V_LEX) $(LEX) $(LFLAGS) -o $@ $<
211
212 # Only the parsers (specifically the header files generated at the same time)
213 # need to be in BUILT_SOURCES. Though if we list the parser headers YACC is
214 # called for the .c/.cpp file and the .h files. By listing the .c/.cpp files
215 # YACC is only executed once for each parser. The rest of the generated code
216 # will be created at the appropriate times according to standard automake
217 # dependency rules.
218 BUILT_SOURCES =                                         \
219         glsl_parser.cpp                                 \
220         glsl_lexer.cpp                                  \
221         glcpp/glcpp-parse.c                             \
222         glcpp/glcpp-lex.c                               \
223         nir/nir_opt_algebraic.c
224 CLEANFILES =                                            \
225         glcpp/glcpp-parse.h                             \
226         glsl_parser.h                                   \
227         $(BUILT_SOURCES)
228
229 clean-local:
230         $(RM) -r subtest-cr subtest-cr-lf subtest-lf subtest-lf-cr
231
232 dist-hook:
233         $(RM) glcpp/tests/*.out
234         $(RM) glcpp/tests/subtest*/*.out
235
236 nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
237         $(MKDIR_P) nir;                                                 \
238         $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py > $@