1 # Makefile for PCSX ReARMed (libretro)
7 # Dynarec options: lightrec, ari64
12 ifeq ($(shell uname -a),)
14 else ifneq ($(findstring MINGW,$(shell uname -a)),)
16 else ifneq ($(findstring Darwin,$(shell uname -a)),)
18 else ifneq ($(findstring win,$(shell uname -a)),)
29 TARGET_NAME := pcsx_rearmed
30 GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
31 ifneq ($(GIT_VERSION)," unknown")
32 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
34 ifneq ($(WANT_ZLIB),1)
37 LIBPTHREAD := -lpthread
38 ifneq ($(findstring Haiku,$(shell uname -s)),)
39 LIBDL := -lroot -lnetwork
48 ifeq ($(platform), unix)
49 TARGET := $(TARGET_NAME)_libretro.so
52 ifneq ($(findstring SunOS,$(shell uname -s)),)
56 ifneq ($(findstring __thumb__,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h)),)
57 # must disable thumb as recompiler can't handle it
62 else ifeq ($(platform), linux-portable)
63 TARGET := $(TARGET_NAME)_libretro.so
64 fpic := -fPIC -nostdlib
65 EXTRA_LDFLAGS += -fPIC -nostdlib
73 else ifeq ($(platform), osx)
75 TARGET := $(TARGET_NAME)_libretro.dylib
77 fpic += -mmacosx-version-min=10.1
80 else ifeq ($(platform),$(filter $(platform),ios-arm64))
85 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
87 CC = clang -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0
88 CXX = clang++ -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0
91 else ifneq (,$(findstring ios,$(platform)))
96 TARGET := $(TARGET_NAME)_libretro_ios.dylib
97 ifeq ($(DYNAREC),lightrec)
102 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
107 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
110 CC = clang -arch armv7 -isysroot $(IOSSDK)
111 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
112 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
113 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
114 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
116 ifeq ($(platform),ios9)
117 CC += -miphoneos-version-min=8.0
118 CXX += -miphoneos-version-min=8.0
119 CC_AS += -miphoneos-version-min=8.0
120 CFLAGS += -miphoneos-version-min=8.0
122 CC += -miphoneos-version-min=5.0
123 CXX += -miphoneos-version-min=5.0
124 CC_AS += -miphoneos-version-min=5.0
125 CFLAGS += -miphoneos-version-min=5.0
128 # Nintendo Switch (libnx)
129 else ifeq ($(platform), libnx)
130 export DEPSDIR := $(CURDIR)/
131 include $(DEVKITPRO)/libnx/switch_rules
132 TARGET := $(TARGET_NAME)_libretro_$(platform).a
136 CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition -include $(LIBNX)/include/switch.h
137 CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs -DNO_OS -DNO_DYLIB -DNO_SOCKET -D__arm64__ -D__ARM_NEON__
138 CFLAGS += -D__SWITCH__
139 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
140 CFLAGS += -ftree-vectorize
141 CFLAGS += -Ifrontend/switch -ftree-vectorize
145 # Lakka Switch (arm64)
146 else ifeq ($(platform), arm64)
147 TARGET := $(TARGET_NAME)_libretro.so
151 CFLAGS := $(filter-out -O2, $(CFLAGS))
152 CFLAGS += -O3 -ftree-vectorize
154 # Lightweight PS3 Homebrew SDK
155 else ifeq ($(platform), psl1ght)
156 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
157 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
158 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
159 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
162 else ifeq ($(platform), psp1)
163 TARGET := $(TARGET_NAME)_libretro_psp1.a
164 CC = psp-gcc$(EXE_EXT)
165 AR = psp-ar$(EXE_EXT)
169 else ifeq ($(platform), vita)
170 TARGET := $(TARGET_NAME)_libretro_vita.a
171 CC = arm-vita-eabi-gcc$(EXE_EXT)
172 AR = arm-vita-eabi-ar$(EXE_EXT)
174 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
175 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
176 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
177 CFLAGS += -fno-optimize-sibling-calls
178 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
179 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
180 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
182 # CFLAGS += -U__ARM_NEON__
193 else ifeq ($(platform), ctr)
194 TARGET := $(TARGET_NAME)_libretro_ctr.a
195 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
196 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
197 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
198 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET -DTHREAD_ENABLED -DGPU_UNAI_USE_FLOATMATH -DGPU_UNAI_USE_FLOAT_DIV_MULTINV
199 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
200 CFLAGS += -Wall -mword-relocations
201 CFLAGS += -fomit-frame-pointer -ffast-math -funroll-loops
202 CFLAGS += -Ifrontend/3ds -I$(CTRULIB)/include
203 CFLAGS += -Werror=implicit-function-declaration
205 OBJS += frontend/3ds/utils.o
217 else ifeq ($(platform), xenon)
218 TARGET := $(TARGET_NAME)_libretro_xenon360.a
219 CC = xenon-gcc$(EXE_EXT)
220 AR = xenon-ar$(EXE_EXT)
221 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
224 else ifeq ($(platform), ngc)
225 TARGET := $(TARGET_NAME)_libretro_ngc.a
226 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
227 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
228 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
231 else ifeq ($(platform), wii)
232 TARGET := libretro_$(TARGET_NAME)_wii.a
233 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
234 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
235 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
238 else ifeq ($(platform), qnx)
239 TARGET := $(TARGET_NAME)_libretro_qnx.so
241 CC = qcc -Vgcc_ntoarmv7le
248 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
249 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
250 MAIN_LDLIBS += -lsocket
256 else ifeq ($(platform), rpi2)
257 TARGET := $(TARGET_NAME)_libretro.so
259 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
260 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
267 else ifeq ($(platform), rpi3)
268 TARGET := $(TARGET_NAME)_libretro.so
270 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
271 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
277 #Raspberry Pi 4 with a 32bit GNU/Linux OS
278 else ifeq ($(platform), rpi4)
279 TARGET := $(TARGET_NAME)_libretro.so
281 CFLAGS += -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
282 ASFLAGS += -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
288 #Raspberry Pi 4 with a 64bit GNU/Linux OS
289 else ifeq ($(platform), rpi4_64)
290 TARGET := $(TARGET_NAME)_libretro.so
295 CFLAGS += -march=armv8-a+crc+simd -mtune=cortex-a72 -ftree-vectorize
297 # Classic Platforms ####################
298 # Platform affix = classic_<ISA>_<µARCH>
299 # Help at https://modmyclassic.com/comp
301 # (armv7 a7, hard point, neon based) ###
302 # NESC, SNESC, C64 mini
303 else ifeq ($(platform), classic_armv7_a7)
304 TARGET := $(TARGET_NAME)_libretro.so
307 -flto=4 -fwhole-program -fuse-linker-plugin \
308 -fdata-sections -ffunction-sections -Wl,--gc-sections \
309 -fno-stack-protector -fno-ident -fomit-frame-pointer \
310 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
311 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
312 -fmerge-all-constants -fno-math-errno \
313 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
314 CXXFLAGS += $(CFLAGS)
315 CPPFLAGS += $(CFLAGS)
321 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
322 CFLAGS += -march=armv7-a
324 CFLAGS += -march=armv7ve
325 # If gcc is 5.0 or later
326 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
327 LDFLAGS += -static-libgcc -static-libstdc++
331 # (armv8 a35, hard point, neon based) ###
332 # PlayStation Classic
333 else ifeq ($(platform), classic_armv8_a35)
334 TARGET := $(TARGET_NAME)_libretro.so
337 -fmerge-all-constants -fno-math-errno -march=armv8-a \
338 -marm -mcpu=cortex-a35 -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
343 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
345 #######################################
348 else ifneq (,$(findstring armv,$(platform)))
349 TARGET := $(TARGET_NAME)_libretro.so
354 ifneq (,$(findstring cortexa8,$(platform)))
355 CFLAGS += -marm -mcpu=cortex-a8
356 ASFLAGS += -mcpu=cortex-a8
357 else ifneq (,$(findstring cortexa7,$(platform)))
358 CFLAGS += -marm -mcpu=cortex-a7
359 ASFLAGS += -mcpu=cortex-a7
361 else ifneq (,$(findstring cortexa9,$(platform)))
362 CFLAGS += -marm -mcpu=cortex-a9
363 ASFLAGS += -mcpu=cortex-a9
366 ifneq (,$(findstring neon,$(platform)))
368 ASFLAGS += -mfpu=neon
372 ifneq (,$(findstring softfloat,$(platform)))
373 CFLAGS += -mfloat-abi=softfp
374 ASFLAGS += -mfloat-abi=softfp
375 else ifneq (,$(findstring hardfloat,$(platform)))
376 CFLAGS += -mfloat-abi=hard
377 ASFLAGS += -mfloat-abi=hard
383 else ifeq ($(platform), emscripten)
384 TARGET := $(TARGET_NAME)_libretro_$(platform).bc
386 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
387 CFLAGS += -DNO_DYLIB -DNO_SOCKET
392 TARGET := $(TARGET_NAME)_libretro.dll
395 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
396 CFLAGS += -D__WIN32__ -DNO_DYLIB
398 MAIN_LDLIBS += -lws2_32
405 MAIN_LDFLAGS += -shared
406 MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
408 # enable large file support if available
409 ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
410 CFLAGS += -D_FILE_OFFSET_BITS=64
413 # try to autodetect stuff for the lazy
415 ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
418 HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
420 ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
421 MAIN_LDFLAGS += -Wl,--no-undefined
424 TARGET ?= libretro.so
427 SOUND_DRIVERS = libretro
433 #ifeq ($(platform),ios)
435 # make -f Makefile.libretro DYNAREC=0 platform=$(platform) clean
436 # make -f Makefile.libretro DYNAREC=0 platform=$(platform)
442 # no special AS needed for gpu_neon
443 plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
444 $(CC) $(CFLAGS) -c $^ -o $@