#
# makefile for ANDROID (generic ARM)
#
# export NDK=<ndk_home>
# tested with android-ndk-r8c-linux-x86
#

ANDROID_NDK_HOME=$(NDK)
ANDROID_NDK_BIN=$(ANDROID_NDK_HOME)/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin

# -fpic -Os
# -fstack-protector 
ANDROID_FLAGS=\
  -MMD -MP -MF \
  -fpic -ffunction-sections -funwind-tables -fstack-protector \
  -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
  -march=armv5te -mtune=xscale -msoft-float -mthumb -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
  -I$(ANDROID_NDK_HOME)/sources/cxx-stl/system/include \
  -I$(ANDROID_NDK_HOME)/platforms/android-3/arch-arm/usr/include \
  -DANDROID -DANDROID_NDK -DNDEBUG \

ANDROID_LINK= \
  -Wl,--gc-sections -Wl,-z,nocopyreloc \
  --sysroot=$(NDK)/platforms/android-3/arch-arm \
  -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \
  -L$(NDK)/platforms/android-3/arch-arm/usr/lib -lstdc++ \
  $(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libsupc++.a \
  -lc -lm 

OPTFLAGS=-O3 -s

ALLFLAGS=${OPTFLAGS} -pipe \
	-DNDEBUG -D_REENTRANT -DENV_UNIX \
	$(ANDROID_FLAGS) \
	$(LOCAL_FLAGS)

CXX=$(ANDROID_NDK_BIN)/arm-linux-androideabi-g++ -fexceptions -frtti
CC=$(ANDROID_NDK_BIN)/arm-linux-androideabi-gcc
CC_EXE= -fPIE
LINK_EXE=-fPIE -pie  # -fPIE -pie : only for executable
CC_SHARED= -fpic
LINK_SHARED=-fpic -shared

LOCAL_LIBS=$(ANDROID_LINK)
LOCAL_LIBS_DLL=$(LOCAL_LIBS) # -ldl

OBJ_CRC32=$(OBJ_CRC32_C)
OBJ_AES=

