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