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
51 ifneq ($(findstring SunOS,$(shell uname -s)),)
55 ifneq ($(findstring __thumb__,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h)),)
56 # must disable thumb as recompiler can't handle it
61 else ifeq ($(platform), linux-portable)
62 TARGET := $(TARGET_NAME)_libretro.so
63 fpic := -fPIC -nostdlib
64 EXTRA_LDFLAGS += -fPIC -nostdlib
72 else ifeq ($(platform), osx)
74 TARGET := $(TARGET_NAME)_libretro.dylib
76 fpic += -mmacosx-version-min=10.1
79 else ifeq ($(platform),$(filter $(platform),ios-arm64))
84 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
86 CC = clang -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0
87 CXX = clang++ -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0
90 else ifneq (,$(findstring ios,$(platform)))
95 TARGET := $(TARGET_NAME)_libretro_ios.dylib
96 ifeq ($(DYNAREC),lightrec)
99 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
104 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
107 CC = clang -arch armv7 -isysroot $(IOSSDK)
108 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
109 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
110 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
111 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
113 ifeq ($(platform),ios9)
114 CC += -miphoneos-version-min=8.0
115 CXX += -miphoneos-version-min=8.0
116 CC_AS += -miphoneos-version-min=8.0
117 CFLAGS += -miphoneos-version-min=8.0
119 CC += -miphoneos-version-min=5.0
120 CXX += -miphoneos-version-min=5.0
121 CC_AS += -miphoneos-version-min=5.0
122 CFLAGS += -miphoneos-version-min=5.0
125 # Nintendo Switch (libnx)
126 else ifeq ($(platform), libnx)
127 export DEPSDIR := $(CURDIR)/
128 include $(DEVKITPRO)/libnx/switch_rules
129 TARGET := $(TARGET_NAME)_libretro_$(platform).a
133 CFLAGS += -O3 -fomit-frame-pointer -ffast-math -I$(DEVKITPRO)/libnx/include/ -fPIE -Wl,--allow-multiple-definition -include $(LIBNX)/include/switch.h
134 CFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs -DNO_OS -DNO_DYLIB -DNO_SOCKET -D__arm64__ -D__ARM_NEON__
135 CFLAGS += -D__SWITCH__
136 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
137 CFLAGS += -ftree-vectorize
138 CFLAGS += -Ifrontend/switch -ftree-vectorize
142 # Lakka Switch (arm64)
143 else ifeq ($(platform), arm64)
144 TARGET := $(TARGET_NAME)_libretro.so
148 CFLAGS := $(filter-out -O2, $(CFLAGS))
149 CFLAGS += -O3 -ftree-vectorize
152 else ifeq ($(platform), ps3)
153 TARGET := $(TARGET_NAME)_libretro_ps3.a
154 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
155 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
156 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
159 else ifeq ($(platform), sncps3)
160 TARGET := $(TARGET_NAME)_libretro_ps3.a
161 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
162 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
163 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
165 # Lightweight PS3 Homebrew SDK
166 else ifeq ($(platform), psl1ght)
167 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
168 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
169 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
170 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
173 else ifeq ($(platform), psp1)
174 TARGET := $(TARGET_NAME)_libretro_psp1.a
175 CC = psp-gcc$(EXE_EXT)
176 AR = psp-ar$(EXE_EXT)
180 else ifeq ($(platform), vita)
181 TARGET := $(TARGET_NAME)_libretro_vita.a
182 CC = arm-vita-eabi-gcc$(EXE_EXT)
183 AR = arm-vita-eabi-ar$(EXE_EXT)
185 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
186 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
187 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
188 CFLAGS += -fno-optimize-sibling-calls -fcommon
189 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
190 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
191 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
193 # CFLAGS += -U__ARM_NEON__
204 else ifeq ($(platform), ctr)
205 TARGET := $(TARGET_NAME)_libretro_ctr.a
206 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
207 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
208 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
209 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET -DTHREAD_ENABLED -DGPU_UNAI_USE_FLOATMATH -DGPU_UNAI_USE_FLOAT_DIV_MULTINV
210 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
211 CFLAGS += -Wall -mword-relocations -fcommon
212 CFLAGS += -fomit-frame-pointer -ffast-math -funroll-loops
213 CFLAGS += -Ifrontend/3ds -I$(CTRULIB)/include
214 CFLAGS += -Werror=implicit-function-declaration
216 OBJS += frontend/3ds/utils.o
227 else ifeq ($(platform), xenon)
228 TARGET := $(TARGET_NAME)_libretro_xenon360.a
229 CC = xenon-gcc$(EXE_EXT)
230 AR = xenon-ar$(EXE_EXT)
231 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
234 else ifeq ($(platform), ngc)
235 TARGET := $(TARGET_NAME)_libretro_ngc.a
236 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
237 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
238 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
241 else ifeq ($(platform), wii)
242 TARGET := libretro_$(TARGET_NAME)_wii.a
243 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
244 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
245 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
248 else ifeq ($(platform), qnx)
249 TARGET := $(TARGET_NAME)_libretro_qnx.so
251 CC = qcc -Vgcc_ntoarmv7le
258 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
259 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
260 MAIN_LDLIBS += -lsocket
266 else ifeq ($(platform), rpi2)
267 TARGET := $(TARGET_NAME)_libretro.so
269 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
270 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
277 else ifeq ($(platform), rpi3)
278 TARGET := $(TARGET_NAME)_libretro.so
280 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
281 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
288 else ifeq ($(platform), rpi4)
289 TARGET := $(TARGET_NAME)_libretro.so
291 CFLAGS += -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
292 ASFLAGS += -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
298 # Classic Platforms ####################
299 # Platform affix = classic_<ISA>_<µARCH>
300 # Help at https://modmyclassic.com/comp
302 # (armv7 a7, hard point, neon based) ###
303 # NESC, SNESC, C64 mini
304 else ifeq ($(platform), classic_armv7_a7)
305 TARGET := $(TARGET_NAME)_libretro.so
308 -flto=4 -fwhole-program -fuse-linker-plugin \
309 -fdata-sections -ffunction-sections -Wl,--gc-sections \
310 -fno-stack-protector -fno-ident -fomit-frame-pointer \
311 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
312 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
313 -fmerge-all-constants -fno-math-errno \
314 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
315 CXXFLAGS += $(CFLAGS)
316 CPPFLAGS += $(CFLAGS)
322 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
323 CFLAGS += -march=armv7-a
325 CFLAGS += -march=armv7ve
326 # If gcc is 5.0 or later
327 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
328 LDFLAGS += -static-libgcc -static-libstdc++
332 # (armv8 a35, hard point, neon based) ###
333 # PlayStation Classic
334 else ifeq ($(platform), classic_armv8_a35)
335 TARGET := $(TARGET_NAME)_libretro.so
338 -fmerge-all-constants -fno-math-errno -march=armv8-a \
339 -marm -mcpu=cortex-a35 -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
344 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
346 #######################################
349 else ifneq (,$(findstring armv,$(platform)))
350 TARGET := $(TARGET_NAME)_libretro.so
355 ifneq (,$(findstring cortexa8,$(platform)))
356 CFLAGS += -marm -mcpu=cortex-a8
357 ASFLAGS += -mcpu=cortex-a8
358 else ifneq (,$(findstring cortexa7,$(platform)))
359 CFLAGS += -marm -mcpu=cortex-a7
360 ASFLAGS += -mcpu=cortex-a7
362 else ifneq (,$(findstring cortexa9,$(platform)))
363 CFLAGS += -marm -mcpu=cortex-a9
364 ASFLAGS += -mcpu=cortex-a9
367 ifneq (,$(findstring neon,$(platform)))
369 ASFLAGS += -mfpu=neon
373 ifneq (,$(findstring softfloat,$(platform)))
374 CFLAGS += -mfloat-abi=softfp
375 ASFLAGS += -mfloat-abi=softfp
376 else ifneq (,$(findstring hardfloat,$(platform)))
377 CFLAGS += -mfloat-abi=hard
378 ASFLAGS += -mfloat-abi=hard
384 else ifeq ($(platform), emscripten)
385 TARGET := $(TARGET_NAME)_libretro_$(platform).bc
387 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
388 CFLAGS += -DNO_DYLIB -DNO_SOCKET
393 TARGET := $(TARGET_NAME)_libretro.dll
396 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
397 CFLAGS += -D__WIN32__ -DNO_DYLIB
399 MAIN_LDLIBS += -lws2_32
406 MAIN_LDFLAGS += -shared
407 MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
409 # enable large file support if available
410 ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
411 CFLAGS += -D_FILE_OFFSET_BITS=64
414 # try to autodetect stuff for the lazy
416 ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
419 HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
421 ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
422 MAIN_LDFLAGS += -Wl,--no-undefined
425 TARGET ?= libretro.so
428 SOUND_DRIVERS = libretro
434 #ifeq ($(platform),ios)
436 # make -f Makefile.libretro DYNAREC=0 platform=$(platform) clean
437 # make -f Makefile.libretro DYNAREC=0 platform=$(platform)
443 # no special AS needed for gpu_neon
444 plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
445 $(CC) $(CFLAGS) -c $^ -o $@