Refactor the statistics gathering code in run.ml
[tatoo.git] / Remakefile.in
1 .OPTIONS = variable-propagation
2 OCAMLFINDPACKAGES = "ulex,unix,expat,camlp4.macro,bigarray"
3 OCAMLFINDSYNTAX = camlp4o
4 OCAMLFINDPPOPTS = $(addprefix "-ppopt ", @CAMLP4FLAGS@ -I include)
5 OCAMLFINDINCLUDES = $(addprefix "-I ", src)
6 OCAMLFINDFLAGS = -syntax $(OCAMLFINDSYNTAX) -package $(OCAMLFINDPACKAGES)  \
7         $(OCAMLFINDPPOPTS) $(OCAMLFINDINCLUDES)
8 OCAMLFINDLINKFLAGS = -linkpkg
9 PACKAGE = @PACKAGE_TARNAME@
10 SRC = src
11 BIN = src/@PACKAGE_TARNAME@.native@EXE@
12 BYTE = src/@PACKAGE_TARNAME@.byte@EXE@
13 EXE = @EXE@
14
15 REMAKE = @REMAKE@
16 OCAMLDEP = @OCAMLDEP@
17 ODEPS = tools/odeps.sh $(OCAMLDEP)
18 OCAMLC = @OCAMLC@
19 OCAMLOPT = @OCAMLOPT@
20 OCAMLFLAGS = @OCAMLFLAGS@ 
21 OCAMLOPTFLAGS = @OCAMLOPTFLAGS@
22 OCAMLCFLAGS = @OCAMLCFLAGS@
23 OCAMLYACC = @OCAMLYACC@
24
25 all: $(BIN)
26
27 tools: tools/xml_diff.native$(EXE) tools/XPathEval.class tools/split_path.native$(EXE)
28
29 Remakefile: Remakefile.in config.status
30         ./config.status Remakefile
31
32 configure config.status: configure.in
33         autoconf
34         ./config.status --recheck
35
36 clean:
37         for dir in src tools; do
38                 find $dir -name '*.cm*' -o -name '*.o' -o -name '*.byte' -o \
39                           -name '*.native' -o -name '*.mll' -o -name '*.mly' -o \
40                           -name '*.class' -o -name '*.depo' -o -name '*.depx' -o -name '*.ml.str' | while read file; do
41                 case "$file" in
42                         *.mll)
43                                 rm -f "${file%.mll}.ml"
44                         ;;
45                         *.mly)
46                                 rm -f "${file%.mly}.ml" "${file%.mly}.mli"
47                         ;;
48                         *.ml.str)
49                                 rm -f "${file%.ml.str}.ml"
50                         ;;
51                         *)
52                                 rm -f "$file"
53                         ;;
54                 esac
55                 done
56         done
57
58 distclean: clean test_clean
59         rm -rf config.status configure config.log autom4te.cache .remake Remakefile remake Makefile
60
61 %.class: %.java
62         javac $<
63
64 %.native$(EXE): %.cmx %.depx
65         if test -f $@".flags"; then
66                 FLAGS=`cat $@".flags"`
67         fi
68         objects=`cat $*.depx | xargs | sed 's/[.]depx/.cmx/g'`
69         $(REMAKE) OCAMLNATIVE="-native" $objects #ensure all objects have been built
70         $(OCAMLOPT) -o $@  $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $FLAGS $objects $<
71
72 %.byte$(EXE): %.cmo %.depo
73         objects=`cat $*.depo | xargs | sed 's/[.]depo/.cmo/g'`
74         $(REMAKE) OCAMLNATIVE="" $objects #ensure all objects have been built
75         $(OCAMLC) -o $@  $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $objects $<
76
77 %.ml:
78         if test -f $*.mly; then
79                 $(REMAKE) $*.mly
80                 $(OCAMLYACC) $*.mly
81         elif test -f $*.mll; then
82                 $(REMAKE) $*.mll
83                 $(OCAMLLEX) $*.mll
84         elif test -f $*.ml.str; then
85                 $(REMAKE) $*.ml.str
86                 echo -n 'let content = "' > $*.ml
87                 sed -e 's/\(["\\]\)/\\\1/g' $*.ml.str | sed -e 's/^\(.*\)$/\1\\n\\/g' >> $*.ml
88                 echo '' >> $*.ml
89                 echo '"' >> $*.ml
90         fi
91
92 %.cmx %.depx:
93         base=$*
94         target=$@
95         DEPEXT=depx
96         NATIVE=-native
97         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
98         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
99         SRC=$(SRC)
100         if test -f "$base".flags; then
101                 FLAGS=`cat "$base".flags`
102         fi
103         COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS) $FLAGS"
104         . tools/ocamldriver.sh
105
106 %.cmo %.depo:
107         base=$*
108         target=$@
109         DEPEXT=depo
110         NATIVE=""
111         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
112         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
113         SRC=$(SRC)
114         COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
115         . tools/ocamldriver.sh
116
117 %.cmi:
118         base=$*
119         target=$@
120         NATIVE=$(OCAMLNATIVE)
121         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
122         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
123         SRC=$(SRC)
124         if test -z "$NATIVE"; then
125                 DEPEXT=.depo
126                 COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
127         else
128                 COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
129                 DEPEXT=.depx
130         fi
131         . tools/ocamldriver.sh
132
133 ## Tests
134
135 test_byte: tools $(BYTE)
136         $(REMAKE) TEST=$(BYTE) real_test
137
138 test_native: tools $(BIN)
139         $(REMAKE) TEST=$(BIN) real_test
140
141 test: test_native
142
143 real_test:
144         for i in tests/*.xml
145         do
146           for j in 1 2 3
147           do
148                 $(REMAKE) TEST=$(TEST) "$i".test"$j".summary
149           done
150         done
151
152 test_clean:
153         rm -rf tests/*.summary tests/*.results/*_"$(PACKAGE)"_*.*
154
155 %.summary:
156         target=$@
157         base=$*
158         test=${base#*.xml.}
159         xml=${base%.$test}
160         REMAKE=$(REMAKE)
161         BIN=$(TEST)
162         SPLIT=tools/split_path.native$(EXE)
163         XMLDIFF=tools/xml_diff.native$(EXE)
164         PACKAGE=$(PACKAGE)
165         $REMAKE $xml ${xml}.queries tests/${test}.sh
166         rm -f "$target"
167         . tests/${test}.sh