android: fix the build
[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 mydir := $(call my-dir)
32
33 sources := \
34 main/api_exec_es1_dispatch.h \
35 main/api_exec_es1_remap_helper.h \
36 main/api_exec_es2_dispatch.h \
37 main/api_exec_es2_remap_helper.h
38
39 LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
40
41 LOCAL_C_INCLUDES += $(intermediates)/main
42
43 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
44 ifeq ($(TARGET_ARCH),x86)
45 sources += x86/matypes.h
46 LOCAL_C_INCLUDES += $(intermediates)/x86
47 endif
48 endif
49
50 sources += main/git_sha1.h
51
52 sources := $(addprefix $(intermediates)/, $(sources))
53
54 LOCAL_GENERATED_SOURCES += $(sources)
55
56 glapi := $(MESA_TOP)/src/mapi/glapi/gen
57
58 es_src_deps := \
59 $(LOCAL_PATH)/main/APIspec.xml \
60 $(LOCAL_PATH)/main/es_generator.py \
61 $(LOCAL_PATH)/main/APIspecutil.py \
62 $(LOCAL_PATH)/main/APIspec.py
63
64 es_hdr_deps := \
65 $(wildcard $(glapi)/*.py) \
66 $(wildcard $(glapi)/*.xml)
67
68 define es-gen
69 @mkdir -p $(dir $@)
70 @echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
71 $(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
72 endef
73
74 define generate-local
75 @echo "generate local sources"
76 $(hide) $(MESA_PYTHON2) $(glapi)/gl_enums.py -f $(glapi)/gl_and_es_API.xml > $(mydir)/main/enums.c
77 $(hide) $(MESA_PYTHON2) $(glapi)/gl_table.py -m remap_table -f $(glapi)/gl_and_es_API.xml > $(mydir)/main/dispatch.h
78 $(hide) $(MESA_PYTHON2) $(glapi)/remap_helper.py -f $(glapi)/gl_API.xml > $(mydir)/main/remap_helper.h
79 $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES1.1 -S $(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es1.c
80 $(hide) $(MESA_PYTHON2) $(mydir)/main/es_generator.py -V GLES2.0 -S $(mydir)/main/APIspec.xml > $(mydir)/main/api_exec_es2.c
81
82 @echo "Mesa Lex : $(PRIVATE_MODULE)"
83 $(hide) $(LEX) -o $(mydir)/program/lex.yy.c $(mydir)/program/program_lexer.l
84 @echo "Mesa Yacc: $(PRIVATE_MODULE)"
85 $(hide) $(YACC) -d -o $(mydir)/program/program_parse.tab.c $(mydir)/program/program_parse.y
86 endef
87
88 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
89 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
90 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
91 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
92
93 $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
94 $(call es-gen, -c $* -m remap_table)
95
96 $(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
97 $(call es-gen, -c $*)
98
99 $(intermediates)/main/git_sha1.h:
100 @mkdir -p $(dir $@)
101 @echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
102 $(hide) touch $@
103 $(hide) if which git > /dev/null; then \
104 git --git-dir $(PRIVATE_PATH)/../../.git log -n 1 --oneline | \
105 sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
106 > $@; \
107 fi
108
109 matypes_deps := \
110 $(BUILD_OUT_EXECUTABLES)/mesa_gen_matypes$(BUILD_EXECUTABLE_SUFFIX) \
111 $(LOCAL_PATH)/main/mtypes.h \
112 $(LOCAL_PATH)/tnl/t_context.h
113
114 $(intermediates)/x86/matypes.h: $(matypes_deps)
115 @mkdir -p $(dir $@)
116 @echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
117 $(hide) $< > $@
118 $(call generate-local)