1 # ---------------------------------------------------------------------------
3 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
4 # ---------------------------------------------------------------------------
5 # SquirrelJME is under the Mozilla Public License Version 2.0.
6 # See license.mkd for licensing and copyright information.
7 # ---------------------------------------------------------------------------
8 # DESCRIPTION: Makefile specifically for SquirrelJME RatufaCoat on RetroArch.
10 ###### CORE DEFINED OPTIONS ######
13 ##################################
16 GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
18 STATIC_LINKING_LINK = 0
21 ifeq ($(platform),linux-portable_x86)
22 include $(BUILD_DIR)/Makefile.linux-portable_x86
23 else ifeq ($(platform),linux-portable_x86_64)
24 include $(BUILD_DIR)/Makefile.linux-portable_x86_64
25 else ifeq ($(platform),linux_x86)
26 include $(BUILD_DIR)/Makefile.linux_x86
27 else ifeq ($(platform),linux_x86_64)
28 include $(BUILD_DIR)/Makefile.linux_x86_64
29 else ifeq ($(platform),osx_x86)
30 include $(BUILD_DIR)/Makefile.osx_x86
31 else ifeq ($(platform),osx_x86_64)
32 include $(BUILD_DIR)/Makefile.osx_x86_64
33 else ifeq ($(platform),mingw_x86)
34 include $(BUILD_DIR)/Makefile.mingw_x86
35 else ifeq ($(platform),mingw_x86_64)
36 include $(BUILD_DIR)/Makefile.mingw_x86_64
37 else ifeq ($(platform),ps3_ppc)
38 include $(BUILD_DIR)/Makefile.ps3_ppc
39 else ifeq ($(platform),vita_arm)
40 include $(BUILD_DIR)/Makefile.vita_arm
41 else ifeq ($(platform),wii_ppc)
42 include $(BUILD_DIR)/Makefile.wii_ppc
43 else ifeq ($(platform),windows_x86)
44 include $(BUILD_DIR)/Makefile.windows_x86
45 else ifeq ($(platform),windows_msvc2003_x86)
46 include $(BUILD_DIR)/Makefile.windows_msvc2003_x86
47 else ifeq ($(platform),windows_msvc2005_x86)
48 include $(BUILD_DIR)/Makefile.windows_msvc2005_x86
49 else ifeq ($(platform),windows_msvc2008_x86)
50 include $(BUILD_DIR)/Makefile.windows_msvc2008_x86
51 else ifeq ($(platform),windows_msvc2010_x86)
52 include $(BUILD_DIR)/Makefile.windows_msvc2010_x86
53 else ifeq ($(platform),windows_msvc2010_x64)
54 include $(BUILD_DIR)/Makefile.windows_msvc2010_x64
55 else ifeq ($(platform),windows_msvc2015_x64)
56 include $(BUILD_DIR)/Makefile.windows_msvc2015_x64
57 else ifeq ($(platform),windows_x86_64)
58 include $(BUILD_DIR)/Makefile.windows_x86_64
62 ifeq ($(shell uname -a),)
64 else ifneq ($(findstring MINGW,$(shell uname -a)),)
66 else ifneq ($(findstring Darwin,$(shell uname -a)),)
68 else ifneq ($(findstring win,$(shell uname -a)),)
76 SPACE := $(SPACE) $(SPACE)
78 BACKSLASH := \$(BACKSLASH)
79 filter_out1 = $(filter-out $(firstword $1),$1)
80 filter_out2 = $(call filter_out1,$(call filter_out1,$1))
81 unixpath = $(subst \,/,$1)
82 unixcygpath = /$(subst :,,$(call unixpath,$1))
85 system_platform = unix
86 ifeq ($(shell uname -a),)
89 else ifneq ($(findstring Darwin,$(shell uname -a)),)
92 # Architecture is not defined?
95 ifeq ($(shell uname -p),powerpc)
99 ifeq ($(shell uname -p),arm)
102 # Assume x86 otherwise
108 else ifneq ($(findstring MINGW,$(shell uname -a)),)
109 system_platform = win
113 TARGET_NAME := squirreljme
116 ifeq ($(STATIC_LINKING),1)
119 ifeq ($(platform), unix)
122 STATIC_LINKING_LINK = 1
127 ifeq ($(platform), unix)
129 TARGET := $(TARGET_NAME)_libretro$(PLAT).$(EXT)
131 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
132 ifneq ($(findstring Haiku,$(shell uname -a)),)
136 # Linux (portable library)
137 else ifeq ($(platform), linux-portable)
139 TARGET := $(TARGET_NAME)_libretro.$(EXT)
140 fpic := -fPIC -nostdlib
141 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
145 else ifeq ($(platform), osx)
147 TARGET := $(TARGET_NAME)_libretro.$(EXT)
151 CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
155 CFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
156 CPPFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
157 CXXFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
158 LDFLAGS += -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
161 OSXVER = $(shell sw_vers -productVersion | cut -d. -f 2)
162 OSX_GT_MOJAVE = $(shell (( $(OSXVER) >= 14)) && echo "YES")
163 ifneq ($(OSX_GT_MOJAVE),YES)
164 #this breaks compiling on Mac OS Mojave
165 fpic += -mmacosx-version-min=10.1
167 SHARED := -dynamiclib
170 else ifneq (,$(findstring ios,$(platform)))
172 TARGET := $(TARGET_NAME)_libretro_ios.$(EXT)
174 SHARED := -dynamiclib
177 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
180 ifeq ($(platform), ios-arm64)
181 CC = cc -arch arm64 -isysroot $(IOSSDK)
183 CC = cc -arch armv7 -isysroot $(IOSSDK)
186 LD = armv7-apple-darwin11-ld
188 ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
189 CC += -miphoneos-version-min=8.0
190 CFLAGS += -miphoneos-version-min=8.0
192 CC += -miphoneos-version-min=5.0
193 CFLAGS += -miphoneos-version-min=5.0
197 else ifeq ($(platform), tvos-arm64)
199 TARGET := $(TARGET_NAME)_libretro_tvos.$(EXT)
201 SHARED := -dynamiclib
203 IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
208 else ifeq ($(platform), theos_ios)
209 DEPLOYMENT_IOSVERSION = 5.0
210 TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION)
212 TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION)
213 THEOS_BUILD_DIR := objs
214 include $(THEOS)/makefiles/common.mk
215 LIBRARY_NAME = $(TARGET_NAME)_libretro_ios
218 else ifeq ($(platform), qnx)
220 TARGET := $(TARGET_NAME)_libretro_qnx.$(EXT)
222 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
223 CC = qcc -Vgcc_ntoarmv7le
224 AR = qcc -Vgcc_ntoarmv7le
225 CFLAGS += -D__BLACKBERRY_QNX__
228 else ifeq ($(platform), ps3)
230 TARGET := $(TARGET_NAME)_libretro_ps3.$(EXT)
231 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
232 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
233 CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
235 STATIC_LINKING_LINK = 1
238 else ifeq ($(platform), sncps3)
240 TARGET := $(TARGET_NAME)_libretro_ps3.$(EXT)
241 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
242 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
243 CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
245 STATIC_LINKING_LINK = 1
247 # Lightweight PS3 Homebrew SDK
248 else ifeq ($(platform), psl1ght)
250 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
251 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
252 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
253 CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
255 STATIC_LINKING_LINK = 1
258 else ifeq ($(platform), psp1)
260 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
261 CC = psp-gcc$(EXE_EXT)
262 AR = psp-ar$(EXE_EXT)
265 STATIC_LINKING_LINK = 1
268 else ifeq ($(platform), dos)
270 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
271 CC = i686-pc-msdosdjgpp-gcc
272 AR = i686-pc-msdosdjgpp-ar
273 CFLAGS += -march=i386
275 STATIC_LINKING_LINK = 1
278 else ifeq ($(platform), vita)
280 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
281 CC = arm-vita-eabi-gcc$(EXE_EXT)
282 AR = arm-vita-eabi-ar$(EXE_EXT)
285 STATIC_LINKING_LINK = 1
288 else ifeq ($(platform), ctr)
290 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
291 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
292 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
293 CFLAGS += -DARM11 -D_3DS
294 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard
295 CFLAGS += -Wall -mword-relocations
296 CFLAGS += -fomit-frame-pointer -ffast-math
299 STATIC_LINKING_LINK = 1
302 else ifeq ($(platform), rpi2)
303 TARGET := $(TARGET_NAME)_libretro.so
305 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T -Wl,--no-undefined
307 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -funsafe-math-optimizations
308 CFLAGS += -fomit-frame-pointer -ffast-math
312 else ifeq ($(platform), rpi3)
313 TARGET := $(TARGET_NAME)_libretro.so
315 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T -Wl,--no-undefined
317 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -funsafe-math-optimizations
318 CFLAGS += -fomit-frame-pointer -ffast-math
321 # Classic Platforms ####################
322 # Platform affix = classic_<ISA>_<uARCH>
323 # (armv7 a7, hard point, neon based) ###
324 # NESC, SNESC, C64 mini
325 else ifeq ($(platform), classic_armv7_a7)
326 TARGET := $(TARGET_NAME)_libretro.so
328 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T -Wl,--no-undefined
330 -flto=4 -fwhole-program -fuse-linker-plugin \
331 -fdata-sections -ffunction-sections -Wl,--gc-sections \
332 -fno-stack-protector -fno-ident -fomit-frame-pointer \
333 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
334 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
335 -fmerge-all-constants -fno-math-errno \
336 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
337 CXXFLAGS += $(CFLAGS)
338 CPPFLAGS += $(CFLAGS)
342 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
343 CFLAGS += -march=armv7-a
345 CFLAGS += -march=armv7ve
346 # If gcc is 5.0 or later
347 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
348 LDFLAGS += -static-libgcc -static-libstdc++
353 else ifeq ($(platform), xenon)
355 TARGET := $(TARGET_NAME)_libretro_xenon360.$(EXT)
356 CC = xenon-gcc$(EXE_EXT)
357 AR = xenon-ar$(EXE_EXT)
358 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
360 STATIC_LINKING_LINK = 1
363 else ifeq ($(platform), ngc)
365 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
366 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
367 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
368 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
369 CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
371 STATIC_LINKING_LINK = 1
374 else ifeq ($(platform), wii)
376 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
377 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
378 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
379 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
380 CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
382 STATIC_LINKING_LINK = 1
385 else ifeq ($(platform), wiiu)
387 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
388 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
389 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
390 CFLAGS += -DGEKKO -DHW_RVL -mcpu=750 -meabi -mhard-float -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
391 CFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
393 STATIC_LINKING_LINK = 1
396 else ifneq (,$(findstring armv,$(platform)))
398 TARGET := $(TARGET_NAME)_libretro.$(EXT)
399 SHARED := -shared -Wl,--no-undefined
402 ifneq (,$(findstring cortexa8,$(platform)))
403 CFLAGS += -marm -mcpu=cortex-a8
404 ASFLAGS += -mcpu=cortex-a8
405 else ifneq (,$(findstring cortexa9,$(platform)))
406 CFLAGS += -marm -mcpu=cortex-a9
407 ASFLAGS += -mcpu=cortex-a9
410 ifneq (,$(findstring neon,$(platform)))
412 ASFLAGS += -mfpu=neon
415 ifneq (,$(findstring softfloat,$(platform)))
416 CFLAGS += -mfloat-abi=softfp
417 ASFLAGS += -mfloat-abi=softfp
418 else ifneq (,$(findstring hardfloat,$(platform)))
419 CFLAGS += -mfloat-abi=hard
420 ASFLAGS += -mfloat-abi=hard
425 else ifeq ($(platform), emscripten)
426 TARGET := $(TARGET_NAME)_libretro_emscripten.bc
431 else ifeq ($(platform), gcw0)
432 TARGET := $(TARGET_NAME)_libretro.so
433 CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc
434 CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++
435 AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
436 SHARED := -shared -Wl,--version-script=$(BUILD_DIR)/link.T
438 CFLAGS += $(PTHREAD_FLAGS)
439 CFLAGS += -ffast-math -march=mips32 -mtune=mips32r2 -mhard-float
441 else ifeq ($(platform), msvc)
444 # Nintendo Switch (libtransistor)
445 else ifeq ($(platform), switch)
447 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
448 include $(LIBTRANSISTOR_HOME)/libtransistor.mk
450 STATIC_LINKING_LINK = 1
452 # Nintendo Switch (libnx)
453 else ifeq ($(platform), libnx)
454 include $(DEVKITPRO)/libnx/switch_rules
456 TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
457 DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL
458 CFLAGS := $(DEFINES) -g \
460 -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
462 CFLAGS += $(INCLUDE) -D__SWITCH__ -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft
463 CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
466 STATIC_LINKING_LINK = 1
468 # Windows MSVC 2003 Xbox 1
469 else ifeq ($(platform), xbox1_msvc2003)
470 TARGET := $(TARGET_NAME)_libretro_xdk1.lib
475 export INCLUDE := $(XDK)\xbox\include
476 export LIB := $(XDK)\xbox\lib
477 PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH)
480 CFLAGS += -D_XBOX -D_XBOX1
481 CXXFLAGS += -D_XBOX -D_XBOX1
483 STATIC_LINKING_LINK = 1
486 else ifeq ($(platform), ps2)
487 TARGET := $(TARGET_NAME)_libretro_$(platform).a
488 CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
489 CXX = mips64r5900el-ps2-elf-g++$(EXE_EXT)
490 AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
491 CFLAGS += -Wall -DPS2 -DABGR1555 -DRENDER_GSKIT_PS2 -fsingle-precision-constant
492 CFLAGS += -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I$(PS2DEV)/gsKit/include
494 STATIC_LINKING_LINK = 1
499 TARGET := $(TARGET_NAME)_libretro.$(EXT)
501 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=$(BUILD_DIR)/link.T
502 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
505 ifeq ($(STATIC_LINKING), 1)
513 CFLAGS += -O2 -DNDEBUG
514 ifneq ($(GIT_VERSION), " unknown")
515 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
519 include $(BUILD_DIR)/Makefile.common
521 OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o) $(SOURCES_ASM:.S=.o)
523 DEFINES += $(COREDEFINES)
525 ifeq ($(STATIC_LINKING), 1)
526 DEFINES += -DSTATIC_LINKING
529 ifeq ($(platform), sncps3)
532 else ifeq ($(platform), ios)
535 else ifneq (,$(findstring msvc,$(platform)))
539 WARNINGS_DEFINES = -Wall -W -Wno-unused-parameter -Wno-sign-compare -Wno-uninitialized
540 CODE_DEFINES = -fomit-frame-pointer
543 COMMON_DEFINES += $(CODE_DEFINES) $(WARNINGS_DEFINES) $(fpic)
545 CFLAGS += $(DEFINES) $(COMMON_DEFINES)
546 CXXFLAGS += $(DEFINES) $(COMMON_DEFINES)
548 ifneq (,$(findstring msvc,$(platform)))
551 ifeq ($(STATIC_LINKING),1)
563 ifeq ($(platform), theos_ios)
564 COMMON_FLAGS := -DIOS -DARM $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error
565 $(LIBRARY_NAME)_CFLAGS += $(COMMON_FLAGS)
566 ${LIBRARY_NAME}_FILES = $(SOURCES_C) $(SOURCES_CXX) $(SOURCES_ASM)
567 include $(THEOS_MAKE_PATH)/library.mk
571 $(TARGET): $(OBJECTS)
572 @echo "** BUILDING $(TARGET) FOR PLATFORM $(platform) $(arch) **"
573 ifeq ($(platform), emscripten)
574 $(AR) rcs $@ $(OBJECTS)
575 else ifeq ($(STATIC_LINKING_LINK), 1)
576 ifneq (,$(findstring msvc,$(platform)))
577 $(LD) $(LINKOUT)$@ $(OBJECTS)
579 $(AR) rcs $@ $(OBJECTS)
582 $(CC) $(fpic) $(SHARED) $(INCFLAGS) $(LDFLAGS) $(OBJOUT)$@ $(OBJECTS) $(LIBM)
586 $(CC) $(INCFLAGS) $(CFLAGS) -c $(OBJOUT)$@ $<
589 $(CC) $(INCFLAGS) $(CFLAGS) -c $(OBJOUT)$@ $<
595 rm -f $(OBJECTS) $(TARGET)