This repository has been archived by the owner on Nov 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
/
MakeAndroid
99 lines (78 loc) · 7.5 KB
/
MakeAndroid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#armeabi-v7a, x86, armeabi
ABI=armeabi
#e.g. C:/Users/Egor/Documents/Android/ndk/android-ndk-r12b
ANDK_DIR=$(subst \,/,$(ANDROID_NDK))
TOOLCHAINS_VER=4.9
ANDROID_API=android-15
BUILD_TYPE=Release
OUTPUT_DIR=Bin/Android/$(ABI)
URHO3D_SRC_DIR=Urho3D/Source
URHO3D_ANDROID_DIR=Urho3D/Urho3D_Android/$(ABI)
TOOLCHAIN_NAME=arm-linux-androideabi-$(TOOLCHAINS_VER)
ifndef OS
OS=$(shell uname)
endif
ifeq ($(OS), Darwin)
PREBUILT_DIR=darwin-x86_64
MKDIR_CMD=mkdir -p
else
PREBUILT_DIR=windows-x86_64
WINDOWS_EXT=.exe
MKDIR_CMD=mkdir
endif
ifeq ($(ABI), x86)
PLATFORM=x86
TOOLCHAIN_NAME=x86-4.9
ANDK_GCC=$(ANDK_DIR)/toolchains/x86-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/i686-linux-android-gcc$(WINDOWS_EXT)
ANDK_GPP=$(ANDK_DIR)/toolchains/x86-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/i686-linux-android-g++$(WINDOWS_EXT)
ANDK_STRIP=$(ANDK_DIR)/toolchains/x86-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/i686-linux-android-strip$(WINDOWS_EXT)
else ifeq ($(ABI), x86_64)
ANDROID_API=android-21
PLATFORM=x86_64
TOOLCHAIN_NAME=x86_64-$(TOOLCHAINS_VER)
ANDK_GCC=$(ANDK_DIR)/toolchains/x86_64-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/x86_64-linux-android-gcc$(WINDOWS_EXT)
ANDK_GPP=$(ANDK_DIR)/toolchains/x86_64-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/x86_64-linux-android-g++$(WINDOWS_EXT)
ANDK_STRIP=$(ANDK_DIR)/toolchains/x86_64-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/x86_64-linux-android-strip$(WINDOWS_EXT)
else ifeq ($(ABI), arm64-v8a)
ANDROID_API=android-21
PLATFORM=arm64
TOOLCHAIN_NAME=aarch64-linux-android-$(TOOLCHAINS_VER)
ANDK_GCC=$(ANDK_DIR)/toolchains/aarch64-linux-android-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/aarch64-linux-android-gcc$(WINDOWS_EXT)
ANDK_GPP=$(ANDK_DIR)/toolchains/aarch64-linux-android-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/aarch64-linux-android-g++$(WINDOWS_EXT)
ANDK_STRIP=$(ANDK_DIR)/toolchains/aarch64-linux-android-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/aarch64-linux-android-strip$(WINDOWS_EXT)
else
PLATFORM=arm
TOOLCHAIN_NAME=arm-linux-androideabi-$(TOOLCHAINS_VER)
ANDK_GCC=$(ANDK_DIR)/toolchains/arm-linux-androideabi-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/arm-linux-androideabi-gcc$(WINDOWS_EXT)
ANDK_GPP=$(ANDK_DIR)/toolchains/arm-linux-androideabi-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/arm-linux-androideabi-g++$(WINDOWS_EXT)
ANDK_STRIP=$(ANDK_DIR)/toolchains/arm-linux-androideabi-$(TOOLCHAINS_VER)/prebuilt/$(PREBUILT_DIR)/bin/arm-linux-androideabi-strip$(WINDOWS_EXT)
endif
# fixes 'error: relocation overflow in R_ARM_THM_CALL' on armeabi
ifeq ($(ABI), armeabi)
ABI_FLAGS= -march=armv6t2
endif
C_FLAGS=-fexceptions -fPIC --sysroot=$(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM) -funwind-tables -funswitch-loops -finline-limit=300 -fsigned-char -no-canonical-prefixes -fdata-sections -ffunction-sections -Wa,--noexecstack -fstack-protector -fomit-frame-pointer -fstrict-aliasing -O3 -DNDEBUG -isystem $(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM)/usr/include -isystem $(ANDK_DIR)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAINS_VER)/include -isystem $(ANDK_DIR)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAINS_VER)/libs/$(ABI)/include -isystem $(ANDK_DIR)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAINS_VER)/include/backward -I$(URHO3D_ANDROID_DIR)/include -I$(URHO3D_ANDROID_DIR)/include/Urho3D/ThirdParty -I$(URHO3D_ANDROID_DIR)/include/Urho3D/ThirdParty/Bullet -I$(URHO3D_SRC_DIR)/Source/Samples
CXX_FLAGS = --sysroot=$(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM) $(ABI_FLAGS) -fpermissive -fsigned-char -funwind-tables -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fdata-sections -ffunction-sections -frtti -funswitch-loops -finline-limit=300 -fstack-protector -fomit-frame-pointer -fstrict-aliasing -fexceptions -std=gnu++11 -Wno-invalid-offsetof -O3 -DNDEBUG -fPIC -isystem $(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM)/usr/include -isystem $(ANDK_DIR)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAINS_VER)/include -isystem $(ANDK_DIR)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAINS_VER)/libs/$(ABI)/include -isystem $(ANDK_DIR)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAINS_VER)/include/backward
CXX_DEFINES = -DANDROID -DURHO3D_FILEWATCHER -DURHO3D_IK -DURHO3D_LOGGING -DURHO3D_NAVIGATION -DURHO3D_NETWORK -DURHO3D_PHYSICS -DURHO3D_PROFILING -DURHO3D_STATIC_DEFINE -DURHO3D_THREADING -DURHO3D_URHO2D
CXX_INCLUDES = -isystem $(ANDK_DIR)/sources/cxx-stl/llvm-libc++/include -isystem $(ANDK_DIR)/sources/cxx-stl/llvm-libc++abi/include -isystem $(ANDK_DIR)/sources/android/support/include -IC:/prj/urho/Urho3D/Urho3D_Android/armeabi/include -I$(URHO3D_ANDROID_DIR)/include -I$(URHO3D_ANDROID_DIR)/include/Urho3D/ThirdParty -I$(URHO3D_ANDROID_DIR)/include/Urho3D/ThirdParty/Bullet -I$(URHO3D_SRC_DIR)/Source/Samples
ApplicationProxy.o:
$(ANDK_GPP) $(CXX_DEFINES) $(CXX_FLAGS) $(CXX_INCLUDES) -o $(OUTPUT_DIR)/ApplicationProxy.cpp.o -c Bindings/Native/ApplicationProxy.cpp
Glue.o:
$(ANDK_GPP) $(CXX_DEFINES) $(CXX_FLAGS) $(CXX_INCLUDES) -o $(OUTPUT_DIR)/glue.cpp.o -c Bindings/Native/glue.cpp
Vector.o:
$(ANDK_GPP) $(CXX_DEFINES) $(CXX_FLAGS) $(CXX_INCLUDES) -o $(OUTPUT_DIR)/Vector.cpp.o -c Bindings/Native/Vector.cpp
Binding.o:
$(ANDK_GPP) $(CXX_DEFINES) $(CXX_FLAGS) $(CXX_INCLUDES) -o $(OUTPUT_DIR)/binding.cpp.o -c Bindings/Portable/Generated/binding.cpp
Events.o:
$(ANDK_GPP) $(CXX_DEFINES) $(CXX_FLAGS) $(CXX_INCLUDES) -o $(OUTPUT_DIR)/events.cpp.o -c Bindings/Portable/Generated/events.cpp
SDL.o:
$(ANDK_GCC) $(CXX_DEFINES) $(C_FLAGS) -o $(OUTPUT_DIR)/SDL_android_main.c.o -c $(URHO3D_SRC_DIR)/Source/ThirdParty/SDL/src/main/android/SDL_android_main.c
Urho3D_Android:
rm -rf $(URHO3D_ANDROID_DIR) && $(MKDIR_CMD) "$(URHO3D_ANDROID_DIR)" && cd $(URHO3D_SRC_DIR) && cmake -E make_directory ../Urho3D_Android/$(ABI) && cmake -E chdir ../Urho3D_Android/$(ABI) cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../$(URHO3D_SRC_DIR)/CMake/Toolchains/Android.cmake .../Urho3D_Android/$(ABI) -DANDROID=1 -DANDROID_ABI=$(ABI) -DANDROID_NATIVE_API_LEVEL=$(ANDROID_API) -DANDROID_TOOLCHAIN_NAME=$(TOOLCHAIN_NAME) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DURHO3D_PCH=0 -DURHO3D_C++11=0 -DURHO3D_TOOLS=0 -DURHO3D_LUA=0 -DURHO3D_WEBP=0 -DURHO3D_ANGELSCRIPT=0 -DURHO3D_SSE=0 ../../../$(URHO3D_SRC_DIR)/
libUrho3D.a: Urho3D_Android
cd $(URHO3D_ANDROID_DIR) && make Urho3D
MakeBinDirectory:
$(MKDIR_CMD) "$(OUTPUT_DIR)"
objects: MakeBinDirectory ApplicationProxy.o Glue.o Vector.o Binding.o Events.o SDL.o
libmono-urho.so: libUrho3D.a objects
$(ANDK_GPP) --sysroot=$(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM) $(C_DEFINES) -fPIC -fsigned-char -funwind-tables -no-canonical-prefixes -Wa,--noexecstack $(ABI_FLAGS) -Wformat -Werror=format-security -fdata-sections -ffunction-sections -frtti -fexceptions -std=gnu++11 -Wno-invalid-offsetof -O3 -DNDEBUG -Wl,--build-id -Wl,--warn-shared-textrel -Wl,-rpath-link,"$(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM)/usr/lib":"$(ANDK_DIR)/platforms/$(ANDROID_API)/arch-$(PLATFORM)/lib":"$(ANDK_DIR)/sources/cxx-stl/llvm-libc++/libs/$(ABI)" -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--fatal-warnings -Wl,--gc-sections -shared -Wl,-soname,libmono-urho.so -o $(OUTPUT_DIR)/libmono-urho.so $(OUTPUT_DIR)/ApplicationProxy.cpp.o $(OUTPUT_DIR)/Vector.cpp.o $(OUTPUT_DIR)/Glue.cpp.o $(OUTPUT_DIR)/events.cpp.o $(OUTPUT_DIR)/binding.cpp.o $(OUTPUT_DIR)/SDL_android_main.c.o $(URHO3D_ANDROID_DIR)/libs/$(ABI)/libUrho3D.a -ldl -llog -landroid -lGLESv1_CM -lGLESv2 -L$(ANDK_DIR)/sources/cxx-stl/llvm-libc++/libs/$(ABI) -Wl,-Bstatic -lc++ -Wl,-Bdynamic -Wl,-z,muldefs && cd $(OUTPUT_DIR) && rm *.o && $(ANDK_STRIP) libmono-urho.so