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)
100 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
105 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
108 CC = clang -arch armv7 -isysroot $(IOSSDK)
109 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
110 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
111 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
112 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
114 ifeq ($(platform),ios9)
115 CC += -miphoneos-version-min=8.0
116 CXX += -miphoneos-version-min=8.0
117 CC_AS += -miphoneos-version-min=8.0
118 CFLAGS += -miphoneos-version-min=8.0
120 CC += -miphoneos-version-min=5.0
121 CXX += -miphoneos-version-min=5.0
122 CC_AS += -miphoneos-version-min=5.0
123 CFLAGS += -miphoneos-version-min=5.0
126 # Nintendo Switch (libnx)
127 else ifeq ($(platform), libnx)
128 export DEPSDIR := $(CURDIR)/
129 include $(DEVKITPRO)/libnx/switch_rules
130 TARGET := $(TARGET_NAME)_libretro_$(platform).a
134 CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition -include $(LIBNX)/include/switch.h
135 CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs -DNO_OS -DNO_DYLIB -DNO_SOCKET -D__arm64__ -D__ARM_NEON__
136 CFLAGS += -D__SWITCH__
137 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
138 CFLAGS += -ftree-vectorize
139 CFLAGS += -Ifrontend/switch -ftree-vectorize
143 # Lakka Switch (arm64)
144 else ifeq ($(platform), arm64)
145 TARGET := $(TARGET_NAME)_libretro.so
149 CFLAGS := $(filter-out -O2, $(CFLAGS))
150 CFLAGS += -O3 -ftree-vectorize
153 else ifeq ($(platform), ps3)
154 TARGET := $(TARGET_NAME)_libretro_ps3.a
155 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
156 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
157 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
160 else ifeq ($(platform), sncps3)
161 TARGET := $(TARGET_NAME)_libretro_ps3.a
162 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
163 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
164 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
166 # Lightweight PS3 Homebrew SDK
167 else ifeq ($(platform), psl1ght)
168 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
169 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
170 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
171 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
174 else ifeq ($(platform), psp1)
175 TARGET := $(TARGET_NAME)_libretro_psp1.a
176 CC = psp-gcc$(EXE_EXT)
177 AR = psp-ar$(EXE_EXT)
181 else ifeq ($(platform), vita)
182 TARGET := $(TARGET_NAME)_libretro_vita.a
183 CC = arm-vita-eabi-gcc$(EXE_EXT)
184 AR = arm-vita-eabi-ar$(EXE_EXT)
186 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
187 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
188 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
189 CFLAGS += -fno-optimize-sibling-calls
190 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
191 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
192 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
194 # CFLAGS += -U__ARM_NEON__
205 else ifeq ($(platform), ctr)
206 TARGET := $(TARGET_NAME)_libretro_ctr.a
207 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
208 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
209 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
210 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET -DTHREAD_ENABLED -DGPU_UNAI_USE_FLOATMATH -DGPU_UNAI_USE_FLOAT_DIV_MULTINV
211 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
212 CFLAGS += -Wall -mword-relocations
213 CFLAGS += -fomit-frame-pointer -ffast-math -funroll-loops
214 CFLAGS += -Ifrontend/3ds -I$(CTRULIB)/include
215 CFLAGS += -Werror=implicit-function-declaration
217 OBJS += frontend/3ds/utils.o
229 else ifeq ($(platform), xenon)
230 TARGET := $(TARGET_NAME)_libretro_xenon360.a
231 CC = xenon-gcc$(EXE_EXT)
232 AR = xenon-ar$(EXE_EXT)
233 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
236 else ifeq ($(platform), ngc)
237 TARGET := $(TARGET_NAME)_libretro_ngc.a
238 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
239 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
240 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
243 else ifeq ($(platform), wii)
244 TARGET := libretro_$(TARGET_NAME)_wii.a
245 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
246 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
247 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
250 else ifeq ($(platform), qnx)
251 TARGET := $(TARGET_NAME)_libretro_qnx.so
253 CC = qcc -Vgcc_ntoarmv7le
260 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
261 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
262 MAIN_LDLIBS += -lsocket
268 else ifeq ($(platform), rpi2)
269 TARGET := $(TARGET_NAME)_libretro.so
271 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
272 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
279 else ifeq ($(platform), rpi3)
280 TARGET := $(TARGET_NAME)_libretro.so
282 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
283 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
290 else ifeq ($(platform), rpi4)
291 TARGET := $(TARGET_NAME)_libretro.so
293 CFLAGS += -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
294 ASFLAGS += -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
300 # Classic Platforms ####################
301 # Platform affix = classic_<ISA>_<µARCH>
302 # Help at https://modmyclassic.com/comp
304 # (armv7 a7, hard point, neon based) ###
305 # NESC, SNESC, C64 mini
306 else ifeq ($(platform), classic_armv7_a7)
307 TARGET := $(TARGET_NAME)_libretro.so
310 -flto=4 -fwhole-program -fuse-linker-plugin \
311 -fdata-sections -ffunction-sections -Wl,--gc-sections \
312 -fno-stack-protector -fno-ident -fomit-frame-pointer \
313 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
314 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
315 -fmerge-all-constants -fno-math-errno \
316 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
317 CXXFLAGS += $(CFLAGS)
318 CPPFLAGS += $(CFLAGS)
324 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
325 CFLAGS += -march=armv7-a
327 CFLAGS += -march=armv7ve
328 # If gcc is 5.0 or later
329 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
330 LDFLAGS += -static-libgcc -static-libstdc++
334 # (armv8 a35, hard point, neon based) ###
335 # PlayStation Classic
336 else ifeq ($(platform), classic_armv8_a35)
337 TARGET := $(TARGET_NAME)_libretro.so
340 -fmerge-all-constants -fno-math-errno -march=armv8-a \
341 -marm -mcpu=cortex-a35 -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
346 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
348 #######################################
351 else ifneq (,$(findstring armv,$(platform)))
352 TARGET := $(TARGET_NAME)_libretro.so
357 ifneq (,$(findstring cortexa8,$(platform)))
358 CFLAGS += -marm -mcpu=cortex-a8
359 ASFLAGS += -mcpu=cortex-a8
360 else ifneq (,$(findstring cortexa7,$(platform)))
361 CFLAGS += -marm -mcpu=cortex-a7
362 ASFLAGS += -mcpu=cortex-a7
364 else ifneq (,$(findstring cortexa9,$(platform)))
365 CFLAGS += -marm -mcpu=cortex-a9
366 ASFLAGS += -mcpu=cortex-a9
369 ifneq (,$(findstring neon,$(platform)))
371 ASFLAGS += -mfpu=neon
375 ifneq (,$(findstring softfloat,$(platform)))
376 CFLAGS += -mfloat-abi=softfp
377 ASFLAGS += -mfloat-abi=softfp
378 else ifneq (,$(findstring hardfloat,$(platform)))
379 CFLAGS += -mfloat-abi=hard
380 ASFLAGS += -mfloat-abi=hard
386 else ifeq ($(platform), emscripten)
387 TARGET := $(TARGET_NAME)_libretro_$(platform).bc
389 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
390 CFLAGS += -DNO_DYLIB -DNO_SOCKET
395 TARGET := $(TARGET_NAME)_libretro.dll
398 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
399 CFLAGS += -D__WIN32__ -DNO_DYLIB
401 MAIN_LDLIBS += -lws2_32
408 MAIN_LDFLAGS += -shared
409 MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
411 # enable large file support if available
412 ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
413 CFLAGS += -D_FILE_OFFSET_BITS=64
416 # try to autodetect stuff for the lazy
418 ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
421 HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
423 ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
424 MAIN_LDFLAGS += -Wl,--no-undefined
427 TARGET ?= libretro.so
430 SOUND_DRIVERS = libretro
436 #ifeq ($(platform),ios)
438 # make -f Makefile.libretro DYNAREC=0 platform=$(platform) clean
439 # make -f Makefile.libretro DYNAREC=0 platform=$(platform)
445 # no special AS needed for gpu_neon
446 plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
447 $(CC) $(CFLAGS) -c $^ -o $@