android: generate matching remap_helper to dispatch table
[mesa.git] / src / mesa / Android.gen.mk
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
26 ifeq ($(LOCAL_MODULE_CLASS),)
27 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
28 endif
29
30 intermediates := $(call local-intermediates-dir)
31
32 # This is the list of auto-generated files: sources and headers
33 sources := \
34 main/enums.c \
35 main/api_exec_es1.c \
36 main/api_exec_es1_dispatch.h \
37 main/api_exec_es1_remap_helper.h \
38 program/program_parse.tab.c \
39 program/lex.yy.c \
40 main/dispatch.h \
41 main/remap_helper.h \
42 main/get_hash.h
43
44 LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
45
46 LOCAL_C_INCLUDES += $(intermediates)/main
47
48 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
49 ifeq ($(TARGET_ARCH),x86)
50 sources += x86/matypes.h
51 LOCAL_C_INCLUDES += $(intermediates)/x86
52 endif
53 endif
54
55 sources += main/git_sha1.h
56
57 sources := $(addprefix $(intermediates)/, $(sources))
58
59 LOCAL_GENERATED_SOURCES += $(sources)
60
61 glapi := $(MESA_TOP)/src/mapi/glapi/gen
62
63 es_src_deps := \
64 $(LOCAL_PATH)/main/APIspec.xml \
65 $(LOCAL_PATH)/main/es_generator.py \
66 $(LOCAL_PATH)/main/APIspecutil.py \
67 $(LOCAL_PATH)/main/APIspec.py
68
69 es_hdr_deps := \
70 $(wildcard $(glapi)/*.py) \
71 $(wildcard $(glapi)/*.xml)
72
73 define local-l-to-c
74 @mkdir -p $(dir $@)
75 @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
76 $(hide) $(LEX) -o$@ $<
77 endef
78
79 define mesa_local-y-to-c-and-h
80 @mkdir -p $(dir $@)
81 @echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
82 $(hide) $(YACC) -o $@ -p "_mesa_program_" $<
83 endef
84
85 define es-gen
86 @mkdir -p $(dir $@)
87 @echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
88 $(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
89 endef
90
91 $(intermediates)/main/api_exec_%.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(LOCAL_PATH)/main/es_generator.py
92 $(intermediates)/main/api_exec_%.c: PRIVATE_XML := -S $(LOCAL_PATH)/main/APIspec.xml
93 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
94 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
95 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
96 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
97
98 $(intermediates)/main/api_exec_es1.c: $(es_src_deps)
99 $(call es-gen, -V GLES1.1)
100
101 $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
102 $(call es-gen, -c $* -m remap_table)
103
104 $(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
105 $(call es-gen, -c $*)
106
107 $(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program/program_parse.y
108 $(mesa_local-y-to-c-and-h)
109
110 $(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
111 $(local-l-to-c)
112
113 $(intermediates)/main/git_sha1.h:
114 @mkdir -p $(dir $@)
115 @echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
116 $(hide) touch $@
117 $(hide) if which git > /dev/null; then \
118 git --git-dir $(PRIVATE_PATH)/../../.git log -n 1 --oneline | \
119 sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
120 > $@; \
121 fi
122
123 matypes_deps := \
124 $(BUILD_OUT_EXECUTABLES)/mesa_gen_matypes$(BUILD_EXECUTABLE_SUFFIX) \
125 $(LOCAL_PATH)/main/mtypes.h \
126 $(LOCAL_PATH)/tnl/t_context.h
127
128 $(intermediates)/x86/matypes.h: $(matypes_deps)
129 @mkdir -p $(dir $@)
130 @echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
131 $(hide) $< > $@
132
133 $(intermediates)/main/dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
134 $(intermediates)/main/dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
135
136 $(intermediates)/main/dispatch.h: $(es_hdr_deps)
137 $(call es-gen, $* -m remap_table)
138
139 $(intermediates)/main/remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
140 $(intermediates)/main/remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
141
142 $(intermediates)/main/remap_helper.h: $(es_hdr_deps)
143 $(call es-gen, $*)
144
145 $(intermediates)/main/enums.c: PRIVATE_SCRIPT :=$(MESA_PYTHON2) $(glapi)/gl_enums.py
146 $(intermediates)/main/enums.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
147
148 $(intermediates)/main/enums.c: $(es_src_deps)
149 $(call es-gen)
150
151 GET_HASH_GEN := $(LOCAL_PATH)/main/get_hash_generator.py
152 GET_HASH_GEN_FLAGS := $(patsubst %,-a %,$(MESA_ENABLED_APIS))
153
154 $(intermediates)/main/get_hash.h: $(glapi)/gl_and_es_API.xml \
155 $(LOCAL_PATH)/main/get_hash_params.py $(GET_HASH_GEN)
156 @$(MESA_PYTHON2) $(GET_HASH_GEN) $(GET_HASH_GEN_FLAGS) -f $< > $@