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