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