-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (49 loc) · 1.14 KB
/
Makefile
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
54
55
56
57
58
59
60
#The Makefile for bfc
#
#Providies conviniance for building and cleaning the project.
#
#Author: John Berg
#The name of the target file.
TARGET := bfc
#Project directories.
out := $(CURDIR)/build
obj := $(CURDIR)/obj
src := $(CURDIR)/src
#Tools.
RM := rm -rf
GHC := ghc
#The compiler flags to be used turing compilaiton.
CFLAGS :=
CFLAGS += -tmpdir $(obj)
CFLAGS += -odir $(obj)
CFLAGS += -hidir $(obj)
CFLAGS += -i$(obj)
CFLAGS += -O3
CFLAGS += -Wall
CFLAGS += -o
#A variable for storing all the rules which are not actual targets.
PHONY :=
#Default rule.
#Build the projcet.
all: build
#Build the project.
PHONY += build
build: $(out)/$(TARGET)
#Make the projcet.
#Create the obj and out directory if they do not exist.
#Compile all the haskell source files.
$(out)/$(TARGET): $(wildcard $(src)/*.hs)
$(mkdir -p $(obj))
$(mkdir -p $(out))
$(GHC) $(CFLAGS) $@ $^
#Rebuild the project.
#Clean the project then build the project.
PHONY += rebuild
rebuild: clean build
#Clean the project.
#Remove all the .hi .o files in the out and obj directories.
PHONY += clean
clean:
$(RM) $(obj)/*.o $(obj)*.hi $(out)/bfc
#Mark PHONY as .PHONY
.PHONY: PHONY