[reflection] Check whether a pointer is valid before dereferencing (#19842)
[mono-project.git] / sdks / builds / android.mk
blob2c80c215676e769a93836a9863e1dd657082d8c4
2 ANDROID_URI?=https://dl.google.com/android/repository/
3 ANT_URI?=https://archive.apache.org/dist/ant/binaries/
5 ANDROID_SDK_PREFIX?=$(ANDROID_TOOLCHAIN_DIR)/sdk
6 ANDROID_TOOLCHAIN_PREFIX?=$(ANDROID_TOOLCHAIN_DIR)/toolchains
7 ANDROID_NEW_NDK=$(shell if test `grep 'Pkg\.Revision' $(ANDROID_TOOLCHAIN_DIR)/ndk/source.properties | cut -d '=' -f 2 | tr -d ' ' | cut -d '.' -f 1` -ge 18; then echo yes; else echo no; fi)
9 android_SOURCES_DIR = $(TOP)/sdks/out/android-sources
10 android_TPN_DIR = $(TOP)/sdks/out/android-tpn
11 android_HOST_DARWIN_LIB_DIR = $(TOP)/sdks/out/android-host-Darwin-$(CONFIGURATION)/lib
12 android_HOST_DARWIN_BIN_DIR = $(TOP)/sdks/out/android-host-Darwin-$(CONFIGURATION)/bin
13 android_PLATFORM_BIN=$(XCODE_DIR)/Toolchains/XcodeDefault.xctoolchain/usr/bin
15 ifneq (,$(filter $(UNAME),Darwin Linux))
16 android_ARCHIVE += android-sources android-tpn
17 ADDITIONAL_PACKAGE_DEPS += $(android_SOURCES_DIR) $(android_TPN_DIR)
18 endif
20 ifeq ($(UNAME),Darwin)
21 ANDROID_LIBCLANG = $(ANDROID_TOOLCHAIN_DIR)/ndk/toolchains/llvm/prebuilt/darwin-x86_64/lib64/libclang.dylib
22 else ifeq ($(UNAME),Linux)
23 ANDROID_LIBCLANG = $(ANDROID_TOOLCHAIN_DIR)/ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/libclang.so.8svn
24 endif
26 COMMA := ,
29 # Parameters:
30 # $(1): target
31 # $(2): dir
32 # $(3): subdir (optional)
33 # $(4): stamp (optional, default to $(1))
34 define AndroidProvisioningTemplate
36 $$(ANDROID_TOOLCHAIN_CACHE_DIR)/$(1).zip:
37 mkdir -p $$(dir $$@)
38 wget --no-verbose -O $$@ $$(ANDROID_URI)$(1).zip
40 $$(ANDROID_TOOLCHAIN_DIR)/$(2)/.stamp-$$(or $(4),$(1)): $$(ANDROID_TOOLCHAIN_CACHE_DIR)/$(1).zip
41 mkdir -p $$(dir $$@)
42 rm -rf $$(ANDROID_TOOLCHAIN_DIR)/$(2)$$(if $(3),/$(3))
43 ./unzip-android-archive.sh "$$<" "$$(ANDROID_TOOLCHAIN_DIR)/$(2)$$(if $(3),/$(3))"
44 touch $$@
46 .PHONY: provision-android
47 provision-android: $$(ANDROID_TOOLCHAIN_DIR)/$(2)/.stamp-$$(or $(4),$(1))
49 endef
52 # Parameters:
53 # $(1): target
54 # $(2): dir
55 # $(3): subdir (optional)
56 # $(4): stamp (optional, default to $(1))
57 define AndroidProvisioningTemplateStub
59 .PHONY: provision-android-$(1)
60 provision-android-$(1):
61 @echo "TODO: provision $(2)/.stamp-$$(or $(4),$(1)) for $$(UNAME)"
63 .PHONY: provision-android
64 provision-android: provision-android-$(1)
66 endef
68 ifeq ($(UNAME),Darwin)
69 $(eval $(call AndroidProvisioningTemplate,android-ndk-$(ANDROID_NDK_VERSION)-darwin-x86_64,ndk,,ndk))
70 $(eval $(call AndroidProvisioningTemplate,platform-tools_r$(ANDROID_PLATFORM_TOOLS_VERSION)-darwin,sdk,platform-tools))
71 $(eval $(call AndroidProvisioningTemplate,sdk-tools-darwin-$(ANDROID_SDKTOOLS_VERSION),sdk,tools))
72 $(eval $(call AndroidProvisioningTemplate,cmake-$(ANDROID_CMAKE_VERSION)-darwin-x86_64,sdk,cmake/$(ANDROID_CMAKE_VERSION)))
73 else ifeq ($(UNAME),Linux)
74 $(eval $(call AndroidProvisioningTemplate,android-ndk-$(ANDROID_NDK_VERSION)-linux-x86_64,ndk,,ndk))
75 $(eval $(call AndroidProvisioningTemplate,platform-tools_r$(ANDROID_PLATFORM_TOOLS_VERSION)-linux,sdk,platform-tools))
76 $(eval $(call AndroidProvisioningTemplate,sdk-tools-linux-$(ANDROID_SDKTOOLS_VERSION),sdk,tools))
77 $(eval $(call AndroidProvisioningTemplate,cmake-$(ANDROID_CMAKE_VERSION)-linux-x86_64,sdk,cmake/$(ANDROID_CMAKE_VERSION)))
78 else ifeq ($(UNAME),Windows)
79 $(eval $(call AndroidProvisioningTemplateStub,android-ndk-$(ANDROID_NDK_VERSION)-win32-x86_64,ndk,,ndk))
80 $(eval $(call AndroidProvisioningTemplateStub,platform-tools_r$(ANDROID_PLATFORM_TOOLS_VERSION)-win32,sdk,platform-tools))
81 $(eval $(call AndroidProvisioningTemplateStub,sdk-tools-win32-$(ANDROID_SDKTOOLS_VERSION),sdk,tools))
82 $(eval $(call AndroidProvisioningTemplateStub,cmake-$(ANDROID_CMAKE_VERSION)-win32-x86_64,sdk,cmake/$(ANDROID_CMAKE_VERSION)))
83 endif
86 # Parameters:
87 # $(1): target
88 # $(2): arch
89 # $(3): abi_name
90 # $(4): host_triple
91 # $(5): interpreter (either '-interpreter' or empty)
93 # Flags:
94 # android-$(1)_CFLAGS
95 # android-$(1)_CXXFLAGS
96 # android-$(1)_LDFLAGS
97 define AndroidTargetTemplate
98 _android$(5)-$(1)_AR=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-ar
99 _android$(5)-$(1)_AS=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-as
100 _android$(5)-$(1)_CC=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-clang
101 _android$(5)-$(1)_CXX=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-clang++
102 _android$(5)-$(1)_CPP=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-$$(if $(wildcard $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-cpp),cpp,clang -E)
103 _android$(5)-$(1)_CXXCPP=$$(CCACHE) $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-$$(if $(wildcard $$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-cpp),cpp,clang++ -E)
104 _android$(5)-$(1)_DLLTOOL=
105 _android$(5)-$(1)_LD=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-ld
106 _android$(5)-$(1)_OBJDUMP="$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-objdump"
107 _android$(5)-$(1)_RANLIB=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-ranlib
108 _android$(5)-$(1)_CMAKE=$$(ANDROID_SDK_PREFIX)/cmake/$(ANDROID_CMAKE_VERSION)/bin/cmake
109 _android$(5)-$(1)_STRIP=$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/bin/$(3)-strip
111 _android$(5)-$(1)_AC_VARS= \
112 mono_cv_uscore=yes \
113 ac_cv_func_sched_getaffinity=no \
114 ac_cv_func_sched_setaffinity=no \
115 ac_cv_func_shm_open_working_with_mmap=no
117 _android$(5)-$(1)_CFLAGS= \
118 -fstack-protector \
119 -DMONODROID=1 $$(if $$(filter $$(ANDROID_NEW_NDK),yes),-D__ANDROID_API__=$$(ANDROID_SDK_VERSION_$(1)))
121 _android$(5)-$(1)_CXXFLAGS= \
122 -fstack-protector \
123 -DMONODROID=1 $$(if $$(filter $$(ANDROID_NEW_NDK),yes),-D__ANDROID_API__=$$(ANDROID_SDK_VERSION_$(1)))
126 _android$(5)-$(1)_CPPFLAGS= \
127 -I$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/sysroot/usr/include
129 _android$(5)-$(1)_CXXCPPFLAGS= \
130 -I$$(ANDROID_TOOLCHAIN_PREFIX)/$(1)-clang/sysroot/usr/include
132 _android$(5)-$(1)_LDFLAGS= \
133 -z now -z relro -z noexecstack \
134 -ldl -lm -llog -lc -lgcc \
135 -Wl,-rpath-link=$$(ANDROID_TOOLCHAIN_DIR)/ndk/platforms/android-$$(ANDROID_SDK_VERSION_$(1))/arch-$(2)/usr/lib,-dynamic-linker=/system/bin/linker \
136 -L$$(ANDROID_TOOLCHAIN_DIR)/ndk/platforms/android-$$(ANDROID_SDK_VERSION_$(1))/arch-$(2)/usr/lib
138 _android$(5)-$(1)_CONFIGURE_FLAGS= \
139 --disable-boehm \
140 --disable-executables \
141 --disable-iconv \
142 --disable-mcs-build \
143 --disable-nls \
144 --enable-dynamic-btls \
145 --enable-maintainer-mode \
146 --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,$$(if $(5),,interpreter$$(COMMA)),gac,cfgdir_config \
147 --enable-monodroid \
148 --with-btls-android-ndk=$$(ANDROID_TOOLCHAIN_DIR)/ndk \
149 --with-btls-android-api=$$(ANDROID_SDK_VERSION_$(1)) \
150 $$(if $$(filter $$(ANDROID_NEW_NDK),yes),--with-btls-android-ndk-asm-workaround) \
151 --with-btls-android-cmake-toolchain=$$(ANDROID_TOOLCHAIN_DIR)/ndk/build/cmake/android.toolchain.cmake \
152 --with-sigaltstack=yes \
153 --with-tls=pthread \
154 --without-ikvm-native \
155 --disable-cooperative-suspend \
156 --disable-hybrid-suspend \
157 --disable-crash-reporting
159 ifeq ($(5),-interpreter)
160 .stamp-android$(5)-$(1)-toolchain: .stamp-android-$(1)-toolchain
161 else
162 .stamp-android-$(1)-toolchain: | $$(if $$(IGNORE_PROVISION_ANDROID),,provision-android)
163 $(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
164 touch $$@
165 endif
167 $$(eval $$(call RuntimeTemplate,android,$(1),$(4),,$(5)))
169 endef
172 # Parameters:
173 # $(1): target
174 # $(2): arch
175 # $(3): abi_name
176 # $(4): host_triple
178 # Flags:
179 # android-$(1)_CFLAGS
180 # android-$(1)_CXXFLAGS
181 # android-$(1)_LDFLAGS
182 define AndroidTargetTemplateStub
184 .stamp-android-$(1)-toolchain: | $$(if $$(IGNORE_PROVISION_ANDROID),,provision-android)
185 touch $$@
187 $$(eval $$(call RuntimeTemplateStub,android,$(1),$(4)))
189 endef
191 ## android-armeabi-v7a
192 android-armeabi-v7a_CFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -march=armv7-a -mtune=cortex-a8 -mfpu=vfp -mfloat-abi=softfp
193 android-armeabi-v7a_CXXFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -march=armv7-a -mtune=cortex-a8 -mfpu=vfp -mfloat-abi=softfp
194 android-armeabi-v7a_LDFLAGS=-Wl,--fix-cortex-a8
195 ifeq ($(UNAME),Windows)
196 $(eval $(call AndroidTargetTemplateStub,armeabi-v7a,arm,arm-linux-androideabi,armv5-linux-androideabi))
197 else
198 $(eval $(call AndroidTargetTemplate,armeabi-v7a,arm,arm-linux-androideabi,armv5-linux-androideabi))
199 $(eval $(call AndroidTargetTemplate,armeabi-v7a,arm,arm-linux-androideabi,armv5-linux-androideabi,-interpreter))
200 endif
202 ## android-arm64-v8a
203 android-arm64-v8a_CFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -DL_cuserid=9 -DANDROID64
204 android-arm64-v8a_CXXFLAGS=-D__POSIX_VISIBLE=201002 -DSK_RELEASE -DNDEBUG -UDEBUG -fpic -DL_cuserid=9 -DANDROID64
205 ifeq ($(UNAME),Windows)
206 $(eval $(call AndroidTargetTemplateStub,arm64-v8a,arm64,aarch64-linux-android,aarch64-linux-android))
207 else
208 $(eval $(call AndroidTargetTemplate,arm64-v8a,arm64,aarch64-linux-android,aarch64-linux-android))
209 $(eval $(call AndroidTargetTemplate,arm64-v8a,arm64,aarch64-linux-android,aarch64-linux-android,-interpreter))
210 endif
212 ## android-x86
213 ifeq ($(UNAME),Windows)
214 $(eval $(call AndroidTargetTemplateStub,x86,x86,i686-linux-android,i686-linux-android))
215 else
216 $(eval $(call AndroidTargetTemplate,x86,x86,i686-linux-android,i686-linux-android))
217 $(eval $(call AndroidTargetTemplate,x86,x86,i686-linux-android,i686-linux-android,-interpreter))
218 endif
220 ## android-x86_64
221 android-x86_64_CFLAGS=-DL_cuserid=9
222 android-x86_64_CXXFLAGS=-DL_cuserid=9
223 ifeq ($(UNAME),Windows)
224 $(eval $(call AndroidTargetTemplateStub,x86_64,x86_64,x86_64-linux-android,x86_64-linux-android))
225 else
226 $(eval $(call AndroidTargetTemplate,x86_64,x86_64,x86_64-linux-android,x86_64-linux-android))
227 $(eval $(call AndroidTargetTemplate,x86_64,x86_64,x86_64-linux-android,x86_64-linux-android,-interpreter))
228 endif
231 # Parameters
232 # $(1): target
234 # Flags:
235 # android-$(1)_CFLAGS
236 # android-$(1)_CXXFLAGS
237 define AndroidHostTemplate
239 _android-$(1)_AR=ar
240 _android-$(1)_AS=as
241 _android-$(1)_CC=cc
242 _android-$(1)_CXX=c++
243 _android-$(1)_CXXCPP=cpp
244 _android-$(1)_LD=ld
245 _android-$(1)_RANLIB=ranlib
246 _android-$(1)_STRIP=strip
248 _android-$(1)_CFLAGS= \
249 $$(if $$(filter $$(UNAME),Darwin),-mmacosx-version-min=10.9)
251 _android-$(1)_CONFIGURE_FLAGS= \
252 --disable-boehm \
253 --disable-iconv \
254 --disable-mono-debugger \
255 --disable-nls \
256 --disable-mcs-build \
257 --enable-dynamic-btls \
258 --enable-maintainer-mode \
259 --enable-monodroid \
260 --with-mcs-docs=no \
261 --without-ikvm-native \
262 --with-static_mono=no \
263 --disable-crash-reporting
265 .stamp-android-$(1)-toolchain:
266 touch $$@
268 $$(eval $$(call RuntimeTemplate,android,$(1)))
270 ifeq ($$(UNAME),Darwin)
271 ADDITIONAL_PACKAGE_DEPS += $$(android_HOST_DARWIN_LIB_DIR)/.stamp-android-loader-path
272 endif
274 endef
276 # on Windows, we use the AndroidHostMxeTemplate, instead
277 ifneq ($(UNAME),Windows)
278 $(eval $(call AndroidHostTemplate,host-$(UNAME)))
279 endif
282 # Parameters
283 # $(1): target
284 # $(2): arch
285 define AndroidHostMxeTemplate
287 _android-$(1)_PATH=$$(MXE_PREFIX)/bin
289 _android-$(1)_AR=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-ar
290 _android-$(1)_AS=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-as
291 _android-$(1)_CC=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-gcc
292 _android-$(1)_CXX=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-g++
293 _android-$(1)_DLLTOOL=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-dlltool
294 _android-$(1)_LD=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-ld
295 _android-$(1)_OBJDUMP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-objdump
296 _android-$(1)_RANLIB=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-ranlib
297 _android-$(1)_STRIP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-strip
299 # On Cygwin, assume x86_64-mingw32-zlib and i686-mingw32-zlib are installed
300 # TODO: WSL packages will depend on the distro
301 _android-$(1)_AC_VARS= \
302 $$(if $$(filter $$(UNAME),Windows),,ac_cv_header_zlib_h=no) \
303 ac_cv_search_dlopen=no
305 _android-$(1)_CFLAGS= \
306 -DXAMARIN_PRODUCT_VERSION=0 \
307 $$(if $$(filter $$(UNAME),Windows),,-I$$(MXE_PREFIX)/opt/mingw-zlib/usr/$(2)-w64-mingw32/include)
309 _android-$(1)_CXXFLAGS= \
310 -DXAMARIN_PRODUCT_VERSION=0 \
311 $$(if $$(filter $$(UNAME),Windows),,-I$$(MXE_PREFIX)/opt/mingw-zlib/usr/$(2)-w64-mingw32/include)
313 _android-$(1)_CONFIGURE_FLAGS= \
314 --disable-boehm \
315 --disable-llvm \
316 --disable-mcs-build \
317 --disable-nls \
318 --enable-static-gcc-libs \
319 --enable-maintainer-mode \
320 --enable-monodroid \
321 --with-monodroid \
322 --with-static_mono=no \
323 --disable-crash-reporting
325 ifeq ($(UNAME),Darwin)
326 _android-$(1)_LDFLAGS= \
327 $$(MXE_PREFIX)/opt/mingw-zlib/usr/$(2)-w64-mingw32/lib/libz.a
328 endif
330 .stamp-android-$(1)-toolchain:
331 touch $$@
333 .stamp-android-$(1)-$$(CONFIGURATION)-configure: | $(if $(IGNORE_PROVISION_MXE),,provision-mxe)
335 $$(eval $$(call RuntimeTemplate,android,$(1),$(2)-w64-mingw32))
337 endef
339 ifneq ($(UNAME),Windows)
340 $(eval $(call AndroidHostMxeTemplate,host-mxe-Win32,i686))
341 $(eval $(call AndroidHostMxeTemplate,host-mxe-Win64,x86_64))
342 else
343 # on Windows the MinGW-built Mono is the host Mono. But we have to use the cross template
344 # because 'gcc' is the cygwin or WSL compiler, while the x86_64-w64-mingw32-gcc is the windows native compiler.
345 # TODO: build $(eval $(call AndroidHostMxeTemplate,host-mxe-Win64,x86_64))
346 # TODO: also build $(eval $(call AndroidHostMxeTemplate,host-mxe-Win32,i686))
347 endif
350 # Parameters
351 # $(1): target
352 # $(2): host arch
353 # $(3): target arch
354 # $(4): device target (armeabi-v7a, arm64-v8a, x86 or x86_64)
355 # $(5): llvm (llvm64 or llvmwin64)
356 # $(6): offsets dumper abi
357 define AndroidCrossTemplate
359 _android-$(1)_OFFSETS_DUMPER_ARGS=--libclang="$$(ANDROID_LIBCLANG)" --sysroot="$$(ANDROID_TOOLCHAIN_DIR)/ndk/sysroot"
361 _android-$(1)_AR=ar
362 _android-$(1)_AS=as
363 _android-$(1)_CC=$$(or $$(android-$(1)_CC),cc)
364 _android-$(1)_CXX=$$(or $$(android-$(1)_CXX),c++)
365 _android-$(1)_CXXCPP=cpp
366 _android-$(1)_LD=ld
367 _android-$(1)_RANLIB=ranlib
368 _android-$(1)_STRIP=strip
370 _android-$(1)_CFLAGS= \
371 $$(if $$(RELEASE),,-DDEBUG_CROSS) \
372 $$(if $$(filter $$(UNAME),Darwin),-mmacosx-version-min=10.9) \
373 -DXAMARIN_PRODUCT_VERSION=0
375 _android-$(1)_CXXFLAGS= \
376 $$(if $$(RELEASE),,-DDEBUG_CROSS) \
377 $$(if $$(filter $$(UNAME),Darwin),-mmacosx-version-min=10.9 -stdlib=libc++) \
378 -DXAMARIN_PRODUCT_VERSION=0
380 _android-$(1)_CONFIGURE_FLAGS= \
381 --disable-boehm \
382 --disable-mcs-build \
383 --disable-nls \
384 --enable-maintainer-mode \
385 --with-tls=pthread
387 $$(eval $$(call CrossRuntimeTemplate,android,$(1),$$(if $$(filter $$(UNAME),Darwin),$(2)-apple-darwin10,$$(if $$(filter $$(UNAME),Linux),$(2)-linux-gnu)),$(3)-linux-android,$(4),$(5),$(6)))
389 endef
392 # Parameters
393 # $(1): target
394 # $(2): host arch
395 # $(3): target arch
396 # $(4): device target (armeabi-v7a, arm64-v8a, x86 or x86_64)
397 # $(5): llvm (llvm64 or llvmwin64)
398 # $(6): offsets dumper abi
399 define AndroidCrossTemplateStub
401 $$(eval $$(call CrossRuntimeTemplateStub,android,$(1),$$(if $$(filter $$(UNAME),Darwin),$(2)-apple-darwin10,$$(if $$(filter $$(UNAME),Linux),$(2)-linux-gnu)),$(3)-linux-android,$(4),$(5),$(6)))
403 endef
405 ifeq ($(UNAME),Windows)
406 $(eval $(call AndroidCrossTemplateStub,cross-arm,x86_64,armv7,armeabi-v7a,llvm-llvm64,armv7-none-linux-androideabi))
407 $(eval $(call AndroidCrossTemplateStub,cross-arm64,x86_64,aarch64-v8a,arm64-v8a,llvm-llvm64,aarch64-v8a-linux-android))
408 $(eval $(call AndroidCrossTemplateStub,cross-x86,x86_64,i686,x86,llvm-llvm64,i686-none-linux-android))
409 $(eval $(call AndroidCrossTemplateStub,cross-x86_64,x86_64,x86_64,x86_64,llvm-llvm64,x86_64-none-linux-android))
410 else
411 $(eval $(call AndroidCrossTemplate,cross-arm,x86_64,armv7,armeabi-v7a,llvm-llvm64,armv7-none-linux-androideabi))
412 $(eval $(call AndroidCrossTemplate,cross-arm64,x86_64,aarch64-v8a,arm64-v8a,llvm-llvm64,aarch64-v8a-linux-android))
413 $(eval $(call AndroidCrossTemplate,cross-x86,x86_64,i686,x86,llvm-llvm64,i686-none-linux-android))
414 $(eval $(call AndroidCrossTemplate,cross-x86_64,x86_64,x86_64,x86_64,llvm-llvm64,x86_64-none-linux-android))
415 endif
418 # Parameters
419 # $(1): target
420 # $(2): host arch
421 # $(3): target arch
422 # $(4): device target
423 # $(5): llvm
424 # $(6): offsets dumper abi
425 define AndroidCrossMXETemplate
427 _android-$(1)_OFFSETS_DUMPER_ARGS=--libclang="$$(ANDROID_LIBCLANG)" --sysroot="$$(ANDROID_TOOLCHAIN_DIR)/ndk/sysroot"
429 _android-$(1)_PATH=$$(MXE_PREFIX)/bin
431 _android-$(1)_AR=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-ar
432 _android-$(1)_AS=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-as
433 _android-$(1)_CC=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-gcc
434 _android-$(1)_CXX=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-g++
435 _android-$(1)_DLLTOOL=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-dlltool
436 _android-$(1)_LD=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-ld
437 _android-$(1)_OBJDUMP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-objdump
438 _android-$(1)_RANLIB=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-ranlib
439 _android-$(1)_STRIP=$$(MXE_PREFIX)/bin/$(2)-w64-mingw32-strip
441 _android-$(1)_CFLAGS= \
442 $$(if $$(RELEASE),,-DDEBUG_CROSS) \
443 -DXAMARIN_PRODUCT_VERSION=0 \
444 -I$$(MXE_PREFIX)/opt/mingw-zlib/usr/$(2)-w64-mingw32/include
446 _android-$(1)_CXXFLAGS= \
447 $$(if $$(RELEASE),,-DDEBUG_CROSS) \
448 -DXAMARIN_PRODUCT_VERSION=0 \
449 -I$$(MXE_PREFIX)/opt/mingw-zlib/usr/$(2)-w64-mingw32/include
451 _android-$(1)_LDFLAGS=
454 _android-$(1)_CONFIGURE_FLAGS= \
455 --disable-boehm \
456 --disable-mcs-build \
457 --disable-nls \
458 --enable-static-gcc-libs \
459 --enable-maintainer-mode \
460 --with-tls=pthread
462 ifeq ($(UNAME),Darwin)
463 _android-$(1)_CONFIGURE_FLAGS += \
464 --with-static-zlib=$$(MXE_PREFIX)/opt/mingw-zlib/usr/$(2)-w64-mingw32/lib/libz.a
465 endif
467 .stamp-android-$(1)-$$(CONFIGURATION)-configure: | $(if $(IGNORE_PROVISION_MXE),,provision-mxe)
469 $$(eval $$(call CrossRuntimeTemplate,android,$(1),$(2)-w64-mingw32,$(3)-linux-android,$(4),$(5),$(6)))
471 endef
474 # Parameters
475 # $(1): target
476 # $(2): host arch
477 # $(3): target arch
478 # $(4): device target
479 # $(5): llvm
480 # $(6): offsets dumper abi
481 define AndroidCrossMXETemplateStub
483 $$(eval $$(call CrossRuntimeTemplateStub,android,$(1),$(2)-w64-mingw32,$(3)-linux-android,$(4),$(5),$(6)))
485 endef
487 ifneq ($(UNAME),Windows)
488 $(eval $(call AndroidCrossMXETemplate,cross-arm-win,x86_64,armv7,armeabi-v7a,llvm-llvmwin64,armv7-none-linux-androideabi))
489 $(eval $(call AndroidCrossMXETemplate,cross-arm64-win,x86_64,aarch64-v8a,arm64-v8a,llvm-llvmwin64,aarch64-v8a-linux-android))
490 $(eval $(call AndroidCrossMXETemplate,cross-x86-win,x86_64,i686,x86,llvm-llvmwin64,i686-none-linux-android))
491 $(eval $(call AndroidCrossMXETemplate,cross-x86_64-win,x86_64,x86_64,x86_64,llvm-llvmwin64,x86_64-none-linux-android))
492 else
493 $(eval $(call AndroidCrossMXETemplateStub,cross-arm-win,x86_64,armv7,armeabi-v7a,llvm-llvmwin64,armv7-none-linux-androideabi))
494 $(eval $(call AndroidCrossMXETemplateStub,cross-arm64-win,x86_64,aarch64-v8a,arm64-v8a,llvm-llvmwin64,aarch64-v8a-linux-android))
495 $(eval $(call AndroidCrossMXETemplateStub,cross-x86-win,x86_64,i686,x86,llvm-llvmwin64,i686-none-linux-android))
496 $(eval $(call AndroidCrossMXETemplateStub,cross-x86_64-win,x86_64,x86_64,x86_64,llvm-llvmwin64,x86_64-none-linux-android))
497 endif
499 ifeq ($(UNAME),Windows)
500 _bcl_android_BUILD_FLAGS += \
501 PROFILE_PLATFORM=win32
502 endif
504 $(eval $(call BclTemplate,android,monodroid monodroid_tools,monodroid monodroid_tools))
506 $(android_SOURCES_DIR)/external/linker/README.md: # we use this as a sentinel file to avoid rsyncing everything on each build (slows down iterating)
507 mkdir -p $(android_SOURCES_DIR)/external/linker
508 cd $(TOP) && rsync -r --include='*.cs' --include="README.md" --include="*/" --exclude="*" external/linker $(android_SOURCES_DIR)/external
510 $(android_SOURCES_DIR): $(android_SOURCES_DIR)/external/linker/README.md
512 $(android_TPN_DIR)/LICENSE:
513 mkdir -p $(android_TPN_DIR)
514 cd $(TOP) && rsync -r --include='THIRD-PARTY-NOTICES.TXT' --include='license.txt' --include='License.txt' --include='LICENSE' --include='LICENSE.txt' --include='LICENSE.TXT' --include='COPYRIGHT.regex' --include='*/' --exclude="*" --prune-empty-dirs . $(android_TPN_DIR)
516 $(android_TPN_DIR): $(android_TPN_DIR)/LICENSE
518 $(android_HOST_DARWIN_LIB_DIR)/.stamp-android-loader-path: package-android-host-Darwin
519 $(android_PLATFORM_BIN)/install_name_tool -id @loader_path/libmonosgen-2.0.dylib $(android_HOST_DARWIN_LIB_DIR)/libmonosgen-2.0.dylib
520 $(android_PLATFORM_BIN)/install_name_tool -change $(android_HOST_DARWIN_LIB_DIR)/libmonosgen-2.0.1.dylib @loader_path/libmonosgen-2.0.dylib $(android_HOST_DARWIN_BIN_DIR)/mono
521 touch $@