forked from caradoc-org/caradoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (76 loc) · 3.24 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
OCAML_OPTS=-w,+a-3-4-32..39-58,-warn-error,+a,-strict-sequence,-noautolink
PROGRAM=caradoc
ML= $(shell find $(pwd) -name "*.ml")
MLI= $(shell find $(pwd) -name "*.mli")
INDENTML= $(ML:.ml=.indentml)
INDENTMLI= $(MLI:.mli=.indentmli)
PDFPOS= $(shell find test_files/positive -name "*.pdf")
PDFNEG= $(shell find test_files/negative -name "*.pdf")
PDFCLEANUP= $(shell find test_files/cleanup -name "*.pdf")
TRAILERNEG= $(shell find test_files/negative -name "*.trailer")
XREFNEG= $(shell find test_files/negative -name "*.xref")
CLEANNEG= $(shell find test_files/negative -name "*.clean")
TYPESNEG= $(shell find test_files/negative -name "*.types")
TESTSTATS= $(PDFPOS:.pdf=.teststats) $(PDFNEG:.pdf=.teststats)
TESTSTATS_STRICT= $(PDFPOS:.pdf=.teststats_strict) $(PDFNEG:.pdf=.teststats_strict)
TESTTRAILER= $(PDFPOS:.pdf=.testtrailer) $(TRAILERNEG:.trailer=.testtrailer)
TESTXREF= $(PDFPOS:.pdf=.testxref) $(XREFNEG:.xref=.testxref)
TESTCLEANUP= $(PDFPOS:.pdf=.testcleanup) $(CLEANNEG:.clean=.testcleanup)
TESTCLEANUP_OPTIONS= $(PDFCLEANUP:.pdf=.testcleanup_options)
TESTTYPES= $(PDFPOS:.pdf=.testtypes) $(TYPESNEG:.types=.testtypes)
TESTS= $(TESTSTATS) $(TESTSTATS_STRICT) $(TESTTRAILER) $(TESTXREF) $(TESTCLEANUP) $(TESTCLEANUP_OPTIONS) $(TESTTYPES)
BINDIR ?= /usr/bin
all: $(PROGRAM)
test: unit.byte unit.native $(TESTS)
./unit.byte
./unit.native
indent: $(INDENTML) $(INDENTMLI)
$(PROGRAM): main.native
cp -P main.native $(PROGRAM)
debug-menhir:
ocamlbuild -use-ocamlfind -menhir "menhir --dump --trace" src/main.native
main.byte main.native:
ocamlbuild -cflags $(OCAML_OPTS) -use-ocamlfind src/$@
rm -f $@
ln -s _build/src/$@
unit.byte unit.native:
ocamlbuild -cflags $(OCAML_OPTS) -tag-line "true: package(oUnit)" -use-ocamlfind -no-hygiene test/$@
rm -f $@
ln -s _build/test/$@
%.indentml: %.ml
ocp-indent -i $<
%.indentmli: %.mli
ocp-indent -i $<
tmpfolder:
mkdir -p tmp
%.teststats: %.pdf %.stats $(PROGRAM)
./$(PROGRAM) stats $< 2>&1 | cmp -s $*.stats -
%.teststats_strict: %.pdf %.stats $(PROGRAM)
./$(PROGRAM) stats --strict $< 2>&1 | cmp -s $*.stats_strict -
%.testtrailer: %.pdf %.trailer $(PROGRAM)
./$(PROGRAM) trailer --sort-dicts $< | cmp -s $*.trailer -
%.testxref: %.pdf %.xref $(PROGRAM) tmpfolder
./$(PROGRAM) xref $< | cmp -s $*.xref -;
./$(PROGRAM) extract --xref tmp/xref $< > /dev/null;
cmp -s $*.xref tmp/xref
%.testcleanup: %.pdf %.clean $(PROGRAM) tmpfolder
./$(PROGRAM) cleanup --merge-content-streams --out tmp/clean $<;
cmp -s $*.clean tmp/clean
./$(PROGRAM) cleanup --merge-content-streams --out tmp/clean $*.clean;
cmp -s $*.clean tmp/clean
%.testcleanup_options: %.pdf %.options %.clean $(PROGRAM) tmpfolder
./$(PROGRAM) cleanup --merge-content-streams --options $*.options --out tmp/clean $<;
cmp -s $*.clean tmp/clean
./$(PROGRAM) cleanup --merge-content-streams --options $*.options --out tmp/clean $*.clean;
cmp -s $*.clean tmp/clean
%.testtypes: %.pdf %.types $(PROGRAM) tmpfolder
./$(PROGRAM) extract --types tmp/types $< > /dev/null;
cmp -s $*.types tmp/types
.PHONY: main.native unit.native main.byte unit.byte all test clean indent
clean:
rm -f $(PROGRAM) *.native *.byte
rm -Rf _build
rm -f oUnit-anon.cache
rm -Rf tmp
install: $(PROGRAM)
install -D -m 0755 "$(PROGRAM)" "$(BINDIR)/$$(basename $(PROGRAM))"