3 # Build Mesa3DGL private libcompiler.a
6 include $(SRCDIR)/config/aros.cfg
8 CUR_MESADIR := src/compiler
9 include $(SRCDIR)/$(CURDIR)/../mesa.cfg
10 include $(top_srcdir)/$(CUR_MESADIR)/Makefile.sources
12 #MM- mesa3dgl-linklibs : mesa3d-linklib-compiler
16 -I$(top_srcdir)/src/mesa \
17 -iquote $(top_srcdir)/src/mapi \
18 -iquote $(top_srcdir)/$(CUR_MESADIR) \
19 -iquote $(top_srcdir)/$(CUR_MESADIR)/glsl \
20 -iquote $(top_srcdir)/$(CUR_MESADIR)/glsl/glcpp \
21 -iquote $(top_srcdir)/$(CUR_MESADIR)/nir \
22 -iquote $(top_builddir)/$(CUR_MESADIR) \
23 -iquote $(top_builddir)/$(CUR_MESADIR)/glsl \
24 -iquote $(top_builddir)/$(CUR_MESADIR)/glsl/glcpp \
25 -iquote $(top_builddir)/$(CUR_MESADIR)/nir \
26 -iquote $(top_srcdir)/src/gallium/include \
27 -iquote $(top_srcdir)/src/gallium/auxiliary
29 # disable necessary warnings
32 $(NOWARN_RETURN_TYPE) \
33 $(NOWARN_MAYBE_UNINITIALIZED) \
34 $(NOWARN_MISLEADING_INDENTATION) \
35 $(NOWARN_STRICT_ALIASING) \
36 $(NOWARN_UNUSED_FUNCTION)
37 USER_CFLAGS += $(NOWARN_FLAGS)
38 USER_CXXFLAGS += $(NOWARN_FLAGS)
40 define local-l-or-ll-to-c-or-cpp
41 %mkdir_q dir="$(dir $@)"
42 @$(ECHO) "Generating Lex file $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
43 $(Q)$(LEX) $(FFLAGS) -o $@ $<
46 define local-yy-to-cpp-and-h
47 %mkdir_q dir="$(dir $@)"
48 $(Q)$(ECHO) "Generating C++ Parser file(s) $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
49 $(Q)$(BISON) $(BFLAGS) -o $@ -p "_mesa_glsl_" --defines=$(@:$1=.h) $<
52 define glsl_local-y-to-c-and-h
53 %mkdir_q dir="$(dir $@)"
54 $(Q)$(ECHO) "Generating C Parser file(s) $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
55 $(Q)$(BISON) $(BFLAGS) -o $@ -p "glcpp_parser_" --defines=$(@:.c=.h) $<
58 $(top_builddir)/$(CUR_MESADIR)/glsl/glcpp/glcpp-lex.c : $(top_srcdir)/$(CUR_MESADIR)/glsl/glcpp/glcpp-lex.l
59 $(call local-l-or-ll-to-c-or-cpp)
61 $(top_builddir)/$(CUR_MESADIR)/glsl/glcpp/glcpp-parse.c : $(top_srcdir)/$(CUR_MESADIR)/glsl/glcpp/glcpp-parse.y
62 $(call glsl_local-y-to-c-and-h)
64 $(top_builddir)/$(CUR_MESADIR)/glsl/glsl_lexer.cpp : $(top_srcdir)/$(CUR_MESADIR)/glsl/glsl_lexer.ll
65 $(call local-l-or-ll-to-c-or-cpp)
67 $(top_builddir)/$(CUR_MESADIR)/glsl/glsl_parser.cpp : $(top_srcdir)/$(CUR_MESADIR)/glsl/glsl_parser.yy
68 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
69 $(call local-yy-to-cpp-and-h,.cpp)
71 $(top_builddir)/$(CUR_MESADIR)/glsl/glsl_parser.h: $(top_builddir)/$(CUR_MESADIR)/glsl/glsl_parser.cpp
73 nir_builder_opcodes_gen := $(top_srcdir)/$(CUR_MESADIR)/nir/nir_builder_opcodes_h.py
74 nir_builder_opcodes_deps := \
75 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes.py \
76 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_builder_opcodes_h.py
78 $(top_builddir)/$(CUR_MESADIR)/nir/nir_builder_opcodes.h: $(nir_builder_opcodes_deps)
79 %mkdir_q dir="$(dir $@)"
80 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
81 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_builder_opcodes_gen) $< > $@
83 nir_constant_expressions_gen := $(top_srcdir)/$(CUR_MESADIR)/nir/nir_constant_expressions.py
84 nir_constant_expressions_deps := \
85 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes.py \
86 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_constant_expressions.py \
87 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_constant_expressions.h
89 $(top_builddir)/$(CUR_MESADIR)/nir/nir_constant_expressions.c: $(nir_constant_expressions_deps)
90 %mkdir_q dir="$(dir $@)"
91 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
92 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_constant_expressions_gen) $< > $@
94 nir_intrinsics_h_gen := $(top_srcdir)/$(CUR_MESADIR)/nir/nir_intrinsics_h.py
95 nir_intrinsics_h_deps := \
96 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_intrinsics.py \
97 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_intrinsics_h.py
99 $(top_builddir)/$(CUR_MESADIR)/nir/nir_intrinsics.h: $(nir_intrinsics_h_deps)
100 %mkdir_q dir="$(dir $@)"
101 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
102 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_intrinsics_h_gen) --outdir $(dir $@) || ($(RM) $@; false)
104 nir_intrinsics_c_gen :=$(top_srcdir)/$(CUR_MESADIR)/nir/nir_intrinsics_c.py
105 nir_intrinsics_c_deps := \
106 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_intrinsics.py \
107 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_intrinsics_h.py
109 $(top_builddir)/$(CUR_MESADIR)/nir/nir_intrinsics.c: $(nir_intrinsics_c_deps)
110 %mkdir_q dir="$(dir $@)"
111 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
112 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_intrinsics_c_gen) --outdir $(dir $@) || ($(RM) $@; false)
114 nir_opcodes_h_gen := $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes_h.py
115 nir_opcodes_h_deps := \
116 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes.py \
117 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes_h.py
119 $(top_builddir)/$(CUR_MESADIR)/nir/nir_opcodes.h: $(nir_opcodes_h_deps)
120 %mkdir_q dir="$(dir $@)"
121 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
122 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_opcodes_h_gen) $< > $@
124 nir_opcodes_c_gen := $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes_c.py
125 nir_opcodes_c_deps := \
126 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes.py \
127 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opcodes_c.py
129 $(top_builddir)/$(CUR_MESADIR)/nir/nir_opcodes.c: $(nir_opcodes_c_deps)
130 %mkdir_q dir="$(dir $@)"
131 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
132 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_opcodes_c_gen) $< > $@
134 nir_opt_algebraic_gen := $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opt_algebraic.py
135 nir_opt_algebraic_deps := \
136 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_opt_algebraic.py \
137 $(top_srcdir)/$(CUR_MESADIR)/nir/nir_algebraic.py
139 $(top_builddir)/$(CUR_MESADIR)/nir/nir_opt_algebraic.c: $(nir_opt_algebraic_deps)
140 %mkdir_q dir="$(dir $@)"
141 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
142 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $(nir_opt_algebraic_gen) $< > $@
145 $(top_builddir)/$(CUR_MESADIR)/glsl/ir_expression_operation.h: $(top_srcdir)/$(CUR_MESADIR)/glsl/ir_expression_operation.py
146 %mkdir_q dir="$(dir $@)"
147 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
148 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $< enum > $@
151 $(top_builddir)/$(CUR_MESADIR)/glsl/ir_expression_operation_constant.h: $(top_srcdir)/$(CUR_MESADIR)/glsl/ir_expression_operation.py
152 %mkdir_q dir="$(dir $@)"
153 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
154 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $< constant > $@
157 $(top_builddir)/$(CUR_MESADIR)/glsl/ir_expression_operation_strings.h: $(top_srcdir)/$(CUR_MESADIR)/glsl/ir_expression_operation.py
158 %mkdir_q dir="$(dir $@)"
159 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
160 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $< strings > $@
162 $(top_builddir)/$(CUR_MESADIR)/glsl/float64_glsl.h: $(top_srcdir)/$(CUR_MESADIR)/glsl/xxd.py $(top_srcdir)/$(CUR_MESADIR)/glsl/float64.glsl
163 %mkdir_q dir="$(dir $@)"
164 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
165 $(Q)cd $(glapi) && $(PYTHON) $(PYTHON_FLAGS) $^ $@ -n float64_source || ($(RM) $@; false)
168 $(top_builddir)/$(CUR_MESADIR)/spirv/spirv_info.c: $(top_srcdir)/$(CUR_MESADIR)/spirv/spirv_info_c.py $(top_srcdir)/$(CUR_MESADIR)/spirv/spirv.core.grammar.json
169 %mkdir_q dir="$(dir $@)"
170 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
171 $(Q)$(PYTHON) $(PYTHON_FLAGS) $(top_srcdir)/$(CUR_MESADIR)/spirv/spirv_info_c.py $(top_srcdir)/$(CUR_MESADIR)/spirv/spirv.core.grammar.json $@ || ($(RM) $@; false)
173 $(top_builddir)/$(CUR_MESADIR)/spirv/vtn_gather_types.c: $(top_srcdir)/$(CUR_MESADIR)/spirv/vtn_gather_types_c.py $(top_srcdir)/$(CUR_MESADIR)/spirv/spirv.core.grammar.json
174 %mkdir_q dir="$(dir $@)"
175 $(Q)$(ECHO) "Generating $(if $(filter /%,$@),$(if $(filter $(SRCDIR)/%,$(abspath $@)),$(patsubst $(SRCDIR)/%,%,$(abspath $@)),$(patsubst $(TOP)/%,%,$(abspath $@))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/$@)))"
176 $(Q)$(PYTHON) $(PYTHON_FLAGS) $(top_srcdir)/$(CUR_MESADIR)/spirv/vtn_gather_types_c.py $(top_srcdir)/$(CUR_MESADIR)/spirv/spirv.core.grammar.json $@ || ($(RM) $@; false)
178 MESA3DGL_GLSL_GENERATED_FILES := $(addprefix $(top_builddir)/$(CUR_MESADIR)/,$(LIBGLSL_GENERATED_FILES))
179 MESA3DGL_GLSL_GENERATED_HEADERS := $(filter %.h,$(MESA3DGL_GLSL_GENERATED_FILES))
181 MESA3DGL_SPIRV_GENERATED_FILES := $(addprefix $(top_builddir)/$(CUR_MESADIR)/,$(SPIRV_GENERATED_FILES))
182 MESA3DGL_NIR_GENERATED_FILES := $(addprefix $(top_builddir)/$(CUR_MESADIR)/,$(NIR_GENERATED_FILES))
183 MESA3DGL_GLSL_GENERATED_C_SOURCES := $(filter %.c,$(MESA3DGL_NIR_GENERATED_FILES) $(MESA3DGL_GLSL_GENERATED_FILES) $(MESA3DGL_SPIRV_GENERATED_FILES))
184 MESA3DGL_GLSL_C_SOURCES := $(wildcard $(addprefix $(top_srcdir)/$(CUR_MESADIR)/,$(filter %.c,$(LIBGLSL_FILES) $(NIR_FILES) $(SPIRV_FILES))))
186 MESA3DGL_GLSL_GENERATED_CXX_SOURCES := $(filter %.cpp,$(MESA3DGL_GLSL_GENERATED_FILES))
187 MESA3DGL_GLSL_CXX_SOURCES := $(wildcard $(addprefix $(top_srcdir)/$(CUR_MESADIR)/,$(filter %.cpp,$(LIBGLSL_FILES) $(NIR_FILES))))
189 MESA3DGL_GLSL_SOURCES_C := \
190 $(MESA3DGL_GLSL_GENERATED_C_SOURCES:.c=) \
191 $(MESA3DGL_GLSL_C_SOURCES:.c=)
192 MESA3DGL_GLSL_SOURCES_CXX := \
193 $(MESA3DGL_GLSL_GENERATED_CXX_SOURCES:.cpp=) \
194 $(MESA3DGL_GLSL_CXX_SOURCES:.cpp=) \
197 MESA3DGL_GLCPP_GENERATED_FILES := $(addprefix $(top_builddir)/$(CUR_MESADIR)/,$(LIBGLCPP_GENERATED_FILES))
198 MESA3DGL_GLCPP_GENERATED_C_SOURCES := $(filter %.c,$(MESA3DGL_GLCPP_GENERATED_FILES))
200 MESA3DGL_GLCPP_FILES := $(addprefix $(top_srcdir)/$(CUR_MESADIR)/,$(LIBGLCPP_FILES))
201 MESA3DGL_GLCPP_C_SOURCES := $(filter %.c,$(MESA3DGL_GLCPP_FILES))
203 MESA3DGL_GLCPP_SOURCES_C := \
204 $(MESA3DGL_GLCPP_GENERATED_C_SOURCES:.c=) \
205 $(MESA3DGL_GLCPP_C_SOURCES:.c=)
207 LIBCOMPILER_C_FILES := $(addprefix $(top_srcdir)/$(CUR_MESADIR)/,$(filter %.c,$(LIBCOMPILER_FILES)))
208 LIBCOMPILER_CXX_FILES := $(addprefix $(top_srcdir)/$(CUR_MESADIR)/,$(filter %.cpp,$(LIBCOMPILER_FILES)))
210 LIBCOMPILER_C_SOURCES := $(LIBCOMPILER_C_FILES:.c=)
211 LIBCOMPILER_CXX_SOURCES := $(LIBCOMPILER_CXX_FILES:.cpp=)
214 mesa3d-linklib-compiler-generate : $(MESA3DGL_GLSL_GENERATED_FILES) $(MESA3DGL_GLCPP_GENERATED_FILES) $(MESA3DGL_NIR_GENERATED_FILES) $(MESA3DGL_SPIRV_GENERATED_FILES)
216 #MM mesa3d-linklib-compiler : mesa3d-linklib-compiler-generate
218 %build_linklib mmake=mesa3d-linklib-compiler libname=compiler libdir=$(top_libdir) objdir=$(top_builddir)/$(CUR_MESADIR) files="$(MESA3DGL_GLSL_SOURCES_C) $(MESA3DGL_GLCPP_SOURCES_C) $(LIBCOMPILER_C_SOURCES)" cxxfiles="$(MESA3DGL_GLSL_SOURCES_CXX) $(LIBCOMPILER_CXX_SOURCES)"