# Makefile for PCSX ReARMed (libretro)
-DEBUG=0
-WANT_ZLIB=1
+DEBUG ?= 0
+WANT_ZLIB ?= 1
+HAVE_CHD ?= 1
+USE_LIBRETRO_VFS ?= 0
+
+# Dynarec options: lightrec, ari64
+DYNAREC ?= lightrec
ifeq ($(platform),)
platform = unix
LIBDL := -ldl
endif
LIBM := -lm
-MMAP_WIN32=0
+MMAP_WIN32 = 0
EXTRA_LDFLAGS =
# Unix
ifeq ($(platform), unix)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
+ THREAD_RENDERING = 1
ifneq ($(findstring SunOS,$(shell uname -s)),)
CC = gcc
endif
+ifeq ($(ARCH), arm)
+ifneq ($(findstring __thumb__,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h)),)
+ # must disable thumb as recompiler can't handle it
+ CFLAGS += -marm
+endif
+endif
+
+# ODROIDN2
+else ifneq (,$(findstring CortexA73_G12B,$(platform)))
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC
+ SHARED := -shared -Wl,-version-script=link.T
+ ARCH = arm64
+ CFLAGS += -fomit-frame-pointer -ffast-math -DARM
+ CPUFLAGS += -march=armv8-a+crc -mfpu=neon-fp-armv8 -mcpu=cortex-a73 -mtune=cortex-a73.cortex-a53
+
+# ALLWINNER H5
+else ifneq (,$(findstring h5,$(platform)))
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC
+ SHARED := -shared -Wl,-version-script=link.T
+ ARCH = arm64
+ DYNAREC ?= ari64
+ CFLAGS += -fomit-frame-pointer -ffast-math -DARM
+ CPUFLAGS += -march=armv8-a+crc -mfpu=neon-fp-armv8 -mcpu=cortex-a53 -mtune=cortex-a53
else ifeq ($(platform), linux-portable)
TARGET := $(TARGET_NAME)_libretro.so
# OS X
else ifeq ($(platform), osx)
+ DYNAREC := 0
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
- fpic += -mmacosx-version-min=10.1
+ HAVE_NEON = 0
+ MACSOSVER = `sw_vers -productVersion | cut -d. -f 1`
+ OSXVER = `sw_vers -productVersion | cut -d. -f 2`
+ OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
+ ifeq ($(OSX_LT_MAVERICKS),YES)
+ fpic += -mmacosx-version-min=10.1
+ endif
+
+ ifeq ($(CROSS_COMPILE),1)
+ TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
+ CFLAGS += $(TARGET_RULE)
+ CPPFLAGS += $(TARGET_RULE)
+ CXXFLAGS += $(TARGET_RULE)
+ LDFLAGS += $(TARGET_RULE)
+ endif
+
+ CFLAGS += $(ARCHFLAGS)
+ CXXFLAGS += $(ARCHFLAGS)
+ LDFLAGS += $(ARCHFLAGS)
# iOS
-else ifeq ($(platform),$(filter $(platform),ios-arm64))
- ARCH := arm64
- USE_DYNAREC = 0
- HAVE_NEON = 0
- BUILTIN_GPU = peops
- TARGET := $(TARGET_NAME)_libretro_ios.dylib
-
else ifneq (,$(findstring ios,$(platform)))
- ARCH := arm
- USE_DYNAREC ?= 1
- HAVE_NEON = 1
- BUILTIN_GPU = neon
TARGET := $(TARGET_NAME)_libretro_ios.dylib
-ifeq ($(USE_DYNAREC),1)
+ MINVERSION :=
+ifeq ($(DYNAREC),lightrec)
# Override
- TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
+ DYNAREC := 0
endif
fpic := -fPIC
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
- CC = clang -arch armv7 -isysroot $(IOSSDK)
- CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
- CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
- CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
+ CFLAGS += -DIOS -marm
+ifeq ($(platform),ios-arm64)
+ CC = cc -arch arm64 -isysroot $(IOSSDK)
+ CXX = c++ -arch arm64 -isysroot $(IOSSDK)
+ ARCH := arm64
+ HAVE_NEON = 0
+ BUILTIN_GPU = peops
+ DYNAREC = 0
+else
+ CC = cc -arch armv7 -isysroot $(IOSSDK)
+ CXX = c++ -arch armv7 -isysroot $(IOSSDK)
+ ARCH := arm
+ HAVE_NEON = 1
+ BUILTIN_GPU = neon
+ CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
- CFLAGS += -DIOS
-ifeq ($(platform),ios9)
- CC += -miphoneos-version-min=8.0
- CXX += -miphoneos-version-min=8.0
- CC_AS += -miphoneos-version-min=8.0
- CFLAGS += -miphoneos-version-min=8.0
+endif
+ CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
+ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
+ MINVERSION = -miphoneos-version-min=8.0
else
- CC += -miphoneos-version-min=5.0
- CXX += -miphoneos-version-min=5.0
- CC_AS += -miphoneos-version-min=5.0
- CFLAGS += -miphoneos-version-min=5.0
+ MINVERSION = -miphoneos-version-min=5.0
endif
+ CFLAGS += $(MINVERSION)
-# PS3
-else ifeq ($(platform), ps3)
- TARGET := $(TARGET_NAME)_libretro_ps3.a
- CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
- AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
- CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
+else ifeq ($(platform), tvos-arm64)
+ TARGET := $(TARGET_NAME)_libretro_tvos.dylib
+ MINVERSION :=
+ifeq ($(DYNAREC),lightrec)
+ # Override
+ DYNAREC := 0
+endif
+ fpic := -fPIC
-# sncps3
-else ifeq ($(platform), sncps3)
- TARGET := $(TARGET_NAME)_libretro_ps3.a
- CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
- AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
- CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
+ ifeq ($(IOSSDK),)
+ IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
+ endif
+
+ CFLAGS += -DIOS -DTVOS -marm
+ CC = cc -arch arm64 -isysroot $(IOSSDK)
+ CXX = c++ -arch arm64 -isysroot $(IOSSDK)
+ ARCH := arm64
+ HAVE_NEON = 0
+ BUILTIN_GPU = peops
+ DYNAREC = 0
+ CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
+
+# Nintendo Switch (libnx)
+else ifeq ($(platform), libnx)
+ export DEPSDIR := $(CURDIR)/
+ include $(DEVKITPRO)/libnx/switch_rules
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ ARCH := arm64
+ BUILTIN_GPU = unai
+ HAVE_VFS_FD = 0
+ CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition -include $(LIBNX)/include/switch.h
+ CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs -DNO_OS -DNO_DYLIB -DNO_SOCKET -D__arm64__ -D__ARM_NEON__
+ CFLAGS += -D__SWITCH__
+ CFLAGS += -DARM -D__aarch64__=1 -march=armv8-a -mtune=cortex-a57 -mtp=soft -DHAVE_INTTYPES -DLSB_FIRST -ffast-math -mcpu=cortex-a57+crc+fp+simd -ffunction-sections
+ CFLAGS += -ftree-vectorize
+ CFLAGS += -Ifrontend/switch -ftree-vectorize
+ LIBPTHREAD :=
+ STATIC_LINKING=1
+ # Lightning requires rw/rx patches first
+ DYNAREC := 0
+
+# Lakka Switch (arm64)
+else ifeq ($(platform), arm64)
+ TARGET := $(TARGET_NAME)_libretro.so
+ ARCH := arm64
+ BUILTIN_GPU = unai
+ fpic := -fPIC
+ CFLAGS := $(filter-out -O2, $(CFLAGS))
+ CFLAGS += -O3 -ftree-vectorize
# Lightweight PS3 Homebrew SDK
else ifeq ($(platform), psl1ght)
CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
- CFLAGS += -fno-optimize-sibling-calls
+ CFLAGS += -fno-optimize-sibling-calls
CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
HAVE_NEON = 1
BUILTIN_GPU = neon
- USE_DYNAREC = 1
+ DYNAREC = ari64
DRC_CACHE_BASE = 0
ARCH = arm
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
- CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET
+ CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET -DTHREAD_ENABLED -DGPU_UNAI_USE_FLOATMATH -DGPU_UNAI_USE_FLOAT_DIV_MULTINV
CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
CFLAGS += -Wall -mword-relocations
- CFLAGS += -fomit-frame-pointer -ffast-math
- CFLAGS += -Ifrontend/3ds
+ CFLAGS += -fomit-frame-pointer -ffast-math -funroll-loops
+ CFLAGS += -Ifrontend/3ds -I$(CTRULIB)/include
CFLAGS += -Werror=implicit-function-declaration
+ CFLAGS += -DHAVE_UNISTD_H
+
+ OBJS += frontend/3ds/utils.o
# CFLAGS += -DPCSX
-# BUILTIN_GPU = unai
- USE_DYNAREC = 1
+ BUILTIN_GPU = unai
+ THREAD_RENDERING = 1
+ DYNAREC = ari64
DRC_CACHE_BASE = 0
ARCH = arm
HAVE_NEON = 0
-
STATIC_LINKING = 1
# Xbox 360
CC = qcc -Vgcc_ntoarmv7le
CC_AS = $(CC)
HAVE_NEON = 1
- USE_DYNAREC = 1
+ DYNAREC = ari64
DRC_CACHE_BASE = 0
BUILTIN_GPU = neon
ARCH = arm
CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
- ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
+ ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
MAIN_LDLIBS += -lsocket
LIBPTHREAD :=
LIBDL :=
LIBM :=
+#Raspberry Pi 1
+else ifeq ($(platform), rpi1)
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC
+ CFLAGS += -marm -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
+ ASFLAGS += -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
+ HAVE_NEON = 0
+ ARCH = arm
+ BUILTIN_GPU = unai
+ DYNAREC = ari64
+
#Raspberry Pi 2
else ifeq ($(platform), rpi2)
TARGET := $(TARGET_NAME)_libretro.so
HAVE_NEON = 1
ARCH = arm
BUILTIN_GPU = neon
- USE_DYNAREC = 1
+ DYNAREC = ari64
#Raspberry Pi 3
else ifeq ($(platform), rpi3)
HAVE_NEON = 1
ARCH = arm
BUILTIN_GPU = neon
- USE_DYNAREC = 1
+ DYNAREC = ari64
+
+#Raspberry Pi 3 with a 64bit GNU/Linux OS
+else ifeq ($(platform), rpi3_64)
+ TARGET := $(TARGET_NAME)_libretro.so
+ ARCH := arm64
+ BUILTIN_GPU = unai
+ DYNAREC = ari64
+ fpic := -fPIC
+ CFLAGS += -march=armv8-a+crc+simd -mtune=cortex-a53 -ftree-vectorize
+
+#Raspberry Pi 4 with a 32bit GNU/Linux OS
+else ifeq ($(platform), rpi4)
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC
+ CFLAGS += -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
+ ASFLAGS += -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
+ HAVE_NEON = 1
+ ARCH = arm
+ BUILTIN_GPU = neon
+ DYNAREC = ari64
+
+#Raspberry Pi 4 with a 64bit GNU/Linux OS
+else ifeq ($(platform), rpi4_64)
+ TARGET := $(TARGET_NAME)_libretro.so
+ ARCH := arm64
+ BUILTIN_GPU = unai
+ DYNAREC = ari64
+ fpic := -fPIC
+ CFLAGS += -march=armv8-a+crc+simd -mtune=cortex-a72 -ftree-vectorize
# Classic Platforms ####################
# Platform affix = classic_<ISA>_<µARCH>
HAVE_NEON = 1
ARCH = arm
BUILTIN_GPU = neon
- USE_DYNAREC = 1
+ DYNAREC = ari64
ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
- CFLAGS += -march=armv7-a
+ CFLAGS += -march=armv7-a
else
- CFLAGS += -march=armv7ve
- # If gcc is 5.0 or later
- ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
- LDFLAGS += -static-libgcc -static-libstdc++
- endif
+ CFLAGS += -march=armv7ve
+ # If gcc is 5.0 or later
+ ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
+ LDFLAGS += -static-libgcc -static-libstdc++
+ endif
endif
+
+# (armv8 a35, hard point, neon based) ###
+# PlayStation Classic
+else ifeq ($(platform), classic_armv8_a35)
+ TARGET := $(TARGET_NAME)_libretro.so
+ fpic := -fPIC
+ CFLAGS += -Ofast \
+ -fmerge-all-constants -fno-math-errno -march=armv8-a \
+ -marm -mcpu=cortex-a35 -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
+ HAVE_NEON = 1
+ ARCH = arm
+ BUILTIN_GPU = neon
+ DYNAREC = ari64
+ LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
+
#######################################
# ARM
else ifneq (,$(findstring armv,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
+ HAVE_NEON = 0
DRC_CACHE_BASE = 0
+ BUILTIN_GPU = peops
ifneq (,$(findstring cortexa8,$(platform)))
CFLAGS += -marm -mcpu=cortex-a8
ASFLAGS += -mcpu=cortex-a8
ASFLAGS += -mfloat-abi=hard
endif
ARCH = arm
- USE_DYNAREC = 1
+ DYNAREC = ari64
+
+# Emscripten
+else ifeq ($(platform), emscripten)
+ TARGET := $(TARGET_NAME)_libretro_$(platform).bc
+ fpic := -fPIC
+ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
+ CFLAGS += -DNO_DYLIB -DNO_SOCKET
+ STATIC_LINKING = 1
# Windows
else
TARGET := $(TARGET_NAME)_libretro.dll
- BUILTIN_GPU = peops
- PLATFORM = libretro
+ BUILTIN_GPU = peops
+ PLATFORM = libretro
MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
CFLAGS += -D__WIN32__ -DNO_DYLIB
MMAP_WIN32=1
LIBPTHREAD :=
LIBDL :=
LIBM :=
+ USE_LIBRETRO_VFS = 1
endif
CFLAGS += $(fpic)
MAIN_LDFLAGS += -shared
MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
-# try to autodetect stuff for the lazy
-ifndef ARCH
-ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
-endif
-ifndef HAVE_NEON
-HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
-endif
-ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
-MAIN_LDFLAGS += -Wl,--no-undefined
+# enable large file support if available
+ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
+CFLAGS += -D_FILE_OFFSET_BITS=64
endif
# try to autodetect stuff for the lazy
ifndef HAVE_NEON
HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
endif
-ifeq ($(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
+ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
MAIN_LDFLAGS += -Wl,--no-undefined
endif
PLUGINS =
NO_CONFIG_MAK = yes
-libretro_all: all
-ifeq ($(platform),ios)
-ifeq ($(USE_DYNAREC),1)
- make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
- make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
-endif
-endif
+# what does this do
+#libretro_all: all
+#ifeq ($(platform),ios)
+#ifeq ($(DYNAREC),1)
+# make -f Makefile.libretro DYNAREC=0 platform=$(platform) clean
+# make -f Makefile.libretro DYNAREC=0 platform=$(platform)
+#endif
+#endif
include Makefile