Makefile 2.43 KB
Newer Older
1
2
3
4
5
6
7
.PHONY: all clean test

# Find Menhir.
ifndef MENHIR
  MENHIR := $(shell ../../demos/find-menhir.sh)
endif

8
MENHIRFLAGS     := --infer -v --fixed-exception
9
10
11
12
OCAMLBUILD      := ocamlbuild -use-ocamlfind
MAIN            := calc

all:
13
	cd .. && ./build.sh
14
# ocamlyacc.
POTTIER Francois's avatar
POTTIER Francois committed
15
	@ $(OCAMLBUILD) -build-dir _ocamlyacc                      $(MAIN).native
16
# Menhir, code back-end, %inline disabled.
POTTIER Francois's avatar
POTTIER Francois committed
17
	@ $(OCAMLBUILD) -build-dir _menhir_code         -tag fancy $(MAIN).native \
POTTIER Francois's avatar
POTTIER Francois committed
18
19
20
21
	  -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS) -lc 1 --comment --no-code-inlining --no-inline"
# Menhir, code back-end, %inline enabled.
	@ $(OCAMLBUILD) -build-dir _menhir_code_inline  -tag fancy $(MAIN).native \
	  -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS) -lc 1 --comment --no-code-inlining"
22
# Menhir, table back-end, %inline disabled.
POTTIER Francois's avatar
POTTIER Francois committed
23
	@ $(OCAMLBUILD) -build-dir _menhir_table        -tag fancy $(MAIN).native \
POTTIER Francois's avatar
POTTIER Francois committed
24
	  -package menhirLib -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS) --table --no-inline "
25
# Menhir, table back-end, %inline enabled.
POTTIER Francois's avatar
POTTIER Francois committed
26
	@ $(OCAMLBUILD) -build-dir _menhir_table_inline -tag fancy $(MAIN).native \
POTTIER Francois's avatar
POTTIER Francois committed
27
	  -package menhirLib -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS) --table"
28
29

clean:
POTTIER Francois's avatar
POTTIER Francois committed
30
	@ rm -f *~ .*~ *.log
POTTIER Francois's avatar
POTTIER Francois committed
31
32
	@ $(OCAMLBUILD) -build-dir _ocamlyacc           -clean
	@ $(OCAMLBUILD) -build-dir _menhir_code         -clean
POTTIER Francois's avatar
POTTIER Francois committed
33
	@ $(OCAMLBUILD) -build-dir _menhir_code_inline  -clean
POTTIER Francois's avatar
POTTIER Francois committed
34
35
	@ $(OCAMLBUILD) -build-dir _menhir_table        -clean
	@ $(OCAMLBUILD) -build-dir _menhir_table_inline -clean
POTTIER Francois's avatar
POTTIER Francois committed
36

37
# We try every input file whose name matches *.in.
38
# We parse it using each of the parsers,
39
# and compare the results pairwise.
40
41

test: all
POTTIER Francois's avatar
POTTIER Francois committed
42
	@ for f in *.in ; do \
POTTIER Francois's avatar
POTTIER Francois committed
43
44
	  base=$${f%*.in} ; \
	  out=$$base.out ; \
POTTIER Francois's avatar
POTTIER Francois committed
45
	  for target in _ocamlyacc _menhir_code _menhir_code_inline _menhir_table _menhir_table_inline ; do \
POTTIER Francois's avatar
POTTIER Francois committed
46
47
	    $$target/$(MAIN).native < $$f > $$target/$$out ; \
	  done ; \
48
49
50
51
52
	done
	@ for pair in \
	  _ocamlyacc/_menhir_code \
	  _ocamlyacc/_menhir_table \
	  _menhir_code/_menhir_table \
POTTIER Francois's avatar
POTTIER Francois committed
53
	  _menhir_code_inline/_menhir_table_inline \
POTTIER Francois's avatar
POTTIER Francois committed
54
	  _menhir_table/_menhir_table_inline \
POTTIER Francois's avatar
POTTIER Francois committed
55
	  _menhir_code/_menhir_code_inline \
56
57
58
59
60
61
	; do \
	  left=$${pair%/*} ; \
	  right=$${pair#*/} ; \
	  for f in *.in ; do \
	    base=$${f%*.in} ; \
	    out=$$base.out ; \
POTTIER Francois's avatar
POTTIER Francois committed
62
63
64
65
66
67
68
69
	    log=$$base.$$left.$$right.log ; \
	    if diff $$left/$$out $$right/$$out > $$log ; then \
	      echo "$$left versus $$right: $$f: OK" ; \
	    else \
	      echo "$$left versus $$right: $$f: FAILURE" ; \
	      cat $$log ; \
	    fi ; \
	  done ; \
POTTIER Francois's avatar
POTTIER Francois committed
70
	done
71