fix track information when loading CHDs.
[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
294 CFLAGS += -marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
295 HAVE_NEON = 1
296 ARCH = arm
297 BUILTIN_GPU = neon
298 USE_DYNAREC = 1
299 CFLAGS += -march=armv8-a
300 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
301
d28150f7
RSH
302#######################################
303
fb01e82a 304# ARM
1af4c281 305else ifneq (,$(findstring armv,$(platform)))
fb01e82a 306 TARGET := $(TARGET_NAME)_libretro.so
53919f9e 307 fpic := -fPIC
2cf8d379 308 HAVE_NEON = 0
fb01e82a 309 DRC_CACHE_BASE = 0
2cf8d379 310 BUILTIN_GPU = peops
fb01e82a 311 ifneq (,$(findstring cortexa8,$(platform)))
312 CFLAGS += -marm -mcpu=cortex-a8
313 ASFLAGS += -mcpu=cortex-a8
77aa1e8a
A
314 else ifneq (,$(findstring cortexa7,$(platform)))
315 CFLAGS += -marm -mcpu=cortex-a7
316 ASFLAGS += -mcpu=cortex-a7
17d0c85f 317 LIBZ :=
fb01e82a 318 else ifneq (,$(findstring cortexa9,$(platform)))
319 CFLAGS += -marm -mcpu=cortex-a9
320 ASFLAGS += -mcpu=cortex-a9
321 endif
322 CFLAGS += -marm
323 ifneq (,$(findstring neon,$(platform)))
324 CFLAGS += -mfpu=neon
325 ASFLAGS += -mfpu=neon
326 HAVE_NEON = 1
327 BUILTIN_GPU = neon
328 endif
329 ifneq (,$(findstring softfloat,$(platform)))
330 CFLAGS += -mfloat-abi=softfp
331 ASFLAGS += -mfloat-abi=softfp
332 else ifneq (,$(findstring hardfloat,$(platform)))
333 CFLAGS += -mfloat-abi=hard
334 ASFLAGS += -mfloat-abi=hard
335 endif
336 ARCH = arm
53919f9e 337 USE_DYNAREC = 1
fb01e82a 338
339# Windows
1c6ab616 340else
fb01e82a 341 TARGET := $(TARGET_NAME)_libretro.dll
a9422018
HH
342 BUILTIN_GPU = peops
343 PLATFORM = libretro
95527e35 344 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
778ad9ce 345 CFLAGS += -D__WIN32__ -DNO_DYLIB
fb01e82a 346 MMAP_WIN32=1
95527e35 347 MAIN_LDLIBS += -lws2_32
348 LIBPTHREAD :=
349 LIBDL :=
958c9818 350 LIBM :=
1c6ab616 351endif
352
c4052f4d 353CFLAGS += $(fpic)
9aff1963 354MAIN_LDFLAGS += -shared
958c9818 355MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
706252fc 356
99a5a336
HH
357# enable large file support if available
358ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
359CFLAGS += -D_FILE_OFFSET_BITS=64
360endif
361
4e0771f5 362# try to autodetect stuff for the lazy
363ifndef ARCH
364ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
365endif
366ifndef HAVE_NEON
367HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
368endif
95527e35 369ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
4e0771f5 370MAIN_LDFLAGS += -Wl,--no-undefined
371endif
372
a4874585 373TARGET ?= libretro.so
706252fc 374PLATFORM = libretro
a4874585 375BUILTIN_GPU ?= peops
706252fc 376SOUND_DRIVERS = libretro
9aff1963 377PLUGINS =
378NO_CONFIG_MAK = yes
706252fc 379
3bc0af70 380# what does this do
381#libretro_all: all
382#ifeq ($(platform),ios)
383#ifeq ($(USE_DYNAREC),1)
384# make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
385# make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
386#endif
387#endif
cbf0ed57 388
9aff1963 389include Makefile
cd230693 390
af32009f 391# no special AS needed for gpu_neon
392plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
393 $(CC) $(CFLAGS) -c $^ -o $@