Merge pull request #472 from negativeExponent/input_descriptors
[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
6f1edc3c
PC
7# Dynarec options: lightrec, ari64
8DYNAREC ?= lightrec
9
1c6ab616 10ifeq ($(platform),)
fb01e82a 11 platform = unix
12 ifeq ($(shell uname -a),)
13 platform = win
14 else ifneq ($(findstring MINGW,$(shell uname -a)),)
15 platform = win
16 else ifneq ($(findstring Darwin,$(shell uname -a)),)
17 platform = osx
18 else ifneq ($(findstring win,$(shell uname -a)),)
19 platform = win
20 endif
1c6ab616 21endif
22
a4874585
C
23CC ?= gcc
24CXX ?= g++
25AS ?= as
8ad07683 26CC_AS ?= $(CC)
b09a1d34 27CFLAGS ?=
1c6ab616 28
468564e2 29TARGET_NAME := pcsx_rearmed
8fc5171a
GR
30GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
31ifneq ($(GIT_VERSION)," unknown")
32 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
33endif
7795edd6 34ifneq ($(WANT_ZLIB),1)
917a47e0 35LIBZ := -lz
7795edd6 36endif
917a47e0 37LIBPTHREAD := -lpthread
2085a865 38ifneq ($(findstring Haiku,$(shell uname -s)),)
39LIBDL := -lroot -lnetwork
40else
8356146f 41LIBDL := -ldl
2085a865 42endif
958c9818 43LIBM := -lm
a9422018 44MMAP_WIN32 = 0
917a47e0 45EXTRA_LDFLAGS =
ce0e7ac9 46
fb01e82a 47# Unix
1c6ab616 48ifeq ($(platform), unix)
fb01e82a 49 TARGET := $(TARGET_NAME)_libretro.so
50 fpic := -fPIC
a903b131 51 THREAD_RENDERING = 1
2085a865 52ifneq ($(findstring SunOS,$(shell uname -s)),)
cf1d58b3 53 CC = gcc
54endif
4abd2871
HH
55ifeq ($(ARCH), arm)
56ifneq ($(findstring __thumb__,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h)),)
57 # must disable thumb as recompiler can't handle it
58 CFLAGS += -marm
59endif
60endif
fb01e82a 61
917a47e0 62else ifeq ($(platform), linux-portable)
63 TARGET := $(TARGET_NAME)_libretro.so
64 fpic := -fPIC -nostdlib
65 EXTRA_LDFLAGS += -fPIC -nostdlib
917a47e0 66 LIBZ :=
67 LIBPTHREAD :=
68 LIBDL :=
958c9818 69 LIBM :=
95527e35 70 NO_UNDEF_CHECK = 1
71
fb01e82a 72# OS X
1c6ab616 73else ifeq ($(platform), osx)
9382523c 74 DYNAREC ?= lightrec
fb01e82a 75 TARGET := $(TARGET_NAME)_libretro.dylib
76 fpic := -fPIC
33b82111 77 fpic += -mmacosx-version-min=10.1
fb01e82a 78
79# iOS
aab1b446 80else ifeq ($(platform),$(filter $(platform),ios-arm64))
a9422018 81 ARCH := arm64
a9422018
HH
82 HAVE_NEON = 0
83 BUILTIN_GPU = peops
405f21d0 84 DYNAREC = 0
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
e8772367 93# DYNAREC ?= ari64
c8c2bdfe 94 HAVE_NEON = 1
95 BUILTIN_GPU = neon
fb01e82a 96 TARGET := $(TARGET_NAME)_libretro_ios.dylib
3d96277d 97ifeq ($(DYNAREC),lightrec)
cbf0ed57 98 # Override
405f21d0 99 DYNAREC = 0
cbf0ed57
JC
100 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
101endif
fb01e82a 102 fpic := -fPIC
1c6ab616 103
fb01e82a 104 ifeq ($(IOSSDK),)
d45e563f 105 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
fb01e82a 106 endif
ac86f051 107
fb01e82a 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
fb01e82a 113 CFLAGS += -DIOS
5c166f37 114ifeq ($(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
119else
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
124endif
fb01e82a 125
12367ad0 126# Nintendo Switch (libnx)
127else ifeq ($(platform), libnx)
128 export DEPSDIR := $(CURDIR)/
129 include $(DEVKITPRO)/libnx/switch_rules
130 TARGET := $(TARGET_NAME)_libretro_$(platform).a
131 ARCH := arm64
132 BUILTIN_GPU = unai
133 HAVE_VFS_FD = 0
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
140 LIBPTHREAD :=
12367ad0 141 STATIC_LINKING=1
142
143# Lakka Switch (arm64)
144else ifeq ($(platform), arm64)
145 TARGET := $(TARGET_NAME)_libretro.so
146 ARCH := arm64
147 BUILTIN_GPU = unai
148 fpic := -fPIC
149 CFLAGS := $(filter-out -O2, $(CFLAGS))
150 CFLAGS += -O3 -ftree-vectorize
12367ad0 151
fb01e82a 152# PS3
1c6ab616 153else ifeq ($(platform), ps3)
fb01e82a 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__
158
159# sncps3
1c6ab616 160else ifeq ($(platform), sncps3)
fb01e82a 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__
165
166# Lightweight PS3 Homebrew SDK
1c6ab616 167else ifeq ($(platform), psl1ght)
fb01e82a 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__
172
173# PSP
1c6ab616 174else ifeq ($(platform), psp1)
93305561 175 TARGET := $(TARGET_NAME)_libretro_psp1.a
1c6ab616 176 CC = psp-gcc$(EXE_EXT)
177 AR = psp-ar$(EXE_EXT)
178 CFLAGS += -DPSP -G0
fb01e82a 179
c90258c8 180# Vita
181else 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)
185 CFLAGS += -DVITA
186 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
778ad9ce 187 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
73081f23 188 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
1a32b0f8 189 CFLAGS += -fno-optimize-sibling-calls
c4052f4d 190 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
191 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
c90258c8 192 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
c4052f4d 193
95527e35 194# CFLAGS += -U__ARM_NEON__
c90258c8 195 HAVE_NEON = 1
196 BUILTIN_GPU = neon
197
3d96277d 198 DYNAREC = ari64
1cc8c854 199 DRC_CACHE_BASE = 0
c4052f4d 200
201 ARCH = arm
95527e35 202 STATIC_LINKING = 1
c4052f4d 203
fc99395c 204# CTR(3DS)
205else 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)
c81b3e15 210 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET -DTHREAD_ENABLED -DGPU_UNAI_USE_FLOATMATH -DGPU_UNAI_USE_FLOAT_DIV_MULTINV
f72db18e 211 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
1a32b0f8 212 CFLAGS += -Wall -mword-relocations
eca6163f 213 CFLAGS += -fomit-frame-pointer -ffast-math -funroll-loops
31f52a9f 214 CFLAGS += -Ifrontend/3ds -I$(CTRULIB)/include
fc99395c 215 CFLAGS += -Werror=implicit-function-declaration
216
b37c639e
JW
217 OBJS += frontend/3ds/utils.o
218
fc99395c 219# CFLAGS += -DPCSX
c1567e8c 220 BUILTIN_GPU = unai
c765eb86 221 THREAD_RENDERING = 1
3d96277d 222 DYNAREC = ari64
9508b4c7 223 DRC_CACHE_BASE = 0
fc99395c 224 ARCH = arm
86cf0ab7 225 HAVE_NEON = 0
fc99395c 226 STATIC_LINKING = 1
227
fb01e82a 228# Xbox 360
1c6ab616 229else ifeq ($(platform), xenon)
fb01e82a 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__
234
235# Nintendo Game Cube
1c6ab616 236else ifeq ($(platform), ngc)
fb01e82a 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__
241
242# Nintendo Wii
1c6ab616 243else ifeq ($(platform), wii)
fb01e82a 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__
248
249# QNX
a4874585 250else ifeq ($(platform), qnx)
fb01e82a 251 TARGET := $(TARGET_NAME)_libretro_qnx.so
ea13a2f2 252 fpic := -fPIC
fb01e82a 253 CC = qcc -Vgcc_ntoarmv7le
254 CC_AS = $(CC)
255 HAVE_NEON = 1
3d96277d 256 DYNAREC = ari64
fb01e82a 257 DRC_CACHE_BASE = 0
258 BUILTIN_GPU = neon
259 ARCH = arm
1e212a25 260 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
a9422018 261 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
95527e35 262 MAIN_LDLIBS += -lsocket
263 LIBPTHREAD :=
264 LIBDL :=
958c9818 265 LIBM :=
fb01e82a 266
ea13a2f2
LM
267#Raspberry Pi 2
268else ifeq ($(platform), rpi2)
269 TARGET := $(TARGET_NAME)_libretro.so
270 fpic := -fPIC
ea13a2f2 271 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
f125f441 272 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
ea13a2f2
LM
273 HAVE_NEON = 1
274 ARCH = arm
275 BUILTIN_GPU = neon
3d96277d 276 DYNAREC = ari64
778ad9ce 277
46ffb580
LM
278#Raspberry Pi 3
279else ifeq ($(platform), rpi3)
280 TARGET := $(TARGET_NAME)_libretro.so
281 fpic := -fPIC
46ffb580
LM
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
284 HAVE_NEON = 1
285 ARCH = arm
286 BUILTIN_GPU = neon
3d96277d 287 DYNAREC = ari64
ea13a2f2 288
40aec7ad
EM
289#Raspberry Pi 4
290else ifeq ($(platform), rpi4)
291 TARGET := $(TARGET_NAME)_libretro.so
292 fpic := -fPIC
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
295 HAVE_NEON = 1
296 ARCH = arm
297 BUILTIN_GPU = neon
3d96277d 298 DYNAREC = ari64
40aec7ad 299
d28150f7
RSH
300# Classic Platforms ####################
301# Platform affix = classic_<ISA>_<µARCH>
166f75f0 302# Help at https://modmyclassic.com/comp
d28150f7
RSH
303
304# (armv7 a7, hard point, neon based) ###
305# NESC, SNESC, C64 mini
306else ifeq ($(platform), classic_armv7_a7)
307 TARGET := $(TARGET_NAME)_libretro.so
308 fpic := -fPIC
309 CFLAGS += -Ofast \
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 \
10a39de1 316 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
166f75f0
RSH
317 CXXFLAGS += $(CFLAGS)
318 CPPFLAGS += $(CFLAGS)
d28150f7
RSH
319 ASFLAGS += $(CFLAGS)
320 HAVE_NEON = 1
321 ARCH = arm
322 BUILTIN_GPU = neon
3d96277d 323 DYNAREC = ari64
10a39de1 324 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
a9422018 325 CFLAGS += -march=armv7-a
10a39de1 326 else
a9422018
HH
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++
331 endif
10a39de1 332 endif
5ffd1f23
WS
333
334# (armv8 a35, hard point, neon based) ###
335# PlayStation Classic
336else ifeq ($(platform), classic_armv8_a35)
337 TARGET := $(TARGET_NAME)_libretro.so
338 fpic := -fPIC
763dadc7
WS
339 CFLAGS += -Ofast \
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
5ffd1f23
WS
342 HAVE_NEON = 1
343 ARCH = arm
344 BUILTIN_GPU = neon
3d96277d 345 DYNAREC = ari64
5ffd1f23
WS
346 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
347
d28150f7
RSH
348#######################################
349
fb01e82a 350# ARM
1af4c281 351else ifneq (,$(findstring armv,$(platform)))
fb01e82a 352 TARGET := $(TARGET_NAME)_libretro.so
53919f9e 353 fpic := -fPIC
2cf8d379 354 HAVE_NEON = 0
fb01e82a 355 DRC_CACHE_BASE = 0
2cf8d379 356 BUILTIN_GPU = peops
fb01e82a 357 ifneq (,$(findstring cortexa8,$(platform)))
358 CFLAGS += -marm -mcpu=cortex-a8
359 ASFLAGS += -mcpu=cortex-a8
77aa1e8a
A
360 else ifneq (,$(findstring cortexa7,$(platform)))
361 CFLAGS += -marm -mcpu=cortex-a7
362 ASFLAGS += -mcpu=cortex-a7
17d0c85f 363 LIBZ :=
fb01e82a 364 else ifneq (,$(findstring cortexa9,$(platform)))
365 CFLAGS += -marm -mcpu=cortex-a9
366 ASFLAGS += -mcpu=cortex-a9
367 endif
368 CFLAGS += -marm
369 ifneq (,$(findstring neon,$(platform)))
370 CFLAGS += -mfpu=neon
371 ASFLAGS += -mfpu=neon
372 HAVE_NEON = 1
373 BUILTIN_GPU = neon
374 endif
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
381 endif
382 ARCH = arm
3d96277d 383 DYNAREC = ari64
fb01e82a 384
db0d70df 385# Emscripten
386else ifeq ($(platform), emscripten)
387 TARGET := $(TARGET_NAME)_libretro_$(platform).bc
388 fpic := -fPIC
389 SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
390 CFLAGS += -DNO_DYLIB -DNO_SOCKET
391 STATIC_LINKING = 1
392
fb01e82a 393# Windows
1c6ab616 394else
fb01e82a 395 TARGET := $(TARGET_NAME)_libretro.dll
a9422018
HH
396 BUILTIN_GPU = peops
397 PLATFORM = libretro
95527e35 398 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
778ad9ce 399 CFLAGS += -D__WIN32__ -DNO_DYLIB
fb01e82a 400 MMAP_WIN32=1
95527e35 401 MAIN_LDLIBS += -lws2_32
402 LIBPTHREAD :=
403 LIBDL :=
958c9818 404 LIBM :=
1c6ab616 405endif
406
c4052f4d 407CFLAGS += $(fpic)
9aff1963 408MAIN_LDFLAGS += -shared
958c9818 409MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
706252fc 410
99a5a336
HH
411# enable large file support if available
412ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
413CFLAGS += -D_FILE_OFFSET_BITS=64
414endif
415
4e0771f5 416# try to autodetect stuff for the lazy
417ifndef ARCH
418ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
419endif
420ifndef HAVE_NEON
421HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
422endif
95527e35 423ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
4e0771f5 424MAIN_LDFLAGS += -Wl,--no-undefined
425endif
426
a4874585 427TARGET ?= libretro.so
706252fc 428PLATFORM = libretro
a4874585 429BUILTIN_GPU ?= peops
706252fc 430SOUND_DRIVERS = libretro
9aff1963 431PLUGINS =
432NO_CONFIG_MAK = yes
706252fc 433
3bc0af70 434# what does this do
435#libretro_all: all
436#ifeq ($(platform),ios)
3d96277d 437#ifeq ($(DYNAREC),1)
438# make -f Makefile.libretro DYNAREC=0 platform=$(platform) clean
439# make -f Makefile.libretro DYNAREC=0 platform=$(platform)
3bc0af70 440#endif
441#endif
cbf0ed57 442
9aff1963 443include Makefile
cd230693 444
af32009f 445# no special AS needed for gpu_neon
446plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
447 $(CC) $(CFLAGS) -c $^ -o $@