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_pack.c \
39	main/format_unpack.c \
40	main/format_info.h \
41	main/remap_helper.h \
42	main/get_hash.h
43
44LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
45
46LOCAL_C_INCLUDES += $(intermediates)/main
47
48ifeq ($(strip $(MESA_ENABLE_ASM)),true)
49ifeq ($(TARGET_ARCH),x86)
50sources += x86/matypes.h
51LOCAL_C_INCLUDES += $(intermediates)/x86
52endif
53endif
54
55sources += main/git_sha1.h
56
57sources := $(addprefix $(intermediates)/, $(sources))
58
59LOCAL_GENERATED_SOURCES += $(sources)
60
61glapi := $(MESA_TOP)/src/mapi/glapi/gen
62
63dispatch_deps := \
64	$(wildcard $(glapi)/*.py) \
65	$(wildcard $(glapi)/*.xml)
66
67define es-gen
68	@mkdir -p $(dir $@)
69	@echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
70	$(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
71endef
72
73$(intermediates)/main/git_sha1.h:
74	@mkdir -p $(dir $@)
75	@echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
76	$(hide) touch $@
77	$(hide) if which git > /dev/null; then \
78			git --git-dir $(PRIVATE_PATH)/../../.git log -n 1 --oneline | \
79			sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
80			> $@; \
81		fi
82
83matypes_deps := \
84	$(BUILD_OUT_EXECUTABLES)/mesa_gen_matypes$(BUILD_EXECUTABLE_SUFFIX) \
85	$(LOCAL_PATH)/main/mtypes.h \
86	$(LOCAL_PATH)/tnl/t_context.h
87
88$(intermediates)/x86/matypes.h: $(matypes_deps)
89	@mkdir -p $(dir $@)
90	@echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
91	$(hide) $< > $@
92
93$(intermediates)/main/dispatch.h: $(prebuilt_intermediates)/main/dispatch.h
94	cp -a $< $@
95
96$(intermediates)/main/remap_helper.h: $(prebuilt_intermediates)/main/remap_helper.h
97	cp -a $< $@
98
99$(intermediates)/main/enums.c: $(prebuilt_intermediates)/main/enums.c
100	cp -a $< $@
101
102$(intermediates)/main/api_exec.c: $(prebuilt_intermediates)/main/api_exec.c
103	cp -a $< $@
104
105$(intermediates)/main/get_hash.h: $(prebuilt_intermediates)/main/get_hash.h
106	cp -a $< $@
107
108$(intermediates)/main/format_info.h: $(prebuilt_intermediates)/main/format_info.h
109	cp -a $< $@
110
111$(intermediates)/main/format_pack.c: $(prebuilt_intermediates)/main/format_pack.c
112	cp -a $< $@
113
114$(intermediates)/main/format_unpack.c: $(prebuilt_intermediates)/main/format_unpack.c
115	cp -a $< $@
116