1b54199365041008a4537d5657ed9c50a5b3e0b3
[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 OCAMLFINDFLAGSNOSYNTAX = -package $(OCAMLFINDPACKAGES) $(OCAMLFINDPPOPTS) $(OCAMLFINDINCLUDES)
7 OCAMLFINDFLAGS = -syntax $(OCAMLFINDSYNTAX) $(OCAMLFINDFLAGSNOSYNTAX)
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 MENHIR = @MENHIR@
24
25
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): %.cmx %.depx
70         if test -f $@".flags"; then
71                 FLAGS=`cat $@".flags"`
72         fi
73         objects=`cat $*.depx | xargs | sed 's/[.]depx/.cmx/g'`
74         $(REMAKE) OCAMLNATIVE="-native" $objects #ensure all objects have been built
75         $(OCAMLOPT) -o $@  $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $FLAGS $objects $<
76
77 %.byte$(EXE): %.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 $<
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         NATIVE=-native
102         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
103         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
104         SRC=$(SRC)
105         COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
106         . tools/ocamldriver.sh
107
108 %.cmo %.depo:
109         base=$*
110         target=$@
111         DEPEXT=depo
112         NATIVE=""
113         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
114         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS) $(OCAMLFIND_EXTRAFLAGS)"
115         SRC=$(SRC)
116         COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFIND_EXTRAFLAGS) "
117
118         . tools/ocamldriver.sh
119
120 %.cmi:
121         base=$*
122         target=$@
123         NATIVE=$(OCAMLNATIVE)
124         REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
125         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
126         SRC=$(SRC)
127         if test -z "$NATIVE"; 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 test_byte: tools $(BYTE)
139         $(REMAKE) TEST=$(BYTE) real_test
140
141 test_native: tools $(BIN)
142         $(REMAKE) TEST=$(BIN) real_test
143
144 test: test_native
145
146 real_test:
147         for i in tests/*.xml
148         do
149           for j in 1 2 3
150           do
151                 $(REMAKE) TEST=$(TEST) "$i".test"$j".summary
152           done
153         done
154
155 test_clean:
156         rm -rf tests/*.summary tests/*.results/*_"$(PACKAGE)"_*.*
157
158 %.summary:
159         target=$@
160         base=$*
161         test=${base#*.xml.}
162         xml=${base%.$test}
163         REMAKE=$(REMAKE)
164         BIN=$(TEST)
165         SPLIT=tools/split_path.native$(EXE)
166         XMLDIFF=tools/xml_diff.native$(EXE)
167         PACKAGE=$(PACKAGE)
168         $REMAKE $xml ${xml}.queries tests/${test}.sh
169         rm -f "$target"
170         . tests/${test}.sh