1 # Makefile for PCSX ReARMed (libretro)
9 ifeq ($(shell uname -a),)
11 else ifneq ($(findstring MINGW,$(shell uname -a)),)
13 else ifneq ($(findstring Darwin,$(shell uname -a)),)
15 else ifneq ($(findstring win,$(shell uname -a)),)
26 TARGET_NAME := pcsx_rearmed
27 GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
28 ifneq ($(GIT_VERSION)," unknown")
29 CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
31 ifneq ($(WANT_ZLIB),1)
34 LIBPTHREAD := -lpthread
35 ifneq ($(findstring Haiku,$(shell uname -s)),)
36 LIBDL := -lroot -lnetwork
45 ifeq ($(platform), unix)
46 TARGET := $(TARGET_NAME)_libretro.so
48 ifneq ($(findstring SunOS,$(shell uname -s)),)
52 ifneq ($(findstring __thumb__,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h)),)
53 # must disable thumb as recompiler can't handle it
58 else ifeq ($(platform), linux-portable)
59 TARGET := $(TARGET_NAME)_libretro.so
60 fpic := -fPIC -nostdlib
61 EXTRA_LDFLAGS += -fPIC -nostdlib
69 else ifeq ($(platform), osx)
71 TARGET := $(TARGET_NAME)_libretro.dylib
73 fpic += -mmacosx-version-min=10.1
74 ifeq ($(USE_DYNAREC),0)
76 TARGET := $(TARGET_NAME)_interpreter_libretro.dylib
80 else ifeq ($(platform),$(filter $(platform),ios-arm64))
85 TARGET := $(TARGET_NAME)_libretro_ios.dylib
87 else ifneq (,$(findstring ios,$(platform)))
92 TARGET := $(TARGET_NAME)_libretro_ios.dylib
93 ifeq ($(USE_DYNAREC),0)
95 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
100 IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
103 CC = clang -arch armv7 -isysroot $(IOSSDK)
104 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
105 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
106 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
107 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
109 ifeq ($(platform),ios9)
110 CC += -miphoneos-version-min=8.0
111 CXX += -miphoneos-version-min=8.0
112 CC_AS += -miphoneos-version-min=8.0
113 CFLAGS += -miphoneos-version-min=8.0
115 CC += -miphoneos-version-min=5.0
116 CXX += -miphoneos-version-min=5.0
117 CC_AS += -miphoneos-version-min=5.0
118 CFLAGS += -miphoneos-version-min=5.0
122 else ifeq ($(platform), ps3)
123 TARGET := $(TARGET_NAME)_libretro_ps3.a
124 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
125 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
126 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
129 else ifeq ($(platform), sncps3)
130 TARGET := $(TARGET_NAME)_libretro_ps3.a
131 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
132 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
133 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
135 # Lightweight PS3 Homebrew SDK
136 else ifeq ($(platform), psl1ght)
137 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
138 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
139 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
140 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
143 else ifeq ($(platform), psp1)
144 TARGET := $(TARGET_NAME)_libretro_psp1.a
145 CC = psp-gcc$(EXE_EXT)
146 AR = psp-ar$(EXE_EXT)
150 else ifeq ($(platform), vita)
151 TARGET := $(TARGET_NAME)_libretro_vita.a
152 CC = arm-vita-eabi-gcc$(EXE_EXT)
153 AR = arm-vita-eabi-ar$(EXE_EXT)
155 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
156 CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
157 CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops
158 CFLAGS += -fno-optimize-sibling-calls
159 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
160 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
161 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
163 # CFLAGS += -U__ARM_NEON__
174 else ifeq ($(platform), ctr)
175 TARGET := $(TARGET_NAME)_libretro_ctr.a
176 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
177 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
178 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
179 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET
180 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
181 CFLAGS += -Wall -mword-relocations
182 CFLAGS += -fomit-frame-pointer -ffast-math
183 CFLAGS += -Ifrontend/3ds
184 CFLAGS += -Werror=implicit-function-declaration
196 else ifeq ($(platform), xenon)
197 TARGET := $(TARGET_NAME)_libretro_xenon360.a
198 CC = xenon-gcc$(EXE_EXT)
199 AR = xenon-ar$(EXE_EXT)
200 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
203 else ifeq ($(platform), ngc)
204 TARGET := $(TARGET_NAME)_libretro_ngc.a
205 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
206 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
207 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
210 else ifeq ($(platform), wii)
211 TARGET := libretro_$(TARGET_NAME)_wii.a
212 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
213 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
214 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
217 else ifeq ($(platform), qnx)
218 TARGET := $(TARGET_NAME)_libretro_qnx.so
220 CC = qcc -Vgcc_ntoarmv7le
227 CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
228 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
229 MAIN_LDLIBS += -lsocket
235 else ifeq ($(platform), rpi2)
236 TARGET := $(TARGET_NAME)_libretro.so
238 CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
239 ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
246 else ifeq ($(platform), rpi3)
247 TARGET := $(TARGET_NAME)_libretro.so
249 CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
250 ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
257 else ifeq ($(platform), rpi4)
258 TARGET := $(TARGET_NAME)_libretro.so
260 CFLAGS += -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
261 ASFLAGS += -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard
267 # Classic Platforms ####################
268 # Platform affix = classic_<ISA>_<µARCH>
269 # Help at https://modmyclassic.com/comp
271 # (armv7 a7, hard point, neon based) ###
272 # NESC, SNESC, C64 mini
273 else ifeq ($(platform), classic_armv7_a7)
274 TARGET := $(TARGET_NAME)_libretro.so
277 -flto=4 -fwhole-program -fuse-linker-plugin \
278 -fdata-sections -ffunction-sections -Wl,--gc-sections \
279 -fno-stack-protector -fno-ident -fomit-frame-pointer \
280 -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
281 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \
282 -fmerge-all-constants -fno-math-errno \
283 -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
284 CXXFLAGS += $(CFLAGS)
285 CPPFLAGS += $(CFLAGS)
291 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
292 CFLAGS += -march=armv7-a
294 CFLAGS += -march=armv7ve
295 # If gcc is 5.0 or later
296 ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1)
297 LDFLAGS += -static-libgcc -static-libstdc++
301 # (armv8 a35, hard point, neon based) ###
302 # PlayStation Classic
303 else ifeq ($(platform), classic_armv8_a35)
304 TARGET := $(TARGET_NAME)_libretro.so
307 -fmerge-all-constants -fno-math-errno -march=armv8-a \
308 -marm -mcpu=cortex-a35 -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard
313 LDFLAGS += -static-libgcc -static-libstdc++ -fPIC
315 #######################################
318 else ifneq (,$(findstring armv,$(platform)))
319 TARGET := $(TARGET_NAME)_libretro.so
324 ifneq (,$(findstring cortexa8,$(platform)))
325 CFLAGS += -marm -mcpu=cortex-a8
326 ASFLAGS += -mcpu=cortex-a8
327 else ifneq (,$(findstring cortexa7,$(platform)))
328 CFLAGS += -marm -mcpu=cortex-a7
329 ASFLAGS += -mcpu=cortex-a7
331 else ifneq (,$(findstring cortexa9,$(platform)))
332 CFLAGS += -marm -mcpu=cortex-a9
333 ASFLAGS += -mcpu=cortex-a9
336 ifneq (,$(findstring neon,$(platform)))
338 ASFLAGS += -mfpu=neon
342 ifneq (,$(findstring softfloat,$(platform)))
343 CFLAGS += -mfloat-abi=softfp
344 ASFLAGS += -mfloat-abi=softfp
345 else ifneq (,$(findstring hardfloat,$(platform)))
346 CFLAGS += -mfloat-abi=hard
347 ASFLAGS += -mfloat-abi=hard
354 TARGET := $(TARGET_NAME)_libretro.dll
357 MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s
358 CFLAGS += -D__WIN32__ -DNO_DYLIB
360 MAIN_LDLIBS += -lws2_32
367 MAIN_LDFLAGS += -shared
368 MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ)
370 # enable large file support if available
371 ifeq ($(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep __SIZEOF_LONG__ | awk '{print $$3}'),4)
372 CFLAGS += -D_FILE_OFFSET_BITS=64
375 # try to autodetect stuff for the lazy
377 ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
380 HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
382 ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
383 MAIN_LDFLAGS += -Wl,--no-undefined
386 TARGET ?= libretro.so
389 SOUND_DRIVERS = libretro
395 #ifeq ($(platform),ios)
396 #ifeq ($(USE_DYNAREC),1)
397 # make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
398 # make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
404 # no special AS needed for gpu_neon
405 plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
406 $(CC) $(CFLAGS) -c $^ -o $@