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