From 4750306a1fab727bf7daf34f9f993eec9d9b8af5 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Fri, 25 Jan 2019 19:01:53 +0100 Subject: [PATCH] Improve dependency file generation Run the whole generation in one command --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fcf31f4..b7da052 100644 --- a/Makefile +++ b/Makefile @@ -67,13 +67,12 @@ $(DEPSDIR)/%.d: $(SRCDIR)/%.asm dummy @echo Building deps file $@ @mkdir -p $(DEPSDIR) @mkdir -p $(OBJDIR) - @set -e @# Generate dependency file (side effect: also compiles!) - @# Output to a different file to not overwrite the old one on compilation failure (Make would think the compilation succeeded the next time) - $(RGBASM) -M $@.tmp $(ASFLAGS) -o $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$<) $< - @# Add all obj dependencies to the deps file too, so Make knows to remake it - @sed 's,\($*\)\.o[ :]*,\1.o $@: ,g' < $@.tmp > $@ - @rm $@.tmp + @# Output to a different file to make `sed` work (otherwise it would use the same file as input and output) + set -e; \ + $(RGBASM) -M $@.tmp $(ASFLAGS) -o $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$<) $<; \ + sed 's,\($*\)\.o[ :]*,\1.o $@: ,g' < $@.tmp > $@; \ + rm $@.tmp # Include (and potentially remake) all dependency files include $(patsubst $(SRCDIR)/%.asm,$(DEPSDIR)/%.d,$(ASMFILES))