blob: bacaeff15736ea32fd358d24ff229df929bd7c2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
GHC = ghc
GHCBASEFLAGS = -package parsec -package array
GHCFLAGS = $(GHCBASEFLAGS) -Wall -O2 -threaded -fdefer-typed-holes
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++17 -O2
FUTHARK = futhark
OBJDIR = obj
HASKELL_AUX := Input.hs Util.hs Asm.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=)
FUTHARK_SRC := $(wildcard *.fut)
FUTHARK_BIN := $(FUTHARK_SRC:.fut=)
BINARIES := $(HASKELL_BIN) $(CPP_BIN) $(FUTHARK_BIN)
.PHONY: all clean depend
all: $(BINARIES)
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 $@ $<
$(CPP_BIN): %: %.cpp $(CPP_AUX) | $(OBJDIR)
$(CXX) $(CXXFLAGS) -o $@ $<
$(FUTHARK_BIN): %: %.fut
$(FUTHARK) c $<
$(OBJDIR)/%:
mkdir -p $@
# By default, if it's needed, just create an empty file (but don't truncate if it exists)
.depend_hs:
touch $@
-include .depend_hs
|