1############## 2# Works on hosts Linux, Windows and Darwin 3# Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 5######################### 6# Check the host platform 7 8HOST_PLATFORM = linux 9ifeq ($(shell uname -a),) 10 HOST_PLATFORM = windows 11else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 HOST_PLATFORM = windows 13else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 HOST_PLATFORM = darwin 15else ifneq ($(findstring win,$(shell uname -a)),) 16 HOST_PLATFORM = windows 17endif 18 19######################### 20# Set the target platform 21 22TARGET_PLATFORM = android_mips 23 24################# 25# Toolchain setup 26 27CC = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-gcc 28CXX = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-g++ 29AS = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-as 30AR = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-ar 31 32############ 33# Extensions 34 35OBJEXT = .android_mips.o 36SOEXT = .android_mips.so 37LIBEXT = .android_mips.a 38 39################ 40# Platform setup 41 42STATIC_LINKING = 0 43platform = android 44PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45PLATCFLAGS = -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -fomit-frame-pointer -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46PLATCXXFLAGS = -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -fomit-frame-pointer -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-mips -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-mips -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/libgnustl_static.a 49 50################ 51# libretro setup 52 53RETRODEFS = -D__LIBRETRO__ 54RETROCFLAGS = 55RETROCXXFLAGS = 56RETROLDFLAGS = 57RETROLDXFLAGS = 58 59################# 60# Final variables 61 62DEFINES = $(PLATDEFS) $(RETRODEFS) 63CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 68######## 69# Tuning 70 71ifneq ($(DEBUG),) 72 CFLAGS += -O0 -g 73 CXXFLAGS += -O0 -g 74else 75 CFLAGS += -O3 -DNDEBUG 76 CXXFLAGS += -O3 -DNDEBUG 77endif 78 79ifneq ($(LOG_PERFORMANCE),) 80 CFLAGS += -DLOG_PERFORMANCE 81 CXXFLAGS += -DLOG_PERFORMANCE 82endif 83 84#################################### 85# Variable setup for Makefile.common 86 87CORE_DIR ?= .. 88BUILD_DIR ?= . 89INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-9/arch-mips/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 91include $(BUILD_DIR)/Makefile.common 92 93############### 94# Include rules 95 96include $(BUILD_DIR)/Makefile.rules 97