merge from libretro
[pcsx_rearmed.git] / Makefile
CommitLineData
4132e8ca 1# Makefile for PCSX ReARMed
a80ae4a0 2
61bc6d40 3# default stuff goes here, so that config can override
9aff1963 4TARGET ?= pcsx
41846131 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)
fad9f755 15CFLAGS += -O2
79c4d434 16ifneq ($(ASSERTS), 1)
fad9f755 17CFLAGS += -DNDEBUG
18endif
b60f2812 19endif
36c76c86
PC
20ifeq ($(DEBUG_ASAN), 1)
21CFLAGS += -fsanitize=address
5dd884df 22LDFLAGS += -fsanitize=address
23#LDFLAGS += -static-libasan
36c76c86 24endif
fad9f755 25ifneq ($(NO_FSECTIONS), 1)
26CFLAGS += -ffunction-sections -fdata-sections
e6f13b47 27FSECTIONS_LDFLAGS ?= -Wl,--gc-sections
28LDFLAGS += $(FSECTIONS_LDFLAGS)
fad9f755 29endif
9165d434 30CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \
31 -DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \
4bb8d7e1
PC
32 -DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \
33 -DDISABLE_MEM_LUTS=0
61bc6d40 34CXXFLAGS += $(CFLAGS)
4132e8ca 35#DRC_DBG = 1
36#PCNT = 1
80c2304e 37
a4c71501 38# Suppress minor warnings for dependencies
39deps/%: CFLAGS += -Wno-unused -Wno-unused-function
40
38c2028e 41all: config.mak target_ plugins_
de38f20e 42
9aff1963 43ifndef NO_CONFIG_MAK
4132e8ca 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
9aff1963 54else # NO_CONFIG_MAK
55config.mak:
56endif
57
4132e8ca 58-include Makefile.local
80c2304e 59
9aff1963 60CC_LINK ?= $(CC)
61CC_AS ?= $(CC)
22fa3f2b 62LDFLAGS += $(MAIN_LDFLAGS)
9aff1963 63EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
07c13dfd 64LDLIBS += $(MAIN_LDLIBS)
e0aec5ee 65ifdef PCNT
66CFLAGS += -DPCNT
67endif
61bc6d40 68
80c2304e 69# core
08d9d257 70OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cdrom-async.o \
71 libpcsxcore/cheat.o libpcsxcore/database.o \
7d7672a5 72 libpcsxcore/decode_xa.o libpcsxcore/mdec.o \
80c2304e 73 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
0890ae15 74 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o \
9a0a61d2 75 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o \
76 libpcsxcore/psxevents.o libpcsxcore/r3000a.o \
abf09485 77 libpcsxcore/sio.o libpcsxcore/spu.o libpcsxcore/gpu.o
59774ed0 78OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
7d7672a5 79#OBJS += libpcsxcore/debug.o libpcsxcore/socket.o libpcsxcore/disr3000a.o
79c4d434 80
81ifeq ($(WANT_ZLIB),1)
82ZLIB_DIR = deps/libchdr/deps/zlib-1.3.1
83CFLAGS += -I$(ZLIB_DIR)
84OBJS += $(ZLIB_DIR)/adler32.o \
85 $(ZLIB_DIR)/compress.o \
86 $(ZLIB_DIR)/crc32.o \
87 $(ZLIB_DIR)/deflate.o \
88 $(ZLIB_DIR)/gzclose.o \
89 $(ZLIB_DIR)/gzlib.o \
90 $(ZLIB_DIR)/gzread.o \
91 $(ZLIB_DIR)/gzwrite.o \
92 $(ZLIB_DIR)/infback.o \
93 $(ZLIB_DIR)/inffast.o \
94 $(ZLIB_DIR)/inflate.o \
95 $(ZLIB_DIR)/inftrees.o \
96 $(ZLIB_DIR)/trees.o \
97 $(ZLIB_DIR)/uncompr.o \
98 $(ZLIB_DIR)/zutil.o
99$(ZLIB_DIR)/%.o: CFLAGS += -DHAVE_UNISTD_H
100endif
101
59774ed0 102ifeq "$(ARCH)" "arm"
103OBJS += libpcsxcore/gte_arm.o
104endif
57467c77 105ifeq "$(HAVE_NEON_ASM)" "1"
8cfbda97 106OBJS += libpcsxcore/gte_neon.o
107endif
305c8c93 108libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
ab948f7e 109
fad9f755 110ifeq "$(USE_ASYNC_CDROM)" "1"
111libpcsxcore/cdrom-async.o: CFLAGS += -DUSE_ASYNC_CDROM
112frontend/libretro.o: CFLAGS += -DUSE_ASYNC_CDROM
113frontend/menu.o: CFLAGS += -DUSE_ASYNC_CDROM
114USE_RTHREADS := 1
115endif
116
f95a77f7 117# dynarec
a4c71501 118ifeq "$(DYNAREC)" "lightrec"
119CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \
120 -DLIGHTREC -DLIGHTREC_STATIC
121LIGHTREC_CUSTOM_MAP ?= 0
122LIGHTREC_CUSTOM_MAP_OBJ ?= libpcsxcore/lightrec/mem.o
123LIGHTREC_THREADED_COMPILER ?= 0
124LIGHTREC_CODE_INV ?= 0
125CFLAGS += -DLIGHTREC_CUSTOM_MAP=$(LIGHTREC_CUSTOM_MAP) \
126 -DLIGHTREC_CODE_INV=$(LIGHTREC_CODE_INV) \
127 -DLIGHTREC_ENABLE_THREADED_COMPILER=$(LIGHTREC_THREADED_COMPILER)
128ifeq ($(LIGHTREC_CUSTOM_MAP),1)
129LDLIBS += -lrt
130OBJS += $(LIGHTREC_CUSTOM_MAP_OBJ)
131endif
132ifeq ($(NEED_SYSCONF),1)
133OBJS += libpcsxcore/lightrec/sysconf.o
134endif
135ifeq ($(LIGHTREC_THREADED_COMPILER),1)
136OBJS += deps/lightrec/recompiler.o \
137 deps/lightrec/reaper.o
138endif
139OBJS += deps/lightrec/tlsf/tlsf.o
140OBJS += libpcsxcore/lightrec/plugin.o
141OBJS += deps/lightning/lib/jit_disasm.o \
142 deps/lightning/lib/jit_memory.o \
143 deps/lightning/lib/jit_names.o \
144 deps/lightning/lib/jit_note.o \
145 deps/lightning/lib/jit_print.o \
146 deps/lightning/lib/jit_size.o \
147 deps/lightning/lib/lightning.o \
148 deps/lightrec/blockcache.o \
149 deps/lightrec/constprop.o \
150 deps/lightrec/disassembler.o \
151 deps/lightrec/emitter.o \
152 deps/lightrec/interpreter.o \
153 deps/lightrec/lightrec.o \
154 deps/lightrec/memmanager.o \
155 deps/lightrec/optimizer.o \
156 deps/lightrec/regcache.o
157deps/lightning/%.o: CFLAGS += -DHAVE_MMAP=P_HAVE_MMAP
158deps/lightning/%: CFLAGS += -Wno-uninitialized
159deps/lightrec/%: CFLAGS += -Wno-uninitialized
160libpcsxcore/lightrec/mem.o: CFLAGS += -D_GNU_SOURCE
161ifeq ($(MMAP_WIN32),1)
162CFLAGS += -Iinclude/mman -I deps/mman
163OBJS += deps/mman/mman.o
164endif
165else ifeq "$(DYNAREC)" "ari64"
be516ebe 166OBJS += libpcsxcore/new_dynarec/new_dynarec.o
7e605697 167OBJS += libpcsxcore/new_dynarec/pcsxmem.o
be516ebe 168 ifeq "$(ARCH)" "arm"
169 OBJS += libpcsxcore/new_dynarec/linkage_arm.o
687b4580 170 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
57467c77 171 else ifneq (,$(findstring $(ARCH),aarch64 arm64))
be516ebe 172 OBJS += libpcsxcore/new_dynarec/linkage_arm64.o
687b4580 173 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm64.c
be516ebe 174 else
175 $(error no dynarec support for architecture $(ARCH))
176 endif
0b1633d7 177 ifeq "$(NDRC_THREAD)" "1"
178 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -DNDRC_THREAD
179 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -DNDRC_THREAD
180 frontend/libretro.o: CFLAGS += -DNDRC_THREAD
181 USE_RTHREADS := 1
182 endif
448bbcae 183else
41e82ad4 184CFLAGS += -DDRC_DISABLE
7139f3c8 185endif
9a0a61d2 186OBJS += libpcsxcore/new_dynarec/emu_if.o
687b4580 187libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/pcsxmem_inline.c
3eb78778 188ifdef DRC_DBG
189libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
190CFLAGS += -DDRC_DBG
191endif
2a014d73 192ifeq "$(BASE_ADDR_DYNAMIC)" "1"
193libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_DYNAMIC=1
a327ad27 194endif
f95a77f7 195
e906c010 196# spu
ee849648 197OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
07c13dfd 198 plugins/dfsound/registers.o plugins/dfsound/spu.o \
199 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
6d866bb7 200plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
201 plugins/dfsound/xa.c
3a721c1f 202ifeq "$(ARCH)" "arm"
b17618c0 203OBJS += plugins/dfsound/arm_utils.o
204endif
5514a050 205ifeq "$(HAVE_C64_TOOLS)" "1"
42dde520 206plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE
5514a050 207plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c
8886a808 208frontend/menu.o: CFLAGS += -DC64X_DSP
5514a050 209endif
07c13dfd 210ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
211plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
de38f20e 212OBJS += plugins/dfsound/oss.o
213endif
07c13dfd 214ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
215plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
de38f20e 216OBJS += plugins/dfsound/alsa.o
4132e8ca 217LDLIBS += -lasound
218endif
07c13dfd 219ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
220plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
d8a2f79b 221OBJS += plugins/dfsound/sdl.o
222endif
07c13dfd 223ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
224plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
225OBJS += plugins/dfsound/pulseaudio.o
226endif
227ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
228plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
de38f20e 229endif
230
61bc6d40 231# builtin gpu
232OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
61bc6d40 233ifeq "$(BUILTIN_GPU)" "neon"
79c4d434 234CFLAGS += -DGPU_NEON
57467c77 235OBJS += plugins/gpu_neon/psx_gpu_if.o
90ca4913 236plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
237plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
57467c77 238frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_NEON
239 ifeq "$(HAVE_NEON_ASM)" "1"
240 OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
241 else
242 OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_simd.o
243 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DSIMD_BUILD
244 plugins/gpu_neon/psx_gpu/psx_gpu_simd.o: CFLAGS += -DSIMD_BUILD
245 endif
61bc6d40 246endif
247ifeq "$(BUILTIN_GPU)" "peops"
79c4d434 248CFLAGS += -DGPU_PEOPS
2ef486ee 249# note: code is not safe for strict-aliasing? (Castlevania problems)
62d7fa95 250plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
251plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
252OBJS += plugins/dfxvideo/gpulib_if.o
79c4d434 253ifeq "$(THREAD_RENDERING)" "1"
254CFLAGS += -DTHREAD_RENDERING
255OBJS += plugins/gpulib/gpulib_thread_if.o
256endif
90ca4913 257endif
e0c692d9 258
4cfc568d 259ifeq "$(BUILTIN_GPU)" "unai"
79c4d434 260CFLAGS += -DGPU_UNAI
261CFLAGS += -DUSE_GPULIB=1
4cfc568d 262OBJS += plugins/gpu_unai/gpulib_if.o
0bfe8d59 263ifeq "$(ARCH)" "arm"
4cfc568d 264OBJS += plugins/gpu_unai/gpu_arm.o
0bfe8d59 265endif
5ddc3a7a 266ifeq "$(THREAD_RENDERING)" "1"
267CFLAGS += -DTHREAD_RENDERING
268OBJS += plugins/gpulib/gpulib_thread_if.o
269endif
270ifneq "$(GPU_UNAI_NO_OLD)" "1"
271OBJS += plugins/gpu_unai/old/if.o
272else
273CFLAGS += -DGPU_UNAI_NO_OLD
274endif
275plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1
276plugins/gpu_unai/gpulib_if.o \
277plugins/gpu_unai/old/if.o: CFLAGS += -O3
0bfe8d59 278CC_LINK = $(CXX)
279endif
280
a51adab4 281# libchdr
79c4d434 282ifeq "$(HAVE_CHD)" "1"
58126d96 283LCHDR = deps/libchdr
8c065899 284LCHDR_LZMA = $(LCHDR)/deps/lzma-24.05
285LCHDR_ZSTD = $(LCHDR)/deps/zstd-1.5.6/lib
58126d96 286OBJS += $(LCHDR)/src/libchdr_bitstream.o
287OBJS += $(LCHDR)/src/libchdr_cdrom.o
288OBJS += $(LCHDR)/src/libchdr_chd.o
289OBJS += $(LCHDR)/src/libchdr_flac.o
290OBJS += $(LCHDR)/src/libchdr_huffman.o
a4c71501 291$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -Wno-maybe-uninitialized -std=gnu11
58126d96 292OBJS += $(LCHDR_LZMA)/src/Alloc.o
58126d96 293OBJS += $(LCHDR_LZMA)/src/CpuArch.o
294OBJS += $(LCHDR_LZMA)/src/Delta.o
295OBJS += $(LCHDR_LZMA)/src/LzFind.o
58126d96 296OBJS += $(LCHDR_LZMA)/src/LzmaDec.o
297OBJS += $(LCHDR_LZMA)/src/LzmaEnc.o
298OBJS += $(LCHDR_LZMA)/src/Sort.o
8c065899 299$(LCHDR_LZMA)/src/%.o: CFLAGS += -Wno-unused -DZ7_ST -I$(LCHDR_LZMA)/include
58126d96 300$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_LZMA)/include
58126d96 301OBJS += $(LCHDR_ZSTD)/common/entropy_common.o
302OBJS += $(LCHDR_ZSTD)/common/error_private.o
303OBJS += $(LCHDR_ZSTD)/common/fse_decompress.o
58126d96 304OBJS += $(LCHDR_ZSTD)/common/xxhash.o
305OBJS += $(LCHDR_ZSTD)/common/zstd_common.o
306OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress.o
8c065899 307OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress_amd64.o
58126d96 308OBJS += $(LCHDR_ZSTD)/decompress/zstd_ddict.o
309OBJS += $(LCHDR_ZSTD)/decompress/zstd_decompress_block.o
310OBJS += $(LCHDR_ZSTD)/decompress/zstd_decompress.o
311$(LCHDR_ZSTD)/common/%.o \
8c065899 312$(LCHDR_ZSTD)/decompress/%.o: CFLAGS += -I$(LCHDR_ZSTD)
58126d96 313$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_ZSTD)
68e7d409 314libpcsxcore/cdriso.o: CFLAGS += -Wno-unused-function
58126d96 315CFLAGS += -DHAVE_CHD -I$(LCHDR)/include
79c4d434 316endif
e906c010 317
cc56203b 318# frontend/gui
c82f907a 319OBJS += frontend/cspace.o
57467c77 320ifeq "$(HAVE_NEON_ASM)" "1"
c82f907a 321OBJS += frontend/cspace_neon.o
9b592b3f 322frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x
d57557c0 323else
324ifeq "$(ARCH)" "arm"
325OBJS += frontend/cspace_arm.o
57467c77 326frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565
d57557c0 327endif
c82f907a 328endif
329
4132e8ca 330ifeq "$(PLATFORM)" "generic"
5b9aa749 331OBJS += frontend/libpicofe/in_sdl.o
332OBJS += frontend/libpicofe/plat_sdl.o
cc56203b 333OBJS += frontend/libpicofe/plat_dummy.o
334OBJS += frontend/libpicofe/linux/in_evdev.o
5b9aa749 335OBJS += frontend/plat_sdl.o
336ifeq "$(HAVE_GLES)" "1"
2c616080 337OBJS += frontend/libpicofe/gl.o frontend/libpicofe/gl_platform.o
5b9aa749 338LDLIBS += $(LDLIBS_GLES)
339frontend/libpicofe/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
2c616080 340frontend/libpicofe/gl_platform.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
5b9aa749 341frontend/libpicofe/gl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
342frontend/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
343endif
cc56203b 344USE_PLUGIN_LIB = 1
38c2028e 345USE_FRONTEND = 1
4132e8ca 346endif
55b0eeea 347ifeq "$(PLATFORM)" "pandora"
cc56203b 348OBJS += frontend/libpicofe/pandora/plat.o
349OBJS += frontend/libpicofe/linux/fbdev.o frontend/libpicofe/linux/xenv.o
350OBJS += frontend/libpicofe/linux/in_evdev.o
351OBJS += frontend/plat_pandora.o frontend/plat_omap.o
da710571 352frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
3aba4185 353frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
cc56203b 354USE_PLUGIN_LIB = 1
38c2028e 355USE_FRONTEND = 1
fad9f755 356CFLAGS += -gdwarf-3
4132e8ca 357endif
55b0eeea 358ifeq "$(PLATFORM)" "caanoo"
cc56203b 359OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o
360OBJS += frontend/libpicofe/gp2x/soc_pollux.o
361OBJS += frontend/libpicofe/linux/in_evdev.o
faf2b2aa 362OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
da710571 363frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h
cc56203b 364USE_PLUGIN_LIB = 1
38c2028e 365USE_FRONTEND = 1
366endif
367ifeq "$(PLATFORM)" "maemo"
baaef67b 368OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o
38c2028e 369maemo/%.o: maemo/%.c
cc56203b 370USE_PLUGIN_LIB = 1
a76fd953 371LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse)
7010034e 372CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB
a76fd953
PI
373CFLAGS += `pkg-config --cflags glib-2.0 libosso dbus-1 hildon-fm-2`
374LDFLAGS += `pkg-config --libs glib-2.0 libosso dbus-1 hildon-fm-2`
38c2028e 375endif
376ifeq "$(PLATFORM)" "libretro"
835c219c 377ifneq "$(HAVE_PHYSICAL_CDROM)$(USE_LIBRETRO_VFS)" "00"
378OBJS += deps/libretro-common/compat/compat_strl.o
379OBJS += deps/libretro-common/file/file_path.o
380OBJS += deps/libretro-common/string/stdstring.o
381OBJS += deps/libretro-common/vfs/vfs_implementation.o
382endif
383ifeq "$(HAVE_PHYSICAL_CDROM)" "1"
e0216409 384OBJS += frontend/libretro-cdrom.o
385OBJS += deps/libretro-common/lists/string_list.o
835c219c 386OBJS += deps/libretro-common/memmap/memalign.o
387OBJS += deps/libretro-common/vfs/vfs_implementation_cdrom.o
388CFLAGS += -DHAVE_CDROM
389endif
390ifeq "$(USE_LIBRETRO_VFS)" "1"
391OBJS += deps/libretro-common/compat/compat_posix_string.o
392OBJS += deps/libretro-common/compat/fopen_utf8.o
393OBJS += deps/libretro-common/encodings/encoding_utf.o
394OBJS += deps/libretro-common/streams/file_stream.o
395OBJS += deps/libretro-common/streams/file_stream_transforms.o
396OBJS += deps/libretro-common/time/rtime.o
397CFLAGS += -DUSE_LIBRETRO_VFS
398endif
38c2028e 399OBJS += frontend/libretro.o
46aa5b98 400CFLAGS += -DFRONTEND_SUPPORTS_RGB565
0b1633d7 401CFLAGS += -DHAVE_LIBRETRO
402INC_LIBRETRO_COMMON := 1
ce0e7ac9 403
a4c71501 404ifneq ($(DYNAREC),lightrec)
ce0e7ac9 405ifeq ($(MMAP_WIN32),1)
406OBJS += libpcsxcore/memmap_win32.o
407endif
38c2028e 408endif
0b1633d7 409endif # $(PLATFORM) == "libretro"
410
411ifeq "$(USE_RTHREADS)" "1"
412OBJS += frontend/libretro-rthreads.o
413OBJS += deps/libretro-common/features/features_cpu.o
d135f6d2 414frontend/main.o: CFLAGS += -DHAVE_RTHREADS
0b1633d7 415INC_LIBRETRO_COMMON := 1
416endif
417ifeq "$(INC_LIBRETRO_COMMON)" "1"
418CFLAGS += -Ideps/libretro-common/include
a4c71501 419endif
cc56203b 420
421ifeq "$(USE_PLUGIN_LIB)" "1"
38c2028e 422OBJS += frontend/plugin_lib.o
cc56203b 423OBJS += frontend/libpicofe/linux/plat.o
424OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
a4da039c 425frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
57467c77 426ifeq "$(HAVE_NEON_ASM)" "1"
cc56203b 427OBJS += frontend/libpicofe/arm/neon_scale2x.o
428OBJS += frontend/libpicofe/arm/neon_eagle2x.o
429frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
430frontend/libpicofe/arm/neon_eagle2x.o: CFLAGS += -DDO_BGR_TO_RGB
431endif
432endif
433ifeq "$(USE_FRONTEND)" "1"
434OBJS += frontend/menu.o
435OBJS += frontend/libpicofe/input.o
436frontend/menu.o: frontend/libpicofe/menu.c
38c2028e 437ifeq "$(HAVE_TSLIB)" "1"
438frontend/%.o: CFLAGS += -DHAVE_TSLIB
439OBJS += frontend/pl_gun_ts.o
440endif
441else
442CFLAGS += -DNO_FRONTEND
55b0eeea 443endif
a80ae4a0 444
cc56203b 445# misc
446OBJS += frontend/main.o frontend/plugin.o
0d87d062 447frontend/main.o: CFLAGS += -DBUILTIN_GPU=$(BUILTIN_GPU)
e0aec5ee 448
a1a232ad 449frontend/menu.o frontend/main.o: frontend/revision.h
450frontend/plat_sdl.o frontend/libretro.o: frontend/revision.h
3c70c47b 451
fad9f755 452CFLAGS += $(CFLAGS_LAST)
453
cc56203b 454frontend/libpicofe/%.c:
fa56d360 455 @echo "libpicofe module is missing, please run:"
456 @echo "git submodule init && git submodule update"
457 @exit 1
458
59774ed0 459libpcsxcore/gte_nf.o: libpcsxcore/gte.c
460 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
461
3c70c47b 462frontend/revision.h: FORCE
4527b1fd 463 @(git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
3c70c47b 464 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
465 @rm $@_
3c70c47b 466
90ca4913 467%.o: %.S
9aff1963 468 $(CC_AS) $(CFLAGS) -c $^ -o $@
80c2304e 469
e0aec5ee 470
38c2028e 471target_: $(TARGET)
472
80c2304e 473$(TARGET): $(OBJS)
20a25fd7 474ifeq ($(PARTIAL_LINKING), 1)
a6a0a4d3 475 $(LD) -o $(basename $(TARGET))1.o -r --gc-sections $(addprefix -u , $(shell cat frontend/libretro-extern)) $^
20a25fd7 476 $(OBJCOPY) --keep-global-symbols=frontend/libretro-extern $(basename $(TARGET))1.o $(basename $(TARGET)).o
477 $(AR) rcs $@ $(basename $(TARGET)).o
478else ifeq ($(STATIC_LINKING), 1)
479 $(AR) rcs $@ $^
480else
07f64ac7 481 $(CC_LINK) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
20a25fd7 482endif
80c2304e 483
dd4d5a35 484clean: $(PLAT_CLEAN) clean_plugins
20a25fd7 485 $(RM) $(TARGET) *.o $(OBJS) $(TARGET).map frontend/revision.h
0d464c77 486
4132e8ca 487ifneq ($(PLUGINS),)
dd4d5a35 488plugins_: $(PLUGINS)
489
ee78346e 490$(PLUGINS):
4cccc4d2 491 $(MAKE) -C $(dir $@)
f932e54b 492
ee78346e 493clean_plugins:
4cccc4d2 494 $(MAKE) -C plugins/gpulib/ clean
ee78346e 495 for dir in $(PLUGINS) ; do \
496 $(MAKE) -C $$(dirname $$dir) clean; done
dd4d5a35 497else
498plugins_:
499clean_plugins:
4132e8ca 500endif
80c2304e 501
fa56d360 502.PHONY: all clean target_ plugins_ clean_plugins FORCE
503
857275a9 504ifneq "$(PLATFORM)" "pandora"
505ifdef CPATH
506$(warning warning: CPATH is defined)
507endif
508endif
509
303ee308 510# ----------- release -----------
511
4527b1fd 512VER ?= $(shell git describe --always HEAD)
4132e8ca 513
dd4d5a35 514ifeq "$(PLATFORM)" "generic"
515OUT = pcsx_rearmed_$(VER)
516
517rel: pcsx $(PLUGINS) \
518 frontend/pandora/skin readme.txt COPYING
519 rm -rf $(OUT)
520 mkdir -p $(OUT)/plugins
521 mkdir -p $(OUT)/bios
522 cp -r $^ $(OUT)/
523 mv $(OUT)/*.so* $(OUT)/plugins/
524 zip -9 -r $(OUT).zip $(OUT)
525endif
526
4132e8ca 527ifeq "$(PLATFORM)" "pandora"
303ee308 528PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
529
8886a808 530rel: pcsx plugins/dfsound/pcsxr_spu_area3.out $(PLUGINS) \
9e0630ab 531 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
532 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
303ee308 533 rm -rf out
bbd837c6 534 mkdir -p out/plugins
303ee308 535 cp -r $^ out/
3938f69a 536 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
537 rm out/pcsx.pxml.templ
bbd837c6 538 mv out/*.so out/plugins/
9e0630ab 539 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
4132e8ca 540endif
541
542ifeq "$(PLATFORM)" "caanoo"
543PLAT_CLEAN = caanoo_clean
544
545caanoo_clean:
546 $(RM) frontend/320240/pollux_set
547
4132e8ca 548rel: pcsx $(PLUGINS) \
549 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
550 frontend/320240/pcsxb.png frontend/320240/skin \
551 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
552 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
553 frontend/320240/haptic_s.cfg \
554 readme.txt COPYING
555 rm -rf out
556 mkdir -p out/pcsx_rearmed/plugins
557 cp -r $^ out/pcsx_rearmed/
4132e8ca 558 mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
559 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
560 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
561 mkdir out/pcsx_rearmed/lib/
562 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
563 mkdir out/pcsx_rearmed/bios/
564 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
565endif