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