Add "Spu Irq" core option
[pcsx_rearmed.git] / Makefile.libretro
CommitLineData
706252fc 1# Makefile for PCSX ReARMed (libretro)
2
a9422018
HH
3DEBUG ?= 0
4WANT_ZLIB ?= 1
b0ec2e6d 5HAVE_CHD ?= 1
9b400da1 6
1c6ab616 7ifeq ($(platform),)
fb01e82a 8 platform = unix
9 ifeq ($(shell uname -a),)
10 platform = win
11 else ifneq ($(findstring MINGW,$(shell uname -a)),)
12 platform = win
13 else ifneq ($(findstring Darwin,$(shell uname -a)),)
14 platform = osx
15 else ifneq ($(findstring win,$(shell uname -a)),)
16 platform = win
17 endif
1c6ab616 18endif
19
a4874585
C
20CC ?= gcc
21CXX ?= g++
22AS ?= as
8ad07683 23CC_AS ?= $(CC)
b09a1d34 24CFLAGS ?=
1c6ab616 25
468564e2 26TARGET_NAME := pcsx_rearmed
8fc5171a
GR
27GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
28ifneq ($(GIT_VERSION)," unknown")
29 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
30endif
7795edd6 31ifneq ($(WANT_ZLIB),1)
917a47e0 32LIBZ := -lz
7795edd6 33endif
917a47e0 34LIBPTHREAD := -lpthread
2085a865 35ifneq ($(findstring Haiku,$(shell uname -s)),)
36LIBDL := -lroot -lnetwork
37else
8356146f 38LIBDL := -ldl
2085a865 39endif
958c9818 40LIBM := -lm
a9422018 41MMAP_WIN32 = 0
917a47e0 42EXTRA_LDFLAGS =
ce0e7ac9 43
fb01e82a 44# Unix
1c6ab616 45ifeq ($(platform), unix)
fb01e82a 46 TARGET := $(TARGET_NAME)_libretro.so
47 fpic := -fPIC
2085a865 48ifneq ($(findstring SunOS,$(shell uname -s)),)
cf1d58b3 49 CC = gcc
50endif
4abd2871
HH
51ifeq ($(ARCH), arm)
52ifneq ($(findstring __thumb__,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h)),)
53 # must disable thumb as recompiler can't handle it
54 CFLAGS += -marm
55endif
56endif
fb01e82a 57
917a47e0 58else ifeq ($(platform), linux-portable)
59 TARGET := $(TARGET_NAME)_libretro.so
60 fpic := -fPIC -nostdlib
61 EXTRA_LDFLAGS += -fPIC -nostdlib
917a47e0 62 LIBZ :=
63 LIBPTHREAD :=
64 LIBDL :=
958c9818 65 LIBM :=
95527e35 66 NO_UNDEF_CHECK = 1
67
fb01e82a 68# OS X
1c6ab616 69else ifeq ($(platform), osx)
c8c2bdfe 70 USE_DYNAREC ?= 1
fb01e82a 71 TARGET := $(TARGET_NAME)_libretro.dylib
72 fpic := -fPIC
33b82111 73 fpic += -mmacosx-version-min=10.1
c8c2bdfe 74ifeq ($(USE_DYNAREC),0)
75 # Override
76 TARGET := $(TARGET_NAME)_interpreter_libretro.dylib
77endif
fb01e82a 78
79# iOS
aab1b446 80else ifeq ($(platform),$(filter $(platform),ios-arm64))
a9422018
HH
81 ARCH := arm64
82 USE_DYNAREC = 0
83 HAVE_NEON = 0
84 BUILTIN_GPU = peops
d1cce326
YS
85 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
86
87 CC = clang -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0
88 CXX = clang++ -arch arm64 -isysroot $(IOSSDK) -miphoneos-version-min=8.0
89 CFLAGS += -marm -DIOS
8fb0f7c5 90
5c166f37 91else ifneq (,$(findstring ios,$(platform)))
fb01e82a 92 ARCH := arm
cbf0ed57 93 USE_DYNAREC ?= 1
c8c2bdfe 94 HAVE_NEON = 1
95 BUILTIN_GPU = neon
fb01e82a 96 TARGET := $(TARGET_NAME)_libretro_ios.dylib
3bc0af70 97ifeq ($(USE_DYNAREC),0)
cbf0ed57
JC
98 # Override
99 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
100endif
fb01e82a 101 fpic := -fPIC
1c6ab616 102
fb01e82a 103 ifeq ($(IOSSDK),)
d45e563f 104 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
fb01e82a 105 endif
ac86f051 106
fb01e82a 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
fb01e82a 112 CFLAGS += -DIOS
5c166f37 113ifeq ($(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
118else
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
123endif
fb01e82a 124
125# PS3
1c6ab616 126else ifeq ($(platform), ps3)
fb01e82a 127 TARGET := $(TARGET_NAME)_libretro_ps3.a
128 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
129 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
130 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
131
132# sncps3
1c6ab616 133else ifeq ($(platform), sncps3)
fb01e82a 134 TARGET := $(TARGET_NAME)_libretro_ps3.a
135 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
136 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
137 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
138
139# Lightweight PS3 Homebrew SDK
1c6ab616 140else ifeq ($(platform), psl1ght)
fb01e82a 141 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
142 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
143 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
144 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
145
146# PSP
1c6ab616 147else ifeq ($(platform), psp1)
93305561 148 TARGET := $(TARGET_NAME)_libretro_psp1.a
1c6ab616 149 CC = psp-gcc$(EXE_EXT)
150 AR = psp-ar$(EXE_EXT)
151 CFLAGS += -DPSP -G0
fb01e82a 152
c90258c8 153# Vita
154else ifeq ($(platform), vita)
155 TARGET := $(TARGET_NAME)_libretro_vita.a
156 CC = arm-vita-eabi-gcc$(EXE_EXT)
157 AR = arm-vita-eabi-ar$(EXE_EXT)
158 CFLAGS += -DVITA
159 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
778ad9ce 160 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
73081f23 161 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
a9422018 162 CFLAGS += -fno-optimize-sibling-calls
c4052f4d 163 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
164 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
c90258c8 165 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
c4052f4d 166
95527e35 167# CFLAGS += -U__ARM_NEON__
c90258c8 168 HAVE_NEON = 1
169 BUILTIN_GPU = neon
170
0702a1f3 171 USE_DYNAREC = 1
1cc8c854 172 DRC_CACHE_BASE = 0
c4052f4d 173
174 ARCH = arm
95527e35 175 STATIC_LINKING = 1
c4052f4d 176
fc99395c 177# CTR(3DS)
178else ifeq ($(platform), ctr)
179 TARGET := $(TARGET_NAME)_libretro_ctr.a
180 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
181 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
182 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
f72db18e 183 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET
184 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
fc99395c 185 CFLAGS += -Wall -mword-relocations
778ad9ce 186 CFLAGS += -fomit-frame-pointer -ffast-math
f72db18e 187 CFLAGS += -Ifrontend/3ds
fc99395c 188 CFLAGS += -Werror=implicit-function-declaration
189
fc99395c 190# CFLAGS += -DPCSX
c1567e8c 191 BUILTIN_GPU = unai
fc99395c 192 USE_DYNAREC = 1
9508b4c7 193 DRC_CACHE_BASE = 0
fc99395c 194 ARCH = arm
86cf0ab7 195 HAVE_NEON = 0
fc99395c 196 STATIC_LINKING = 1
197
fb01e82a 198# Xbox 360
1c6ab616 199else ifeq ($(platform), xenon)
fb01e82a 200 TARGET := $(TARGET_NAME)_libretro_xenon360.a
201 CC = xenon-gcc$(EXE_EXT)
202 AR = xenon-ar$(EXE_EXT)
203 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
204
205# Nintendo Game Cube
1c6ab616 206else ifeq ($(platform), ngc)
fb01e82a 207 TARGET := $(TARGET_NAME)_libretro_ngc.a
208 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
209 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
210 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
211
212# Nintendo Wii
1c6ab616 213else ifeq ($(platform), wii)
fb01e82a 214 TARGET := libretro_$(TARGET_NAME)_wii.a
215 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
216 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
217 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
218
219# QNX
a4874585 220else ifeq ($(platform), qnx)
fb01e82a 221 TARGET := $(TARGET_NAME)_libretro_qnx.so
ea13a2f2 222 fpic := -fPIC
fb01e82a 223 CC = qcc -Vgcc_ntoarmv7le
224 CC_AS = $(CC)
225 HAVE_NEON = 1
226 USE_DYNAREC = 1
227 DRC_CACHE_BASE = 0
228 BUILTIN_GPU = neon
229 ARCH = arm
1e212a25 230 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
a9422018 231 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
95527e35 232 MAIN_LDLIBS += -lsocket
233 LIBPTHREAD :=
234 LIBDL :=
958c9818 235 LIBM :=
fb01e82a 236
ea13a2f2
LM
237#Raspberry Pi 2
238else ifeq ($(platform), rpi2)
239 TARGET := $(TARGET_NAME)_libretro.so
240 fpic := -fPIC
ea13a2f2 241 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
f125f441 242 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
ea13a2f2
LM
243 HAVE_NEON = 1
244 ARCH = arm
245 BUILTIN_GPU = neon
246 USE_DYNAREC = 1
778ad9ce 247
46ffb580
LM
248#Raspberry Pi 3
249else ifeq ($(platform), rpi3)
250 TARGET := $(TARGET_NAME)_libretro.so
251 fpic := -fPIC
46ffb580
LM
252 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
253 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
254 HAVE_NEON = 1
255 ARCH = arm
256 BUILTIN_GPU = neon
257 USE_DYNAREC = 1
ea13a2f2 258
40aec7ad
EM
259#Raspberry Pi 4
260else ifeq ($(platform), rpi4)
261 TARGET := $(TARGET_NAME)_libretro.so
262 fpic := -fPIC
263 CFLAGS += -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
264 ASFLAGS += -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
265 HAVE_NEON = 1
266 ARCH = arm
267 BUILTIN_GPU = neon
268 USE_DYNAREC = 1
269
d28150f7
RSH
270# Classic Platforms ####################
271# Platform affix = classic_<ISA>_<µARCH>
166f75f0 272# Help at https://modmyclassic.com/comp
d28150f7
RSH
273
274# (armv7 a7, hard point, neon based) ###
275# NESC, SNESC, C64 mini
276else ifeq ($(platform), classic_armv7_a7)
277 TARGET := $(TARGET_NAME)_libretro.so
278 fpic := -fPIC
279 CFLAGS += -Ofast \
280 -flto=4 -fwhole-program -fuse-linker-plugin \
281 -fdata-sections -ffunction-sections -Wl,--gc-sections \
282 -fno-stack-protector -fno-ident -fomit-frame-pointer \
283 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
284 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
285 -fmerge-all-constants -fno-math-errno \
10a39de1 286 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
166f75f0
RSH
287 CXXFLAGS += $(CFLAGS)
288 CPPFLAGS += $(CFLAGS)
d28150f7
RSH
289 ASFLAGS += $(CFLAGS)
290 HAVE_NEON = 1
291 ARCH = arm
292 BUILTIN_GPU = neon
293 USE_DYNAREC = 1
10a39de1 294 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
a9422018 295 CFLAGS += -march=armv7-a
10a39de1 296 else
a9422018
HH
297 CFLAGS += -march=armv7ve
298 # If gcc is 5.0 or later
299 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
300 LDFLAGS += -static-libgcc -static-libstdc++
301 endif
10a39de1 302 endif
5ffd1f23
WS
303
304# (armv8 a35, hard point, neon based) ###
305# PlayStation Classic
306else ifeq ($(platform), classic_armv8_a35)
307 TARGET := $(TARGET_NAME)_libretro.so
308 fpic := -fPIC
763dadc7
WS
309 CFLAGS += -Ofast \
310 -fmerge-all-constants -fno-math-errno -march=armv8-a \
311 -marm -mcpu=cortex-a35 -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
5ffd1f23
WS
312 HAVE_NEON = 1
313 ARCH = arm
314 BUILTIN_GPU = neon
315 USE_DYNAREC = 1
5ffd1f23
WS
316 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
317
d28150f7
RSH
318#######################################
319
fb01e82a 320# ARM
1af4c281 321else ifneq (,$(findstring armv,$(platform)))
fb01e82a 322 TARGET := $(TARGET_NAME)_libretro.so
53919f9e 323 fpic := -fPIC
2cf8d379 324 HAVE_NEON = 0
fb01e82a 325 DRC_CACHE_BASE = 0
2cf8d379 326 BUILTIN_GPU = peops
fb01e82a 327 ifneq (,$(findstring cortexa8,$(platform)))
328 CFLAGS += -marm -mcpu=cortex-a8
329 ASFLAGS += -mcpu=cortex-a8
77aa1e8a
A
330 else ifneq (,$(findstring cortexa7,$(platform)))
331 CFLAGS += -marm -mcpu=cortex-a7
332 ASFLAGS += -mcpu=cortex-a7
17d0c85f 333 LIBZ :=
fb01e82a 334 else ifneq (,$(findstring cortexa9,$(platform)))
335 CFLAGS += -marm -mcpu=cortex-a9
336 ASFLAGS += -mcpu=cortex-a9
337 endif
338 CFLAGS += -marm
339 ifneq (,$(findstring neon,$(platform)))
340 CFLAGS += -mfpu=neon
341 ASFLAGS += -mfpu=neon
342 HAVE_NEON = 1
343 BUILTIN_GPU = neon
344 endif
345 ifneq (,$(findstring softfloat,$(platform)))
346 CFLAGS += -mfloat-abi=softfp
347 ASFLAGS += -mfloat-abi=softfp
348 else ifneq (,$(findstring hardfloat,$(platform)))
349 CFLAGS += -mfloat-abi=hard
350 ASFLAGS += -mfloat-abi=hard
351 endif
352 ARCH = arm
53919f9e 353 USE_DYNAREC = 1
fb01e82a 354
355# Windows
1c6ab616 356else
fb01e82a 357 TARGET := $(TARGET_NAME)_libretro.dll
a9422018
HH
358 BUILTIN_GPU = peops
359 PLATFORM = libretro
95527e35 360 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
778ad9ce 361 CFLAGS += -D__WIN32__ -DNO_DYLIB
fb01e82a 362 MMAP_WIN32=1
95527e35 363 MAIN_LDLIBS += -lws2_32
364 LIBPTHREAD :=
365 LIBDL :=
958c9818 366 LIBM :=
1c6ab616 367endif
368
c4052f4d 369CFLAGS += $(fpic)
9aff1963 370MAIN_LDFLAGS += -shared
958c9818 371MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
706252fc 372
99a5a336
HH
373# enable large file support if available
374ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
375CFLAGS += -D_FILE_OFFSET_BITS=64
376endif
377
4e0771f5 378# try to autodetect stuff for the lazy
379ifndef ARCH
380ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
381endif
382ifndef HAVE_NEON
383HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
384endif
95527e35 385ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
4e0771f5 386MAIN_LDFLAGS += -Wl,--no-undefined
387endif
388
a4874585 389TARGET ?= libretro.so
706252fc 390PLATFORM = libretro
a4874585 391BUILTIN_GPU ?= peops
706252fc 392SOUND_DRIVERS = libretro
9aff1963 393PLUGINS =
394NO_CONFIG_MAK = yes
706252fc 395
3bc0af70 396# what does this do
397#libretro_all: all
398#ifeq ($(platform),ios)
399#ifeq ($(USE_DYNAREC),1)
400# make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
401# make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
402#endif
403#endif
cbf0ed57 404
9aff1963 405include Makefile
cd230693 406
af32009f 407# no special AS needed for gpu_neon
408plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
409 $(CC) $(CFLAGS) -c $^ -o $@