summaryrefslogtreecommitdiff
path: root/2020/Makefile
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-12-01 12:02:17 +0100
committerTom Smeding <tom.smeding@gmail.com>2020-12-01 12:02:17 +0100
commitec5353f4018c7e1ad56d521e38ec06af8d938d97 (patch)
tree27a3df1ef495ae9070d54bd7433b5c816a06c28f /2020/Makefile
parent1fb24f91c66fb320721760a2f8fa92f1e873b4c4 (diff)
Start of 2020
Diffstat (limited to '2020/Makefile')
-rw-r--r--2020/Makefile42
1 files changed, 42 insertions, 0 deletions
diff --git a/2020/Makefile b/2020/Makefile
new file mode 100644
index 0000000..b48727b
--- /dev/null
+++ b/2020/Makefile
@@ -0,0 +1,42 @@
+GHC = ghc
+GHCFLAGS = -Wall -O2 -threaded
+CXX = g++
+CXXFLAGS = -Wall -Wextra -std=c++17 -O2
+
+OBJDIR = obj
+
+HASKELL_AUX := Input.hs
+CPP_AUX :=
+HASKELL_SRC := $(filter-out $(HASKELL_AUX),$(wildcard *.hs))
+CPP_SRC := $(filter-out $(CPP_AUX),$(wildcard *.cpp))
+HASKELL_BIN := $(HASKELL_SRC:.hs=)
+CPP_BIN := $(CPP_SRC:.cpp=)
+
+BINARIES := $(HASKELL_BIN) $(CPP_BIN)
+
+.PHONY: all clean
+
+
+all: $(BINARIES)
+
+clean:
+ rm -f $(BINARIES) .depend_hs
+ rm -rf $(OBJDIR)
+
+$(HASKELL_BIN): %: %.hs | $(OBJDIR)/%
+ $(GHC) $(GHCFLAGS) -odir $(OBJDIR)/$* -hidir $(OBJDIR)/$* -o $@ $<
+
+$(CPP_BIN): %: %.cpp $(CPP_AUX) | $(OBJDIR)
+ $(CXX) $(CXXFLAGS) -o $@ $<
+
+$(OBJDIR)/%:
+ mkdir -p $@
+
+
+.depend_hs: $(HASKELL_SRC) $(HASKELL_AUX)
+ ghc -dep-suffix '' -dep-makefile $@ -M $(HASKELL_SRC)
+ rm -f .depend_hs.bak
+ sed 's/\.o *:/:/; s/\.hi$$/.hs/g; s/\.hi[ \t]/.hs/g' <$@ >$@.tmp
+ mv $@.tmp $@
+
+-include .depend_hs