From b270f0d9813c31d6b00b52eea31ac35cb9201e94 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 8 Feb 2019 11:19:23 +0100 Subject: [PATCH] Automatically generate up-to-date dependencies %.d files in obj directory --- src/Makefile | 18 +++++-- src/Makefile.dep | 137 ----------------------------------------------- 2 files changed, 13 insertions(+), 142 deletions(-) delete mode 100644 src/Makefile.dep diff --git a/src/Makefile b/src/Makefile index afcace93..a303197a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -727,6 +727,7 @@ ifndef NORECOIL OBJS += loadrecoil.o recoil.o endif OBJ = $(addprefix $(OBJDIR)/,$(OBJS)) +DEP = $(patsubst %.o,%.d,$(OBJ)) GENERATEDOCOBJ = $(addprefix $(OBJDIR)/,generatedoc.o hotkeys.o keyboard.o) @@ -787,10 +788,12 @@ DOC_FILESRTF = ../doc/quickstart.rtf # for silent/verbose building ACTUAL_CC := $(CC) -CC_0 = @echo "$(if $(findstring .o,$@),Compiling $<,Linking $@)" ; $(ACTUAL_CC) +CC_0 = @echo "$(if $(findstring .o,$@),Compiling $<,$(if $(findstring .d,$@),Building dependencies for $<,Linking $@))" ; $(ACTUAL_CC) CC_1 = $(ACTUAL_CC) CC = $(CC_$(V)) +DEPFLAGS = -MM -MT $(patsubst %.d,%.o,$@) -MT $@ +# -M : with system headers, -MM : without ifeq ($(PLATFORM),Darwin) all : $(MACAPPEXE) @@ -962,8 +965,11 @@ $(OBJDIR)/%.o : %.m $(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR)) $(CC) $(COPT) -c $*.m -o $(OBJDIR)/$*.o -depend : - $(CC) -MM *.c | sed 's:^[^ ]:$$(OBJDIR)/&:' > Makefile.dep +depend: $(DEP) + +$(OBJDIR)/%.d : %.c + $(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR)) + $(CC) $(COPT) $(CFLAGS) $(DEPFLAGS) -o $@ $< # update the gfx2.rc Windows ressource file comma := , @@ -982,7 +988,7 @@ $(OBJDIR)/haiku.o : haiku.cpp g++ -c haiku.cpp -o $(OBJDIR)/haiku.o $(COPT) -Wno-multichar clean : - $(DELCOMMAND) $(OBJ) + $(DELCOMMAND) $(OBJ) $(DEP) $(DELCOMMAND) $(BIN) if [ -d ../3rdparty ] ; then $(DELCOMMAND) recoil.c recoil.h ; fi @@ -1061,4 +1067,6 @@ htmldoc: $(GENERATEDOCBIN) print-%: @echo "$* = $($*)" --include Makefile.dep +ifneq ($(MAKECMDGOALS),clean) +-include $(DEP) +endif diff --git a/src/Makefile.dep b/src/Makefile.dep deleted file mode 100644 index 9e92c308..00000000 --- a/src/Makefile.dep +++ /dev/null @@ -1,137 +0,0 @@ -$(OBJDIR)/SFont.o: SFont.c SFont.h gfx2surface.h struct.h const.h -$(OBJDIR)/brush.o: brush.c global.h struct.h const.h graph.h misc.h errors.h \ - gfx2log.h windows.h screen.h brush.h tiles.h -$(OBJDIR)/brush_ops.o: brush_ops.c brush.h struct.h const.h buttons.h loadsave.h \ - gfx2surface.h engine.h global.h graph.h misc.h operatio.h pages.h \ - screen.h windows.h keyboard.h -$(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.h \ - readline.h filesel.h loadsave.h gfx2surface.h init.h buttons.h \ - operatio.h pages.h palette.h errors.h gfx2log.h readini.h saveini.h \ - shade.h io.h help.h text.h screen.h windows.h brush.h input.h keycodes.h \ - special.h tiles.h setup.h unicode.h -$(OBJDIR)/buttons_effects.o: buttons_effects.c brush.h struct.h const.h buttons.h \ - loadsave.h gfx2surface.h engine.h global.h graph.h help.h input.h \ - keycodes.h misc.h pages.h readline.h screen.h windows.h tiles.h -$(OBJDIR)/colorred.o: colorred.c colorred.h struct.h const.h -$(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \ - buttons.h loadsave.h gfx2surface.h operatio.h shade.h errors.h gfx2log.h \ - screen.h windows.h brush.h input.h keycodes.h engine.h pages.h layers.h \ - factory.h io.h pxsimple.h oldies.h -$(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h loadsave.h \ - gfx2surface.h engine.h errors.h gfx2log.h filesel.h global.h graph.h \ - io.h misc.h pages.h readline.h screen.h windows.h palette.h input.h \ - keycodes.h help.h realpath.h setup.h tiles.h -$(OBJDIR)/fileformats.o: fileformats.c gfx2log.h errors.h global.h struct.h const.h \ - loadsave.h gfx2surface.h misc.h io.h pages.h windows.h fileformats.h -$(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h gfx2log.h \ - io.h windows.h screen.h loadsave.h gfx2surface.h mountlist.h engine.h \ - readline.h input.h keycodes.h help.h unicode.h filesel.h -$(OBJDIR)/generatedoc.o: generatedoc.c global.h struct.h const.h hotkeys.h \ - helpfile.h keyboard.h -$(OBJDIR)/gfx2log.o: gfx2log.c gfx2log.h -$(OBJDIR)/gfx2surface.o: gfx2surface.c gfx2surface.h struct.h const.h errors.h \ - gfx2log.h -$(OBJDIR)/graph.o: graph.c global.h struct.h const.h engine.h buttons.h loadsave.h \ - gfx2surface.h pages.h errors.h gfx2log.h screen.h graph.h misc.h \ - pxsimple.h pxtall.h pxwide.h pxdouble.h pxtriple.h pxwide2.h pxtall2.h \ - pxtall3.h pxquad.h windows.h input.h keycodes.h brush.h tiles.h -$(OBJDIR)/help.o: help.c recoil.h const.h struct.h global.h misc.h engine.h \ - helpfile.h help.h screen.h text.h keyboard.h windows.h input.h \ - keycodes.h hotkeys.h errors.h gfx2log.h pages.h factory.h -$(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h keycodes.h -$(OBJDIR)/init.o: init.c buttons.h struct.h const.h loadsave.h gfx2surface.h \ - errors.h gfx2log.h global.h graph.h init.h io.h factory.h help.h \ - hotkeys.h keyboard.h misc.h mountlist.h operatio.h palette.h screen.h \ - setup.h transform.h windows.h layers.h special.h -$(OBJDIR)/input.o: input.c gfx2log.h global.h struct.h const.h keyboard.h screen.h \ - windows.h errors.h misc.h buttons.h loadsave.h gfx2surface.h input.h \ - keycodes.h -$(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h unicode.h global.h -$(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h keycodes.h -$(OBJDIR)/layers.o: layers.c const.h struct.h global.h windows.h engine.h pages.h \ - screen.h input.h keycodes.h help.h misc.h readline.h graph.h -$(OBJDIR)/libraw2crtc.o: libraw2crtc.c const.h global.h struct.h loadsave.h \ - gfx2surface.h -$(OBJDIR)/loadrecoil.o: loadrecoil.c struct.h const.h global.h loadsave.h \ - gfx2surface.h io.h errors.h gfx2log.h recoil.h -$(OBJDIR)/loadsave.o: loadsave.c gfx2log.h buttons.h struct.h const.h loadsave.h \ - gfx2surface.h errors.h global.h keycodes.h io.h misc.h graph.h op_c.h \ - colorred.h pages.h palette.h screen.h windows.h engine.h brush.h setup.h \ - filesel.h unicode.h fileformats.h -$(OBJDIR)/main.o: main.c gfx2log.h const.h struct.h global.h graph.h misc.h init.h \ - buttons.h loadsave.h gfx2surface.h engine.h pages.h screen.h errors.h \ - readini.h saveini.h io.h text.h setup.h windows.h brush.h palette.h \ - realpath.h input.h keycodes.h help.h filesel.h -$(OBJDIR)/misc.o: misc.c struct.h const.h global.h errors.h gfx2log.h buttons.h \ - loadsave.h gfx2surface.h engine.h misc.h keyboard.h screen.h windows.h \ - palette.h input.h keycodes.h graph.h pages.h -$(OBJDIR)/miscfileformats.o: miscfileformats.c engine.h struct.h const.h errors.h \ - gfx2log.h global.h io.h libraw2crtc.h loadsave.h gfx2surface.h misc.h \ - screen.h windows.h oldies.h pages.h keycodes.h fileformats.h -$(OBJDIR)/mountlist.o: mountlist.c mountlist.h -$(OBJDIR)/oldies.o: oldies.c struct.h const.h global.h errors.h gfx2log.h misc.h \ - palette.h pages.h windows.h layers.h -$(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h colorred.h errors.h gfx2log.h \ - global.h engine.h windows.h -$(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h misc.h engine.h graph.h \ - operatio.h buttons.h loadsave.h gfx2surface.h pages.h errors.h gfx2log.h \ - screen.h brush.h windows.h input.h keycodes.h special.h tiles.h \ - keyboard.h -$(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h gfx2log.h \ - loadsave.h gfx2surface.h misc.h windows.h tiles.h graph.h -$(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \ - buttons.h loadsave.h gfx2surface.h pages.h help.h screen.h errors.h \ - gfx2log.h op_c.h colorred.h windows.h input.h keycodes.h palette.h \ - shade.h -$(OBJDIR)/pversion.o: pversion.c -$(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h screen.h misc.h graph.h \ - pxdouble.h pxwide.h -$(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h screen.h misc.h graph.h \ - pxquad.h -$(OBJDIR)/pxsimple.o: pxsimple.c global.h struct.h const.h screen.h misc.h graph.h \ - pxsimple.h -$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h screen.h misc.h graph.h \ - pxtall.h pxsimple.h -$(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h screen.h misc.h graph.h \ - pxtall2.h -$(OBJDIR)/pxtall3.o: pxtall3.c global.h struct.h const.h screen.h misc.h graph.h \ - pxtall3.h -$(OBJDIR)/pxtriple.o: pxtriple.c global.h struct.h const.h screen.h misc.h graph.h \ - pxtriple.h -$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h screen.h misc.h graph.h \ - pxwide.h -$(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h screen.h misc.h graph.h \ - pxwide2.h -$(OBJDIR)/readini.o: readini.c const.h errors.h gfx2log.h global.h struct.h misc.h \ - readini.h setup.h realpath.h io.h windows.h -$(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h \ - gfx2log.h screen.h readline.h windows.h input.h keycodes.h engine.h \ - unicode.h -$(OBJDIR)/realpath.o: realpath.c -$(OBJDIR)/recoil.o: recoil.c recoil.h -$(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h readini.h io.h errors.h \ - gfx2log.h misc.h saveini.h setup.h windows.h -$(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h sdlscreen.h errors.h \ - gfx2log.h misc.h -$(OBJDIR)/setup.o: setup.c struct.h const.h io.h setup.h -$(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h errors.h \ - gfx2log.h misc.h readline.h help.h screen.h windows.h input.h keycodes.h \ - shade.h -$(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \ - special.h pages.h misc.h buttons.h loadsave.h gfx2surface.h -$(OBJDIR)/text.o: text.c struct.h const.h global.h io.h errors.h gfx2log.h \ - windows.h misc.h setup.h loadsave.h gfx2surface.h SFont.h -$(OBJDIR)/tiles.o: tiles.c struct.h const.h global.h graph.h screen.h engine.h \ - windows.h input.h keycodes.h misc.h tiles.h -$(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \ - screen.h windows.h input.h keycodes.h help.h misc.h readline.h buttons.h \ - loadsave.h gfx2surface.h pages.h tiles.h -$(OBJDIR)/unicode.o: unicode.c unicode.h struct.h const.h -$(OBJDIR)/version.o: version.c -$(OBJDIR)/win32screen.o: win32screen.c screen.h struct.h const.h global.h errors.h \ - gfx2log.h windows.h input.h keycodes.h keyboard.h -$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \ - gfx2log.h global.h graph.h input.h keycodes.h misc.h op_c.h colorred.h \ - readline.h screen.h palette.h unicode.h keyboard.h -$(OBJDIR)/x11screen.o: x11screen.c screen.h struct.h const.h global.h gfx2surface.h \ - loadsave.h gfx2log.h