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