unbreak build
[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)
15284c51 15CFLAGS += -O3
79c4d434 16ifneq ($(ASSERTS), 1)
fad9f755 17CFLAGS += -DNDEBUG
18endif
b60f2812 19endif
254477d4 20ifeq ($(LOG_UNHANDLED), 1)
21CFLAGS += -DLOG_UNHANDLED
22endif
319ccafa 23ifndef NO_AUTODEPS
24AUTODEPFLAGS += -MMD -MP
25endif
36c76c86
PC
26ifeq ($(DEBUG_ASAN), 1)
27CFLAGS += -fsanitize=address
5dd884df 28LDFLAGS += -fsanitize=address
29#LDFLAGS += -static-libasan
36c76c86 30endif
597571ad 31ifeq ($(DEBUG_UBSAN), 1)
32CFLAGS += -fsanitize=undefined -fno-sanitize=shift-base
33LDFLAGS += -fsanitize=undefined
34endif
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)
f49a4c48 63#EXTRA_LDFLAGS ?= -Wl,-Map=$@.map # not on some linkers
07c13dfd 64LDLIBS += $(MAIN_LDLIBS)
e0aec5ee 65ifdef PCNT
66CFLAGS += -DPCNT
67endif
61bc6d40 68
f49a4c48 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
80c2304e 82# core
08d9d257 83OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cdrom-async.o \
84 libpcsxcore/cheat.o libpcsxcore/database.o \
7d7672a5 85 libpcsxcore/decode_xa.o libpcsxcore/mdec.o \
80c2304e 86 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
0890ae15 87 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o \
9a0a61d2 88 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o \
89 libpcsxcore/psxevents.o libpcsxcore/r3000a.o \
abf09485 90 libpcsxcore/sio.o libpcsxcore/spu.o libpcsxcore/gpu.o
59774ed0 91OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
7d7672a5 92#OBJS += libpcsxcore/debug.o libpcsxcore/socket.o libpcsxcore/disr3000a.o
79c4d434 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
59774ed0 115ifeq "$(ARCH)" "arm"
116OBJS += libpcsxcore/gte_arm.o
117endif
57467c77 118ifeq "$(HAVE_NEON_ASM)" "1"
8cfbda97 119OBJS += libpcsxcore/gte_neon.o
120endif
305c8c93 121libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
ab948f7e 122
9c0bfd96 123ifeq ($(MMAP_WIN32),1)
124CFLAGS += -Iinclude/mman -Ideps/mman
125OBJS += deps/mman/mman.o
126endif
fad9f755 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
7fe57395 133ifeq "$(USE_ASYNC_GPU)" "1"
134frontend/libretro.o: CFLAGS += -DUSE_ASYNC_GPU
135frontend/menu.o: CFLAGS += -DUSE_ASYNC_GPU
136USE_RTHREADS := 1
137endif
fad9f755 138
f95a77f7 139# dynarec
a4c71501 140ifeq "$(DYNAREC)" "lightrec"
141CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \
142 -DLIGHTREC -DLIGHTREC_STATIC
97fa754e
PC
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
a4c71501 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) \
97fa754e 157 -DLIGHTREC_ENABLE_THREADED_COMPILER=$(LIGHTREC_THREADED_COMPILER) \
746146ba
PC
158 -DLIGHTREC_ENABLE_DISASSEMBLER=$(or $(LIGHTREC_DEBUG),0) \
159 -DLIGHTREC_NO_DEBUG=$(if $(LIGHTREC_DEBUG),0,1)
a4c71501 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)
9c0bfd96 194deps/lightning/lib/lightning.o: CFLAGS += -Dmprotect=_mprotect # deps/mman
195deps/lightning/lib/jit_print.o: CFLAGS += -w
a4c71501 196endif
197else ifeq "$(DYNAREC)" "ari64"
be516ebe 198OBJS += libpcsxcore/new_dynarec/new_dynarec.o
7e605697 199OBJS += libpcsxcore/new_dynarec/pcsxmem.o
be516ebe 200 ifeq "$(ARCH)" "arm"
201 OBJS += libpcsxcore/new_dynarec/linkage_arm.o
57467c77 202 else ifneq (,$(findstring $(ARCH),aarch64 arm64))
be516ebe 203 OBJS += libpcsxcore/new_dynarec/linkage_arm64.o
204 else
205 $(error no dynarec support for architecture $(ARCH))
206 endif
0b1633d7 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
448bbcae 213else
41e82ad4 214CFLAGS += -DDRC_DISABLE
7139f3c8 215endif
9a0a61d2 216OBJS += libpcsxcore/new_dynarec/emu_if.o
3eb78778 217ifdef DRC_DBG
218libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
219CFLAGS += -DDRC_DBG
220endif
2a014d73 221ifeq "$(BASE_ADDR_DYNAMIC)" "1"
222libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_DYNAMIC=1
a327ad27 223endif
f95a77f7 224
e906c010 225# spu
ee849648 226OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
07c13dfd 227 plugins/dfsound/registers.o plugins/dfsound/spu.o \
228 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
3a721c1f 229ifeq "$(ARCH)" "arm"
b17618c0 230OBJS += plugins/dfsound/arm_utils.o
231endif
5514a050 232ifeq "$(HAVE_C64_TOOLS)" "1"
42dde520 233plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE
8886a808 234frontend/menu.o: CFLAGS += -DC64X_DSP
5514a050 235endif
07c13dfd 236ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
237plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
de38f20e 238OBJS += plugins/dfsound/oss.o
239endif
07c13dfd 240ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
241plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
de38f20e 242OBJS += plugins/dfsound/alsa.o
4132e8ca 243LDLIBS += -lasound
244endif
07c13dfd 245ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
246plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
d8a2f79b 247OBJS += plugins/dfsound/sdl.o
248endif
07c13dfd 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
de38f20e 255endif
256
5368e5b9
A
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
61bc6d40 265# builtin gpu
f060f4be 266OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o plugins/gpulib/prim.o
7fe57395 267ifeq "$(USE_ASYNC_GPU)" "1"
268OBJS += plugins/gpulib/gpu_async.o
269plugins/gpulib/%.o: CFLAGS += -DUSE_ASYNC_GPU
270endif
61bc6d40 271ifeq "$(BUILTIN_GPU)" "neon"
79c4d434 272CFLAGS += -DGPU_NEON
57467c77 273OBJS += plugins/gpu_neon/psx_gpu_if.o
90ca4913 274plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
57467c77 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
61bc6d40 283endif
284ifeq "$(BUILTIN_GPU)" "peops"
79c4d434 285CFLAGS += -DGPU_PEOPS
2ef486ee 286# note: code is not safe for strict-aliasing? (Castlevania problems)
62d7fa95 287plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
f2ba1d45 288frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_PEOPS
62d7fa95 289OBJS += plugins/dfxvideo/gpulib_if.o
90ca4913 290endif
e0c692d9 291
4cfc568d 292ifeq "$(BUILTIN_GPU)" "unai"
79c4d434 293CFLAGS += -DGPU_UNAI
294CFLAGS += -DUSE_GPULIB=1
4cfc568d 295OBJS += plugins/gpu_unai/gpulib_if.o
0bfe8d59 296ifeq "$(ARCH)" "arm"
4cfc568d 297OBJS += plugins/gpu_unai/gpu_arm.o
0bfe8d59 298endif
5ddc3a7a 299ifneq "$(GPU_UNAI_NO_OLD)" "1"
300OBJS += plugins/gpu_unai/old/if.o
301else
302CFLAGS += -DGPU_UNAI_NO_OLD
303endif
8177857b 304plugins/gpu_unai/gpulib_if.o: plugins/gpu_unai/*.h
5ddc3a7a 305plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1
f2ba1d45 306frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_UNAI
6aa72faf 307ifneq ($(DEBUG), 1)
5ddc3a7a 308plugins/gpu_unai/gpulib_if.o \
309plugins/gpu_unai/old/if.o: CFLAGS += -O3
6aa72faf 310endif
0bfe8d59 311CC_LINK = $(CXX)
312endif
313
a51adab4 314# libchdr
79c4d434 315ifeq "$(HAVE_CHD)" "1"
58126d96 316LCHDR = deps/libchdr
8c065899 317LCHDR_LZMA = $(LCHDR)/deps/lzma-24.05
318LCHDR_ZSTD = $(LCHDR)/deps/zstd-1.5.6/lib
58126d96 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
ded8498a 324$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -Wno-maybe-uninitialized -std=gnu11
58126d96 325OBJS += $(LCHDR_LZMA)/src/Alloc.o
58126d96 326OBJS += $(LCHDR_LZMA)/src/CpuArch.o
327OBJS += $(LCHDR_LZMA)/src/Delta.o
328OBJS += $(LCHDR_LZMA)/src/LzFind.o
58126d96 329OBJS += $(LCHDR_LZMA)/src/LzmaDec.o
330OBJS += $(LCHDR_LZMA)/src/LzmaEnc.o
331OBJS += $(LCHDR_LZMA)/src/Sort.o
8c065899 332$(LCHDR_LZMA)/src/%.o: CFLAGS += -Wno-unused -DZ7_ST -I$(LCHDR_LZMA)/include
58126d96 333$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_LZMA)/include
58126d96 334OBJS += $(LCHDR_ZSTD)/common/entropy_common.o
335OBJS += $(LCHDR_ZSTD)/common/error_private.o
336OBJS += $(LCHDR_ZSTD)/common/fse_decompress.o
58126d96 337OBJS += $(LCHDR_ZSTD)/common/xxhash.o
338OBJS += $(LCHDR_ZSTD)/common/zstd_common.o
339OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress.o
8c065899 340OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress_amd64.o
58126d96 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 \
8c065899 345$(LCHDR_ZSTD)/decompress/%.o: CFLAGS += -I$(LCHDR_ZSTD)
58126d96 346$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_ZSTD)
68e7d409 347libpcsxcore/cdriso.o: CFLAGS += -Wno-unused-function
58126d96 348CFLAGS += -DHAVE_CHD -I$(LCHDR)/include
79c4d434 349endif
e906c010 350
cc56203b 351# frontend/gui
c82f907a 352OBJS += frontend/cspace.o
57467c77 353ifeq "$(HAVE_NEON_ASM)" "1"
c82f907a 354OBJS += frontend/cspace_neon.o
9b592b3f 355frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x
d57557c0 356else
357ifeq "$(ARCH)" "arm"
358OBJS += frontend/cspace_arm.o
57467c77 359frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565
d57557c0 360endif
c82f907a 361endif
362
4132e8ca 363ifeq "$(PLATFORM)" "generic"
5b9aa749 364OBJS += frontend/libpicofe/in_sdl.o
81023939 365#OBJS += frontend/libpicofe/plat_sdl.o
cc56203b 366OBJS += frontend/libpicofe/plat_dummy.o
5b9aa749 367OBJS += frontend/plat_sdl.o
81023939 368frontend/plat_sdl.o frontend/libpicofe/plat_sdl.o: CFLAGS += -DSDL_OVERLAY_2X
369frontend/menu.o: CFLAGS += -DSDL_OVERLAY_2X -DMENU_SHOW_VARSCALER=1
f49a4c48 370ifeq "$(HAVE_EVDEV)" "1"
371OBJS += frontend/libpicofe/linux/in_evdev.o
372endif
5b9aa749 373ifeq "$(HAVE_GLES)" "1"
2c616080 374OBJS += frontend/libpicofe/gl.o frontend/libpicofe/gl_platform.o
86e02a02 375OBJS += frontend/libpicofe/gl_loader.o
376#LDLIBS += $(LDLIBS_GLES) # loaded dynamically now
5b9aa749 377frontend/libpicofe/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
2c616080 378frontend/libpicofe/gl_platform.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
5b9aa749 379frontend/libpicofe/gl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
380frontend/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
381endif
cc56203b 382USE_PLUGIN_LIB = 1
38c2028e 383USE_FRONTEND = 1
4132e8ca 384endif
55b0eeea 385ifeq "$(PLATFORM)" "pandora"
cc56203b 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
da710571 390frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
1ae743b1 391frontend/main.o frontend/plugin_lib.o: CFLAGS += -DPANDORA
3aba4185 392frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
cc56203b 393USE_PLUGIN_LIB = 1
38c2028e 394USE_FRONTEND = 1
fad9f755 395CFLAGS += -gdwarf-3
4132e8ca 396endif
55b0eeea 397ifeq "$(PLATFORM)" "caanoo"
cc56203b 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
faf2b2aa 401OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
da710571 402frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h
cc56203b 403USE_PLUGIN_LIB = 1
38c2028e 404USE_FRONTEND = 1
405endif
8cf3ffc7
A
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
38c2028e 416ifeq "$(PLATFORM)" "maemo"
baaef67b 417OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o
cc56203b 418USE_PLUGIN_LIB = 1
a76fd953 419LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse)
7010034e 420CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB
a76fd953
PI
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`
38c2028e 423endif
424ifeq "$(PLATFORM)" "libretro"
835c219c 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"
e0216409 432OBJS += frontend/libretro-cdrom.o
433OBJS += deps/libretro-common/lists/string_list.o
835c219c 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
38c2028e 447OBJS += frontend/libretro.o
0b1633d7 448CFLAGS += -DHAVE_LIBRETRO
449INC_LIBRETRO_COMMON := 1
ce0e7ac9 450
0b1633d7 451endif # $(PLATFORM) == "libretro"
452
453ifeq "$(USE_RTHREADS)" "1"
6112127e 454OBJS += frontend/pcsxr-threads.o
0b1633d7 455OBJS += deps/libretro-common/features/features_cpu.o
d135f6d2 456frontend/main.o: CFLAGS += -DHAVE_RTHREADS
0b1633d7 457INC_LIBRETRO_COMMON := 1
458endif
459ifeq "$(INC_LIBRETRO_COMMON)" "1"
460CFLAGS += -Ideps/libretro-common/include
a4c71501 461endif
cc56203b 462
463ifeq "$(USE_PLUGIN_LIB)" "1"
38c2028e 464OBJS += frontend/plugin_lib.o
cc56203b 465OBJS += frontend/libpicofe/linux/plat.o
466OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
a4da039c 467frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
57467c77 468ifeq "$(HAVE_NEON_ASM)" "1"
cc56203b 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
b21c766f 478frontend/libpicofe/input.o: CFLAGS += -Wno-array-bounds
38c2028e 479ifeq "$(HAVE_TSLIB)" "1"
480frontend/%.o: CFLAGS += -DHAVE_TSLIB
481OBJS += frontend/pl_gun_ts.o
482endif
483else
484CFLAGS += -DNO_FRONTEND
55b0eeea 485endif
a80ae4a0 486
cc56203b 487# misc
488OBJS += frontend/main.o frontend/plugin.o
f906311d 489frontend/main.o libpcsxcore/misc.o: CFLAGS += -DBUILTIN_GPU=$(BUILTIN_GPU)
e0aec5ee 490
f906311d 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
3c70c47b 494
fad9f755 495CFLAGS += $(CFLAGS_LAST)
496
cc56203b 497frontend/libpicofe/%.c:
fa56d360 498 @echo "libpicofe module is missing, please run:"
499 @echo "git submodule init && git submodule update"
500 @exit 1
501
59774ed0 502libpcsxcore/gte_nf.o: libpcsxcore/gte.c
ced6ed32 503 $(CC) -c -o $@ $< $(CFLAGS) $(AUTODEPFLAGS) -DFLAGLESS
59774ed0 504
f906311d 505include/revision.h: FORCE
4527b1fd 506 @(git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
3c70c47b 507 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
508 @rm $@_
3c70c47b 509
319ccafa 510%.o: %.cpp
511 $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(AUTODEPFLAGS) -c $< -o $@
512
513%.o: %.c
514 $(CC) $(CPPFLAGS) $(CFLAGS) $(AUTODEPFLAGS) -c $< -o $@
515
90ca4913 516%.o: %.S
319ccafa 517 $(CC_AS) $(CPPFLAGS) $(CFLAGS) $(AUTODEPFLAGS) -c $< -o $@
80c2304e 518
e0aec5ee 519
38c2028e 520target_: $(TARGET)
521
80c2304e 522$(TARGET): $(OBJS)
20a25fd7 523ifeq ($(PARTIAL_LINKING), 1)
a7a6db33 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
20a25fd7 526 $(AR) rcs $@ $(basename $(TARGET)).o
527else ifeq ($(STATIC_LINKING), 1)
528 $(AR) rcs $@ $^
529else
07f64ac7 530 $(CC_LINK) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
20a25fd7 531endif
80c2304e 532
dd4d5a35 533clean: $(PLAT_CLEAN) clean_plugins
319ccafa 534 $(RM) $(TARGET) *.o $(OBJS) $(OBJS:.o=.d) $(TARGET).map include/revision.h
0d464c77 535
4132e8ca 536ifneq ($(PLUGINS),)
dd4d5a35 537plugins_: $(PLUGINS)
538
ddab6158 539plugins/gpulib/gpulib.$(ARCH).a:
540 $(MAKE) -C plugins/gpulib/
541
542$(PLUGINS): plugins/gpulib/gpulib.$(ARCH).a
4cccc4d2 543 $(MAKE) -C $(dir $@)
f932e54b 544
ee78346e 545clean_plugins:
4cccc4d2 546 $(MAKE) -C plugins/gpulib/ clean
ee78346e 547 for dir in $(PLUGINS) ; do \
548 $(MAKE) -C $$(dirname $$dir) clean; done
dd4d5a35 549else
550plugins_:
551clean_plugins:
4132e8ca 552endif
80c2304e 553
319ccafa 554ifndef NO_AUTODEPS
555$(OBJS:.o=.d): ;
556-include $(OBJS:.o=.d)
557endif
558
fa56d360 559.PHONY: all clean target_ plugins_ clean_plugins FORCE
560
857275a9 561ifneq "$(PLATFORM)" "pandora"
562ifdef CPATH
563$(warning warning: CPATH is defined)
564endif
565endif
566
303ee308 567# ----------- release -----------
568
4527b1fd 569VER ?= $(shell git describe --always HEAD)
4132e8ca 570
dd4d5a35 571ifeq "$(PLATFORM)" "generic"
572OUT = pcsx_rearmed_$(VER)
573
574rel: pcsx $(PLUGINS) \
9fed432c 575 frontend/pandora/skin README.md COPYING
dd4d5a35 576 rm -rf $(OUT)
577 mkdir -p $(OUT)/plugins
578 mkdir -p $(OUT)/bios
579 cp -r $^ $(OUT)/
2eda4524 580 -mv $(OUT)/*.so* $(OUT)/plugins/
dd4d5a35 581 zip -9 -r $(OUT).zip $(OUT)
582endif
583
4132e8ca 584ifeq "$(PLATFORM)" "pandora"
303ee308 585PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
586
8886a808 587rel: pcsx plugins/dfsound/pcsxr_spu_area3.out $(PLUGINS) \
9e0630ab 588 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
9fed432c 589 frontend/pandora/picorestore frontend/pandora/skin frontend/pandora/readme.txt COPYING
303ee308 590 rm -rf out
bbd837c6 591 mkdir -p out/plugins
303ee308 592 cp -r $^ out/
3938f69a 593 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
594 rm out/pcsx.pxml.templ
2eda4524 595 -mv out/*.so out/plugins/
9e0630ab 596 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
4132e8ca 597endif
598
8cf3ffc7
A
599ifeq "$(PLATFORM)" "miyoo"
600
601rel: pcsx $(PLUGINS) \
602 frontend/320240/pcsx26.png \
603 frontend/320240/skin \
9fed432c 604 README.md COPYING
8cf3ffc7
A
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 *
458ddcc5
A
612
613ipk: rel
614 VERSION="$(VER)" gm2xpkg -q -f miyoo/pkg.cfg
615 mv pcsx.ipk pcsx_rearmed.ipk
8cf3ffc7
A
616endif
617
4132e8ca 618ifeq "$(PLATFORM)" "caanoo"
619PLAT_CLEAN = caanoo_clean
620
621caanoo_clean:
622 $(RM) frontend/320240/pollux_set
623
4132e8ca 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 \
9fed432c 630 COPYING
4132e8ca 631 rm -rf out
632 mkdir -p out/pcsx_rearmed/plugins
633 cp -r $^ out/pcsx_rearmed/
2eda4524 634 -mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
4132e8ca 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