1# Mesa 3-D graphics library
2#
3# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
4# Copyright (C) 2010-2011 LunarG Inc.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a
7# copy of this software and associated documentation files (the "Software"),
8# to deal in the Software without restriction, including without limitation
9# the rights to use, copy, modify, merge, publish, distribute, sublicense,
10# and/or sell copies of the Software, and to permit persons to whom the
11# Software is furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included
14# in all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22# DEALINGS IN THE SOFTWARE.
23
24# included by core mesa Android.mk for source generation
25
26ifeq ($(LOCAL_MODULE_CLASS),)
27LOCAL_MODULE_CLASS := STATIC_LIBRARIES
28endif
29
30intermediates := $(call local-generated-sources-dir)
31prebuilt_intermediates := $(MESA_TOP)/prebuilt-intermediates
32
33# This is the list of auto-generated files: sources and headers
34sources := \
35	main/enums.c \
36	main/api_exec.c \
37	main/dispatch.h \
38	main/format_fallback.c \
39	main/format_pack.c \
40	main/format_unpack.c \
41	main/format_info.h \
42	main/remap_helper.h \
43	main/get_hash.h \
44	main/marshal_generated0.c \
45	main/marshal_generated1.c \
46	main/marshal_generated2.c \
47	main/marshal_generated3.c \
48	main/marshal_generated4.c \
49	main/marshal_generated5.c \
50	main/marshal_generated6.c \
51	main/marshal_generated7.c \
52	main/marshal_generated.h
53
54LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
55
56LOCAL_C_INCLUDES += $(intermediates)/main
57
58sources := $(addprefix $(intermediates)/, $(sources))
59
60LOCAL_GENERATED_SOURCES += $(sources)
61
62glapi := $(MESA_TOP)/src/mapi/glapi/gen
63
64dispatch_deps := \
65	$(wildcard $(glapi)/*.py) \
66	$(wildcard $(glapi)/*.xml)
67
68define es-gen
69	@mkdir -p $(dir $@)
70	@echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
71	$(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
72endef
73
74matypes_deps := \
75	$(LOCAL_PATH)/main/mtypes.h \
76	$(LOCAL_PATH)/tnl/t_context.h
77
78$(intermediates)/x86/matypes.h: $(prebuilt_intermediates)/x86/matypes.h
79	@mkdir -p $(dir $@)
80	cp -a $< $@
81
82$(intermediates)/main/dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
83$(intermediates)/main/dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
84
85$(intermediates)/main/dispatch.h: $(dispatch_deps)
86	$(call es-gen, $* -m remap_table)
87
88$(intermediates)/main/remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
89$(intermediates)/main/remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
90
91$(intermediates)/main/remap_helper.h: $(dispatch_deps)
92	$(call es-gen, $*)
93
94$(intermediates)/main/enums.c: PRIVATE_SCRIPT :=$(MESA_PYTHON2) $(glapi)/gl_enums.py
95$(intermediates)/main/enums.c: PRIVATE_XML := -f $(glapi)/../registry/gl.xml
96
97$(intermediates)/main/enums.c: $(dispatch_deps)
98	$(call es-gen)
99
100$(intermediates)/main/api_exec.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_genexec.py
101$(intermediates)/main/api_exec.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
102
103$(intermediates)/main/api_exec.c: $(dispatch_deps)
104	$(call es-gen)
105
106$(intermediates)/main/marshal_generated0.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
107$(intermediates)/main/marshal_generated0.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 0 -n 8
108
109$(intermediates)/main/marshal_generated0.c: $(dispatch_deps)
110	$(call es-gen)
111
112$(intermediates)/main/marshal_generated1.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
113$(intermediates)/main/marshal_generated1.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 1 -n 8
114
115$(intermediates)/main/marshal_generated1.c: $(dispatch_deps)
116	$(call es-gen)
117
118$(intermediates)/main/marshal_generated2.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
119$(intermediates)/main/marshal_generated2.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 2 -n 8
120
121$(intermediates)/main/marshal_generated2.c: $(dispatch_deps)
122	$(call es-gen)
123
124$(intermediates)/main/marshal_generated3.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
125$(intermediates)/main/marshal_generated3.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 3 -n 8
126
127$(intermediates)/main/marshal_generated3.c: $(dispatch_deps)
128	$(call es-gen)
129
130$(intermediates)/main/marshal_generated4.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
131$(intermediates)/main/marshal_generated4.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 4 -n 8
132
133$(intermediates)/main/marshal_generated4.c: $(dispatch_deps)
134	$(call es-gen)
135
136$(intermediates)/main/marshal_generated5.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
137$(intermediates)/main/marshal_generated5.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 5 -n 8
138
139$(intermediates)/main/marshal_generated5.c: $(dispatch_deps)
140	$(call es-gen)
141
142$(intermediates)/main/marshal_generated6.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
143$(intermediates)/main/marshal_generated6.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 6 -n 8
144
145$(intermediates)/main/marshal_generated6.c: $(dispatch_deps)
146	$(call es-gen)
147
148$(intermediates)/main/marshal_generated7.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal.py
149$(intermediates)/main/marshal_generated7.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml -i 7 -n 8
150
151$(intermediates)/main/marshal_generated7.c: $(dispatch_deps)
152	$(call es-gen)
153
154$(intermediates)/main/marshal_generated.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_marshal_h.py
155$(intermediates)/main/marshal_generated.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
156
157$(intermediates)/main/marshal_generated.h: $(dispatch_deps)
158	$(call es-gen)
159
160GET_HASH_GEN := $(LOCAL_PATH)/main/get_hash_generator.py
161
162$(intermediates)/main/get_hash.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(GET_HASH_GEN)
163$(intermediates)/main/get_hash.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
164$(intermediates)/main/get_hash.h: $(glapi)/gl_and_es_API.xml \
165               $(LOCAL_PATH)/main/get_hash_params.py $(GET_HASH_GEN)
166	$(call es-gen)
167
168$(intermediates)/main/format_fallback.c: $(prebuilt_intermediates)/main/format_fallback.c
169	cp -a $< $@
170
171FORMAT_INFO := $(LOCAL_PATH)/main/format_info.py
172format_info_deps := \
173	$(LOCAL_PATH)/main/formats.csv \
174	$(LOCAL_PATH)/main/format_parser.py \
175	$(FORMAT_INFO)
176
177$(intermediates)/main/format_info.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(FORMAT_INFO)
178$(intermediates)/main/format_info.h: PRIVATE_XML :=
179$(intermediates)/main/format_info.h: $(format_info_deps)
180	$(call es-gen, $<)
181
182$(intermediates)/main/format_pack.c: $(prebuilt_intermediates)/main/format_pack.c
183	cp -a $< $@
184
185$(intermediates)/main/format_unpack.c: $(prebuilt_intermediates)/main/format_unpack.c
186	cp -a $< $@
187
188
189