BUILD_TOOLCHAIN_DIR := C:/Android/Sdk/ndk/21.4.7075529
BUILD_NDK_DIR := $(BUILD_TOOLCHAIN_DIR)/toolchains/llvm/prebuilt/windows-x86_64/bin
BUILD_C_COMPILER := $(BUILD_NDK_DIR)/clang.exe
BUILD_CXX_COMPILER := $(BUILD_NDK_DIR)/clang++.exe
STRIP := $(BUILD_NDK_DIR)/llvm-strip.exe

SOURCE_DIR = $(shell pwd)
BUILD_DIR  = $(SOURCE_DIR)/target/release-ndk21-api16-v7a-c++_shared

OPTION := -GNinja
OPTION += -S$(SOURCE_DIR)
OPTION += -B$(BUILD_DIR)
OPTION += -DCMAKE_BUILD_TYPE=Release
OPTION += -DCMAKE_SYSTEM_NAME=Android
OPTION += -DCMAKE_SYSTEM_VERSION=16
OPTION += -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a
OPTION += -DCMAKE_ANDROID_NDK=$(BUILD_TOOLCHAIN_DIR)
OPTION += -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
OPTION += -DCMAKE_ANDROID_STL_TYPE=c++_shared

all:
	cmake $(OPTION)
	ninja -C $(BUILD_DIR)

strip: $(BUILD_DIR)/*.so
	$(STRIP) $<
