From 1d0733a27006b06eef712f541000a8bf10246804 Mon Sep 17 00:00:00 2001 From: Thierry Martinez Date: Wed, 7 Sep 2022 15:45:32 +0200 Subject: [PATCH] Compability with OCaml 5.0, bundles update, fix warnings This commit makes coccinelle compilable with OCaml 5.0. (Coccinelle should still compile with all previous versions of OCaml from 3.12.) This commit updates pyml to the last released version (2022-09-06), for compatiblity with OCaml 5.0, and fixes the other bundles to remove the warnings. --- Makefile | 14 +- Makefile.config.in | 4 +- autogen | 2 + bundles/parmap/Makefile | 5 + bundles/parmap/parmap/.gitignore | 2 + bundles/parmap/parmap/bytearray.ml.in | 25 +- bundles/parmap/parmap/config.h.in | 17 +- bundles/parmap/parmap/configure | 7059 ----------------- bundles/parmap/parmap/configure.ac | 15 +- bundles/parmap/parmap/parmap.ml | 17 +- bundles/parmap/parmap/parmap.mli | 2 +- bundles/parmap/parmap/parmap_utils.ml | 2 +- bundles/parmap/parmap/setcore_stubs.c | 12 +- bundles/pcre/pcre-ocaml/src/pcre.ml | 1055 +++ bundles/pcre/pcre-ocaml/src/pcre_stubs.c | 864 ++ bundles/pyml/Makefile | 19 +- bundles/pyml/pyml-current/.gitignore | 4 + bundles/pyml/pyml-current/CHANGES.md | 148 +- bundles/pyml/pyml-current/LICENSE | 45 +- bundles/pyml/pyml-current/Makefile | 107 +- bundles/pyml/pyml-current/README.md | 17 +- bundles/pyml/pyml-current/dune | 58 +- bundles/pyml/pyml-current/dune-project | 32 +- bundles/pyml/pyml-current/generate.ml | 30 +- bundles/pyml/pyml-current/numpy.ml | 40 +- bundles/pyml/pyml-current/numpy.mli | 39 +- bundles/pyml/pyml-current/numpy_stubs.c | 27 +- bundles/pyml/pyml-current/numpy_tests.ml | 134 + bundles/pyml/pyml-current/py.ml | 853 +- bundles/pyml/pyml-current/py.mli | 118 +- bundles/pyml/pyml-current/pycaml.mli | 1 - bundles/pyml/pyml-current/pyml.opam | 38 +- bundles/pyml/pyml-current/pyml_arch.ml.c | 20 + bundles/pyml/pyml-current/pyml_arch.mli | 10 +- bundles/pyml/pyml-current/pyml_arch_cygwin.ml | 16 - bundles/pyml/pyml-current/pyml_arch_darwin.ml | 12 - bundles/pyml/pyml-current/pyml_arch_unix.ml | 12 - bundles/pyml/pyml-current/pyml_stubs.c | 356 +- bundles/pyml/pyml-current/pyml_stubs.h | 55 +- bundles/pyml/pyml-current/pyml_tests.ml | 81 +- .../pyml/pyml-current/pyml_tests_common.ml | 9 +- .../pyml/pyml-current/pyml_tests_common.mli | 2 + bundles/pyml/pyml-current/pyops.ml.405 | 0 .../pyml-current/{pyops.ml => pyops.ml.new} | 0 bundles/pyml/pyml-current/pyops.mli.405 | 0 .../pyml-current/{pyops.mli => pyops.mli.new} | 0 bundles/pyml/pyml-current/pyutils.ml | 21 +- bundles/pyml/pyml-current/pyutils.mli | 13 - configure.ac | 7 +- 49 files changed, 3727 insertions(+), 7692 deletions(-) delete mode 100755 bundles/parmap/parmap/configure create mode 100644 bundles/pcre/pcre-ocaml/src/pcre.ml create mode 100644 bundles/pcre/pcre-ocaml/src/pcre_stubs.c create mode 100644 bundles/pyml/pyml-current/pyml_arch.ml.c delete mode 100644 bundles/pyml/pyml-current/pyml_arch_cygwin.ml delete mode 100644 bundles/pyml/pyml-current/pyml_arch_darwin.ml delete mode 100644 bundles/pyml/pyml-current/pyml_arch_unix.ml create mode 100644 bundles/pyml/pyml-current/pyops.ml.405 rename bundles/pyml/pyml-current/{pyops.ml => pyops.ml.new} (100%) create mode 100644 bundles/pyml/pyml-current/pyops.mli.405 rename bundles/pyml/pyml-current/{pyops.mli => pyops.mli.new} (100%) diff --git a/Makefile b/Makefile index 0070bfa3f..962c11c6e 100644 --- a/Makefile +++ b/Makefile @@ -98,11 +98,15 @@ PREFIX_spatch := PREFIX_spgen := tools/spgen/source/ -CORE_LIBS := unix bigarray str \ +CORE_LIBS := unix str \ $(STDCOMPATDIR)/stdcompat \ $(patsubst %,bytes,$(BYTESDIR)) \ $(patsubst %,pcre,$(filter %/pcre.cma,$(LNKLIBS))) +ifeq ($(OCAMLATLEAST50),no) +CORE_LIBS += bigarray +endif + ifeq ($(FEATURE_OCAML),1) CORE_LIBS += dynlink endif @@ -184,6 +188,10 @@ SEARCH_PATHS := \ commons/ocamlextra $(LIBRARIES) $(PREFIX_spgen) $(PCREDIR) $(PYMLDIR) \ $(PARMAPDIR) $(BYTESDIR) $(STDCOMPATDIR) +ifneq ($(OCAMLATLEAST50),no) +SEARCH_PATHS += +str +unix +dynlink +endif + SEARCH_PATH_FLAGS := $(addprefix -I ,$(SEARCH_PATHS)) CCLIB := $(patsubst %,-cclib -lparmap_stubs,$(filter %/parmap.cma,$(LNKLIBS))) \ @@ -466,11 +474,11 @@ endif ifneq ($(PARMAP_LIB),) ifeq ($(NATIVE),yes) -$(PARMAP_LIB): +$(PARMAP_LIB): $(STDCOMPAT_LIB) $(MAKE) -C bundles/parmap all $(MAKE) -C bundles/parmap all.opt else -$(PARMAP_LIB): +$(PARMAP_LIB): $(STDCOMPAT_LIB) $(MAKE) -C bundles/parmap all endif endif diff --git a/Makefile.config.in b/Makefile.config.in index 8687e1635..674b84731 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -126,4 +126,6 @@ PYCOCCI_FILE=@PYCOCCI_FILE@ OCAMLCOCCI_FILE=@OCAMLCOCCI_FILE@ REGEXP_FILE=@REGEXP_FILE@ -MENHIR_FLAGS=@DEFAULT_MENHIR_FLAGS@ \ No newline at end of file +MENHIR_FLAGS=@DEFAULT_MENHIR_FLAGS@ + +OCAMLATLEAST50=@OCAMLATLEAST50@ \ No newline at end of file diff --git a/autogen b/autogen index 107e370da..ad70c3cc2 100755 --- a/autogen +++ b/autogen @@ -6,5 +6,7 @@ else fi aclocal -I setup autoconf -Wall +( cd bundles/parmap/parmap && \ + autoconf -Wall ) ( cd bundles/stdcompat/stdcompat-current && \ autoheader && aclocal && automake && autoconf -Wall ) diff --git a/bundles/parmap/Makefile b/bundles/parmap/Makefile index d225217c9..3d1cb91b7 100644 --- a/bundles/parmap/Makefile +++ b/bundles/parmap/Makefile @@ -11,9 +11,14 @@ LIBRARY=parmap SRC_DIR=$(PACKAGE_DIR) OCAMLCCFLAGS+=-ccopt -D_GNU_SOURCE +OCAMLFLAGS+=-I $(STDCOMPATDIR) include ../Makefile.bundles +ifneq ($(OCAMLATLEAST50),no) +OCAMLFLAGS += -I +unix +endif + parmap/bytearray.cmo : parmap/bytearray.cmi .prepare: diff --git a/bundles/parmap/parmap/.gitignore b/bundles/parmap/parmap/.gitignore index d0cd88791..5938774cc 100644 --- a/bundles/parmap/parmap/.gitignore +++ b/bundles/parmap/parmap/.gitignore @@ -2,6 +2,8 @@ log* *~ _build Makefile +configure config.h config.log config.status +bytearray.ml \ No newline at end of file diff --git a/bundles/parmap/parmap/bytearray.ml.in b/bundles/parmap/parmap/bytearray.ml.in index 2ea347e7b..c117b545b 100644 --- a/bundles/parmap/parmap/bytearray.ml.in +++ b/bundles/parmap/parmap/bytearray.ml.in @@ -36,7 +36,14 @@ let unsafe_blit_to_string a i s j l = *) external unsafe_blit_from_string : string -> int -> t -> int -> int -> unit - = "ml_blit_string_to_bigarray" "noalloc" + = "ml_blit_string_to_bigarray" + @BEGIN_FROM_4_02_0@ + [@@noalloc] + @END_FROM_4_02_0@ + @BEGIN_BEFORE_4_02_0@ + "noalloc" + @END_BEFORE_4_02_0@ + (* external unsafe_blit_to_bytes : t -> int -> bytes -> int -> int -> unit = "ml_blit_bigarray_to_string" "noalloc" @@ -114,10 +121,22 @@ external unmarshal : t -> int -> 'a = "ml_unmarshal_from_bigarray" external unsafe_blit_from_floatarray : float array -> int -> tf -> int -> int -> unit - = "ml_blit_floatarray_to_bigarray" "noalloc" + = "ml_blit_floatarray_to_bigarray" + @BEGIN_FROM_4_02_0@ + [@@noalloc] + @END_FROM_4_02_0@ + @BEGIN_BEFORE_4_02_0@ + "noalloc" + @END_BEFORE_4_02_0@ external unsafe_blit_to_floatarray : tf -> int -> float array -> int -> int -> unit - = "ml_blit_bigarray_to_floatarray" "noalloc" + = "ml_blit_bigarray_to_floatarray" + @BEGIN_FROM_4_02_0@ + [@@noalloc] + @END_FROM_4_02_0@ + @BEGIN_BEFORE_4_02_0@ + "noalloc" + @END_BEFORE_4_02_0@ let to_floatarray a l = let fa = Obj.obj (Obj.new_block Obj.double_array_tag l) in diff --git a/bundles/parmap/parmap/config.h.in b/bundles/parmap/parmap/config.h.in index 6f50bb6d2..d93bf96a1 100644 --- a/bundles/parmap/parmap/config.h.in +++ b/bundles/parmap/parmap/config.h.in @@ -1,9 +1,5 @@ /* config.h.in. Generated from configure.ac by autoheader. */ -/* Define to 1 if you have the declaration of `sched_setaffinity', and to 0 if - you don't. */ -#undef HAVE_DECL_SCHED_SETAFFINITY - /* Define to 1 if you have the declaration of `thread_policy_set', and to 0 if you don't. */ #undef HAVE_DECL_THREAD_POLICY_SET @@ -14,15 +10,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MACH_THREAD_POLICY_H -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SCHED_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -59,5 +52,7 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS diff --git a/bundles/parmap/parmap/configure b/bundles/parmap/parmap/configure deleted file mode 100755 index 6ecea3125..000000000 --- a/bundles/parmap/parmap/configure +++ /dev/null @@ -1,7059 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for parmap 1.0-rc7. -# -# Report bugs to . -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: roberto@dicosmo.org about your system, including any -$0: error possibly output before this message. Then install -$0: a modern shell, or manually run the script under such a -$0: shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='parmap' -PACKAGE_TARNAME='parmap' -PACKAGE_VERSION='1.0-rc7' -PACKAGE_STRING='parmap 1.0-rc7' -PACKAGE_BUGREPORT='roberto@dicosmo.org' -PACKAGE_URL='' - -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='LTLIBOBJS -LIBOBJS -MAINT -MAINTAINER_MODE_FALSE -MAINTAINER_MODE_TRUE -C_END_BEFORE_4_06_0 -C_BEGIN_BEFORE_4_06_0 -END_BEFORE_4_06_0 -BEGIN_BEFORE_4_06_0 -C_END_FROM_4_06_0 -C_BEGIN_FROM_4_06_0 -END_FROM_4_06_0 -BEGIN_FROM_4_06_0 -EGREP -GREP -CPP -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -OCAMLFIND -OCAMLBUILD -OCAMLDOC -OCAMLMKLIB -OCAMLMKTOP -OCAMLDEP -OCAML -OCAMLNATDYNLINK -OCAMLOPTDOTOPT -OCAMLCDOTOPT -OCAMLBEST -OCAMLOPT -OCAMLLIB -OCAMLVERSION -OCAMLC -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -runstatedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_maintainer_mode -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures parmap 1.0-rc7 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/parmap] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of parmap 1.0-rc7:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-maintainer-mode - enable make rules and dependencies not useful (and - sometimes confusing) to the casual installer - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -parmap configure 1.0-rc7 -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( $as_echo "## ---------------------------------- ## -## Report this to roberto@dicosmo.org ## -## ---------------------------------- ##" - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -# --------------------------------------------- -# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by parmap $as_me 1.0-rc7, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - # checking for ocamlc - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlc", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLC"; then - ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLC="${ac_tool_prefix}ocamlc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLC=$ac_cv_prog_OCAMLC -if test -n "$OCAMLC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLC" >&5 -$as_echo "$OCAMLC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLC"; then - ac_ct_OCAMLC=$OCAMLC - # Extract the first word of "ocamlc", so it can be a program name with args. -set dummy ocamlc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLC"; then - ac_cv_prog_ac_ct_OCAMLC="$ac_ct_OCAMLC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLC="ocamlc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLC=$ac_cv_prog_ac_ct_OCAMLC -if test -n "$ac_ct_OCAMLC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLC" >&5 -$as_echo "$ac_ct_OCAMLC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLC" = x; then - OCAMLC="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLC=$ac_ct_OCAMLC - fi -else - OCAMLC="$ac_cv_prog_OCAMLC" -fi - - - if test "$OCAMLC" != "no"; then - OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml version is $OCAMLVERSION" >&5 -$as_echo "OCaml version is $OCAMLVERSION" >&6; } - # If OCAMLLIB is set, use it - if test "$OCAMLLIB" = ""; then - OCAMLLIB=`$OCAMLC -where 2>/dev/null | tr -d '\015' || $OCAMLC -v|tail -1|cut -d ' ' -f 4` - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCAMLLIB previously set; preserving it." >&5 -$as_echo "OCAMLLIB previously set; preserving it." >&6; } - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml library path is $OCAMLLIB" >&5 -$as_echo "OCaml library path is $OCAMLLIB" >&6; } - - - - - # checking for ocamlopt - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlopt", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlopt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLOPT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLOPT"; then - ac_cv_prog_OCAMLOPT="$OCAMLOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLOPT="${ac_tool_prefix}ocamlopt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLOPT=$ac_cv_prog_OCAMLOPT -if test -n "$OCAMLOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPT" >&5 -$as_echo "$OCAMLOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLOPT"; then - ac_ct_OCAMLOPT=$OCAMLOPT - # Extract the first word of "ocamlopt", so it can be a program name with args. -set dummy ocamlopt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLOPT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLOPT"; then - ac_cv_prog_ac_ct_OCAMLOPT="$ac_ct_OCAMLOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLOPT="ocamlopt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLOPT=$ac_cv_prog_ac_ct_OCAMLOPT -if test -n "$ac_ct_OCAMLOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPT" >&5 -$as_echo "$ac_ct_OCAMLOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLOPT" = x; then - OCAMLOPT="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLOPT=$ac_ct_OCAMLOPT - fi -else - OCAMLOPT="$ac_cv_prog_OCAMLOPT" -fi - - OCAMLBEST=byte - if test "$OCAMLOPT" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find ocamlopt; bytecode compilation only." >&5 -$as_echo "$as_me: WARNING: Cannot find ocamlopt; bytecode compilation only." >&2;} - else - TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlopt discarded." >&5 -$as_echo "versions differs from ocamlc; ocamlopt discarded." >&6; } - OCAMLOPT=no - else - OCAMLBEST=opt - fi - fi - - - - # checking for ocamlc.opt - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlc.opt", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlc.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLCDOTOPT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLCDOTOPT"; then - ac_cv_prog_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLCDOTOPT="${ac_tool_prefix}ocamlc.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLCDOTOPT=$ac_cv_prog_OCAMLCDOTOPT -if test -n "$OCAMLCDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLCDOTOPT" >&5 -$as_echo "$OCAMLCDOTOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLCDOTOPT"; then - ac_ct_OCAMLCDOTOPT=$OCAMLCDOTOPT - # Extract the first word of "ocamlc.opt", so it can be a program name with args. -set dummy ocamlc.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLCDOTOPT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLCDOTOPT"; then - ac_cv_prog_ac_ct_OCAMLCDOTOPT="$ac_ct_OCAMLCDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLCDOTOPT="ocamlc.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLCDOTOPT=$ac_cv_prog_ac_ct_OCAMLCDOTOPT -if test -n "$ac_ct_OCAMLCDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLCDOTOPT" >&5 -$as_echo "$ac_ct_OCAMLCDOTOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLCDOTOPT" = x; then - OCAMLCDOTOPT="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLCDOTOPT=$ac_ct_OCAMLCDOTOPT - fi -else - OCAMLCDOTOPT="$ac_cv_prog_OCAMLCDOTOPT" -fi - - if test "$OCAMLCDOTOPT" != "no"; then - TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlc.opt discarded." >&5 -$as_echo "versions differs from ocamlc; ocamlc.opt discarded." >&6; } - else - OCAMLC=$OCAMLCDOTOPT - fi - fi - - # checking for ocamlopt.opt - if test "$OCAMLOPT" != "no" ; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlopt.opt", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlopt.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLOPTDOTOPT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLOPTDOTOPT"; then - ac_cv_prog_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLOPTDOTOPT="${ac_tool_prefix}ocamlopt.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLOPTDOTOPT=$ac_cv_prog_OCAMLOPTDOTOPT -if test -n "$OCAMLOPTDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPTDOTOPT" >&5 -$as_echo "$OCAMLOPTDOTOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLOPTDOTOPT"; then - ac_ct_OCAMLOPTDOTOPT=$OCAMLOPTDOTOPT - # Extract the first word of "ocamlopt.opt", so it can be a program name with args. -set dummy ocamlopt.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLOPTDOTOPT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLOPTDOTOPT"; then - ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="$ac_ct_OCAMLOPTDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="ocamlopt.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLOPTDOTOPT=$ac_cv_prog_ac_ct_OCAMLOPTDOTOPT -if test -n "$ac_ct_OCAMLOPTDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPTDOTOPT" >&5 -$as_echo "$ac_ct_OCAMLOPTDOTOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLOPTDOTOPT" = x; then - OCAMLOPTDOTOPT="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLOPTDOTOPT=$ac_ct_OCAMLOPTDOTOPT - fi -else - OCAMLOPTDOTOPT="$ac_cv_prog_OCAMLOPTDOTOPT" -fi - - if test "$OCAMLOPTDOTOPT" != "no"; then - TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamlopt.opt discarded." >&5 -$as_echo "version differs from ocamlc; ocamlopt.opt discarded." >&6; } - else - OCAMLOPT=$OCAMLOPTDOTOPT - fi - fi - fi - - - fi - - - - # checking for native dynlink - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dynlink.cmxa" >&5 -$as_echo_n "checking for dynlink.cmxa... " >&6; } - if test -f "$OCAMLLIB/dynlink.cmxa" ; then - OCAMLNATDYNLINK=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - OCAMLNATDYNLINK=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - - - - # checking for ocaml toplevel - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocaml", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocaml; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAML+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAML"; then - ac_cv_prog_OCAML="$OCAML" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAML="${ac_tool_prefix}ocaml" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAML=$ac_cv_prog_OCAML -if test -n "$OCAML"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAML" >&5 -$as_echo "$OCAML" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAML"; then - ac_ct_OCAML=$OCAML - # Extract the first word of "ocaml", so it can be a program name with args. -set dummy ocaml; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAML+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAML"; then - ac_cv_prog_ac_ct_OCAML="$ac_ct_OCAML" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAML="ocaml" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAML=$ac_cv_prog_ac_ct_OCAML -if test -n "$ac_ct_OCAML"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAML" >&5 -$as_echo "$ac_ct_OCAML" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAML" = x; then - OCAML="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAML=$ac_ct_OCAML - fi -else - OCAML="$ac_cv_prog_OCAML" -fi - - - # checking for ocamldep - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamldep", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamldep; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLDEP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLDEP"; then - ac_cv_prog_OCAMLDEP="$OCAMLDEP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLDEP="${ac_tool_prefix}ocamldep" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLDEP=$ac_cv_prog_OCAMLDEP -if test -n "$OCAMLDEP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDEP" >&5 -$as_echo "$OCAMLDEP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLDEP"; then - ac_ct_OCAMLDEP=$OCAMLDEP - # Extract the first word of "ocamldep", so it can be a program name with args. -set dummy ocamldep; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLDEP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLDEP"; then - ac_cv_prog_ac_ct_OCAMLDEP="$ac_ct_OCAMLDEP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLDEP="ocamldep" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLDEP=$ac_cv_prog_ac_ct_OCAMLDEP -if test -n "$ac_ct_OCAMLDEP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDEP" >&5 -$as_echo "$ac_ct_OCAMLDEP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLDEP" = x; then - OCAMLDEP="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLDEP=$ac_ct_OCAMLDEP - fi -else - OCAMLDEP="$ac_cv_prog_OCAMLDEP" -fi - - - # checking for ocamlmktop - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlmktop", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlmktop; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLMKTOP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLMKTOP"; then - ac_cv_prog_OCAMLMKTOP="$OCAMLMKTOP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLMKTOP="${ac_tool_prefix}ocamlmktop" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLMKTOP=$ac_cv_prog_OCAMLMKTOP -if test -n "$OCAMLMKTOP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKTOP" >&5 -$as_echo "$OCAMLMKTOP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLMKTOP"; then - ac_ct_OCAMLMKTOP=$OCAMLMKTOP - # Extract the first word of "ocamlmktop", so it can be a program name with args. -set dummy ocamlmktop; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLMKTOP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLMKTOP"; then - ac_cv_prog_ac_ct_OCAMLMKTOP="$ac_ct_OCAMLMKTOP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLMKTOP="ocamlmktop" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLMKTOP=$ac_cv_prog_ac_ct_OCAMLMKTOP -if test -n "$ac_ct_OCAMLMKTOP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKTOP" >&5 -$as_echo "$ac_ct_OCAMLMKTOP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLMKTOP" = x; then - OCAMLMKTOP="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLMKTOP=$ac_ct_OCAMLMKTOP - fi -else - OCAMLMKTOP="$ac_cv_prog_OCAMLMKTOP" -fi - - - # checking for ocamlmklib - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlmklib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlmklib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLMKLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLMKLIB"; then - ac_cv_prog_OCAMLMKLIB="$OCAMLMKLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLMKLIB="${ac_tool_prefix}ocamlmklib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLMKLIB=$ac_cv_prog_OCAMLMKLIB -if test -n "$OCAMLMKLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKLIB" >&5 -$as_echo "$OCAMLMKLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLMKLIB"; then - ac_ct_OCAMLMKLIB=$OCAMLMKLIB - # Extract the first word of "ocamlmklib", so it can be a program name with args. -set dummy ocamlmklib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLMKLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLMKLIB"; then - ac_cv_prog_ac_ct_OCAMLMKLIB="$ac_ct_OCAMLMKLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLMKLIB="ocamlmklib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLMKLIB=$ac_cv_prog_ac_ct_OCAMLMKLIB -if test -n "$ac_ct_OCAMLMKLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKLIB" >&5 -$as_echo "$ac_ct_OCAMLMKLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLMKLIB" = x; then - OCAMLMKLIB="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLMKLIB=$ac_ct_OCAMLMKLIB - fi -else - OCAMLMKLIB="$ac_cv_prog_OCAMLMKLIB" -fi - - - # checking for ocamldoc - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamldoc", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamldoc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLDOC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLDOC"; then - ac_cv_prog_OCAMLDOC="$OCAMLDOC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLDOC="${ac_tool_prefix}ocamldoc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLDOC=$ac_cv_prog_OCAMLDOC -if test -n "$OCAMLDOC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDOC" >&5 -$as_echo "$OCAMLDOC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLDOC"; then - ac_ct_OCAMLDOC=$OCAMLDOC - # Extract the first word of "ocamldoc", so it can be a program name with args. -set dummy ocamldoc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLDOC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLDOC"; then - ac_cv_prog_ac_ct_OCAMLDOC="$ac_ct_OCAMLDOC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLDOC="ocamldoc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLDOC=$ac_cv_prog_ac_ct_OCAMLDOC -if test -n "$ac_ct_OCAMLDOC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDOC" >&5 -$as_echo "$ac_ct_OCAMLDOC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLDOC" = x; then - OCAMLDOC="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLDOC=$ac_ct_OCAMLDOC - fi -else - OCAMLDOC="$ac_cv_prog_OCAMLDOC" -fi - - - # checking for ocamlbuild - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlbuild", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlbuild; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLBUILD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLBUILD"; then - ac_cv_prog_OCAMLBUILD="$OCAMLBUILD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLBUILD="${ac_tool_prefix}ocamlbuild" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLBUILD=$ac_cv_prog_OCAMLBUILD -if test -n "$OCAMLBUILD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLBUILD" >&5 -$as_echo "$OCAMLBUILD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLBUILD"; then - ac_ct_OCAMLBUILD=$OCAMLBUILD - # Extract the first word of "ocamlbuild", so it can be a program name with args. -set dummy ocamlbuild; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLBUILD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLBUILD"; then - ac_cv_prog_ac_ct_OCAMLBUILD="$ac_ct_OCAMLBUILD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLBUILD="ocamlbuild" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLBUILD=$ac_cv_prog_ac_ct_OCAMLBUILD -if test -n "$ac_ct_OCAMLBUILD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLBUILD" >&5 -$as_echo "$ac_ct_OCAMLBUILD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLBUILD" = x; then - OCAMLBUILD="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLBUILD=$ac_ct_OCAMLBUILD - fi -else - OCAMLBUILD="$ac_cv_prog_OCAMLBUILD" -fi - - -if test "$OCAMLC" = "no"; then - as_fn_error $? "You must install the OCaml compiler" "$LINENO" 5 -fi - - - # checking for ocamlfind - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlfind", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlfind; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OCAMLFIND+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAMLFIND"; then - ac_cv_prog_OCAMLFIND="$OCAMLFIND" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OCAMLFIND="${ac_tool_prefix}ocamlfind" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OCAMLFIND=$ac_cv_prog_OCAMLFIND -if test -n "$OCAMLFIND"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLFIND" >&5 -$as_echo "$OCAMLFIND" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OCAMLFIND"; then - ac_ct_OCAMLFIND=$OCAMLFIND - # Extract the first word of "ocamlfind", so it can be a program name with args. -set dummy ocamlfind; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OCAMLFIND+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLFIND"; then - ac_cv_prog_ac_ct_OCAMLFIND="$ac_ct_OCAMLFIND" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OCAMLFIND="ocamlfind" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAMLFIND=$ac_cv_prog_ac_ct_OCAMLFIND -if test -n "$ac_ct_OCAMLFIND"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLFIND" >&5 -$as_echo "$ac_ct_OCAMLFIND" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAMLFIND" = x; then - OCAMLFIND="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLFIND=$ac_ct_OCAMLFIND - fi -else - OCAMLFIND="$ac_cv_prog_OCAMLFIND" -fi - - - - -if test "$OCAMLFIND" = "no"; then - as_fn_error $? "You must install OCaml findlib (the ocamlfind command)" "$LINENO" 5 -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in sched.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default" -if test "x$ac_cv_header_sched_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SCHED_H 1 -_ACEOF - -fi - -done - -ac_fn_c_check_decl "$LINENO" "sched_setaffinity" "ac_cv_have_decl_sched_setaffinity" " -#define _GNU_SOURCE 1 -#include - -" -if test "x$ac_cv_have_decl_sched_setaffinity" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_SCHED_SETAFFINITY $ac_have_decl -_ACEOF - - -for ac_header in mach/thread_policy.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "mach/thread_policy.h" "ac_cv_header_mach_thread_policy_h" "$ac_includes_default" -if test "x$ac_cv_header_mach_thread_policy_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MACH_THREAD_POLICY_H 1 -_ACEOF - -fi - -done - -ac_fn_c_check_decl "$LINENO" "thread_policy_set" "ac_cv_have_decl_thread_policy_set" " -#include -#include - -" -if test "x$ac_cv_have_decl_thread_policy_set" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_THREAD_POLICY_SET $ac_have_decl -_ACEOF - - -ac_config_headers="$ac_config_headers config.h" - - - - - - - - -if test `printf "$OCAMLVERSION\n4.06.0" | sort | head -n1` = 4.06.0; then : - - - - - BEGIN_BEFORE_4_06_0='(*' - - END_BEFORE_4_06_0='*)' - - C_BEGIN_BEFORE_4_06_0='/*' - - C_END_BEFORE_4_06_0='*/' - -else - BEGIN_FROM_4_06_0='(*' - - END_FROM_4_06_0='*)' - - C_BEGIN_FROM_4_06_0='/*' - - C_END_FROM_4_06_0='*/' - - - - - -fi - -ac_config_files="$ac_config_files bytearray.ml" - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 -$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } - # Check whether --enable-maintainer-mode was given. -if test "${enable_maintainer_mode+set}" = set; then : - enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval -else - USE_MAINTAINER_MODE=no -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 -$as_echo "$USE_MAINTAINER_MODE" >&6; } - if test $USE_MAINTAINER_MODE = yes; then - MAINTAINER_MODE_TRUE= - MAINTAINER_MODE_FALSE='#' -else - MAINTAINER_MODE_TRUE='#' - MAINTAINER_MODE_FALSE= -fi - - MAINT=$MAINTAINER_MODE_TRUE - - - -if $OCAMLBUILD -use-ocamlfind >/dev/null 2>&1 ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ocaml version $OCAMLVERSION. Use standard Makefile" >&5 -$as_echo "ocaml version $OCAMLVERSION. Use standard Makefile" >&6; } - ac_config_files="$ac_config_files Makefile" - - cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then - as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by parmap $as_me 1.0-rc7, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -parmap config.status 1.0-rc7 -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "bytearray.ml") CONFIG_FILES="$CONFIG_FILES bytearray.ml" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; - - - esac - -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ocamlbuild does not exists or it does not support -use-ocamlfind" >&5 -$as_echo "ocamlbuild does not exists or it does not support -use-ocamlfind" >&6; } - ac_config_files="$ac_config_files Makefile_3.11" - - cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then - as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by parmap $as_me 1.0-rc7, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Report bugs to ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -parmap config.status 1.0-rc7 -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "bytearray.ml") CONFIG_FILES="$CONFIG_FILES bytearray.ml" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "Makefile_3.11") CONFIG_FILES="$CONFIG_FILES Makefile_3.11" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; - - - esac - -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - - mv Makefile_3.11 Makefile -fi - - diff --git a/bundles/parmap/parmap/configure.ac b/bundles/parmap/parmap/configure.ac index d8f27c209..d8ed4a924 100644 --- a/bundles/parmap/parmap/configure.ac +++ b/bundles/parmap/parmap/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(parmap, 1.0-rc7, roberto@dicosmo.org) +AC_INIT([parmap],[1.0-rc7],[roberto@dicosmo.org]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_OCAML if test "$OCAMLC" = "no"; then @@ -11,12 +11,11 @@ if test "$OCAMLFIND" = "no"; then AC_MSG_ERROR([You must install OCaml findlib (the ocamlfind command)]) fi -AC_HEADER_STDC -AC_CHECK_HEADERS([sched.h]) -AC_CHECK_DECLS([sched_setaffinity], [], [], [[ -#define _GNU_SOURCE 1 -#include -]]) +dnl AC_CHECK_HEADERS([sched.h]) +dnl AC_CHECK_DECLS([sched_setaffinity], [], [], [[ +dnl #define _GNU_SOURCE 1 +dnl #include +dnl ]]) AC_CHECK_HEADERS([mach/thread_policy.h]) AC_CHECK_DECLS([thread_policy_set], [], [], [[ @@ -45,6 +44,8 @@ AC_DEFUN([AC_WITH_OCAML_VERSION], [AC_DISABLE_BLOCK([FROM_$1]) AC_ENABLE_BLOCK([BEFORE_$1])])]) +AC_WITH_OCAML_VERSION([4_02_0], [4.02.0]) + AC_WITH_OCAML_VERSION([4_06_0], [4.06.0]) AC_CONFIG_FILES([bytearray.ml]) diff --git a/bundles/parmap/parmap/parmap.ml b/bundles/parmap/parmap/parmap.ml index d221f3ff7..2bcfe7342 100644 --- a/bundles/parmap/parmap/parmap.ml +++ b/bundles/parmap/parmap/parmap.ml @@ -11,6 +11,8 @@ (* library, see the LICENSE file for more information. *) (**************************************************************************) +open Stdcompat + module Utils = Parmap_utils (* OS related constants *) @@ -80,7 +82,7 @@ let can_redirect path = else true let log_debug fmt = - Printf.kprintf ( + Printf.ksprintf ( if !debug_enabled then begin (fun s -> Format.eprintf "[Parmap]: %s@." s) end else ignore @@ -102,7 +104,8 @@ let reopen_out outchan path fname = (* send stdout and stderr to a file to avoid mixing output from different cores, if enabled *) -let redirect ?(path = (Printf.sprintf "/tmp/.parmap.%d" (Unix.getpid ()))) ~id = +let redirect ~(path (* = (Printf.sprintf "/tmp/.parmap.%d" (Unix.getpid ())) *)) + ~id = reopen_out stdout path (Printf.sprintf "stdout.%d" id); reopen_out stderr path (Printf.sprintf "stderr.%d" id);; @@ -204,7 +207,7 @@ let simplemapper (init:int -> unit) (finalize: unit -> unit) ncores' compute opi (* run children *) run_many !ncores ~in_subprocess:(fun i -> init i; (* call initialization function *) - Pervasives.at_exit finalize; (* register finalization function *) + Stdlib.at_exit finalize; (* register finalization function *) let lo=i*chunksize in let hi=if i = !ncores - 1 then ln - 1 else (i + 1) * chunksize - 1 in let exc_handler e j = (* handle an exception at index j *) @@ -240,7 +243,7 @@ let simpleiter init finalize ncores' compute al = (* run children *) run_many !ncores ~in_subprocess:(fun i -> init i; (* call initialization function *) - Pervasives.at_exit finalize; (* register finalization function *) + Stdlib.at_exit finalize; (* register finalization function *) let lo=i*chunksize in let hi=if i= !ncores - 1 then ln-1 else (i+1)*chunksize-1 in let exc_handler e j = (* handle an exception at index j *) @@ -316,7 +319,7 @@ let mapper (init:int -> unit) (finalize:unit -> unit) ncores' ~chunksize compute let pids = spawn_many !ncores ~in_subprocess:(fun i -> init i; (* call initialization function *) - Pervasives.at_exit finalize; (* register finalization function *) + Stdlib.at_exit finalize; (* register finalization function *) let d=Unix.gettimeofday() in (* primitives for communication *) Unix.close pipeup_rd; @@ -417,7 +420,7 @@ let geniter init finalize ncores' ~chunksize compute al = let pids = spawn_many !ncores ~in_subprocess:(fun i -> init i; (* call initialization function *) - Pervasives.at_exit finalize; (* register finalization function *) + Stdlib.at_exit finalize; (* register finalization function *) let d=Unix.gettimeofday() in (* primitives for communication *) Unix.close pipeup_rd; @@ -568,7 +571,7 @@ let parfold let mapi_range lo hi (f:int -> 'a -> 'b) a = let l = hi-lo in if l < 0 then [||] else begin - let r = Array.create (l+1) (f lo (Array.unsafe_get a lo)) in + let r = Array.make (l+1) (f lo (Array.unsafe_get a lo)) in for i = 1 to l do let idx = lo+i in Array.unsafe_set r i (f idx (Array.unsafe_get a idx)) diff --git a/bundles/parmap/parmap/parmap.mli b/bundles/parmap/parmap/parmap.mli index 64d8bcae5..f729e4742 100644 --- a/bundles/parmap/parmap/parmap.mli +++ b/bundles/parmap/parmap/parmap.mli @@ -213,7 +213,7 @@ val debugging : bool -> unit (** {6 Helper function for redirection of stdout and stderr} *) -val redirect : ?path:string -> id:int -> unit +val redirect : path:string -> id:int -> unit (** Helper function that redirects stdout and stderr to files located in the directory [path], carrying names of the shape diff --git a/bundles/parmap/parmap/parmap_utils.ml b/bundles/parmap/parmap/parmap_utils.ml index e9fe74d09..d19f745c4 100644 --- a/bundles/parmap/parmap/parmap_utils.ml +++ b/bundles/parmap/parmap/parmap_utils.ml @@ -1,6 +1,6 @@ let log_error fmt = - Printf.kprintf (fun s -> Format.eprintf "[Parmap]: %s@.%!" s) fmt + Printf.ksprintf (fun s -> Format.eprintf "[Parmap]: %s@.%!" s) fmt (* tail recursive version of List.append *) let append_tr l1 l2 = diff --git a/bundles/parmap/parmap/setcore_stubs.c b/bundles/parmap/parmap/setcore_stubs.c index d9f977f30..7acad108f 100644 --- a/bundles/parmap/parmap/setcore_stubs.c +++ b/bundles/parmap/parmap/setcore_stubs.c @@ -6,10 +6,10 @@ #include // #include #endif -#if HAVE_DECL_SCHED_SETAFFINITY +//#if HAVE_DECL_SCHED_SETAFFINITY //#define _GNU_SOURCE /* See feature_test_macros(7) */ #include -#endif +//#endif #include #include @@ -21,9 +21,9 @@ CAMLprim value numcores(value unit) { CAMLprim value setcore(value which) { int numcores = sysconf( _SC_NPROCESSORS_ONLN ); int w = Int_val(which) % numcores; // stay in the space of existing cores -#if HAVE_DECL_SCHED_SETAFFINITY +//#if HAVE_DECL_SCHED_SETAFFINITY cpu_set_t cpus; -#endif +//#endif #if HAVE_MACH_THREAD_POLICY_H thread_affinity_policy_data_t affinityData; #endif @@ -31,7 +31,7 @@ CAMLprim value setcore(value which) { int finished=0; while (finished==0) { -#if HAVE_DECL_SCHED_SETAFFINITY +//#if HAVE_DECL_SCHED_SETAFFINITY CPU_ZERO(&cpus); CPU_SET (w,&cpus); //fprintf(stderr,"Trying to pin to cpu %d out of %d reported by the system\n",w,numcores); @@ -41,7 +41,7 @@ CAMLprim value setcore(value which) { w=w/2; } else -#endif +//#endif #if HAVE_MACH_THREAD_POLICY_H affinityData.affinity_tag = w; retcode = thread_policy_set(mach_thread_self(), diff --git a/bundles/pcre/pcre-ocaml/src/pcre.ml b/bundles/pcre/pcre-ocaml/src/pcre.ml new file mode 100644 index 000000000..b5546400e --- /dev/null +++ b/bundles/pcre/pcre-ocaml/src/pcre.ml @@ -0,0 +1,1055 @@ +(* + PCRE-OCAML - Perl Compatibility Regular Expressions for OCaml + + Copyright (C) 1999- Markus Mottl + email: markus.mottl@gmail.com + WWW: http://www.ocaml.info + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*) + +open Stdcompat + +(* Public exceptions and their registration with the C runtime *) + +type error = + | Partial + | BadPartial + | BadPattern of string * int + | BadUTF8 + | BadUTF8Offset + | MatchLimit + | RecursionLimit + | InternalError of string + +exception Error of error +exception Backtrack +exception Regexp_or of string * error + +(* Puts exceptions into global C-variables for fast retrieval *) +external pcre_ocaml_init : unit -> unit = "pcre_ocaml_init" + +(* Registers exceptions with the C runtime and caches polymorphic variants *) +let () = + Callback.register_exception "Pcre.Error" (Error (InternalError "")); + Callback.register_exception "Pcre.Backtrack" Backtrack; + pcre_ocaml_init () + + +(* Compilation and runtime flags and their conversion functions *) + +type icflag = int +type irflag = int + +(* Compilation flags *) + +type cflag = + [ + | `CASELESS + | `MULTILINE + | `DOTALL + | `EXTENDED + | `ANCHORED + | `DOLLAR_ENDONLY + | `EXTRA + | `UNGREEDY + | `UTF8 + | `NO_UTF8_CHECK + | `NO_AUTO_CAPTURE + | `AUTO_CALLOUT + | `FIRSTLINE + ] + +let int_of_cflag = function + | `CASELESS -> 0x0001 + | `MULTILINE -> 0x0002 + | `DOTALL -> 0x0004 + | `EXTENDED -> 0x0008 + | `ANCHORED -> 0x0010 + | `DOLLAR_ENDONLY -> 0x0020 + | `EXTRA -> 0x0040 + | `UNGREEDY -> 0x0200 + | `UTF8 -> 0x0800 + | `NO_AUTO_CAPTURE -> 0x1000 + | `NO_UTF8_CHECK -> 0x2000 + | `AUTO_CALLOUT -> 0x4000 + | `FIRSTLINE -> 0x40000 + +let coll_icflag icflag flag = int_of_cflag flag lor icflag +let cflags flags = List.fold_left coll_icflag 0 flags + +let cflag_of_int = function + | 0x0001 -> `CASELESS + | 0x0002 -> `MULTILINE + | 0x0004 -> `DOTALL + | 0x0008 -> `EXTENDED + | 0x0010 -> `ANCHORED + | 0x0020 -> `DOLLAR_ENDONLY + | 0x0040 -> `EXTRA + | 0x0200 -> `UNGREEDY + | 0x0800 -> `UTF8 + | 0x1000 -> `NO_AUTO_CAPTURE + | 0x2000 -> `NO_UTF8_CHECK + | 0x4000 -> `AUTO_CALLOUT + | 0x40000 -> `FIRSTLINE + | _ -> failwith "Pcre.cflag_list: unknown compilation flag" + +let all_cflags = + [ + 0x0001; 0x0002; 0x0004; 0x0008; 0x0010; 0x0020; + 0x0040; 0x0200; 0x0800; 0x1000; 0x2000; 0x4000; 0x40000; + ] + +let cflag_list icflags = + let coll flag_list flag = + if icflags land flag <> 0 then cflag_of_int flag :: flag_list + else flag_list in + List.fold_left coll [] all_cflags + + +(* Runtime flags *) + +type rflag = + [ + | `ANCHORED + | `NOTBOL + | `NOTEOL + | `NOTEMPTY + | `PARTIAL + ] + +let int_of_rflag = function + | `ANCHORED -> 0x0010 + | `NOTBOL -> 0x0080 + | `NOTEOL -> 0x0100 + | `NOTEMPTY -> 0x0400 + | `PARTIAL -> 0x8000 + +let coll_irflag irflag flag = int_of_rflag flag lor irflag +let rflags flags = List.fold_left coll_irflag 0 flags + +let rflag_of_int = function + | 0x0010 -> `ANCHORED + | 0x0080 -> `NOTBOL + | 0x0100 -> `NOTEOL + | 0x0400 -> `NOTEMPTY + | 0x8000 -> `PARTIAL + | _ -> failwith "Pcre.rflag_list: unknown runtime flag" + +let all_rflags = [0x0010; 0x0080; 0x0100; 0x0400; 0x8000] + +let rflag_list irflags = + let coll flag_list flag = + if irflags land flag <> 0 then rflag_of_int flag :: flag_list + else flag_list in + List.fold_left coll [] all_rflags + + +(* Information on the PCRE-configuration (build-time options) *) + +external pcre_version : unit -> string = "pcre_version_stub" + +external pcre_config_utf8 : unit -> bool = "pcre_config_utf8_stub" [@@noalloc] + +external pcre_config_newline : + unit -> char = "pcre_config_newline_stub" [@@noalloc] + +external pcre_config_link_size : unit -> (int [@untagged]) + = "pcre_config_link_size_stub_bc" "pcre_config_link_size_stub" [@@noalloc] + +external pcre_config_match_limit : + unit -> (int [@untagged]) + = "pcre_config_match_limit_stub_bc" "pcre_config_match_limit_stub" [@@noalloc] + +external pcre_config_match_limit_recursion : unit -> (int [@untagged]) + = + "pcre_config_match_limit_recursion_stub_bc" + "pcre_config_match_limit_recursion_stub" + [@@noalloc] + +external pcre_config_stackrecurse : + unit -> bool = "pcre_config_stackrecurse_stub" [@@noalloc] + +let version = pcre_version () +let config_utf8 = pcre_config_utf8 () +let config_newline = pcre_config_newline () +let config_link_size = pcre_config_link_size () +let config_match_limit = pcre_config_match_limit () +let config_match_limit_recursion = pcre_config_match_limit_recursion () +let config_stackrecurse = pcre_config_stackrecurse () + + +(* Information on patterns *) + +type firstbyte_info = + [ `Char of char + | `Start_only + | `ANCHORED ] + +type study_stat = + [ `Not_studied + | `Studied + | `Optimal ] + +type regexp + +external options : regexp -> (icflag [@untagged]) + = "pcre_options_stub_bc" "pcre_options_stub" + +external size : regexp -> (int [@untagged]) + = "pcre_size_stub_bc" "pcre_size_stub" + +external studysize : regexp -> (int [@untagged]) + = "pcre_studysize_stub_bc" "pcre_studysize_stub" + +external capturecount : regexp -> (int [@untagged]) + = "pcre_capturecount_stub_bc" "pcre_capturecount_stub" + +external backrefmax : regexp -> (int [@untagged]) + = "pcre_backrefmax_stub_bc" "pcre_backrefmax_stub" + +external namecount : regexp -> (int [@untagged]) + = "pcre_namecount_stub_bc" "pcre_namecount_stub" + +external nameentrysize : regexp -> (int [@untagged]) + = "pcre_nameentrysize_stub_bc" "pcre_nameentrysize_stub" + +external names : regexp -> string array = "pcre_names_stub" +external firstbyte : regexp -> firstbyte_info = "pcre_firstbyte_stub" +external firsttable : regexp -> string option = "pcre_firsttable_stub" +external lastliteral : regexp -> char option = "pcre_lastliteral_stub" +external study_stat : regexp -> study_stat = "pcre_study_stat_stub" [@@noalloc] + + +(* Compilation of patterns *) + +type chtables + +external maketables : unit -> chtables = "pcre_maketables_stub" + +(* Internal use only! *) +external pcre_study : regexp -> unit = "pcre_study_stub" + +external compile : (icflag [@untagged]) -> chtables option -> string -> regexp + = "pcre_compile_stub_bc" "pcre_compile_stub" + +external get_match_limit : regexp -> int option = "pcre_get_match_limit_stub" + +external get_match_limit_recursion : regexp -> int option + = "pcre_get_match_limit_recursion_stub" + +(* Internal use only! *) +external set_imp_match_limit : regexp -> (int [@untagged]) -> regexp + = "pcre_set_imp_match_limit_stub_bc" "pcre_set_imp_match_limit_stub" + [@@noalloc] + +(* Internal use only! *) +external set_imp_match_limit_recursion : regexp -> (int [@untagged]) -> regexp + = + "pcre_set_imp_match_limit_recursion_stub_bc" + "pcre_set_imp_match_limit_recursion_stub" + [@@noalloc] + +let regexp + ?(study = true) ?limit ?limit_recursion + ?(iflags = 0) ?flags ?chtables pat = + let rex = + match flags with + | Some flag_list -> compile (cflags flag_list) chtables pat + | _ -> compile iflags chtables pat + in + if study then pcre_study rex; + let rex = + match limit with + | None -> rex + | Some lim -> set_imp_match_limit rex lim + in + match limit_recursion with + | None -> rex + | Some lim -> set_imp_match_limit_recursion rex lim + +let regexp_or + ?study ?limit ?limit_recursion ?(iflags = 0) ?flags ?chtables pats = + let check pat = + try ignore (regexp ~study:false ~iflags ?flags ?chtables pat) + with Error error -> raise (Regexp_or (pat, error)) + in + List.iter check pats; + let big_pat = + let cnv pat = "(?:" ^ pat ^ ")" in + String.concat "|" (List.rev (List.rev_map cnv pats)) + in + regexp ?study ?limit ?limit_recursion ~iflags ?flags ?chtables big_pat + +let bytes_unsafe_blit_string str str_ofs bts bts_ofs len = + let str_bts = Bytes.unsafe_of_string str in + Bytes.unsafe_blit str_bts str_ofs bts bts_ofs len + +let string_unsafe_sub str ofs len = + let res = Bytes.create len in + bytes_unsafe_blit_string str ofs res 0 len; + Bytes.unsafe_to_string res + +let quote s = + let len = String.length s in + let buf = Bytes.create (len lsl 1) in + let pos = ref 0 in + for i = 0 to len - 1 do + match String.unsafe_get s i with + | '\\' | '^' | '$' | '.' | '[' | '|' + | '(' | ')' | '?' | '*' | '+' | '{' as c -> + Bytes.unsafe_set buf !pos '\\'; + incr pos; + Bytes.unsafe_set buf !pos c; + incr pos + | c -> Bytes.unsafe_set buf !pos c; incr pos + done; + string_unsafe_sub (Bytes.unsafe_to_string buf) 0 !pos + + +(* Matching of patterns and subpattern extraction *) + +(* Default regular expression when none is provided by the user *) +let def_rex = regexp "\\s+" + +type substrings = string * int array + +type callout_data = + { + callout_number : int; + substrings : substrings; + start_match : int; + current_position : int; + capture_top : int; + capture_last : int; + pattern_position : int; + next_item_length : int; + } + +type callout = callout_data -> unit + +let get_subject (subj, _) = subj + +let num_of_subs (_, ovector) = Array.length ovector / 3 + +let get_offset_start ovector str_num = + if str_num < 0 || str_num >= Array.length ovector / 3 then + invalid_arg "Pcre.get_offset_start: illegal offset"; + let offset = str_num lsl 1 in + offset, Array.unsafe_get ovector offset + +let get_substring_aux (subj, ovector) offset start = + if start < 0 then raise Not_found + else + string_unsafe_sub subj start (Array.unsafe_get ovector (offset + 1) - start) + +let get_substring (_, ovector as substrings) str_num = + let offset, start = get_offset_start ovector str_num in + get_substring_aux substrings offset start + +let get_substring_ofs (_subj, ovector) str_num = + let offset, start = get_offset_start ovector str_num in + if start < 0 then raise Not_found + else start, Array.unsafe_get ovector (offset + 1) + +let unsafe_get_substring (_, ovector as substrings) str_num = + let offset = str_num lsl 1 in + try get_substring_aux substrings offset (Array.unsafe_get ovector offset) + with Not_found -> "" + +let get_substrings ?(full_match = true) (_, ovector as substrings) = + if full_match then + Array.init (Array.length ovector / 3) (unsafe_get_substring substrings) + else + let len = (Array.length ovector / 3) - 1 in + Array.init len (fun n -> unsafe_get_substring substrings (n + 1)) + +let unsafe_get_opt_substring (_, ovector as substrings) str_num = + let offset = str_num lsl 1 in + try + let start = Array.unsafe_get ovector offset in + let str = get_substring_aux substrings offset start in + Some str + with Not_found -> None + +let get_opt_substrings ?(full_match = true) (_, ovector as substrings) = + if full_match then + Array.init (Array.length ovector / 3) (unsafe_get_opt_substring substrings) + else + let len = (Array.length ovector / 3) - 1 in + Array.init len (fun n -> unsafe_get_opt_substring substrings (n + 1)) + +external get_stringnumber : regexp -> string -> (int [@untagged]) + = "pcre_get_stringnumber_stub_bc" "pcre_get_stringnumber_stub" + +let get_named_substring rex name substrings = + get_substring substrings (get_stringnumber rex name) + +let get_named_substring_ofs rex name substrings = + get_substring_ofs substrings (get_stringnumber rex name) + +external unsafe_pcre_exec : + (irflag [@untagged]) -> + regexp -> + pos : (int [@untagged]) -> + subj_start : (int [@untagged]) -> + subj : string -> + int array -> + callout option -> + unit = "pcre_exec_stub_bc" "pcre_exec_stub" + +let make_ovector rex = + let subgroups1 = capturecount rex + 1 in + let subgroups2 = subgroups1 lsl 1 in + subgroups2, Array.make (subgroups1 + subgroups2) 0 + +let pcre_exec ?(iflags = 0) ?flags ?(rex = def_rex) ?pat ?(pos = 0) + ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let _, ovector = make_ovector rex in + unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout; + ovector + +let exec ?iflags ?flags ?rex ?pat ?pos ?callout subj = + subj, pcre_exec ?iflags ?flags ?rex ?pat ?pos ?callout subj + +let next_match ?iflags ?flags ?rex ?pat ?(pos = 0) ?callout (subj, ovector) = + let pos = Array.unsafe_get ovector 1 + pos in + let subj_len = String.length subj in + if pos < 0 || pos > subj_len then + invalid_arg "Pcre.next_match: illegal offset"; + subj, pcre_exec ?iflags ?flags ?rex ?pat ~pos ?callout subj + +let rec copy_lst ar n = function + | [] -> ar + | h :: t -> Array.unsafe_set ar n h; copy_lst ar (n - 1) t + +let exec_all ?(iflags = 0) ?flags ?(rex = def_rex) ?pat ?pos ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let (_, ovector as sstrs) = exec ~iflags ~rex ?pos ?callout subj in + let null_flags = iflags lor 0x0400 in + let subj_len = String.length subj in + let rec loop pos (subj, ovector as sstrs) n lst = + let maybe_ovector = + try + let first = Array.unsafe_get ovector 0 in + if first = pos && Array.unsafe_get ovector 1 = pos then + if pos = subj_len then None + else Some (pcre_exec ~iflags:null_flags ~rex ~pos ?callout subj) + else Some (pcre_exec ~iflags ~rex ~pos ?callout subj) + with Not_found -> None in + match maybe_ovector with + | Some ovector -> + let new_pos = Array.unsafe_get ovector 1 in + loop new_pos (subj, ovector) (n + 1) (sstrs :: lst) + | None -> copy_lst (Array.make (n + 1) sstrs) (n - 1) lst in + loop (Array.unsafe_get ovector 1) sstrs 0 [] + +let extract ?iflags ?flags ?rex ?pat ?pos ?full_match ?callout subj = + get_substrings ?full_match (exec ?iflags ?flags ?rex ?pat ?pos ?callout subj) + +let extract_opt ?iflags ?flags ?rex ?pat ?pos ?full_match ?callout subj = + get_opt_substrings + ?full_match (exec ?iflags ?flags ?rex ?pat ?pos ?callout subj) + +let extract_all ?iflags ?flags ?rex ?pat ?pos ?full_match ?callout subj = + let many_sstrs = exec_all ?iflags ?flags ?rex ?pat ?pos ?callout subj in + Array.map (get_substrings ?full_match) many_sstrs + +let extract_all_opt ?iflags ?flags ?rex ?pat ?pos ?full_match ?callout subj = + let many_sstrs = exec_all ?iflags ?flags ?rex ?pat ?pos ?callout subj in + Array.map (get_opt_substrings ?full_match) many_sstrs + +let pmatch ?iflags ?flags ?rex ?pat ?pos ?callout subj = + try ignore (pcre_exec ?iflags ?flags ?rex ?pat ?pos ?callout subj); true + with Not_found -> false + + +(* String substitution *) + +(* Elements of a substitution pattern *) +type subst = + | SubstString of int * int (* Denotes a substring in the substitution *) + | Backref of int (* nth backreference ($0 is program name!) *) + | Match (* The whole matched string *) + | PreMatch (* The string before the match *) + | PostMatch (* The string after the match *) + | LastParenMatch (* The last matched group *) + +(* Information on substitution patterns *) +type substitution = string (* The substitution string *) + * int (* Highest group number of backreferences *) + * bool (* Makes use of "LastParenMatch" *) + * subst list (* The list of substitution elements *) + +(* Only used internally in "subst" *) +exception FoundAt of int + +let zero = Char.code '0' + +let subst str = + let max_br = ref 0 in + let with_lp = ref false in + let lix = String.length str - 1 in + let rec loop acc n = + if lix < n then acc + else + try + for i = n to lix do + if String.unsafe_get str i = '$' then raise (FoundAt i) + done; + SubstString (n, lix - n + 1) :: acc + with FoundAt i -> + if i = lix then SubstString (n, lix - n + 1) :: acc + else + let i1 = i + 1 in + let acc = if n = i then acc else SubstString (n, i - n) :: acc in + match String.unsafe_get str i1 with + | '0'..'9' as c -> + let subpat_nr = ref (Char.code c - zero) in + (try + for j = i1 + 1 to lix do + let c = String.unsafe_get str j in + if c >= '0' && c <= '9' then + subpat_nr := 10 * !subpat_nr + Char.code c - zero + else raise (FoundAt j) + done; + max_br := max !subpat_nr !max_br; + Backref !subpat_nr :: acc + with FoundAt j -> + max_br := max !subpat_nr !max_br; + loop (Backref !subpat_nr :: acc) j) + | '!' -> loop acc (i1 + 1) + | '$' -> loop (SubstString (i1, 1) :: acc) (i1 + 1) + | '&' -> loop (Match :: acc) (i1 + 1) + | '`' -> loop (PreMatch :: acc) (i1 + 1) + | '\'' -> loop (PostMatch :: acc) (i1 + 1) + | '+' -> + with_lp := true; + loop (LastParenMatch :: acc) (i1 + 1) + | _ -> loop acc i1 in + let subst_lst = loop [] 0 in + str, !max_br, !with_lp, subst_lst + +let def_subst = subst "" + +(* Calculates a list of tuples (str, offset, len) which contain + substrings to be copied on substitutions. Internal use only! *) +let calc_trans_lst subgroups2 ovector subj templ subst_lst = + let prefix_len = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + let coll (res_len, trans_lst as accu) = + let return_lst (_str, _ix, len as el) = + if len = 0 then accu else res_len + len, el :: trans_lst in + function + | SubstString (ix, len) -> return_lst (templ, ix, len) + | Backref 0 -> + let prog_name = Sys.argv.(0) in + return_lst (prog_name, 0, String.length prog_name) + | Backref n -> + let offset = n lsl 1 in + let start = Array.unsafe_get ovector offset in + let len = Array.unsafe_get ovector (offset + 1) - start in + return_lst (subj, start, len) + | Match -> return_lst (subj, prefix_len, last - prefix_len) + | PreMatch -> return_lst (subj, 0, prefix_len) + | PostMatch -> return_lst (subj, last, String.length subj - last) + | LastParenMatch -> + let subgroups2_2 = subgroups2 - 2 in + let pos = ref subgroups2_2 in + let ix = ref (Array.unsafe_get ovector subgroups2_2) in + while !ix < 0 do + let pos_2 = !pos - 2 in + pos := pos_2; + ix := Array.unsafe_get ovector pos_2 + done; + return_lst (subj, !ix, Array.unsafe_get ovector (!pos + 1) - !ix) in + List.fold_left coll (0, []) subst_lst + +let replace ?(iflags = 0) ?flags ?(rex = def_rex) ?pat + ?(pos = 0) ?(itempl = def_subst) ?templ ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let templ, max_br, with_lp, subst_lst = + match templ with + | Some str -> subst str + | _ -> itempl in + let subj_len = String.length subj in + if pos < 0 || pos > subj_len then invalid_arg "Pcre.replace: illegal offset"; + let subgroups2, ovector = make_ovector rex in + let nsubs = (subgroups2 lsr 1) - 1 in + if max_br > nsubs then + failwith "Pcre.replace: backreference denotes nonexistent subpattern"; + if with_lp && nsubs = 0 then failwith "Pcre.replace: no backreferences"; + let rec loop full_len trans_lsts cur_pos = + if + cur_pos > subj_len || + try + unsafe_pcre_exec + iflags rex ~pos:cur_pos ~subj_start:0 ~subj + ovector callout; + false + with Not_found -> true + then + let postfix_len = max (subj_len - cur_pos) 0 in + let left = pos + full_len in + let res = Bytes.create (left + postfix_len) in + bytes_unsafe_blit_string subj 0 res 0 pos; + bytes_unsafe_blit_string subj cur_pos res left postfix_len; + let inner_coll ofs (templ, ix, len) = + bytes_unsafe_blit_string templ ix res ofs len; ofs + len in + let coll ofs (res_len, trans_lst) = + let new_ofs = ofs - res_len in + let _ = List.fold_left inner_coll new_ofs trans_lst in + new_ofs in + let _ = List.fold_left coll left trans_lsts in + Bytes.unsafe_to_string res + else + let first = Array.unsafe_get ovector 0 in + let len = first - cur_pos in + let res_len, _ as trans_lst_el = + calc_trans_lst subgroups2 ovector subj templ subst_lst in + let trans_lsts = + if len > 0 then + trans_lst_el :: (len, [(subj, cur_pos, len)]) :: trans_lsts + else trans_lst_el :: trans_lsts in + let full_len = full_len + len + res_len in + let next = first + 1 in + let last = Array.unsafe_get ovector 1 in + if last < next then + if first < subj_len then + let new_trans_lsts = (1, [(subj, cur_pos + len, 1)]) :: trans_lsts in + loop (full_len + 1) new_trans_lsts next + else loop full_len trans_lsts next + else loop full_len trans_lsts last in + loop 0 [] pos + +let qreplace ?(iflags = 0) ?flags ?(rex = def_rex) ?pat + ?(pos = 0) ?(templ = "") ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let subj_len = String.length subj in + if pos < 0 || pos > subj_len then invalid_arg "Pcre.qreplace: illegal offset"; + let templ_len = String.length templ in + let _, ovector = make_ovector rex in + let rec loop full_len subst_lst cur_pos = + if + cur_pos > subj_len || + try + unsafe_pcre_exec + iflags rex ~pos:cur_pos ~subj_start:0 ~subj ovector callout; + false + with Not_found -> true + then + let postfix_len = max (subj_len - cur_pos) 0 in + let left = pos + full_len in + let res = Bytes.create (left + postfix_len) in + bytes_unsafe_blit_string subj 0 res 0 pos; + bytes_unsafe_blit_string subj cur_pos res left postfix_len; + let coll ofs = function + | Some (substr, ix, len) -> + let new_ofs = ofs - len in + bytes_unsafe_blit_string substr ix res new_ofs len; + new_ofs + | None -> + let new_ofs = ofs - templ_len in + bytes_unsafe_blit_string templ 0 res new_ofs templ_len; + new_ofs in + let _ = List.fold_left coll left subst_lst in + Bytes.unsafe_to_string res + else + let first = Array.unsafe_get ovector 0 in + let len = first - cur_pos in + let subst_lst = + if len > 0 then None :: Some (subj, cur_pos, len) :: subst_lst + else None :: subst_lst in + let last = Array.unsafe_get ovector 1 in + let full_len = full_len + len + templ_len in + let next = first + 1 in + if last < next then + if first < subj_len then + loop (full_len + 1) (Some (subj, cur_pos + len, 1) :: subst_lst) next + else loop full_len subst_lst next + else loop full_len subst_lst last in + loop 0 [] pos + +let substitute_substrings ?(iflags = 0) ?flags ?(rex = def_rex) ?pat + ?(pos = 0) ?callout ~subst subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let subj_len = String.length subj in + if pos < 0 || pos > subj_len then invalid_arg "Pcre.substitute: illegal offset"; + let _, ovector = make_ovector rex in + let rec loop full_len subst_lst cur_pos = + if + cur_pos > subj_len || + try + unsafe_pcre_exec + iflags rex ~pos:cur_pos ~subj_start:0 ~subj ovector callout; + false + with Not_found -> true + then + let postfix_len = max (subj_len - cur_pos) 0 in + let left = pos + full_len in + let res = Bytes.create (left + postfix_len) in + bytes_unsafe_blit_string subj 0 res 0 pos; + bytes_unsafe_blit_string subj cur_pos res left postfix_len; + let coll ofs (templ, ix, len) = + let new_ofs = ofs - len in + bytes_unsafe_blit_string templ ix res new_ofs len; + new_ofs in + let _ = List.fold_left coll left subst_lst in + Bytes.unsafe_to_string res + else + let first = Array.unsafe_get ovector 0 in + let len = first - cur_pos in + let templ = subst (subj, ovector) in + let templ_len = String.length templ in + let subst_lst = + if len > 0 then + (templ, 0, templ_len) :: (subj, cur_pos, len) :: subst_lst + else (templ, 0, templ_len) :: subst_lst in + let last = Array.unsafe_get ovector 1 in + let full_len = full_len + len + templ_len in + let next = first + 1 in + if last < next then + if first < subj_len then + loop (full_len + 1) ((subj, cur_pos + len, 1) :: subst_lst) next + else loop full_len subst_lst next + else loop full_len subst_lst last in + loop 0 [] pos + +let substitute ?iflags ?flags ?rex ?pat ?pos ?callout ~subst:str_subst subj = + let subst (subj, ovector) = + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + str_subst (string_unsafe_sub subj first (last - first)) in + substitute_substrings ?iflags ?flags ?rex ?pat ?pos ?callout ~subst subj + +let replace_first ?(iflags = 0) ?flags ?(rex = def_rex) ?pat ?(pos = 0) + ?(itempl = def_subst) ?templ ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let templ, max_br, with_lp, subst_lst = + match templ with + | Some str -> subst str + | _ -> itempl in + let subgroups2, ovector = make_ovector rex in + let nsubs = (subgroups2 lsr 1) - 1 in + if max_br > nsubs then + failwith "Pcre.replace_first: backreference denotes nonexistent subpattern"; + if with_lp && nsubs = 0 then failwith "Pcre.replace_first: no backreferences"; + try + unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout; + let res_len, trans_lst = + calc_trans_lst subgroups2 ovector subj templ subst_lst in + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + let rest = String.length subj - last in + let res = Bytes.create (first + res_len + rest) in + bytes_unsafe_blit_string subj 0 res 0 first; + let coll ofs (templ, ix, len) = + bytes_unsafe_blit_string templ ix res ofs len; ofs + len in + let ofs = List.fold_left coll first trans_lst in + bytes_unsafe_blit_string subj last res ofs rest; + Bytes.unsafe_to_string res + with Not_found -> subj + +let qreplace_first ?(iflags = 0) ?flags ?(rex = def_rex) ?pat + ?(pos = 0) ?(templ = "") ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let _, ovector = make_ovector rex in + try + unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout; + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + let len = String.length templ in + let rest = String.length subj - last in + let postfix_start = first + len in + let res = Bytes.create (postfix_start + rest) in + bytes_unsafe_blit_string subj 0 res 0 first; + bytes_unsafe_blit_string templ 0 res first len; + bytes_unsafe_blit_string subj last res postfix_start rest; + Bytes.unsafe_to_string res + with Not_found -> subj + +let substitute_substrings_first ?(iflags = 0) ?flags ?(rex = def_rex) ?pat + ?(pos = 0) ?callout ~subst subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let _, ovector = make_ovector rex in + try + unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout; + let subj_len = String.length subj in + let prefix_len = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + let templ = subst (subj, ovector) in + let postfix_len = subj_len - last in + let templ_len = String.length templ in + let postfix_start = prefix_len + templ_len in + let res = Bytes.create (postfix_start + postfix_len) in + bytes_unsafe_blit_string subj 0 res 0 prefix_len; + bytes_unsafe_blit_string templ 0 res prefix_len templ_len; + bytes_unsafe_blit_string subj last res postfix_start postfix_len; + Bytes.unsafe_to_string res + with Not_found -> subj + +let substitute_first ?iflags ?flags ?rex ?pat ?pos + ?callout ~subst:str_subst subj = + let subst (subj, ovector) = + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + str_subst (string_unsafe_sub subj first (last - first)) in + substitute_substrings_first + ?iflags ?flags ?rex ?pat ?pos ?callout ~subst subj + + +(* Splitting *) + +let internal_psplit flags rex max pos callout subj = + let subj_len = String.length subj in + if subj_len = 0 then [] + else if max = 1 then [subj] + else + let subgroups2, ovector = make_ovector rex in + + (* Adds contents of subgroups to the string accumulator *) + let handle_subgroups strs = + let strs = ref strs in + let i = ref 2 in + while !i < subgroups2 do + let first = Array.unsafe_get ovector !i in + incr i; + let last = Array.unsafe_get ovector !i in + let str = + if first < 0 then "" + else string_unsafe_sub subj first (last - first) in + strs := str :: !strs; incr i + done; + !strs in + + (* Performs the recursive split *) + let rec loop strs cnt pos prematch = + let len = subj_len - pos in + if len < 0 then strs + else + (* Checks termination due to max restriction *) + if cnt = 0 then + if prematch && + try + unsafe_pcre_exec + flags rex ~pos ~subj_start:pos ~subj ovector callout; + true + with Not_found -> false + then + let last = Array.unsafe_get ovector 1 in + let strs = handle_subgroups strs in + string_unsafe_sub subj last (subj_len - last) :: strs + else string_unsafe_sub subj pos len :: strs + + (* Calculates next accumulator state for splitting *) + else + if + try + unsafe_pcre_exec + flags rex ~pos ~subj_start:pos ~subj ovector callout; + false + with Not_found -> true + then string_unsafe_sub subj pos len :: strs + else + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + if first = pos then + if last = pos then + let strs = if prematch then handle_subgroups strs else strs in + if len = 0 then "" :: strs + else if + try + unsafe_pcre_exec + (flags lor 0x0410) rex ~pos ~subj_start:pos ~subj + ovector callout; + true + with Not_found -> false + then + let new_strs = handle_subgroups ("" :: strs) in + loop new_strs (cnt - 1) (Array.unsafe_get ovector 1) false + else + let new_strs = string_unsafe_sub subj pos 1 :: strs in + loop new_strs (cnt - 1) (pos + 1) true + else + if prematch then loop (handle_subgroups strs) cnt last false + else loop (handle_subgroups ("" :: strs)) (cnt - 1) last false + else + let new_strs = string_unsafe_sub subj pos (first - pos) :: strs in + loop (handle_subgroups new_strs) (cnt - 1) last false in + loop [] (max - 1) pos false + +let rec strip_all_empty = function "" :: t -> strip_all_empty t | l -> l + +external isspace : char -> bool = "pcre_isspace_stub" [@@noalloc] + +let rec find_no_space ix len str = + if ix = len || not (isspace (String.unsafe_get str ix)) then ix + else find_no_space (ix + 1) len str + +let split ?(iflags = 0) ?flags ?rex ?pat ?(pos = 0) ?(max = 0) ?callout subj = + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let res = + match pat, rex with + | Some str, _ -> internal_psplit iflags (regexp str) max pos callout subj + | _, Some rex -> internal_psplit iflags rex max pos callout subj + | _ -> + (* special case for Perl-splitting semantics *) + let len = String.length subj in + if pos > len || pos < 0 then failwith "Pcre.split: illegal offset"; + let new_pos = find_no_space pos len subj in + internal_psplit iflags def_rex max new_pos callout subj in + List.rev (if max = 0 then strip_all_empty res else res) + +let asplit ?iflags ?flags ?rex ?pat ?pos ?max ?callout subj = + Array.of_list (split ?iflags ?flags ?rex ?pat ?pos ?max ?callout subj) + + +(* Full splitting *) + +type split_result = Text of string + | Delim of string + | Group of int * string + | NoGroup + +let rec strip_all_empty_full = function + | Delim _ :: rest -> strip_all_empty_full rest + | l -> l + +let full_split ?(iflags = 0) ?flags ?(rex = def_rex) ?pat + ?(pos = 0) ?(max = 0) ?callout subj = + let rex = match pat with Some str -> regexp str | _ -> rex in + let iflags = match flags with Some flags -> rflags flags | _ -> iflags in + let subj_len = String.length subj in + if subj_len = 0 then [] + else if max = 1 then [Text (subj)] + else + let subgroups2, ovector = make_ovector rex in + + (* Adds contents of subgroups to the string accumulator *) + let handle_subgroups strs = + let strs = ref strs in + let i = ref 2 in + while !i < subgroups2 do + let group_nr = !i lsr 1 in + let first = Array.unsafe_get ovector !i in + incr i; + let last = Array.unsafe_get ovector !i in + let str = + if first < 0 then NoGroup + else + let group_str = string_unsafe_sub subj first (last - first) in + Group (group_nr, group_str) in + strs := str :: !strs; incr i + done; + !strs in + + (* Performs the recursive split *) + let rec loop strs cnt pos prematch = + let len = subj_len - pos in + if len < 0 then strs + else + (* Checks termination due to max restriction *) + if cnt = 0 then + if prematch && + try + unsafe_pcre_exec + iflags rex ~pos ~subj_start:pos ~subj ovector callout; + true + with Not_found -> false + then + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + let delim = Delim (string_unsafe_sub subj first (last - first)) in + Text (string_unsafe_sub subj last (subj_len - last)) + :: handle_subgroups (delim :: strs) + else + if len = 0 then strs + else Text (string_unsafe_sub subj pos len) :: strs + + (* Calculates next accumulator state for splitting *) + else + if + try + unsafe_pcre_exec + iflags rex ~pos ~subj_start:pos ~subj ovector callout; + false + with Not_found -> true + then + if len = 0 then strs + else Text (string_unsafe_sub subj pos len) :: strs + else + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + if first = pos then + if last = pos then + if len = 0 then handle_subgroups (Delim "" :: strs) + else + let empty_groups = handle_subgroups [] in + if + try + unsafe_pcre_exec + (iflags lor 0x0410) rex ~pos ~subj_start:pos ~subj + ovector callout; + true + with Not_found -> false + then + let first = Array.unsafe_get ovector 0 in + let last = Array.unsafe_get ovector 1 in + let delim = + Delim (string_unsafe_sub subj first (last - first)) in + let new_strs = + handle_subgroups ( + delim :: (if prematch then strs + else empty_groups @ (Delim "" :: strs))) in + loop new_strs (cnt - 1) last false + else + let new_strs = + Text (string_unsafe_sub subj pos 1) + :: empty_groups @ Delim "" :: strs in + loop new_strs (cnt - 1) (pos + 1) true + else + let delim = + Delim (string_unsafe_sub subj first (last - first)) in + loop (handle_subgroups (delim :: strs)) cnt last false + else + let delim = Delim (string_unsafe_sub subj first (last - first)) in + let pre_strs = + Text (string_unsafe_sub subj pos (first - pos)) :: strs in + loop + (handle_subgroups (delim :: pre_strs)) (cnt - 1) last false in + let res = loop [] (max - 1) pos true in + List.rev (if max = 0 then strip_all_empty_full res else res) + + +(* Additional convenience functions useful in combination with this library *) + +let foreach_line ?(ic = stdin) f = + try while true do f (input_line ic) done with End_of_file -> () + +let foreach_file filenames f = + let do_with_file filename = + let file = open_in filename in + try f filename file; close_in file + with exn -> close_in file; raise exn in + List.iter do_with_file filenames diff --git a/bundles/pcre/pcre-ocaml/src/pcre_stubs.c b/bundles/pcre/pcre-ocaml/src/pcre_stubs.c new file mode 100644 index 000000000..f542b608f --- /dev/null +++ b/bundles/pcre/pcre-ocaml/src/pcre_stubs.c @@ -0,0 +1,864 @@ +/* + PCRE-OCAML - Perl Compatibility Regular Expressions for OCaml + + Copyright (C) 1999- Markus Mottl + email: markus.mottl@gmail.com + WWW: http://www.ocaml.info + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#if defined(_WIN32) +# define snprintf _snprintf +# if defined(_DLL) +# define PCREextern __declspec(dllexport) +# else +# define PCREextern +# endif +#endif + +#if _WIN64 + typedef long long *ovec_dst_ptr; +#else + typedef long *ovec_dst_ptr; +#endif + +#if __GNUC__ >= 3 +# define inline inline __attribute__ ((always_inline)) +# define __unused __attribute__ ((unused)) +#else +# define __unused +# define inline +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +/* Error codes as defined for pcre 7.9, undefined in pcre 4.5 */ +#ifndef PCRE_ERROR_PARTIAL +#define PCRE_ERROR_PARTIAL (-12) +#endif +#ifndef PCRE_ERROR_BADPARTIAL +#define PCRE_ERROR_BADPARTIAL (-13) +#endif +#ifndef PCRE_ERROR_RECURSIONLIMIT +#define PCRE_ERROR_RECURSIONLIMIT (-21) +#endif + +typedef const unsigned char *chartables; /* Type of chartable sets */ + +/* Contents of callout data */ +struct cod { + long subj_start; /* Start of subject string */ + value *v_substrings_p; /* Pointer to substrings matched so far */ + value *v_cof_p; /* Pointer to callout function */ + value v_exn; /* Possible exception raised by callout function */ +}; + +/* Cache for exceptions */ +static value *pcre_exc_Error = NULL; /* Exception [Error] */ +static value *pcre_exc_Backtrack = NULL; /* Exception [Backtrack] */ + +/* Cache for polymorphic variants */ +static value var_Start_only; /* Variant [`Start_only] */ +static value var_ANCHORED; /* Variant [`ANCHORED] */ +static value var_Char; /* Variant [`Char char] */ +static value var_Not_studied; /* Variant [`Not_studied] */ +static value var_Studied; /* Variant [`Studied] */ +static value var_Optimal; /* Variant [`Optimal] */ + +static value None = Val_int(0); + +/* Data associated with OCaml values of PCRE regular expression */ +struct pcre_ocaml_regexp { pcre *rex; pcre_extra *extra; int studied; }; + +#define Pcre_ocaml_regexp_val(v) \ + ((struct pcre_ocaml_regexp *) Data_custom_val(v)) + +#define get_rex(v) Pcre_ocaml_regexp_val(v)->rex +#define get_extra(v) Pcre_ocaml_regexp_val(v)->extra +#define get_studied(v) Pcre_ocaml_regexp_val(v)->studied + +#define set_rex(v, r) Pcre_ocaml_regexp_val(v)->rex = r +#define set_extra(v, e) Pcre_ocaml_regexp_val(v)->extra = e +#define set_studied(v, s) Pcre_ocaml_regexp_val(v)->studied = s + +/* Data associated with OCaml values of PCRE tables */ +struct pcre_ocaml_tables { chartables tables; }; + +#define Pcre_ocaml_tables_val(v) \ + ((struct pcre_ocaml_tables *) Data_custom_val(v)) + +#define get_tables(v) Pcre_ocaml_tables_val(v)->tables +#define set_tables(v, t) Pcre_ocaml_tables_val(v)->tables = t + +/* Converts subject offsets from C-integers to OCaml-Integers. + + This is a bit tricky, because there are 32- and 64-bit platforms around + and OCaml chooses the larger possibility for representing integers when + available (also in arrays) - not so the PCRE! +*/ +static inline void copy_ovector( + long subj_start, const int *ovec_src, ovec_dst_ptr ovec_dst, int subgroups2) +{ + if (subj_start == 0) + while (subgroups2--) { + *ovec_dst = Val_int(*ovec_src); + --ovec_src; --ovec_dst; + } + else + while (subgroups2--) { + *ovec_dst = Val_long(*ovec_src + subj_start); + --ovec_src; --ovec_dst; + } +} + +/* Callout handler */ +static int pcre_callout_handler(pcre_callout_block* cb) +{ + struct cod *cod = (struct cod *) cb->callout_data; + + if (cod != NULL) { + /* Callout is available */ + value v_res; + + /* Set up parameter array */ + value v_callout_data = caml_alloc_small(8, 0); + + const value v_substrings = *cod->v_substrings_p; + + const int capture_top = cb->capture_top; + int subgroups2 = capture_top << 1; + const int subgroups2_1 = subgroups2 - 1; + + const int *ovec_src = cb->offset_vector + subgroups2_1; + ovec_dst_ptr ovec_dst = &Field(Field(v_substrings, 1), 0) + subgroups2_1; + long subj_start = cod->subj_start; + + copy_ovector(subj_start, ovec_src, ovec_dst, subgroups2); + + Field(v_callout_data, 0) = Val_int(cb->callout_number); + Field(v_callout_data, 1) = v_substrings; + Field(v_callout_data, 2) = Val_int(cb->start_match + subj_start); + Field(v_callout_data, 3) = Val_int(cb->current_position + subj_start); + Field(v_callout_data, 4) = Val_int(capture_top); + Field(v_callout_data, 5) = Val_int(cb->capture_last); + Field(v_callout_data, 6) = Val_int(cb->pattern_position); + Field(v_callout_data, 7) = Val_int(cb->next_item_length); + + /* Perform callout */ + v_res = caml_callback_exn(*cod->v_cof_p, v_callout_data); + + if (Is_exception_result(v_res)) { + /* Callout raised an exception */ + const value v_exn = Extract_exception(v_res); + if (Field(v_exn, 0) == *pcre_exc_Backtrack) return 1; + cod->v_exn = v_exn; + return PCRE_ERROR_CALLOUT; + } + } + + return 0; +} + +/* Fetchs the named OCaml-values + caches them and + calculates + caches the variant hash values */ +CAMLprim value pcre_ocaml_init(value __unused v_unit) +{ + pcre_exc_Error = caml_named_value("Pcre.Error"); + pcre_exc_Backtrack = caml_named_value("Pcre.Backtrack"); + + var_Start_only = caml_hash_variant("Start_only"); + var_ANCHORED = caml_hash_variant("ANCHORED"); + var_Char = caml_hash_variant("Char"); + var_Not_studied = caml_hash_variant("Not_studied"); + var_Studied = caml_hash_variant("Studied"); + var_Optimal = caml_hash_variant("Optimal"); + + pcre_callout = &pcre_callout_handler; + + return Val_unit; +} + +/* Finalizing deallocation function for chartable sets */ +static void pcre_dealloc_tables(value v_tables) +{ (pcre_free)((void *) get_tables(v_tables)); } + +/* Finalizing deallocation function for compiled regular expressions */ +static void pcre_dealloc_regexp(value v_rex) +{ + void *extra = get_extra(v_rex); + if (extra != NULL) +#ifdef PCRE_STUDY_JIT_COMPILE + pcre_free_study(extra); +#else + pcre_free(extra); +#endif + (pcre_free)(get_rex(v_rex)); +} + + +/* Raising exceptions */ + + +static inline void raise_pcre_error(value v_arg) +; + + +static inline void raise_partial() +; + + +static inline void raise_bad_partial() +; + + +static inline void raise_bad_utf8() +; + + +static inline void raise_bad_utf8_offset() +; + + +static inline void raise_match_limit() +; + + +static inline void raise_recursion_limit() +; + + +static inline void raise_bad_pattern(const char *msg, int pos) +; + + +static inline void raise_internal_error(char *msg) +; + +static inline void raise_pcre_error(value v_arg) +{ caml_raise_with_arg(*pcre_exc_Error, v_arg); } + +static inline void raise_partial() { raise_pcre_error(Val_int(0)); } +static inline void raise_bad_partial() { raise_pcre_error(Val_int(1)); } +static inline void raise_bad_utf8() { raise_pcre_error(Val_int(2)); } +static inline void raise_bad_utf8_offset() { raise_pcre_error(Val_int(3)); } +static inline void raise_match_limit() { raise_pcre_error(Val_int(4)); } +static inline void raise_recursion_limit() { raise_pcre_error(Val_int(5)); } + +static inline void raise_bad_pattern(const char *msg, int pos) +{ + CAMLparam0(); + CAMLlocal1(v_msg); + value v_arg; + v_msg = caml_copy_string(msg); + v_arg = caml_alloc_small(2, 0); + Field(v_arg, 0) = v_msg; + Field(v_arg, 1) = Val_int(pos); + raise_pcre_error(v_arg); + CAMLnoreturn; +} + +static inline void raise_internal_error(char *msg) +{ + CAMLparam0(); + CAMLlocal1(v_msg); + value v_arg; + v_msg = caml_copy_string(msg); + v_arg = caml_alloc_small(1, 1); + Field(v_arg, 0) = v_msg; + raise_pcre_error(v_arg); + CAMLnoreturn; +} + +/* PCRE pattern compilation */ + +static struct custom_operations regexp_ops = { + "pcre_ocaml_regexp", + pcre_dealloc_regexp, + custom_compare_default, + custom_hash_default, + custom_serialize_default, + custom_deserialize_default, + custom_compare_ext_default +}; + +/* Makes compiled regular expression from compilation options, an optional + value of chartables and the pattern string */ + +CAMLprim value pcre_compile_stub(intnat v_opt, value v_tables, value v_pat) +{ + value v_rex; /* Final result -> value of type [regexp] */ + const char *error = NULL; /* pointer to possible error message */ + int error_ofs = 0; /* offset in the pattern at which error occurred */ + + /* If v_tables = [None], then pointer to tables is NULL, otherwise + set it to the appropriate value */ + chartables tables = + (v_tables == None) ? NULL : get_tables(Field(v_tables, 0)); + + /* Compiles the pattern */ + pcre *regexp = pcre_compile(String_val(v_pat), (v_opt), &error, + &error_ofs, tables); + + /* Raises appropriate exception with [BadPattern] if the pattern + could not be compiled */ + if (regexp == NULL) raise_bad_pattern(error, error_ofs); + + /* GC will do a full cycle every 1_000_000 regexp allocations (a typical + regexp probably consumes less than 100 bytes -> maximum of 100_000_000 + bytes unreclaimed regexps) */ + v_rex = + caml_alloc_custom(®exp_ops, + sizeof(struct pcre_ocaml_regexp), 1, 1000000); + + set_rex(v_rex, regexp); + set_extra(v_rex, NULL); + set_studied(v_rex, 0); + + return v_rex; +} + +CAMLprim value pcre_compile_stub_bc(value v_opt, value v_tables, value v_pat) +{ + return pcre_compile_stub(Int_val(v_opt), v_tables, v_pat); +} + + +/* Studies a regexp */ +CAMLprim value pcre_study_stub(value v_rex) +{ + /* If it has not yet been studied */ + if (! get_studied(v_rex)) { + const char *error = NULL; + pcre_extra *extra = pcre_study(get_rex(v_rex), 0, &error); + if (error != NULL) caml_invalid_argument((char *) error); + set_extra(v_rex, extra); + set_studied(v_rex, 1); + } + return v_rex; +} + + +/* Gets the match limit recursion of a regular expression if it exists */ +CAMLprim value pcre_get_match_limit_recursion_stub(value v_rex) +{ + pcre_extra *extra = get_extra(v_rex); + if (extra == NULL) return None; + if (extra->flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION) { + value v_lim = Val_int(extra->match_limit_recursion); + value v_res = caml_alloc_small(1, 0); + Field(v_res, 0) = v_lim; + return v_res; + } + return None; +} + +/* Gets the match limit of a regular expression if it exists */ +CAMLprim value pcre_get_match_limit_stub(value v_rex) +{ + pcre_extra *extra = get_extra(v_rex); + if (extra == NULL) return None; + if (extra->flags & PCRE_EXTRA_MATCH_LIMIT) { + value v_lim = Val_int(extra->match_limit); + value v_res = caml_alloc_small(1, 0); + Field(v_res, 0) = v_lim; + return v_res; + } + return None; +} + + +/* Sets a match limit for a regular expression imperatively */ + +CAMLprim value pcre_set_imp_match_limit_stub(value v_rex, intnat v_lim) +{ + pcre_extra *extra = get_extra(v_rex); + if (extra == NULL) { + extra = pcre_malloc(sizeof(pcre_extra)); + extra->flags = PCRE_EXTRA_MATCH_LIMIT; + set_extra(v_rex, extra); + } else { + unsigned long *flags_ptr = &extra->flags; + *flags_ptr = PCRE_EXTRA_MATCH_LIMIT | *flags_ptr; + } + extra->match_limit = (v_lim); + return v_rex; +} + +CAMLprim value pcre_set_imp_match_limit_stub_bc(value v_rex, value v_lim) +{ + return pcre_set_imp_match_limit_stub(v_rex, Int_val(v_lim)); +} + + +/* Sets a match limit recursion for a regular expression imperatively */ + +CAMLprim value pcre_set_imp_match_limit_recursion_stub( + value v_rex, intnat v_lim) +{ + pcre_extra *extra = get_extra(v_rex); + if (extra == NULL) { + extra = pcre_malloc(sizeof(pcre_extra)); + extra->flags = PCRE_EXTRA_MATCH_LIMIT_RECURSION; + set_extra(v_rex, extra); + } else { + unsigned long *flags_ptr = &extra->flags; + *flags_ptr = PCRE_EXTRA_MATCH_LIMIT_RECURSION | *flags_ptr; + } + extra->match_limit_recursion = (v_lim); + return v_rex; +} + +CAMLprim value pcre_set_imp_match_limit_recursion_stub_bc( + value v_rex, value v_lim) +{ + return pcre_set_imp_match_limit_recursion_stub(v_rex, Int_val(v_lim)); +} + + +/* Performs the call to the pcre_fullinfo function */ +static inline int pcre_fullinfo_stub(value v_rex, int what, void *where) +{ + return pcre_fullinfo(get_rex(v_rex), get_extra(v_rex), what, where); +} + +/* Some stubs for info-functions */ + +/* Generic macro for getting integer results from pcre_fullinfo */ +#define make_intnat_info(tp, name, option) \ + CAMLprim intnat pcre_##name##_stub(value v_rex) \ + { \ + tp options; \ + const int ret = pcre_fullinfo_stub(v_rex, PCRE_INFO_##option, &options); \ + if (ret != 0) raise_internal_error("pcre_##name##_stub"); \ + return (options); \ + } \ + \ + CAMLprim value pcre_##name##_stub_bc(value v_rex) \ + { return Val_int(pcre_##name##_stub(v_rex)); } + +make_intnat_info(unsigned long, options, OPTIONS) +make_intnat_info(size_t, size, SIZE) +make_intnat_info(size_t, studysize, STUDYSIZE) +make_intnat_info(int, capturecount, CAPTURECOUNT) +make_intnat_info(int, backrefmax, BACKREFMAX) +make_intnat_info(int, namecount, NAMECOUNT) +make_intnat_info(int, nameentrysize, NAMEENTRYSIZE) + +CAMLprim value pcre_firstbyte_stub(value v_rex) +{ + int firstbyte; + const int ret = pcre_fullinfo_stub(v_rex, PCRE_INFO_FIRSTBYTE, &firstbyte); + + if (ret != 0) raise_internal_error("pcre_firstbyte_stub"); + + switch (firstbyte) { + case -1 : return var_Start_only; break; /* [`Start_only] */ + case -2 : return var_ANCHORED; break; /* [`ANCHORED] */ + default : + if (firstbyte < 0 ) /* Should not happen */ + raise_internal_error("pcre_firstbyte_stub"); + else { + value v_firstbyte; + /* Allocates the non-constant constructor [`Char of char] and fills + in the appropriate value */ + v_firstbyte = caml_alloc_small(2, 0); + Field(v_firstbyte, 0) = var_Char; + Field(v_firstbyte, 1) = Val_int(firstbyte); + return v_firstbyte; + } + } + return Val_unit; /* unreachable, but warning with OCaml 4.02 */ +} + +CAMLprim value pcre_firsttable_stub(value v_rex) +{ + const unsigned char *ftable; + + int ret = + pcre_fullinfo_stub(v_rex, PCRE_INFO_FIRSTTABLE, (void *) &ftable); + + if (ret != 0) raise_internal_error("pcre_firsttable_stub"); + + if (ftable == NULL) return None; + else { + value v_res, v_res_str; + char *ptr; + int i; + + Begin_roots1(v_rex); + v_res_str = caml_alloc_string(32); + End_roots(); + + ptr = String_val(v_res_str); + for (i = 0; i <= 31; ++i) { *ptr = *ftable; ++ptr; ++ftable; } + + Begin_roots1(v_res_str); + /* Allocates [Some string] from firsttable */ + v_res = caml_alloc_small(1, 0); + End_roots(); + + Field(v_res, 0) = v_res_str; + + return v_res; + } +} + +CAMLprim value pcre_lastliteral_stub(value v_rex) +{ + int lastliteral; + const int ret = pcre_fullinfo_stub(v_rex, PCRE_INFO_LASTLITERAL, + &lastliteral); + + if (ret != 0) raise_internal_error("pcre_lastliteral_stub"); + + if (lastliteral == -1) return None; + if (lastliteral < 0) raise_internal_error("pcre_lastliteral_stub"); + else { + /* Allocates [Some char] */ + value v_res = caml_alloc_small(1, 0); + Field(v_res, 0) = Val_int(lastliteral); + return v_res; + } + return Val_unit; /* unreachable, but warning with OCaml 4.02 */ +} + +CAMLprim value pcre_study_stat_stub(value v_rex) +{ + /* Generates the appropriate constant constructor [`Optimal] or + [`Studied] if regexp has already been studied */ + if (get_studied(v_rex)) + return (get_extra(v_rex) == NULL) ? var_Optimal : var_Studied; + + return var_Not_studied; /* otherwise [`Not_studied] */ +} + + +static inline void handle_exec_error(char *loc, const int ret) +; + +static inline void handle_exec_error(char *loc, const int ret) +{ + switch (ret) { + /* Dedicated exceptions */ + case PCRE_ERROR_NOMATCH : caml_raise_not_found(); + case PCRE_ERROR_PARTIAL : raise_partial(); + case PCRE_ERROR_MATCHLIMIT : raise_match_limit(); + case PCRE_ERROR_BADPARTIAL : raise_bad_partial(); + case PCRE_ERROR_BADUTF8 : raise_bad_utf8(); + case PCRE_ERROR_BADUTF8_OFFSET : raise_bad_utf8_offset(); + case PCRE_ERROR_RECURSIONLIMIT : raise_recursion_limit(); + /* Unknown error */ + default : { + char err_buf[100]; + snprintf(err_buf, 100, "%s: unhandled PCRE error code: %d", loc, ret); + raise_internal_error(err_buf); + } + } +} + +static inline void handle_pcre_exec_result( + int *ovec, value v_ovec, long ovec_len, long subj_start, int ret) +{ + ovec_dst_ptr ocaml_ovec = (ovec_dst_ptr) &Field(v_ovec, 0); + const int subgroups2 = ret * 2; + const int subgroups2_1 = subgroups2 - 1; + const int *ovec_src = ovec + subgroups2_1; + ovec_dst_ptr ovec_clear_stop = ocaml_ovec + (ovec_len * 2) / 3; + ovec_dst_ptr ovec_dst = ocaml_ovec + subgroups2_1; + copy_ovector(subj_start, ovec_src, ovec_dst, subgroups2); + while (++ovec_dst < ovec_clear_stop) *ovec_dst = -1; +} + + +/* Executes a pattern match with runtime options, a regular expression, a + matching position, the start of the the subject string, a subject string, + a number of subgroup offsets, an offset vector and an optional callout + function */ + +CAMLprim value pcre_exec_stub( + intnat v_opt, value v_rex, intnat v_pos, intnat v_subj_start, value v_subj, + value v_ovec, value v_maybe_cof) +{ + int ret; + long + pos = (v_pos), + len = caml_string_length(v_subj), + subj_start = (v_subj_start); + long ovec_len = Wosize_val(v_ovec); + + if (pos > len || pos < subj_start) + caml_invalid_argument("Pcre.pcre_exec_stub: illegal position"); + + if (subj_start > len || subj_start < 0) + caml_invalid_argument("Pcre.pcre_exec_stub: illegal subject start"); + + pos -= subj_start; + len -= subj_start; + + { + const pcre *code = get_rex(v_rex); /* Compiled pattern */ + const pcre_extra *extra = get_extra(v_rex); /* Extra info */ + const char *ocaml_subj = + String_val(v_subj) + subj_start; /* Subject string */ + const int opt = (v_opt); /* Runtime options */ + + /* Special case when no callout functions specified */ + if (v_maybe_cof == None) { + int *ovec = (int *) &Field(v_ovec, 0); + + /* Performs the match */ + ret = pcre_exec(code, extra, ocaml_subj, len, pos, opt, ovec, ovec_len); + + if (ret < 0) handle_exec_error("pcre_exec_stub", ret); + else handle_pcre_exec_result(ovec, v_ovec, ovec_len, subj_start, ret); + } + + /* There are callout functions */ + else { + value v_cof = Field(v_maybe_cof, 0); + value v_substrings; + char *subj = caml_stat_alloc(sizeof(char) * len); + int *ovec = caml_stat_alloc(sizeof(int) * ovec_len); + struct cod cod = { 0, (value *) NULL, (value *) NULL, (value) NULL }; + struct pcre_extra new_extra = +#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION +# ifdef PCRE_EXTRA_MARK +# ifdef PCRE_EXTRA_EXECUTABLE_JIT + { PCRE_EXTRA_CALLOUT_DATA, NULL, 0, NULL, NULL, 0, NULL, NULL }; +# else + { PCRE_EXTRA_CALLOUT_DATA, NULL, 0, NULL, NULL, 0, NULL }; +# endif +# else + { PCRE_EXTRA_CALLOUT_DATA, NULL, 0, NULL, NULL, 0 }; +# endif +#else + { PCRE_EXTRA_CALLOUT_DATA, NULL, 0, NULL, NULL }; +#endif + + cod.subj_start = subj_start; + memcpy(subj, ocaml_subj, len); + + Begin_roots4(v_rex, v_cof, v_substrings, v_ovec); + Begin_roots1(v_subj); + v_substrings = caml_alloc_small(2, 0); + End_roots(); + + Field(v_substrings, 0) = v_subj; + Field(v_substrings, 1) = v_ovec; + + cod.v_substrings_p = &v_substrings; + cod.v_cof_p = &v_cof; + new_extra.callout_data = &cod; + + if (extra == NULL) { + ret = pcre_exec(code, &new_extra, subj, len, pos, opt, ovec, + ovec_len); + } + else { + new_extra.flags = PCRE_EXTRA_CALLOUT_DATA | extra->flags; + new_extra.study_data = extra->study_data; + new_extra.match_limit = extra->match_limit; + new_extra.tables = extra->tables; +#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION + new_extra.match_limit_recursion = extra->match_limit_recursion; +#endif + + ret = pcre_exec(code, &new_extra, subj, len, pos, opt, ovec, + ovec_len); + } + + caml_stat_free(subj); + End_roots(); + + if (ret < 0) { + caml_stat_free(ovec); + if (ret == PCRE_ERROR_CALLOUT) caml_raise(cod.v_exn); + else handle_exec_error("pcre_exec_stub(callout)", ret); + } else { + handle_pcre_exec_result(ovec, v_ovec, ovec_len, subj_start, ret); + caml_stat_free(ovec); + } + } + } + + return Val_unit; +} + +/* Byte-code hook for pcre_exec_stub + Needed, because there are more than 5 arguments */ +CAMLprim value pcre_exec_stub_bc(value *argv, int __unused argn) +{ + return + pcre_exec_stub( + Int_val(argv[0]), argv[1], Int_val(argv[2]), Int_val(argv[3]), + argv[4], argv[5], argv[6]); +} + +static struct custom_operations tables_ops = { + "pcre_ocaml_tables", + pcre_dealloc_tables, + custom_compare_default, + custom_hash_default, + custom_serialize_default, + custom_deserialize_default, + custom_compare_ext_default +}; + +/* Generates a new set of chartables for the current locale (see man + page of PCRE */ +CAMLprim value pcre_maketables_stub(value __unused v_unit) +{ + /* GC will do a full cycle every 1_000_000 table set allocations (one + table set consumes 864 bytes -> maximum of 864_000_000 bytes unreclaimed + table sets) */ + const value v_tables = + caml_alloc_custom( + &tables_ops, sizeof(struct pcre_ocaml_tables), 1, 1000000); + set_tables(v_tables, pcre_maketables()); + return v_tables; +} + +/* Wraps around the isspace-function */ +CAMLprim value pcre_isspace_stub(value v_c) +{ + return Val_bool(isspace(Int_val(v_c))); +} + + +/* Returns number of substring associated with a name */ + +CAMLprim intnat pcre_get_stringnumber_stub(value v_rex, value v_name) +{ + const int ret = pcre_get_stringnumber(get_rex(v_rex), String_val(v_name)); + if (ret == PCRE_ERROR_NOSUBSTRING) + caml_invalid_argument("Named string not found"); + + return (ret); +} + +CAMLprim value pcre_get_stringnumber_stub_bc(value v_rex, value v_name) +{ + return Val_int(pcre_get_stringnumber_stub(v_rex, v_name)); +} + + +/* Returns array of names of named substrings in a regexp */ +CAMLprim value pcre_names_stub(value v_rex) +{ + CAMLparam0(); + CAMLlocal1(v_res); + int name_count; + int entry_size; + const char *tbl_ptr; + int i; + + int ret = pcre_fullinfo_stub(v_rex, PCRE_INFO_NAMECOUNT, &name_count); + if (ret != 0) raise_internal_error("pcre_names_stub: namecount"); + + ret = pcre_fullinfo_stub(v_rex, PCRE_INFO_NAMEENTRYSIZE, &entry_size); + if (ret != 0) raise_internal_error("pcre_names_stub: nameentrysize"); + + ret = pcre_fullinfo_stub(v_rex, PCRE_INFO_NAMETABLE, &tbl_ptr); + if (ret != 0) raise_internal_error("pcre_names_stub: nametable"); + + v_res = caml_alloc(name_count, 0); + + for (i = 0; i < name_count; ++i) { + value v_name = caml_copy_string(tbl_ptr + 2); + Store_field(v_res, i, v_name); + tbl_ptr += entry_size; + } + + CAMLreturn(v_res); +} + +/* Generic stub for getting integer results from pcre_config */ +static inline int pcre_config_int(int what) +{ + int ret; + pcre_config(what, (void *) &ret); + return ret; +} + +/* Generic stub for getting long integer results from pcre_config */ +static inline int pcre_config_long(int what) +{ + long ret; + pcre_config(what, (void *) &ret); + return ret; +} + + +/* Some stubs for config-functions */ + +/* Makes OCaml-string from PCRE-version */ +CAMLprim value pcre_version_stub(value __unused v_unit) +{ + return caml_copy_string((char *) pcre_version()); +} + +/* Returns boolean indicating UTF8-support */ +CAMLprim value pcre_config_utf8_stub(value __unused v_unit) +{ return Val_bool(pcre_config_int(PCRE_CONFIG_UTF8)); } + + +/* Returns character used as newline */ +CAMLprim value pcre_config_newline_stub(value __unused v_unit) +{ return Val_int(pcre_config_int(PCRE_CONFIG_NEWLINE)); } + + +/* Returns number of bytes used for internal linkage of regular expressions */ + +CAMLprim intnat pcre_config_link_size_stub(value __unused v_unit) +{ return (pcre_config_int(PCRE_CONFIG_LINK_SIZE)); } + +CAMLprim value pcre_config_link_size_stub_bc(value v_unit) +{ return Val_int(pcre_config_link_size_stub(v_unit)); } + + +/* Returns default limit for calls to internal matching function */ + +CAMLprim intnat pcre_config_match_limit_stub(value __unused v_unit) +{ return (pcre_config_long(PCRE_CONFIG_MATCH_LIMIT)); } + + +CAMLprim value pcre_config_match_limit_stub_bc(value v_unit) +{ return Val_int(pcre_config_match_limit_stub(v_unit)); } + + +/* Returns default limit for recursive calls to internal matching function */ + +CAMLprim intnat pcre_config_match_limit_recursion_stub(value __unused v_unit) +{ return (pcre_config_long(PCRE_CONFIG_MATCH_LIMIT_RECURSION)); } + +CAMLprim value pcre_config_match_limit_recursion_stub_bc(value v_unit) +{ return Val_int(pcre_config_match_limit_recursion_stub(v_unit)); } + + +/* Returns boolean indicating use of stack recursion */ +CAMLprim value pcre_config_stackrecurse_stub(value __unused v_unit) +{ return Val_bool(pcre_config_int(PCRE_CONFIG_STACKRECURSE)); } diff --git a/bundles/pyml/Makefile b/bundles/pyml/Makefile index 50bc526ef..4e8cb652e 100644 --- a/bundles/pyml/Makefile +++ b/bundles/pyml/Makefile @@ -24,15 +24,7 @@ CLEANOTHERS=pyml-current/generate pyml-current/generate.cmi \ GENERATED_SOURCE_FILES := $(SRC_DIR)/pywrappers.ml $(SRC_DIR)/pywrappers.mli OCAMLCCFLAGS+=-ccopt -I$(STDCOMPATDIR) -UNAME_ARCH := $(shell uname) - -ifeq ($(UNAME_ARCH),Darwin) - PYML_ARCH := pyml_arch_darwin.ml -else ifeq ($(findstring CYGWIN,$(UNAME_ARCH)),CYGWIN) - PYML_ARCH := pyml_arch_cygwin.ml -else - PYML_ARCH := pyml_arch_unix.ml -endif +C_COMPILER := $(shell ocamlc -config | grep '^native_c_compiler:' | cut -d ' ' -f 2) include ../Makefile.bundles @@ -56,6 +48,9 @@ else LINK_BEST := $(LINK_BYTECODE) endif +ifneq ($(OCAMLATLEAST50),no) +OCAMLFLAGS += -I +unix +endif distclean: clean rm -f .prepare @@ -87,7 +82,7 @@ $(SRC_DIR)/pyml_arch.cmo: $(SRC_DIR)/pyml_arch.ml $(SRC_DIR)/pyml_arch.cmi $(SRC_DIR)/pyutils.cmo $(SRC_DIR)/pyutils.cmx : $(SRC_DIR)/pyutils.cmi $(SRC_DIR)/generate : $(SRC_DIR)/pyutils.$(CMOX) $(SRC_DIR)/generate.$(CMOX) - $(OCAMLCOPT) $(OCAMLLDFLAGS) $(LINK_BEST) stdcompat.$(CMAX) unix.$(CMAX) $^ -o $@ + $(OCAMLC_CMD) $(OCAMLLDFLAGS) $(LINK_BEST) stdcompat.$(CMAX) unix.$(CMAX) $^ -o $@ $(SRC_DIR)/generate.cmx: $(SRC_DIR)/generate.ml $(OCAMLOPT_CMD) -c $< -o $@ @@ -95,5 +90,5 @@ $(SRC_DIR)/generate.cmx: $(SRC_DIR)/generate.ml $(SRC_DIR)/generate.cmo: $(SRC_DIR)/generate.ml $(OCAMLC_CMD) -c $< -o $@ -$(SRC_DIR)/pyml_arch.ml: $(SRC_DIR)/$(PYML_ARCH) - cp $< $@ +$(SRC_DIR)/pyml_arch.ml : $(SRC_DIR)/pyml_arch.ml.c + $(C_COMPILER) -E $< | sed '/^#/d' >$@ diff --git a/bundles/pyml/pyml-current/.gitignore b/bundles/pyml/pyml-current/.gitignore index 7c3e29c02..40b91d0db 100644 --- a/bundles/pyml/pyml-current/.gitignore +++ b/bundles/pyml/pyml-current/.gitignore @@ -1,3 +1,4 @@ +_opam _build .merlin .depend @@ -21,3 +22,6 @@ _build /numpy_tests.bytecode /pyml_tests.native /numpy_tests.native +/pyops.ml +/pyops.mli +/pyml_arch_generate.exe diff --git a/bundles/pyml/pyml-current/CHANGES.md b/bundles/pyml/pyml-current/CHANGES.md index fc360225e..e8dc23b83 100644 --- a/bundles/pyml/pyml-current/CHANGES.md +++ b/bundles/pyml/pyml-current/CHANGES.md @@ -1,6 +1,133 @@ [*] marks changes that break compatibility with previous versions. -# Next version +# 2022-09-05 + +- Support for OCaml 5.0 + +- Support for Python 3.11. + All OCaml exceptions raised in callbacks are now encapsulated with their + backtrace in Python exceptions instead of bypassing the Python interpreter. + The former behavior led to segmentation faults in the test-suite, and nothing + indicate that previous versions of Python were supposed to support that well. + *The new behavior can break existing code*, especially code relying on + `Py.Run.simple_string`, which now catches all exceptions, including OCaml + exceptions. If you need proper exception handling, you can use `Py.Run.eval`. + (reported by Jerry James, + https://github.com/thierry-martinez/pyml/issues/84) + +- New function `Py.Object.dir`. + +- New functions `Py.Err.set_interrupt` and, for Python >=3.10, + `Py.Err.set_interrupt_ex`. + +- New functions + `Py.Dict.{to_bindings_seq, to_bindings_seq_map, to_bindings_string_seq}`. + +- New function `Py.Capsule.create`, equivalent to `Py.Capsule.make`, but + returning the record `{ wrap; unwrap }` of the new type `'a Py.Capsule.t` + instead of a pair. + +- Do not let `python` capture `sigint` by default (can be changed by passing + `~python_sigint:true` to `Py.initialize`): `Ctrl+C` now interrupts the + program, even after `Py.initialize` is called. + (reported by Arulselvan Madhavan, + https://github.com/thierry-martinez/pyml/issues/83) + +- Bindings for exceptions: `PyExc_EncodingWarning` (added in Python 3.10), + `PyExc_ResourceWarning` (added in Python 3.2) + (reported by Jerry James, + https://github.com/thierry-martinez/pyml/issues/84) + +- Fixes in bindings for `PyCompilerFlags`, `PyMarshal_WriteObjectToFile`, + and `PySet_Clear` + (reported by Jerry James, + https://github.com/thierry-martinez/pyml/issues/84) + +# 2022-06-15 + +- `Numpy.to_bigarray_k` is continuation-passing-style version of `Numpy.to_bigarray`, + allowing caller to convert Numpy arrays to bigarrays without having to know + the kind and the layout of the array + (suggested by Lindsay Errington and Andie Sigler, + https://github.com/thierry-martinez/pyml/issues/81) + +# 2022-03-25 + +- Fix debug build detection + +- Expose the function `Py.Callable.handle_errors` + +# 2022-03-22 + +- New function `Py.Import.exec_code_module_from_string` + (suggested by Francois Berenger, https://github.com/thierry-martinez/pyml/issues/78) + +- New function `Py.Module.compile` provides a better API than `Py.compile`. + +- `Py.Object.t` can now be serialized (with Marshal or output_value), using Python + pickle module + +- Cross-compiling friendly architecture detection + (suggested by @EduardoRFS, https://discuss.ocaml.org/t/a-zoo-of-values-for-system/8525/20) + +- Detect macro `unix` instead of `__linux__`, to handle *BSD OSes + (reported by Chris Pinnock, https://github.com/thierry-martinez/pyml/issues/74) + +- Fix bug in Windows + +- Null checks for many functions raising OCaml exceptions, instead of segmentation fault + (initial implementation by Laurent Mazare, https://github.com/thierry-martinez/pyml/pull/72) + +- Fix wide character conversion bugs leading to segmentation fault in Py_wfopen + (fixed by Jerry James, https://github.com/thierry-martinez/pyml/pull/75) + +- `Gc.full_major ()` before unloading `libpython` in `Py.finalize`, to prevent + segfaulting on finalizing dangling references to Python values after the library + had been unloaded + (reported by Denis Efremov on coccinelle mailing list) + +- Fix segmentation fault when `~debug_build:true` was passed to `Py.initialize` + (reported by Stéphane Glondu, https://github.com/thierry-martinez/pyml/issues/79) + +# 2021-10-15 + +- More portable architecture detection + (inspired by the discussion https://discuss.ocaml.org/t/a-zoo-of-values-for-system/8525 + initiated by Olaf Hering, with helpful comments from Daniel Bünzli, + @EduardoRFS, David Allsopp, kit-ty-kate and jbeckford) + +- Better compatibility with Windows + +- Correct version detection for Python 3.10 + +# 2021-09-24 + +- Use `dune` as default build system + (dunification done by Laurent Mazare, https://github.com/thierry-martinez/pyml/pull/28) + + This should in particular fix build problems of reverse dependencies + with the byte-code compiler + (reported by @nicoTolly, https://github.com/thierry-martinez/pyml/issues/62) + + - Handle more platforms with dune + (reported by Olaf Hering, https://github.com/thierry-martinez/pyml/issues/68) + + - `pyutils` is no longer used by generate and is shipped with `pyml` package + as it was the case with Makefile-based build system + (reported by Olaf Hering, https://github.com/thierry-martinez/pyml/issues/69) + +- Support for raising exceptions with traceback from OCaml + (implemented by Laurent Mazare, https://github.com/thierry-martinez/pyml/pull/65) + +- Fix soundness bug with `numpy` + (reported by Richard Alligier, https://github.com/thierry-martinez/pyml/pull/65) + +- Fix `Py.Array.numpy` arrays on 32-bit platforms + (reported by Olaf Hering, https://github.com/thierry-martinez/pyml/pull/70) + +- Fix soundness bug on strings with OCaml <4.06 (reported by OCaml CI) + +# 2021-02-26 - Compatibility with Python 3.10 (reported by Richard W.M. Jones) @@ -10,6 +137,25 @@ - `Py_fopen` is optional and `Py_wfopen` is used instead if available. +- More general handling of Unix architectures. + (Fixed by Pino Toscano, https://github.com/thierry-martinez/pyml/pull/57) + +- Add `Py.Set` module for Python sets. + (Added by Laurent Mazare, https://github.com/thierry-martinez/pyml/pull/58) + +- Fix #61: `Numpy.to_bigarray` raises an exception if source value is + not a Numpy array instead of segfaulting. + (Reported by Jonathan Laurent, + https://github.com/thierry-martinez/pyml/issues/61) + +- Fix #56, #59: Add `python-config` heuristics to find Python library. + (Reported by Anders Thuné and Nils Becker, + https://github.com/thierry-martinez/pyml/issues/56 + https://github.com/thierry-martinez/pyml/issues/59) + +- Fix `import_module_opt` for Python <3.6 + (Reported by opam CI.) + # 2020-05-18 - Fix: Add an `__iter__` method to python iterators. diff --git a/bundles/pyml/pyml-current/LICENSE b/bundles/pyml/pyml-current/LICENSE index e9ad7d187..74bd06ead 100644 --- a/bundles/pyml/pyml-current/LICENSE +++ b/bundles/pyml/pyml-current/LICENSE @@ -1,30 +1,25 @@ -Copyright 1992-2016 The FreeBSD Project. All rights reserved. +BSD 2-Clause License -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +Copyright (c) 2016-2021, Thierry Martinez. +All rights reserved. - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: - 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. +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +* 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 views and conclusions contained in the software and documentation -are those of the authors and should not be interpreted as representing -official policies, either expressed or implied, of the FreeBSD -Project. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. diff --git a/bundles/pyml/pyml-current/Makefile b/bundles/pyml/pyml-current/Makefile index 1763b120b..c59461b1d 100644 --- a/bundles/pyml/pyml-current/Makefile +++ b/bundles/pyml/pyml-current/Makefile @@ -4,6 +4,9 @@ INSTALL := install INSTALL_PROGRAM := $(INSTALL) bindir := $(PREFIX)/bin +C_COMPILER := $(shell ocamlc -config | grep '^native_c_compiler:' | cut -d ' ' -f 2) +EXT_LIB := $(shell ocamlc -config | grep '^ext_lib:' | cut -d ' ' -f 2) + HAVE_OCAMLFIND := $(shell \ if $(OCAMLFIND) query -help >/dev/null 2>&1; then \ echo yes; \ @@ -33,12 +36,6 @@ ifneq ($(HAVE_OCAMLFIND),no) OCAMLDEP := $(OCAMLFIND) ocamldep OCAMLDOC := $(OCAMLFIND) ocamldoc STDCOMPAT := $(shell $(OCAMLFIND) query stdcompat) - OCAMLCFLAGS := -package stdcompat - OCAMLLDFLAGS := -linkpkg - OCAMLBYTECODELIBS := -package unix,stdcompat - OCAMLBYTECODELIBSNUMPY := -package unix,stdcompat,bigarray - OCAMLNATIVELIBS := -package unix,stdcompat - OCAMLNATIVELIBSNUMPY := -package unix,stdcompat,bigarray else OCAMLC := $(shell \ if ocamlc.opt -version >/dev/null 2>&1; then \ @@ -64,12 +61,41 @@ $(error There is no OCaml compiler available in path) OCAMLDEP := ocamldep OCAMLDOC := ocamldoc STDCOMPAT := . - OCAMLCFLAGS := - OCAMLLDFLAGS := - OCAMLBYTECODELIBS := unix.cma stdcompat.cma - OCAMLBYTECODELIBSNUMPY := unix.cma stdcompat.cma bigarray.cma - OCAMLNATIVELIBS := unix.cmxa stdcompat.cmxa - OCAMLNATIVELIBSNUMPY := unix.cmxa stdcompat.cmxa bigarray.cmxa +endif + +OCAMLVERSION := $(shell $(OCAMLC) -version) +OCAMLVERSION_LIST := $(subst ., ,$(OCAMLVERSION)) +OCAMLVERSION_MAJOR := $(word 1,$(OCAMLVERSION_LIST)) + +LIBRARIES := unix stdcompat + +ifeq ($(OCAMLVERSION_MAJOR),5) + LIBRARIES_NUMPY = $(LIBRARIES) + OCAMLCFLAGS = -I +unix +else + LIBRARIES_NUMPY = $(LIBRARIES) bigarray +endif + +null := +space := $(null) # +comma := , + +ifneq ($(HAVE_OCAMLFIND),no) + OCAMLCFLAGS += -package stdcompat + OCAMLLDFLAGS += -linkpkg + PACKAGES := $(subst $(space),$(comma),$(LIBRARIES)) + PACKAGES_NUMPY := $(subst $(space),$(comma),$(LIBRARIES_NUMPY)) + OCAMLBYTECODELIBS := -package $(PACKAGES) + OCAMLBYTECODELIBSNUMPY := -package $(PACKAGES_NUMPY) + OCAMLNATIVELIBS := -package $(PACKAGES) + OCAMLNATIVELIBSNUMPY := -package $(PACKAGES_NUMPY) +else + OCAMLCFLAGS += -I $(STDCOMPAT) + OCAMLLDFLAGS += -I $(STDCOMPAT) + OCAMLBYTECODELIBS := $(LIBRARIES:=.cma) + OCAMLBYTECODELIBSNUMPY := $(LIBRARIES_NUMPY:=.cma) + OCAMLNATIVELIBS := $(LIBRARIES:=.cmxa) + OCAMLNATIVELIBSNUMPY := $(LIBRARIES_NUMPY:=.cmxa) endif ifeq ($(wildcard $(STDCOMPAT)/stdcompat.cma),) @@ -119,24 +145,14 @@ OCAMLLIBNUMPYFLAGS := -cclib "-L. -lnumpy_stubs" OCAMLLIBFLAGSNATIVE := $(OCAMLLIBFLAGS) OCAMLLIBFLAGSBYTECODE := -custom $(OCAMLLIBFLAGS) -UNAME_ARCH := $(shell uname) - -ifeq ($(UNAME_ARCH),Darwin) - PYML_ARCH := pyml_arch_darwin.ml -else ifeq ($(findstring CYGWIN,$(UNAME_ARCH)),CYGWIN) - PYML_ARCH := pyml_arch_cygwin.ml -else - PYML_ARCH := pyml_arch_unix.ml -endif - INSTALL_FILES := \ py.mli numpy.mli $(MODULES:=.cmi) $(MODULES:=.cmx) \ numpy.cmi \ - pyml.cma pyml.cmxa pyml.cmxs pyml.a \ - numpy.cma numpy.cmxa numpy.cmxs numpy.a \ + pyml.cma pyml.cmxa pyml.cmxs pyml$(EXT_LIB) \ + numpy.cma numpy.cmxa numpy.cmxs numpy$(EXT_LIB) \ $(MODULES:=.cmx) numpy.cmx \ - libpyml_stubs.a dllpyml_stubs.so \ - libnumpy_stubs.a dllnumpy_stubs.so \ + libpyml_stubs$(EXT_LIB) dllpyml_stubs.so \ + libnumpy_stubs$(EXT_LIB) dllnumpy_stubs.so \ META .PHONY : all @@ -218,15 +234,15 @@ uninstall : clean : for module in $(MODULES) numpy generate pyml_tests_common pyml_tests \ numpy_tests; do \ - rm -f $$module.cmi $$module.cmo $$module.cmx $$module.a \ + rm -f $$module.cmi $$module.cmo $$module.cmx $$module$(EXT_LIB) \ $$module.o; \ done - rm -f pyml.cma pyml.cmxa pyml.cmxs pyml.a - rm -f numpy.cma numpy.cmxa numpy.cmxs numpy.a + rm -f pyml.cma pyml.cmxa pyml.cmxs pyml$(EXT_LIB) + rm -f numpy.cma numpy.cmxa numpy.cmxs numpy$(EXT_LIB) rm -f pywrappers.mli pywrappers.ml pyml_dlsyms.inc pyml_wrappers.inc rm -f pyml.h - rm -f pyml_stubs.o dllpyml_stubs.so libpyml_stubs.a - rm -f numpy_stubs.o dllnumpy_stubs.so libnumpy_stubs.a + rm -f pyml_stubs.o dllpyml_stubs.so libpyml_stubs$(EXT_LIB) + rm -f numpy_stubs.o dllnumpy_stubs.so libnumpy_stubs$(EXT_LIB) rm -f pyml_arch.ml rm -f generate pyml_tests.native pyml_tests.bytecode rm -f numpy_tests.native numpy_tests.bytecode @@ -234,6 +250,7 @@ clean : rm -rf doc rm -f pymltop pytop.cmo pymlutop pyutop.cmo rm -f pymltop_libdir.ml pymltop_libdir.cmo + rm -f pyops.mli pyops.ml .PHONY : tarball tarball : @@ -268,7 +285,7 @@ pywrappers.ml pyml_wrappers.inc : generate pyml_wrappers.inc : pywrappers.ml pywrappers.mli : pywrappers.ml pytypes.cmi pyml_arch.cmi - $(OCAMLC) -i $< >$@ + $(OCAMLC) $(OCAMLCFLAGS) -i $< >$@ pyml_tests.native : py.cmi pyml.cmxa pyml_tests_common.cmx pyml_tests.cmx $(OCAMLOPT) $(OCAMLLDFLAGS) $(OCAMLNATIVELIBS) pyml.cmxa \ @@ -289,8 +306,8 @@ numpy_tests.bytecode : py.cmi pyml.cma numpy.cma \ $(OCAMLC) $(OCAMLLDFLAGS) $(OCAMLBYTECODELIBSNUMPY) pyml.cma \ numpy.cma pyml_tests_common.cmo numpy_tests.cmo -o $@ -pyml_arch.ml : $(PYML_ARCH) - cp $< $@ +pyml_arch.ml : pyml_arch.ml.c + $(C_COMPILER) -E $< | sed '/^#/d' >$@ pyml_arch.cmo pyml_arch.cmx : pyml_arch.cmi @@ -304,29 +321,29 @@ pyml_arch.cmo pyml_arch.cmx : pyml_arch.cmi $(OCAMLOPT) $(OCAMLCFLAGS) -c $< -o $@ %.o : %.c - $(OCAMLC) -package stdcompat -c $< -o $@ + $(OCAMLC) $(OCAMLCFLAGS) -c $< -o $@ pyml_stubs.o : pyml_wrappers.inc -pyml.cma : $(MODULES:=.cmo) libpyml_stubs.a +pyml.cma : $(MODULES:=.cmo) libpyml_stubs$(EXT_LIB) $(OCAMLC) $(OCAMLLIBFLAGSBYTECODE) -a -dllib -lpyml_stubs $(MODULES:=.cmo) -o $@ -pyml.cmxa : $(MODULES:=.cmx) libpyml_stubs.a +pyml.cmxa : $(MODULES:=.cmx) libpyml_stubs$(EXT_LIB) $(OCAMLOPT) $(OCAMLLIBFLAGSNATIVE) -a $(MODULES:=.cmx) -o $@ -pyml.cmxs : $(MODULES:=.cmx) libpyml_stubs.a +pyml.cmxs : $(MODULES:=.cmx) libpyml_stubs$(EXT_LIB) $(OCAMLOPT) $(OCAMLLIBFLAGSNATIVE) -shared $(MODULES:=.cmx) -o $@ -lib%.a : %.o +lib%$(EXT_LIB) : %.o $(OCAMLMKLIB) -o $(basename $<) $< -numpy.cma : numpy.cmo libnumpy_stubs.a +numpy.cma : numpy.cmo libnumpy_stubs$(EXT_LIB) $(OCAMLC) $(OCAMLLIBNUMPYFLAGS) -a -dllib -lnumpy_stubs numpy.cmo -o $@ -numpy.cmxa : numpy.cmx libnumpy_stubs.a +numpy.cmxa : numpy.cmx libnumpy_stubs$(EXT_LIB) $(OCAMLOPT) $(OCAMLLIBNUMPYFLAGS) -a numpy.cmx -o $@ -numpy.cmxs : numpy.cmx libnumpy_stubs.a +numpy.cmxs : numpy.cmx libnumpy_stubs$(EXT_LIB) $(OCAMLOPT) $(OCAMLLIBNUMPYFLAGS) -shared numpy.cmx -o $@ pytop.cmo : pytop.ml pymltop_libdir.cmi @@ -356,3 +373,9 @@ endif # $(OCAMLMKTOP) -o $@ -thread -linkpkg -package utop -dontlink compiler-libs $^ ocamlfind ocamlc -thread -linkpkg -linkall -predicates create_toploop \ -package compiler-libs.toplevel,utop,stdcompat $^ -o $@ + +pyops.ml: pyops.ml.new + cp $< $@ + +pyops.mli: pyops.mli.new + cp $< $@ diff --git a/bundles/pyml/pyml-current/README.md b/bundles/pyml/pyml-current/README.md index 919aa0afe..0516f7362 100644 --- a/bundles/pyml/pyml-current/README.md +++ b/bundles/pyml/pyml-current/README.md @@ -11,7 +11,7 @@ The Python library is linked at runtime and the same executable can be run in a Python 2 or a Python 3 environment. ``py.ml`` does not require any Python library at compile time. The only compile time dependency is -[https://github.com/thierry-martinez/stdcompat/](``Stdcompat``) to ensure compatibility +[``Stdcompat``](https://github.com/thierry-martinez/stdcompat) to ensure compatibility with all OCaml compiler versions from 3.12. Bindings are split in three modules: @@ -142,12 +142,15 @@ When an OCaml function ``f`` is called from Python where ``type`` belongs to the enumeration ``Py.Err.t`` and ``msg`` is an OCaml string. If ``f`` raises an exception that is neither -of the form ``Py.E`` nor ``Py.Err``, then the Python interpreter is interrupted, -and the exception is raised back in OCaml. +of the form ``Py.E`` nor ``Py.Err``, then +this exception is encapsulated with its backtrace in a Python exception +(of class `ocaml exception` derived from `BaseException` and not from +`Exception`, so as not to be caught), leading the Python interpreter to +be interrupted, and the exception is raised back in OCaml. -``Py.Run.simple_string`` catches all Python exceptions and returns a single -Boolean to indicate success. One can prefer ``Py.Run.eval`` to get proper -error handling. +``Py.Run.simple_string`` catches all Python exceptions (and OCaml +exceptions as well) and returns a single Boolean to indicate +success. One can prefer ``Py.Run.eval`` to get proper error handling. Data types ---------- @@ -327,4 +330,4 @@ from test import callback import numpy callback(numpy.array([0,1,2,3])) ") -``` \ No newline at end of file +``` diff --git a/bundles/pyml/pyml-current/dune b/bundles/pyml/pyml-current/dune index d23304744..e1c3e8dde 100644 --- a/bundles/pyml/pyml-current/dune +++ b/bundles/pyml/pyml-current/dune @@ -1,20 +1,14 @@ (library - (name pyml) - (modules numpy py pycaml pyml_arch pytypes pywrappers) - (c_names numpy_stubs pyml_stubs) + (public_name pyml) + (modules numpy py pyops pycaml pyml_arch pytypes pywrappers pyutils) + (foreign_stubs (language c) (names numpy_stubs pyml_stubs)) (wrapped false) - (libraries bigarray stdcompat pyutils)) + (libraries unix bigarray stdcompat)) (executables (names generate) (modules generate) - (libraries stdcompat pyutils)) - -(library - (name pyutils) - (modules pyutils) - (wrapped false) - (libraries stdcompat unix)) + (libraries stdcompat)) (rule (targets pywrappers.ml pyml.h pyml_dlsyms.inc pyml_wrappers.inc) @@ -22,22 +16,52 @@ (action (run %{gen}))) (rule - (targets pyml_arch.ml) - (deps (:pyml_arch pyml_arch_%{ocaml-config:system}.ml)) - (action (copy %{pyml_arch} pyml_arch.ml))) + (target pyml_arch.ml.sharp) + (deps pyml_arch.ml.c) + (action (with-stdout-to %{target} + (run %{ocaml-config:native_c_compiler} -E %{deps})))) + +(rule + (target pyml_arch.ml) + (deps pyml_arch.ml.sharp) + (action (with-stdout-to %{target} + (run sed "/^#/d" %{deps})))) (library (name pyml_tests_common) (modules pyml_tests_common) - (wrapped false) (libraries pyml stdcompat)) (test (name numpy_tests) (modules numpy_tests) - (libraries pyml pyml_tests_common stdcompat pyutils)) + (libraries pyml pyml_tests_common stdcompat)) (test (name pyml_tests) (modules pyml_tests) - (libraries pyml pyml_tests_common stdcompat pyutils)) + (libraries pyml pyml_tests_common stdcompat)) + +(rule + (enabled_if (>= %{ocaml_version} 4.06)) + (target pyops.mli) + (deps pyops.mli.new) + (action (copy %{deps} %{target}))) + +(rule + (enabled_if (>= %{ocaml_version} 4.06)) + (target pyops.ml) + (deps pyops.ml.new) + (action (copy %{deps} %{target}))) + +(rule + (enabled_if (< %{ocaml_version} 4.06)) + (target pyops.mli) + (deps pyops.mli.405) + (action (copy %{deps} %{target}))) + +(rule + (enabled_if (< %{ocaml_version} 4.06)) + (target pyops.ml) + (deps pyops.ml.405) + (action (copy %{deps} %{target}))) diff --git a/bundles/pyml/pyml-current/dune-project b/bundles/pyml/pyml-current/dune-project index a26d6e273..2a9ea707b 100644 --- a/bundles/pyml/pyml-current/dune-project +++ b/bundles/pyml/pyml-current/dune-project @@ -1 +1,31 @@ -(lang dune 1.6) +(lang dune 2.8) + +(name pyml) + +(license BSD-2-Clause) + +(maintainers "Thierry Martinez ") + +(authors "Thierry Martinez ") + +(source + (github thierry-martinez/pyml)) + +(bug_reports "http://github.com/thierry-martinez/pyml/issues") + +(homepage "http://github.com/thierry-martinez/pyml") + +(documentation "http://github.com/thierry-martinez/pyml") + +(generate_opam_files true) + +(package + (name pyml) + (synopsis "OCaml bindings for Python") + (description "OCaml bindings for Python 2 and Python 3") + (depends + (ocaml (>= 3.12.1)) + (ocamlfind :build) + (stdcompat (>= 18)) + (conf-python-3-dev :with-test)) + (depopts utop)) diff --git a/bundles/pyml/pyml-current/generate.ml b/bundles/pyml/pyml-current/generate.ml index 5b4f1566e..d3743aef1 100644 --- a/bundles/pyml/pyml-current/generate.ml +++ b/bundles/pyml/pyml-current/generate.ml @@ -143,14 +143,18 @@ let wrappers = arguments = Fun []; result = Unit; optional = false; }; - { symbol = "PyErr_Restore"; - arguments = Fun [PyObject false; PyObject false; PyObject false]; - result = Unit; - optional = false; }; { symbol = "PyErr_PrintEx"; arguments = Fun [Int]; result = Unit; optional = false; }; + { symbol = "PyErr_SetInterrupt"; + arguments = Fun []; + result = Unit; + optional = false; }; + { symbol = "PyErr_SetInterruptEx"; + arguments = Fun [Int]; + result = Unit; + optional = true; }; (* since 3.10 *) { symbol = "PyErr_SetNone"; arguments = Fun [PyObject false]; result = Unit; @@ -215,6 +219,10 @@ let wrappers = arguments = Deref; result = PyObject false; optional = false; }; + { symbol = "PyExc_EncodingWarning"; + arguments = Deref; + result = PyObject false; + optional = true; }; (* Added in python 3.10 *) { symbol = "PyExc_EOFError"; arguments = Deref; result = PyObject false; @@ -255,6 +263,10 @@ let wrappers = arguments = Deref; result = PyObject false; optional = false; }; + { symbol = "PyExc_ResourceWarning"; + arguments = Deref; + result = PyObject false; + optional = true; }; (* Added in python 3.2 *) { symbol = "PyExc_RuntimeError"; arguments = Deref; result = PyObject false; @@ -510,7 +522,7 @@ let wrappers = optional = false; }; { symbol = "PyMarshal_WriteObjectToFile"; arguments = Fun [PyObject false; FileOut true; Int]; - result = Int; + result = Unit; optional = false; }; { symbol = "PyMarshal_WriteObjectToString"; arguments = Fun [PyObject false; Int]; @@ -696,6 +708,10 @@ let wrappers = arguments = Fun [PyObject false; String]; result = Int; optional = false; }; + { symbol = "PyObject_Dir"; + arguments = Fun [PyObject false]; + result = PyObject true; + optional = false; }; { symbol = "PyObject_GetAttr"; arguments = Fun [PyObject false; PyObject false]; result = PyObject true; @@ -915,7 +931,7 @@ let wrappers = optional = false; }; { symbol = "PySet_Clear"; arguments = Fun [PyObject false]; - result = Unit; + result = Int; optional = false; }; { symbol = "PySet_Discard"; arguments = Fun [PyObject false; PyObject false]; @@ -1576,7 +1592,7 @@ let coercion_of_c ty = | WideString -> Printf.sprintf " CAMLreturn(pyml_wrap_wide_string(result));" | Int | Long | Size | Compare -> Printf.sprintf " CAMLreturn(Val_int(result));" - | Int64 -> Printf.sprintf " CAMLreturn(copy_int64(result));" + | Int64 -> Printf.sprintf " CAMLreturn(caml_copy_int64(result));" | IntPtr -> Printf.sprintf " CAMLreturn(pyml_wrap_intref(result));" | PyCompilerFlags -> Printf.sprintf " CAMLreturn(pyml_wrap_compilerflags(result));" diff --git a/bundles/pyml/pyml-current/numpy.ml b/bundles/pyml/pyml-current/numpy.ml index 2f61b9a60..dccfaafdf 100644 --- a/bundles/pyml/pyml-current/numpy.ml +++ b/bundles/pyml/pyml-current/numpy.ml @@ -69,13 +69,45 @@ let string_of_layout layout = "unknown layout" let to_bigarray kind layout t = + if not (Py.Object.is_instance t (Py.Array.pyarray_type ())) then + invalid_arg "Numpy.to_bigarray"; let kind', layout', array = bigarray_of_pyarray (Py.Array.numpy_api ()) t in if kind <> kind' then - failwith (Printf.sprintf - "Numpy array has elements of kind %s, but to_bigarray expected %s" + invalid_arg (Printf.sprintf + "Numpy.to_bigarray: Numpy array has elements of kind %s, but to_bigarray expected %s" (string_of_kind kind') (string_of_kind kind)); if layout <> layout' then - failwith (Printf.sprintf - "Numpy array has %s layout, but to_bigarray expected %s" + invalid_arg (Printf.sprintf + "Numpy.to_bigarray: Numpy array has %s layout, but to_bigarray expected %s" (string_of_layout layout') (string_of_layout layout)); array + +type ('a, 'b, 'c) to_bigarray = + { kind : ('a, 'b) Bigarray.kind + ; layout : 'c Bigarray.layout + ; array : ('a, 'b, 'c) Bigarray.Genarray.t + } + +type 'r to_bigarray_k = + { f : 'a 'b 'c . ('a, 'b, 'c) to_bigarray -> 'r } + +let to_bigarray_k (k : 'r to_bigarray_k) t : 'r = + if not (Py.Object.is_instance t (Py.Array.pyarray_type ())) then + invalid_arg "Numpy.to_bigarray"; + let kind, layout, array = bigarray_of_pyarray (Py.Array.numpy_api ()) t in + k.f { kind; layout; array } + +external compare_kind : + ('a, 'b) Bigarray.kind -> ('c, 'd) Bigarray.kind -> int = "%compare" + +external compare_layout : + 'a Bigarray.layout -> 'b Bigarray.layout -> int = "%compare" + +let check_kind_and_layout (kind : ('a, 'b) Bigarray.kind) + (layout : 'c Bigarray.layout) t : + ('a, 'b, 'c) Bigarray.Genarray.t option = + if compare_kind kind (Bigarray.Genarray.kind t) = 0 && + compare_layout layout (Bigarray.Genarray.layout t) = 0 then + Some (Obj.magic t) + else + None diff --git a/bundles/pyml/pyml-current/numpy.mli b/bundles/pyml/pyml-current/numpy.mli index f6f75cc6a..f2db1f287 100644 --- a/bundles/pyml/pyml-current/numpy.mli +++ b/bundles/pyml/pyml-current/numpy.mli @@ -31,4 +31,41 @@ val to_bigarray: ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> Py.Object.t -> ('a, 'b, 'c) Bigarray.Genarray.t (** [to_bigarray kind layout a] returns a bigarray that shares the same - contents than the Numpy array [a]. *) + contents than the Numpy array [a]. + If `kind` and/or `layout` are unknown, you may use {!val:to_bigarray_k}. *) + +type ('a, 'b, 'c) to_bigarray = + { kind : ('a, 'b) Bigarray.kind + ; layout : 'c Bigarray.layout + ; array : ('a, 'b, 'c) Bigarray.Genarray.t + } + +type 'r to_bigarray_k = + { f : 'a 'b 'c . ('a, 'b, 'c) to_bigarray -> 'r } + +val to_bigarray_k : 'r to_bigarray_k -> Py.Object.t -> 'r +(** [to_bigarray_k k a] calls [k.f] with the contents of the Numpy array [a]. + [k.f] has to be polymorphic in the kind and the layout of the bigarray: + functions {!val:compare_kind}, {!val:compare_layout} and + {!val:check_kind_and_layout} can be used to introspect the bigarray + polymorphically. *) + +val compare_kind : ('a, 'b) Bigarray.kind -> ('c, 'd) Bigarray.kind -> int +(** [compare_kind] provides a total order on {!val:Bigarray.kind}. + As opposed to generic [compare] of OCaml standard libary, + [compare_kind] is polymorphic in the kind of the bigarray. *) + +val compare_layout : 'a Bigarray.layout -> 'b Bigarray.layout -> int +(** [compare_layout] provides a total order on {!val:Bigarray.layout}. + As opposed to generic [compare] of OCaml standard libary, + [compare_kind] is polymorphic in the layout of the bigarray. *) + +val check_kind_and_layout : + ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> + ('d, 'e, 'f) Bigarray.Genarray.t -> + ('a, 'b, 'c) Bigarray.Genarray.t option +(** [check_kind_and_layout kind layout a] returns [Some a] if [a] has the given + [kind] and [layout] (that is to say, if we have the following type + equalities, ['a = 'd], ['b = 'e] and ['c = 'f]). + This function allows the callback of {!val:to_bigarray_k} to be polymorphic + in the kind of the array. *) diff --git a/bundles/pyml/pyml-current/numpy_stubs.c b/bundles/pyml/pyml-current/numpy_stubs.c index 02d2eb23b..2c75bb8ab 100644 --- a/bundles/pyml/pyml-current/numpy_stubs.c +++ b/bundles/pyml/pyml-current/numpy_stubs.c @@ -6,6 +6,17 @@ #include #include "pyml_stubs.h" +value +pyml_wrap(PyObject *object, bool steal); + +PyObject * +pyml_unwrap(value v); + +struct numpy_custom_operations { + struct custom_operations ops; + PyObject *obj; +}; + static void numpy_finalize(value v) { struct numpy_custom_operations *ops = @@ -33,7 +44,7 @@ pyarray_of_bigarray_wrapper( } int type_num; intnat flags = Caml_ba_array_val(bigarray_ocaml)->flags; - switch (flags & BIGARRAY_KIND_MASK) { + switch (flags & CAML_BA_KIND_MASK) { case CAML_BA_FLOAT32: type_num = NPY_FLOAT; break; @@ -59,7 +70,7 @@ pyarray_of_bigarray_wrapper( type_num = NPY_LONGLONG; break; case CAML_BA_CAML_INT: - failwith("Caml integers are unsupported for NumPy array"); + caml_failwith("Caml integers are unsupported for NumPy array"); break; case CAML_BA_NATIVE_INT: type_num = NPY_LONG; @@ -76,7 +87,7 @@ pyarray_of_bigarray_wrapper( break; #endif default: - failwith("Unsupported bigarray kind for NumPy array"); + caml_failwith("Unsupported bigarray kind for NumPy array"); } int np_flags; switch (flags & CAML_BA_LAYOUT_MASK) { @@ -87,7 +98,7 @@ pyarray_of_bigarray_wrapper( np_flags = NPY_ARRAY_FARRAY; break; default: - failwith("Unsupported bigarray layout for NumPy array"); + caml_failwith("Unsupported bigarray layout for NumPy array"); } void *data = Caml_ba_data_val(bigarray_ocaml); PyTypeObject (*PyArray_SubType) = @@ -111,7 +122,7 @@ bigarray_of_pyarray_wrapper( (PyArrayObject_fields *) pyobjectdescr(array); int nd = fields->nd; npy_intp *shape = fields->dimensions; - long *dims = malloc(nd * sizeof(long)); + intnat *dims = malloc(nd * sizeof(intnat)); int i; for (i = 0; i < nd; i++) { dims[i] = shape[i]; @@ -160,7 +171,7 @@ bigarray_of_pyarray_wrapper( #endif break; default: - failwith("Unsupported NumPy kind for bigarray"); + caml_failwith("Unsupported NumPy kind for bigarray"); } int flags = fields->flags; enum caml_ba_layout layout; @@ -171,13 +182,13 @@ bigarray_of_pyarray_wrapper( layout = CAML_BA_FORTRAN_LAYOUT; } else { - failwith("Unsupported NumPy layout for bigarray"); + caml_failwith("Unsupported NumPy layout for bigarray"); } void *data = fields->data; bigarray = caml_ba_alloc(kind | layout, nd, data, dims); free(dims); Py_INCREF(array); - struct custom_operations *oldops = Custom_ops_val(bigarray); + const struct custom_operations *oldops = Custom_ops_val(bigarray); struct numpy_custom_operations *newops = (struct numpy_custom_operations *) malloc(sizeof(struct numpy_custom_operations)); newops->ops.identifier = oldops->identifier; diff --git a/bundles/pyml/pyml-current/numpy_tests.ml b/bundles/pyml/pyml-current/numpy_tests.ml index 023056236..4bd671e29 100644 --- a/bundles/pyml/pyml-current/numpy_tests.ml +++ b/bundles/pyml/pyml-current/numpy_tests.ml @@ -25,6 +25,37 @@ array[1] = 43. Pyml_tests_common.Passed end) +let () = + Pyml_tests_common.add_test ~title:"of_bigarray2" + (fun () -> + if Py.Import.try_import_module "numpy" = None then + Pyml_tests_common.Disabled "numpy is not available" + else + begin + let array = [| [| 1.; 2.; 3. |]; [| -1.23; Stdcompat.Float.nan; 2.72 |] |] in + let array2 = + Bigarray.Array2.of_array (Bigarray.float64) (Bigarray.c_layout) array in + let bigarray = Bigarray.genarray_of_array2 array2 in + let a = Numpy.of_bigarray bigarray in + let m = Py.Import.add_module "test" in + Py.Module.set m "array" a; + assert (Py.Run.simple_string " +from test import array +import numpy + +assert list(array.shape) == [2, 3] +numpy.testing.assert_almost_equal(array[0], [1, 2, 3]) +assert(numpy.isnan(array[1, 1])) +array[0, 0] = 42. +array[0, 1] = 43. +array[1, 1] = 1. +"); + assert (Bigarray.Array2.get array2 0 0 = 42.); + assert (Bigarray.Array2.get array2 0 1 = 43.); + assert (Bigarray.Array2.get array2 1 1 = 1.); + Pyml_tests_common.Passed + end) + let () = Pyml_tests_common.add_test ~title:"to_bigarray" (fun () -> @@ -36,6 +67,7 @@ let () = let callback arg = let bigarray = Numpy.to_bigarray Bigarray.nativeint Bigarray.c_layout arg.(0) in + assert (Bigarray.Genarray.dims bigarray = [| 4 |]); let array1 = Bigarray.array1_of_genarray bigarray in assert (Bigarray.Array1.get array1 0 = 0n); assert (Bigarray.Array1.get array1 1 = 1n); @@ -51,6 +83,108 @@ callback(numpy.array([0,1,2,3])) Pyml_tests_common.Passed end) +let assert_almost_eq ?(eps = 1e-7) f1 f2 = + if Stdcompat.Float.abs (f1 -. f2) > eps then + failwith (Printf.sprintf "%f <> %f" f1 f2) + +let () = + Pyml_tests_common.add_test ~title:"to_bigarray2" + (fun () -> + if Py.Import.try_import_module "numpy" = None then + Pyml_tests_common.Disabled "numpy is not available" + else + begin + let m = Py.Import.add_module "test" in + let callback arg = + let bigarray = + Numpy.to_bigarray Bigarray.float32 Bigarray.c_layout arg.(0) in + assert (Bigarray.Genarray.dims bigarray = [| 2; 4 |]); + let array2 = Bigarray.array2_of_genarray bigarray in + let assert_almost_eq i j v = + assert_almost_eq (Bigarray.Array2.get array2 i j) v in + let assert_is_nan i j = + let v = Bigarray.Array2.get array2 i j in + assert (Stdcompat.Float.is_nan v) in + assert_almost_eq 0 0 0.12; + assert_almost_eq 0 1 1.23; + assert_almost_eq 0 2 2.34; + assert_almost_eq 0 3 3.45; + assert_almost_eq 1 0 (-1.); + assert_is_nan 1 1; + assert_almost_eq 1 2 1.; + assert_almost_eq 1 3 0.; + Py.none in + Py.Module.set m "callback" (Py.Callable.of_function callback); + assert (Py.Run.simple_string " +from test import callback +import numpy +callback(numpy.array([[0.12,1.23,2.34,3.45],[-1.,numpy.nan,1.,0.]], dtype=numpy.float32)) +"); + Pyml_tests_common.Passed + end) + +let assert_invalid_argument f = + try + let () = f () in + assert false + with Invalid_argument _ -> + () + +let () = + Pyml_tests_common.add_test ~title:"to_bigarray invalid type" + (fun () -> + if Py.Import.try_import_module "numpy" = None then + Pyml_tests_common.Disabled "numpy is not available" + else + begin + assert_invalid_argument (fun () -> + ignore (Numpy.to_bigarray Float64 C_layout Py.none)); + assert_invalid_argument (fun () -> + ignore (Numpy.to_bigarray Float64 C_layout (Py.Int.of_int 0))); + let array = + Numpy.of_bigarray (Bigarray.genarray_of_array1 ( + Bigarray.Array1.of_array (Bigarray.float64) (Bigarray.c_layout) + [| 1.; 2. |])) in + ignore (Numpy.to_bigarray Float64 C_layout array); + assert_invalid_argument (fun () -> + ignore (Numpy.to_bigarray Float32 C_layout array)); + assert_invalid_argument (fun () -> + ignore (Numpy.to_bigarray Float64 Fortran_layout array)); + Pyml_tests_common.Passed + end) + +let () = + Pyml_tests_common.add_test ~title:"to_bigarray_k" + (fun () -> + if Py.Import.try_import_module "numpy" = None then + Pyml_tests_common.Disabled "numpy is not available" + else + begin + let m = Py.Import.add_module "test" in + let callback arg = + let k { Numpy.kind; layout; array } = + assert (Numpy.compare_kind kind Bigarray.nativeint = 0); + assert (Numpy.compare_layout layout Bigarray.c_layout = 0); + let bigarray = + Stdcompat.Option.get (Numpy.check_kind_and_layout + Bigarray.nativeint Bigarray.c_layout array) in + assert (Bigarray.Genarray.dims bigarray = [| 4 |]); + let array1 = Bigarray.array1_of_genarray bigarray in + assert (Bigarray.Array1.get array1 0 = 0n); + assert (Bigarray.Array1.get array1 1 = 1n); + assert (Bigarray.Array1.get array1 2 = 2n); + assert (Bigarray.Array1.get array1 3 = 3n) in + Numpy.to_bigarray_k { Numpy.f = k } arg.(0); + Py.none in + Py.Module.set m "callback" (Py.Callable.of_function callback); + assert (Py.Run.simple_string " +from test import callback +import numpy +callback(numpy.array([0,1,2,3])) +"); + Pyml_tests_common.Passed + end) + let () = if not !Sys.interactive then Pyml_tests_common.main () diff --git a/bundles/pyml/pyml-current/py.ml b/bundles/pyml/pyml-current/py.ml index 79c7e5afb..a33e33075 100644 --- a/bundles/pyml/pyml-current/py.ml +++ b/bundles/pyml/pyml-current/py.ml @@ -7,6 +7,12 @@ type pyobject = Pytypes.pyobject type input = Pytypes.input = Single | File | Eval +let string_of_input input = + match input with + | File -> "exec" + | Eval -> "eval" + | Single -> "single" + type 'a file = 'a Pytypes.file = Filename of string | Channel of 'a type compare = Pytypes.compare = LT | LE | EQ | NE | GT | GE @@ -34,6 +40,8 @@ external pyobject_callmethodobjargs: pyobject -> pyobject -> pyobject array -> pyobject = "PyObject_CallMethodObjArgs_wrapper" external pyerr_fetch_internal: unit -> pyobject * pyobject * pyobject = "PyErr_Fetch_wrapper" +external pyerr_restore_internal: pyobject -> pyobject -> pyobject -> unit + = "PyErr_Restore_wrapper" external pystring_asstringandsize: pyobject -> string option = "PyString_AsStringAndSize_wrapper" external pyobject_ascharbuffer: pyobject -> string option @@ -48,6 +56,8 @@ external pycapsule_isvalid: Pytypes.pyobject -> string -> int = "Python27_PyCapsule_IsValid_wrapper" external pycapsule_check: Pytypes.pyobject -> int = "pyml_capsule_check" +external pyframe_new : string -> string -> int -> Pytypes.pyobject + = "pyml_pyframe_new" external ucs: unit -> ucs = "py_get_UCS" (* Avoid warning 32. *) @@ -104,9 +114,15 @@ let extract_version version_line = let extract_version_major_minor version = try - if String.length version >= 3 && (version.[1] = '.') then + if String.length version >= 3 && version.[1] = '.' then let major = int_of_string (String.sub version 0 1) in - let minor = int_of_string (String.sub version 2 1) in + let minor = + if String.length version = 3 || version.[3] = '.' then + int_of_string (String.sub version 2 1) + else if String.length version >= 5 && version.[4] = '.' then + int_of_string (String.sub version 2 2) + else + raise Exit in (major, minor) else raise Exit @@ -213,7 +229,7 @@ let libpython_from_interpreter python_full_path = let lines = ldd python_full_path in let is_libpython line = let basename = Filename.basename line in - Pyutils.has_prefix "libpython" basename in + Stdcompat.String.starts_with ~prefix:"libpython" basename in List.find_opt is_libpython lines let libpython_from_ldconfig major minor = @@ -226,7 +242,7 @@ let libpython_from_ldconfig major minor = Printf.sprintf "libpython%d.%d" major' minor' in let is_libpython line = let basename = Filename.basename line in - Pyutils.has_prefix prefix basename in + Stdcompat.String.starts_with ~prefix:prefix basename in List.find_opt is_libpython lines let parse_python_list list = @@ -350,6 +366,11 @@ let concat_library_filenames library_paths library_filenames = List.map (fun path -> Filename.concat path filename) library_paths in List.concat (List.map expand_filepaths library_filenames) +let library_suffix = + match Pyml_arch.os with + | Pyml_arch.Mac -> ".dylib" + | _ -> ".so" + let libpython_from_pkg_config version_major version_minor = let command = Printf.sprintf "pkg-config --libs python-%d.%d" version_major @@ -375,7 +396,7 @@ let libpython_from_pkg_config version_major version_minor = if library_filename <> None then unable_to_parse (); let library_filename = - Printf.sprintf "lib%s%s" word' Pyml_arch.library_suffix in + Printf.sprintf "lib%s%s" word' library_suffix in (library_paths, Some library_filename) | _ -> (library_paths, library_filename) else (library_paths, library_filename) in @@ -388,6 +409,41 @@ let libpython_from_pkg_config version_major version_minor = Some (concat_library_filenames library_paths [library_filename]) | _ -> None +let library_patterns : (int -> int -> string) list = + match Pyml_arch.os with + | Pyml_arch.Windows -> + [Printf.sprintf "python%d%dm.dll"; Printf.sprintf "python%d%d.dll"] + | Pyml_arch.Mac -> + [Printf.sprintf "libpython%d.%dm.dylib"; + Printf.sprintf "libpython%d.%d.dylib"] + | Pyml_arch.Unix -> + [Printf.sprintf "libpython%d.%dm.so"; + Printf.sprintf "libpython%d.%d.so"] + +let libpython_from_python_config version_major version_minor = + let command = + Printf.sprintf "python%d.%d-config --ldflags" version_major version_minor in + match run_command_opt command false with + | Some (words :: _) -> + let word_list = String.split_on_char ' ' words in + let parse_word library_paths word = + if String.length word > 2 then + match String.sub word 0 2 with + "-L" -> + let word' = + Pyutils.substring_between word 2 (String.length word) in + word' :: library_paths + | _ -> library_paths + else library_paths in + let library_paths = + List.fold_left parse_word [] word_list in + let library_filenames = + List.map + (fun format -> format version_major version_minor) + library_patterns in + Some (concat_library_filenames library_paths library_filenames) + | _ -> None + let libpython_from_pythonhome version_major version_minor python_full_path = let library_paths = match @@ -403,27 +459,35 @@ let libpython_from_pythonhome version_major version_minor python_full_path = [Filename.concat prefix "lib"] in let library_filenames = List.map - (fun format -> Printf.sprintf format version_major version_minor) - Pyml_arch.library_patterns in + (fun format -> format version_major version_minor) + library_patterns in concat_library_filenames library_paths library_filenames let find_library_path version_major version_minor python_full_path = - match Option.bind python_full_path libpython_from_interpreter with - Some path -> [path] - | None -> - match libpython_from_ldconfig version_major version_minor with - Some path -> [path] - | None -> - match version_major, version_minor with - Some version_major, Some version_minor -> - begin - match libpython_from_pkg_config version_major version_minor with - Some paths -> paths - | None -> - libpython_from_pythonhome version_major version_minor - python_full_path - end - | _ -> failwith "Cannot infer Python version" + let heuristics = [ + (fun () -> + Option.bind python_full_path (fun path -> + Option.map (fun path -> [path]) (libpython_from_interpreter path))); + (fun () -> + Option.map (fun path -> [path]) + (libpython_from_ldconfig version_major version_minor)); + (fun () -> + Option.bind version_major (fun version_major -> + Option.bind version_minor (fun version_minor -> + libpython_from_pkg_config version_major version_minor))); + (fun () -> + Option.bind version_major (fun version_major -> + Option.bind version_minor (fun version_minor -> + libpython_from_python_config version_major version_minor))); + (fun () -> + Option.bind version_major (fun version_major -> + Option.bind version_minor (fun version_minor -> + Some (libpython_from_pythonhome version_major version_minor + python_full_path)))); + ] in + match List.find_map (fun f -> f ()) heuristics with + | None -> failwith "Cannot find Python library" + | Some paths -> paths let python_version_from_interpreter interpreter = let version_line = @@ -436,14 +500,14 @@ let library_filename = ref None let load_library filename = library_filename := filename; - load_library filename + load_library filename None let get_library_filename () = !library_filename -let find_library ~verbose ~version_major ~version_minor ~debug_build +let find_library ~verbose ~version_major ~version_minor ~debug_build:_ python_full_path = try - load_library None debug_build + load_library None with Failure _ -> let library_filenames = find_library_path version_major version_minor python_full_path in @@ -469,7 +533,7 @@ let find_library ~verbose ~version_major ~version_minor ~debug_build Printf.eprintf "Trying to load \"%s\".\n" filename; flush stderr; end; - load_library (Some filename) debug_build; + load_library (Some filename); with Failure msg -> (* if pythonhome_set then @@ -517,9 +581,21 @@ let initialize_library ~verbose ~version_major ~version_minor let get_version = Pywrappers.py_getversion +let which_command = + match Pyml_arch.os with + | Pyml_arch.Windows -> "where" + | _ -> "command -v" + let which program = - let exe = Pyml_arch.ensure_executable_suffix program in - let command = Printf.sprintf "%s \"%s\"" Pyml_arch.which exe in + let exe = + match Pyml_arch.os with + | Pyml_arch.Windows -> + if Filename.check_suffix program ".exe" then + program + else + program ^ ".exe" + | _ -> program in + let command = Printf.sprintf "%s \"%s\"" which_command exe in match run_command_opt command false with Some (path :: _) -> Some path | _ -> None @@ -560,79 +636,102 @@ let version_mismatch interpreter found expected = let build_version_string major minor = Printf.sprintf "%d.%d" major minor -let initialize ?library_name ?interpreter ?version ?minor ?(verbose = false) - ?debug_build () = +let path_separator = + match Pyml_arch.os with + | Pyml_arch.Windows -> ";" + | _ -> ":" + +(* Preserve signal behavior for sigint (Ctrl+C) + (Reported by Arulselvan Madhavan, + see https://github.com/thierry-martinez/pyml/issues/83) + + pythonlib changes the handling of sigint, making programs + uninterruptible when the library is loaded. + + The following function restores sigint handling and `initialize` + uses it except if ~python_sigint:true is passed. + *) + +let keep_sigint f = + let previous_signal_behavior = Sys.signal Sys.sigint Sys.Signal_ignore in + Sys.set_signal Sys.sigint previous_signal_behavior; + Stdcompat.Fun.protect f + ~finally:(fun () -> Sys.set_signal Sys.sigint previous_signal_behavior) + +let initialize ?library_name ?interpreter ?version + ?minor ?(verbose = false) ?debug_build ?(python_sigint = false) () = if !initialized then failwith "Py.initialize: already initialized"; - begin + let do_initialize () = match library_name with | Some library_name -> - load_library (Some library_name) debug_build; + load_library (Some library_name); | None -> - begin - try - let python_full_path = find_interpreter interpreter version minor in - let interpreter_pythonpaths = - match python_full_path with - None -> [] - | Some python_full_path' -> - pythonpaths_from_interpreter python_full_path' in - let new_pythonpaths = - List.rev_append !pythonpaths interpreter_pythonpaths in - if new_pythonpaths <> [] then - begin - let former_pythonpath = Sys.getenv_opt "PYTHONPATH" in - has_set_pythonpath := Some former_pythonpath; - let all_paths = - match former_pythonpath with - None -> new_pythonpaths - | Some former_pythonpath' -> - former_pythonpath' :: new_pythonpaths in - let pythonpath = String.concat Pyml_arch.path_separator all_paths in - if verbose then - begin - Printf.eprintf "Temporary set PYTHONPATH=\"%s\".\n" pythonpath; - flush stderr; - end; - Unix.putenv "PYTHONPATH" pythonpath - end; - let (version_major, version_minor) = - match python_full_path with - Some python_full_path' -> - let version_string = - python_version_from_interpreter python_full_path' in - let (version_major, version_minor) = - extract_version_major_minor version_string in + try + let python_full_path = find_interpreter interpreter version minor in + let interpreter_pythonpaths = + match python_full_path with + None -> [] + | Some python_full_path' -> + pythonpaths_from_interpreter python_full_path' in + let new_pythonpaths = + List.rev_append !pythonpaths interpreter_pythonpaths in + if new_pythonpaths <> [] then begin - match version with - None -> () - | Some version_major' -> - if version_major <> version_major' then - failwith - (version_mismatch - python_full_path' (string_of_int version_major) - (string_of_int version_major')); - match minor with + let former_pythonpath = Sys.getenv_opt "PYTHONPATH" in + has_set_pythonpath := Some former_pythonpath; + let all_paths = + match former_pythonpath with + None -> new_pythonpaths + | Some former_pythonpath' -> + former_pythonpath' :: new_pythonpaths in + let pythonpath = String.concat path_separator all_paths in + if verbose then + begin + Printf.eprintf "Temporary set PYTHONPATH=\"%s\".\n" pythonpath; + flush stderr; + end; + Unix.putenv "PYTHONPATH" pythonpath + end; + let (version_major, version_minor) = + match python_full_path with + Some python_full_path' -> + let version_string = + python_version_from_interpreter python_full_path' in + let (version_major, version_minor) = + extract_version_major_minor version_string in + begin + match version with None -> () - | Some version_minor' -> - if version_minor <> version_minor' then - let expected = - build_version_string version_major version_minor in - let got = - build_version_string version_major' version_minor' in + | Some version_major' -> + if version_major <> version_major' then failwith - (version_mismatch python_full_path' expected got); - end; - (Some version_major, Some version_minor) - | _ -> version, minor in - initialize_library ~verbose ~version_major ~version_minor ~debug_build - python_full_path; - with e -> - uninit_pythonhome (); - uninit_pythonpath (); - raise e - end; - end; + (version_mismatch + python_full_path' (string_of_int version_major) + (string_of_int version_major')); + match minor with + None -> () + | Some version_minor' -> + if version_minor <> version_minor' then + let expected = + build_version_string version_major version_minor in + let got = + build_version_string version_major' version_minor' in + failwith + (version_mismatch python_full_path' expected got); + end; + (Some version_major, Some version_minor) + | _ -> version, minor in + initialize_library ~verbose ~version_major ~version_minor ~debug_build + python_full_path; + with e -> + uninit_pythonhome (); + uninit_pythonpath (); + raise e in + if python_sigint then + do_initialize () + else + keep_sigint do_initialize; let version = get_version () in let (version_major, version_minor) = extract_version_major_minor version in @@ -648,6 +747,7 @@ let on_finalize f = on_finalize_list := f :: !on_finalize_list let finalize () = assert_initialized (); List.iter (fun f -> f ()) !on_finalize_list; + Gc.full_major (); finalize_library (); uninit_pythonhome (); uninit_pythonpath (); @@ -665,6 +765,10 @@ let version_minor () = assert_initialized (); !version_minor_value +let version_pair () = + assert_initialized (); + (!version_major_value, !version_minor_value) + let null = pynull () @@ -681,10 +785,32 @@ exception E of pyobject * pyobject let fetched_exception = ref None +let ocaml_exception_class = ref None + +let ocaml_exception_capsule = ref None + let python_exception () = let ptype, pvalue, ptraceback = pyerr_fetch_internal () in - fetched_exception := Some (ptype, pvalue, ptraceback); - raise (E (ptype, pvalue)) + if + match !ocaml_exception_class with + | None -> false + | Some ocaml_exception_class -> + Lazy.is_val ocaml_exception_class && + Lazy.force ocaml_exception_class = ptype + then + begin + let args = Pywrappers.pyobject_getattrstring pvalue "args" in + assert (args <> null); + let capsule = Pywrappers.pysequence_getitem args 0 in + assert (capsule <> null); + let exc, bt = snd (Option.get !ocaml_exception_capsule) capsule in + Printexc.raise_with_backtrace exc bt + end + else + begin + fetched_exception := Some (ptype, pvalue, ptraceback); + raise (E (ptype, pvalue)) + end let check_not_null result = if result = null then @@ -779,8 +905,14 @@ let option result = else Some result +let assert_not_null function_name obj = + if is_null obj then + invalid_arg (function_name ^ ": unallowed null argument") + module Eval = struct let call_object_with_keywords func arg keyword = + assert_not_null "call_object_with_keywords(!, _, _)" func; + assert_not_null "call_object_with_keywords(_, !, _)" arg; check_not_null (Pywrappers.pyeval_callobjectwithkeywords func arg keyword) let call_object func arg = @@ -797,6 +929,7 @@ let object_repr obj = check_not_null (Pywrappers.pyobject_repr obj) module String_ = struct let as_UTF8_string s = + assert_not_null "as_UTF8_string" s; let f = match ucs () with UCS2 -> Pywrappers.UCS2.pyunicodeucs2_asutf8string @@ -831,7 +964,9 @@ module Tuple_ = struct let init size f = let result = create size in for index = 0 to size - 1 do - set_item result index (f index) + let v = f index in + assert_not_null "init" v; + set_item result index v done; result @@ -847,6 +982,8 @@ module Dict_ = struct check_not_null (Pywrappers.pydict_new ()) let set_item dict key value = + assert_not_null "set_item(!, _)" dict; + assert_not_null "set_item(_, !)" key; assert_int_success (Pywrappers.pydict_setitem dict key value) let of_bindings_map fkey fvalue list = @@ -859,6 +996,10 @@ module Dict_ = struct let of_bindings = of_bindings_map id id let of_bindings_string = of_bindings_map String_.of_string id + + let set_item_string dict name value = + assert_not_null "set_item_string" dict; + assert_int_success (Pywrappers.pydict_setitemstring dict name value) end module Object_ = struct @@ -898,6 +1039,8 @@ module Type = struct external get: pyobject -> t = "pytype" let is_subtype a b = + assert_not_null "of_tuple5(!, _)" a; + assert_not_null "of_tuple5(_, !)" b; bool_of_int (Pywrappers.pytype_issubtype a b) let name t = @@ -947,6 +1090,11 @@ module Type = struct end module Capsule = struct + type 'a t = { + wrap : 'a -> pyobject; + unwrap : pyobject -> 'a; + } + let is_valid v name = pycapsule_isvalid v name <> 0 let check v = is_valid v "ocaml-capsule" @@ -980,7 +1128,14 @@ module Capsule = struct v in (wrap, unwrap) - let type_of x = fst (unsafe_unwrap_value x) + let create name = + let wrap, unwrap = make name in + { wrap; unwrap } + + let type_of x = + if pycapsule_check x = 0 then + Type.mismatch "capsule" x; + fst (unsafe_unwrap_value x) end module Mapping = struct @@ -990,7 +1145,7 @@ module Mapping = struct option (Pywrappers.pymapping_getitemstring mapping key) let find_string mapping key = - Pyutils.option_unwrap (get_item_string mapping key) + Stdcompat.Option.get (get_item_string mapping key) let find_string_opt = get_item_string @@ -1009,11 +1164,18 @@ end module Method = struct let create func self cl = + assert_not_null "create(!, _, _)" func; + assert_not_null "create(_, !, _)" self; + assert_not_null "create(_, _, !)" cl; check_not_null (Pywrappers.pymethod_new func self cl) - let get_function m = check_not_null (Pywrappers.pymethod_function m) + let get_function m = + assert_not_null "get_function" m; + check_not_null (Pywrappers.pymethod_function m) - let self m = option (Pywrappers.pymethod_self m) + let self m = + assert_not_null "self" m; + option (Pywrappers.pymethod_self m) end module Bool = struct @@ -1141,6 +1303,7 @@ module String__ = struct check_not_null (f int_array size') let to_unicode s = + assert_not_null "to_unicode" s; let f = match ucs () with UCS2 -> Pywrappers.UCS2.pyunicodeucs2_asunicode @@ -1275,7 +1438,7 @@ module Err = struct let print_ex i = Pywrappers.pyerr_printex i - let restore = Pywrappers.pyerr_restore + let restore = pyerr_restore_internal let restore_tuple (ptype, pvalue, ptraceback) = restore ptype pvalue ptraceback @@ -1296,41 +1459,49 @@ module Err = struct let set_object = Pywrappers.pyerr_setobject + let of_error = function + Exception -> Pywrappers.pyexc_exception () + | StandardError -> + if !version_major_value <= 2 then + Pywrappers.Python2.pyexc_standarderror () + else + Pywrappers.pyexc_exception () + | ArithmeticError -> Pywrappers.pyexc_arithmeticerror () + | LookupError -> Pywrappers.pyexc_lookuperror () + | AssertionError -> Pywrappers.pyexc_assertionerror () + | AttributeError -> Pywrappers.pyexc_attributeerror () + | EOFError -> Pywrappers.pyexc_eoferror () + | EnvironmentError -> Pywrappers.pyexc_environmenterror () + | FloatingPointError -> Pywrappers.pyexc_floatingpointerror () + | IOError -> Pywrappers.pyexc_ioerror () + | ImportError -> Pywrappers.pyexc_importerror () + | IndexError -> Pywrappers.pyexc_indexerror () + | KeyError -> Pywrappers.pyexc_keyerror () + | KeyboardInterrupt -> Pywrappers.pyexc_keyboardinterrupt () + | MemoryError -> Pywrappers.pyexc_memoryerror () + | NameError -> Pywrappers.pyexc_nameerror () + | NotImplementedError -> Pywrappers.pyexc_notimplementederror () + | OSError -> Pywrappers.pyexc_oserror () + | OverflowError -> Pywrappers.pyexc_overflowerror () + | ReferenceError -> Pywrappers.pyexc_referenceerror () + | RuntimeError -> Pywrappers.pyexc_runtimeerror () + | SyntaxError -> Pywrappers.pyexc_syntaxerror () + | SystemExit -> Pywrappers.pyexc_systemerror () + | TypeError -> Pywrappers.pyexc_typeerror () + | ValueError -> Pywrappers.pyexc_valueerror () + | ZeroDivisionError -> Pywrappers.pyexc_zerodivisionerror () + | StopIteration -> Pywrappers.pyexc_stopiteration () + let set_error error msg = - let exc = - match error with - Exception -> Pywrappers.pyexc_exception () - | StandardError -> - if !version_major_value <= 2 then - Pywrappers.Python2.pyexc_standarderror () - else - Pywrappers.pyexc_exception () - | ArithmeticError -> Pywrappers.pyexc_arithmeticerror () - | LookupError -> Pywrappers.pyexc_lookuperror () - | AssertionError -> Pywrappers.pyexc_assertionerror () - | AttributeError -> Pywrappers.pyexc_attributeerror () - | EOFError -> Pywrappers.pyexc_eoferror () - | EnvironmentError -> Pywrappers.pyexc_environmenterror () - | FloatingPointError -> Pywrappers.pyexc_floatingpointerror () - | IOError -> Pywrappers.pyexc_ioerror () - | ImportError -> Pywrappers.pyexc_importerror () - | IndexError -> Pywrappers.pyexc_indexerror () - | KeyError -> Pywrappers.pyexc_keyerror () - | KeyboardInterrupt -> Pywrappers.pyexc_keyboardinterrupt () - | MemoryError -> Pywrappers.pyexc_memoryerror () - | NameError -> Pywrappers.pyexc_nameerror () - | NotImplementedError -> Pywrappers.pyexc_notimplementederror () - | OSError -> Pywrappers.pyexc_oserror () - | OverflowError -> Pywrappers.pyexc_overflowerror () - | ReferenceError -> Pywrappers.pyexc_referenceerror () - | RuntimeError -> Pywrappers.pyexc_runtimeerror () - | SyntaxError -> Pywrappers.pyexc_syntaxerror () - | SystemExit -> Pywrappers.pyexc_systemerror () - | TypeError -> Pywrappers.pyexc_typeerror () - | ValueError -> Pywrappers.pyexc_valueerror () - | ZeroDivisionError -> Pywrappers.pyexc_zerodivisionerror () - | StopIteration -> Pywrappers.pyexc_stopiteration () in - set_object exc (String.of_string msg) + set_object (of_error error) (String.of_string msg) + + let set_interrupt () = + Pywrappers.pyerr_setinterrupt () + + let set_interrupt_ex signal = + if version_pair () < (3, 10) then + failwith "set_interrupt_ex: only available with Python >= 3.10"; + Pywrappers.pyerr_setinterruptex signal end exception Err of Err.t * string @@ -1341,60 +1512,80 @@ module Object = struct type t = Pytypes.pyobject let del_item obj item = + assert_not_null "del_item(!, _)" obj; + assert_not_null "del_item(_, !)" item; assert_int_success (Pywrappers.pyobject_delitem obj item) let del_item_string obj item = assert_int_success (Pywrappers.pyobject_delitemstring obj item) let get_attr obj attr = + assert_not_null "get_attr(!, _)" obj; + assert_not_null "get_attr(_, !)" attr; option (Pywrappers.pyobject_getattr obj attr) let get_attr_string obj attr = + assert_not_null "get_attr_string" obj; option (Pywrappers.pyobject_getattrstring obj attr) - let find_attr obj attr = Pyutils.option_unwrap (get_attr obj attr) + let find_attr obj attr = Stdcompat.Option.get (get_attr obj attr) let find_attr_opt = get_attr let find_attr_string obj attr = - Pyutils.option_unwrap (get_attr_string obj attr) + Stdcompat.Option.get (get_attr_string obj attr) let find_attr_string_opt = get_attr_string let get_item obj key = option (Pywrappers.pyobject_getitem obj key) - let find obj attr = Pyutils.option_unwrap (get_item obj attr) + let find obj attr = Stdcompat.Option.get (get_item obj attr) let find_opt = get_item let get_item_string obj key = get_item obj (String.of_string key) - let find_string obj attr = Pyutils.option_unwrap (get_item_string obj attr) + let find_string obj attr = Stdcompat.Option.get (get_item_string obj attr) let find_string_opt = get_item_string let get_iter obj = + assert_not_null "get_iter" obj; check_not_null (Pywrappers.pyobject_getiter obj) let get_type obj = + assert_not_null "get_type" obj; check_not_null (Pywrappers.pyobject_type obj) let has_attr obj attr = + assert_not_null "has_attr(!, _)" obj; + assert_not_null "has_attr(_, !)" attr; bool_of_int (Pywrappers.pyobject_hasattr obj attr) let has_attr_string obj attr = + assert_not_null "has_attr_string" obj; bool_of_int (Pywrappers.pyobject_hasattrstring obj attr) - let hash obj = check_int64 (Pywrappers.pyobject_hash obj) + let hash obj = + assert_not_null "hash" obj; + check_int64 (Pywrappers.pyobject_hash obj) - let is_true obj = bool_of_int (Pywrappers.pyobject_istrue obj) + let is_true obj = + assert_not_null "is_true" obj; + bool_of_int (Pywrappers.pyobject_istrue obj) - let not obj = bool_of_int (Pywrappers.pyobject_istrue obj) + let not obj = + assert_not_null "not" obj; + bool_of_int (Pywrappers.pyobject_istrue obj) - let is_instance obj cls = bool_of_int (Pywrappers.pyobject_isinstance obj cls) + let is_instance obj cls = + assert_not_null "is_instance" obj; + bool_of_int (Pywrappers.pyobject_isinstance obj cls) let is_subclass cls1 cls2 = + assert_not_null "is_subclass(!, _)" cls1; + assert_not_null "is_subclass(_, !)" cls2; bool_of_int (Pywrappers.pyobject_issubclass cls1 cls2) let print obj out_channel = @@ -1411,9 +1602,12 @@ module Object = struct bool_of_int (Pywrappers.pyobject_richcomparebool a b cmp) let set_attr obj attr value = + assert_not_null "set_attr(!, _, _)" obj; + assert_not_null "set_attr(_, !, _)" attr; assert_int_success (Pywrappers.pyobject_setattr obj attr value) let set_attr_string obj attr value = + assert_not_null "set_attr_string" obj; assert_int_success (Pywrappers.pyobject_setattrstring obj attr value) let del_attr obj attr = set_attr obj attr null @@ -1462,16 +1656,25 @@ module Object = struct Format.pp_print_string fmt (robust_to_string true v) let call_method_obj_args obj name args = + assert_not_null "call_method_obj_args(!, _, _)" obj; + assert_not_null "call_method_obj_args(_, !, _)" name; check_not_null (pyobject_callmethodobjargs obj name args) let call_method obj name args = call_method_obj_args obj (String.of_string name) args let call callable args kw = + assert_not_null "call(!, _, _)" callable; + assert_not_null "call(_, !, _)" args; check_not_null (Pywrappers.pyobject_call callable args kw) let size obj = + assert_not_null "size" obj; check_int (Pywrappers.pyobject_size obj) + + let dir obj = + assert_not_null "dir" obj; + check_not_null (Pywrappers.pyobject_dir obj) end let exception_printer exn = @@ -1542,87 +1745,147 @@ end module Number = struct let absolute v = check_not_null (Pywrappers.pynumber_absolute v) - let add v0 v1 = check_not_null (Pywrappers.pynumber_add v0 v1) + let add v0 v1 = + assert_not_null "add(!, _)" v0; + assert_not_null "add(_, !)" v1; + check_not_null (Pywrappers.pynumber_add v0 v1) - let number_and v0 v1 = check_not_null (Pywrappers.pynumber_and v0 v1) + let number_and v0 v1 = + assert_not_null "number_and(!, _)" v0; + assert_not_null "number_and(_, !)" v1; + check_not_null (Pywrappers.pynumber_and v0 v1) let _check v = Pywrappers.pynumber_check v <> 0 - let divmod v0 v1 = check_not_null (Pywrappers.pynumber_divmod v0 v1) + let divmod v0 v1 = + assert_not_null "divmod(!, _)" v0; + assert_not_null "divmod(_, !)" v1; + check_not_null (Pywrappers.pynumber_divmod v0 v1) let float v = check_not_null (Pywrappers.pynumber_float v) let floor_divide v0 v1 = + assert_not_null "floor_divide(!, _)" v0; + assert_not_null "floor_divide(_, !)" v1; check_not_null (Pywrappers.pynumber_floordivide v0 v1) - let in_place_add v0 v1 = check_not_null (Pywrappers.pynumber_inplaceadd v0 v1) + let in_place_add v0 v1 = + assert_not_null "in_place_add(!, _)" v0; + assert_not_null "in_place_add(_, !)" v1; + check_not_null (Pywrappers.pynumber_inplaceadd v0 v1) - let in_place_and v0 v1 = check_not_null (Pywrappers.pynumber_inplaceand v0 v1) + let in_place_and v0 v1 = + assert_not_null "in_place_and(!, _)" v0; + assert_not_null "in_place_and(_, !)" v1; + check_not_null (Pywrappers.pynumber_inplaceand v0 v1) let in_place_floor_divide v0 v1 = + assert_not_null "in_place_floor_divide(!, _)" v0; + assert_not_null "in_place_floor_divide(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacefloordivide v0 v1) let in_place_lshift v0 v1 = + assert_not_null "in_place_lshift(!, _)" v0; + assert_not_null "in_place_lshift(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacelshift v0 v1) let in_place_multiply v0 v1 = + assert_not_null "in_place_multiply(!, _)" v0; + assert_not_null "in_place_multiply(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacemultiply v0 v1) let in_place_or v0 v1 = + assert_not_null "in_place_or(!, _)" v0; + assert_not_null "in_place_or(_, !)" v1; check_not_null (Pywrappers.pynumber_inplaceor v0 v1) let in_place_power ?(modulo = none) v0 v1 = + assert_not_null "in_place_power(?modulo:!, _, _)" modulo; + assert_not_null "in_place_power(?modulo:_, !, _)" v0; + assert_not_null "in_place_power(?modulo:_, _, _)" v1; check_not_null (Pywrappers.pynumber_inplacepower v0 v1 modulo) let in_place_remainder v0 v1 = + assert_not_null "in_place_remainder(!, _)" v0; + assert_not_null "in_place_remainder(_, !)" v1; check_not_null (Pywrappers.pynumber_inplaceremainder v0 v1) let in_place_rshift v0 v1 = + assert_not_null "in_place_rshift(!, _)" v0; + assert_not_null "in_place_rshift(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacershift v0 v1) let in_place_subtract v0 v1 = + assert_not_null "in_place_substract(!, _)" v0; + assert_not_null "in_place_substract(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacesubtract v0 v1) let in_place_true_divide v0 v1 = + assert_not_null "in_place_true_divide(!, _)" v0; + assert_not_null "in_place_true_divide(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacetruedivide v0 v1) let in_place_xor v0 v1 = + assert_not_null "in_place_xor(!, _)" v0; + assert_not_null "in_place_xor(_, !)" v1; check_not_null (Pywrappers.pynumber_inplacexor v0 v1) let invert v = + assert_not_null "invert" v; check_not_null (Pywrappers.pynumber_invert v) let lshift v0 v1 = + assert_not_null "in_place_xor(!, _)" v0; + assert_not_null "in_place_xor(_, !)" v1; check_not_null (Pywrappers.pynumber_lshift v0 v1) let multiply v0 v1 = + assert_not_null "in_place_xor(!, _)" v0; + assert_not_null "in_place_xor(_, !)" v1; check_not_null (Pywrappers.pynumber_multiply v0 v1) let negative v = + assert_not_null "negative" v; check_not_null (Pywrappers.pynumber_negative v) let number_or v0 v1 = + assert_not_null "in_place_xor(!, _)" v0; + assert_not_null "in_place_xor(_, !)" v1; check_not_null (Pywrappers.pynumber_or v0 v1) let positive v = + assert_not_null "positive" v; check_not_null (Pywrappers.pynumber_positive v) let power ?(modulo = none) v0 v1 = + assert_not_null "in_place_power(?modulo:!, _, _)" modulo; + assert_not_null "in_place_power(?modulo:_, !, _)" v0; + assert_not_null "in_place_power(?modulo:_, _, _)" v1; check_not_null (Pywrappers.pynumber_power v0 v1 modulo) let remainder v0 v1 = + assert_not_null "remainder(!, _)" v0; + assert_not_null "remainder(_, !)" v1; check_not_null (Pywrappers.pynumber_remainder v0 v1) let rshift v0 v1 = + assert_not_null "rshift(!, _)" v0; + assert_not_null "rshift(_, !)" v1; check_not_null (Pywrappers.pynumber_rshift v0 v1) let subtract v0 v1 = + assert_not_null "substract(!, _)" v0; + assert_not_null "substract(_, !)" v1; check_not_null (Pywrappers.pynumber_subtract v0 v1) let true_divide v0 v1 = + assert_not_null "true_divide_xor(!, _)" v0; + assert_not_null "true_divide_xor(_, !)" v1; check_not_null (Pywrappers.pynumber_truedivide v0 v1) let number_xor v0 v1 = + assert_not_null "number_xor(!, _)" v0; + assert_not_null "number_xor(_, !)" v1; check_not_null (Pywrappers.pynumber_xor v0 v1) let check v = @@ -1669,7 +1932,9 @@ end module Iter_ = struct let check o = Type.get o = Type.Iter - let next i = option (Pywrappers.pyiter_next i) + let next i = + assert_not_null "next" i; + option (Pywrappers.pyiter_next i) let rec iter f i = match next i with @@ -1702,6 +1967,14 @@ module Iter_ = struct match next i with None -> false | Some item -> p item || exists p i + + let unsafe_to_seq_map f i = + let rec seq () = + match next i with + | None -> Seq.Nil + | Some item -> + Seq.Cons (f item, seq) in + seq end (* From stdcompat *) @@ -1728,11 +2001,15 @@ module Sequence = struct let concat s s' = check_not_null (Pywrappers.pysequence_concat s s') - let contains s value = bool_of_int (Pywrappers.pysequence_contains s value) + let contains s value = + assert_not_null "contains(!, _)" s; + assert_not_null "contains(_, !)" value; + bool_of_int (Pywrappers.pysequence_contains s value) let count s value = check_int (Pywrappers.pysequence_count s value) let del_item s index = + assert_not_null "del_item" s; assert_int_success (Pywrappers.pysequence_delitem s index) let fast s msg = check_not_null (Pywrappers.pysequence_fast s msg) @@ -1767,7 +2044,9 @@ module Sequence = struct let set_slice s i0 i1 value = assert_int_success (Pywrappers.pysequence_setslice s i0 i1 value) - let size s = check_int (Pywrappers.pysequence_size s) + let size s = + assert_not_null "size" s; + check_int (Pywrappers.pysequence_size s) let tuple sequence = check_not_null (Pywrappers.pysequence_tuple sequence) @@ -1832,11 +2111,14 @@ module Tuple = struct let of_seq s = of_array (Array.of_seq s) - let of_tuple1 v0 = init 1 (function _ -> v0) + let of_tuple1 v0 = + init 1 (function _ -> v0) - let of_tuple2 (v0, v1) = init 2 (function 0 -> v0 | _ -> v1) + let of_tuple2 (v0, v1) = + init 2 (function 0 -> v0 | _ -> v1) - let of_tuple3 (v0, v1, v2) = init 3 (function 0 -> v0 | 1 -> v1 | _ -> v2) + let of_tuple3 (v0, v1, v2) = + init 3 (function 0 -> v0 | 1 -> v1 | _ -> v2) let of_tuple4 (v0, v1, v2, v3) = init 4 (function 0 -> v0 | 1 -> v1 | 2 -> v2 | _ -> v3) @@ -1869,27 +2151,35 @@ module Dict = struct let check o = Type.get o = Type.Dict - let clear = Pywrappers.pydict_clear + let clear o = + assert_not_null "clear" o; + Pywrappers.pydict_clear o let copy v = check_not_null (Pywrappers.pydict_copy v) let del_item dict item = + assert_not_null "del_item(!, _)" dict; + assert_not_null "del_item(_, !)" item; assert_int_success (Pywrappers.pydict_delitem dict item) let del_item_string dict name = + assert_not_null "del_item_string" dict; assert_int_success (Pywrappers.pydict_delitemstring dict name) let get_item dict key = + assert_not_null "get_item(!, _)" dict; + assert_not_null "get_item(_, !)" key; option (Pywrappers.pydict_getitem dict key) - let find dict key = Pyutils.option_unwrap (get_item dict key) + let find dict key = Stdcompat.Option.get (get_item dict key) let find_opt = get_item let get_item_string dict name = + assert_not_null "get_item_string" dict; option (Pywrappers.pydict_getitemstring dict name) - let find_string dict key = Pyutils.option_unwrap (get_item_string dict key) + let find_string dict key = Stdcompat.Option.get (get_item_string dict key) let find_string_opt = get_item_string @@ -1897,9 +2187,6 @@ module Dict = struct let items dict = check_not_null (Pywrappers.pydict_items dict) - let set_item_string dict name value = - assert_int_success (Pywrappers.pydict_setitemstring dict name value) - let size dict = let sz = Pywrappers.pydict_size dict in assert_int_success sz; @@ -1932,6 +2219,17 @@ module Dict = struct p key value end (Object.get_iter (items dict)) + let to_bindings_seq_map fkey fvalue dict = + Iter_.unsafe_to_seq_map + (fun pair -> + let (key, value) = Tuple.to_pair pair in + (fkey key, fvalue value)) + (Object.get_iter (items dict)) + + let to_bindings_seq = to_bindings_seq_map id id + + let to_bindings_string_seq = to_bindings_seq_map String.to_string id + let to_bindings_map fkey fvalue dict = Iter_.to_list_map begin fun pair -> let (key, value) = Tuple.to_pair pair in @@ -1942,35 +2240,50 @@ module Dict = struct let to_bindings_string = to_bindings_map String.to_string id - let singleton key value = of_bindings [(key, value)] + let singleton key value = + assert_not_null "singleton(!, _)" key; + assert_not_null "singleton(_, !)" value; + of_bindings [(key, value)] - let singleton_string key value = of_bindings_string [(key, value)] + let singleton_string key value = + assert_not_null "singleton_string" value; + of_bindings_string [(key, value)] end module Set = struct let check o = Type.get o = Type.Set - let clear = Pywrappers.pyset_clear + let clear o = + assert_not_null "clear" o; + assert_int_success (Pywrappers.pyset_clear o) let copy v = check_not_null (Pywrappers.pyset_new v) let create () = check_not_null (Pywrappers.pyset_new null) let size set = + assert_not_null "size" set; let sz = Pywrappers.pyset_size set in assert_int_success sz; sz let add set value = + assert_not_null "add(!, _)" set; + assert_not_null "add(_, !)" value; assert_int_success (Pywrappers.pyset_add set value) let contains set value = + assert_not_null "contains(!, _)" set; + assert_not_null "contains(_, !)" value; bool_of_int (Pywrappers.pyset_contains set value) let discard set value = + assert_not_null "discard(!, _)" set; + assert_not_null "discard(_, !)" value; assert_int_success (Pywrappers.pyset_discard set value) let to_list_map f set = + assert_not_null "to_list_map" set; Iter_.to_list_map f (Object.get_iter set) let to_list = to_list_map id @@ -1985,6 +2298,61 @@ module Set = struct let of_list = of_list_map id end +module Traceback = struct + type frame = + { filename : string + ; function_name : string + ; line_number : int + } + + let create_frame { filename; function_name; line_number } = + check_not_null (pyframe_new filename function_name line_number) + + type t = frame list + + let create t = + let types_module = check_not_null (Pywrappers.pyimport_importmodule "types") in + let tb_type = Object.find_attr_string types_module "TracebackType" in + List.fold_left + (fun acc frame -> + let args = + Tuple.of_array [| acc; create_frame frame; Int.of_int 0; Int.of_int frame.line_number |] + in + Object.call tb_type args null) + none + t +end + +exception Err_with_traceback of Err.t * string * Traceback.t + +module Class = struct + let init ?(parents = []) ?(fields = []) ?(methods = []) classname = + if version_major () >= 3 then + let methods = List.rev_map (fun (name, closure) -> + (name, Pywrappers.Python3.pyinstancemethod_new closure)) methods in + Type.create classname parents (List.rev_append methods fields) + else + let classname = String.of_string classname in + let dict = Dict_.of_bindings_string fields in + let c = + check_not_null (Pywrappers.Python2.pyclass_new (Tuple_.of_list parents) + dict classname) in + let add_method (name, closure) = + let m = check_not_null (Pywrappers.pymethod_new closure null c) in + Dict_.set_item_string dict name m in + List.iter add_method methods; + c +end + +let () = + ocaml_exception_class := + Some (lazy (Class.init ~parents:[Pywrappers.pyexc_baseexception ()] + "ocaml exception")) + +let () = + ocaml_exception_capsule := + Some (Capsule.make "ocaml_exception_capsule") + module Callable = struct let check v = Pywrappers.pycallable_check v <> 0 @@ -1993,9 +2361,27 @@ module Callable = struct E (errtype, errvalue) -> Err.set_object errtype errvalue; null - | Err (errtype, msg) -> + | Err (errtype, msg) + | Err_with_traceback (errtype, msg, []) -> Err.set_error errtype msg; null + | Err_with_traceback (errtype, msg, traceback) -> + let () = + (* Traceback objects can only be created since Python 3.7. *) + if !version_major_value <= 2 || (!version_major_value == 3 && !version_minor_value < 7) + then + Err.set_error errtype msg + else + let traceback = Traceback.create traceback in + Err.restore (Err.of_error errtype) (String.of_string msg) traceback; + in + null + | e -> + let err = + fst (Option.get !ocaml_exception_capsule) + (e, Printexc.get_raw_backtrace ()) in + Err.set_object (Lazy.force (Option.get !ocaml_exception_class)) err; + null let of_function_as_tuple ?name ?(docstring = "Anonymous closure") f = check_not_null (pywrap_closure name docstring @@ -2016,13 +2402,13 @@ module Callable = struct if not (check c) then Type.mismatch "Callable" c; function args -> - Eval.call_object c args + Object.call c args null let to_function_as_tuple_and_dict c = if not (check c) then Type.mismatch "Callable" c; fun args keywords -> - Eval.call_object_with_keywords c args keywords + Object.call c args keywords let to_function c = let f = to_function_as_tuple c in @@ -2034,6 +2420,15 @@ module Callable = struct f (Tuple.of_array args) (Dict.of_bindings_string keywords) end +type optimize = Default | Debug | Normal | RemoveDocstrings + +let int_of_optimize opt = + match opt with + | Default -> -1 + | Debug -> 0 + | Normal -> 1 + | RemoveDocstrings -> 2 + module Import = struct (* This function has been removed from Python 3.9, and was marked "for internal use only" before. @@ -2042,12 +2437,43 @@ module Import = struct let add_module name = check_not_null (Pywrappers.pyimport_addmodule name) + let main () = add_module "__main__" + + let builtins () = Object.find_attr_string (main ()) "__builtins__" + + let compile ~source ~filename ?(dont_inherit = false) + ?(optimize = Default) mode = + let compile = + Callable.to_function_with_keywords + (Object.find_attr_string (builtins ()) "compile") in + let source = String.of_string source in + let filename = String.of_string filename in + let mode = String.of_string (string_of_input mode) in + let dont_inherit = Bool.of_bool dont_inherit in + let args = ["dont_inherit", dont_inherit] in + let args = + if !version_minor_value <= 2 then + args + else + begin + let optimize = Int.of_int (int_of_optimize optimize) in + ["optimize", optimize] + end in + compile [| source; filename; mode |] args + let exec_code_module name obj = + assert_not_null "exec_code_module" obj; check_not_null (Pywrappers.pyimport_execcodemodule name obj) let exec_code_module_ex name obj pathname = + assert_not_null "exec_code_module_ex" obj; check_not_null (Pywrappers.pyimport_execcodemoduleex name obj pathname) + let exec_code_module_from_string ~name ?(filename = name) + ?dont_inherit ?optimize source = + let obj = compile ~source ~filename ?dont_inherit ?optimize File in + exec_code_module name obj + let get_magic_number = Pywrappers.pyimport_getmagicnumber let get_module_dict () = @@ -2065,8 +2491,9 @@ module Import = struct with E (e, _msg) when let ty = Object.to_string e in - ty = "" || - ty = "" -> + ty = "" || (* Python >=3.6*) + ty = "" || (* Python <3.6 *) + ty = "" (* Python 2 *) -> None let try_import_module = import_module_opt @@ -2086,11 +2513,6 @@ let import = Import.import_module let import_opt = Import.import_module_opt -let option_map f o = - match o with - | None -> None - | Some x -> Some (f x) - module Module = struct let check o = Type.get o = Type.Module @@ -2098,12 +2520,15 @@ module Module = struct check_not_null (Pywrappers.pymodule_new name) let get_dict m = + assert_not_null "get_dict" m; check_not_null (Pywrappers.pymodule_getdict m) let get_filename m = + assert_not_null "get_filename" m; check_some (Pywrappers.pymodule_getfilename m) let get_name m = + assert_not_null "get_name" m; check_some (Pywrappers.pymodule_getname m) let get = Object.find_attr_string @@ -2114,13 +2539,13 @@ module Module = struct let get_function m name = Callable.to_function (get m name) - let get_function_opt m name = option_map Callable.to_function (get_opt m name) + let get_function_opt m name = Option.map Callable.to_function (get_opt m name) let get_function_with_keywords m name = Callable.to_function_with_keywords (get m name) let get_function_with_keywords_opt m name = - option_map Callable.to_function_with_keywords (get_opt m name) + Option.map Callable.to_function_with_keywords (get_opt m name) let set_function m name f = set m name (Callable.of_function f) @@ -2129,36 +2554,19 @@ module Module = struct let remove = Object.del_attr_string - let main () = Import.add_module "__main__" + let main = Import.main let sys () = Import.import_module "sys" let builtins () = get (main ()) "__builtins__" + let compile = Import.compile + let set_docstring m doc = Pywrappers.pymodule_setdocstring m doc |> assert_int_success end -module Class = struct - let init ?(parents = []) ?(fields = []) ?(methods = []) classname = - if version_major () >= 3 then - let methods = List.rev_map (fun (name, closure) -> - (name, Pywrappers.Python3.pyinstancemethod_new closure)) methods in - Type.create classname parents (List.rev_append methods fields) - else - let classname = String.of_string classname in - let dict = Dict.of_bindings_string fields in - let c = - check_not_null (Pywrappers.Python2.pyclass_new (Tuple.of_list parents) - dict classname) in - let add_method (name, closure) = - let m = check_not_null (Pywrappers.pymethod_new closure null c) in - Dict.set_item_string dict name m in - List.iter add_method methods; - c -end - module Iter = struct include Iter_ @@ -2173,7 +2581,8 @@ module Iter = struct let iter_fn = Callable.of_function (function | [||] -> failwith "__iter__ expects at least one argument" | array -> array.(0)) in - let methods = [next_name, Callable.of_function next'; "__iter__", iter_fn] in + let methods = + [next_name, Callable.of_function next'; "__iter__", iter_fn] in Object.call_function_obj_args (Class.init ~methods "iterator") [| |] @@ -2221,14 +2630,6 @@ module Iter = struct Seq.Cons (item, seq) in seq - let unsafe_to_seq_map f i = - let rec seq () = - match next i with - | None -> Seq.Nil - | Some item -> - Seq.Cons (f item, seq) in - seq - let of_list l = let l = ref l in let next () = @@ -2253,6 +2654,8 @@ module Iter = struct check_not_null (Pywrappers.pyseqiter_new seq) let call_iter call sentinel = + assert_not_null "call_iter(!, _)" call; + assert_not_null "call_iter(_, !)" sentinel; check_not_null (Pywrappers.pycalliter_new call sentinel) (* As a sentinel we use a function so that there is no collision risk. @@ -2278,7 +2681,9 @@ module List = struct let create size = check_not_null (Pywrappers.pylist_new size) - let size list = check_int (Pywrappers.pylist_size list) + let size list = + assert_not_null "size" list; + check_int (Pywrappers.pylist_size list) let length = size @@ -2305,7 +2710,9 @@ module List = struct let of_sequence = Sequence.list - let singleton v = init 1 (fun _ -> v) + let singleton v = + assert_not_null "singleton" v; + init 1 (fun _ -> v) let of_seq s = of_array (Array.of_seq s) end @@ -2332,7 +2739,7 @@ module Marshal = struct let write_object_to_file v file version = let fd = Pytypes.file_map Unix.descr_of_out_channel file in - assert_int_success (Pywrappers.pymarshal_writeobjecttofile v fd version) + Pywrappers.pymarshal_writeobjecttofile v fd version let dump ?(version = version ()) v file = write_object_to_file v file version @@ -2553,23 +2960,17 @@ let set_argv argv = let last_value () = Module.get (Module.builtins ()) "_" -let compile ~source ~filename ?(dont_inherit = false) - ?(optimize = `Default) mode = - let compile = - Module.get_function_with_keywords (Module.builtins ()) "compile" in - let source = String.of_string source in - let filename = String.of_string filename in +let compile ~source ~filename ?dont_inherit ?optimize mode = let mode = - String.of_string @@ match mode with - | `Exec -> "exec" - | `Eval -> "eval" - | `Single -> "single" in + match mode with + | `Exec -> File + | `Eval -> Eval + | `Single -> Single in let optimize = - Int.of_int @@ match optimize with - | `Default -> -1 - | `Debug -> 0 - | `Normal -> 1 - | `RemoveDocstrings -> 2 in - let dont_inherit = Bool.of_bool dont_inherit in - compile [| source; filename; mode |] - ["dont_inherit", dont_inherit; "optimize", optimize] + Stdcompat.Option.map (function + | `Default -> Default + | `Debug -> Debug + | `Normal -> Normal + | `RemoveDocstrings -> RemoveDocstrings) + optimize in + Module.compile ~source ~filename ?dont_inherit ?optimize mode diff --git a/bundles/pyml/pyml-current/py.mli b/bundles/pyml/pyml-current/py.mli index 05b258a15..d968dbf9c 100644 --- a/bundles/pyml/pyml-current/py.mli +++ b/bundles/pyml/pyml-current/py.mli @@ -3,7 +3,8 @@ (** Call [initialize ()] first. *) val initialize: ?library_name:string -> ?interpreter:string -> ?version:int -> - ?minor:int -> ?verbose:bool -> ?debug_build:bool -> unit -> unit + ?minor:int -> ?verbose:bool -> ?debug_build:bool -> ?python_sigint:bool -> + unit -> unit (** [initialize ~interpreter ~version ~minor ~verbose ~debug_build ()] finds and loads the Python library. This function should be called before any other functions, except @@ -23,11 +24,17 @@ val initialize: ?library_name:string -> ?interpreter:string -> ?version:int -> in the directory [../lib] relatively to the directory where the [python] executable is. If the library has been statically linked with the executable, it will be used. - When [verbose] is true (default: false), library filenames that are + When [verbose] is [true] (default: [false]), library filenames that are tried to be loaded are printed on standard error. [debug_build] specifies whether the Python library is a debug build: if the argument is left unspecified, debug build is detected - automatically. *) + automatically. + If [python_sigint] is [true] (default: [false]), the function let + [pythonlib] take handle on [sigint], preventing programs from + being interrupted by [Ctrl+C]. When [python_sigint] is [false] + (the default), the previous signal behavior of [sigint] is restored after + the library has been loaded (so, [Ctrl+C] will still interrupt the + program, unless this behavior was changed elsewhere). *) val finalize: unit -> unit (** [finalize ()] unloads the library. No other functions except @@ -62,6 +69,10 @@ val version_minor: unit -> int (** [version_minor ()] returns the minor number (the second component) of the version of the Python library. *) +val version_pair: unit -> int * int +(** [version_pair ()] returns the major and the minor numbers of the + version of the Python library. *) + type compare = Pytypes.compare = LT | LE | EQ | NE | GT | GE (** Either a filename or a channel. @@ -286,6 +297,10 @@ module Object: sig val size: t -> int (** Wrapper for {{:https://docs.python.org/3/c-api/object.html#c.PyObject_Size} PyObject_Size} *) + + val dir: t -> t + (** Wrapper for + {{:https://docs.python.org/3/c-api/object.html#c.PyObject_Dir} PyObject_Dir} *) end exception E of Object.t * Object.t @@ -414,6 +429,13 @@ module Callable: sig Wrapper for {{: https://docs.python.org/3/c-api/object.html#c.PyCallable_Check} PyCallable_Check}. *) + val handle_errors : ('a -> Object.t) -> 'a -> Object.t + (** [handle_errors f x] calls [f x] and returns its result if the call + succeeds. If [f x] raises a Python exception + ([Py.E (errtype, errvalue)] or [Py.Err (errtype, msg)]), + this exception is raised as a Python exception + (via {!Err.set_object} or {!Err.set_error} respectively). *) + val of_function_as_tuple: ?name:string -> ?docstring:string -> (Object.t -> Object.t) -> Object.t (** [of_function_as_tuple f] returns a Python callable object that calls the @@ -468,11 +490,16 @@ end (** Embedding of OCaml values in Python. *) module Capsule: sig + type 'a t = { + wrap : 'a -> Object.t; + unwrap : Object.t -> 'a; + } + val check: Object.t -> bool (** [check v] returns [true] if [v] contains an OCaml value. *) - val make: string -> ('a -> Object.t) * (Object.t -> 'a) - (** For a given type ['a], [make s] returns a pair [(wrap, unwrap)]. + val create: string -> 'a t + (** For a given type ['a], [create s] returns a pair [{ wrap; unwrap }]. [wrap v] transforms the value [v] of type 'a to an opaque Python object. [unwrap w] transforms the opaque Python object [w] previously obtained with [wrap v] into the original OCaml value [v], @@ -480,6 +507,9 @@ module Capsule: sig [Failure _] is raised if a wrapper has already been generated for a type of the same name. *) + val make: string -> ('a -> Object.t) * (Object.t -> 'a) + (** Same as {!val:create}, but returns a plain pair instead of a record. *) + val type_of: Object.t -> string (** [type_of w] returns the type string associated to the opaque Python object [w]. *) @@ -681,8 +711,8 @@ module Dict: sig [p key value]. *) val to_bindings: Object.t -> (Object.t * Object.t) list - (** [to_bindings o] returns all the pairs [(key, value)] in the Python dictionary - [o]. *) + (** [to_bindings o] returns all the pairs [(key, value)] in the Python + dictionary [o]. *) val to_bindings_map: (Object.t -> 'a) -> (Object.t -> 'b) -> Object.t -> ('a * 'b) list @@ -693,6 +723,19 @@ module Dict: sig (** [to_bindings_string o] returns all the pairs [(key, value)] in the Python dictionary [o]. *) + val to_bindings_seq: Object.t -> (Object.t * Object.t) Stdcompat.Seq.t + (** [to_bindings_seq o] returns the ephemeral sequence of all the pairs + (key, value) in the Python dictionary [o]. *) + + val to_bindings_seq_map: (Object.t -> 'a) -> (Object.t -> 'b) -> Object.t -> + ('a * 'b) Stdcompat.Seq.t + (** [to_bindings_seq_map fkey fvalue o] returns the ephemeral sequence of all + the pairs (fkey key, fvalue value) in the Python dictionary [o]. *) + + val to_bindings_string_seq: Object.t -> (string * Object.t) Stdcompat.Seq.t + (** [to_bindings_string_seq o] returns the ephemeral sequence of all the pairs + (key, value) in the Python dictionary [o]. *) + val of_bindings: (Object.t * Object.t) list -> Object.t (** [of_bindings b] returns then Python dictionary mapping all the pairs [(key, value)] in [b]. *) @@ -859,11 +902,34 @@ module Err: sig {{:https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetObject} PyErr_SetObject}. In a closure/method/callback, it is recommended to raise a [Py.E _] exception instead. *) + + val set_interrupt: unit -> unit + (** Wrapper for + {{:https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetInterrupt} PyErr_SetInterrupt} *) + + val set_interrupt_ex: int -> unit + (** Since Python 3.10. Wrapper for + {{:https://docs.python.org/3/c-api/exceptions.html#c.PyErr_SetInterruptEx} PyErr_SetInterruptEx} *) +end + +module Traceback : sig + type frame = + { filename : string + ; function_name : string + ; line_number : int + } + + val create_frame : frame -> Object.t + + type t = frame list end exception Err of Err.t * string (** Represents an exception to be set with {!Err.set_error} in a callback. *) +exception Err_with_traceback of Err.t * string * Traceback.t +(** Represents an exception with traceback information to be set with {!Err.restore}. *) + module Eval: sig val call_object: Object.t -> Object.t -> Object.t (** See {{:https://docs.python.org/3.0/extending/extending.html} Extending Python with C or C++} *) @@ -901,6 +967,9 @@ module Float: sig {{:https://docs.python.org/3/c-api/float.html#c.PyFloat_FromDouble} PyFloat_FromDouble}. *) end +type optimize = Default | Debug | Normal | RemoveDocstrings + +val int_of_optimize : optimize -> int (** Importing Modules *) module Import: sig @@ -916,8 +985,9 @@ module Import: sig {{:https://docs.python.org/3/c-api/import.html#c.PyImport_AddModule} PyImport_AddModule} *) val exec_code_module: string -> Object.t -> Object.t - (** [exec_code_module name bytecode] imports the module [name] compiled in [bytecode]. - [bytecode] can be obtained with {!val:Py.compile}. + (** [exec_code_module name bytecode] imports the module [name] compiled in + [bytecode]. [bytecode] can be obtained with {!val:Py.Module.compile} + (you may also consider {!val:Py.Import.exec_code_module_from_string}. Wrapper for {{:https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModule} PyImport_ExecCodeModule} *) @@ -925,6 +995,14 @@ module Import: sig (** Wrapper for {{:https://docs.python.org/3/c-api/import.html#c.PyImport_ExecCodeModuleEx} PyImport_ExecCodeModuleEx} *) + val exec_code_module_from_string : name:string -> ?filename:string -> + ?dont_inherit:bool -> ?optimize:optimize -> string -> Object.t + (** [exec_code_module ~name ?filename ?dont_inherit ?optimize source_code] + compiles [source_code] and imports the resulting bytecode as + module [name]. [filename] is equal to [name] by default and is used + in error messages. [dont_inherit] and [optimize] are passed to + {!val:Py.Module.compile} for compiling [source_code]. *) + val get_magic_number: unit -> int64 (** Wrapper for {{:https://docs.python.org/3/c-api/import.html#c.PyImport_GetMagicNumber} PyImport_GetMagicNumber} *) @@ -1227,6 +1305,10 @@ module Method: sig {{:https://docs.python.org/3/c-api/method.html#c.PyMethod_Self} PyMethod_Self} *) end +type input = Pytypes.input = Single | File | Eval + +val string_of_input : input -> string + (** Interface for Python values of type [Module]. *) module Module: sig val check: Object.t -> bool @@ -1305,6 +1387,14 @@ module Module: sig val set_docstring: Object.t -> string -> unit (** Wrapper for {{:https://docs.python.org/3/c-api/module.html#c.PyModule_SetDocString} PyModule_SetDocString} *) + + val compile : source:string -> filename:string -> ?dont_inherit:bool -> + ?optimize:optimize -> input -> Object.t + (** [compile ~source ~filename ?dont_inherit ?optimize mode] returns + the bytecode obtained by compiling ~source. It is a wrapper for + the built-in function + {{:https://docs.python.org/3/library/functions.html#compile} compile()}. + {{:https://github.com/thierry-martinez/pyml/issues/25} GitHub issue #25}*) end (** Interface for Python values of type [Number]. *) @@ -1481,8 +1571,6 @@ module Number: sig (** Synomym of {!rshift} *) end -type input = Pytypes.input = Single | File | Eval - (** Interface for Python values of type [Run]. *) module Run: sig val eval: ?start:input -> ?globals:Object.t -> ?locals:Object.t -> string @@ -1802,7 +1890,7 @@ module Tuple: sig (** The empty tuple [()]. This value is guaranteed to be the unique value associated to [()]. *) - val is_empty: Object.t -> bool + val is_empty: Object.t -> bool (** [Py.is_empty v] is true if and only if [v] is [()]. Since [Py.Tuple.empty] is guaranteed to be the unique value associated to [()], [Py.is_empty v] is equivalent to [v == Py.empty]. *) @@ -2129,8 +2217,4 @@ val exception_printer: exn -> string option val compile: source:string -> filename:string -> ?dont_inherit:bool -> ?optimize:[`Default | `Debug | `Normal | `RemoveDocstrings ] -> [`Exec | `Eval | `Single] -> Object.t -(** [compile ~source ~filename ?dont_inherit ?optimize mode] returns - the bytecode obtained by compiling ~source. It is a wrapper for - the built-in function - {{:https://docs.python.org/3/library/functions.html#compile} compile()}. - {{:https://github.com/thierry-martinez/pyml/issues/25} GitHub issue #25}*) +(** Old interface for {!val:Py.Module.compile}. *) diff --git a/bundles/pyml/pyml-current/pycaml.mli b/bundles/pyml/pyml-current/pycaml.mli index 85b5f83c6..d02d43cda 100644 --- a/bundles/pyml/pyml-current/pycaml.mli +++ b/bundles/pyml/pyml-current/pycaml.mli @@ -707,7 +707,6 @@ val pyerr_setstring : pyobject * string -> unit val pyerr_occurred : unit -> pyobject val pyerr_clear : unit -> unit val pyerr_fetch : pyobject * pyobject * pyobject -> pyobject * pyobject * pyobject -val pyerr_restore : pyobject * pyobject * pyobject -> unit val pyerr_givenexceptionmatches : pyobject * pyobject -> int val pyerr_exceptionmatches : pyobject -> int val pyerr_normalizeexception : pyobject * pyobject * pyobject -> pyobject * pyobject * pyobject diff --git a/bundles/pyml/pyml-current/pyml.opam b/bundles/pyml/pyml-current/pyml.opam index 96c821616..4aa5a2159 100644 --- a/bundles/pyml/pyml-current/pyml.opam +++ b/bundles/pyml/pyml-current/pyml.opam @@ -1,20 +1,34 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -maintainer: "Thierry Martinez " -authors: "Thierry Martinez " -homepage: "http://github.com/thierry-martinez/pyml" -bug-reports: "http://github.com/thierry-martinez/pyml/issues" -license: "BSD" -dev-repo: "git+https://github.com/thierry-martinez/pyml.git" -build: [make "all" "pymltop" "pymlutop" {utop:installed} "PREFIX=%{prefix}%"] -install: [make "install" "PREFIX=%{prefix}%"] -run-test: [make "test"] synopsis: "OCaml bindings for Python" description: "OCaml bindings for Python 2 and Python 3" +maintainer: ["Thierry Martinez "] +authors: ["Thierry Martinez "] +license: "BSD-2-Clause" +homepage: "http://github.com/thierry-martinez/pyml" +doc: "http://github.com/thierry-martinez/pyml" +bug-reports: "http://github.com/thierry-martinez/pyml/issues" depends: [ - "ocaml" {>= "3.12.1" & < "4.12.0"} + "dune" {>= "2.8"} + "ocaml" {>= "3.12.1"} "ocamlfind" {build} - "stdcompat" {>= "13"} + "stdcompat" {>= "18"} "conf-python-3-dev" {with-test} + "odoc" {with-doc} ] depopts: ["utop"] -version: "20200518" \ No newline at end of file +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/thierry-martinez/pyml.git" diff --git a/bundles/pyml/pyml-current/pyml_arch.ml.c b/bundles/pyml/pyml-current/pyml_arch.ml.c new file mode 100644 index 000000000..4d9da0e11 --- /dev/null +++ b/bundles/pyml/pyml-current/pyml_arch.ml.c @@ -0,0 +1,20 @@ +#if __APPLE__ + #define PLATFORM_NAME Mac +#elif defined(WIN32) || defined(_WIN32) + #define PLATFORM_NAME Windows + #define WIN_HANDLE_FD +#elif unix + #define PLATFORM_NAME Unix +#else + #error "Unknown platform" +#endif + +type t = Windows | Mac | Unix + +let os = PLATFORM_NAME + +#ifdef WIN_HANDLE_FD + external fd_of_int : int -> Unix.file_descr = "win_handle_fd" +#else + external fd_of_int : int -> Unix.file_descr = "%identity" +#endif diff --git a/bundles/pyml/pyml-current/pyml_arch.mli b/bundles/pyml/pyml-current/pyml_arch.mli index 2f60f999d..4e5757e4b 100644 --- a/bundles/pyml/pyml-current/pyml_arch.mli +++ b/bundles/pyml/pyml-current/pyml_arch.mli @@ -1,11 +1,5 @@ -val library_patterns: (int -> int -> string, unit, string) format list +type t = Windows | Mac | Unix -val library_suffix: string - -val ensure_executable_suffix: string -> string - -val which: string +val os : t val fd_of_int: int -> Unix.file_descr - -val path_separator: string diff --git a/bundles/pyml/pyml-current/pyml_arch_cygwin.ml b/bundles/pyml/pyml-current/pyml_arch_cygwin.ml deleted file mode 100644 index ae197c2a8..000000000 --- a/bundles/pyml/pyml-current/pyml_arch_cygwin.ml +++ /dev/null @@ -1,16 +0,0 @@ -let library_patterns: (int -> int -> string, unit, string) format list = - ["python%d%d.dll"] - -let library_suffix = ".dll" - -let ensure_executable_suffix executable = - if Filename.check_suffix executable ".exe" then - executable - else - executable ^ ".exe" - -let which = "where" - -external fd_of_int: int -> Unix.file_descr = "win_handle_fd" - -let path_separator = ";" diff --git a/bundles/pyml/pyml-current/pyml_arch_darwin.ml b/bundles/pyml/pyml-current/pyml_arch_darwin.ml deleted file mode 100644 index 43102a45d..000000000 --- a/bundles/pyml/pyml-current/pyml_arch_darwin.ml +++ /dev/null @@ -1,12 +0,0 @@ -let library_patterns: (int -> int -> string, unit, string) format list = - ["libpython%d.%dm.dylib"; "libpython%d.%d.dylib"] - -let library_suffix = ".dylib" - -let ensure_executable_suffix executable = executable - -let which = "which" - -external fd_of_int: int -> Unix.file_descr = "%identity" - -let path_separator = ":" diff --git a/bundles/pyml/pyml-current/pyml_arch_unix.ml b/bundles/pyml/pyml-current/pyml_arch_unix.ml deleted file mode 100644 index 76d3b73d9..000000000 --- a/bundles/pyml/pyml-current/pyml_arch_unix.ml +++ /dev/null @@ -1,12 +0,0 @@ -let library_patterns: (int -> int -> string, unit, string) format list = - ["libpython%d.%dm.so"; "libpython%d.%d.so"] - -let library_suffix = ".so" - -let ensure_executable_suffix executable = executable - -let which = "which" - -external fd_of_int: int -> Unix.file_descr = "%identity" - -let path_separator = ":" diff --git a/bundles/pyml/pyml-current/pyml_stubs.c b/bundles/pyml/pyml-current/pyml_stubs.c index 9cb696fbc..149695c7a 100644 --- a/bundles/pyml/pyml-current/pyml_stubs.c +++ b/bundles/pyml/pyml-current/pyml_stubs.c @@ -5,25 +5,25 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include +#include #include "pyml_stubs.h" static FILE *(*Python__Py_fopen)(const char *pathname, const char *mode); -static FILE *(*Python__Py_wfopen)(const wchar_t *pathname, const char *mode); +static FILE *(*Python__Py_wfopen)(const wchar_t *pathname, const wchar_t *mode); static void *xmalloc(size_t size) { void *p = malloc(size); if (!p) { - failwith("Virtual memory exhausted\n"); + caml_failwith("Virtual memory exhausted\n"); } return p; } @@ -39,7 +39,13 @@ open_library(const char *filename) return LoadLibrary(filename); } -void +static char * +get_library_error() +{ + return "Unable to load library"; +} + +static void close_library(library_t library) { if (!FreeLibrary(library)) { @@ -64,9 +70,12 @@ int unsetenv(const char *name) { size_t len = strlen(name); - char string[len + 2]; + char *string = xmalloc(len + 2); + int result; snprintf(string, len + 2, "%s=", name); - return _putenv(string); + result = _putenv(string); + free(string); + return result; } extern int win_CRT_fd_of_filedescr(value handle); @@ -76,7 +85,7 @@ file_of_file_descr(value file_descr, const char *mode) { CAMLparam1(file_descr); int fd = win_CRT_fd_of_filedescr(file_descr); - FILE *result = _fdopen(dup(fd), mode); + FILE *result = _fdopen(_dup(fd), mode); CAMLreturnT(FILE *, result); } #else @@ -90,6 +99,12 @@ open_library(const char *filename) return dlopen(filename, RTLD_LAZY | RTLD_GLOBAL); } +static char * +get_library_error() +{ + return dlerror(); +} + void close_library(library_t filename) { @@ -121,42 +136,6 @@ file_of_file_descr(value file_descr, const char *mode) } #endif -/* The following definitions are extracted and simplified from -#include -*/ - -typedef struct { - int cf_flags; -} PyCompilerFlags; - -#define Py_TPFLAGS_INT_SUBCLASS (1L<<23) -#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) -#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) -#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) -#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) -#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) -#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) -#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) -#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) - -#define Py_LT 0 -#define Py_LE 1 -#define Py_EQ 2 -#define Py_NE 3 -#define Py_GT 4 -#define Py_GE 5 - -typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); - -typedef struct PyMethodDef { - const char *ml_name; - PyCFunction ml_meth; - int ml_flags; - const char *ml_doc; -} PyMethodDef; - -typedef void (*PyCapsule_Destructor)(PyObject *); - static void *Python27__PyObject_NextNotImplemented; /* Global variables for the library */ @@ -188,6 +167,7 @@ static PyObject *(*Python_PyObject_CallMethodObjArgs)( /* Wrapped by PyErr_Fetch_wrapper */ static void (*Python_PyErr_Fetch)(PyObject **, PyObject **, PyObject **); +static void (*Python_PyErr_Restore)(PyObject *, PyObject *, PyObject *); static void (*Python_PyErr_NormalizeException) (PyObject **, PyObject **, PyObject **); @@ -210,12 +190,18 @@ static PyObject *(*Python_PyLong_FromString)(const char *, const char **, int); /* Internal use only */ static void (*Python_PyMem_Free)(void *); +/* Generate traceback objects. */ +static PyObject *(*Python_PyThreadState_Get)(); +static PyObject *(*Python_PyFrame_New)(PyObject*, PyObject*, PyObject*, PyObject*); +static PyObject *(*Python_PyCode_NewEmpty)(const char*, const char*, int); + static enum UCS { UCS_NONE, UCS2, UCS4 } ucs; /* Single instance of () */ static PyObject *tuple_empty; #include "pyml.h" +#include static void *getcustom( value v ) { @@ -283,10 +269,102 @@ pyhash( value v ) } } +void +pyml_assert_initialized() +{ + if (!version_major) { + caml_failwith("Run 'Py.initialize ()' first"); + } +} + +/** Creates a Python tuple initialized with a single element given by the + argument. The reference to the argument is stolen. */ +static PyObject * +singleton(PyObject *value) +{ + PyObject *result = Python_PyTuple_New(1); + if (!result) { + caml_failwith("PyTuple_New"); + } + if (Python_PyTuple_SetItem(result, 0, value)) { + caml_failwith("PyTuple_SetItem"); + } + return result; +} + +static void +pyserialize(value v, uintnat *bsize_32, uintnat *bsize_64) +{ + pyml_assert_initialized(); + PyObject *value = getcustom(v); + PyObject *pickle = Python_PyImport_ImportModule("pickle"); + if (pickle == NULL) { + caml_failwith("Cannot import pickle"); + } + PyObject *dumps = Python_PyObject_GetAttrString(pickle, "dumps"); + if (dumps == NULL) { + caml_failwith("pickle.dumps unavailable"); + } + PyObject *args = singleton(value); + PyObject *bytes = Python_PyObject_Call(dumps, args, NULL); + if (bytes == NULL) { + caml_failwith("pickle.dumps failed"); + } + Py_ssize_t size; + char *contents; + if (version_major >= 3) { + size = Python3_PyBytes_Size(bytes); + contents = (char *) Python3_PyBytes_AsString(bytes); + } + else { + size = Python2_PyString_Size(bytes); + contents = (char *) Python2_PyString_AsString(bytes); + } + caml_serialize_int_8(size); + caml_serialize_block_1(contents, size); + *bsize_32 = 4; + *bsize_64 = 8; + /*Py_DECREF(bytes);*/ /* reference stolen by args */ + Py_DECREF(args); + Py_DECREF(dumps); + Py_DECREF(pickle); +} + static uintnat pydeserialize(void *dst) { - return 0L; + pyml_assert_initialized(); + Py_ssize_t size = caml_deserialize_uint_8(); + PyObject *bytes; + char *contents; + if (version_major >= 3) { + bytes = Python3_PyBytes_FromStringAndSize(NULL, size); + contents = (char *) Python3_PyBytes_AsString(bytes); + } + else { + bytes = Python2_PyString_FromStringAndSize(NULL, size); + contents = (char *) Python2_PyString_AsString(bytes); + } + caml_deserialize_block_1(contents, size); + PyObject *pickle = Python_PyImport_ImportModule("pickle"); + if (pickle == NULL) { + caml_failwith("Cannot import pickle"); + } + PyObject *loads = Python_PyObject_GetAttrString(pickle, "loads"); + if (loads == NULL) { + caml_failwith("pickle.loads unavailable"); + } + PyObject *args = singleton(bytes); + PyObject *value = Python_PyObject_Call(loads, args, NULL); + if (value == NULL) { + caml_failwith("pickle.loads failed"); + } + *((PyObject **) dst) = value; + /*Py_DECREF(bytes);*/ /* reference stolen by args */ + Py_DECREF(args); + Py_DECREF(loads); + Py_DECREF(pickle); + return sizeof(PyObject *); } struct custom_operations pyops = @@ -295,7 +373,7 @@ struct custom_operations pyops = pydecref, pycompare, pyhash, - custom_serialize_default, + pyserialize, pydeserialize }; @@ -316,7 +394,7 @@ resolve(const char *symbol) ssize_t size = snprintf(NULL, 0, fmt, symbol); char *msg = xmalloc(size + 1); snprintf(msg, size + 1, fmt, symbol); - failwith(msg); + caml_failwith(msg); } return result; } @@ -405,6 +483,10 @@ pyml_unwrap_compilerflags(value v) if (Is_block(v)) { PyCompilerFlags *flags = malloc(sizeof(PyCompilerFlags)); flags->cf_flags = Int_val(Field(Field(v, 0), 0)); + + /* only useful for Python >= 3.8 */ + flags->cf_feature_version = version_minor; + CAMLreturnT(PyCompilerFlags *, flags); } else { @@ -512,7 +594,7 @@ camlwrap_capsule(value val, void *aux_str, int size) { value *v = (value *) malloc(sizeof(value) + size); *v = val; - memcpy((void *)v + sizeof(value), aux_str, size); + memcpy((char *)v + sizeof(value), aux_str, size); caml_register_global_root(v); return wrap_capsule(v, "ocaml-capsule", camldestr_capsule); } @@ -521,15 +603,7 @@ static void * caml_aux(PyObject *obj) { value *v = (value *) unwrap_capsule(obj, "ocaml-closure"); - return (void *) v + sizeof(value); -} - -void -pyml_assert_initialized() -{ - if (!version_major) { - failwith("Run 'Py.initialize ()' first"); - } + return (char *) v + sizeof(value); } void @@ -537,7 +611,7 @@ pyml_assert_python2() { if (version_major != 2) { pyml_assert_initialized(); - failwith("Python 2 needed"); + caml_failwith("Python 2 needed"); } } @@ -546,7 +620,7 @@ pyml_assert_ucs2() { if (ucs != UCS2) { pyml_assert_initialized(); - failwith("Python with UCS2 needed"); + caml_failwith("Python with UCS2 needed"); } } @@ -555,7 +629,7 @@ pyml_assert_ucs4() { if (ucs != UCS4) { pyml_assert_initialized(); - failwith("Python with UCS4 needed"); + caml_failwith("Python with UCS4 needed"); } } @@ -564,7 +638,7 @@ pyml_assert_python3() { if (version_major != 3) { pyml_assert_initialized(); - failwith("Python 3 needed"); + caml_failwith("Python 3 needed"); } } @@ -575,16 +649,16 @@ pyml_check_symbol_available(void *symbol, char *symbol_name) char *fmt = "Symbol unavailable with this version of Python: %s.\n"; ssize_t size = snprintf(NULL, 0, fmt, symbol_name); if (size < 0) { - failwith("Symbol unavailable with this version of Python.\n"); + caml_failwith("Symbol unavailable with this version of Python.\n"); return; } char *msg = xmalloc(size + 1); size = snprintf(msg, size + 1, fmt, symbol_name); if (size < 0) { - failwith("Symbol unavailable with this version of Python.\n"); + caml_failwith("Symbol unavailable with this version of Python.\n"); return; } - failwith(msg); + caml_failwith(msg); } } @@ -652,6 +726,51 @@ pyml_wrap_closure(value name, value docstring, value closure) int debug_build; +int trace_refs_build; + +static void +guess_debug_build() +{ + PyObject *sysconfig = Python_PyImport_ImportModule("sysconfig"); + if (!sysconfig) { + caml_failwith("Cannot import sysconfig"); + } + PyObject *get_config_var = + Python_PyObject_GetAttrString(sysconfig, "get_config_var"); + assert(get_config_var); + PyObject *args; + PyObject *py_debug; + PyObject *debug_build_py; + char *py_debug_str = "Py_DEBUG"; + if (version_major >= 3) { + py_debug = Python3_PyUnicode_FromStringAndSize(py_debug_str, 8); + } + else { + py_debug = Python2_PyString_FromStringAndSize(py_debug_str, 8); + } + assert(py_debug); + args = singleton(py_debug); + debug_build_py = Python_PyObject_Call(get_config_var, args, NULL); + assert(debug_build_py); + if (debug_build_py == Python__Py_NoneStruct) { + debug_build = 0; + } + else { + if (version_major >= 3) { + debug_build = Python_PyLong_AsLong(debug_build_py); + } + else { + debug_build = Python2_PyInt_AsLong(debug_build_py); + } + if (debug_build == -1) { + caml_failwith("Cannot check for debug build"); + } + } + Py_DECREF(args); + Py_DECREF(get_config_var); + Py_DECREF(sysconfig); +} + CAMLprim value py_load_library(value filename_ocaml, value debug_build_ocaml) { @@ -660,7 +779,7 @@ py_load_library(value filename_ocaml, value debug_build_ocaml) const char *filename = String_val(Field(filename_ocaml, 0)); library = open_library(filename); if (!library) { - failwith("Library not found"); + caml_failwith(get_library_error()); } } else { @@ -668,7 +787,7 @@ py_load_library(value filename_ocaml, value debug_build_ocaml) } Python_Py_GetVersion = find_symbol(library, "Py_GetVersion"); if (!Python_Py_GetVersion) { - failwith("No Python symbol"); + caml_failwith("No Python symbol"); } const char *version = Python_Py_GetVersion(); version_major = version[0] - '0'; @@ -686,6 +805,7 @@ py_load_library(value filename_ocaml, value debug_build_ocaml) Python_PyObject_CallMethodObjArgs = resolve("PyObject_CallMethodObjArgs"); Python_PyErr_Fetch = resolve("PyErr_Fetch"); + Python_PyErr_Restore = resolve("PyErr_Restore"); Python_PyErr_NormalizeException = resolve("PyErr_NormalizeException"); Python_PyObject_AsCharBuffer = resolve_optional("PyObject_AsCharBuffer"); Python_PyObject_AsReadBuffer = resolve_optional("PyObject_AsReadBuffer"); @@ -700,6 +820,9 @@ py_load_library(value filename_ocaml, value debug_build_ocaml) } Python_PyLong_FromString = resolve("PyLong_FromString"); Python_PyMem_Free = resolve("PyMem_Free"); + Python_PyThreadState_Get = resolve("PyThreadState_Get"); + Python_PyFrame_New = resolve("PyFrame_New"); + Python_PyCode_NewEmpty = resolve("PyCode_NewEmpty"); if (version_major >= 3) { Python__Py_wfopen = resolve_optional("_Py_wfopen"); /* Python >=3.10 */ Python__Py_fopen = resolve_optional("_Py_fopen"); @@ -719,49 +842,19 @@ py_load_library(value filename_ocaml, value debug_build_ocaml) } #include "pyml_dlsyms.inc" Python_Py_Initialize(); + PyObject *sys = Python_PyImport_ImportModule("sys"); + if (!sys) { + caml_failwith("cannot import module sys"); + } + trace_refs_build = Python_PyObject_HasAttrString(sys, "getobjects"); if (Is_block(debug_build_ocaml)) { debug_build = Int_val(Field(debug_build_ocaml, 0)); } else { - PyObject *sysconfig = Python_PyImport_ImportModule("sysconfig"); - PyObject *get_config_var = - Python_PyObject_GetAttrString(sysconfig, "get_config_var"); - PyObject *args; - PyObject *py_debug; - PyObject *debug_build_py; - char *py_debug_str = "Py_DEBUG"; - if (version_major >= 3) { - py_debug = Python3_PyUnicode_FromStringAndSize(py_debug_str, 8); - } - else { - py_debug = Python2_PyString_FromStringAndSize(py_debug_str, 8); - } - if (!py_debug) { - failwith("py_debug"); - } - args = Python_PyTuple_New(1); - if (!args) { - failwith("PyTuple_New"); - } - if (Python_PyTuple_SetItem(args, 0, py_debug)) { - failwith("PyTuple_SetItem"); - } - debug_build_py = - Python_PyEval_CallObjectWithKeywords(get_config_var, args, NULL); - if (!debug_build_py) { - failwith("PyEval_CallObjectWithKeywords"); - } - if (version_major >= 3) { - debug_build = Python_PyLong_AsLong(debug_build_py); - } - else { - debug_build = Python2_PyInt_AsLong(debug_build_py); - } - if (debug_build == -1) { - failwith("AsLong"); - } + guess_debug_build(); } tuple_empty = Python_PyTuple_New(0); + caml_register_custom_operations(&pyops); CAMLreturn(Val_unit); } @@ -772,7 +865,7 @@ struct PyObjectDebug { }; PyObjectDescr *pyobjectdescr(PyObject *obj) { - if (debug_build) { + if (trace_refs_build) { return &((struct PyObjectDebug *) obj)->descr; } else { @@ -807,7 +900,7 @@ py_unsetenv(value name_ocaml) CAMLparam1(name_ocaml); const char *name = String_val(name_ocaml); if (unsetenv(name) == -1) { - failwith(strerror(errno)); + caml_failwith(strerror(errno)); } CAMLreturn(Val_unit); } @@ -1084,7 +1177,7 @@ pyml_capsule_check(value v) { CAMLparam1(v); pyml_assert_initialized(); - PyObject *o = getcustom(v); + PyObject *o = pyml_unwrap(v); PyObject *ob_type = pyobjectdescr(o)->ob_type; int check_result = ob_type == Python_PyCapsule_Type; CAMLreturn(Val_int(check_result)); @@ -1131,6 +1224,26 @@ PyErr_Fetch_wrapper(value unit) CAMLreturn(result); } +// PyErr_Restore steals the references. +// https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Restore +// However the objects can be null, so we do not want to run Py_INCREF if +// this is the case as this would trigger some segfaults. +CAMLprim value +PyErr_Restore_wrapper(value arg0_ocaml, value arg1_ocaml, value arg2_ocaml) +{ + CAMLparam3(arg0_ocaml, arg1_ocaml, arg2_ocaml); + pyml_assert_initialized(); + PyObject *arg0 = pyml_unwrap(arg0_ocaml); + if (arg0) Py_INCREF(arg0); + PyObject *arg1 = pyml_unwrap(arg1_ocaml); + if (arg1) Py_INCREF(arg1); + PyObject *arg2 = pyml_unwrap(arg2_ocaml); + if (arg2) Py_INCREF(arg2); + Python_PyErr_Restore(arg0, arg1, arg2); + CAMLreturn(Val_unit); +} + + CAMLprim value pyml_wrap_string_option(const char *s) { @@ -1178,7 +1291,7 @@ wide_string_of_string(const char *s) exit(EXIT_FAILURE); } wchar_t *ws = xmalloc((n + 1) * sizeof (wchar_t)); - mbstowcs(ws, s, n); + mbstowcs(ws, s, n + 1); return ws; } @@ -1302,7 +1415,9 @@ open_file(value file, const char *mode) } else if (Python__Py_wfopen != NULL) { wchar_t *wide_filename = wide_string_of_string(filename); - result = Python__Py_wfopen(wide_filename, mode); + wchar_t *wide_mode = wide_string_of_string(mode); + result = Python__Py_wfopen(wide_filename, wide_mode); + free(wide_mode); free(wide_filename); } else { @@ -1343,7 +1458,7 @@ get_pyarray_type(value numpy_api_ocaml) PyObject *c_api = pyml_unwrap(numpy_api_ocaml); void **PyArray_API = pyml_get_pyarray_api(c_api); PyObject *result = PyArray_API[2]; - CAMLreturn(pyml_wrap(result, true)); + CAMLreturn(pyml_wrap(result, false)); } CAMLprim value @@ -1358,6 +1473,9 @@ pyarray_of_floatarray_wrapper( (PyTypeObject *, int, npy_intp *, int, npy_intp *, void *, int, int, PyObject *) = PyArray_API[93]; npy_intp length = Wosize_val(array_ocaml); + #ifndef ARCH_SIXTYFOUR + length /= 2; + #endif void *data = (double *) array_ocaml; PyTypeObject (*PyArray_SubType) = (PyTypeObject *) pyml_unwrap(array_type_ocaml); @@ -1403,7 +1521,7 @@ Python27_PyCapsule_IsValid_wrapper(value arg0_ocaml, value arg1_ocaml) pyml_assert_initialized(); if (!Python27_PyCapsule_IsValid) { - failwith("PyCapsule_IsValid is only available in Python >2.7"); + caml_failwith("PyCapsule_IsValid is only available in Python >2.7"); } PyObject *arg0 = pyml_unwrap(arg0_ocaml); const char *arg1 = String_val(arg1_ocaml); @@ -1411,4 +1529,22 @@ Python27_PyCapsule_IsValid_wrapper(value arg0_ocaml, value arg1_ocaml) CAMLreturn(Val_int(result)); } +CAMLprim value +pyml_pyframe_new(value filename_ocaml, value funcname_ocaml, value lineno_ocaml) { + CAMLparam3(filename_ocaml, funcname_ocaml, lineno_ocaml); + const char *filename = String_val(filename_ocaml); + const char *funcname = String_val(funcname_ocaml); + int lineno = Int_val(lineno_ocaml); + PyObject *code = Python_PyCode_NewEmpty(filename, funcname, lineno); + PyObject *globals = Python_PyDict_New(); + PyObject *result = Python_PyFrame_New( + Python_PyThreadState_Get(), + code, + globals, + NULL); + Py_DECREF(code); + Py_DECREF(globals); + CAMLreturn(pyml_wrap(result, true)); +} + #include "pyml_wrappers.inc" diff --git a/bundles/pyml/pyml-current/pyml_stubs.h b/bundles/pyml/pyml-current/pyml_stubs.h index 7c3d61d96..64b8b6b68 100644 --- a/bundles/pyml/pyml-current/pyml_stubs.h +++ b/bundles/pyml/pyml-current/pyml_stubs.h @@ -1,12 +1,23 @@ #ifndef _PYML_STUBS_H_ #define _PYML_STUBS_H_ #include -#include +#include +#include +#include /* The following definitions are extracted and simplified from #include */ +/* ssize_t is POSIX and not defined with Visual Studio */ +/* See for instance https://github.com/vlm/asn1c/issues/159 */ +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#else +#include +#endif + typedef ssize_t Py_ssize_t; #define _PyObject_HEAD_EXTRA @@ -104,12 +115,6 @@ pyml_assert_ucs4(); void pyml_assert_python3(); -value -pyml_wrap(PyObject *object, bool steal); - -PyObject * -pyml_unwrap(value v); - /* Numpy */ /* from ndarraytypes.h */ @@ -222,9 +227,37 @@ typedef struct tagPyArrayObject_fields { PyObject *weakreflist; } PyArrayObject_fields; -struct numpy_custom_operations { - struct custom_operations ops; - PyObject *obj; -}; +typedef struct { + int cf_flags; + int cf_feature_version; /* Python >=3.8 */ +} PyCompilerFlags; + +#define Py_TPFLAGS_INT_SUBCLASS (1L<<23) +#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) +#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) +#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) +#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) +#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) +#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) +#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) +#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) + +#define Py_LT 0 +#define Py_LE 1 +#define Py_EQ 2 +#define Py_NE 3 +#define Py_GT 4 +#define Py_GE 5 + +typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); + +typedef struct PyMethodDef { + const char *ml_name; + PyCFunction ml_meth; + int ml_flags; + const char *ml_doc; +} PyMethodDef; + +typedef void (*PyCapsule_Destructor)(PyObject *); #endif /* _PYML_STUBS_H_ */ diff --git a/bundles/pyml/pyml-current/pyml_tests.ml b/bundles/pyml/pyml-current/pyml_tests.ml index 4495b55e4..acf70ec17 100644 --- a/bundles/pyml/pyml-current/pyml_tests.ml +++ b/bundles/pyml/pyml-current/pyml_tests.ml @@ -162,6 +162,65 @@ except Exception as err: Pyml_tests_common.Passed ) +let () = + Pyml_tests_common.add_test + ~title:"ocaml exception with traceback" + (fun () -> + let m = Py.Import.add_module "test" in + let traceback = [ + { Py.Traceback.filename = "file1.ml"; + function_name = "func1"; + line_number = 1}; + { Py.Traceback.filename = "file2.ml"; + function_name = "func2"; + line_number = 2} + ] in + let mywrap _ = + raise (Py.Err_with_traceback (Py.Err.Exception, "Great", traceback)) in + Py.Module.set_function m "mywrap" mywrap; + assert (Py.Run.simple_string " +from test import mywrap +import sys +import traceback +try: + mywrap() + raise Exception('No exception raised') +except Exception as err: + if sys.version_info.major == 3 and sys.version_info.minor >= 7: + if sys.version_info.minor >= 11: + filenames = [ + f.filename for f in + traceback.StackSummary.extract( + traceback.walk_tb(err.__traceback__))] + else: + filenames = [ + f.filename for f in traceback.extract_tb(err.__traceback__)] + assert filenames == ['', 'file2.ml', 'file1.ml'] + assert str(err) == \"Great\" +"); + Pyml_tests_common.Passed + ) + +let () = + Pyml_tests_common.add_test + ~title:"restore with null" + (fun () -> + try + let _ = Py.Run.eval ~start:Py.File " +raise Exception('Great') +" in + Pyml_tests_common.Failed "uncaught exception" + with Py.E (_, value) -> begin + assert (Py.Object.to_string value = "Great"); + match Py.Err.fetched () with + | None -> Pyml_tests_common.Failed "unexpected none" + | Some (err, _args, _traceback) -> + (* Test that using [Py.Err.restore] on null works fine. *) + Py.Err.restore err Py.null Py.null; + Py.Err.clear (); + Pyml_tests_common.Passed + end) + let () = Pyml_tests_common.add_test ~title:"ocaml other exception" @@ -170,7 +229,7 @@ let () = let mywrap _ = raise Exit in Py.Module.set_function m "mywrap" mywrap; try - assert (Py.Run.simple_string " + ignore (Py.Run.eval ~start:File " from test import mywrap try: mywrap() @@ -229,7 +288,7 @@ let () = Pyml_tests_common.Passed; with Py.E (_, value) -> Pyml_tests_common.Failed (Py.Object.to_string value)) -(* + let () = Pyml_tests_common.add_test ~title:"reinitialize" @@ -248,7 +307,7 @@ let () = Py.initialize ~verbose:true ?version ?minor (); Pyml_tests_common.Passed ) -*) + let () = Pyml_tests_common.add_test ~title:"string conversion error" @@ -307,7 +366,8 @@ from test import ocaml_iterator res = 0 for v in ocaml_iterator: res += v "); - let res = Py.Dict.find_string (Py.Eval.get_globals ()) "res" in + let main = Py.Module.get_dict (Py.Import.add_module "__main__") in + let res = Py.Dict.find_string main "res" in assert (Py.Int.to_int res = 14); let iter = Py.Iter.of_list_map Py.String.of_string ["a"; "b"; "c"] in let list = Py.Iter.to_list_map Py.String.to_string iter in @@ -337,7 +397,8 @@ from test import ocaml_iterator2 res = 0 for v in ocaml_iterator2: res += v "); - let res = Py.Dict.find_string (Py.Eval.get_globals ()) "res" in + let main = Py.Module.get_dict (Py.Import.add_module "__main__") in + let res = Py.Dict.find_string main "res" in assert (Py.Int.to_int res = 14); let iter = iter_of_list Py.String.of_string ["a"; "b"; "c"] in let list = Py.Iter.to_list_map Py.String.to_string iter in @@ -638,6 +699,16 @@ let () = assert (Py.Set.size set' = 10); Pyml_tests_common.Passed) +let () = + Pyml_tests_common.add_test + ~title:"serialize" + (fun () -> + let value = Py.String.of_string "hello" in + let pickled = Marshal.to_string value [] in + let unpickled = Marshal.from_string pickled 0 in + assert (Py.String.to_string unpickled = "hello"); + Pyml_tests_common.Passed) + let () = if not !Sys.interactive then Pyml_tests_common.main () diff --git a/bundles/pyml/pyml-current/pyml_tests_common.ml b/bundles/pyml/pyml-current/pyml_tests_common.ml index df2f8da6d..553db2907 100644 --- a/bundles/pyml/pyml-current/pyml_tests_common.ml +++ b/bundles/pyml/pyml-current/pyml_tests_common.ml @@ -61,10 +61,11 @@ let main () = begin match String.length version with 1 -> None, Some (int_of_string version), None - | 3 when version.[1] = '.' -> + | (3 | 4) when version.[1] = '.' -> None, Some (int_of_string (String.sub version 0 1)), - Some (int_of_string (String.sub version 2 1)) + Some + (int_of_string (String.sub version 2 (String.length version - 2))) | _ -> Some version, None, None end | _ -> failwith "Argument should be a version number" in @@ -75,12 +76,14 @@ let main () = show_environment_variable "DYLD_LIBRARY_PATH"; show_environment_variable "DYLD_FALLBACK_LIBRARY_PATH"; prerr_endline "Initializing library..."; - Py.initialize ?library_name ~verbose:true ?version ?minor (); + Py.initialize ?library_name ~verbose:true ?version ?minor ~debug_build:true (); begin match Py.get_library_filename () with None -> prerr_endline "No library has been loaded.\n" | Some filename -> Printf.eprintf "Library \"%s\" has been loaded.\n" filename end; + Format.eprintf "platform: %s@." (Pywrappers.py_getplatform ()); + Format.eprintf "build info: %s@." (Pywrappers.py_getbuildinfo ()); if Py.is_debug_build () then prerr_endline "Debug build." else diff --git a/bundles/pyml/pyml-current/pyml_tests_common.mli b/bundles/pyml/pyml-current/pyml_tests_common.mli index 5eaba4a43..f3f6d0c87 100644 --- a/bundles/pyml/pyml-current/pyml_tests_common.mli +++ b/bundles/pyml/pyml-current/pyml_tests_common.mli @@ -9,4 +9,6 @@ val use_version: (int option * int option) ref val enable_only_on_unix: ('a -> status) -> 'a -> status +val launch_tests : unit -> unit + val main: unit -> unit diff --git a/bundles/pyml/pyml-current/pyops.ml.405 b/bundles/pyml/pyml-current/pyops.ml.405 new file mode 100644 index 000000000..e69de29bb diff --git a/bundles/pyml/pyml-current/pyops.ml b/bundles/pyml/pyml-current/pyops.ml.new similarity index 100% rename from bundles/pyml/pyml-current/pyops.ml rename to bundles/pyml/pyml-current/pyops.ml.new diff --git a/bundles/pyml/pyml-current/pyops.mli.405 b/bundles/pyml/pyml-current/pyops.mli.405 new file mode 100644 index 000000000..e69de29bb diff --git a/bundles/pyml/pyml-current/pyops.mli b/bundles/pyml/pyml-current/pyops.mli.new similarity index 100% rename from bundles/pyml/pyml-current/pyops.mli rename to bundles/pyml/pyml-current/pyops.mli.new diff --git a/bundles/pyml/pyml-current/pyutils.ml b/bundles/pyml/pyml-current/pyutils.ml index 96005dd78..96ebaced1 100644 --- a/bundles/pyml/pyml-current/pyutils.ml +++ b/bundles/pyml/pyml-current/pyutils.ml @@ -4,11 +4,6 @@ let option_find f x = try Some (f x) with Not_found -> None -let option_unwrap option = - match option with - None -> raise Not_found - | Some result -> result - let substring_between string before after = String.sub string before (after - before) @@ -39,10 +34,6 @@ let trim_carriage_return line = else line -let has_prefix prefix s = - let prefix_length = String.length prefix in - String.length s >= prefix_length && String.sub s 0 prefix_length = prefix - let input_lines channel = let accu = ref [] in try @@ -53,15 +44,6 @@ let input_lines channel = with End_of_file -> List.rev !accu -let read_and_close channel f arg = - try - let result = f arg in - close_in channel; - result - with e -> - close_in_noerr channel; - raise e - let write_and_close channel f arg = try let result = f arg in @@ -75,8 +57,7 @@ let with_temp_file contents f = let (file, channel) = Filename.open_temp_file "pyml_tests" ".py" in Fun.protect begin fun () -> write_and_close channel (output_string channel) contents; - let channel = open_in file in - read_and_close channel (f file) channel + Stdcompat.In_channel.with_open_bin file (f file) end ~finally:(fun () -> Sys.remove file) diff --git a/bundles/pyml/pyml-current/pyutils.mli b/bundles/pyml/pyml-current/pyutils.mli index 8ce497b8b..c772029a2 100644 --- a/bundles/pyml/pyml-current/pyutils.mli +++ b/bundles/pyml/pyml-current/pyutils.mli @@ -25,9 +25,6 @@ val trim_carriage_return: string -> string (** If the string ends with ['\r'], then returns the string without this character, else returns the whole string. *) -val has_prefix: string -> string -> bool -(** [has_prefix prefix s] returns [true] if [s] begins with [prefix]. *) - val input_lines: in_channel -> string list (** Reads and returns all the lines from an input channel to the end of file. Carriage return characters are removed from the end of lines if any. *) @@ -36,16 +33,6 @@ val option_find: ('a -> 'b) -> 'a -> 'b option (** [option_find f x] returns [Some (f x)], or [None] if [f x] raises [Not_found]. *) -val option_unwrap: 'a option -> 'a -(** [option_unwrap x] returns [x'] if [x] is [Some x'], and raises - [Not_found] if [x] is [None]. *) - -val read_and_close: in_channel -> ('a -> 'b) -> 'a -> 'b -(** [read_and_close channel f arg] calls [f arg], and returns the result of - [f]. - [channel] is always closed after [f] has been called, even if [f] raises - an exception. *) - val write_and_close: out_channel -> ('a -> 'b) -> 'a -> 'b (** [write_and_close channel f arg] calls [f arg], and returns the result of [f]. diff --git a/configure.ac b/configure.ac index 7db0ececc..a7b96bf05 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,7 @@ AC_CHECK_OCAMLVERSION([OCAMLATLEAST312],[3.12]) AS_IF([test "x$OCAMLATLEAST312" = xno],[AC_MSG_ERROR([OCaml >= 3.12 is required to compile Coccinelle])]) AC_CHECK_OCAMLVERSION([OCAMLATLEAST4020],[4.02]) AC_CHECK_OCAMLVERSION([OCAMLATLEAST4030],[4.03]) +AC_CHECK_OCAMLVERSION([OCAMLATLEAST50],[5.0]) AC_SUBST([OCAMLCORIG],["$OCAMLC"]) AS_IF([test "x$OCAMLC" = xno -o "x$OCAMLDEP" = xno -o "x$OCAMLDOC" = xno -o "x$OCAMLMKLIB" = xno], @@ -147,14 +148,16 @@ AC_COCCI_INIT_PKG_EMPTY([parmap]) dnl required ocaml packages AC_MSG_NOTICE([the following OCaml packages should be provided by your ocaml installation]) AC_REQ_COCCI_STDPKG([unix]) -AC_REQ_COCCI_STDPKG([bigarray]) +AS_IF([test "x$OCAMLATLEAST50" = xno],[AC_REQ_COCCI_STDPKG([bigarray])]) AC_REQ_COCCI_STDPKG([str]) dnl required modules (Some are available locally too) AC_REQ_COCCI_EXTPKG([dynlink]) AC_REQ_COCCI_EXTPKG([parmap]) -AC_REQ_COCCI_EXTPKG([stdcompat]) +dnl AC_REQ_COCCI_EXTPKG([stdcompat]) +AC_SUBST([MAKE_stdcompat],[$COCCI_SRCDIR/bundles/stdcompat]) +AC_SUBST([PATH_stdcompat],[$COCCI_SRCDIR/bundles/stdcompat]) dnl AC_CACHE_SAVE