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