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