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