1 # generated automatically by aclocal 1.12.2 -*- Autoconf -*-
3 # Copyright (C) 1996-2012 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.
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
14 dnl autoconf macros for OCaml
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
22 dnl For documentation, please read the ocaml.m4 man page.
24 AC_DEFUN([AC_PROG_OCAML],
27 AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
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`
36 AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
38 AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
40 AC_SUBST([OCAMLVERSION])
43 # checking for ocamlopt
44 AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
46 if test "$OCAMLOPT" = "no"; then
47 AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
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.])
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.])
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.])
79 OCAMLOPT=$OCAMLOPTDOTOPT
89 # checking for ocaml toplevel
90 AC_CHECK_TOOL([OCAML],[ocaml],[no])
92 # checking for ocamldep
93 AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
95 # checking for ocamlmktop
96 AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no])
98 # checking for ocamlmklib
99 AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no])
101 # checking for ocamldoc
102 AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
104 # checking for ocamlbuild
105 AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
109 AC_DEFUN([AC_PROG_OCAMLLEX],
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
122 AC_DEFUN([AC_PROG_OCAMLYACC],
124 AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
125 AC_SUBST([OCAMLYACC])
129 AC_DEFUN([AC_PROG_CAMLP4],
131 AC_REQUIRE([AC_PROG_OCAML])dnl
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])
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])
156 AC_SUBST([CAMLP4OOF])
157 AC_SUBST([CAMLP4ORF])
158 AC_SUBST([CAMLP4PROF])
164 AC_DEFUN([AC_PROG_FINDLIB],
166 AC_REQUIRE([AC_PROG_OCAML])dnl
168 # checking for ocamlfind
169 AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
170 AC_SUBST([OCAMLFIND])
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],
179 AC_REQUIRE([AC_PROG_FINDLIB])dnl
181 AC_MSG_CHECKING([for OCaml findlib package $1])
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
194 if test "$found" = "no" ; then
195 AC_MSG_RESULT([not found])
196 AS_TR_SH([OCAML_PKG_$1])=no
199 AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
203 AC_DEFUN([AC_CHECK_OCAML_MODULE],
205 AC_MSG_CHECKING([for OCaml module $2])
207 cat > conftest.ml <<EOF
211 for $1 in $$1 $4 ; do
212 if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
218 if test "$found" ; then
221 AC_MSG_RESULT([not found])
228 dnl XXX Cross-compiling
229 AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
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)
236 OCAML_WORD_SIZE=`$OCAML conftest.ml`
237 AC_MSG_RESULT([$OCAML_WORD_SIZE])
238 AC_SUBST([OCAML_WORD_SIZE])
241 AC_DEFUN([AC_CHECK_OCAML_OS_TYPE],
243 AC_REQUIRE([AC_PROG_OCAML])dnl
244 AC_MSG_CHECKING([OCaml Sys.os_type])
246 cat > conftest.ml <<EOF
247 print_string(Sys.os_type);;
250 OCAML_OS_TYPE=`$OCAML conftest.ml`
251 AC_MSG_RESULT([$OCAML_OS_TYPE])
252 AC_SUBST([OCAML_OS_TYPE])