CIL: Include dynlink for OCaml 3.11.
[ocaml-bitstring.git] / aclocal.m4
1 # generated automatically by aclocal 1.11 -*- Autoconf -*-
2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 # 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 dnl autoconf macros for OCaml
15 dnl
16 dnl Copyright © 2009      Richard W.M. Jones
17 dnl Copyright © 2009      Stefano Zacchiroli
18 dnl Copyright © 2000-2005 Olivier Andrieu
19 dnl Copyright © 2000-2005 Jean-Christophe Filliâtre
20 dnl Copyright © 2000-2005 Georges Mariano
21 dnl
22 dnl For documentation, please read the ocaml.m4 man page.
23
24 AC_DEFUN([AC_PROG_OCAML],
25 [dnl
26   # checking for ocamlc
27   AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
28
29   if test "$OCAMLC" != "no"; then
30      OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
31      AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
32      # If OCAMLLIB is set, use it
33      if test "$OCAMLLIB" = ""; then
34         OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
35      else
36         AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
37      fi
38      AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
39
40      AC_SUBST([OCAMLVERSION])
41      AC_SUBST([OCAMLLIB])
42
43      # checking for ocamlopt
44      AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
45      OCAMLBEST=byte
46      if test "$OCAMLOPT" = "no"; then
47         AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
48      else
49         TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
50         if test "$TMPVERSION" != "$OCAMLVERSION" ; then
51             AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
52             OCAMLOPT=no
53         else
54             OCAMLBEST=opt
55         fi
56      fi
57
58      AC_SUBST([OCAMLBEST])
59
60      # checking for ocamlc.opt
61      AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
62      if test "$OCAMLCDOTOPT" != "no"; then
63         TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
64         if test "$TMPVERSION" != "$OCAMLVERSION" ; then
65             AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
66         else
67             OCAMLC=$OCAMLCDOTOPT
68         fi
69      fi
70
71      # checking for ocamlopt.opt
72      if test "$OCAMLOPT" != "no" ; then
73         AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
74         if test "$OCAMLOPTDOTOPT" != "no"; then
75            TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
76            if test "$TMPVERSION" != "$OCAMLVERSION" ; then
77               AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
78            else
79               OCAMLOPT=$OCAMLOPTDOTOPT
80            fi
81         fi
82      fi
83
84      AC_SUBST([OCAMLOPT])
85   fi
86
87   AC_SUBST([OCAMLC])
88
89   # checking for ocaml toplevel
90   AC_CHECK_TOOL([OCAML],[ocaml],[no])
91
92   # checking for ocamldep
93   AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
94
95   # checking for ocamlmktop
96   AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no])
97
98   # checking for ocamlmklib
99   AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no])
100
101   # checking for ocamldoc
102   AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
103
104   # checking for ocamlbuild
105   AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
106 ])
107
108
109 AC_DEFUN([AC_PROG_OCAMLLEX],
110 [dnl
111   # checking for ocamllex
112   AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
113   if test "$OCAMLLEX" != "no"; then
114     AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
115     if test "$OCAMLLEXDOTOPT" != "no"; then
116         OCAMLLEX=$OCAMLLEXDOTOPT
117     fi
118   fi
119   AC_SUBST([OCAMLLEX])
120 ])
121
122 AC_DEFUN([AC_PROG_OCAMLYACC],
123 [dnl
124   AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
125   AC_SUBST([OCAMLYACC])
126 ])
127
128
129 AC_DEFUN([AC_PROG_CAMLP4],
130 [dnl
131   AC_REQUIRE([AC_PROG_OCAML])dnl
132
133   # checking for camlp4
134   AC_CHECK_TOOL([CAMLP4],[camlp4],[no])
135   if test "$CAMLP4" != "no"; then
136      TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
137      if test "$TMPVERSION" != "$OCAMLVERSION" ; then
138         AC_MSG_RESULT([versions differs from ocamlc])
139         CAMLP4=no
140      fi
141   fi
142   AC_SUBST([CAMLP4])
143
144   # checking for companion tools
145   AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no])
146   AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no])
147   AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no])
148   AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no])
149   AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no])
150   AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no])
151   AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no])
152   AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no])
153   AC_SUBST([CAMLP4BOOT])
154   AC_SUBST([CAMLP4O])
155   AC_SUBST([CAMLP4OF])
156   AC_SUBST([CAMLP4OOF])
157   AC_SUBST([CAMLP4ORF])
158   AC_SUBST([CAMLP4PROF])
159   AC_SUBST([CAMLP4R])
160   AC_SUBST([CAMLP4RF])
161 ])
162
163
164 AC_DEFUN([AC_PROG_FINDLIB],
165 [dnl
166   AC_REQUIRE([AC_PROG_OCAML])dnl
167
168   # checking for ocamlfind
169   AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
170   AC_SUBST([OCAMLFIND])
171 ])
172
173
174 dnl Thanks to Jim Meyering for working this next bit out for us.
175 dnl XXX We should define AS_TR_SH if it's not defined already
176 dnl (eg. for old autoconf).
177 AC_DEFUN([AC_CHECK_OCAML_PKG],
178 [dnl
179   AC_REQUIRE([AC_PROG_FINDLIB])dnl
180
181   AC_MSG_CHECKING([for OCaml findlib package $1])
182
183   unset found
184   unset pkg
185   found=no
186   for pkg in $1 $2 ; do
187     if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
188       AC_MSG_RESULT([found])
189       AS_TR_SH([OCAML_PKG_$1])=$pkg
190       found=yes
191       break
192     fi
193   done
194   if test "$found" = "no" ; then
195     AC_MSG_RESULT([not found])
196     AS_TR_SH([OCAML_PKG_$1])=no
197   fi
198
199   AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
200 ])
201
202
203 AC_DEFUN([AC_CHECK_OCAML_MODULE],
204 [dnl
205   AC_MSG_CHECKING([for OCaml module $2])
206
207   cat > conftest.ml <<EOF
208 open $3
209 EOF
210   unset found
211   for $1 in $$1 $4 ; do
212     if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
213       found=yes
214       break
215     fi
216   done
217
218   if test "$found" ; then
219     AC_MSG_RESULT([$$1])
220   else
221     AC_MSG_RESULT([not found])
222     $1=no
223   fi
224   AC_SUBST([$1])
225 ])
226
227
228 dnl XXX Cross-compiling
229 AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
230 [dnl
231   AC_REQUIRE([AC_PROG_OCAML])dnl
232   AC_MSG_CHECKING([for OCaml compiler word size])
233   cat > conftest.ml <<EOF
234   print_endline (string_of_int Sys.word_size)
235   EOF
236   OCAML_WORD_SIZE=`$OCAML conftest.ml`
237   AC_MSG_RESULT([$OCAML_WORD_SIZE])
238   AC_SUBST([OCAML_WORD_SIZE])
239 ])
240
241 AC_DEFUN([AC_CHECK_OCAML_OS_TYPE],
242 [dnl
243   AC_REQUIRE([AC_PROG_OCAML])dnl
244   AC_MSG_CHECKING([OCaml Sys.os_type])
245
246   cat > conftest.ml <<EOF
247   print_string(Sys.os_type);;
248 EOF
249
250   OCAML_OS_TYPE=`$OCAML conftest.ml`
251   AC_MSG_RESULT([$OCAML_OS_TYPE])
252   AC_SUBST([OCAML_OS_TYPE])
253 ])
254