1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
include runtime.mk
ANDROID_URI?=https://dl.google.com/android/repository/
ANDROID_TOOLCHAIN_PREFIX?=$(TOP)/sdks/builds/toolchains/android
ANDROID_TOOLCHAIN_DIR?=$(TOP)/sdks/builds/toolchains/android
ANDROID_TOOLCHAIN_CACHE_DIR?=$(TOP)/sdks/builds/toolchains/android
ANT_URI?=https://archive.apache.org/dist/ant/binaries/
$(ANDROID_TOOLCHAIN_CACHE_DIR):
mkdir -p $@
##
# Parameters:
# $(1): target
# $(2): dir
# $(3): category
# $(4): url prefix
define AndroidProvisioningTemplate
$$(ANDROID_TOOLCHAIN_CACHE_DIR)/$(1).zip: | $$(ANDROID_TOOLCHAIN_CACHE_DIR)
wget --no-verbose -O $$@ $(4)$(1).zip
$$(ANDROID_TOOLCHAIN_DIR)/$(3)$$(if $(2),/$(2))/.stamp-$(1): $$(ANDROID_TOOLCHAIN_CACHE_DIR)/$(1).zip
rm -rf $$(ANDROID_TOOLCHAIN_DIR)/$(3)$$(if $(2),/$(2))
./unzip-android-archive.sh "$$<" "$$(ANDROID_TOOLCHAIN_DIR)/$(3)$$(if $(2),/$(2))"
touch $$@
.PHONY: provision-android-$(3)-$(1)
provision-android-$(3)-$(1): $$(ANDROID_TOOLCHAIN_DIR)/$(3)$$(if $(2),/$(2))/.stamp-$(1)
.PHONY: provision-android
provision-android: provision-android-$(3)-$(1)
endef
AndroidNDKProvisioningTemplate=$(call AndroidProvisioningTemplate,$(1),,ndk,$(ANDROID_URI))
ifeq ($(UNAME),Darwin)
$(eval $(call AndroidNDKProvisioningTemplate,android-ndk-$(ANDROID_NDK_VERSION)-darwin-x86_64))
else
ifeq ($(UNAME),Linux)
$(eval $(call AndroidNDKProvisioningTemplate,android-ndk-$(ANDROID_NDK_VERSION)-linux-x86_64))
else
$(error "Unknown UNAME=$(UNAME)")
endif
endif
AndroidSDKProvisioningTemplate=$(call AndroidProvisioningTemplate,$(1),$(2),sdk,$(ANDROID_URI)$(3))
ifeq ($(UNAME),Darwin)
$(eval $(call AndroidSDKProvisioningTemplate,build-tools_r$(ANDROID_BUILD_TOOLS_VERSION)-macosx,build-tools/$(or $(ANDROID_BUILD_TOOLS_DIR),$(ANDROID_BUILD_TOOLS_VERSION))))
$(eval $(call AndroidSDKProvisioningTemplate,platform-tools_r27.0.1-darwin,platforms-tools))
$(eval $(call AndroidSDKProvisioningTemplate,sdk-tools-darwin-4333796,tools))
$(eval $(call AndroidSDKProvisioningTemplate,emulator-darwin-4266726,emulator))
else
ifeq ($(UNAME),Linux)
$(eval $(call AndroidSDKProvisioningTemplate,build-tools_r$(ANDROID_BUILD_TOOLS_VERSION)-linux,build-tools/$(or $(ANDROID_BUILD_TOOLS_DIR),$(ANDROID_BUILD_TOOLS_VERSION))))
$(eval $(call AndroidSDKProvisioningTemplate,platform-tools_r27.0.1-linux,platform-tools))
$(eval $(call AndroidSDKProvisioningTemplate,sdk-tools-linux-4333796,tools))
$(eval $(call AndroidSDKProvisioningTemplate,emulator-linux-4266726,emulator))
else
$(error "Unknown UNAME=$(UNAME)")
endif
endif
$(eval $(call AndroidSDKProvisioningTemplate,android-2.3.3_r02-linux,platforms/android-10))
$(eval $(call AndroidSDKProvisioningTemplate,android-15_r03,platforms/android-15))
$(eval $(call AndroidSDKProvisioningTemplate,android-16_r04,platforms/android-16))
$(eval $(call AndroidSDKProvisioningTemplate,android-17_r02,platforms/android-17))
$(eval $(call AndroidSDKProvisioningTemplate,android-18_r02,platforms/android-18))
$(eval $(call AndroidSDKProvisioningTemplate,android-19_r03,platforms/android-19))
$(eval $(call AndroidSDKProvisioningTemplate,android-20_r02,platforms/android-20))
$(eval $(call AndroidSDKProvisioningTemplate,android-21_r02,platforms/android-21))
$(eval $(call AndroidSDKProvisioningTemplate,android-22_r02,platforms/android-22))
$(eval $(call AndroidSDKProvisioningTemplate,platform-23_r03,platforms/android-23))
$(eval $(call AndroidSDKProvisioningTemplate,platform-24_r02,platforms/android-24))
$(eval $(call AndroidSDKProvisioningTemplate,platform-25_r03,platforms/android-25))
$(eval $(call AndroidSDKProvisioningTemplate,platform-26_r01,platforms/android-26))
$(eval $(call AndroidSDKProvisioningTemplate,platform-27_r01,platforms/android-27))
$(eval $(call AndroidSDKProvisioningTemplate,platform-P_r01,platforms/android-P))
$(eval $(call AndroidSDKProvisioningTemplate,docs-24_r01,docs))
$(eval $(call AndroidSDKProvisioningTemplate,android_m2repository_r16,extras/android/m2repository))
$(eval $(call AndroidSDKProvisioningTemplate,x86-21_r05,system-images/android-21/default/x86,sys-img/android/))
AndroidAntProvisioningTemplate=$(call AndroidProvisioningTemplate,$(1),,ant,$(ANT_URI))
$(eval $(call AndroidAntProvisioningTemplate,apache-ant-1.9.9-bin))
##
# Parameters:
# $(1): target
# $(2): arch
# $(3): abi_name
# $(4): host_triple
#
# Flags:
# android-$(1)_CFLAGS
# android-$(1)_CXXFLAGS
# android-$(1)_LDFLAGS
define AndroidTargetTemplate
_android-$(1)_AR=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-ar
_android-$(1)_AS=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-as
_android-$(1)_CC=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-clang
_android-$(1)_CXX=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-clang++
_android-$(1)_CPP=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-cpp
_android-$(1)_CXXCPP=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-cpp
_android-$(1)_DLLTOOL=
_android-$(1)_LD=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-ld
_android-$(1)_OBJDUMP="$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-objdump"
_android-$(1)_RANLIB=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-ranlib
_android-$(1)_STRIP=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-strip
_android-$(1)_AC_VARS= \
mono_cv_uscore=yes \
ac_cv_func_sched_getaffinity=no \
ac_cv_func_sched_setaffinity=no
_android-$(1)_CFLAGS= \
-fstack-protector \
-DMONODROID=1 \
$$(android-$(1)_CFLAGS)
_android-$(1)_CXXFLAGS= \
-fstack-protector \
-DMONODROID=1 \
$$(android-$(1)_CXXFLAGS)
_android-$(1)_CPPFLAGS= \
-I$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/usr/include
_android-$(1)_CXXCPPFLAGS= \
-I$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/usr/include
_android-$(1)_LDFLAGS= \
-z now -z relro -z noexecstack \
-ldl -lm -llog -lc -lgcc \
-Wl,-rpath-link=$$(ANDROID_TOOLCHAIN_DIR)/ndk/platforms/android-$$(ANDROID_SDK_VERSION_$(1))/arch-$(2)/usr/lib,-dynamic-linker=/system/bin/linker \
-L$$(ANDROID_TOOLCHAIN_DIR)/ndk/platforms/android-$$(ANDROID_SDK_VERSION_$(1))/arch-$(2)/usr/lib \
$$(android-$(1)_LDFLAGS)
_android-$(1)_CONFIGURE_FLAGS= \
--host=$(4) \
--cache-file=$$(TOP)/sdks/builds/android-$(1)-$$(CONFIGURATION).config.cache \
--prefix=$$(TOP)/sdks/out/android-$(1)-$$(CONFIGURATION) \
--disable-boehm \
--disable-executables \
--disable-iconv \
--disable-mcs-build \
--disable-nls \
--enable-dynamic-btls \
--enable-maintainer-mode \
--enable-minimal=ssa,portability,attach,verifier,full_messages,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,security,shared_handles,interpreter \
--with-btls-android-ndk=$$(ANDROID_TOOLCHAIN_DIR)/ndk \
--with-sigaltstack=yes \
--with-tls=pthread \
--without-ikvm-native
.stamp-android-$(1)-toolchain: | $$(if $$(IGNORE_PROVISION_ANDROID),,provision-android)
python "$$(ANDROID_TOOLCHAIN_DIR)/ndk/build/tools/make_standalone_toolchain.py" --verbose --force --api=$$(ANDROID_SDK_VERSION_$(1)) --arch=$(2) --install-dir=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang
touch $$@
$$(eval $$(call RuntimeTemplate,android-$(1)))
endef
## android-armeabi
android-armeabi_CFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -march=armv5te
android-armeabi_CXXFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -march=armv5te
android-armeabi_LDFLAGS=-Wl,--fix-cortex-a8
$(eval $(call AndroidTargetTemplate,armeabi,arm,arm-linux-androideabi,armv5-linux-androideabi))
## android-armeabi-v7a
android-armeabi-v7a_CFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -march=armv7-a -mtune=cortex-a8 -mfpu=vfp -mfloat-abi=softfp
android-armeabi-v7a_CXXFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -march=armv7-a -mtune=cortex-a8 -mfpu=vfp -mfloat-abi=softfp
android-armeabi-v7a_LDFLAGS=-Wl,--fix-cortex-a8
$(eval $(call AndroidTargetTemplate,armeabi-v7a,arm,arm-linux-androideabi,armv5-linux-androideabi))
## android-arm64-v8a
android-arm64-v8a_CFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -DL_cuserid=9 -DANDROID64
android-arm64-v8a_CXXFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -DL_cuserid=9 -DANDROID64
$(eval $(call AndroidTargetTemplate,arm64-v8a,arm64,aarch64-linux-android,aarch64-linux-android))
## android-x86
$(eval $(call AndroidTargetTemplate,x86,x86,i686-linux-android,i686-linux-android))
## android-x86_64
android-x86_64_CFLAGS=-DL_cuserid=9
android-x86_64_CXXFLAGS=-DL_cuserid=9
$(eval $(call AndroidTargetTemplate,x86_64,x86_64,x86_64-linux-android,x86_64-linux-android))
##
# Parameters
# $(1): target
#
# Flags:
# android-$(1)_CFLAGS
# android-$(1)_CXXFLAGS
define AndroidHostTemplate
_android-$(1)_AR=ar
_android-$(1)_AS=as
_android-$(1)_CC=cc
_android-$(1)_CXX=c++
_android-$(1)_CXXCPP=cpp
_android-$(1)_LD=ld
_android-$(1)_RANLIB=ranlib
_android-$(1)_STRIP=strip
_android-$(1)_CFLAGS=$$(android-$(1)_CFLAGS)
_android-$(1)_CXXFLAGS=$$(android-$(1)_CXXFLAGS)
_android-$(1)_CONFIGURE_FLAGS= \
--cache-file=$$(TOP)/sdks/builds/android-$(1)-$$(CONFIGURATION).config.cache \
--prefix=$$(TOP)/sdks/out/android-$(1)-$$(CONFIGURATION) \
--disable-boehm \
--disable-iconv \
--disable-mono-debugger \
--disable-nls \
--enable-dynamic-btls \
--enable-maintainer-mode \
--with-mcs-docs=no \
--with-monodroid \
--with-profile4_x=no \
--without-ikvm-native
.stamp-android-$(1)-toolchain:
touch $$@
$$(eval $$(call RuntimeTemplate,android-$(1)))
endef
android-host-Darwin_CFLAGS=-mmacosx-version-min=10.9
$(eval $(call AndroidHostTemplate,host-Darwin))
$(eval $(call AndroidHostTemplate,host-Linux))
##
# Parameters
# $(1): target
# $(2): arch
define AndroidHostMxeTemplate
_android-$(1)_PATH=$$(MXE_PREFIX)/bin
_android-$(1)_AR=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-ar
_android-$(1)_AS=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-as
_android-$(1)_CC=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-gcc
_android-$(1)_CXX=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-g++
_android-$(1)_DLLTOOL=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-dlltool
_android-$(1)_LD=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-ld
_android-$(1)_OBJDUMP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-objdump
_android-$(1)_RANLIB=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-ranlib
_android-$(1)_STRIP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static)-strip
_android-$(1)_AC_VARS= \
ac_cv_header_zlib_h=no \
ac_cv_search_dlopen=no
_android-$(1)_CFLAGS= \
-DXAMARIN_PRODUCT_VERSION=0
_android-$(1)_CXXFLAGS= \
-DXAMARIN_PRODUCT_VERSION=0
_android-$(1)_CONFIGURE_FLAGS= \
--host=$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static) \
--target=$(2)-w64-mingw32$$(if $$(filter $(UNAME),Darwin),.static) \
--cache-file=$$(TOP)/sdks/builds/android-$(1)-$$(CONFIGURATION).config.cache \
--prefix=$$(TOP)/sdks/out/android-$(1)-$$(CONFIGURATION) \
--disable-boehm \
--disable-llvm \
--disable-mcs-build \
--disable-nls \
--enable-maintainer-mode \
--with-monodroid
.stamp-android-$(1)-toolchain:
touch $$@
.stamp-android-$(1)-$$(CONFIGURATION)-configure: | $(if $(IGNORE_PROVISION_MXE),,provision-mxe)
$$(eval $$(call RuntimeTemplate,android-$(1)))
endef
ifneq ($(MXE_PREFIX),)
$(eval $(call AndroidHostMxeTemplate,host-mxe-Win32,i686))
$(eval $(call AndroidHostMxeTemplate,host-mxe-Win64,x86_64))
endif
|