adjust dma alignment and some cleanup
[pcsx_rearmed.git] / Makefile
index bff1a1c..57fee2f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,13 @@ else
 CFLAGS += -O2 -DNDEBUG
 endif
 endif
+ifeq ($(DEBUG_ASAN), 1)
+CFLAGS += -fsanitize=address
+endif
+CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \
+         -DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \
+         -DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \
+         -DDISABLE_MEM_LUTS=0
 CXXFLAGS += $(CFLAGS)
 #DRC_DBG = 1
 #PCNT = 1
@@ -41,49 +48,52 @@ endif
 CC_LINK ?= $(CC)
 CC_AS ?= $(CC)
 LDFLAGS += $(MAIN_LDFLAGS)
+ifeq ($(DEBUG_ASAN), 1)
+LDFLAGS += -static-libasan
+endif
 EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
 LDLIBS += $(MAIN_LDLIBS)
 ifdef PCNT
 CFLAGS += -DPCNT
 endif
 
-LIGHTREC_CUSTOM_MAP ?= 0
-
 # core
 OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/database.o \
        libpcsxcore/decode_xa.o libpcsxcore/mdec.o \
        libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
-       libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
-       libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
-       libpcsxcore/sio.o libpcsxcore/spu.o
+       libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o \
+       libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o \
+       libpcsxcore/psxevents.o libpcsxcore/r3000a.o \
+       libpcsxcore/sio.o libpcsxcore/spu.o libpcsxcore/gpu.o
 OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
 
 ifeq ($(DEBUG), 1)
-OBJS += libpcsxcore/debug.o    libpcsxcore/socket.o libpcsxcore/disr3000a.o
+#OBJS += libpcsxcore/debug.o   libpcsxcore/socket.o libpcsxcore/disr3000a.o
 endif
 
 ifeq ($(WANT_ZLIB),1)
-CFLAGS += -Ideps/libchdr/deps/zlib-1.2.11
-OBJS += deps/libchdr/deps/zlib-1.2.11/adler32.o \
-        deps/libchdr/deps/zlib-1.2.11/compress.o \
-        deps/libchdr/deps/zlib-1.2.11/crc32.o \
-        deps/libchdr/deps/zlib-1.2.11/deflate.o \
-        deps/libchdr/deps/zlib-1.2.11/gzclose.o \
-        deps/libchdr/deps/zlib-1.2.11/gzlib.o \
-        deps/libchdr/deps/zlib-1.2.11/gzread.o \
-        deps/libchdr/deps/zlib-1.2.11/gzwrite.o \
-        deps/libchdr/deps/zlib-1.2.11/infback.o \
-        deps/libchdr/deps/zlib-1.2.11/inffast.o \
-        deps/libchdr/deps/zlib-1.2.11/inflate.o \
-        deps/libchdr/deps/zlib-1.2.11/inftrees.o \
-        deps/libchdr/deps/zlib-1.2.11/trees.o \
-        deps/libchdr/deps/zlib-1.2.11/uncompr.o \
-        deps/libchdr/deps/zlib-1.2.11/zutil.o
+CFLAGS += -Ideps/libchdr/deps/zlib-1.2.13
+OBJS += deps/libchdr/deps/zlib-1.2.13/adler32.o \
+        deps/libchdr/deps/zlib-1.2.13/compress.o \
+        deps/libchdr/deps/zlib-1.2.13/crc32.o \
+        deps/libchdr/deps/zlib-1.2.13/deflate.o \
+        deps/libchdr/deps/zlib-1.2.13/gzclose.o \
+        deps/libchdr/deps/zlib-1.2.13/gzlib.o \
+        deps/libchdr/deps/zlib-1.2.13/gzread.o \
+        deps/libchdr/deps/zlib-1.2.13/gzwrite.o \
+        deps/libchdr/deps/zlib-1.2.13/infback.o \
+        deps/libchdr/deps/zlib-1.2.13/inffast.o \
+        deps/libchdr/deps/zlib-1.2.13/inflate.o \
+        deps/libchdr/deps/zlib-1.2.13/inftrees.o \
+        deps/libchdr/deps/zlib-1.2.13/trees.o \
+        deps/libchdr/deps/zlib-1.2.13/uncompr.o \
+        deps/libchdr/deps/zlib-1.2.13/zutil.o
+deps/libchdr/deps/zlib-1.2.13/%.o: CFLAGS += -DHAVE_UNISTD_H
 endif
 ifeq "$(ARCH)" "arm"
 OBJS += libpcsxcore/gte_arm.o
 endif
-ifeq "$(HAVE_NEON)" "1"
+ifeq "$(HAVE_NEON_ASM)" "1"
 OBJS += libpcsxcore/gte_neon.o
 endif
 libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
@@ -91,12 +101,24 @@ libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
 # dynarec
 ifeq "$(DYNAREC)" "lightrec"
 CFLAGS += -Ideps/lightning/include -Ideps/lightrec -Iinclude/lightning -Iinclude/lightrec \
-                 -DLIGHTREC -DLIGHTREC_STATIC \
-                 -DLIGHTREC_CUSTOM_MAP=$(LIGHTREC_CUSTOM_MAP)
-LDLIBS += -lrt
+                 -DLIGHTREC -DLIGHTREC_STATIC
+LIGHTREC_CUSTOM_MAP ?= 0
+LIGHTREC_CUSTOM_MAP_OBJ ?= libpcsxcore/lightrec/mem.o
+LIGHTREC_THREADED_COMPILER ?= 0
+CFLAGS += -DLIGHTREC_CUSTOM_MAP=$(LIGHTREC_CUSTOM_MAP) \
+         -DLIGHTREC_ENABLE_THREADED_COMPILER=$(LIGHTREC_THREADED_COMPILER)
 ifeq ($(LIGHTREC_CUSTOM_MAP),1)
-OBJS += libpcsxcore/lightrec/mem.o
+LDLIBS += -lrt
+OBJS += $(LIGHTREC_CUSTOM_MAP_OBJ)
+endif
+ifeq ($(NEED_SYSCONF),1)
+OBJS += libpcsxcore/lightrec/sysconf.o
 endif
+ifeq ($(LIGHTREC_THREADED_COMPILER),1)
+OBJS += deps/lightrec/recompiler.o \
+       deps/lightrec/reaper.o
+endif
+OBJS += deps/lightrec/tlsf/tlsf.o
 OBJS += libpcsxcore/lightrec/plugin.o
 OBJS += deps/lightning/lib/jit_disasm.o \
                deps/lightning/lib/jit_memory.o \
@@ -106,18 +128,20 @@ OBJS += deps/lightning/lib/jit_disasm.o \
                deps/lightning/lib/jit_size.o \
                deps/lightning/lib/lightning.o \
                deps/lightrec/blockcache.o \
+               deps/lightrec/constprop.o \
                deps/lightrec/disassembler.o \
                deps/lightrec/emitter.o \
                deps/lightrec/interpreter.o \
                deps/lightrec/lightrec.o \
                deps/lightrec/memmanager.o \
                deps/lightrec/optimizer.o \
-               deps/lightrec/regcache.o \
-               deps/lightrec/recompiler.o \
-               deps/lightrec/reaper.o
+               deps/lightrec/regcache.o
+deps/lightning/%.o: CFLAGS += -DHAVE_MMAP=P_HAVE_MMAP
+deps/lightning/%: CFLAGS += -w
+deps/lightrec/%: CFLAGS += -w
 libpcsxcore/lightrec/mem.o: CFLAGS += -D_GNU_SOURCE
 ifeq ($(MMAP_WIN32),1)
-CFLAGS += -Iinclude/mman
+CFLAGS += -Iinclude/mman -I deps/mman
 OBJS += deps/mman/mman.o
 endif
 else ifeq "$(DYNAREC)" "ari64"
@@ -185,13 +209,16 @@ OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
 ifeq "$(BUILTIN_GPU)" "neon"
 CFLAGS += -DGPU_NEON
 OBJS += plugins/gpu_neon/psx_gpu_if.o
-ifeq "$(HAVE_NEON)" "1"
-OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
-else
-plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
-endif
 plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
+frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_NEON
+ ifeq "$(HAVE_NEON_ASM)" "1"
+ OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
+ else
+ OBJS += plugins/gpu_neon/psx_gpu/psx_gpu_simd.o
+ plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DSIMD_BUILD
+ plugins/gpu_neon/psx_gpu/psx_gpu_simd.o: CFLAGS += -DSIMD_BUILD
+ endif
 endif
 ifeq "$(BUILTIN_GPU)" "peops"
 CFLAGS += -DGPU_PEOPS
@@ -248,18 +275,15 @@ CFLAGS += -DHAVE_CHD -D_7ZIP_ST
 LDFLAGS += -lm
 endif
 
-# dfinput
-ifneq "$(PLATFORM)" "libretro"
-OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
-endif
-
 # frontend/gui
 OBJS += frontend/cspace.o
-ifeq "$(HAVE_NEON)" "1"
+ifeq "$(HAVE_NEON_ASM)" "1"
 OBJS += frontend/cspace_neon.o
+frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565 -DHAVE_bgr888_to_x
 else
 ifeq "$(ARCH)" "arm"
 OBJS += frontend/cspace_arm.o
+frontend/cspace.o: CFLAGS += -DHAVE_bgr555_to_rgb565
 endif
 endif
 
@@ -310,20 +334,20 @@ LDFLAGS += `pkg-config --libs glib-2.0 libosso dbus-1 hildon-fm-2`
 endif
 ifeq "$(PLATFORM)" "libretro"
 ifeq "$(USE_LIBRETRO_VFS)" "1"
-OBJS += libretro-common/compat/compat_posix_string.o
-OBJS += libretro-common/compat/fopen_utf8.o
-OBJS += libretro-common/encodings/compat_strl.o
-OBJS += libretro-common/encodings/encoding_utf.o
-OBJS += libretro-common/file/file_path.o
-OBJS += libretro-common/streams/file_stream.o
-OBJS += libretro-common/streams/file_stream_transforms.o
-OBJS += libretro-common/string/stdstring.o
-OBJS += libretro-common/time/rtime.o
-OBJS += libretro-common/vfs/vfs_implementation.o
+OBJS += deps/libretro-common/compat/compat_posix_string.o
+OBJS += deps/libretro-common/compat/fopen_utf8.o
+OBJS += deps/libretro-common/compat/compat_strl.o
+OBJS += deps/libretro-common/encodings/encoding_utf.o
+OBJS += deps/libretro-common/file/file_path.o
+OBJS += deps/libretro-common/streams/file_stream.o
+OBJS += deps/libretro-common/streams/file_stream_transforms.o
+OBJS += deps/libretro-common/string/stdstring.o
+OBJS += deps/libretro-common/time/rtime.o
+OBJS += deps/libretro-common/vfs/vfs_implementation.o
 CFLAGS += -DUSE_LIBRETRO_VFS
 endif
 OBJS += frontend/libretro.o
-CFLAGS += -Ilibretro-common/include
+CFLAGS += -Ideps/libretro-common/include
 CFLAGS += -DFRONTEND_SUPPORTS_RGB565
 CFLAGS += -DHAVE_LIBRETRO
 
@@ -339,7 +363,7 @@ OBJS += frontend/plugin_lib.o
 OBJS += frontend/libpicofe/linux/plat.o
 OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
 frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
-ifeq "$(HAVE_NEON)" "1"
+ifeq "$(HAVE_NEON_ASM)" "1"
 OBJS += frontend/libpicofe/arm/neon_scale2x.o
 OBJS += frontend/libpicofe/arm/neon_eagle2x.o
 frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
@@ -360,7 +384,7 @@ endif
 
 # misc
 OBJS += frontend/main.o frontend/plugin.o
-
+frontend/main.o: CFLAGS += -DBUILTIN_GPU=$(BUILTIN_GPU)
 
 frontend/menu.o frontend/main.o: frontend/revision.h
 frontend/plat_sdl.o frontend/libretro.o: frontend/revision.h
@@ -393,7 +417,7 @@ $(TARGET): $(OBJS)
 ifeq ($(STATIC_LINKING), 1)
        $(AR) rcs $@ $(OBJS)
 else
-       $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
+       $(CC_LINK) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
 endif
 
 clean: $(PLAT_CLEAN) clean_plugins
@@ -403,10 +427,10 @@ ifneq ($(PLUGINS),)
 plugins_: $(PLUGINS)
 
 $(PLUGINS):
-       make -C $(dir $@)
+       $(MAKE) -C $(dir $@)
 
 clean_plugins:
-       make -C plugins/gpulib/ clean
+       $(MAKE) -C plugins/gpulib/ clean
        for dir in $(PLUGINS) ; do \
                $(MAKE) -C $$(dirname $$dir) clean; done
 else