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