summaryrefslogtreecommitdiff
path: root/2020
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-12-08 21:03:10 +0100
committerTom Smeding <tom.smeding@gmail.com>2020-12-08 21:03:10 +0100
commit204499e92663b478405aa68e3ed210532feec290 (patch)
tree807f07f672720e685dafa5989dfa710664475b0f /2020
parent151a363bd5ce4fb6ba465fa0bd6d2bda56f18c92 (diff)
Less intrusive Makefile dependency tracking
Diffstat (limited to '2020')
-rw-r--r--2020/Makefile15
1 files changed, 10 insertions, 5 deletions
diff --git a/2020/Makefile b/2020/Makefile
index 340e2ce..ff844f6 100644
--- a/2020/Makefile
+++ b/2020/Makefile
@@ -15,7 +15,7 @@ CPP_BIN := $(CPP_SRC:.cpp=)
BINARIES := $(HASKELL_BIN) $(CPP_BIN)
-.PHONY: all clean
+.PHONY: all clean depend
all: $(BINARIES)
@@ -24,6 +24,12 @@ clean:
rm -f $(BINARIES) .depend_hs
rm -rf $(OBJDIR)
+# Generate the .depend_hs file for correct Haskell dependency tracking
+depend:
+ ghc -dep-suffix '' -dep-makefile .depend_hs -M $(GHCBASEFLAGS) $(HASKELL_SRC)
+ sed -i 's/\.o *:/:/; s/\.hi$$/.hs/g; s/\.hi[ \t]/.hs/g' .depend_hs
+ rm -f .depend_hs.bak
+
$(HASKELL_BIN): %: %.hs | $(OBJDIR)/%
$(GHC) $(GHCFLAGS) -odir $(OBJDIR)/$* -hidir $(OBJDIR)/$* -o $@ $<
@@ -34,9 +40,8 @@ $(OBJDIR)/%:
mkdir -p $@
-.depend_hs: $(HASKELL_SRC) $(HASKELL_AUX)
- ghc -dep-suffix '' -dep-makefile $@ -M $(GHCBASEFLAGS) $(HASKELL_SRC)
- rm -f .depend_hs.bak
- sed -i 's/\.o *:/:/; s/\.hi$$/.hs/g; s/\.hi[ \t]/.hs/g' $@
+# By default, if it's needed, just create an empty file (but don't truncate if it exists)
+.depend_hs:
+ touch $@
-include .depend_hs