automake,android: Build program/ into a helper lib (v2)
[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/dispatch.h \
36 main/remap_helper.h \
37 main/get_hash.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 dispatch_deps := \
59 $(wildcard $(glapi)/*.py) \
60 $(wildcard $(glapi)/*.xml)
61
62 define es-gen
63 @mkdir -p $(dir $@)
64 @echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
65 $(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
66 endef
67
68 $(intermediates)/main/git_sha1.h:
69 @mkdir -p $(dir $@)
70 @echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
71 $(hide) touch $@
72 $(hide) if which git > /dev/null; then \
73 git --git-dir $(PRIVATE_PATH)/../../.git log -n 1 --oneline | \
74 sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
75 > $@; \
76 fi
77
78 matypes_deps := \
79 $(BUILD_OUT_EXECUTABLES)/mesa_gen_matypes$(BUILD_EXECUTABLE_SUFFIX) \
80 $(LOCAL_PATH)/main/mtypes.h \
81 $(LOCAL_PATH)/tnl/t_context.h
82
83 $(intermediates)/x86/matypes.h: $(matypes_deps)
84 @mkdir -p $(dir $@)
85 @echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
86 $(hide) $< > $@
87
88 $(intermediates)/main/dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
89 $(intermediates)/main/dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
90
91 $(intermediates)/main/dispatch.h: $(dispatch_deps)
92 $(call es-gen, $* -m remap_table)
93
94 $(intermediates)/main/remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
95 $(intermediates)/main/remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
96
97 $(intermediates)/main/remap_helper.h: $(dispatch_deps)
98 $(call es-gen, $*)
99
100 $(intermediates)/main/enums.c: PRIVATE_SCRIPT :=$(MESA_PYTHON2) $(glapi)/gl_enums.py
101 $(intermediates)/main/enums.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
102
103 $(intermediates)/main/enums.c: $(dispatch_deps)
104 $(call es-gen)
105
106 $(intermediates)/main/api_exec.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_genexec.py
107 $(intermediates)/main/api_exec.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
108
109 $(intermediates)/main/api_exec.c: $(dispatch_deps)
110 $(call es-gen)
111
112 GET_HASH_GEN := $(LOCAL_PATH)/main/get_hash_generator.py
113 GET_HASH_GEN_FLAGS := $(patsubst %,-a %,$(MESA_ENABLED_APIS))
114
115 $(intermediates)/main/get_hash.h: $(glapi)/gl_and_es_API.xml \
116 $(LOCAL_PATH)/main/get_hash_params.py $(GET_HASH_GEN)
117 @$(MESA_PYTHON2) $(GET_HASH_GEN) $(GET_HASH_GEN_FLAGS) -f $< > $@