forked from douglasgscofield/tinyutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (73 loc) · 2.53 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
UTILS = boolify \
cumsum \
diffs \
hist \
inrange \
log \
log10 \
max \
mean \
median \
min \
mult \
range \
round \
stripfilt \
sum \
table
ZIPFILE = tinyutils.zip
TARBALL = tinyutils.tar.gz
TESTDIR = tests
TESTINPUT = tinyutils.dat
TESTEXPECT = tinyutils.expected
TESTOUTPUT = tinyutils.output
TESTDIFF = tinyutils.testdiff
all: test $(ZIPFILE) $(TARBALL)
$(ZIPFILE): $(UTILS) $(TESTDIR) Makefile README.md
@if [ -e $(TESTDIR)/$(TESTDIFF) -o -e $(TESTDIR)/$(TESTOUTPUT) ] ; then \
echo "$(TESTDIR)/ still contains $(TESTDIFF) and/or $(TESTOUTPUT)" ; \
exit 1; \
fi ;
@( rm -f $@ ; \
chmod 755 $(UTILS) $(TESTDIR); \
chmod 644 $(TESTDIR)/* Makefile README.md; \
zip -r $@ $^ && echo "Created $@" ; \
)
$(TARBALL): $(UTILS) $(TESTDIR) Makefile README.md
@if [ -e $(TESTDIR)/$(TESTDIFF) -o -e $(TESTDIR)/$(TESTOUTPUT) ] ; then \
echo "$(TESTDIR)/ still contains $(TESTDIFF) and/or $(TESTOUTPUT)" ; \
exit 1; \
fi ;
@( rm -f $@ ; \
chmod 755 $(UTILS) $(TESTDIR); \
chmod 644 $(TESTDIR)/* Makefile README.md; \
tar cvzf $@ $^ && echo "Created $@" ; \
)
test: $(TESTDIR)/$(TESTOUTPUT)
@( cd $(TESTDIR); \
if diff $(TESTOUTPUT) $(TESTEXPECT) > $(TESTDIFF) ; then \
echo "PASSED tinyutils test" ; \
rm -f $(TESTOUTPUT) $(TESTDIFF) ; \
else \
echo "FAILED** tinyutils test, diff file in $(TESTDIR)/$(TESTDIFF)" ; \
fi ; \
)
# Sort table output for comparison because keys come out in various orders
$(TESTDIR)/$(TESTOUTPUT): $(UTILS)
@( cd $(TESTDIR); rm -f $(TESTDIFF) ; \
cat /dev/null > $(TESTOUTPUT) ; \
for U in boolify cumsum diffs hist log log10 max mean median min range stripfilt sum ; do \
echo $$U >> $(TESTOUTPUT) ;\
../$$U $(TESTINPUT) >> $(TESTOUTPUT) ; \
done ; \
echo 'mult mult=2' >> $(TESTOUTPUT); ../mult mult=2 $(TESTINPUT) >> $(TESTOUTPUT) ; \
echo 'round digits=0' >> $(TESTOUTPUT); ../round digits=0 $(TESTINPUT) >> $(TESTOUTPUT) ; \
echo 'table | sort -k1,1 -n' >> $(TESTOUTPUT); ../table $(TESTINPUT) | sort -k1,1 -n >> $(TESTOUTPUT) ; \
echo 'stripfilt inverse=1' >> $(TESTOUTPUT); ../stripfilt inverse=1 $(TESTINPUT) >> $(TESTOUTPUT) ; \
echo 'stripfilt header=0 inverse=1' >> $(TESTOUTPUT); ../stripfilt header=0 inverse=1 $(TESTINPUT) >> $(TESTOUTPUT) ; \
echo 'inrange min=1 max=8' >> $(TESTOUTPUT); ../inrange min=1 max=8 $(TESTINPUT) >> $(TESTOUTPUT) ; \
echo 'inrange abs=4' >> $(TESTOUTPUT); ../inrange abs=4 $(TESTINPUT) >> $(TESTOUTPUT) ; \
)
clean:
rm -f $(ZIPFILE) ; ( cd $(TESTDIR) ; rm -f $(TESTDIFF) $(TESTOUTPUT) )
.PHONY: $(UTILS)