drc: rework jump_out lists
[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
9ifeq ($(platform), $(filter $(platform), vita ctr))
10CFLAGS += -O3 -DNDEBUG
11else
12CFLAGS += -O2 -DNDEBUG
13endif
14endif
15CXXFLAGS += $(CFLAGS)
16#DRC_DBG = 1
17#PCNT = 1
18
19# Suppress minor warnings for dependencies
20deps/%: CFLAGS += -Wno-unused -Wno-unused-function
21
22all: config.mak target_ plugins_
23
24ifndef NO_CONFIG_MAK
25ifneq ($(wildcard config.mak),)
26config.mak: ./configure
27 @echo $@ is out-of-date, running configure
28 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
29include config.mak
30else
31config.mak:
32 @echo "Please run ./configure before running make!"
33 @exit 1
34endif
35else # NO_CONFIG_MAK
36config.mak:
37endif
38
39-include Makefile.local
40
41CC_LINK ?= $(CC)
42CC_AS ?= $(CC)
43LDFLAGS += $(MAIN_LDFLAGS)
44EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
45LDLIBS += $(MAIN_LDLIBS)
46ifdef PCNT
47CFLAGS += -DPCNT
48endif
49
50# core
51OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/database.o \
52 libpcsxcore/decode_xa.o libpcsxcore/mdec.o \
53 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
54 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
55 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
56 libpcsxcore/sio.o libpcsxcore/spu.o
57OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
58
59ifeq ($(DEBUG), 1)
60OBJS += libpcsxcore/debug.o libpcsxcore/socket.o libpcsxcore/disr3000a.o
61endif
62
63ifeq ($(WANT_ZLIB),1)
64CFLAGS += -Ideps/libchdr/deps/zlib-1.2.11
65OBJS += deps/libchdr/deps/zlib-1.2.11/adler32.o \
66 deps/libchdr/deps/zlib-1.2.11/compress.o \
67 deps/libchdr/deps/zlib-1.2.11/crc32.o \
68 deps/libchdr/deps/zlib-1.2.11/deflate.o \
69 deps/libchdr/deps/zlib-1.2.11/gzclose.o \
70 deps/libchdr/deps/zlib-1.2.11/gzlib.o \
71 deps/libchdr/deps/zlib-1.2.11/gzread.o \
72 deps/libchdr/deps/zlib-1.2.11/gzwrite.o \
73 deps/libchdr/deps/zlib-1.2.11/infback.o \
74 deps/libchdr/deps/zlib-1.2.11/inffast.o \
75 deps/libchdr/deps/zlib-1.2.11/inflate.o \
76 deps/libchdr/deps/zlib-1.2.11/inftrees.o \
77 deps/libchdr/deps/zlib-1.2.11/trees.o \
78 deps/libchdr/deps/zlib-1.2.11/uncompr.o \
79 deps/libchdr/deps/zlib-1.2.11/zutil.o
80endif
81ifeq "$(ARCH)" "arm"
82OBJS += libpcsxcore/gte_arm.o
83endif
84ifeq "$(HAVE_NEON)" "1"
85OBJS += libpcsxcore/gte_neon.o
86endif
87libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
88
89# dynarec
90ifeq "$(DYNAREC)" "lightrec"
91CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \
92 -DLIGHTREC -DLIGHTREC_STATIC
93OBJS += libpcsxcore/lightrec/plugin.o
94OBJS += deps/lightning/lib/jit_disasm.o \
95 deps/lightning/lib/jit_memory.o \
96 deps/lightning/lib/jit_names.o \
97 deps/lightning/lib/jit_note.o \
98 deps/lightning/lib/jit_print.o \
99 deps/lightning/lib/jit_size.o \
100 deps/lightning/lib/lightning.o \
101 deps/lightrec/blockcache.o \
102 deps/lightrec/disassembler.o \
103 deps/lightrec/emitter.o \
104 deps/lightrec/interpreter.o \
105 deps/lightrec/lightrec.o \
106 deps/lightrec/memmanager.o \
107 deps/lightrec/optimizer.o \
108 deps/lightrec/regcache.o \
109 deps/lightrec/recompiler.o \
110 deps/lightrec/reaper.o
111ifeq ($(MMAP_WIN32),1)
112CFLAGS += -Iinclude/mman
113OBJS += deps/mman/mman.o
114endif
115else ifeq "$(DYNAREC)" "ari64"
116OBJS += libpcsxcore/new_dynarec/new_dynarec.o
117OBJS += libpcsxcore/new_dynarec/pcsxmem.o
118 ifeq "$(ARCH)" "arm"
119 OBJS += libpcsxcore/new_dynarec/linkage_arm.o
120 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
121 else ifneq (,$(findstring $(ARCH),aarch64 arm64))
122 OBJS += libpcsxcore/new_dynarec/linkage_arm64.o
123 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm64.c
124 else
125 $(error no dynarec support for architecture $(ARCH))
126 endif
127else
128CFLAGS += -DDRC_DISABLE
129endif
130OBJS += libpcsxcore/new_dynarec/emu_if.o
131libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/pcsxmem_inline.c
132ifdef DRC_DBG
133libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
134CFLAGS += -DDRC_DBG
135endif
136ifeq "$(BASE_ADDR_DYNAMIC)" "1"
137libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_DYNAMIC=1
138endif
139
140# spu
141OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
142 plugins/dfsound/registers.o plugins/dfsound/spu.o \
143 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
144plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
145 plugins/dfsound/xa.c
146ifeq "$(ARCH)" "arm"
147OBJS += plugins/dfsound/arm_utils.o
148endif
149ifeq "$(HAVE_C64_TOOLS)" "1"
150plugins/dfsound/spu.o: CFLAGS += -DC64X_DSP
151plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c
152frontend/menu.o: CFLAGS += -DC64X_DSP
153endif
154ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
155plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
156OBJS += plugins/dfsound/oss.o
157endif
158ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
159plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
160OBJS += plugins/dfsound/alsa.o
161LDLIBS += -lasound
162endif
163ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
164plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
165OBJS += plugins/dfsound/sdl.o
166endif
167ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
168plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
169OBJS += plugins/dfsound/pulseaudio.o
170endif
171ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
172plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
173endif
174
175# builtin gpu
176OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
177ifeq "$(BUILTIN_GPU)" "neon"
178CFLAGS += -DGPU_NEON
179OBJS += plugins/gpu_neon/psx_gpu_if.o
180ifeq "$(HAVE_NEON)" "1"
181OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
182plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
183else
184plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
185endif
186plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
187endif
188ifeq "$(BUILTIN_GPU)" "peops"
189CFLAGS += -DGPU_PEOPS
190# note: code is not safe for strict-aliasing? (Castlevania problems)
191plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
192plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
193OBJS += plugins/dfxvideo/gpulib_if.o
194ifeq "$(THREAD_RENDERING)" "1"
195CFLAGS += -DTHREAD_RENDERING
196OBJS += plugins/gpulib/gpulib_thread_if.o
197endif
198endif
199ifeq "$(BUILTIN_GPU)" "unai"
200CFLAGS += -DGPU_UNAI
201CFLAGS += -DUSE_GPULIB=1
202#CFLAGS += -DINLINE="static __inline__"
203#CFLAGS += -Dasm="__asm__ __volatile__"
204OBJS += plugins/gpu_unai/gpulib_if.o
205ifeq "$(ARCH)" "arm"
206OBJS += plugins/gpu_unai/gpu_arm.o
207endif
208ifeq "$(THREAD_RENDERING)" "1"
209CFLAGS += -DTHREAD_RENDERING
210OBJS += plugins/gpulib/gpulib_thread_if.o
211endif
212plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
213CC_LINK = $(CXX)
214endif
215
216# cdrcimg
217OBJS += plugins/cdrcimg/cdrcimg.o
218
219# libchdr
220ifeq "$(HAVE_CHD)" "1"
221CFLAGS += -Ideps/libchdr/include
222CFLAGS += -Ideps/libchdr/include/libchdr
223OBJS += deps/libchdr/deps/lzma-19.00/src/Alloc.o
224OBJS += deps/libchdr/deps/lzma-19.00/src/Bra86.o
225OBJS += deps/libchdr/deps/lzma-19.00/src/BraIA64.o
226OBJS += deps/libchdr/deps/lzma-19.00/src/CpuArch.o
227OBJS += deps/libchdr/deps/lzma-19.00/src/Delta.o
228OBJS += deps/libchdr/deps/lzma-19.00/src/LzFind.o
229OBJS += deps/libchdr/deps/lzma-19.00/src/Lzma86Dec.o
230OBJS += deps/libchdr/deps/lzma-19.00/src/LzmaDec.o
231OBJS += deps/libchdr/deps/lzma-19.00/src/LzmaEnc.o
232OBJS += deps/libchdr/deps/lzma-19.00/src/Sort.o
233OBJS += deps/libchdr/src/libchdr_bitstream.o
234OBJS += deps/libchdr/src/libchdr_cdrom.o
235OBJS += deps/libchdr/src/libchdr_chd.o
236OBJS += deps/libchdr/src/libchdr_flac.o
237OBJS += deps/libchdr/src/libchdr_huffman.o
238CFLAGS += -Ideps/libchdr/deps/lzma-19.00/include
239CFLAGS += -DHAVE_CHD -D_7ZIP_ST
240LDFLAGS += -lm
241endif
242
243# dfinput
244ifneq "$(PLATFORM)" "libretro"
245OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
246endif
247
248# frontend/gui
249OBJS += frontend/cspace.o
250ifeq "$(HAVE_NEON)" "1"
251OBJS += frontend/cspace_neon.o
252else
253ifeq "$(ARCH)" "arm"
254OBJS += frontend/cspace_arm.o
255endif
256endif
257
258ifeq "$(PLATFORM)" "generic"
259OBJS += frontend/libpicofe/in_sdl.o
260OBJS += frontend/libpicofe/plat_sdl.o
261OBJS += frontend/libpicofe/plat_dummy.o
262OBJS += frontend/libpicofe/linux/in_evdev.o
263OBJS += frontend/plat_sdl.o
264ifeq "$(HAVE_GLES)" "1"
265OBJS += frontend/libpicofe/gl.o frontend/libpicofe/gl_platform.o
266LDLIBS += $(LDLIBS_GLES)
267frontend/libpicofe/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
268frontend/libpicofe/gl_platform.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
269frontend/libpicofe/gl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
270frontend/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
271endif
272USE_PLUGIN_LIB = 1
273USE_FRONTEND = 1
274endif
275ifeq "$(PLATFORM)" "pandora"
276OBJS += frontend/libpicofe/pandora/plat.o
277OBJS += frontend/libpicofe/linux/fbdev.o frontend/libpicofe/linux/xenv.o
278OBJS += frontend/libpicofe/linux/in_evdev.o
279OBJS += frontend/plat_pandora.o frontend/plat_omap.o
280frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
281frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
282USE_PLUGIN_LIB = 1
283USE_FRONTEND = 1
284endif
285ifeq "$(PLATFORM)" "caanoo"
286OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o
287OBJS += frontend/libpicofe/gp2x/soc_pollux.o
288OBJS += frontend/libpicofe/linux/in_evdev.o
289OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
290frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h
291USE_PLUGIN_LIB = 1
292USE_FRONTEND = 1
293endif
294ifeq "$(PLATFORM)" "maemo"
295OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o
296maemo/%.o: maemo/%.c
297USE_PLUGIN_LIB = 1
298LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse)
299CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB
300CFLAGS += `pkg-config --cflags glib-2.0 libosso dbus-1 hildon-fm-2`
301LDFLAGS += `pkg-config --libs glib-2.0 libosso dbus-1 hildon-fm-2`
302endif
303ifeq "$(PLATFORM)" "libretro"
304ifeq "$(USE_LIBRETRO_VFS)" "1"
305OBJS += libretro-common/compat/compat_posix_string.o
306OBJS += libretro-common/compat/fopen_utf8.o
307OBJS += libretro-common/encodings/compat_strl.o
308OBJS += libretro-common/encodings/encoding_utf.o
309OBJS += libretro-common/file/file_path.o
310OBJS += libretro-common/streams/file_stream.o
311OBJS += libretro-common/streams/file_stream_transforms.o
312OBJS += libretro-common/string/stdstring.o
313OBJS += libretro-common/time/rtime.o
314OBJS += libretro-common/vfs/vfs_implementation.o
315CFLAGS += -DUSE_LIBRETRO_VFS
316endif
317OBJS += frontend/libretro.o
318CFLAGS += -Ilibretro-common/include
319CFLAGS += -DFRONTEND_SUPPORTS_RGB565
320CFLAGS += -DHAVE_LIBRETRO
321
322ifneq ($(DYNAREC),lightrec)
323ifeq ($(MMAP_WIN32),1)
324OBJS += libpcsxcore/memmap_win32.o
325endif
326endif
327endif
328
329ifeq "$(USE_PLUGIN_LIB)" "1"
330OBJS += frontend/plugin_lib.o
331OBJS += frontend/libpicofe/linux/plat.o
332OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
333frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
334ifeq "$(HAVE_NEON)" "1"
335OBJS += frontend/libpicofe/arm/neon_scale2x.o
336OBJS += frontend/libpicofe/arm/neon_eagle2x.o
337frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
338frontend/libpicofe/arm/neon_eagle2x.o: CFLAGS += -DDO_BGR_TO_RGB
339endif
340endif
341ifeq "$(USE_FRONTEND)" "1"
342OBJS += frontend/menu.o
343OBJS += frontend/libpicofe/input.o
344frontend/menu.o: frontend/libpicofe/menu.c
345ifeq "$(HAVE_TSLIB)" "1"
346frontend/%.o: CFLAGS += -DHAVE_TSLIB
347OBJS += frontend/pl_gun_ts.o
348endif
349else
350CFLAGS += -DNO_FRONTEND
351endif
352
353# misc
354OBJS += frontend/main.o frontend/plugin.o
355
356
357frontend/menu.o frontend/main.o: frontend/revision.h
358frontend/plat_sdl.o frontend/libretro.o: frontend/revision.h
359
360frontend/libpicofe/%.c:
361 @echo "libpicofe module is missing, please run:"
362 @echo "git submodule init && git submodule update"
363 @exit 1
364
365libpcsxcore/gte_nf.o: libpcsxcore/gte.c
366 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
367
368frontend/revision.h: FORCE
369 @(git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
370 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
371 @rm $@_
372
373%.o: %.S
374 $(CC_AS) $(CFLAGS) -c $^ -o $@
375
376%.o: %.cpp
377 $(CXX) $(CXXFLAGS) -c -o $@ $<
378
379%.o: %.c
380 $(CC) $(CFLAGS) -c -o $@ $<
381
382target_: $(TARGET)
383
384$(TARGET): $(OBJS)
385ifeq ($(STATIC_LINKING), 1)
386 $(AR) rcs $@ $(OBJS)
387else
388 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
389endif
390
391clean: $(PLAT_CLEAN) clean_plugins
392 $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
393
394ifneq ($(PLUGINS),)
395plugins_: $(PLUGINS)
396
397$(PLUGINS):
398 make -C $(dir $@)
399
400clean_plugins:
401 make -C plugins/gpulib/ clean
402 for dir in $(PLUGINS) ; do \
403 $(MAKE) -C $$(dirname $$dir) clean; done
404else
405plugins_:
406clean_plugins:
407endif
408
409.PHONY: all clean target_ plugins_ clean_plugins FORCE
410
411# ----------- release -----------
412
413VER ?= $(shell git describe --always HEAD)
414
415ifeq "$(PLATFORM)" "generic"
416OUT = pcsx_rearmed_$(VER)
417
418rel: pcsx $(PLUGINS) \
419 frontend/pandora/skin readme.txt COPYING
420 rm -rf $(OUT)
421 mkdir -p $(OUT)/plugins
422 mkdir -p $(OUT)/bios
423 cp -r $^ $(OUT)/
424 mv $(OUT)/*.so* $(OUT)/plugins/
425 zip -9 -r $(OUT).zip $(OUT)
426endif
427
428ifeq "$(PLATFORM)" "pandora"
429PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
430
431rel: pcsx plugins/dfsound/pcsxr_spu_area3.out $(PLUGINS) \
432 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
433 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
434 rm -rf out
435 mkdir -p out/plugins
436 cp -r $^ out/
437 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
438 rm out/pcsx.pxml.templ
439 mv out/*.so out/plugins/
440 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
441endif
442
443ifeq "$(PLATFORM)" "caanoo"
444PLAT_CLEAN = caanoo_clean
445
446caanoo_clean:
447 $(RM) frontend/320240/pollux_set
448
449rel: pcsx $(PLUGINS) \
450 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
451 frontend/320240/pcsxb.png frontend/320240/skin \
452 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
453 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
454 frontend/320240/haptic_s.cfg \
455 readme.txt COPYING
456 rm -rf out
457 mkdir -p out/pcsx_rearmed/plugins
458 cp -r $^ out/pcsx_rearmed/
459 mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
460 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
461 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
462 mkdir out/pcsx_rearmed/lib/
463 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
464 mkdir out/pcsx_rearmed/bios/
465 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
466endif