(iOS) Use GCC (not working yet)
[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
d02d2725 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__
87else
88 TARGET := snes9x_next_retro.dll
89 CC = gcc
90 fpic := -fPIC
91 LD_FLAGS := -fPIC
92 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=libretro/link.T
93 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
94endif
95
96CFLAGS += -fPIC
d02d2725 97ASFLAGS +=
98LDFLAGS +=
99LDLIBS += -lpthread
6e1ff5d2 100MAIN_LDFLAGS += -shared
d02d2725 101MAIN_LDLIBS += -ldl -lm -lz
102PLUGIN_CFLAGS += -fPIC
103
104TARGET = libretro.so
105PLATFORM = libretro
106BUILTIN_GPU = peops
107SOUND_DRIVERS = libretro
108PLUGINS = plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so
109
110CC_LINK = $(CC)
111LDFLAGS += $(MAIN_LDFLAGS)
112LDLIBS += $(MAIN_LDLIBS)
113ifdef PCNT
114CFLAGS += -DPCNT
115endif
116
117# core
118OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
119 libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
120 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
121 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
122 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
123 libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
124OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
125ifeq "$(ARCH)" "arm"
126OBJS += libpcsxcore/gte_arm.o
127endif
128ifeq "$(HAVE_NEON)" "1"
129OBJS += libpcsxcore/gte_neon.o
130endif
131libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
132
133# dynarec
134ifeq "$(USE_DYNAREC)" "1"
135OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
136OBJS += libpcsxcore/new_dynarec/pcsxmem.o
137else
138libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DDRC_DISABLE
139endif
140OBJS += libpcsxcore/new_dynarec/emu_if.o
141libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
142 libpcsxcore/new_dynarec/pcsxmem_inline.c
143libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
144ifdef DRC_DBG
145libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
146CFLAGS += -DDRC_DBG
147endif
148ifeq "$(DRC_CACHE_BASE)" "1"
149libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
150endif
151
152# spu
153OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
154 plugins/dfsound/registers.o plugins/dfsound/spu.o \
155 plugins/dfsound/out.o
156plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
157 plugins/dfsound/xa.c
158ifeq "$(ARCH)" "arm"
159OBJS += plugins/dfsound/arm_utils.o
160endif
161plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
162
163# builtin gpu
164OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
165ifeq "$(BUILTIN_GPU)" "neon"
166OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
167plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
168plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
169endif
170ifeq "$(BUILTIN_GPU)" "peops"
171# note: code is not safe for strict-aliasing? (Castlevania problems)
172plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
173plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
174OBJS += plugins/dfxvideo/gpulib_if.o
175endif
176ifeq "$(BUILTIN_GPU)" "unai"
177OBJS += plugins/gpu_unai/gpulib_if.o
178ifeq "$(ARCH)" "arm"
179OBJS += plugins/gpu_unai/gpu_arm.o
180endif
181plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
182CC_LINK = $(CXX)
183endif
184
185# cdrcimg
186OBJS += plugins/cdrcimg/cdrcimg.o
187
188# dfinput
189OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
190
191# frontend/gui
192OBJS += frontend/cspace.o
193ifeq "$(HAVE_NEON)" "1"
194OBJS += frontend/cspace_neon.o
195else
196ifeq "$(ARCH)" "arm"
197OBJS += frontend/cspace_arm.o
198endif
199endif
200
201CFLAGS += -DFRONTEND_SUPPORTS_RGB565 -DNO_FRONTEND
202
203# misc
204OBJS += frontend/libretro.o frontend/main.o frontend/plugin.o
205
206
207frontend/menu.o frontend/main.o: frontend/revision.h
208frontend/libretro.o: frontend/revision.h
209
210libpcsxcore/gte_nf.o: libpcsxcore/gte.c
211 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
212
213frontend/revision.h: FORCE
214 @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
215 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
216 @rm $@_
217
218%.o: %.S
219 $(CC) $(CFLAGS) -c $^ -o $@
220
221
222target_: $(TARGET)
223
224$(TARGET): $(OBJS)
225 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
226
227clean: $(PLAT_CLEAN) clean_plugins
228 $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
229
230ifneq ($(PLUGINS),)
231plugins_: $(PLUGINS)
232
233$(PLUGINS):
234 make -C $(dir $@)
235
236clean_plugins:
237 make -C plugins/gpulib/ clean
238 for dir in $(PLUGINS) ; do \
239 $(MAKE) -C $$(dirname $$dir) clean; done
240else
241plugins_:
242clean_plugins:
243endif
244
245.PHONY: all clean target_ plugins_ clean_plugins FORCE