redports backport
[pcsx_rearmed.git] / Makefile
... / ...
CommitLineData
1# Makefile for PCSX ReARMed
2
3# default stuff goes here, so that config can override
4TARGET ?= pcsx
5CFLAGS += -Wall -Iinclude -ffast-math
6ifeq ($(DEBUG), 1)
7CFLAGS += -O0 -ggdb
8else
9CFLAGS += -O2 -DNDEBUG
10endif
11CXXFLAGS += $(CFLAGS)
12#DRC_DBG = 1
13#PCNT = 1
14
15all: config.mak target_ plugins_
16
17ifndef NO_CONFIG_MAK
18ifneq ($(wildcard config.mak),)
19config.mak: ./configure
20 @echo $@ is out-of-date, running configure
21 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
22include config.mak
23else
24config.mak:
25 @echo "Please run ./configure before running make!"
26 @exit 1
27endif
28else # NO_CONFIG_MAK
29config.mak:
30endif
31
32-include Makefile.local
33
34CC_LINK ?= $(CC)
35CC_AS ?= $(CC)
36LDFLAGS += $(MAIN_LDFLAGS)
37EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
38LDLIBS += $(MAIN_LDLIBS)
39ifdef PCNT
40CFLAGS += -DPCNT
41endif
42
43# core
44OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
45 libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
46 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
47 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
48 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
49 libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
50OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
51ifeq "$(ARCH)" "arm"
52OBJS += libpcsxcore/gte_arm.o
53endif
54ifeq "$(HAVE_NEON)" "1"
55OBJS += libpcsxcore/gte_neon.o
56endif
57libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
58
59# dynarec
60ifeq "$(USE_DYNAREC)" "1"
61OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
62OBJS += libpcsxcore/new_dynarec/pcsxmem.o
63else
64libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DDRC_DISABLE
65frontend/libretro.o: CFLAGS += -DDRC_DISABLE
66endif
67OBJS += libpcsxcore/new_dynarec/emu_if.o
68libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
69 libpcsxcore/new_dynarec/pcsxmem_inline.c
70libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
71ifdef DRC_DBG
72libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
73CFLAGS += -DDRC_DBG
74endif
75ifeq "$(DRC_CACHE_BASE)" "1"
76libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
77endif
78
79# spu
80OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
81 plugins/dfsound/registers.o plugins/dfsound/spu.o \
82 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
83plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
84 plugins/dfsound/xa.c
85ifeq "$(ARCH)" "arm"
86OBJS += plugins/dfsound/arm_utils.o
87endif
88ifeq "$(HAVE_C64_TOOLS)" "1"
89plugins/dfsound/spu.o: CFLAGS += -DC64X_DSP
90plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c
91frontend/menu.o: CFLAGS += -DC64X_DSP
92endif
93ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
94plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
95OBJS += plugins/dfsound/oss.o
96endif
97ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
98plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
99OBJS += plugins/dfsound/alsa.o
100LDLIBS += -lasound
101endif
102ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
103plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
104OBJS += plugins/dfsound/sdl.o
105endif
106ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
107plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
108OBJS += plugins/dfsound/pulseaudio.o
109endif
110ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
111plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
112endif
113
114# builtin gpu
115OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
116ifeq "$(BUILTIN_GPU)" "neon"
117OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
118plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
119plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
120endif
121ifeq "$(BUILTIN_GPU)" "peops"
122# note: code is not safe for strict-aliasing? (Castlevania problems)
123plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
124plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
125OBJS += plugins/dfxvideo/gpulib_if.o
126endif
127ifeq "$(BUILTIN_GPU)" "unai"
128OBJS += plugins/gpu_unai/gpulib_if.o
129ifeq "$(ARCH)" "arm"
130OBJS += plugins/gpu_unai/gpu_arm.o
131endif
132plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
133CC_LINK = $(CXX)
134endif
135
136# cdrcimg
137OBJS += plugins/cdrcimg/cdrcimg.o
138
139# dfinput
140OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
141
142# frontend/gui
143OBJS += frontend/cspace.o
144ifeq "$(HAVE_NEON)" "1"
145OBJS += frontend/cspace_neon.o
146else
147ifeq "$(ARCH)" "arm"
148OBJS += frontend/cspace_arm.o
149endif
150endif
151
152ifeq "$(PLATFORM)" "generic"
153OBJS += frontend/libpicofe/in_sdl.o
154OBJS += frontend/libpicofe/plat_sdl.o
155OBJS += frontend/libpicofe/plat_dummy.o
156OBJS += frontend/libpicofe/linux/in_evdev.o
157OBJS += frontend/plat_sdl.o
158ifeq "$(HAVE_GLES)" "1"
159OBJS += frontend/libpicofe/gl.o frontend/libpicofe/gl_platform.o
160LDLIBS += $(LDLIBS_GLES)
161frontend/libpicofe/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
162frontend/libpicofe/gl_platform.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
163frontend/libpicofe/gl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
164frontend/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
165endif
166USE_PLUGIN_LIB = 1
167USE_FRONTEND = 1
168endif
169ifeq "$(PLATFORM)" "pandora"
170OBJS += frontend/libpicofe/pandora/plat.o
171OBJS += frontend/libpicofe/linux/fbdev.o frontend/libpicofe/linux/xenv.o
172OBJS += frontend/libpicofe/linux/in_evdev.o
173OBJS += frontend/plat_pandora.o frontend/plat_omap.o
174frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
175frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
176USE_PLUGIN_LIB = 1
177USE_FRONTEND = 1
178endif
179ifeq "$(PLATFORM)" "caanoo"
180OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o
181OBJS += frontend/libpicofe/gp2x/soc_pollux.o
182OBJS += frontend/libpicofe/linux/in_evdev.o
183OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
184frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h
185USE_PLUGIN_LIB = 1
186USE_FRONTEND = 1
187endif
188ifeq "$(PLATFORM)" "maemo"
189OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o
190maemo/%.o: maemo/%.c
191USE_PLUGIN_LIB = 1
192LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse)
193CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB
194CFLAGS += `pkg-config --cflags glib-2.0 libosso dbus-1 hildon-fm-2`
195LDFLAGS += `pkg-config --libs glib-2.0 libosso dbus-1 hildon-fm-2`
196endif
197ifeq "$(PLATFORM)" "libretro"
198OBJS += frontend/libretro.o
199CFLAGS += -DFRONTEND_SUPPORTS_RGB565
200CFLAGS += -DHAVE_LIBRETRO
201
202ifeq ($(MMAP_WIN32),1)
203OBJS += libpcsxcore/memmap_win32.o
204endif
205endif
206
207ifeq "$(USE_PLUGIN_LIB)" "1"
208OBJS += frontend/plugin_lib.o
209OBJS += frontend/libpicofe/linux/plat.o
210OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
211ifeq "$(HAVE_NEON)" "1"
212OBJS += frontend/libpicofe/arm/neon_scale2x.o
213OBJS += frontend/libpicofe/arm/neon_eagle2x.o
214frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
215frontend/libpicofe/arm/neon_eagle2x.o: CFLAGS += -DDO_BGR_TO_RGB
216endif
217endif
218ifeq "$(USE_FRONTEND)" "1"
219OBJS += frontend/menu.o
220OBJS += frontend/libpicofe/input.o
221frontend/menu.o: frontend/libpicofe/menu.c
222ifeq "$(HAVE_TSLIB)" "1"
223frontend/%.o: CFLAGS += -DHAVE_TSLIB
224OBJS += frontend/pl_gun_ts.o
225endif
226else
227CFLAGS += -DNO_FRONTEND
228endif
229
230# misc
231OBJS += frontend/main.o frontend/plugin.o
232
233
234frontend/menu.o frontend/main.o: frontend/revision.h
235frontend/plat_sdl.o frontend/libretro.o: frontend/revision.h
236
237frontend/libpicofe/%.c:
238 @echo "libpicofe module is missing, please run:"
239 @echo "git submodule init && git submodule update"
240 @exit 1
241
242libpcsxcore/gte_nf.o: libpcsxcore/gte.c
243 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
244
245frontend/revision.h: FORCE
246 @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
247 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
248 @rm $@_
249
250%.o: %.S
251 $(CC_AS) $(CFLAGS) -c $^ -o $@
252
253%.o: %.cpp
254 $(CXX) $(CXXFLAGS) -c -o $@ $<
255
256
257
258target_: $(TARGET)
259
260$(TARGET): $(OBJS)
261ifeq ($(STATIC_LINKING), 1)
262 $(AR) rcs $@ $(OBJS)
263else
264 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
265endif
266
267clean: $(PLAT_CLEAN) clean_plugins
268 $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
269
270ifneq ($(PLUGINS),)
271plugins_: $(PLUGINS)
272
273$(PLUGINS):
274 make -C $(dir $@)
275
276clean_plugins:
277 make -C plugins/gpulib/ clean
278 for dir in $(PLUGINS) ; do \
279 $(MAKE) -C $$(dirname $$dir) clean; done
280else
281plugins_:
282clean_plugins:
283endif
284
285.PHONY: all clean target_ plugins_ clean_plugins FORCE
286
287# ----------- release -----------
288
289VER ?= $(shell git describe HEAD)
290
291ifeq "$(PLATFORM)" "generic"
292OUT = pcsx_rearmed_$(VER)
293
294rel: pcsx $(PLUGINS) \
295 frontend/pandora/skin readme.txt COPYING
296 rm -rf $(OUT)
297 mkdir -p $(OUT)/plugins
298 mkdir -p $(OUT)/bios
299 cp -r $^ $(OUT)/
300 mv $(OUT)/*.so* $(OUT)/plugins/
301 zip -9 -r $(OUT).zip $(OUT)
302endif
303
304ifeq "$(PLATFORM)" "pandora"
305PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
306
307rel: pcsx plugins/dfsound/pcsxr_spu_area3.out $(PLUGINS) \
308 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
309 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
310 rm -rf out
311 mkdir -p out/plugins
312 cp -r $^ out/
313 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
314 rm out/pcsx.pxml.templ
315 mv out/*.so out/plugins/
316 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
317endif
318
319ifeq "$(PLATFORM)" "caanoo"
320PLAT_CLEAN = caanoo_clean
321
322caanoo_clean:
323 $(RM) frontend/320240/pollux_set
324
325rel: pcsx $(PLUGINS) \
326 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
327 frontend/320240/pcsxb.png frontend/320240/skin \
328 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
329 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
330 frontend/320240/haptic_s.cfg \
331 readme.txt COPYING
332 rm -rf out
333 mkdir -p out/pcsx_rearmed/plugins
334 cp -r $^ out/pcsx_rearmed/
335 mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
336 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
337 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
338 mkdir out/pcsx_rearmed/lib/
339 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
340 mkdir out/pcsx_rearmed/bios/
341 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
342endif