Makefile (11282B)
1STATIC_LINKING := 0 2AR ?= ar 3 4ifeq ($(platform),) 5platform = unix 6ifeq ($(shell uname -a),) 7 platform = win 8else ifneq ($(findstring MINGW,$(shell uname -a)),) 9 platform = win 10else ifneq ($(findstring Darwin,$(shell uname -a)),) 11 platform = osx 12else ifneq ($(findstring win,$(shell uname -a)),) 13 platform = win 14endif 15endif 16 17# system platform 18system_platform = unix 19ifeq ($(shell uname -a),) 20 EXE_EXT = .exe 21 system_platform = win 22else ifneq ($(findstring Darwin,$(shell uname -a)),) 23 system_platform = osx 24 arch = intel 25ifeq ($(shell uname -p),powerpc) 26 arch = ppc 27endif 28 ifeq ($(shell uname -p),arm) 29 arch = arm 30 endif 31else ifneq ($(findstring MINGW,$(shell uname -a)),) 32 system_platform = win 33endif 34 35export DEPSDIR := $(CURDIR)/ 36CORE_DIR += . 37SOURCE_DIR += ../../src 38TARGET_NAME := gearboy 39LIBM = -lm 40 41ifeq ($(UNIVERSAL),1) 42ifeq ($(archs),ppc) 43 ARCHFLAGS = -arch ppc -arch ppc64 44else ifeq ($(archs),arm) 45 ARCHFLAGS = -arch arm64 -arch ppc64 46else 47 ARCHFLAGS = -arch i386 -arch x86_64 48endif 49 50 CXXFLAGS += $(ARCHFLAGS) 51 LFLAGS += $(ARCHFLAGS) 52endif 53 54ifeq ($(STATIC_LINKING), 1) 55EXT := a 56endif 57 58# Unix 59ifneq (,$(findstring unix,$(platform))) 60 TARGET := $(TARGET_NAME)_libretro.so 61 fpic := -fPIC 62 SHARED := -shared -Wl,-version-script=$(CORE_DIR)/link.T 63 ifneq (,$(findstring Haiku,$(shell uname -s))) 64 LDFLAGS += -lnetwork -lroot 65 endif 66 67 prefix := /usr 68 libdir := $(prefix)/lib 69 LIBRETRO_INSTALL_DIR := libretro 70 71 # Raspberry Pi 72 ifneq (,$(findstring rpi,$(platform))) 73 CFLAGS += -fomit-frame-pointer -ffast-math -marm 74 CXXFLAGS += $(CFLAGS) 75 ifneq (,$(findstring rpi1,$(platform))) 76 CFLAGS += -march=armv6j -mfpu=vfp -mfloat-abi=hard 77 else ifneq (,$(findstring rpi2,$(platform))) 78 CFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard 79 else ifneq (,$(findstring rpi3,$(platform))) 80 CFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard 81 endif 82 endif 83 84# (armv7 a7, hard point, neon based) ### 85# NESC, SNESC, C64 mini 86else ifeq ($(platform), classic_armv7_a7) 87 TARGET := $(TARGET_NAME)_libretro.so 88 fpic := -fPIC 89 SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined 90 CFLAGS += -Ofast \ 91 -flto=4 -fwhole-program -fuse-linker-plugin \ 92 -fdata-sections -ffunction-sections -Wl,--gc-sections \ 93 -fno-stack-protector -fno-ident -fomit-frame-pointer \ 94 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ 95 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ 96 -fmerge-all-constants -fno-math-errno \ 97 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard 98 CXXFLAGS += $(CFLAGS) 99 CPPFLAGS += $(CFLAGS) 100 ASFLAGS += $(CFLAGS) 101 HAVE_NEON = 1 102 ARCH = arm 103 BUILTIN_GPU = neon 104 USE_DYNAREC = 1 105 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) 106 CFLAGS += -march=armv7-a 107 else 108 CFLAGS += -march=armv7ve 109 # If gcc is 5.0 or later 110 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1) 111 LDFLAGS += -static-libgcc -static-libstdc++ 112 endif 113 endif 114####################################### 115 116# Nintendo Switch (libtransistor) 117else ifeq ($(platform), switch) 118 TARGET := $(TARGET_NAME)_libretro_$(platform).a 119 include $(LIBTRANSISTOR_HOME)/libtransistor.mk 120 CXXFLAGS += -DMINIZ_NO_TIME -Wall 121 STATIC_LINKING=1 122# Nintendo Switch (libnx) 123else ifeq ($(platform), libnx) 124 include $(DEVKITPRO)/libnx/switch_rules 125 TARGET := $(TARGET_NAME)_libretro_$(platform).a 126 DEFINES := -D__SWITCH__ -DHAVE_LIBNX 127 CFLAGS := $(DEFINES) -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -specs=$(LIBNX)/switch.specs 128 CFLAGS += -march=armv8-a -mtune=cortex-a57 -mtp=soft -mcpu=cortex-a57+crc+fp+simd -ffast-math 129 CXXFLAGS := $(ASFLAGS) $(CFLAGS) -DMINIZ_NO_TIME -Wall 130 STATIC_LINKING=1 131# Nintendo Game Cube / Wii / WiiU 132else ifneq (,$(filter $(platform), ngc wii wiiu)) 133 TARGET := $(TARGET_NAME)_libretro_$(platform).a 134 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) 135 CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) 136 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) 137 CXXFLAGS += -DMINIZ_NO_TIME -DGEKKO -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -I$(DEVKITPRO)/libogc/include 138 CXXFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int 139 STATIC_LINKING = 1 140 ifneq (,$(findstring wiiu,$(platform))) 141 CXXFLAGS += -DWIIU -DHW_RVL 142 else ifneq (,$(findstring wii,$(platform))) 143 CXXFLAGS += -DHW_RVL -mrvl 144 else ifneq (,$(findstring ngc,$(platform))) 145 CXXFLAGS += -DHW_DOL -mrvl 146 endif 147# PS3 148else ifneq (,$(filter $(platform), ps3 psl1ght)) 149 TARGET := $(TARGET_NAME)_libretro_$(platform).a 150 CC = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)gcc$(EXE_EXT) 151 CXX = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)g++$(EXE_EXT) 152 AR = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)ar$(EXE_EXT) 153 CXXFLAGS += -DMINIZ_NO_TIME -DMINIZ_NO_STDIO -Wall -D__ppc__ -DMSB_FIRST 154 STATIC_LINKING = 1 155# OSX 156else ifneq (,$(findstring osx,$(platform))) 157 TARGET := $(TARGET_NAME)_libretro.dylib 158 fpic := -fPIC 159 SHARED := -dynamiclib 160 161 ifeq ($(CROSS_COMPILE),1) 162 TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) 163 CFLAGS += $(TARGET_RULE) 164 CPPFLAGS += $(TARGET_RULE) 165 CXXFLAGS += $(TARGET_RULE) 166 LDFLAGS += $(TARGET_RULE) 167 endif 168 169 CFLAGS += $(ARCHFLAGS) 170 CXXFLAGS += $(ARCHFLAGS) 171 LDFLAGS += $(ARCHFLAGS) 172# iOS 173else ifneq (,$(findstring ios,$(platform))) 174 TARGET := $(TARGET_NAME)_libretro_ios.dylib 175 fpic := -fPIC 176 SHARED := -dynamiclib 177 MINVERSION := 178 ifeq ($(IOSSDK),) 179 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) 180 endif 181 ifeq ($(platform),ios-arm64) 182 CC = cc -arch arm64 -isysroot $(IOSSDK) 183 CXX = c++ -arch arm64 -isysroot $(IOSSDK) 184 else 185 CC = cc -arch armv7 -isysroot $(IOSSDK) 186 CXX = c++ -arch armv7 -isysroot $(IOSSDK) 187 endif 188 ifeq ($(platform),$(filter $(platform),ios9 ios-arm64)) 189 MINVERSION = -miphoneos-version-min=8.0 190 else 191 MINVERSION = -miphoneos-version-min=5.0 192 endif 193 PLATFORM_DEFINES := $(MINVERSION) 194# tvOS 195else ifeq ($(platform), tvos-arm64) 196 TARGET := $(TARGET_NAME)_libretro_tvos.dylib 197 fpic := -fPIC 198 SHARED := -dynamiclib 199 ifeq ($(IOSSDK),) 200 IOSSDK := $(shell xcodebuild -version -sdk appletvos Path) 201 endif 202 203 CC = cc -arch arm64 -isysroot $(IOSSDK) 204 CXX = c++ -arch arm64 -isysroot $(IOSSDK) 205 206# QNX 207else ifneq (,$(findstring qnx,$(platform))) 208 TARGET := $(TARGET_NAME)_libretro_qnx.so 209 fpic := -fPIC 210 SHARED := -shared -Wl,--version-script=$(CORE_DIR)/link.T -Wl,--no-undefined 211# emscripten 212else ifeq ($(platform), emscripten) 213 TARGET := $(TARGET_NAME)_libretro_emscripten.bc 214 fpic := -fPIC 215 SHARED := -shared -Wl,--version-script=$(CORE_DIR)/link.T -Wl 216# RS90 217else ifeq ($(platform), rs90) 218 TARGET := $(TARGET_NAME)_libretro.so 219 CC = /opt/rs90-toolchain/usr/bin/mipsel-linux-gcc 220 CXX = /opt/rs90-toolchain/usr/bin/mipsel-linux-g++ 221 AR = /opt/rs90-toolchain/usr/bin/mipsel-linux-ar 222 fpic := -fPIC 223 SHARED := -shared -Wl,-version-script=$(CORE_DIR)/link.T 224 PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS 225 CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 226 CXXFLAGS += $(CFLAGS) 227# GCW0 228else ifeq ($(platform), gcw0) 229 TARGET := $(TARGET_NAME)_libretro.so 230 CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc 231 CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ 232 AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar 233 fpic := -fPIC 234 SHARED := -shared -Wl,-version-script=$(CORE_DIR)/link.T 235 PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS 236 CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float 237 CXXFLAGS += $(CFLAGS) 238# RETROFW 239else ifeq ($(platform), retrofw) 240 TARGET := $(TARGET_NAME)_libretro.so 241 CC = /opt/retrofw-toolchain/usr/bin/mipsel-linux-gcc 242 CXX = /opt/retrofw-toolchain/usr/bin/mipsel-linux-g++ 243 AR = /opt/retrofw-toolchain/usr/bin/mipsel-linux-ar 244 fpic := -fPIC 245 SHARED := -shared -Wl,-version-script=$(CORE_DIR)/link.T 246 PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS 247 LDFLAGS += -flto -mplt 248 CFLAGS += -fomit-frame-pointer -ffast-math -march=mips32 -mtune=mips32 -mhard-float 249 CFLAGS += -flto -DPERFORMANCE 250 CXXFLAGS += $(CFLAGS) 251# MIYOO 252else ifeq ($(platform), miyoo) 253 TARGET := $(TARGET_NAME)_libretro.so 254 CC = /opt/miyoo/usr/bin/arm-linux-gcc 255 CXX = /opt/miyoo/usr/bin/arm-linux-g++ 256 AR = /opt/miyoo/usr/bin/arm-linux-ar 257 fpic := -fPIC 258 SHARED := -shared -Wl,-version-script=$(CORE_DIR)/link.T 259 PLATFORM_DEFINES := -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS 260 CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s 261 CXXFLAGS += $(CFLAGS) 262# PS2 263else ifeq ($(platform), ps2) 264 TARGET := $(TARGET_NAME)_libretro_$(platform).a 265 CC = mips64r5900el-ps2-elf-gcc 266 CXX = mips64r5900el-ps2-elf-g++ 267 AR = mips64r5900el-ps2-elf-gcc-ar 268 CXXFLAGS += -Wall -DMINIZ_NO_TIME -ffast-math -fsingle-precision-constant -flto -march=r5900 -DPS2 269 STATIC_LINKING = 1 270# PSP 271else ifeq ($(platform), psp1) 272 TARGET := $(TARGET_NAME)_libretro_$(platform).a 273 CC = psp-gcc 274 CXX = psp-g++ 275 AR = psp-ar 276 CXXFLAGS += -Wall -DMINIZ_NO_TIME -ffast-math -fsingle-precision-constant -DPSP 277 STATIC_LINKING = 1 278# Vita 279else ifeq ($(platform), vita) 280 TARGET := $(TARGET_NAME)_libretro_$(platform).a 281 CC = arm-vita-eabi-gcc 282 CXX = arm-vita-eabi-g++ 283 AR = arm-vita-eabi-ar 284 CXXFLAGS += -Wl,-q -Wall -DMINIZ_NO_TIME -mword-relocations -fno-optimize-sibling-calls 285 STATIC_LINKING = 1 286# CTR(3DS) 287else ifeq ($(platform), ctr) 288 TARGET := $(TARGET_NAME)_libretro_$(platform).a 289 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT) 290 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) 291 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) 292 PLATFORM_DEFINES := -DARM11 -D_3DS -DCC_RESAMPLER -DCC_RESAMPLER_NO_HIGHPASS 293 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard 294 CFLAGS += -Wall -mword-relocations 295 CFLAGS += -fomit-frame-pointer -ffast-math 296 CXXFLAGS += $(CFLAGS) 297 STATIC_LINKING = 1 298else 299 CC ?= gcc 300 CXX ?= g++ 301 TARGET := $(TARGET_NAME)_libretro.dll 302 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=$(CORE_DIR)/link.T -Wl,--no-undefined 303endif 304 305LDFLAGS += $(LIBM) 306 307ifeq ($(DEBUG), 1) 308 CXXFLAGS += -O0 -DDEBUG -g 309else 310 CXXFLAGS += -O3 311endif 312 313include Makefile.common 314 315OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o) 316 317INCLUDES += -I$(SOURCE_DIR) 318 319CFLAGS += -DGEARBOY_DISABLE_DISASSEMBLER -Wall -D__LIBRETRO__ $(fpic) 320CXXFLAGS += -DGEARBOY_DISABLE_DISASSEMBLER -Wall -D__LIBRETRO__ $(fpic) 321 322all: $(TARGET) 323 324$(TARGET): $(OBJECTS) 325ifeq ($(STATIC_LINKING), 1) 326 $(AR) rcs $@ $(OBJECTS) 327else 328 $(CXX) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS) 329endif 330 331%.o: %.c 332 $(CXX) $(CXXFLAGS) $(fpic) -c -o $@ $< 333 334clean: 335 rm -f $(OBJECTS) $(TARGET) 336 337install: 338 install -D -m 755 $(TARGET) $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET) 339 install -D -m 755 $(TARGET_NAME).libretro $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET_NAME).libretro 340 341uninstall: 342 rm $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET) 343 rm $(DESTDIR)$(libdir)/$(LIBRETRO_INSTALL_DIR)/$(TARGET_NAME).libretro 344 345.PHONY: clean install uninstall