checks arm64 properly now
[pcsx_rearmed.git] / Makefile.libretro
CommitLineData
706252fc 1# Makefile for PCSX ReARMed (libretro)
2
2f73c14c 3DEBUG=0
9b400da1 4
1c6ab616 5ifeq ($(platform),)
fb01e82a 6 platform = unix
7 ifeq ($(shell uname -a),)
8 platform = win
9 else ifneq ($(findstring MINGW,$(shell uname -a)),)
10 platform = win
11 else ifneq ($(findstring Darwin,$(shell uname -a)),)
12 platform = osx
13 else ifneq ($(findstring win,$(shell uname -a)),)
14 platform = win
15 endif
1c6ab616 16endif
17
a4874585
C
18CC ?= gcc
19CXX ?= g++
20AS ?= as
8ad07683 21CC_AS ?= $(CC)
b09a1d34 22CFLAGS ?=
1c6ab616 23
468564e2 24TARGET_NAME := pcsx_rearmed
8fc5171a
GR
25GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
26ifneq ($(GIT_VERSION)," unknown")
27 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
28endif
917a47e0 29LIBZ := -lz
30LIBPTHREAD := -lpthread
8356146f 31LIBDL := -ldl
ce0e7ac9 32MMAP_WIN32=0
917a47e0 33EXTRA_LDFLAGS =
ce0e7ac9 34
fb01e82a 35# Unix
1c6ab616 36ifeq ($(platform), unix)
fb01e82a 37 TARGET := $(TARGET_NAME)_libretro.so
38 fpic := -fPIC
fb01e82a 39
917a47e0 40else ifeq ($(platform), linux-portable)
41 TARGET := $(TARGET_NAME)_libretro.so
42 fpic := -fPIC -nostdlib
43 EXTRA_LDFLAGS += -fPIC -nostdlib
917a47e0 44 LIBZ :=
45 LIBPTHREAD :=
46 LIBDL :=
95527e35 47 NO_UNDEF_CHECK = 1
48
fb01e82a 49# OS X
1c6ab616 50else ifeq ($(platform), osx)
fb01e82a 51 TARGET := $(TARGET_NAME)_libretro.dylib
52 fpic := -fPIC
33b82111 53 fpic += -mmacosx-version-min=10.1
fb01e82a 54
55# iOS
8fb0f7c5
G
56else ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
57 ARCH := arm64
58 USE_DYNAREC = 0
59 HAVE_NEON = 0
60 BUILTIN_GPU = peops
61 TARGET := $(TARGET_NAME)_libretro_ios.dylib
62
5c166f37 63else ifneq (,$(findstring ios,$(platform)))
fb01e82a 64 ARCH := arm
cbf0ed57 65 USE_DYNAREC ?= 1
778ad9ce
G
66 HAVE_NEON = 1
67 BUILTIN_GPU = neon
fb01e82a 68 TARGET := $(TARGET_NAME)_libretro_ios.dylib
cbf0ed57
JC
69ifeq ($(USE_DYNAREC),0)
70 # Override
71 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
72endif
fb01e82a 73 fpic := -fPIC
1c6ab616 74
fb01e82a 75 ifeq ($(IOSSDK),)
d45e563f 76 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
fb01e82a 77 endif
ac86f051 78
fb01e82a 79 CC = clang -arch armv7 -isysroot $(IOSSDK)
80 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
81 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
82 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
83 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
fb01e82a 84 CFLAGS += -DIOS
5c166f37 85ifeq ($(platform),ios9)
86 CC += -miphoneos-version-min=8.0
87 CXX += -miphoneos-version-min=8.0
88 CC_AS += -miphoneos-version-min=8.0
89 CFLAGS += -miphoneos-version-min=8.0
90else
91 CC += -miphoneos-version-min=5.0
92 CXX += -miphoneos-version-min=5.0
93 CC_AS += -miphoneos-version-min=5.0
94 CFLAGS += -miphoneos-version-min=5.0
95endif
fb01e82a 96
97# PS3
1c6ab616 98else ifeq ($(platform), ps3)
fb01e82a 99 TARGET := $(TARGET_NAME)_libretro_ps3.a
100 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
101 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
102 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
103
104# sncps3
1c6ab616 105else ifeq ($(platform), sncps3)
fb01e82a 106 TARGET := $(TARGET_NAME)_libretro_ps3.a
107 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
108 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
109 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
110
111# Lightweight PS3 Homebrew SDK
1c6ab616 112else ifeq ($(platform), psl1ght)
fb01e82a 113 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
114 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
115 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
116 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
117
118# PSP
1c6ab616 119else ifeq ($(platform), psp1)
93305561 120 TARGET := $(TARGET_NAME)_libretro_psp1.a
1c6ab616 121 CC = psp-gcc$(EXE_EXT)
122 AR = psp-ar$(EXE_EXT)
123 CFLAGS += -DPSP -G0
fb01e82a 124
c90258c8 125# Vita
126else ifeq ($(platform), vita)
127 TARGET := $(TARGET_NAME)_libretro_vita.a
128 CC = arm-vita-eabi-gcc$(EXE_EXT)
129 AR = arm-vita-eabi-ar$(EXE_EXT)
130 CFLAGS += -DVITA
131 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
778ad9ce 132 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
73081f23 133 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
30373936 134 CFLAGS += -fno-optimize-sibling-calls
c4052f4d 135 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
136 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
c90258c8 137 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
c4052f4d 138
95527e35 139# CFLAGS += -U__ARM_NEON__
c90258c8 140 HAVE_NEON = 1
141 BUILTIN_GPU = neon
142
0702a1f3 143 USE_DYNAREC = 1
1cc8c854 144 DRC_CACHE_BASE = 0
c4052f4d 145
146 ARCH = arm
95527e35 147 STATIC_LINKING = 1
c4052f4d 148
fc99395c 149# CTR(3DS)
150else ifeq ($(platform), ctr)
151 TARGET := $(TARGET_NAME)_libretro_ctr.a
152 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
153 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
154 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
f72db18e 155 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET
156 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
fc99395c 157 CFLAGS += -Wall -mword-relocations
778ad9ce 158 CFLAGS += -fomit-frame-pointer -ffast-math
f72db18e 159 CFLAGS += -Ifrontend/3ds
fc99395c 160 CFLAGS += -Werror=implicit-function-declaration
161
fc99395c 162# CFLAGS += -DPCSX
163# BUILTIN_GPU = unai
164 USE_DYNAREC = 1
9508b4c7 165 DRC_CACHE_BASE = 0
fc99395c 166 ARCH = arm
86cf0ab7 167 HAVE_NEON = 0
fc99395c 168
169 STATIC_LINKING = 1
170
fb01e82a 171# Xbox 360
1c6ab616 172else ifeq ($(platform), xenon)
fb01e82a 173 TARGET := $(TARGET_NAME)_libretro_xenon360.a
174 CC = xenon-gcc$(EXE_EXT)
175 AR = xenon-ar$(EXE_EXT)
176 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
177
178# Nintendo Game Cube
1c6ab616 179else ifeq ($(platform), ngc)
fb01e82a 180 TARGET := $(TARGET_NAME)_libretro_ngc.a
181 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
182 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
183 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
184
185# Nintendo Wii
1c6ab616 186else ifeq ($(platform), wii)
fb01e82a 187 TARGET := libretro_$(TARGET_NAME)_wii.a
188 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
189 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
190 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
191
192# QNX
a4874585 193else ifeq ($(platform), qnx)
fb01e82a 194 TARGET := $(TARGET_NAME)_libretro_qnx.so
ea13a2f2 195 fpic := -fPIC
fb01e82a 196 CC = qcc -Vgcc_ntoarmv7le
197 CC_AS = $(CC)
198 HAVE_NEON = 1
199 USE_DYNAREC = 1
200 DRC_CACHE_BASE = 0
201 BUILTIN_GPU = neon
202 ARCH = arm
1e212a25 203 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
fb01e82a 204 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
95527e35 205 MAIN_LDLIBS += -lsocket
206 LIBPTHREAD :=
207 LIBDL :=
fb01e82a 208
ea13a2f2
LM
209#Raspberry Pi 2
210else ifeq ($(platform), rpi2)
211 TARGET := $(TARGET_NAME)_libretro.so
212 fpic := -fPIC
ea13a2f2 213 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
f125f441 214 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
ea13a2f2
LM
215 HAVE_NEON = 1
216 ARCH = arm
217 BUILTIN_GPU = neon
218 USE_DYNAREC = 1
778ad9ce 219
46ffb580
LM
220#Raspberry Pi 3
221else ifeq ($(platform), rpi3)
222 TARGET := $(TARGET_NAME)_libretro.so
223 fpic := -fPIC
46ffb580
LM
224 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
225 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
226 HAVE_NEON = 1
227 ARCH = arm
228 BUILTIN_GPU = neon
229 USE_DYNAREC = 1
ea13a2f2 230
fb01e82a 231# ARM
1af4c281 232else ifneq (,$(findstring armv,$(platform)))
fb01e82a 233 TARGET := $(TARGET_NAME)_libretro.so
53919f9e 234 fpic := -fPIC
fb01e82a 235 DRC_CACHE_BASE = 0
236 ifneq (,$(findstring cortexa8,$(platform)))
237 CFLAGS += -marm -mcpu=cortex-a8
238 ASFLAGS += -mcpu=cortex-a8
239 else ifneq (,$(findstring cortexa9,$(platform)))
240 CFLAGS += -marm -mcpu=cortex-a9
241 ASFLAGS += -mcpu=cortex-a9
242 endif
243 CFLAGS += -marm
244 ifneq (,$(findstring neon,$(platform)))
245 CFLAGS += -mfpu=neon
246 ASFLAGS += -mfpu=neon
247 HAVE_NEON = 1
248 BUILTIN_GPU = neon
249 endif
250 ifneq (,$(findstring softfloat,$(platform)))
251 CFLAGS += -mfloat-abi=softfp
252 ASFLAGS += -mfloat-abi=softfp
253 else ifneq (,$(findstring hardfloat,$(platform)))
254 CFLAGS += -mfloat-abi=hard
255 ASFLAGS += -mfloat-abi=hard
256 endif
257 ARCH = arm
53919f9e 258 USE_DYNAREC = 1
fb01e82a 259
260# Windows
1c6ab616 261else
fb01e82a 262 TARGET := $(TARGET_NAME)_libretro.dll
c7dde5ef 263 BUILTIN_GPU = peops
264 PLATFORM = libretro
95527e35 265 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
778ad9ce 266 CFLAGS += -D__WIN32__ -DNO_DYLIB
fb01e82a 267 MMAP_WIN32=1
95527e35 268 MAIN_LDLIBS += -lws2_32
269 LIBPTHREAD :=
270 LIBDL :=
1c6ab616 271endif
272
c4052f4d 273CFLAGS += $(fpic)
9aff1963 274MAIN_LDFLAGS += -shared
95527e35 275MAIN_LDLIBS += $(LIBPTHREAD) $(LIBDL) $(LIBZ)
706252fc 276
4e0771f5 277# try to autodetect stuff for the lazy
278ifndef ARCH
279ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
280endif
281ifndef HAVE_NEON
282HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
283endif
95527e35 284ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
4e0771f5 285MAIN_LDFLAGS += -Wl,--no-undefined
286endif
287
e230dbf6 288# try to autodetect stuff for the lazy
289ifndef ARCH
290ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
291endif
292ifndef HAVE_NEON
293HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
294endif
295ifeq ($(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
296MAIN_LDFLAGS += -Wl,--no-undefined
297endif
298
a4874585 299TARGET ?= libretro.so
706252fc 300PLATFORM = libretro
a4874585 301BUILTIN_GPU ?= peops
706252fc 302SOUND_DRIVERS = libretro
9aff1963 303PLUGINS =
304NO_CONFIG_MAK = yes
706252fc 305
cbf0ed57
JC
306libretro_all: all
307ifeq ($(platform),ios)
308ifeq ($(USE_DYNAREC),1)
309 make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
310 make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
311endif
312endif
313
9aff1963 314include Makefile
cd230693 315
af32009f 316# no special AS needed for gpu_neon
317plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
318 $(CC) $(CFLAGS) -c $^ -o $@