Update to ocaml-autoconf macros 1.1
authorRichard Jones <rjones@redhat.com>
Wed, 30 Dec 2009 15:24:14 +0000 (15:24 +0000)
committerRichard Jones <rjones@redhat.com>
Wed, 30 Dec 2009 15:24:14 +0000 (15:24 +0000)
m4/ocaml.m4

index fa8c4ce..479f3a8 100644 (file)
@@ -16,7 +16,12 @@ AC_DEFUN([AC_PROG_OCAML],
   if test "$OCAMLC" != "no"; then
      OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
      AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
-     OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
+     # 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])
@@ -68,6 +73,9 @@ AC_DEFUN([AC_PROG_OCAML],
 
   AC_SUBST([OCAMLC])
 
+  # checking for ocaml toplevel
+  AC_CHECK_TOOL([OCAML],[ocaml],[no])
+
   # checking for ocamldep
   AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
 
@@ -207,11 +215,26 @@ EOF
 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`
+  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])
+])