-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
70 lines (53 loc) · 1.5 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
CONFIG = config.json
DATACHECK = data/data.complete
LOGS = log.csv log.json
PLOTCHECK = plots/plots.complete
SCREENSHOTS = *.ps
DATASET = $(DATACHECK) \
data/*[[:digit:]]*.config \
data/*.csv \
data/*.json \
data/*.sh
PLOTS = $(PLOTCHECK) \
plots/*.pdf
CLEAN = $(DATASET) \
$(LOGS) \
$(PLOTS) \
$(SCREENSHOTS)
# Change to python3 (or other alias) if needed
PYTHON = python
SUGARSCAPE = sugarscape.py
# Check for local Python aliases
PYCHECK = $(shell which python > /dev/null; echo $$?)
PY3CHECK = $(shell which python3 > /dev/null; echo $$?)
$(DATACHECK):
cd data && $(PYTHON) run.py --conf ../$(CONFIG) --mode csv
touch $(DATACHECK)
$(PLOTCHECK): $(DATACHECK)
cd plots && $(PYTHON) plot.py --path ../data/ --conf ../$(CONFIG)
touch $(PLOTCHECK)
all: $(DATACHECK) $(PLOTCHECK)
data: $(DATACHECK)
plots: $(PLOTCHECK)
seeds:
cd data && $(PYTHON) run.py --conf ../$(CONFIG) --mode csv --seeds
setup:
@echo "Checking for local Python installation."
ifeq ($(PY3CHECK), 0)
@echo "Found alias for Python."
sed -i 's/PYTHON = python$$/PYTHON = python3/g' Makefile
sed -i 's/"python"/"python3"/g' $(CONFIG)
else ifneq ($(PYCHECK), 0)
@echo "Could not find a local Python installation."
@echo "Please update the Makefile and configuration file manually."
else
@echo "This message should never be reached."
endif
test:
$(PYTHON) $(SUGARSCAPE) --conf $(CONFIG)
clean:
rm -rf $(CLEAN) || true
lean:
rm -rf $(PLOTS) || true
.PHONY: all clean data lean plots setup
# vim: set noexpandtab tabstop=4: