Add support for PlayBook/BB10 with libretro
[pcsx_rearmed.git] / Makefile.libretro
1 # Makefile for PCSX ReARMed (libretro)
2
3 # default stuff goes here, so that config can override
4 CFLAGS += -Wall -ggdb -Iinclude -ffast-math
5 ifndef DEBUG
6 CFLAGS += -O2 -DNDEBUG
7 endif
8 CXXFLAGS += $(CFLAGS)
9 #DRC_DBG = 1
10 #PCNT = 1
11
12 all: target_ plugins_
13
14 ifeq ($(platform),)
15 platform = unix
16 ifeq ($(shell uname -a),)
17    platform = win
18 else ifneq ($(findstring MINGW,$(shell uname -a)),)
19    platform = win
20 else ifneq ($(findstring Darwin,$(shell uname -a)),)
21    platform = osx
22 else ifneq ($(findstring win,$(shell uname -a)),)
23    platform = win
24 endif
25 endif
26
27 CC ?= gcc
28 CXX ?= g++
29 AS ?= as
30
31 ifeq ($(platform), unix)
32    TARGET := snes9x_next_libretro.so
33    fpic := -fPIC
34    SHARED := -shared -Wl,--version-script=libretro/link.T
35 else ifeq ($(platform), osx)
36    TARGET := snes9x_next_libretro.dylib
37    fpic := -fPIC
38    SHARED := -dynamiclib
39 else ifeq ($(platform), ios)
40 ARCH := arm
41    TARGET := snes9x_next_libretro.dylib
42    fpic := -fPIC
43    SHARED := -dynamiclib
44
45 CC = $(IOSSDK)../../usr/bin/gcc
46 CXX = $(IOSSDK)../../usr/bin/g++
47 CFLAGS += -cpu=cortex-a8 -mfpu=neon
48 ASFLAGS += -cpu=cortex-a8 -mfpu=neon
49
50    HAVE_NEON = 1
51    CFLAGS += -DIOS
52 else 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__
57 else 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__
62 else 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__
67 else 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
72 else 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__
77 else 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__
82 else 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__
87 else 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
96 else
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__
103 endif
104
105 CFLAGS +=  -fPIC
106 ASFLAGS += 
107 LDFLAGS += 
108
109 ifneq ($(platform),qnx)
110    LDLIBS += -lpthread
111    MAIN_LDLIBS += -ldl
112 endif
113 MAIN_LDFLAGS +=  -shared
114 MAIN_LDLIBS += -lm -lz
115 PLUGIN_CFLAGS +=  -fPIC
116
117 TARGET ?= libretro.so
118 PLATFORM = libretro
119 BUILTIN_GPU ?= peops
120 SOUND_DRIVERS = libretro
121 #PLUGINS = plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so
122
123 CC_LINK = $(CC)
124 LDFLAGS += $(MAIN_LDFLAGS)
125 LDLIBS += $(MAIN_LDLIBS)
126 ifdef PCNT
127 CFLAGS += -DPCNT
128 endif
129
130 # core
131 OBJS += 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
137 OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
138 ifeq "$(ARCH)" "arm"
139 OBJS += libpcsxcore/gte_arm.o
140 endif
141 ifeq "$(HAVE_NEON)" "1"
142 OBJS += libpcsxcore/gte_neon.o
143 endif
144 libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
145
146 # dynarec
147 ifeq "$(USE_DYNAREC)" "1"
148 OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
149 OBJS += libpcsxcore/new_dynarec/pcsxmem.o
150 else
151 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DDRC_DISABLE
152 endif
153 OBJS += libpcsxcore/new_dynarec/emu_if.o
154 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
155         libpcsxcore/new_dynarec/pcsxmem_inline.c
156 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
157 ifdef DRC_DBG
158 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
159 CFLAGS += -DDRC_DBG
160 endif
161 ifeq "$(DRC_CACHE_BASE)" "1"
162 libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
163 endif
164
165 # spu
166 OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
167         plugins/dfsound/registers.o plugins/dfsound/spu.o \
168         plugins/dfsound/out.o
169 plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
170         plugins/dfsound/xa.c
171 ifeq "$(ARCH)" "arm"
172 OBJS += plugins/dfsound/arm_utils.o
173 endif
174 plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
175
176 # builtin gpu
177 OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
178 ifeq "$(BUILTIN_GPU)" "neon"
179 OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
180 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
181 plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
182 endif
183 ifeq "$(BUILTIN_GPU)" "peops"
184 # note: code is not safe for strict-aliasing? (Castlevania problems)
185 plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
186 plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
187 OBJS += plugins/dfxvideo/gpulib_if.o
188 endif
189 ifeq "$(BUILTIN_GPU)" "unai"
190 OBJS += plugins/gpu_unai/gpulib_if.o
191 ifeq "$(ARCH)" "arm"
192 OBJS += plugins/gpu_unai/gpu_arm.o
193 endif
194 plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3 
195 CC_LINK = $(CXX)
196 endif
197
198 # cdrcimg
199 OBJS += plugins/cdrcimg/cdrcimg.o
200
201 # dfinput
202 OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
203
204 # frontend/gui
205 OBJS += frontend/cspace.o
206 ifeq "$(HAVE_NEON)" "1"
207 OBJS += frontend/cspace_neon.o
208 else
209 ifeq "$(ARCH)" "arm"
210 OBJS += frontend/cspace_arm.o
211 endif
212 endif
213
214 CFLAGS += -DFRONTEND_SUPPORTS_RGB565 -DNO_FRONTEND
215
216 # misc
217 OBJS += frontend/libretro.o frontend/main.o frontend/plugin.o
218
219
220 frontend/menu.o frontend/main.o: frontend/revision.h
221 frontend/libretro.o: frontend/revision.h
222
223 libpcsxcore/gte_nf.o: libpcsxcore/gte.c
224         $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
225
226 frontend/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 $@
233         
234 %.o: %.s
235         $(CC) $(ASFLAGS) -c $^ -o $@
236
237
238 target_: $(TARGET)
239
240 $(TARGET): $(OBJS)
241         $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
242
243 clean: $(PLAT_CLEAN) clean_plugins
244         $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
245
246 ifneq ($(PLUGINS),)
247 plugins_: $(PLUGINS)
248
249 $(PLUGINS):
250         make -C $(dir $@)
251
252 clean_plugins:
253         make -C plugins/gpulib/ clean
254         for dir in $(PLUGINS) ; do \
255                 $(MAKE) -C $$(dirname $$dir) clean; done
256 else
257 plugins_:
258 clean_plugins:
259 endif
260
261 .PHONY: all clean target_ plugins_ clean_plugins FORCE