(CTR/3DS) add a warning message when mprotect is called without the
[pcsx_rearmed.git] / Makefile.libretro
... / ...
CommitLineData
1# Makefile for PCSX ReARMed (libretro)
2
3ifeq ($(platform),)
4 platform = unix
5 ifeq ($(shell uname -a),)
6 platform = win
7 else ifneq ($(findstring MINGW,$(shell uname -a)),)
8 platform = win
9 else ifneq ($(findstring Darwin,$(shell uname -a)),)
10 platform = osx
11 else ifneq ($(findstring win,$(shell uname -a)),)
12 platform = win
13 endif
14endif
15
16CC ?= gcc
17CXX ?= g++
18AS ?= as
19CC_AS ?= $(CC)
20CFLAGS ?=
21
22TARGET_NAME := pcsx_rearmed
23LIBM := -lm
24LIBZ := -lz
25LIBPTHREAD := -lpthread
26LIBDL := -ldl
27MMAP_WIN32=0
28EXTRA_LDFLAGS =
29
30# Unix
31ifeq ($(platform), unix)
32 TARGET := $(TARGET_NAME)_libretro.so
33 fpic := -fPIC
34 SHARED := -shared -Wl,--version-script=libretro/link.T
35
36else ifeq ($(platform), linux-portable)
37 TARGET := $(TARGET_NAME)_libretro.so
38 fpic := -fPIC -nostdlib
39 EXTRA_LDFLAGS += -fPIC -nostdlib
40 LIBM :=
41 LIBZ :=
42 LIBPTHREAD :=
43 LIBDL :=
44 SHARED := -shared -Wl,--version-script=libretro/link.T
45# OS X
46else ifeq ($(platform), osx)
47 TARGET := $(TARGET_NAME)_libretro.dylib
48 fpic := -fPIC
49 SHARED := -dynamiclib
50 OSXVER = `sw_vers -productVersion | cut -d. -f 2`
51 OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
52 fpic += -mmacosx-version-min=10.1
53
54# iOS
55else ifeq ($(platform), ios)
56 ARCH := arm
57 USE_DYNAREC ?= 1
58 TARGET := $(TARGET_NAME)_libretro_ios.dylib
59ifeq ($(USE_DYNAREC),0)
60 # Override
61 TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib
62endif
63 fpic := -fPIC
64 SHARED := -dynamiclib
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
78 OSXVER = `sw_vers -productVersion | cut -d. -f 2`
79 OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
80 ifeq ($(OSX_LT_MAVERICKS),"YES")
81 CC += -miphoneos-version-min=5.0
82 CXX += -miphoneos-version-min=5.0
83 CC_AS += -miphoneos-version-min=5.0
84 CFLAGS += -miphoneos-version-min=5.0
85 endif
86
87# PS3
88else ifeq ($(platform), ps3)
89 TARGET := $(TARGET_NAME)_libretro_ps3.a
90 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
91 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
92 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
93
94# sncps3
95else ifeq ($(platform), sncps3)
96 TARGET := $(TARGET_NAME)_libretro_ps3.a
97 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
98 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
99 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
100
101# Lightweight PS3 Homebrew SDK
102else ifeq ($(platform), psl1ght)
103 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
104 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
105 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
106 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
107
108# PSP
109else ifeq ($(platform), psp1)
110 TARGET := $(TARGET_NAME)_libretro_psp1.a
111 CC = psp-gcc$(EXE_EXT)
112 AR = psp-ar$(EXE_EXT)
113 CFLAGS += -DPSP -G0
114
115# Vita
116else ifeq ($(platform), vita)
117 TARGET := $(TARGET_NAME)_libretro_vita.a
118 CC = arm-vita-eabi-gcc$(EXE_EXT)
119 AR = arm-vita-eabi-ar$(EXE_EXT)
120 CFLAGS += -DVITA
121 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
122 CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
123 CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB
124 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
125
126# CFLAGS += -U__ARM_NEON__
127 HAVE_NEON = 1
128 BUILTIN_GPU = neon
129
130# USE_DYNAREC = 1
131# DRC_CACHE_BASE = 0
132
133 ARCH = arm
134 STATIC_LINKING = 1
135
136# CTR(3DS)
137else ifeq ($(platform), ctr)
138 TARGET := $(TARGET_NAME)_libretro_ctr.a
139 CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
140 CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
141 AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
142 CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB
143 CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp
144 CFLAGS += -Wall -mword-relocations
145 CFLAGS += -fomit-frame-pointer -ffast-math
146 CFLAGS += -I$(CTRULIB)/include -I$(DEVKITPRO)/portlibs/armv6k/include -Ifrontend/3ds
147 CFLAGS += -Werror=implicit-function-declaration
148
149 OBJS += frontend/3ds/3ds_utils.o
150
151
152# CFLAGS += -DPCSX
153# BUILTIN_GPU = unai
154 USE_DYNAREC = 1
155 DRC_CACHE_BASE = 0
156 ARCH = arm
157
158 STATIC_LINKING = 1
159
160# Xbox 360
161else ifeq ($(platform), xenon)
162 TARGET := $(TARGET_NAME)_libretro_xenon360.a
163 CC = xenon-gcc$(EXE_EXT)
164 AR = xenon-ar$(EXE_EXT)
165 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
166
167# Nintendo Game Cube
168else ifeq ($(platform), ngc)
169 TARGET := $(TARGET_NAME)_libretro_ngc.a
170 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
171 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
172 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
173
174# Nintendo Wii
175else ifeq ($(platform), wii)
176 TARGET := libretro_$(TARGET_NAME)_wii.a
177 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
178 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
179 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
180
181# QNX
182else ifeq ($(platform), qnx)
183 TARGET := $(TARGET_NAME)_libretro_qnx.so
184 fpic := -fPIC
185 CC = qcc -Vgcc_ntoarmv7le
186 CC_AS = $(CC)
187 HAVE_NEON = 1
188 USE_DYNAREC = 1
189 DRC_CACHE_BASE = 0
190 BUILTIN_GPU = neon
191 ARCH = arm
192 CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
193 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
194
195# ARM
196else ifneq (,$(findstring armv,$(platform)))
197 TARGET := $(TARGET_NAME)_libretro.so
198 SHARED := -shared -Wl,--no-undefined
199 fpic := -fPIC
200 DRC_CACHE_BASE = 0
201 ifneq (,$(findstring cortexa8,$(platform)))
202 CFLAGS += -marm -mcpu=cortex-a8
203 ASFLAGS += -mcpu=cortex-a8
204 else ifneq (,$(findstring cortexa9,$(platform)))
205 CFLAGS += -marm -mcpu=cortex-a9
206 ASFLAGS += -mcpu=cortex-a9
207 endif
208 CFLAGS += -marm
209 ifneq (,$(findstring neon,$(platform)))
210 CFLAGS += -mfpu=neon
211 ASFLAGS += -mfpu=neon
212 HAVE_NEON = 1
213 BUILTIN_GPU = neon
214 endif
215 ifneq (,$(findstring softfloat,$(platform)))
216 CFLAGS += -mfloat-abi=softfp
217 ASFLAGS += -mfloat-abi=softfp
218 else ifneq (,$(findstring hardfloat,$(platform)))
219 CFLAGS += -mfloat-abi=hard
220 ASFLAGS += -mfloat-abi=hard
221 endif
222 ARCH = arm
223 USE_DYNAREC = 1
224
225# Windows
226else
227 TARGET := $(TARGET_NAME)_libretro.dll
228 CC = gcc
229 fpic := -fPIC
230 LD_FLAGS := -fPIC
231 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=libretro/link.T
232 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
233 MMAP_WIN32=1
234endif
235
236CFLAGS += $(fpic)
237ifeq ($(platform),win)
238 MAIN_LDLIBS += -lws2_32
239else ifneq ($(platform),qnx)
240 LDLIBS += $(LIBPHTREAD)
241 MAIN_LDLIBS += $(LIBDL)
242endif
243MAIN_LDFLAGS += -shared
244MAIN_LDLIBS += $(LIBM) $(LIBZ)
245
246TARGET ?= libretro.so
247PLATFORM = libretro
248BUILTIN_GPU ?= peops
249SOUND_DRIVERS = libretro
250PLUGINS =
251NO_CONFIG_MAK = yes
252
253libretro_all: all
254ifeq ($(platform),ios)
255ifeq ($(USE_DYNAREC),1)
256 make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean
257 make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform)
258endif
259endif
260
261include Makefile
262
263# no special AS needed for gpu_neon
264plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
265 $(CC) $(CFLAGS) -c $^ -o $@