Revert "Hide nonfunctional NEON options in aarch64"
[pcsx_rearmed.git] / Makefile.libretro
... / ...
CommitLineData
1# Makefile for PCSX ReARMed (libretro)
2
3DEBUG=0
4WANT_ZLIB=1
5
6ifeq ($(platform),)
7 platform = unix
8 ifeq ($(shell uname -a),)
9 platform = win
10 else ifneq ($(findstring MINGW,$(shell uname -a)),)
11 platform = win
12 else ifneq ($(findstring Darwin,$(shell uname -a)),)
13 platform = osx
14 else ifneq ($(findstring win,$(shell uname -a)),)
15 platform = win
16 endif
17endif
18
19CC ?= gcc
20CXX ?= g++
21AS ?= as
22CC_AS ?= $(CC)
23CFLAGS ?=
24
25TARGET_NAME := pcsx_rearmed
26GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
27ifneq ($(GIT_VERSION)," unknown")
28 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
29endif
30ifneq ($(WANT_ZLIB),1)
31LIBZ := -lz
32endif
33LIBPTHREAD := -lpthread
34ifneq ($(findstring Haiku,$(shell uname -s)),)
35LIBDL := -lroot -lnetwork
36else
37LIBDL := -ldl
38endif
39MMAP_WIN32=0
40EXTRA_LDFLAGS =
41
42# Unix
43ifeq ($(platform), unix)
44 TARGET := $(TARGET_NAME)_libretro.so
45 fpic := -fPIC
46ifneq ($(findstring SunOS,$(shell uname -s)),)
47 CC = gcc
48endif
49
50else ifeq ($(platform), linux-portable)
51 TARGET := $(TARGET_NAME)_libretro.so
52 fpic := -fPIC -nostdlib
53 EXTRA_LDFLAGS += -fPIC -nostdlib
54 LIBZ :=
55 LIBPTHREAD :=
56 LIBDL :=
57 NO_UNDEF_CHECK = 1
58
59# OS X
60else ifeq ($(platform), osx)
61 TARGET := $(TARGET_NAME)_libretro.dylib
62 fpic := -fPIC
63 fpic += -mmacosx-version-min=10.1
64
65# iOS
66else ifeq ($(platform),$(filter $(platform),ios-arm64))
67 ARCH := arm64
68 USE_DYNAREC = 0
69 HAVE_NEON = 0
70 BUILTIN_GPU = peops
71 TARGET := $(TARGET_NAME)_libretro_ios.dylib
72
73else ifneq (,$(findstring ios,$(platform)))
74 ARCH := arm
75 USE_DYNAREC ?= 1
76 HAVE_NEON = 1
77 BUILTIN_GPU = neon
78 TARGET := $(TARGET_NAME)_libretro_ios.dylib
79ifeq ($(USE_DYNAREC),1)
80 # Override
81 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
82endif
83 fpic := -fPIC
84
85 ifeq ($(IOSSDK),)
86 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
87 endif
88
89 CC = clang -arch armv7 -isysroot $(IOSSDK)
90 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
91 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
92 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
93 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
94 CFLAGS += -DIOS
95ifeq ($(platform),ios9)
96 CC += -miphoneos-version-min=8.0
97 CXX += -miphoneos-version-min=8.0
98 CC_AS += -miphoneos-version-min=8.0
99 CFLAGS += -miphoneos-version-min=8.0
100else
101 CC += -miphoneos-version-min=5.0
102 CXX += -miphoneos-version-min=5.0
103 CC_AS += -miphoneos-version-min=5.0
104 CFLAGS += -miphoneos-version-min=5.0
105endif
106
107# PS3
108else ifeq ($(platform), ps3)
109 TARGET := $(TARGET_NAME)_libretro_ps3.a
110 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
111 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
112 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
113
114# sncps3
115else ifeq ($(platform), sncps3)
116 TARGET := $(TARGET_NAME)_libretro_ps3.a
117 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
118 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
119 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
120
121# Lightweight PS3 Homebrew SDK
122else ifeq ($(platform), psl1ght)
123 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
124 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
125 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
126 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
127
128# PSP
129else ifeq ($(platform), psp1)
130 TARGET := $(TARGET_NAME)_libretro_psp1.a
131 CC = psp-gcc$(EXE_EXT)
132 AR = psp-ar$(EXE_EXT)
133 CFLAGS += -DPSP -G0
134
135# Vita
136else ifeq ($(platform), vita)
137 TARGET := $(TARGET_NAME)_libretro_vita.a
138 CC = arm-vita-eabi-gcc$(EXE_EXT)
139 AR = arm-vita-eabi-ar$(EXE_EXT)
140 CFLAGS += -DVITA
141 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
142 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
143 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
144 CFLAGS += -fno-optimize-sibling-calls
145 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
146 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
147 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
148
149# CFLAGS += -U__ARM_NEON__
150 HAVE_NEON = 1
151 BUILTIN_GPU = neon
152
153 USE_DYNAREC = 1
154 DRC_CACHE_BASE = 0
155
156 ARCH = arm
157 STATIC_LINKING = 1
158
159# CTR(3DS)
160else ifeq ($(platform), ctr)
161 TARGET := $(TARGET_NAME)_libretro_ctr.a
162 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
163 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
164 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
165 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET
166 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
167 CFLAGS += -Wall -mword-relocations
168 CFLAGS += -fomit-frame-pointer -ffast-math
169 CFLAGS += -Ifrontend/3ds
170 CFLAGS += -Werror=implicit-function-declaration
171
172# CFLAGS += -DPCSX
173 BUILTIN_GPU = unai
174 USE_DYNAREC = 1
175 DRC_CACHE_BASE = 0
176 ARCH = arm
177 HAVE_NEON = 0
178
179 STATIC_LINKING = 1
180
181# Xbox 360
182else ifeq ($(platform), xenon)
183 TARGET := $(TARGET_NAME)_libretro_xenon360.a
184 CC = xenon-gcc$(EXE_EXT)
185 AR = xenon-ar$(EXE_EXT)
186 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
187
188# Nintendo Game Cube
189else ifeq ($(platform), ngc)
190 TARGET := $(TARGET_NAME)_libretro_ngc.a
191 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
192 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
193 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
194
195# Nintendo Wii
196else ifeq ($(platform), wii)
197 TARGET := libretro_$(TARGET_NAME)_wii.a
198 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
199 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
200 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
201
202# QNX
203else ifeq ($(platform), qnx)
204 TARGET := $(TARGET_NAME)_libretro_qnx.so
205 fpic := -fPIC
206 CC = qcc -Vgcc_ntoarmv7le
207 CC_AS = $(CC)
208 HAVE_NEON = 1
209 USE_DYNAREC = 1
210 DRC_CACHE_BASE = 0
211 BUILTIN_GPU = neon
212 ARCH = arm
213 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
214 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
215 MAIN_LDLIBS += -lsocket
216 LIBPTHREAD :=
217 LIBDL :=
218
219#Raspberry Pi 2
220else ifeq ($(platform), rpi2)
221 TARGET := $(TARGET_NAME)_libretro.so
222 fpic := -fPIC
223 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
224 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
225 HAVE_NEON = 1
226 ARCH = arm
227 BUILTIN_GPU = neon
228 USE_DYNAREC = 1
229
230#Raspberry Pi 3
231else ifeq ($(platform), rpi3)
232 TARGET := $(TARGET_NAME)_libretro.so
233 fpic := -fPIC
234 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
235 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
236 HAVE_NEON = 1
237 ARCH = arm
238 BUILTIN_GPU = neon
239 USE_DYNAREC = 1
240
241# Classic Platforms ####################
242# Platform affix = classic_<ISA>_<µARCH>
243# Help at https://modmyclassic.com/comp
244
245# (armv7 a7, hard point, neon based) ###
246# NESC, SNESC, C64 mini
247else ifeq ($(platform), classic_armv7_a7)
248 TARGET := $(TARGET_NAME)_libretro.so
249 fpic := -fPIC
250 CFLAGS += -Ofast \
251 -flto=4 -fwhole-program -fuse-linker-plugin \
252 -fdata-sections -ffunction-sections -Wl,--gc-sections \
253 -fno-stack-protector -fno-ident -fomit-frame-pointer \
254 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
255 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
256 -fmerge-all-constants -fno-math-errno \
257 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
258 CXXFLAGS += $(CFLAGS)
259 CPPFLAGS += $(CFLAGS)
260 ASFLAGS += $(CFLAGS)
261 HAVE_NEON = 1
262 ARCH = arm
263 BUILTIN_GPU = neon
264 USE_DYNAREC = 1
265 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
266 CFLAGS += -march=armv7-a
267 else
268 CFLAGS += -march=armv7ve
269 # If gcc is 5.0 or later
270 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
271 LDFLAGS += -static-libgcc -static-libstdc++
272 endif
273 endif
274#######################################
275
276# ARM
277else ifneq (,$(findstring armv,$(platform)))
278 TARGET := $(TARGET_NAME)_libretro.so
279 fpic := -fPIC
280 DRC_CACHE_BASE = 0
281 ifneq (,$(findstring cortexa8,$(platform)))
282 CFLAGS += -marm -mcpu=cortex-a8
283 ASFLAGS += -mcpu=cortex-a8
284 else ifneq (,$(findstring cortexa7,$(platform)))
285 CFLAGS += -marm -mcpu=cortex-a7
286 ASFLAGS += -mcpu=cortex-a7
287 LIBZ :=
288 else ifneq (,$(findstring cortexa9,$(platform)))
289 CFLAGS += -marm -mcpu=cortex-a9
290 ASFLAGS += -mcpu=cortex-a9
291 endif
292 CFLAGS += -marm
293 ifneq (,$(findstring neon,$(platform)))
294 CFLAGS += -mfpu=neon
295 ASFLAGS += -mfpu=neon
296 HAVE_NEON = 1
297 BUILTIN_GPU = neon
298 endif
299 ifneq (,$(findstring softfloat,$(platform)))
300 CFLAGS += -mfloat-abi=softfp
301 ASFLAGS += -mfloat-abi=softfp
302 else ifneq (,$(findstring hardfloat,$(platform)))
303 CFLAGS += -mfloat-abi=hard
304 ASFLAGS += -mfloat-abi=hard
305 endif
306 ARCH = arm
307 USE_DYNAREC = 1
308
309# Windows
310else
311 TARGET := $(TARGET_NAME)_libretro.dll
312 BUILTIN_GPU = peops
313 PLATFORM = libretro
314 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
315 CFLAGS += -D__WIN32__ -DNO_DYLIB
316 MMAP_WIN32=1
317 MAIN_LDLIBS += -lws2_32
318 LIBPTHREAD :=
319 LIBDL :=
320endif
321
322CFLAGS += $(fpic)
323MAIN_LDFLAGS += -shared
324MAIN_LDLIBS += $(LIBPTHREAD) $(LIBDL) $(LIBZ)
325
326# try to autodetect stuff for the lazy
327ifndef ARCH
328ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
329endif
330ifndef HAVE_NEON
331HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
332endif
333ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
334MAIN_LDFLAGS += -Wl,--no-undefined
335endif
336
337# try to autodetect stuff for the lazy
338ifndef ARCH
339ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
340endif
341ifndef HAVE_NEON
342HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
343endif
344ifeq ($(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
345MAIN_LDFLAGS += -Wl,--no-undefined
346endif
347
348TARGET ?= libretro.so
349PLATFORM = libretro
350BUILTIN_GPU ?= peops
351SOUND_DRIVERS = libretro
352PLUGINS =
353NO_CONFIG_MAK = yes
354
355libretro_all: all
356ifeq ($(platform),ios)
357ifeq ($(USE_DYNAREC),1)
358 make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
359 make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
360endif
361endif
362
363include Makefile
364
365# no special AS needed for gpu_neon
366plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
367 $(CC) $(CFLAGS) -c $^ -o $@