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