diff mbox

[1/2] ocaml: Copy up-to-date m4/ocaml.m4 from forge.ocamlcore

Message ID 1484927202-28014-2-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Jan. 20, 2017, 3:46 p.m. UTC
From
  https://forge.ocamlcore.org/anonscm/git/ocaml-autoconf/ocaml-autoconf.git
  commit id a20a590beb523fb64bf087b52a883cf628256d2f

Copy ocaml.m4, and also LICENSE to m4/ocaml.m4.LICENSE.  (This is a
permissive licence and thus compatible with the licence of Xen.)

We mostly want this because in this version OCAMLC is set to ocamlopt
where available, or ocamlc otherwise.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 m4/ocaml.m4         | 96 ++++++++++++++++++++++++++++++-----------------------
 m4/ocaml.m4.LICENSE | 29 ++++++++++++++++
 2 files changed, 83 insertions(+), 42 deletions(-)
 create mode 100644 m4/ocaml.m4.LICENSE
diff mbox

Patch

diff --git a/m4/ocaml.m4 b/m4/ocaml.m4
index b067ee9..1d3b657 100644
--- a/m4/ocaml.m4
+++ b/m4/ocaml.m4
@@ -1,6 +1,6 @@ 
 dnl autoconf macros for OCaml
-dnl from http://forge.ocamlcore.org/
 dnl
+dnl Copyright © 2013      Gabriel Kerneis
 dnl Copyright © 2009      Richard W.M. Jones
 dnl Copyright © 2009      Stefano Zacchiroli
 dnl Copyright © 2000-2005 Olivier Andrieu
@@ -19,7 +19,7 @@  AC_DEFUN([AC_PROG_OCAML],
      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`
+        OCAMLLIB=`$OCAMLC -where 2>/dev/null | tr -d '\015' || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
      else
         AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
      fi
@@ -32,15 +32,15 @@  AC_DEFUN([AC_PROG_OCAML],
      AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
      OCAMLBEST=byte
      if test "$OCAMLOPT" = "no"; then
-	AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
+        AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
      else
-	TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
-	if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	    AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
-	    OCAMLOPT=no
-	else
-	    OCAMLBEST=opt
-	fi
+        TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+        if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+           AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
+           OCAMLOPT=no
+        else
+           OCAMLBEST=opt
+        fi
      fi
 
      AC_SUBST([OCAMLBEST])
@@ -48,25 +48,25 @@  AC_DEFUN([AC_PROG_OCAML],
      # checking for ocamlc.opt
      AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
      if test "$OCAMLCDOTOPT" != "no"; then
-	TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
-	if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	    AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
-	else
-	    OCAMLC=$OCAMLCDOTOPT
-	fi
+        TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+        if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+           AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
+        else
+           OCAMLC=$OCAMLCDOTOPT
+        fi
      fi
 
      # checking for ocamlopt.opt
      if test "$OCAMLOPT" != "no" ; then
-	AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
-	if test "$OCAMLOPTDOTOPT" != "no"; then
-	   TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
-	   if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	      AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
-	   else
-	      OCAMLOPT=$OCAMLOPTDOTOPT
-	   fi
-        fi
+        AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
+        if test "$OCAMLOPTDOTOPT" != "no"; then
+           TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+           if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+              AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
+           else
+              OCAMLOPT=$OCAMLOPTDOTOPT
+           fi
+       fi
      fi
 
      AC_SUBST([OCAMLOPT])
@@ -74,6 +74,18 @@  AC_DEFUN([AC_PROG_OCAML],
 
   AC_SUBST([OCAMLC])
 
+  # checking for native dynlink
+  AC_MSG_CHECKING([for dynlink.cmxa])
+  if test -f "$OCAMLLIB/dynlink.cmxa" ; then
+     OCAMLNATDYNLINK=yes
+     AC_MSG_RESULT([yes])
+  else
+     OCAMLNATDYNLINK=no
+     AC_MSG_RESULT([no])
+  fi
+
+  AC_SUBST([OCAMLNATDYNLINK])
+
   # checking for ocaml toplevel
   AC_CHECK_TOOL([OCAML],[ocaml],[no])
 
@@ -99,10 +111,10 @@  AC_DEFUN([AC_PROG_OCAMLLEX],
   # 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
+     AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
+     if test "$OCAMLLEXDOTOPT" != "no"; then
+        OCAMLLEX=$OCAMLLEXDOTOPT
+     fi
   fi
   AC_SUBST([OCAMLLEX])
 ])
@@ -123,7 +135,7 @@  AC_DEFUN([AC_PROG_CAMLP4],
   if test "$CAMLP4" != "no"; then
      TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
      if test "$TMPVERSION" != "$OCAMLVERSION" ; then
-	AC_MSG_RESULT([versions differs from ocamlc])
+        AC_MSG_RESULT([versions differs from ocamlc])
         CAMLP4=no
      fi
   fi
@@ -173,15 +185,15 @@  AC_DEFUN([AC_CHECK_OCAML_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
+       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
+     AC_MSG_RESULT([not found])
+     AS_TR_SH([OCAML_PKG_$1])=no
   fi
 
   AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
@@ -198,16 +210,16 @@  EOF
   unset found
   for $1 in $$1 $4 ; do
     if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
-      found=yes
-      break
+       found=yes
+       break
     fi
   done
 
   if test "$found" ; then
-    AC_MSG_RESULT([$$1])
+     AC_MSG_RESULT([$$1])
   else
-    AC_MSG_RESULT([not found])
-    $1=no
+     AC_MSG_RESULT([not found])
+     $1=no
   fi
   AC_SUBST([$1])
 ])
@@ -220,7 +232,7 @@  AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
   AC_MSG_CHECKING([for OCaml compiler word size])
   cat > conftest.ml <<EOF
   print_endline (string_of_int Sys.word_size)
-  EOF
+EOF
   OCAML_WORD_SIZE=`$OCAML conftest.ml`
   AC_MSG_RESULT([$OCAML_WORD_SIZE])
   AC_SUBST([OCAML_WORD_SIZE])
diff --git a/m4/ocaml.m4.LICENSE b/m4/ocaml.m4.LICENSE
new file mode 100644
index 0000000..d4d3d16
--- /dev/null
+++ b/m4/ocaml.m4.LICENSE
@@ -0,0 +1,29 @@ 
+Copyright © 2013      Gabriel Kerneis
+Copyright © 2009      Richard W.M. Jones
+Copyright © 2009      Stefano Zacchiroli
+Copyright © 2000-2005 Olivier Andrieu
+Copyright © 2000-2005 Jean-Christophe Filliâtre
+Copyright © 2000-2005 Georges Mariano
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+* The names of the contributors may not be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.