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