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