• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1NDK_ROOT := $(shell dirname $(CC))/../../../../..
2
3ifeq "$(findstring 64, $(ARCH))" "64"
4	# lowest 64-bit API level
5	API_LEVEL := 21
6else ifeq "$(ARCH)" "i386"
7	# clone(2) declaration is present only since this api level
8	API_LEVEL := 17
9else
10	# lowest supported 32-bit API level
11	API_LEVEL := 16
12endif
13
14ifeq "$(ARCH)" "arm"
15	SYSROOT_ARCH := arm
16	STL_ARCH := armeabi-v7a
17	TRIPLE := armv7-none-linux-androideabi
18	ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
19else ifeq "$(ARCH)" "aarch64"
20	SYSROOT_ARCH := arm64
21	STL_ARCH := arm64-v8a
22	TRIPLE := aarch64-none-linux-android
23else ifeq "$(ARCH)" "i386"
24	SYSROOT_ARCH := x86
25	STL_ARCH := x86
26	TRIPLE := i686-none-linux-android
27else ifeq "$(ARCH)" "mips64r6"
28	SYSROOT_ARCH := mips64
29	STL_ARCH := mips64
30	TRIPLE := mips64el-none-linux-android
31else ifeq "$(ARCH)" "mips32"
32	SYSROOT_ARCH := mips
33	STL_ARCH := mips
34	TRIPLE := mipsel-none-linux-android
35else
36	SYSROOT_ARCH := $(ARCH)
37	STL_ARCH := $(ARCH)
38	TRIPLE := $(ARCH)-none-linux-android
39endif
40
41ifeq "$(findstring 86,$(ARCH))" "86"
42	TOOLCHAIN_DIR := $(STL_ARCH)-4.9
43else ifeq "$(ARCH)" "arm"
44	TOOLCHAIN_DIR := arm-linux-androideabi-4.9
45else
46	TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
47endif
48
49ifeq "$(ARCH)" "arm"
50	TOOL_PREFIX := arm-linux-androideabi
51else
52	TOOL_PREFIX := $(subst -none,,$(TRIPLE))
53endif
54
55ifeq "$(HOST_OS)" "Linux"
56	HOST_TAG := linux-x86_64
57else ifeq "$(HOST_OS)" "Darwin"
58	HOST_TAG := darwin-x86_64
59else
60	HOST_TAG := windows-x86_64
61endif
62
63GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
64
65OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy
66ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar
67
68ifeq "$(findstring clang,$(CC))" "clang"
69	ARCH_CFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
70	ARCH_LDFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
71endif
72
73ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \
74	-isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \
75	-D__ANDROID_API__=$(API_LEVEL) \
76	-isystem $(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include
77
78ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
79
80ARCH_CXXFLAGS += \
81	-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
82	-isystem $(NDK_ROOT)/sources/android/support/include \
83	-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
84
85ARCH_LDFLAGS += \
86	-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
87	$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
88	-lc++abi \
89	-nostdlib++
90