unbreak build
[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
6
7DEBUG ?= 0
8DEBUG_SYMS ?= 0
9ASSERTS ?= 0
10HAVE_CHD ?= 1
11ifneq ($(DEBUG)$(DEBUG_SYMS), 00)
12CFLAGS += -ggdb
13endif
14ifneq ($(DEBUG), 1)
15CFLAGS += -O3
16ifneq ($(ASSERTS), 1)
17CFLAGS += -DNDEBUG
18endif
19endif
20ifeq ($(LOG_UNHANDLED), 1)
21CFLAGS += -DLOG_UNHANDLED
22endif
23ifndef NO_AUTODEPS
24AUTODEPFLAGS += -MMD -MP
25endif
26ifeq ($(DEBUG_ASAN), 1)
27CFLAGS += -fsanitize=address
28LDFLAGS += -fsanitize=address
29#LDFLAGS += -static-libasan
30endif
31ifeq ($(DEBUG_UBSAN), 1)
32CFLAGS += -fsanitize=undefined -fno-sanitize=shift-base
33LDFLAGS += -fsanitize=undefined
34endif
35#DRC_DBG = 1
36#PCNT = 1
37
38# Suppress minor warnings for dependencies
39deps/%: CFLAGS += -Wno-unused -Wno-unused-function
40
41all: config.mak target_ plugins_
42
43ifndef NO_CONFIG_MAK
44ifneq ($(wildcard config.mak),)
45config.mak: ./configure
46 @echo $@ is out-of-date, running configure
47 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
48include config.mak
49else
50config.mak:
51 @echo "Please run ./configure before running make!"
52 @exit 1
53endif
54else # NO_CONFIG_MAK
55config.mak:
56endif
57
58-include Makefile.local
59
60CC_LINK ?= $(CC)
61CC_AS ?= $(CC)
62LDFLAGS += $(MAIN_LDFLAGS)
63#EXTRA_LDFLAGS ?= -Wl,-Map=$@.map # not on some linkers
64LDLIBS += $(MAIN_LDLIBS)
65ifdef PCNT
66CFLAGS += -DPCNT
67endif
68
69ifneq ($(NO_FSECTIONS), 1)
70CFLAGS += -ffunction-sections -fdata-sections
71ifeq ($(GNU_LINKER),1)
72FSECTIONS_LDFLAGS ?= -Wl,--gc-sections
73LDFLAGS += $(FSECTIONS_LDFLAGS)
74endif
75endif # NO_FSECTIONS
76CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \
77 -DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \
78 -DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \
79 -DDISABLE_MEM_LUTS=0
80CXXFLAGS += $(CFLAGS)
81
82# core
83OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cdrom-async.o \
84 libpcsxcore/cheat.o libpcsxcore/database.o \
85 libpcsxcore/decode_xa.o libpcsxcore/mdec.o \
86 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
87 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o \
88 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o \
89 libpcsxcore/psxevents.o libpcsxcore/r3000a.o \
90 libpcsxcore/sio.o libpcsxcore/spu.o libpcsxcore/gpu.o
91OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
92#OBJS += libpcsxcore/debug.o libpcsxcore/socket.o libpcsxcore/disr3000a.o
93
94ifeq ($(WANT_ZLIB),1)
95ZLIB_DIR = deps/libchdr/deps/zlib-1.3.1
96CFLAGS += -I$(ZLIB_DIR)
97OBJS += $(ZLIB_DIR)/adler32.o \
98 $(ZLIB_DIR)/compress.o \
99 $(ZLIB_DIR)/crc32.o \
100 $(ZLIB_DIR)/deflate.o \
101 $(ZLIB_DIR)/gzclose.o \
102 $(ZLIB_DIR)/gzlib.o \
103 $(ZLIB_DIR)/gzread.o \
104 $(ZLIB_DIR)/gzwrite.o \
105 $(ZLIB_DIR)/infback.o \
106 $(ZLIB_DIR)/inffast.o \
107 $(ZLIB_DIR)/inflate.o \
108 $(ZLIB_DIR)/inftrees.o \
109 $(ZLIB_DIR)/trees.o \
110 $(ZLIB_DIR)/uncompr.o \
111 $(ZLIB_DIR)/zutil.o
112$(ZLIB_DIR)/%.o: CFLAGS += -DHAVE_UNISTD_H
113endif
114
115ifeq "$(ARCH)" "arm"
116OBJS += libpcsxcore/gte_arm.o
117endif
118ifeq "$(HAVE_NEON_ASM)" "1"
119OBJS += libpcsxcore/gte_neon.o
120endif
121libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
122
123ifeq ($(MMAP_WIN32),1)
124CFLAGS += -Iinclude/mman -Ideps/mman
125OBJS += deps/mman/mman.o
126endif
127ifeq "$(USE_ASYNC_CDROM)" "1"
128libpcsxcore/cdrom-async.o: CFLAGS += -DUSE_ASYNC_CDROM
129frontend/libretro.o: CFLAGS += -DUSE_ASYNC_CDROM
130frontend/menu.o: CFLAGS += -DUSE_ASYNC_CDROM
131USE_RTHREADS := 1
132endif
133ifeq "$(USE_ASYNC_GPU)" "1"
134frontend/libretro.o: CFLAGS += -DUSE_ASYNC_GPU
135frontend/menu.o: CFLAGS += -DUSE_ASYNC_GPU
136USE_RTHREADS := 1
137endif
138
139# dynarec
140ifeq "$(DYNAREC)" "lightrec"
141CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \
142 -DLIGHTREC -DLIGHTREC_STATIC
143ifeq ($(LIGHTREC_DEBUG),1)
144deps/lightrec/%.o: CFLAGS += -DLOG_LEVEL=DEBUG_L
145libpcsxcore/lightrec/plugin.o: CFLAGS += -DLIGHTREC_DEBUG=1
146frontend/main.o: CFLAGS += -DLIGHTREC_DEBUG=1
147deps/lightning/%.o: CFLAGS += -DDISASSEMBLER=1 -DBINUTILS_2_38=1 -DBINUTILS_2_29=1 \
148 -DHAVE_DISASSEMBLE_INIT_FOR_TARGET=1 -DPACKAGE_VERSION=1
149LDFLAGS += -lopcodes -lbfd
150endif
151LIGHTREC_CUSTOM_MAP ?= 0
152LIGHTREC_CUSTOM_MAP_OBJ ?= libpcsxcore/lightrec/mem.o
153LIGHTREC_THREADED_COMPILER ?= 0
154LIGHTREC_CODE_INV ?= 0
155CFLAGS += -DLIGHTREC_CUSTOM_MAP=$(LIGHTREC_CUSTOM_MAP) \
156 -DLIGHTREC_CODE_INV=$(LIGHTREC_CODE_INV) \
157 -DLIGHTREC_ENABLE_THREADED_COMPILER=$(LIGHTREC_THREADED_COMPILER) \
158 -DLIGHTREC_ENABLE_DISASSEMBLER=$(or $(LIGHTREC_DEBUG),0) \
159 -DLIGHTREC_NO_DEBUG=$(if $(LIGHTREC_DEBUG),0,1)
160ifeq ($(LIGHTREC_CUSTOM_MAP),1)
161LDLIBS += -lrt
162OBJS += $(LIGHTREC_CUSTOM_MAP_OBJ)
163endif
164ifeq ($(NEED_SYSCONF),1)
165OBJS += libpcsxcore/lightrec/sysconf.o
166endif
167ifeq ($(LIGHTREC_THREADED_COMPILER),1)
168OBJS += deps/lightrec/recompiler.o \
169 deps/lightrec/reaper.o
170endif
171OBJS += deps/lightrec/tlsf/tlsf.o
172OBJS += libpcsxcore/lightrec/plugin.o
173OBJS += deps/lightning/lib/jit_disasm.o \
174 deps/lightning/lib/jit_memory.o \
175 deps/lightning/lib/jit_names.o \
176 deps/lightning/lib/jit_note.o \
177 deps/lightning/lib/jit_print.o \
178 deps/lightning/lib/jit_size.o \
179 deps/lightning/lib/lightning.o \
180 deps/lightrec/blockcache.o \
181 deps/lightrec/constprop.o \
182 deps/lightrec/disassembler.o \
183 deps/lightrec/emitter.o \
184 deps/lightrec/interpreter.o \
185 deps/lightrec/lightrec.o \
186 deps/lightrec/memmanager.o \
187 deps/lightrec/optimizer.o \
188 deps/lightrec/regcache.o
189deps/lightning/%.o: CFLAGS += -DHAVE_MMAP=P_HAVE_MMAP
190deps/lightning/%: CFLAGS += -Wno-uninitialized
191deps/lightrec/%: CFLAGS += -Wno-uninitialized
192libpcsxcore/lightrec/mem.o: CFLAGS += -D_GNU_SOURCE
193ifeq ($(MMAP_WIN32),1)
194deps/lightning/lib/lightning.o: CFLAGS += -Dmprotect=_mprotect # deps/mman
195deps/lightning/lib/jit_print.o: CFLAGS += -w
196endif
197else ifeq "$(DYNAREC)" "ari64"
198OBJS += libpcsxcore/new_dynarec/new_dynarec.o
199OBJS += libpcsxcore/new_dynarec/pcsxmem.o
200 ifeq "$(ARCH)" "arm"
201 OBJS += libpcsxcore/new_dynarec/linkage_arm.o
202 else ifneq (,$(findstring $(ARCH),aarch64 arm64))
203 OBJS += libpcsxcore/new_dynarec/linkage_arm64.o
204 else
205 $(error no dynarec support for architecture $(ARCH))
206 endif
207 ifeq "$(NDRC_THREAD)" "1"
208 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -DNDRC_THREAD
209 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DNDRC_THREAD
210 frontend/libretro.o: CFLAGS += -DNDRC_THREAD
211 USE_RTHREADS := 1
212 endif
213else
214CFLAGS += -DDRC_DISABLE
215endif
216OBJS += libpcsxcore/new_dynarec/emu_if.o
217ifdef DRC_DBG
218libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
219CFLAGS += -DDRC_DBG
220endif
221ifeq "$(BASE_ADDR_DYNAMIC)" "1"
222libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_DYNAMIC=1
223endif
224
225# spu
226OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
227 plugins/dfsound/registers.o plugins/dfsound/spu.o \
228 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
229ifeq "$(ARCH)" "arm"
230OBJS += plugins/dfsound/arm_utils.o
231endif
232ifeq "$(HAVE_C64_TOOLS)" "1"
233plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE
234frontend/menu.o: CFLAGS += -DC64X_DSP
235endif
236ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
237plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
238OBJS += plugins/dfsound/oss.o
239endif
240ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
241plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
242OBJS += plugins/dfsound/alsa.o
243LDLIBS += -lasound
244endif
245ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
246plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
247OBJS += plugins/dfsound/sdl.o
248endif
249ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
250plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
251OBJS += plugins/dfsound/pulseaudio.o
252endif
253ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
254plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
255endif
256
257# supported gpu list in menu
258ifeq "$(HAVE_NEON_GPU)" "1"
259frontend/menu.o: CFLAGS += -DGPU_NEON
260endif
261ifeq "$(HAVE_GLES)" "1"
262frontend/menu.o: CFLAGS += -DHAVE_GLES
263endif
264
265# builtin gpu
266OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o plugins/gpulib/prim.o
267ifeq "$(USE_ASYNC_GPU)" "1"
268OBJS += plugins/gpulib/gpu_async.o
269plugins/gpulib/%.o: CFLAGS += -DUSE_ASYNC_GPU
270endif
271ifeq "$(BUILTIN_GPU)" "neon"
272CFLAGS += -DGPU_NEON
273OBJS += plugins/gpu_neon/psx_gpu_if.o
274plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
275frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_NEON
276 ifeq "$(HAVE_NEON_ASM)" "1"
277 OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
278 else
279 OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_simd.o
280 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DSIMD_BUILD
281 plugins/gpu_neon/psx_gpu/psx_gpu_simd.o: CFLAGS += -DSIMD_BUILD
282 endif
283endif
284ifeq "$(BUILTIN_GPU)" "peops"
285CFLAGS += -DGPU_PEOPS
286# note: code is not safe for strict-aliasing? (Castlevania problems)
287plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
288frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_PEOPS
289OBJS += plugins/dfxvideo/gpulib_if.o
290endif
291
292ifeq "$(BUILTIN_GPU)" "unai"
293CFLAGS += -DGPU_UNAI
294CFLAGS += -DUSE_GPULIB=1
295OBJS += plugins/gpu_unai/gpulib_if.o
296ifeq "$(ARCH)" "arm"
297OBJS += plugins/gpu_unai/gpu_arm.o
298endif
299ifneq "$(GPU_UNAI_NO_OLD)" "1"
300OBJS += plugins/gpu_unai/old/if.o
301else
302CFLAGS += -DGPU_UNAI_NO_OLD
303endif
304plugins/gpu_unai/gpulib_if.o: plugins/gpu_unai/*.h
305plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1
306frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_UNAI
307ifneq ($(DEBUG), 1)
308plugins/gpu_unai/gpulib_if.o \
309plugins/gpu_unai/old/if.o: CFLAGS += -O3
310endif
311CC_LINK = $(CXX)
312endif
313
314# libchdr
315ifeq "$(HAVE_CHD)" "1"
316LCHDR = deps/libchdr
317LCHDR_LZMA = $(LCHDR)/deps/lzma-24.05
318LCHDR_ZSTD = $(LCHDR)/deps/zstd-1.5.6/lib
319OBJS += $(LCHDR)/src/libchdr_bitstream.o
320OBJS += $(LCHDR)/src/libchdr_cdrom.o
321OBJS += $(LCHDR)/src/libchdr_chd.o
322OBJS += $(LCHDR)/src/libchdr_flac.o
323OBJS += $(LCHDR)/src/libchdr_huffman.o
324$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -Wno-maybe-uninitialized -std=gnu11
325OBJS += $(LCHDR_LZMA)/src/Alloc.o
326OBJS += $(LCHDR_LZMA)/src/CpuArch.o
327OBJS += $(LCHDR_LZMA)/src/Delta.o
328OBJS += $(LCHDR_LZMA)/src/LzFind.o
329OBJS += $(LCHDR_LZMA)/src/LzmaDec.o
330OBJS += $(LCHDR_LZMA)/src/LzmaEnc.o
331OBJS += $(LCHDR_LZMA)/src/Sort.o
332$(LCHDR_LZMA)/src/%.o: CFLAGS += -Wno-unused -DZ7_ST -I$(LCHDR_LZMA)/include
333$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_LZMA)/include
334OBJS += $(LCHDR_ZSTD)/common/entropy_common.o
335OBJS += $(LCHDR_ZSTD)/common/error_private.o
336OBJS += $(LCHDR_ZSTD)/common/fse_decompress.o
337OBJS += $(LCHDR_ZSTD)/common/xxhash.o
338OBJS += $(LCHDR_ZSTD)/common/zstd_common.o
339OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress.o
340OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress_amd64.o
341OBJS += $(LCHDR_ZSTD)/decompress/zstd_ddict.o
342OBJS += $(LCHDR_ZSTD)/decompress/zstd_decompress_block.o
343OBJS += $(LCHDR_ZSTD)/decompress/zstd_decompress.o
344$(LCHDR_ZSTD)/common/%.o \
345$(LCHDR_ZSTD)/decompress/%.o: CFLAGS += -I$(LCHDR_ZSTD)
346$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_ZSTD)
347libpcsxcore/cdriso.o: CFLAGS += -Wno-unused-function
348CFLAGS += -DHAVE_CHD -I$(LCHDR)/include
349endif
350
351# frontend/gui
352OBJS += frontend/cspace.o
353ifeq "$(HAVE_NEON_ASM)" "1"
354OBJS += frontend/cspace_neon.o
355frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x
356else
357ifeq "$(ARCH)" "arm"
358OBJS += frontend/cspace_arm.o
359frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565
360endif
361endif
362
363ifeq "$(PLATFORM)" "generic"
364OBJS += frontend/libpicofe/in_sdl.o
365#OBJS += frontend/libpicofe/plat_sdl.o
366OBJS += frontend/libpicofe/plat_dummy.o
367OBJS += frontend/plat_sdl.o
368frontend/plat_sdl.o frontend/libpicofe/plat_sdl.o: CFLAGS += -DSDL_OVERLAY_2X
369frontend/menu.o: CFLAGS += -DSDL_OVERLAY_2X -DMENU_SHOW_VARSCALER=1
370ifeq "$(HAVE_EVDEV)" "1"
371OBJS += frontend/libpicofe/linux/in_evdev.o
372endif
373ifeq "$(HAVE_GLES)" "1"
374OBJS += frontend/libpicofe/gl.o frontend/libpicofe/gl_platform.o
375OBJS += frontend/libpicofe/gl_loader.o
376#LDLIBS += $(LDLIBS_GLES) # loaded dynamically now
377frontend/libpicofe/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
378frontend/libpicofe/gl_platform.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
379frontend/libpicofe/gl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
380frontend/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
381endif
382USE_PLUGIN_LIB = 1
383USE_FRONTEND = 1
384endif
385ifeq "$(PLATFORM)" "pandora"
386OBJS += frontend/libpicofe/pandora/plat.o
387OBJS += frontend/libpicofe/linux/fbdev.o frontend/libpicofe/linux/xenv.o
388OBJS += frontend/libpicofe/linux/in_evdev.o
389OBJS += frontend/plat_pandora.o frontend/plat_omap.o
390frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
391frontend/main.o frontend/plugin_lib.o: CFLAGS += -DPANDORA
392frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
393USE_PLUGIN_LIB = 1
394USE_FRONTEND = 1
395CFLAGS += -gdwarf-3
396endif
397ifeq "$(PLATFORM)" "caanoo"
398OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o
399OBJS += frontend/libpicofe/gp2x/soc_pollux.o
400OBJS += frontend/libpicofe/linux/in_evdev.o
401OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
402frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h
403USE_PLUGIN_LIB = 1
404USE_FRONTEND = 1
405endif
406ifeq "$(PLATFORM)" "miyoo"
407HOMEPATH = /mnt
408OBJS += frontend/libpicofe/in_sdl.o
409OBJS += frontend/libpicofe/linux/in_evdev.o
410OBJS += frontend/libpicofe/plat_dummy.o
411OBJS += frontend/plat_sdl.o
412frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_miyoo.h
413USE_PLUGIN_LIB = 1
414USE_FRONTEND = 1
415endif
416ifeq "$(PLATFORM)" "maemo"
417OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o
418USE_PLUGIN_LIB = 1
419LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse)
420CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB
421CFLAGS += `pkg-config --cflags glib-2.0 libosso dbus-1 hildon-fm-2`
422LDFLAGS += `pkg-config --libs glib-2.0 libosso dbus-1 hildon-fm-2`
423endif
424ifeq "$(PLATFORM)" "libretro"
425ifneq "$(HAVE_PHYSICAL_CDROM)$(USE_LIBRETRO_VFS)" "00"
426OBJS += deps/libretro-common/compat/compat_strl.o
427OBJS += deps/libretro-common/file/file_path.o
428OBJS += deps/libretro-common/string/stdstring.o
429OBJS += deps/libretro-common/vfs/vfs_implementation.o
430endif
431ifeq "$(HAVE_PHYSICAL_CDROM)" "1"
432OBJS += frontend/libretro-cdrom.o
433OBJS += deps/libretro-common/lists/string_list.o
434OBJS += deps/libretro-common/memmap/memalign.o
435OBJS += deps/libretro-common/vfs/vfs_implementation_cdrom.o
436CFLAGS += -DHAVE_CDROM
437endif
438ifeq "$(USE_LIBRETRO_VFS)" "1"
439OBJS += deps/libretro-common/compat/compat_posix_string.o
440OBJS += deps/libretro-common/compat/fopen_utf8.o
441OBJS += deps/libretro-common/encodings/encoding_utf.o
442OBJS += deps/libretro-common/streams/file_stream.o
443OBJS += deps/libretro-common/streams/file_stream_transforms.o
444OBJS += deps/libretro-common/time/rtime.o
445CFLAGS += -DUSE_LIBRETRO_VFS
446endif
447OBJS += frontend/libretro.o
448CFLAGS += -DHAVE_LIBRETRO
449INC_LIBRETRO_COMMON := 1
450
451endif # $(PLATFORM) == "libretro"
452
453ifeq "$(USE_RTHREADS)" "1"
454OBJS += frontend/pcsxr-threads.o
455OBJS += deps/libretro-common/features/features_cpu.o
456frontend/main.o: CFLAGS += -DHAVE_RTHREADS
457INC_LIBRETRO_COMMON := 1
458endif
459ifeq "$(INC_LIBRETRO_COMMON)" "1"
460CFLAGS += -Ideps/libretro-common/include
461endif
462
463ifeq "$(USE_PLUGIN_LIB)" "1"
464OBJS += frontend/plugin_lib.o
465OBJS += frontend/libpicofe/linux/plat.o
466OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
467frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
468ifeq "$(HAVE_NEON_ASM)" "1"
469OBJS += frontend/libpicofe/arm/neon_scale2x.o
470OBJS += frontend/libpicofe/arm/neon_eagle2x.o
471frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
472frontend/libpicofe/arm/neon_eagle2x.o: CFLAGS += -DDO_BGR_TO_RGB
473endif
474endif
475ifeq "$(USE_FRONTEND)" "1"
476OBJS += frontend/menu.o
477OBJS += frontend/libpicofe/input.o
478frontend/libpicofe/input.o: CFLAGS += -Wno-array-bounds
479ifeq "$(HAVE_TSLIB)" "1"
480frontend/%.o: CFLAGS += -DHAVE_TSLIB
481OBJS += frontend/pl_gun_ts.o
482endif
483else
484CFLAGS += -DNO_FRONTEND
485endif
486
487# misc
488OBJS += frontend/main.o frontend/plugin.o
489frontend/main.o libpcsxcore/misc.o: CFLAGS += -DBUILTIN_GPU=$(BUILTIN_GPU)
490
491frontend/menu.o frontend/main.o: include/revision.h
492frontend/plat_sdl.o frontend/libretro.o: include/revision.h
493libpcsxcore/misc.o: include/revision.h
494
495CFLAGS += $(CFLAGS_LAST)
496
497frontend/libpicofe/%.c:
498 @echo "libpicofe module is missing, please run:"
499 @echo "git submodule init && git submodule update"
500 @exit 1
501
502libpcsxcore/gte_nf.o: libpcsxcore/gte.c
503 $(CC) -c -o $@ $< $(CFLAGS) $(AUTODEPFLAGS) -DFLAGLESS
504
505include/revision.h: FORCE
506 @(git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
507 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
508 @rm $@_
509
510%.o: %.cpp
511 $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(AUTODEPFLAGS) -c $< -o $@
512
513%.o: %.c
514 $(CC) $(CPPFLAGS) $(CFLAGS) $(AUTODEPFLAGS) -c $< -o $@
515
516%.o: %.S
517 $(CC_AS) $(CPPFLAGS) $(CFLAGS) $(AUTODEPFLAGS) -c $< -o $@
518
519
520target_: $(TARGET)
521
522$(TARGET): $(OBJS)
523ifeq ($(PARTIAL_LINKING), 1)
524 $(LD) -o $(basename $(TARGET))1.o -r --gc-sections $(addprefix -u ,$(shell cat frontend/libretro-extern)) $(addprefix -u ,$(EXTRA_EXTERN_SYMS)) $^
525 $(OBJCOPY) --keep-global-symbols=frontend/libretro-extern $(addprefix -G ,$(EXTRA_EXTERN_SYMS)) $(basename $(TARGET))1.o $(basename $(TARGET)).o
526 $(AR) rcs $@ $(basename $(TARGET)).o
527else ifeq ($(STATIC_LINKING), 1)
528 $(AR) rcs $@ $^
529else
530 $(CC_LINK) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
531endif
532
533clean: $(PLAT_CLEAN) clean_plugins
534 $(RM) $(TARGET) *.o $(OBJS) $(OBJS:.o=.d) $(TARGET).map include/revision.h
535
536ifneq ($(PLUGINS),)
537plugins_: $(PLUGINS)
538
539plugins/gpulib/gpulib.$(ARCH).a:
540 $(MAKE) -C plugins/gpulib/
541
542$(PLUGINS): plugins/gpulib/gpulib.$(ARCH).a
543 $(MAKE) -C $(dir $@)
544
545clean_plugins:
546 $(MAKE) -C plugins/gpulib/ clean
547 for dir in $(PLUGINS) ; do \
548 $(MAKE) -C $$(dirname $$dir) clean; done
549else
550plugins_:
551clean_plugins:
552endif
553
554ifndef NO_AUTODEPS
555$(OBJS:.o=.d): ;
556-include $(OBJS:.o=.d)
557endif
558
559.PHONY: all clean target_ plugins_ clean_plugins FORCE
560
561ifneq "$(PLATFORM)" "pandora"
562ifdef CPATH
563$(warning warning: CPATH is defined)
564endif
565endif
566
567# ----------- release -----------
568
569VER ?= $(shell git describe --always HEAD)
570
571ifeq "$(PLATFORM)" "generic"
572OUT = pcsx_rearmed_$(VER)
573
574rel: pcsx $(PLUGINS) \
575 frontend/pandora/skin README.md COPYING
576 rm -rf $(OUT)
577 mkdir -p $(OUT)/plugins
578 mkdir -p $(OUT)/bios
579 cp -r $^ $(OUT)/
580 -mv $(OUT)/*.so* $(OUT)/plugins/
581 zip -9 -r $(OUT).zip $(OUT)
582endif
583
584ifeq "$(PLATFORM)" "pandora"
585PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
586
587rel: pcsx plugins/dfsound/pcsxr_spu_area3.out $(PLUGINS) \
588 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
589 frontend/pandora/picorestore frontend/pandora/skin frontend/pandora/readme.txt COPYING
590 rm -rf out
591 mkdir -p out/plugins
592 cp -r $^ out/
593 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
594 rm out/pcsx.pxml.templ
595 -mv out/*.so out/plugins/
596 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
597endif
598
599ifeq "$(PLATFORM)" "miyoo"
600
601rel: pcsx $(PLUGINS) \
602 frontend/320240/pcsx26.png \
603 frontend/320240/skin \
604 README.md COPYING
605 rm -rf out
606 mkdir -p out/pcsx_rearmed/plugins
607 cp -r $^ out/pcsx_rearmed/
608 -mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
609 mkdir out/pcsx_rearmed/lib/
610 mkdir out/pcsx_rearmed/bios/
611 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_miyoo.zip *
612
613ipk: rel
614 VERSION="$(VER)" gm2xpkg -q -f miyoo/pkg.cfg
615 mv pcsx.ipk pcsx_rearmed.ipk
616endif
617
618ifeq "$(PLATFORM)" "caanoo"
619PLAT_CLEAN = caanoo_clean
620
621caanoo_clean:
622 $(RM) frontend/320240/pollux_set
623
624rel: pcsx $(PLUGINS) \
625 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
626 frontend/320240/pcsxb.png frontend/320240/skin \
627 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
628 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
629 frontend/320240/haptic_s.cfg \
630 COPYING
631 rm -rf out
632 mkdir -p out/pcsx_rearmed/plugins
633 cp -r $^ out/pcsx_rearmed/
634 -mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
635 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
636 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
637 mkdir out/pcsx_rearmed/lib/
638 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
639 mkdir out/pcsx_rearmed/bios/
640 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
641endif