summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Andrieu <oandrieu@gmail.com>2009-12-01 23:55:40 +0100
committerOlivier Andrieu <oandrieu@gmail.com>2009-12-01 23:55:40 +0100
commit1f95a4821276f5105e21a55bcd5732024061b9c9 (patch)
tree1afd939cea2ae2759c5887404652f7ebea923708
parent78c65012b827588ca3384742674f644cc5604d89 (diff)
replace ocaml.m4 by the one from ocaml-autoconf
-rw-r--r--support/ocaml.m4367
1 files changed, 191 insertions, 176 deletions
diff --git a/support/ocaml.m4 b/support/ocaml.m4
index 8804361..326d99e 100644
--- a/support/ocaml.m4
+++ b/support/ocaml.m4
@@ -1,209 +1,224 @@
-dnl -*- autoconf -*- macros for OCaml
-dnl by Olivier Andrieu
-dnl from a configure.in by Jean-Christophe Filliâtre,
-dnl from a first script by Georges Mariano
+dnl autoconf macros for OCaml
dnl
-dnl defines AC_PROG_OCAML that will check the OCaml compiler
-dnl and set the following variables :
-dnl OCAMLC "ocamlc" if present in the path, or a failure
-dnl or "ocamlc.opt" if present with same version number as ocamlc
-dnl OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or unset
-dnl OCAMLBEST either "byte" if no native compiler was found,
-dnl "opt" otherwise
-dnl OCAMLDEP "ocamldep"
-dnl OCAMLLIB the path to the ocaml standard library
-dnl OCAMLVERSION the ocaml version number
+dnl Copyright © 2009 Richard W.M. Jones
+dnl Copyright © 2009 Stefano Zacchiroli
+dnl Copyright © 2000-2005 Olivier Andrieu
+dnl Copyright © 2000-2005 Jean-Christophe Filliâtre
+dnl Copyright © 2000-2005 Georges Mariano
dnl
-dnl OCAMLMKTOP
-dnl OCAMLMKLIB
-dnl OCAMLDOC
+dnl For documentation, please read the ocaml.m4 man page.
+
AC_DEFUN([AC_PROG_OCAML],
[dnl
-# checking for ocamlc
-AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.))
-OCAMLVERSION=$($OCAMLC -version)
-AC_MSG_RESULT(OCaml version is $OCAMLVERSION)
-OCAMLLIB=$($OCAMLC -where)
-AC_MSG_RESULT(OCaml library path is $OCAMLLIB)
-# checking for ocamlopt
-AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt)
-OCAMLBEST=byte
-if test -z "$OCAMLOPT"; then
- AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.)
-else
+ # checking for ocamlc
+ AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
+
+ if test "$OCAMLC" != "no"; then
+ OCAMLVERSION=$($OCAMLC -version)
+ AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
+ # If OCAMLLIB is set, use it
+ if test "$OCAMLLIB" = ""; then
+ OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
+ else
+ AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
+ fi
+ AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
+
+ AC_SUBST([OCAMLVERSION])
+ AC_SUBST([OCAMLLIB])
+
+ # checking for ocamlopt
+ AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
+ OCAMLBEST=byte
+ if test "$OCAMLOPT" = "no"; then
+ AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
+ else
TMPVERSION=$($OCAMLOPT -version)
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT(versions differs from ocamlc; ocamlopt discarded.)
- unset OCAMLOPT
+ AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
+ OCAMLOPT=no
else
OCAMLBEST=opt
fi
-fi
-# checking for ocamlc.opt
-AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt)
-if test "$OCAMLCDOTOPT"; then
+ fi
+
+ AC_SUBST([OCAMLBEST])
+
+ # checking for ocamlc.opt
+ AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
+ if test "$OCAMLCDOTOPT" != "no"; then
TMPVERSION=$($OCAMLCDOTOPT -version)
if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.)
+ AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
else
OCAMLC=$OCAMLCDOTOPT
fi
-fi
-# checking for ocamlopt.opt
-if test "$OCAMLOPT" ; then
- AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt)
- if test "$OCAMLOPTDOTOPT"; then
- TMPVERSION=$($OCAMLOPTDOTOPT -version)
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.)
- else
- OCAMLOPT=$OCAMLOPTDOTOPT
- fi
- fi
-fi
-# checking for ocamldep
-AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.))
-
-#checking for ocamlmktop
-AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.))
-#checking for ocamlmklib
-AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.))
-# checking for ocamldoc
-AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.))
-
-# get the C compiler used by ocamlc
-if test -z "$CC" ; then
- touch conftest.c
- CC=$($OCAMLC -verbose conftest.c 2>&1 | awk '/^+/ {print $[]2 ; exit}')
- echo OCaml uses $CC to compile C files
-fi
-
-AC_SUBST(OCAMLC)
-AC_SUBST(OCAMLOPT)
-AC_SUBST(OCAMLDEP)
-AC_SUBST(OCAMLBEST)
-AC_SUBST(OCAMLVERSION)
-AC_SUBST(OCAMLLIB)
-AC_SUBST(OCAMLMKLIB)
-AC_SUBST(OCAMLMKTOP)
-AC_SUBST(OCAMLDOC)
+ fi
+
+ # checking for ocamlopt.opt
+ if test "$OCAMLOPT" != "no" ; then
+ AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
+ if test "$OCAMLOPTDOTOPT" != "no"; then
+ TMPVERSION=$($OCAMLOPTDOTOPT -version)
+ if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+ AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
+ else
+ OCAMLOPT=$OCAMLOPTDOTOPT
+ fi
+ fi
+ fi
+ fi
+
+ # checking for ocaml toplevel
+ AC_CHECK_TOOL([OCAML],[ocaml],[no])
+
+ # checking for ocamldep
+ AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
+
+ # checking for ocamlmktop
+ AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no])
+
+ # checking for ocamlmklib
+ AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no])
+
+ # checking for ocamldoc
+ AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
+
+ # checking for ocamlbuild
+ AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
])
-dnl
-dnl
-dnl
-dnl macro AC_PROG_OCAML_TOOLS will check OCamllex and OCamlyacc :
-dnl OCAMLLEX "ocamllex" or "ocamllex.opt" if present
-dnl OCAMLYACC "ocamlyac"
-AC_DEFUN([AC_PROG_OCAML_TOOLS],
+
+
+AC_DEFUN([AC_PROG_OCAMLLEX],
[dnl
-# checking for ocamllex and ocamlyacc
-AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,AC_MSG_ERROR(Cannot find ocamllex.))
-if test "$OCAMLLEX"; then
- AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt)
- if test "$OCAMLLEXDOTOPT"; then
+ # checking for ocamllex
+ AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
+ if test "$OCAMLLEX" != "no"; then
+ AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
+ if test "$OCAMLLEXDOTOPT" != "no"; then
OCAMLLEX=$OCAMLLEXDOTOPT
fi
-else
- AC_MSG_ERROR(Cannot find ocamllex.)
-fi
-AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,AC_MSG_ERROR(Cannot find ocamlyacc.))
-AC_SUBST(OCAMLLEX)
-AC_SUBST(OCAMLYACC)
+ fi
])
-dnl
-dnl
-dnl
-dnl AC_PROG_CAMLP4 checks for Camlp4
+
+AC_DEFUN([AC_PROG_OCAMLYACC],
+[dnl
+ AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
+])
+
+
AC_DEFUN([AC_PROG_CAMLP4],
[dnl
-AC_REQUIRE([AC_PROG_OCAML])
-# checking for camlp4
-AC_CHECK_PROG(CAMLP4,camlp4,camlp4)
-if test "$CAMLP4"; then
- TMPVERSION=$($CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p')
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_ERROR(versions differs from ocamlc)
- else
- AC_CHECK_PROG(CAMLP4O,camlp4o,camlp4o)
- fi
-fi
-AC_SUBST(CAMLP4)
-AC_SUBST(CAMLP4O)
+ AC_REQUIRE([AC_PROG_OCAML])dnl
+
+ # checking for camlp4
+ AC_CHECK_TOOL([CAMLP4],[camlp4],[no])
+ if test "$CAMLP4" != "no"; then
+ TMPVERSION=$($CAMLP4 -version)
+ if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+ AC_MSG_RESULT([versions differs from ocamlc])
+ CAMLP4=no
+ fi
+ fi
+
+ # checking for companion tools
+ AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no])
+ AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no])
+ AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no])
+ AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no])
+ AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no])
+ AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no])
+ AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no])
+ AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no])
])
-dnl
-dnl
-dnl
-dnl macro AC_PROG_FINDLIB will check for the presence of
-dnl ocamlfind if configure is called with --with-findlib
+
+
AC_DEFUN([AC_PROG_FINDLIB],
[dnl
-AC_ARG_WITH(findlib,[ --with-findlib use findlib package system],
- use_findlib="$withval")
-# checking for ocamlfind
-if test "$use_findlib" = yes ; then
- AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind,
- AC_MSG_ERROR(ocamlfind not found))
-else
- unset OCAMLFIND
-fi
-AC_SUBST(OCAMLFIND)
+ AC_REQUIRE([AC_PROG_OCAML])dnl
+
+ # checking for ocamlfind
+ AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
])
-dnl
-dnl
-dnl
-dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present
-dnl defines pkg_name to name
+
+
+dnl Thanks to Jim Meyering for working this next bit out for us.
+dnl XXX We should define AS_TR_SH if it's not defined already
+dnl (eg. for old autoconf).
AC_DEFUN([AC_CHECK_OCAML_PKG],
[dnl
-AC_REQUIRE([AC_PROG_FINDLIB])
-if test "$use_findlib" = yes ; then
- AC_MSG_CHECKING(findlib package $1)
- if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then
- AC_MSG_RESULT(found)
- pkg_$1="$1"
- else
- AC_MSG_WARN(not found)
- unset pkg_$1
- fi
-fi
-])
-dnl
-dnl
-dnl
-dnl AC_ARG_OCAML_INSTALLDIR adds a --with-installdir option
-AC_DEFUN([AC_ARG_OCAML_INSTALLDIR],
-[dnl
-AC_ARG_WITH(installdir,[ --with-installdir=DIR specify installation directory],INSTALLDIR="$withval")
-if ! test "$INSTALLDIR" -o "$use_findlib" ; then
- INSTALLDIR='$(OCAMLLIB)/$(NAME)'
-fi
-AC_SUBST(INSTALLDIR)
+ AC_REQUIRE([AC_PROG_FINDLIB])dnl
+
+ AC_MSG_CHECKING([for OCaml findlib package $1])
+
+ unset found
+ unset pkg
+ found=no
+ for pkg in $1 $2 ; do
+ if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
+ AC_MSG_RESULT([found])
+ AS_TR_SH([OCAML_PKG_$1])=$pkg
+ found=yes
+ break
+ fi
+ done
+ if test "$found" = "no" ; then
+ AC_MSG_RESULT([not found])
+ AS_TR_SH([OCAML_PKG_$1])=no
+ fi
+
+ AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
])
-dnl
-dnl
-dnl
-dnl AC_CHECK_OCAML_MODULE looks for a module in a given path
-dnl 1 -> name (for printing)
-dnl 2 -> env var name
-dnl 3 -> module to check
-dnl 4 -> default dirs
+
+
AC_DEFUN([AC_CHECK_OCAML_MODULE],
[dnl
-AC_MSG_CHECKING($1 directory)
-cat > conftest.ml <<EOF
+ AC_MSG_CHECKING([for OCaml module $2])
+
+ cat > conftest.ml <<EOF
open $3
EOF
-unset found
-for $2 in $$2 $4 ; do
- if $OCAMLC -c -I "$$2" conftest.ml > /dev/null 2>&1 ; then
- found=yes
- break
+ unset found
+ for $1 in $$1 $4 ; do
+ if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
+ found=yes
+ break
+ fi
+ done
+
+ if test "$found" ; then
+ AC_MSG_RESULT([$$1])
+ else
+ AC_MSG_RESULT([not found])
+ $1=no
fi
-done
-if test "$found" ; then
- AC_MSG_RESULT($$2)
-else
- AC_MSG_RESULT(not found)
- unset $2
-fi
-AC_SUBST($2)])
+ AC_SUBST([$1])
+])
+
+
+dnl XXX Cross-compiling
+AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
+[dnl
+ AC_REQUIRE([AC_PROG_OCAML])dnl
+ AC_MSG_CHECKING([for OCaml compiler word size])
+ cat > conftest.ml <<EOF
+ print_endline (string_of_int Sys.word_size)
+ EOF
+ OCAML_WORD_SIZE=`$OCAML conftest.ml`
+ AC_MSG_RESULT([$OCAML_WORD_SIZE])
+ AC_SUBST([OCAML_WORD_SIZE])
+])
+
+AC_DEFUN([AC_CHECK_OCAML_OS_TYPE],
+[dnl
+ AC_REQUIRE([AC_PROG_OCAML])dnl
+ AC_MSG_CHECKING([OCaml Sys.os_type])
+
+ cat > conftest.ml <<EOF
+ print_string(Sys.os_type);;
+EOF
+
+ OCAML_OS_TYPE=`$OCAML conftest.ml`
+ AC_MSG_RESULT([$OCAML_OS_TYPE])
+ AC_SUBST([OCAML_OS_TYPE])
+])