2a32aa2ea4ac2ef9e0447a38513825a025d4e2ca
[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 tools: tools/xml_diff.native$(EXE) tools/XPathEval.class tools/split_path.native$(EXE)
30
31 Remakefile: Remakefile.in config.status
32         ./config.status Remakefile
33
34 configure config.status: configure.in
35         autoconf
36         ./config.status --recheck
37
38 clean:
39         for dir in src tools; do
40                 find $dir -name '*.cm*' -o -name '*.o' -o -name '*.byte' -o \
41                           -name '*.native' -o -name '*.mll' -o -name '*.mly' -o \
42                           -name '*.class' -o -name '*.depo' -o -name '*.depx' -o -name '*.ml.str' | while read file; do
43                 case "$file" in
44                         *.mll)
45                                 rm -f "${file%.mll}.ml"
46                         ;;
47                         *.mly)
48                                 rm -f "${file%.mly}.ml" "${file%.mly}.mli"
49                         ;;
50                         *.ml.str)
51                                 rm -f "${file%.ml.str}.ml"
52                         ;;
53                         *)
54                                 rm -f "$file"
55                         ;;
56                 esac
57                 done
58         done
59
60 distclean: clean test_clean
61         rm -rf config.status configure config.log autom4te.cache .remake Remakefile remake Makefile
62
63 %.class: %.java
64         javac $<
65
66 %.native$(EXE):
67         $(REMAKE) OCAMLNATIVE="-native" $*.cmx $*.depx
68         objects=`cat $*.depx | xargs | sed 's/[.]depx/.cmx/g'`
69         $(REMAKE) OCAMLNATIVE="-native" $objects #ensure all objects have been built
70         $(OCAMLOPT) -o $@  $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $objects $*.cmx
71
72
73 %.byte$(EXE):
74         $(REMAKE) OCAMLNATIVE="" $*.cmo $*.depo
75         objects=`cat $*.depo | xargs | sed 's/[.]depo/.cmo/g'`
76         $(REMAKE) OCAMLNATIVE="" $objects #ensure all objects have been built
77         $(OCAMLC) -o $@  $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $objects $*.cmo
78
79 %.ml:
80         if test -f $*.mly; then
81                 $(REMAKE) $*.mly
82                 #Work around menhir warning
83                 $(MENHIR) $*.mly 2>&1 | grep -v -- 'you are\|--infer'
84                 #Work around crazy ulex chocking on identifier 'lexer', generated by menhir.
85                 cat $*.ml | sed -e 's/\blexer\b/__lexer/g' > $*.tmp
86                 mv $*.tmp $*.ml
87         elif test -f $*.mll; then
88                 $(REMAKE) $*.mll
89                 $(OCAMLLEX) $*.mll
90         elif test -f $*.ml.str; then
91                 $(REMAKE) $*.ml.str
92                 echo -n 'let content = "' > $*.ml
93                 sed -e 's/\(["\\]\)/\\\1/g' $*.ml.str | sed -e 's/^\(.*\)$/\1\\n\\/g' >> $*.ml
94                 echo '' >> $*.ml
95                 echo '"' >> $*.ml
96         fi
97
98 %.cmx %.depx:
99         base=$*
100         target=$@
101         DEPEXT=depx
102         REMAKE="$(REMAKE)"
103         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
104         OCAMLNATIVE=$(OCAMLNATIVE)
105         SRC=$(SRC)
106         COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
107         . tools/ocamldriver.sh
108
109
110 %.cmo %.depo:
111         base=$*
112         target=$@
113         DEPEXT=depo
114         REMAKE="$(REMAKE)"
115         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
116         OCAMLNATIVE=$(OCAMLNATIVE)
117         SRC=$(SRC)
118         COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
119         . tools/ocamldriver.sh
120
121 %.cmi:
122         base=$*
123         target=$@
124         REMAKE="$(REMAKE)"
125         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
126         SRC=$(SRC)
127         OCAMLNATIVE=$(OCAMLNATIVE)
128         if test -z "$OCAMLNATIVE"; then
129                 DEPEXT=.depo
130                 COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
131         else
132                 COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
133                 DEPEXT=.depx
134         fi
135         . tools/ocamldriver.sh
136
137 ## Tests
138
139
140 real_test:
141         echo $(TEST)
142         for i in tests/*.xml
143         do
144           for j in 1 2 3
145           do
146                 $(REMAKE) TEST=$(TEST) "$i".test"$j".summary
147           done
148         done
149
150 test_byte:
151          $(REMAKE) TEST=$(BYTE) real_test
152 test_native:
153         $(REMAKE) TEST=$(BIN) real_test
154
155 test: test_native
156
157 test_clean:
158         rm -rf tests/*.summary tests/*.results/*_"$(PACKAGE)"_*.*
159
160 %.summary:
161         $(REMAKE) tools $(TEST)
162         target=$@
163         base=$*
164         test=${base#*.xml.}
165         xml=${base%.$test}
166         REMAKE=$(REMAKE)
167         BIN=$(TEST)
168         SPLIT=tools/split_path.native$(EXE)
169         XMLDIFF=tools/xml_diff.native$(EXE)
170         PACKAGE=$(PACKAGE)
171         $REMAKE $xml ${xml}.queries tests/${test}.sh
172         rm -f "$target"
173         . tests/${test}.sh