-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathMakefile
143 lines (115 loc) · 4.64 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
SOURCES=TypeCheck.hs PrettyPrint.hs LayoutToken.hs Parser.hs Syntax.hs Environment.hs Modules.hs Main.hs Equal.hs
TESTS=Makefile Logic.pi Equality.pi Nat.pi Product.pi Fin.pi Vec.pi List.pi Lambda0.pi Lambda1.pi Lambda2.pi
SRCS=$(addprefix src/,$(SOURCES))
EXTRA=LICENSE README.md pi-forall.cabal Setup.hs stack.yaml
VERSION1=$(addprefix ../version1/,$(SRCS)) $(addprefix ../version1/test/,Lec1.pi Hw1.pi) $(EXTRA)
VERSION2=$(addprefix ../version2/,$(SRCS)) $(addprefix ../version2/test/,Lec1.pi Hw1.pi Lec2.pi Hw2.pi NatChurch.pi) $(EXTRA)
VERSION2=$(addprefix ../version3/,$(SRCS)) $(addprefix ../version3/test/,Lec1.pi Hw1.pi Lec2.pi Hw2.pi NatChurch.pi) $(EXTRA)
SOLNS=$(addprefix ../full/,$(SRCS)) $(addprefix ../full/test/, $(TESTS) Lec1.pi Hw1.pi Lec2.pi Hw2.pi Lec3.pi Fin1.pi Lec4.pi)
STUBREGEX='BEGIN { undef $$/; } s/[\{][-]\s*?SOLN.*?STUBWITH(\s*\r?\n|\s)(.*?)\s*[-][\}]/$$2/sg'
SOLNREGEX='BEGIN { undef $$/; } s/[\{][-]\s*?SOLN\s*?[-][\}](\s*\r?\n|\s)(.*?)[\{][-]\s*STUBWITH(\s*\r?\n|\s)(.*?)\s*[-][\}]/$$2/sg'
flags=
all: version1 version2 version3 full
test : all
BUILD = cabal new-build --disable-documentation
EXEC = cabal new-exec pi-forall --
version1: $(VERSION1)
cd ../version1 && $(BUILD)
test_version1: ../version1
cd ../version1 && $(EXEC) test/Lec1.pi
version2: $(VERSION2)
cd ../version2 && $(BUILD)
test_version2 : ../version2
cd ../version2 && $(EXEC) test/Lec1.pi
cd ../version2 && $(EXEC) test/Lec2.pi
cd ../version2 && $(EXEC) test/Hw1.pi
cd ../version2 && $(EXEC) test/Hw2.pi
cd ../version2 && $(EXEC) test/NatChurch.pi
version3: $(VERSION3)
cd ../version3 && $(BUILD)
full: $(SOLNS) Makefile $(EXTRA)
cd ../full && $(BUILD)
test_full: ../full
cd ../full/test && make
uninstall:
-ghc-pkg unregister `ghc-pkg list | grep pi-forall`
@echo
@echo You need to manually delete any pi-forall binaries on your path.
@echo You can find them with \`which pi-forall\`
clean:
-rm -rf src/dist src/cabal-dev ../version1/ ../version2/ ../full/ dist/
test:
cd test && make
# adds a link to the executable in the test directory
pi: cabal-dev
cabal-dev install --disable-documentation .
ln -fs `pwd`/cabal-dev/bin/pi-forall test
# You need to have the cabal install dir on your path (by default
# ~/.cabal/bin) so that `cabal-dev` command is found.
cabal-dev:
cabal install --overwrite-policy=always cabal-dev
../version1/% : % Makefile $(EXTRA)
@echo ========== Creating Version 1 ==========
@mkdir -p ../version1
@mkdir -p ../version1/src
@mkdir -p ../version1/test
-chmod 640 $@
cp $< $@
perl -i -pe $(subst SOLN,SOLN HW,$(STUBREGEX)) $@
perl -i -pe $(subst SOLN,SOLN DATA,$(STUBREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EQUAL,$(STUBREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EP,$(STUBREGEX)) $@
cp pi-forall.cabal ../version1/pi-forall.cabal
cp LICENSE ../version1/LICENSE
cp README.md ../version1/README.md
cp Setup.hs ../version1/Setup.hs
cp stack.yaml ../version1/stack.yaml
../version2/% : % Makefile $(EXTRA)
@echo ========== Creating ../Version 2 ==========
@mkdir -p ../version2
@mkdir -p ../version2/src
@mkdir -p ../version2/test
-chmod 640 $@
cp $< $@
perl -i -pe $(subst SOLN,SOLN HW,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EQUAL,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN DATA,$(STUBREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EP,$(STUBREGEX)) $@
cp pi-forall.cabal ../version2/pi-forall.cabal
cp LICENSE ../version2/LICENSE
cp README.md ../version2/README.md
cp Setup.hs ../version2/Setup.hs
cp stack.yaml ../version2/stack.yaml
../version3/% : % Makefile $(EXTRA)
@echo ========== Creating ../Version 3 ==========
@mkdir -p ../version3
@mkdir -p ../version3/src
@mkdir -p ../version3/test
-chmod 640 $@
cp $< $@
perl -i -pe $(subst SOLN,SOLN HW,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EQUAL,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN DATA,$(STUBREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EP,$(SOLNREGEX)) $@
cp pi-forall.cabal ../version3/pi-forall.cabal
cp LICENSE ../version3/LICENSE
cp README.md ../version3/README.md
cp Setup.hs ../version3/Setup.hs
cp stack.yaml ../version3/stack.yaml
../full/% : % Makefile $(EXTRA)
@echo ========== Creating .hs Fulls ==========
@mkdir -p ../full/
@mkdir -p ../full/src
@mkdir -p ../full/test
-chmod 640 $@
cp $< $@
perl -i -pe $(subst SOLN,SOLN HW,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN DATA,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EQUAL,$(SOLNREGEX)) $@
perl -i -pe $(subst SOLN,SOLN EP,$(SOLNREGEX)) $@
cp pi-forall.cabal ../full/pi-forall.cabal
cp LICENSE ../full/LICENSE
cp README.md ../full/README.md
cp Setup.hs ../full/Setup.hs
cp stack.yaml ../full/stack.yaml
# chmod 440 $@ # prevent inadvertent modification of stub code