Makefile 1.71 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
14
	@ $(OCAMLBUILD) -build-dir _ocamlyacc               $(MAIN).native
	@ $(OCAMLBUILD) -build-dir _menhir       -tag fancy $(MAIN).native \
15
	  -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS)"
16
17
	@ $(OCAMLBUILD) -build-dir _menhir_table -tag fancy $(MAIN).native \
	  -use-menhir -menhir "$(MENHIR) $(MENHIRFLAGS) --table" -package menhirLib
18
19

clean:
POTTIER Francois's avatar
POTTIER Francois committed
20
	@ rm -f *~ .*~
21
22
23
	@ $(OCAMLBUILD) -build-dir _ocamlyacc    -clean
	@ $(OCAMLBUILD) -build-dir _menhir       -clean
	@ $(OCAMLBUILD) -build-dir _menhir_table -clean
POTTIER Francois's avatar
POTTIER Francois committed
24

25
26
27
# We try every input file whose name matches *.in.
# We parse it using each of the three parsers,
# and compare the results pairwise.
28
29

test: all
POTTIER Francois's avatar
POTTIER Francois committed
30
31
32
	@ for f in *.in ; do \
	  out=$${f%*.in}.out ; \
	  log=$${f%*.in}.log ; \
33
	  for target in _ocamlyacc _menhir _menhir_table ; do \
POTTIER Francois's avatar
POTTIER Francois committed
34
35
36
	    $$target/$(MAIN).native < $$f > $$target/$$out ; \
	  done ; \
	  if diff _ocamlyacc/$$out _menhir/$$out > $$log ; then \
37
38
39
40
41
42
43
	    echo "ocamlyacc versus menhir(code): $$f: OK" ; \
	  else \
	    echo "ocamlyacc versus menhir(code): $$f: FAILURE" ; \
	    cat $$log ; \
	  fi ; \
	  if diff _ocamlyacc/$$out _menhir_table/$$out > $$log ; then \
	    echo "ocamlyacc versus menhir(table): $$f: OK" ; \
POTTIER Francois's avatar
POTTIER Francois committed
44
	  else \
45
46
47
48
49
50
51
	    echo "ocamlyacc versus menhir(table): $$f: FAILURE" ; \
	    cat $$log ; \
	  fi ; \
	  if diff _menhir/$$out _menhir_table/$$out > $$log ; then \
	    echo "menhir(code) versus menhir(table): $$f: OK" ; \
	  else \
	    echo "menhir(code) versus menhir(table): $$f: FAILURE" ; \
POTTIER Francois's avatar
POTTIER Francois committed
52
53
54
	    cat $$log ; \
	  fi ; \
	done
55