X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Makefile.libretro;h=22fa7e80a99e994892d68a1ecff2eb83aa53969c;hb=12367ad02622ba0e6457a7bea7b859bcf85ecb46;hp=a7fa0ebbe277d983a547cf2c5954b52e91dd95b6;hpb=d4ee47f3f4d639d551b187e3eef39490fa859758;p=pcsx_rearmed.git diff --git a/Makefile.libretro b/Makefile.libretro index a7fa0ebb..22fa7e80 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -1,6 +1,8 @@ # Makefile for PCSX ReARMed (libretro) -DEBUG=0 +DEBUG ?= 0 +WANT_ZLIB ?= 1 +HAVE_CHD ?= 1 ifeq ($(platform),) platform = unix @@ -22,16 +24,36 @@ CC_AS ?= $(CC) CFLAGS ?= TARGET_NAME := pcsx_rearmed +GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" +ifneq ($(GIT_VERSION)," unknown") + CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" +endif +ifneq ($(WANT_ZLIB),1) LIBZ := -lz +endif LIBPTHREAD := -lpthread +ifneq ($(findstring Haiku,$(shell uname -s)),) +LIBDL := -lroot -lnetwork +else LIBDL := -ldl -MMAP_WIN32=0 +endif +LIBM := -lm +MMAP_WIN32 = 0 EXTRA_LDFLAGS = # Unix ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC +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 else ifeq ($(platform), linux-portable) TARGET := $(TARGET_NAME)_libretro.so @@ -40,18 +62,37 @@ else ifeq ($(platform), linux-portable) LIBZ := LIBPTHREAD := LIBDL := + LIBM := NO_UNDEF_CHECK = 1 # OS X else ifeq ($(platform), osx) + USE_DYNAREC ?= 1 TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC fpic += -mmacosx-version-min=10.1 +ifeq ($(USE_DYNAREC),0) + # Override + TARGET := $(TARGET_NAME)_interpreter_libretro.dylib +endif # iOS +else ifeq ($(platform),$(filter $(platform),ios-arm64)) + ARCH := arm64 + USE_DYNAREC = 0 + HAVE_NEON = 0 + BUILTIN_GPU = peops + TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib + + CC = clang -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0 + CXX = clang++ -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0 + CFLAGS += -marm -DIOS + 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),0) # Override @@ -68,8 +109,6 @@ endif CC_AS = perl ./tools/gas-preprocessor.pl $(CC) CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon - HAVE_NEON = 1 - BUILTIN_GPU = neon CFLAGS += -DIOS ifeq ($(platform),ios9) CC += -miphoneos-version-min=8.0 @@ -83,6 +122,34 @@ else CFLAGS += -miphoneos-version-min=5.0 endif +# 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 := + USE_DYNAREC = 0 + STATIC_LINKING=1 + +# 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 + USE_DYNAREC = 0 + # PS3 else ifeq ($(platform), ps3) TARGET := $(TARGET_NAME)_libretro_ps3.a @@ -118,9 +185,9 @@ else ifeq ($(platform), vita) AR = arm-vita-eabi-ar$(EXE_EXT) CFLAGS += -DVITA CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm - CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables + 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 @@ -144,16 +211,16 @@ else ifeq ($(platform), ctr) CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft CFLAGS += -Wall -mword-relocations - CFLAGS += -fomit-frame-pointer -ffast-math + CFLAGS += -fomit-frame-pointer -ffast-math CFLAGS += -Ifrontend/3ds CFLAGS += -Werror=implicit-function-declaration # CFLAGS += -DPCSX -# BUILTIN_GPU = unai + BUILTIN_GPU = unai USE_DYNAREC = 1 - DRC_CACHE_BASE = 1 + DRC_CACHE_BASE = 0 ARCH = arm - + HAVE_NEON = 0 STATIC_LINKING = 1 # Xbox 360 @@ -189,10 +256,11 @@ else ifeq ($(platform), qnx) 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 2 else ifeq ($(platform), rpi2) @@ -204,7 +272,7 @@ else ifeq ($(platform), rpi2) ARCH = arm BUILTIN_GPU = neon USE_DYNAREC = 1 - + #Raspberry Pi 3 else ifeq ($(platform), rpi3) TARGET := $(TARGET_NAME)_libretro.so @@ -216,14 +284,81 @@ else ifeq ($(platform), rpi3) BUILTIN_GPU = neon USE_DYNAREC = 1 +#Raspberry Pi 4 +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 + USE_DYNAREC = 1 + +# Classic Platforms #################### +# Platform affix = classic__<µARCH> +# Help at https://modmyclassic.com/comp + +# (armv7 a7, hard point, neon based) ### +# NESC, SNESC, C64 mini +else ifeq ($(platform), classic_armv7_a7) + TARGET := $(TARGET_NAME)_libretro.so + fpic := -fPIC + CFLAGS += -Ofast \ + -flto=4 -fwhole-program -fuse-linker-plugin \ + -fdata-sections -ffunction-sections -Wl,--gc-sections \ + -fno-stack-protector -fno-ident -fomit-frame-pointer \ + -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ + -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ + -fmerge-all-constants -fno-math-errno \ + -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard + CXXFLAGS += $(CFLAGS) + CPPFLAGS += $(CFLAGS) + ASFLAGS += $(CFLAGS) + HAVE_NEON = 1 + ARCH = arm + BUILTIN_GPU = neon + USE_DYNAREC = 1 + ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) + 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 + 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 + USE_DYNAREC = 1 + 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 + else ifneq (,$(findstring cortexa7,$(platform))) + CFLAGS += -marm -mcpu=cortex-a7 + ASFLAGS += -mcpu=cortex-a7 + LIBZ := else ifneq (,$(findstring cortexa9,$(platform))) CFLAGS += -marm -mcpu=cortex-a9 ASFLAGS += -mcpu=cortex-a9 @@ -248,27 +383,24 @@ else ifneq (,$(findstring armv,$(platform))) # Windows else TARGET := $(TARGET_NAME)_libretro.dll + BUILTIN_GPU = peops + PLATFORM = libretro MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s - CFLAGS += -D__WIN32__ + CFLAGS += -D__WIN32__ -DNO_DYLIB MMAP_WIN32=1 MAIN_LDLIBS += -lws2_32 LIBPTHREAD := LIBDL := + LIBM := endif CFLAGS += $(fpic) MAIN_LDFLAGS += -shared -MAIN_LDLIBS += $(LIBPTHREAD) $(LIBDL) $(LIBZ) +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 @@ -278,7 +410,7 @@ 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 ($(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 @@ -289,13 +421,14 @@ SOUND_DRIVERS = libretro 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 ($(USE_DYNAREC),1) +# make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean +# make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) +#endif +#endif include Makefile