Split the formula cache into a top-down and bottom-up cache.
[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' | 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                         *)
49                         rm -f "$file"
50                         ;;
51                 esac
52                 done
53         done
54
55 distclean: clean test_clean
56         rm -rf config.status configure config.log autom4te.cache .remake Remakefile remake Makefile
57
58 %.class: %.java
59         javac $<
60
61 %.native$(EXE): %.cmx %.depx
62         if test -f $@".flags"; then
63                 FLAGS=`cat $@".flags"`
64         fi
65         objects=`cat $*.depx | xargs | sed 's/[.]depx/.cmx/g'`
66         $(REMAKE) OCAMLNATIVE="-native" $objects #ensure all objects have been built
67         $(OCAMLOPT) -o $@  $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $FLAGS $objects $<
68
69 %.byte$(EXE): %.cmo %.depo
70         objects=`cat $*.depo | xargs | sed 's/[.]depo/.cmo/g'`
71         $(REMAKE) OCAMLNATIVE="" $objects #ensure all objects have been built
72         $(OCAMLC) -o $@  $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $objects $<
73
74 %.ml:
75         if test -f $*.mly; then
76                 $(REMAKE) $*.mly
77                 $(OCAMLYACC) $*.mly
78         elif test -f $*.mll; then
79                 $(REMAKE) $*.mll
80                 $(OCAMLLEX) $*.mll
81         fi
82
83 %.cmx %.depx:
84         base=$*
85         target=$@
86         DEPEXT=depx
87         NATIVE=-native
88         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
89         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
90         SRC=$(SRC)
91         if test -f "$base".flags; then
92                 FLAGS=`cat "$base".flags`
93         fi
94         COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS) $FLAGS"
95         . tools/ocamldriver.sh
96
97 %.cmo %.depo:
98         base=$*
99         target=$@
100         DEPEXT=depo
101         NATIVE=""
102         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
103         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
104         SRC=$(SRC)
105         COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
106         . tools/ocamldriver.sh
107
108 %.cmi:
109         base=$*
110         target=$@
111         NATIVE=$(OCAMLNATIVE)
112         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
113         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
114         SRC=$(SRC)
115         if test -z "$NATIVE"; then
116                 DEPEXT=.depo
117                 COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
118         else
119                 COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
120                 DEPEXT=.depx
121         fi
122         . tools/ocamldriver.sh
123
124 ## Tests
125
126 test_byte: tools $(BYTE)
127         $(REMAKE) TEST=$(BYTE) real_test
128
129 test_native: tools $(BIN)
130         $(REMAKE) TEST=$(BIN) real_test
131
132 test: test_native
133
134 real_test:
135         for i in tests/*.xml
136         do
137           for j in 1 2 3
138           do
139                 $(REMAKE) TEST=$(TEST) "$i".test"$j".summary
140           done
141         done
142
143 test_clean:
144         rm -rf tests/*.summary tests/*.results/*_"$(PACKAGE)"_*.*
145
146 %.summary:
147         target=$@
148         base=$*
149         test=${base#*.xml.}
150         xml=${base%.$test}
151         REMAKE=$(REMAKE)
152         BIN=$(TEST)
153         SPLIT=tools/split_path.native$(EXE)
154         XMLDIFF=tools/xml_diff.native$(EXE)
155         PACKAGE=$(PACKAGE)
156         $REMAKE $xml ${xml}.queries tests/${test}.sh
157         rm -f "$target"
158         . tests/${test}.sh