2012-06-22 13:39:24 +02:00
|
|
|
|
|
|
|
ifeq ($(NDK),)
|
|
|
|
$(error Must export NDK location before building for Android)
|
|
|
|
endif
|
|
|
|
NDK_ROOT:=$(NDK)
|
2015-01-27 11:46:48 +01:00
|
|
|
#NDK_LOG:=1
|
2012-06-22 13:39:24 +02:00
|
|
|
include $(NDK)/build/core/init.mk
|
2015-01-27 11:46:48 +01:00
|
|
|
|
2020-05-15 17:03:52 +02:00
|
|
|
TOOLCHAIN:=$(foreach chain, $(NDK_ALL_TOOLCHAINS), $(if $(findstring arm, $(chain)), $(chain), ))
|
2015-01-27 11:46:48 +01:00
|
|
|
# Filter out clang
|
2020-05-15 17:03:52 +02:00
|
|
|
TEMP_TC := $(foreach chain, $(TOOLCHAIN), $(if $(findstring clang, $(chain)), , $(chain)))
|
|
|
|
ifneq ($(strip $(TEMP_TC)),)
|
|
|
|
TOOLCHAIN := $(TEMP_TC)
|
2015-01-27 11:46:48 +01:00
|
|
|
endif
|
|
|
|
# use freshmost compiler
|
2020-05-15 17:03:52 +02:00
|
|
|
TOOLCHAIN:=$(lastword $(TOOLCHAIN))
|
|
|
|
|
|
|
|
TOOLCHAIN_ARCH:=
|
|
|
|
-include $(NDK)/build/core/toolchains/$(TOOLCHAIN)/config.mk
|
|
|
|
-include $(NDK)/build/core/toolchains/$(TOOLCHAIN)/setup.mk
|
|
|
|
|
|
|
|
ifeq ($(TOOLCHAIN_ARCH),arm)
|
|
|
|
|
|
|
|
TOOL_PATH:=$(NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin
|
|
|
|
CROSS_PREFIX:=$(TOOL_PATH)/$(TOOLCHAIN_NAME)-
|
|
|
|
|
|
|
|
#Now it's time to decide upon clang/clang++
|
2021-01-07 16:06:41 +01:00
|
|
|
CLANG_NAME:=$(subst arm-,armv7a-,$(TOOLCHAIN_NAME))
|
2020-05-15 17:03:52 +02:00
|
|
|
CLANG_NUM:=$(shell mi=256; for i in `seq 24 $$mi`; do [ -e $(TOOL_PATH)/$(CLANG_NAME)$$i-clang ] && [ $$i -le $$mi ] && mi=$$i; done; echo $$mi)
|
|
|
|
CXX:=$(TOOL_PATH)/$(CLANG_NAME)$(CLANG_NUM)-clang++
|
|
|
|
CC:=$(TOOL_PATH)/$(CLANG_NAME)$(CLANG_NUM)-clang
|
|
|
|
|
|
|
|
#CROSS_FLAGS:=--sysroot=$(NDK)/sysroot \
|
|
|
|
# -I$(ROOT)/gen/cross \
|
|
|
|
# -I$(NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1
|
|
|
|
|
|
|
|
CROSS_FLAGS:=--sysroot=$(NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot \
|
|
|
|
-I$(ROOT)/gen/cross
|
|
|
|
|
|
|
|
else
|
|
|
|
#TOOLCHAIN_ARCH
|
2015-01-27 11:46:48 +01:00
|
|
|
|
2014-06-06 12:29:23 +02:00
|
|
|
ifeq ($(HOST_TAG64),)
|
|
|
|
HOST_TAG64:=linux-x86
|
|
|
|
endif
|
|
|
|
NDK_TOOLCHAIN_VERSION:=$(shell echo $(TOOLCHAIN_DIR) | awk -F - '{print $$NF;}')
|
2012-06-22 13:39:24 +02:00
|
|
|
|
2018-02-07 18:16:57 +01:00
|
|
|
CROSS_PLATFORM:=$(NDK)/platforms
|
|
|
|
ALEVEL:=$(shell for i in `seq 256`; do [ -d $(CROSS_PLATFORM)/android-$${i} ] && adir=$${i}; done; echo $${adir})
|
|
|
|
CROSS_PLATFORM:=$(CROSS_PLATFORM)/android-$(ALEVEL)/arch-arm
|
|
|
|
|
2014-06-06 12:29:23 +02:00
|
|
|
CROSS_PREFIX:=$(NDK)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG64)/bin/arm-linux-androideabi-
|
2012-06-22 13:39:24 +02:00
|
|
|
|
|
|
|
CXX:=$(CROSS_PREFIX)g++
|
|
|
|
CC:=$(CROSS_PREFIX)gcc
|
2020-05-15 17:03:52 +02:00
|
|
|
|
|
|
|
CROSS_FLAGS=--sysroot=$(CROSS_PLATFORM) \
|
|
|
|
-I$(CROSS_PLATFORM)/usr/include -I$(ROOT)/gen/cross \
|
|
|
|
-I$(NDK)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/include \
|
|
|
|
-I$(NDK)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/armeabi/include
|
|
|
|
|
|
|
|
endif
|
|
|
|
#TOOLCHAIN_ARCH
|
|
|
|
|
|
|
|
|
2012-06-22 13:39:24 +02:00
|
|
|
AR:=$(CROSS_PREFIX)ar
|
|
|
|
AS:=$(CROSS_PREFIX)as
|
|
|
|
LD:=$(CROSS_PREFIX)ld
|
|
|
|
NM:=$(CROSS_PREFIX)nm
|
|
|
|
OBJCOPY:=$(CROSS_PREFIX)objcopy
|
|
|
|
OBJDUMP:=$(CROSS_PREFIX)objdump
|
|
|
|
RANLIB:=$(CROSS_PREFIX)ranlib
|
|
|
|
STRIP:=$(CROSS_PREFIX)strip
|
|
|
|
|
2018-02-07 18:16:57 +01:00
|
|
|
export CXX
|
|
|
|
export CC
|
|
|
|
export AR
|
|
|
|
|
|
|
|
export CROSS_FLAGS
|
|
|
|
|
|
|
|
COMMON_FLAGS=-ggdb -DFB_SEND_FLAGS=MSG_NOSIGNAL -DLINUX -DANDROID -DARM -pipe -MMD -fPIC -fmessage-length=0 \
|
|
|
|
-I$(ROOT)/extern/libtommath -I$(ROOT)/extern/libtomcrypt/src/headers \
|
2019-05-24 19:11:17 +02:00
|
|
|
$(CROSS_FLAGS) -fsigned-char
|
2015-01-27 11:46:48 +01:00
|
|
|
|
|
|
|
OPTIMIZE_FLAGS=-fno-omit-frame-pointer
|
2012-06-22 13:39:24 +02:00
|
|
|
WARN_FLAGS=-Wall -Wno-switch -Wno-parentheses -Wno-unknown-pragmas -Wno-unused-variable
|
|
|
|
|
|
|
|
PROD_FLAGS=$(COMMON_FLAGS) $(OPTIMIZE_FLAGS)
|
|
|
|
DEV_FLAGS=$(COMMON_FLAGS) $(WARN_FLAGS)
|
|
|
|
|
|
|
|
CROSS_CONFIG=android.arme
|
|
|
|
|
2014-06-06 12:29:23 +02:00
|
|
|
LDFLAGS += --sysroot=$(CROSS_PLATFORM) -L$(NDK)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/armeabi \
|
|
|
|
-L$(NDK)/sources/cxx-stl/gnu-libstdc++/libs/armeabi
|
2020-05-15 17:03:52 +02:00
|
|
|
DroidLibs := -lm -ldl $(DECLIB) $(RE2LIB)
|
|
|
|
UDR_SUPPORT_LIBS :=
|
2012-06-22 13:39:24 +02:00
|
|
|
|
|
|
|
LINK_LIBS = $(DroidLibs)
|
|
|
|
SO_LINK_LIBS = $(DroidLibs)
|
|
|
|
|
2019-05-24 19:05:35 +02:00
|
|
|
EXE_LINK_OPTIONS= $(LDFLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(LINK_EMPTY_SYMBOLS) -pie
|
2012-06-22 13:39:24 +02:00
|
|
|
LIB_LINK_OPTIONS= $(LDFLAGS) -shared
|
2015-01-27 11:46:48 +01:00
|
|
|
|
|
|
|
UNICODE_DIR := $(shell dirname `find /usr/include -name ucnv.h`)
|
|
|
|
UNICODE_DIR := $(filter %unicode, $(UNICODE_DIR))
|
|
|
|
UNICODE_DIR := $(firstword $(UNICODE_DIR))
|
|
|
|
ifndef UNICODE_DIR
|
|
|
|
$(error ERROR while locating ICU include directory, probably missing ucnv.h)
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: prerequisites
|
|
|
|
prerequisites: $(ROOT)/gen/cross/unicode
|
|
|
|
|
|
|
|
$(ROOT)/gen/cross/unicode:
|
|
|
|
echo $(UNICODE_DIR)
|
|
|
|
rm -rf $(ROOT)/gen/cross
|
|
|
|
mkdir $(ROOT)/gen/cross
|
|
|
|
ln -s $(UNICODE_DIR) cross/unicode
|