Remove passing $NATIVE on the remake command line of every target, since variable...
[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 distclean
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 %.cmo %.depo:
109         base=$*
110         target=$@
111         DEPEXT=depo
112         REMAKE="$(REMAKE)"
113         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
114         OCAMLNATIVE=$(OCAMLNATIVE)
115         SRC=$(SRC)
116         COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFIND_EXTRAFLAGS) "
117         . tools/ocamldriver.sh
118
119 %.cmi:
120         base=$*
121         target=$@
122         REMAKE="$(REMAKE)"
123         OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
124         SRC=$(SRC)
125         OCAMLNATIVE=$(OCAMLNATIVE)
126         if test -z "$OCAMLNATIVE"; then
127                 DEPEXT=.depo
128                 COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
129         else
130                 COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
131                 DEPEXT=.depx
132         fi
133         . tools/ocamldriver.sh
134
135 ## Tests
136
137 test_byte: tools $(BYTE)
138         $(REMAKE) TEST=$(BYTE) real_test
139
140 test_native: tools $(BIN)
141         $(REMAKE) TEST=$(BIN) real_test
142
143 test: test_native
144
145 real_test:
146         for i in tests/*.xml
147         do
148           for j in 1 2 3
149           do
150                 $(REMAKE) TEST=$(TEST) "$i".test"$j".summary
151           done
152         done
153
154 test_clean:
155         rm -rf tests/*.summary tests/*.results/*_"$(PACKAGE)"_*.*
156
157 %.summary:
158         target=$@
159         base=$*
160         test=${base#*.xml.}
161         xml=${base%.$test}
162         REMAKE=$(REMAKE)
163         BIN=$(TEST)
164         SPLIT=tools/split_path.native$(EXE)
165         XMLDIFF=tools/xml_diff.native$(EXE)
166         PACKAGE=$(PACKAGE)
167         $REMAKE $xml ${xml}.queries tests/${test}.sh
168         rm -f "$target"
169         . tests/${test}.sh