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