asm: use a macro for functions
[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
a4874585
C
27CC ?= gcc
28CXX ?= g++
29AS ?= as
8ad07683 30CC_AS ?= $(CC)
1c6ab616 31
32ifeq ($(platform), unix)
33 TARGET := snes9x_next_libretro.so
34 fpic := -fPIC
35 SHARED := -shared -Wl,--version-script=libretro/link.T
36else ifeq ($(platform), osx)
37 TARGET := snes9x_next_libretro.dylib
38 fpic := -fPIC
39 SHARED := -dynamiclib
40else ifeq ($(platform), ios)
41ARCH := arm
42 TARGET := snes9x_next_libretro.dylib
43 fpic := -fPIC
44 SHARED := -dynamiclib
45
46CC = clang -arch armv7 -isysroot $(IOSSDK)
47CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
8ad07683 48CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
1c6ab616 49CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
50ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
51 HAVE_NEON = 1
52 CFLAGS += -DIOS
53else ifeq ($(platform), ps3)
54 TARGET := snes9x_next_libretro_ps3.a
55 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
56 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
57 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
58else ifeq ($(platform), sncps3)
59 TARGET := snes9x_next_libretro_ps3.a
60 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
61 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
62 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
63else ifeq ($(platform), psl1ght)
64 TARGET := snes9x_next_libretro_psl1ght.a
65 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
66 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
67 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
68else ifeq ($(platform), psp1)
69 TARGET := snes9x_next_libretro_psp1.a
70 CC = psp-gcc$(EXE_EXT)
71 AR = psp-ar$(EXE_EXT)
72 CFLAGS += -DPSP -G0
73else ifeq ($(platform), xenon)
74 TARGET := snes9x_next_libretro_xenon360.a
75 CC = xenon-gcc$(EXE_EXT)
76 AR = xenon-ar$(EXE_EXT)
77 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
78else ifeq ($(platform), ngc)
79 TARGET := snes9x_next_libretro_ngc.a
80 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
81 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
82 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
83else ifeq ($(platform), wii)
84 TARGET := snes9x_next_libretro_wii.a
85 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
86 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
87 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
a4874585
C
88else ifeq ($(platform), qnx)
89 TARGET := libretro_pcsx_rearmed_qnx.so
90 HAVE_NEON = 1
91 USE_DYNAREC = 1
92 DRC_CACHE_BASE = 0
93 BUILTIN_GPU = neon
94 ARCH = arm
95 CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
96 ASFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp
1c6ab616 97else
98 TARGET := snes9x_next_retro.dll
99 CC = gcc
100 fpic := -fPIC
101 LD_FLAGS := -fPIC
102 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=libretro/link.T
103 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
104endif
105
106CFLAGS += -fPIC
706252fc 107ASFLAGS +=
108LDFLAGS +=
a4874585
C
109
110ifneq ($(platform),qnx)
111 LDLIBS += -lpthread
112 MAIN_LDLIBS += -ldl
113endif
1c6ab616 114MAIN_LDFLAGS += -shared
a4874585 115MAIN_LDLIBS += -lm -lz
706252fc 116PLUGIN_CFLAGS += -fPIC
117
a4874585 118TARGET ?= libretro.so
706252fc 119PLATFORM = libretro
a4874585 120BUILTIN_GPU ?= peops
706252fc 121SOUND_DRIVERS = libretro
a4874585 122#PLUGINS = plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so
706252fc 123
124CC_LINK = $(CC)
125LDFLAGS += $(MAIN_LDFLAGS)
126LDLIBS += $(MAIN_LDLIBS)
127ifdef PCNT
128CFLAGS += -DPCNT
129endif
130
131# core
132OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
133 libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
134 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
135 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
136 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
137 libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
138OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
139ifeq "$(ARCH)" "arm"
140OBJS += libpcsxcore/gte_arm.o
141endif
142ifeq "$(HAVE_NEON)" "1"
143OBJS += libpcsxcore/gte_neon.o
144endif
145libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
146
147# dynarec
148ifeq "$(USE_DYNAREC)" "1"
149OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
150OBJS += libpcsxcore/new_dynarec/pcsxmem.o
151else
152libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DDRC_DISABLE
153endif
154OBJS += libpcsxcore/new_dynarec/emu_if.o
155libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
156 libpcsxcore/new_dynarec/pcsxmem_inline.c
157libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
158ifdef DRC_DBG
159libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
160CFLAGS += -DDRC_DBG
161endif
162ifeq "$(DRC_CACHE_BASE)" "1"
163libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
164endif
165
166# spu
167OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
168 plugins/dfsound/registers.o plugins/dfsound/spu.o \
169 plugins/dfsound/out.o
170plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
171 plugins/dfsound/xa.c
172ifeq "$(ARCH)" "arm"
173OBJS += plugins/dfsound/arm_utils.o
174endif
175plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
176
177# builtin gpu
178OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
179ifeq "$(BUILTIN_GPU)" "neon"
180OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
181plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
182plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
183endif
184ifeq "$(BUILTIN_GPU)" "peops"
185# note: code is not safe for strict-aliasing? (Castlevania problems)
186plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
187plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
188OBJS += plugins/dfxvideo/gpulib_if.o
189endif
190ifeq "$(BUILTIN_GPU)" "unai"
191OBJS += plugins/gpu_unai/gpulib_if.o
192ifeq "$(ARCH)" "arm"
193OBJS += plugins/gpu_unai/gpu_arm.o
194endif
195plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
196CC_LINK = $(CXX)
197endif
198
199# cdrcimg
200OBJS += plugins/cdrcimg/cdrcimg.o
201
202# dfinput
203OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
204
205# frontend/gui
206OBJS += frontend/cspace.o
207ifeq "$(HAVE_NEON)" "1"
208OBJS += frontend/cspace_neon.o
209else
210ifeq "$(ARCH)" "arm"
211OBJS += frontend/cspace_arm.o
212endif
213endif
214
215CFLAGS += -DFRONTEND_SUPPORTS_RGB565 -DNO_FRONTEND
216
217# misc
218OBJS += frontend/libretro.o frontend/main.o frontend/plugin.o
219
220
221frontend/menu.o frontend/main.o: frontend/revision.h
222frontend/libretro.o: frontend/revision.h
223
224libpcsxcore/gte_nf.o: libpcsxcore/gte.c
225 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
226
227frontend/revision.h: FORCE
228 @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
229 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
230 @rm $@_
231
232%.o: %.S
8ad07683 233 $(CC_AS) $(CFLAGS) -c $^ -o $@
a4874585
C
234
235%.o: %.s
236 $(CC) $(ASFLAGS) -c $^ -o $@
706252fc 237
238
239target_: $(TARGET)
240
241$(TARGET): $(OBJS)
242 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
243
244clean: $(PLAT_CLEAN) clean_plugins
245 $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
246
247ifneq ($(PLUGINS),)
248plugins_: $(PLUGINS)
249
250$(PLUGINS):
251 make -C $(dir $@)
252
253clean_plugins:
254 make -C plugins/gpulib/ clean
255 for dir in $(PLUGINS) ; do \
256 $(MAKE) -C $$(dirname $$dir) clean; done
257else
258plugins_:
259clean_plugins:
260endif
261
262.PHONY: all clean target_ plugins_ clean_plugins FORCE