Add support for PlayBook/BB10 with libretro
[pcsx_rearmed.git] / Makefile.libretro
CommitLineData
706252fc 1# Makefile for PCSX ReARMed (libretro)
2
3# default stuff goes here, so that config can override
4CFLAGS += -Wall -ggdb -Iinclude -ffast-math
5ifndef DEBUG
6CFLAGS += -O2 -DNDEBUG
7endif
8CXXFLAGS += $(CFLAGS)
9#DRC_DBG = 1
10#PCNT = 1
11
12all: target_ plugins_
13
1c6ab616 14ifeq ($(platform),)
15platform = unix
16ifeq ($(shell uname -a),)
17 platform = win
18else ifneq ($(findstring MINGW,$(shell uname -a)),)
19 platform = win
20else ifneq ($(findstring Darwin,$(shell uname -a)),)
21 platform = osx
22else ifneq ($(findstring win,$(shell uname -a)),)
23 platform = win
24endif
25endif
26
a4874585
C
27CC ?= gcc
28CXX ?= g++
29AS ?= as
1c6ab616 30
31ifeq ($(platform), unix)
32 TARGET := snes9x_next_libretro.so
33 fpic := -fPIC
34 SHARED := -shared -Wl,--version-script=libretro/link.T
35else ifeq ($(platform), osx)
36 TARGET := snes9x_next_libretro.dylib
37 fpic := -fPIC
38 SHARED := -dynamiclib
39else ifeq ($(platform), ios)
40ARCH := arm
41 TARGET := snes9x_next_libretro.dylib
42 fpic := -fPIC
43 SHARED := -dynamiclib
44
45CC = clang -arch armv7 -isysroot $(IOSSDK)
46CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
47CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
48ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
49 HAVE_NEON = 1
50 CFLAGS += -DIOS
51else ifeq ($(platform), ps3)
52 TARGET := snes9x_next_libretro_ps3.a
53 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
54 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
55 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
56else ifeq ($(platform), sncps3)
57 TARGET := snes9x_next_libretro_ps3.a
58 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
59 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
60 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
61else ifeq ($(platform), psl1ght)
62 TARGET := snes9x_next_libretro_psl1ght.a
63 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
64 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
65 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
66else ifeq ($(platform), psp1)
67 TARGET := snes9x_next_libretro_psp1.a
68 CC = psp-gcc$(EXE_EXT)
69 AR = psp-ar$(EXE_EXT)
70 CFLAGS += -DPSP -G0
71else ifeq ($(platform), xenon)
72 TARGET := snes9x_next_libretro_xenon360.a
73 CC = xenon-gcc$(EXE_EXT)
74 AR = xenon-ar$(EXE_EXT)
75 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
76else ifeq ($(platform), ngc)
77 TARGET := snes9x_next_libretro_ngc.a
78 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
79 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
80 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
81else ifeq ($(platform), wii)
82 TARGET := snes9x_next_libretro_wii.a
83 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
84 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
85 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
a4874585
C
86else ifeq ($(platform), qnx)
87 TARGET := libretro_pcsx_rearmed_qnx.so
88 HAVE_NEON = 1
89 USE_DYNAREC = 1
90 DRC_CACHE_BASE = 0
91 BUILTIN_GPU = neon
92 ARCH = arm
93 CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
94 ASFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp
1c6ab616 95else
96 TARGET := snes9x_next_retro.dll
97 CC = gcc
98 fpic := -fPIC
99 LD_FLAGS := -fPIC
100 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=libretro/link.T
101 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
102endif
103
104CFLAGS += -fPIC
706252fc 105ASFLAGS +=
106LDFLAGS +=
a4874585
C
107
108ifneq ($(platform),qnx)
109 LDLIBS += -lpthread
110 MAIN_LDLIBS += -ldl
111endif
1c6ab616 112MAIN_LDFLAGS += -shared
a4874585 113MAIN_LDLIBS += -lm -lz
706252fc 114PLUGIN_CFLAGS += -fPIC
115
a4874585 116TARGET ?= libretro.so
706252fc 117PLATFORM = libretro
a4874585 118BUILTIN_GPU ?= peops
706252fc 119SOUND_DRIVERS = libretro
a4874585 120#PLUGINS = plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so
706252fc 121
122CC_LINK = $(CC)
123LDFLAGS += $(MAIN_LDFLAGS)
124LDLIBS += $(MAIN_LDLIBS)
125ifdef PCNT
126CFLAGS += -DPCNT
127endif
128
129# core
130OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
131 libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
132 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
133 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
134 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
135 libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
136OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
137ifeq "$(ARCH)" "arm"
138OBJS += libpcsxcore/gte_arm.o
139endif
140ifeq "$(HAVE_NEON)" "1"
141OBJS += libpcsxcore/gte_neon.o
142endif
143libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
144
145# dynarec
146ifeq "$(USE_DYNAREC)" "1"
147OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
148OBJS += libpcsxcore/new_dynarec/pcsxmem.o
149else
150libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DDRC_DISABLE
151endif
152OBJS += libpcsxcore/new_dynarec/emu_if.o
153libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
154 libpcsxcore/new_dynarec/pcsxmem_inline.c
155libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
156ifdef DRC_DBG
157libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
158CFLAGS += -DDRC_DBG
159endif
160ifeq "$(DRC_CACHE_BASE)" "1"
161libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
162endif
163
164# spu
165OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
166 plugins/dfsound/registers.o plugins/dfsound/spu.o \
167 plugins/dfsound/out.o
168plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
169 plugins/dfsound/xa.c
170ifeq "$(ARCH)" "arm"
171OBJS += plugins/dfsound/arm_utils.o
172endif
173plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
174
175# builtin gpu
176OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
177ifeq "$(BUILTIN_GPU)" "neon"
178OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
179plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
180plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
181endif
182ifeq "$(BUILTIN_GPU)" "peops"
183# note: code is not safe for strict-aliasing? (Castlevania problems)
184plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
185plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
186OBJS += plugins/dfxvideo/gpulib_if.o
187endif
188ifeq "$(BUILTIN_GPU)" "unai"
189OBJS += plugins/gpu_unai/gpulib_if.o
190ifeq "$(ARCH)" "arm"
191OBJS += plugins/gpu_unai/gpu_arm.o
192endif
193plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
194CC_LINK = $(CXX)
195endif
196
197# cdrcimg
198OBJS += plugins/cdrcimg/cdrcimg.o
199
200# dfinput
201OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
202
203# frontend/gui
204OBJS += frontend/cspace.o
205ifeq "$(HAVE_NEON)" "1"
206OBJS += frontend/cspace_neon.o
207else
208ifeq "$(ARCH)" "arm"
209OBJS += frontend/cspace_arm.o
210endif
211endif
212
213CFLAGS += -DFRONTEND_SUPPORTS_RGB565 -DNO_FRONTEND
214
215# misc
216OBJS += frontend/libretro.o frontend/main.o frontend/plugin.o
217
218
219frontend/menu.o frontend/main.o: frontend/revision.h
220frontend/libretro.o: frontend/revision.h
221
222libpcsxcore/gte_nf.o: libpcsxcore/gte.c
223 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
224
225frontend/revision.h: FORCE
226 @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
227 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
228 @rm $@_
229
230%.o: %.S
231 $(CC) $(CFLAGS) -c $^ -o $@
a4874585
C
232
233%.o: %.s
234 $(CC) $(ASFLAGS) -c $^ -o $@
706252fc 235
236
237target_: $(TARGET)
238
239$(TARGET): $(OBJS)
240 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
241
242clean: $(PLAT_CLEAN) clean_plugins
243 $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
244
245ifneq ($(PLUGINS),)
246plugins_: $(PLUGINS)
247
248$(PLUGINS):
249 make -C $(dir $@)
250
251clean_plugins:
252 make -C plugins/gpulib/ clean
253 for dir in $(PLUGINS) ; do \
254 $(MAKE) -C $$(dirname $$dir) clean; done
255else
256plugins_:
257clean_plugins:
258endif
259
260.PHONY: all clean target_ plugins_ clean_plugins FORCE