-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (47 loc) · 2.17 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
CXX=g++ -std=c++11
MAINFILE=code/main
STRATEGIES=naive
ALLOUTPUTS=$(foreach strategy, $(STRATEGIES), $(patsubst data/%.in, data/$(strategy).%.ans, $(wildcard data/*.in)))
ALLVISUALIZATIONS=$(foreach strategy, $(STRATEGIES), $(patsubst data/%.in, data/$(strategy).%.png, $(filter-out data/big.in, $(wildcard data/*.in))))
all: data visualizations
data: $(ALLOUTPUTS)
visualizations: $(ALLVISUALIZATIONS)
sample: $(foreach strategy, $(STRATEGIES), data/$(strategy).example.ans)
build: clean
zip -r build.zip code visualizations README.md Makefile LICENSE .gitignore grader
clean:
rm -f $(MAINFILE) $(ALLOUTPUTS) $(ALLVISUALIZATIONS) grader/main grades.html
grader/main: $(wildcard grader/*.cpp)
$(CXX) -o grader/main grader/main.cpp
grades.html: grader/main
grader/main > grades.html
$(MAINFILE): $(wildcard code/*.cpp)
$(CXX) -o $(MAINFILE) $(MAINFILE).cpp
# One block per algorithm
# Template for naive algorithm:
# data/naive.%.ans: $(MAINFILE)
# $(MAINFILE) naive < $(@:data/naive.%.ans=data/%.in) > $@
data/naive.%.ans: $(MAINFILE)
$(MAINFILE) naive < $(@:data/naive.%.ans=data/%.in) > $@
## Visualization
# compile
visualize/%.class: $(@:%.class=%.java)
javac -cp visualize $(@:%.class=%.java)
visualize/vis: $(wildcard visualize/*.cpp)
$(CXX) -o visualize/vis visualize/AnswerToGnu.cpp
# input pictures
data/%.in.dat: visualize/InputToGnu.class data/%.in
java -cp visualize InputToGnu < $(@:%.dat=%) > $@
data/%.in.png: visualize/InputToGnu.class data/%.in.dat
gnuplot -e "datafile='$(@:data/%.png=data/%.dat)';outputname='$@'" visualize/plot_input.plg
data/%.in.dat: visualize/InputToGnu.class
java -cp visualize InputToGnu < $(@:%.dat=%) > $@
# One block per algorithm
# Java Example
# data/naive.%.ans.dat: data/naive.%.ans visualize/AnswerToGnu.class
# java -cp visualize AnswerToGnu $(@:data/naive.%.ans.dat=data/%.in) $(@:%.dat=%) > $@
# naive output pictures
data/naive.%.ans.dat: data/naive.%.ans visualize/vis
visualize/vis $(@:%.dat=%) < $(@:data/naive.%.ans.dat=data/%.in) > $@
data/naive.%.png: data/naive.%.ans.dat data/%.in.dat
gnuplot -e "datafile='$(@:data/naive.%.png=data/%.in.dat)';datafile2='$(@:%.png=%.ans.dat)'; outputname='$@'" visualize/plot_balloons.plg