glcpp: link with tests/common.c
[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 AM_CPPFLAGS = \
23 -I$(top_srcdir)/include \
24 -I$(top_srcdir)/src/mapi \
25 -I$(top_srcdir)/src/mesa/ \
26 -I$(top_srcdir)/src/glsl/glcpp \
27 -I$(top_srcdir)/src/gtest/include \
28 $(DEFINES)
29 AM_CFLAGS = $(VISIBILITY_CFLAGS)
30 AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
31
32 include Makefile.sources
33
34 TESTS = glcpp/tests/glcpp-test \
35 tests/general-ir-test \
36 tests/optimization-test \
37 tests/ralloc-test \
38 tests/sampler-types-test \
39 tests/uniform-initializer-test
40
41 TESTS_ENVIRONMENT= \
42 export PYTHON2=$(PYTHON2); \
43 export PYTHON_FLAGS=$(PYTHON_FLAGS);
44
45 noinst_LTLIBRARIES = libglsl.la libglcpp.la
46 check_PROGRAMS = \
47 glcpp/glcpp \
48 glsl_test \
49 tests/general-ir-test \
50 tests/ralloc-test \
51 tests/sampler-types-test \
52 tests/uniform-initializer-test
53
54 noinst_PROGRAMS = glsl_compiler
55
56 tests_general_ir_test_SOURCES = \
57 $(top_srcdir)/src/mesa/main/hash_table.c \
58 $(top_srcdir)/src/mesa/main/imports.c \
59 $(top_srcdir)/src/mesa/program/prog_hash_table.c\
60 $(top_srcdir)/src/mesa/program/symbol_table.c \
61 $(GLSL_SRCDIR)/standalone_scaffolding.cpp \
62 tests/builtin_variable_test.cpp \
63 tests/invalidate_locations_test.cpp \
64 tests/general_ir_test.cpp \
65 tests/varyings_test.cpp \
66 tests/common.c
67 tests_general_ir_test_CFLAGS = \
68 $(PTHREAD_CFLAGS)
69 tests_general_ir_test_LDADD = \
70 $(top_builddir)/src/gtest/libgtest.la \
71 $(top_builddir)/src/glsl/libglsl.la \
72 $(PTHREAD_LIBS)
73
74 tests_uniform_initializer_test_SOURCES = \
75 $(top_srcdir)/src/mesa/main/hash_table.c \
76 $(top_srcdir)/src/mesa/main/imports.c \
77 $(top_srcdir)/src/mesa/program/prog_hash_table.c\
78 $(top_srcdir)/src/mesa/program/symbol_table.c \
79 tests/copy_constant_to_storage_tests.cpp \
80 tests/set_uniform_initializer_tests.cpp \
81 tests/uniform_initializer_utils.cpp \
82 tests/common.c
83 tests_uniform_initializer_test_CFLAGS = \
84 $(PTHREAD_CFLAGS)
85 tests_uniform_initializer_test_LDADD = \
86 $(top_builddir)/src/gtest/libgtest.la \
87 $(top_builddir)/src/glsl/libglsl.la \
88 $(PTHREAD_LIBS)
89
90 tests_ralloc_test_SOURCES = \
91 tests/ralloc_test.cpp \
92 $(top_builddir)/src/glsl/ralloc.c
93 tests_ralloc_test_CFLAGS = $(PTHREAD_CFLAGS)
94 tests_ralloc_test_LDADD = \
95 $(top_builddir)/src/gtest/libgtest.la \
96 $(PTHREAD_LIBS)
97
98 tests_sampler_types_test_SOURCES = \
99 $(top_srcdir)/src/mesa/program/prog_hash_table.c\
100 $(top_srcdir)/src/mesa/program/symbol_table.c \
101 tests/sampler_types_test.cpp \
102 tests/common.c
103 tests_sampler_types_test_CFLAGS = \
104 $(PTHREAD_CFLAGS)
105 tests_sampler_types_test_LDADD = \
106 $(top_builddir)/src/gtest/libgtest.la \
107 $(top_builddir)/src/glsl/libglsl.la \
108 $(PTHREAD_LIBS)
109
110 libglcpp_la_SOURCES = \
111 glcpp/glcpp-lex.c \
112 glcpp/glcpp-parse.c \
113 $(LIBGLCPP_FILES)
114
115 glcpp_glcpp_SOURCES = \
116 glcpp/glcpp.c \
117 tests/common.c \
118 $(top_srcdir)/src/mesa/program/prog_hash_table.c
119 glcpp_glcpp_LDADD = \
120 libglcpp.la \
121 -lm
122
123 libglsl_la_LIBADD = libglcpp.la
124 libglsl_la_SOURCES = \
125 glsl_lexer.cpp \
126 glsl_parser.cpp \
127 $(LIBGLSL_FILES)
128
129 glsl_compiler_SOURCES = \
130 $(top_srcdir)/src/mesa/main/hash_table.c \
131 $(top_srcdir)/src/mesa/main/imports.c \
132 $(top_srcdir)/src/mesa/program/prog_hash_table.c \
133 $(top_srcdir)/src/mesa/program/symbol_table.c \
134 $(GLSL_COMPILER_CXX_FILES)
135
136 glsl_compiler_LDADD = \
137 libglsl.la \
138 $(PTHREAD_LIBS)
139
140 glsl_test_SOURCES = \
141 $(top_srcdir)/src/mesa/main/hash_table.c \
142 $(top_srcdir)/src/mesa/main/imports.c \
143 $(top_srcdir)/src/mesa/program/prog_hash_table.c \
144 $(top_srcdir)/src/mesa/program/symbol_table.c \
145 $(GLSL_SRCDIR)/standalone_scaffolding.cpp \
146 tests/common.c \
147 test.cpp \
148 test_optpass.cpp
149
150 glsl_test_LDADD = libglsl.la
151
152 # We write our own rules for yacc and lex below. We'd rather use automake,
153 # but automake makes it especially difficult for a number of reasons:
154 #
155 # * < automake-1.12 generates .h files from .yy and .ypp files, but
156 # >=automake-1.12 generates .hh and .hpp files respectively. There's no
157 # good way of making a project that uses C++ yacc files compatible with
158 # both versions of automake. Strong work automake developers.
159 #
160 # * Since we're generating code from .l/.y files in a subdirectory (glcpp/)
161 # we'd like the resulting generated code to also go in glcpp/ for purposes
162 # of distribution. Automake gives no way to do this.
163 #
164 # * Since we're building multiple yacc parsers into one library (and via one
165 # Makefile) we have to use per-target YFLAGS. Using per-target YFLAGS causes
166 # automake to name the resulting generated code as <library-name>_filename.c.
167 # Frankly, that's ugly and we don't want a libglcpp_glcpp_parser.h file.
168
169 # In order to make build output print "LEX" and "YACC", we reproduce the
170 # automake variables below.
171
172 AM_V_LEX = $(am__v_LEX_$(V))
173 am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY))
174 am__v_LEX_0 = @echo " LEX " $@;
175 am__v_LEX_1 =
176
177 AM_V_YACC = $(am__v_YACC_$(V))
178 am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY))
179 am__v_YACC_0 = @echo " YACC " $@;
180 am__v_YACC_1 =
181
182 glsl_parser.cpp glsl_parser.h: glsl_parser.yy
183 $(AM_V_YACC) $(YACC) $(YFLAGS) -o $@ -p "_mesa_glsl_" --defines=$(GLSL_BUILDDIR)/glsl_parser.h $<
184
185 glsl_lexer.cpp: glsl_lexer.ll
186 $(AM_V_LEX) $(LEX) $(LFLAGS) -o $@ $<
187
188 glcpp/glcpp-parse.c glcpp/glcpp-parse.h: glcpp/glcpp-parse.y
189 $(AM_V_at)$(MKDIR_P) glcpp
190 $(AM_V_YACC) $(YACC) $(YFLAGS) -o $@ -p "glcpp_parser_" --defines=$(GLSL_BUILDDIR)/glcpp/glcpp-parse.h $<
191
192 glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
193 $(AM_V_at)$(MKDIR_P) glcpp
194 $(AM_V_LEX) $(LEX) $(LFLAGS) -o $@ $<
195
196 # Only the parsers (specifically the header files generated at the same time)
197 # need to be in BUILT_SOURCES. Though if we list the parser headers YACC is
198 # called for the .c/.cpp file and the .h files. By listing the .c/.cpp files
199 # YACC is only executed once for each parser. The rest of the generated code
200 # will be created at the appropriate times according to standard automake
201 # dependency rules.
202 BUILT_SOURCES = \
203 glsl_parser.cpp \
204 glsl_lexer.cpp \
205 glcpp/glcpp-parse.c \
206 glcpp/glcpp-lex.c
207 CLEANFILES = \
208 glcpp/glcpp-parse.h \
209 glsl_parser.h \
210 $(BUILT_SOURCES)