Updated MANIFEST.
[virt-mem.git] / aclocal.m4
1 dnl autoconf macros for OCaml
2 dnl by Olivier Andrieu
3 dnl modified by Richard W.M. Jones
4 dnl from a configure.in by Jean-Christophe FilliĆ¢tre,
5 dnl from a first script by Georges Mariano
6 dnl
7 dnl defines AC_PROG_OCAML that will check the OCaml compiler
8 dnl and set the following variables :
9 dnl   OCAMLC        "ocamlc" if present in the path, or a failure
10 dnl                 or "ocamlc.opt" if present with same version number as ocamlc
11 dnl   OCAMLOPT      "ocamlopt" (or "ocamlopt.opt" if present), or "no"
12 dnl   OCAMLBEST     either "byte" if no native compiler was found, 
13 dnl                 or "opt" otherwise
14 dnl   OCAMLDEP      "ocamldep"
15 dnl   OCAMLLIB      the path to the ocaml standard library
16 dnl   OCAMLVERSION  the ocaml version number
17 AC_DEFUN(AC_PROG_OCAML,
18 [dnl
19 # checking for ocamlc
20 AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.))
21 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
22 AC_MSG_RESULT(OCaml version is $OCAMLVERSION)
23 OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
24 AC_MSG_RESULT(OCaml library path is $OCAMLLIB)
25 # checking for ocamlopt
26 AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt)
27 OCAMLBEST=byte
28 if test -z "$OCAMLOPT"; then
29         AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.)
30 else
31         TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
32         if test "$TMPVERSION" != "$OCAMLVERSION" ; then
33             AC_MSG_RESULT(versions differs from ocamlc; ocamlopt discarded.)
34             unset OCAMLOPT
35         else
36             OCAMLBEST=opt
37         fi
38 fi
39 # checking for ocamlc.opt
40 AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt)
41 if test -z "$OCAMLCDOTOPT"; then
42         TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
43         if test "$TMPVERSION" != "$OCAMLVERSION" ; then
44             AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.)
45         else
46             OCAMLC=$OCAMLCDOTOPT
47         fi
48 fi
49 # checking for ocamlopt.opt
50 if test "$OCAMLOPT" ; then
51     AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt)
52     if test "$OCAMLOPTDOTOPT"; then
53         TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
54         if test "$TMPVER" != "$OCAMLVERSION" ; then
55             AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.)
56         else
57             OCAMLOPT=$OCAMLOPTDOTOPT
58         fi
59     fi
60 fi
61 # checking for ocamldep
62 AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.))
63
64 #checking for ocamlmktop
65 AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.))
66 #checking for ocamlmklib
67 AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.))
68 # checking for ocamldoc
69 AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.))
70
71
72 AC_SUBST(OCAMLC)
73 AC_SUBST(OCAMLOPT)
74 AC_SUBST(OCAMLDEP)
75 AC_SUBST(OCAMLBEST)
76 AC_SUBST(OCAMLVERSION)
77 AC_SUBST(OCAMLLIB)
78 AC_SUBST(OCAMLMKLIB)
79 AC_SUBST(OCAMLDOC)
80 ])
81
82
83 dnl macro AC_PROG_OCAML_TOOLS will check OCamllex and OCamlyacc :
84 dnl   OCAMLLEX      "ocamllex" or "ocamllex.opt" if present
85 dnl   OCAMLYACC     "ocamlyac"
86 AC_DEFUN(AC_PROG_OCAML_TOOLS,
87 [dnl
88 # checking for ocamllex and ocamlyacc
89 AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex)
90 if test "$OCAMLLEX"; then
91     AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt)
92     if test "$OCAMLLEXDOTOPT"; then
93         OCAMLLEX=$OCAMLLEXDOTOPT
94     fi
95 else
96         AC_MSG_ERROR(Cannot find ocamllex.)
97 fi
98 AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,AC_MSG_ERROR(Cannot find ocamlyacc.))
99 AC_SUBST(OCAMLLEX)
100 AC_SUBST(OCAMLYACC)
101 ])
102
103
104 dnl AC_PROG_CAMLP4 checks for Camlp4
105 AC_DEFUN(AC_PROG_CAMLP4,
106 [dnl
107 AC_REQUIRE([AC_PROG_OCAML])
108 # checking for camlp4
109 AC_CHECK_PROG(CAMLP4,camlp4,camlp4)
110 if test "$CAMLP4"; then
111         TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
112         if test "$TMPVERSION" != "$OCAMLVERSION" ; then
113             AC_MSG_RESULT(versions differs from ocamlc)
114         fi
115 fi
116 ])
117
118
119 dnl macro AC_PROG_FINDLIB will check for the presence of
120 dnl   ocamlfind
121 AC_DEFUN(AC_PROG_FINDLIB,
122 [dnl
123 # checking for ocamlfind
124 AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind,
125         AC_MSG_WARN([ocamlfind not found]))
126 AC_SUBST(OCAMLFIND)
127 ])
128
129
130 dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present
131 dnl   defines pkg_name to "yes"
132 AC_DEFUN(AC_CHECK_OCAML_PKG,
133 [dnl
134 AC_REQUIRE([AC_PROG_FINDLIB])
135 AC_MSG_CHECKING(findlib package $1)
136 if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then
137 AC_MSG_RESULT(found)
138 eval "pkg_`echo $1 | tr - _`=yes"
139 else
140 AC_MSG_RESULT(not found)
141 eval "pkg_`echo $1 | tr - _`=no"
142 fi
143 ])
144
145
146 dnl AC_CHECK_OCAML_MODULE looks for a module in a given path
147 dnl 1st arg -> name (just for printing messages)
148 dnl 2nd arg -> env var name (set to include path, or "no" if not found)
149 dnl 3rd arg -> module to check
150 dnl 4th arg -> default include dirs to check
151 AC_DEFUN([AC_CHECK_OCAML_MODULE],
152 [dnl
153 AC_MSG_CHECKING(for module $1)
154 cat > conftest.ml <<EOF
155 open $3
156 EOF
157 unset found
158 for $2 in $$2 $4 ; do
159   if $OCAMLC -c -I "$$2" conftest.ml >&5 2>&5 ; then
160     found=yes
161     break
162   fi
163 done
164 if test "$found" ; then
165   AC_MSG_RESULT($$2)
166 else
167   AC_MSG_RESULT(not found)
168   $2=no
169 fi
170 AC_SUBST($2)])
171
172
173 dnl AC_CHECK_OCAML_WORD_SIZE(var) sets var=32 or var=64
174 dnl according to the compiler word size.
175 dnl Contributed by Richard W.M. Jones <rjones@redhat.com>
176 dnl XXX This completely fails to deal with cross-compiler case.
177 AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
178 [dnl
179 AC_MSG_CHECKING(for OCaml compiler word size)
180 cat > conftest.ml <<EOF
181 print_endline (string_of_int Sys.word_size)
182 EOF
183 $1=`ocaml conftest.ml`
184 AC_MSG_RESULT($$1)
185 AC_SUBST($1)])