From: notaz Date: Mon, 22 Dec 2025 20:43:44 +0000 (+0200) Subject: make: use automatic dependencies X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=319ccafae4f9fcafe3e84123a96e6bfe777adf04;p=pcsx_rearmed.git make: use automatic dependencies better late than never I guess --- diff --git a/Makefile b/Makefile index 9df61c85..eab4fe98 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,9 @@ ifneq ($(ASSERTS), 1) CFLAGS += -DNDEBUG endif endif +ifndef NO_AUTODEPS +AUTODEPFLAGS += -MMD -MP +endif ifeq ($(DEBUG_ASAN), 1) CFLAGS += -fsanitize=address LDFLAGS += -fsanitize=address @@ -188,10 +191,8 @@ OBJS += libpcsxcore/new_dynarec/new_dynarec.o OBJS += libpcsxcore/new_dynarec/pcsxmem.o ifeq "$(ARCH)" "arm" OBJS += libpcsxcore/new_dynarec/linkage_arm.o - libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c else ifneq (,$(findstring $(ARCH),aarch64 arm64)) OBJS += libpcsxcore/new_dynarec/linkage_arm64.o - libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm64.c else $(error no dynarec support for architecture $(ARCH)) endif @@ -205,7 +206,6 @@ else CFLAGS += -DDRC_DISABLE endif OBJS += libpcsxcore/new_dynarec/emu_if.o -libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/pcsxmem_inline.c ifdef DRC_DBG libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64 CFLAGS += -DDRC_DBG @@ -218,14 +218,11 @@ endif OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \ plugins/dfsound/registers.o plugins/dfsound/spu.o \ plugins/dfsound/out.o plugins/dfsound/nullsnd.o -plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \ - plugins/dfsound/xa.c ifeq "$(ARCH)" "arm" OBJS += plugins/dfsound/arm_utils.o endif ifeq "$(HAVE_C64_TOOLS)" "1" plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE -plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c frontend/menu.o: CFLAGS += -DC64X_DSP endif ifneq ($(findstring oss,$(SOUND_DRIVERS)),) @@ -263,7 +260,6 @@ ifeq "$(BUILTIN_GPU)" "neon" CFLAGS += -DGPU_NEON OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP -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 @@ -277,7 +273,6 @@ ifeq "$(BUILTIN_GPU)" "peops" CFLAGS += -DGPU_PEOPS # note: code is not safe for strict-aliasing? (Castlevania problems) plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing -plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c frontend/menu.o frontend/plugin_lib.o: CFLAGS += -DBUILTIN_GPU_PEOPS OBJS += plugins/dfxvideo/gpulib_if.o ifeq "$(THREAD_RENDERING)" "1" @@ -416,7 +411,6 @@ USE_FRONTEND = 1 endif ifeq "$(PLATFORM)" "maemo" OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o -maemo/%.o: maemo/%.c USE_PLUGIN_LIB = 1 LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse) CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB @@ -478,7 +472,6 @@ ifeq "$(USE_FRONTEND)" "1" OBJS += frontend/menu.o OBJS += frontend/libpicofe/input.o frontend/libpicofe/input.o: CFLAGS += -Wno-array-bounds -frontend/menu.o: frontend/libpicofe/menu.c ifeq "$(HAVE_TSLIB)" "1" frontend/%.o: CFLAGS += -DHAVE_TSLIB OBJS += frontend/pl_gun_ts.o @@ -503,15 +496,21 @@ frontend/libpicofe/%.c: @exit 1 libpcsxcore/gte_nf.o: libpcsxcore/gte.c - $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS + $(CC) -c -o $@ $^ $(CFLAGS) $(AUTODEPFLAGS) -DFLAGLESS include/revision.h: FORCE @(git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > $@_ @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@ @rm $@_ +%.o: %.cpp + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(AUTODEPFLAGS) -c $< -o $@ + +%.o: %.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(AUTODEPFLAGS) -c $< -o $@ + %.o: %.S - $(CC_AS) $(CFLAGS) -c $^ -o $@ + $(CC_AS) $(CPPFLAGS) $(CFLAGS) $(AUTODEPFLAGS) -c $< -o $@ target_: $(TARGET) @@ -528,7 +527,7 @@ else endif clean: $(PLAT_CLEAN) clean_plugins - $(RM) $(TARGET) *.o $(OBJS) $(TARGET).map include/revision.h + $(RM) $(TARGET) *.o $(OBJS) $(OBJS:.o=.d) $(TARGET).map include/revision.h ifneq ($(PLUGINS),) plugins_: $(PLUGINS) @@ -548,6 +547,11 @@ plugins_: clean_plugins: endif +ifndef NO_AUTODEPS +$(OBJS:.o=.d): ; +-include $(OBJS:.o=.d) +endif + .PHONY: all clean target_ plugins_ clean_plugins FORCE ifneq "$(PLATFORM)" "pandora" diff --git a/plugins/gpulib/gpulib.mak b/plugins/gpulib/gpulib.mak index 65b443ea..fef76c03 100644 --- a/plugins/gpulib/gpulib.mak +++ b/plugins/gpulib/gpulib.mak @@ -7,10 +7,12 @@ ifeq ($(GNU_LINKER),1) LDFLAGS += -Wl,--no-undefined endif CFLAGS += $(PLUGIN_CFLAGS) -#LDLIBS_GPULIB += `sdl-config --libs` ifdef DEBUG CFLAGS += -O0 endif +ifndef NO_AUTODEPS + CFLAGS += -MMD -MP +endif GPULIB_A = ../gpulib/gpulib.$(ARCH).a @@ -41,16 +43,22 @@ ifdef BIN_GPULIB ifneq ($(findstring .cpp,$(SRC_GPULIB)),) CC_GPULIB = $(CXX) endif -$(BIN_GPULIB): $(SRC) $(SRC_GPULIB) $(GPULIB_A) - $(CC_GPULIB) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_GPULIB) +DEPS_GPULIB = $(SRC) $(SRC_GPULIB) $(GPULIB_A) +$(BIN_GPULIB): $(DEPS_GPULIB) + $(CC_GPULIB) -o $@ $(CFLAGS) $(LDFLAGS) $(DEPS_GPULIB) $(LDLIBS) $(LDLIBS_GPULIB) ln -fs $(PLUGINDIR)/$@ ../ + +ifndef NO_AUTODEPS +$(BIN_GPULIB:.so=.d): ; +-include $(BIN_GPULIB:.so=.d) +endif endif $(GPULIB_A): $(MAKE) -C ../gpulib/ all clean: - $(RM) $(TARGETS) + $(RM) $(TARGETS) $(BIN_GPULIB:.so=.d) ../../config.mak: @echo "Please run ./configure before running make!"