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 := 9
12endif
13
14ifeq "$(ARCH)" "arm"
15	SYSROOT_ARCH := arm
16	STL_ARCH := armeabi-v7a
17	ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
18else ifeq "$(ARCH)" "aarch64"
19	SYSROOT_ARCH := arm64
20	STL_ARCH := arm64-v8a
21else ifeq "$(ARCH)" "i386"
22	SYSROOT_ARCH := x86
23	STL_ARCH := x86
24else ifeq "$(ARCH)" "mips64r6"
25	SYSROOT_ARCH := mips64
26	STL_ARCH := mips64
27else ifeq "$(ARCH)" "mips32"
28	SYSROOT_ARCH := mips
29	STL_ARCH := mips
30else
31	SYSROOT_ARCH := $(ARCH)
32	STL_ARCH := $(ARCH)
33endif
34
35ARCH_CFLAGS += \
36	--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) \
37	-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
38	-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
39	-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
40ARCH_LDFLAGS += -lm \
41	$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a \
42	--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)
43