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