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