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