+])
+
+dnl GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT
+dnl
+dnl Check whether libunistring has iconv support. When it lacks iconv
+dnl support, `mem_iconveh' returns -1 (ENOSYS) and conversions from one
+dnl codeset to another do not work.
+AC_DEFUN([GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT], [
+ AC_CACHE_CHECK([whether libunistring was built with iconv support],
+ [ac_cv_libunistring_with_iconv_support], [
+ save_LIBS=$LIBS
+ LIBS="$LIBS $LIBUNISTRING"
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <uniconv.h>
+ #include <unistring/iconveh.h>
+ int
+ main (int argc, char *argv[])
+ {
+ size_t result_size;
+ return (NULL == u32_conv_from_encoding ("ASCII", iconveh_question_mark,
+ "a", 1,
+ NULL, NULL, &result_size));
+ }
+ ]])],
+ [ac_cv_libunistring_with_iconv_support=yes],
+ [ac_cv_libunistring_with_iconv_support=no],
+ [ac_cv_libunistring_with_iconv_support=yes])
+ LIBS=$save_LIBS
+ ])
+])
+
+dnl GUILE_UNISTRING_CONSTANT NAME
+dnl
+dnl Determine the compile-time value of NAME and define/substitute
+dnl `SCM_I_GSC_NAME'.
+AC_DEFUN([GUILE_UNISTRING_CONSTANT], [
+ m4_pushdef([UPPER_CASE_NAME],
+ [m4_translit([$1],[abcdefghijklmnopqrstuvwxyz],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
+
+ AC_CACHE_CHECK([the value of `$1'], [ac_cv_]$1, [
+ AC_COMPUTE_INT([ac_cv_]$1, [$1],
+ [AC_INCLUDES_DEFAULT
+#include <uniconv.h>
+],
+ [AC_MSG_ERROR([failed to determine the value of `$1'])])
+ ])
+
+ [SCM_I_GSC_]UPPER_CASE_NAME="$ac_cv_[]$1"
+ AC_SUBST([SCM_I_GSC_]UPPER_CASE_NAME)
+ m4_popdef([UPPER_CASE_NAME])])
+
+dnl GUILE_UNISTRING_ICONVEH_VALUES
+dnl
+dnl Determine the values of the `iconveh_' libunistring constants.
+AC_DEFUN([GUILE_UNISTRING_ICONVEH_VALUES], [
+ GUILE_UNISTRING_CONSTANT([iconveh_error])
+ GUILE_UNISTRING_CONSTANT([iconveh_question_mark])
+ GUILE_UNISTRING_CONSTANT([iconveh_escape_sequence])
+])
+
+dnl GUILE_CHECK_VERSION
+dnl
+dnl Ensure that $GUILE_FOR_BUILD has the same version as ourselves.
+AC_DEFUN([GUILE_CHECK_VERSION], [
+ if ! "$GUILE_FOR_BUILD" --version > /dev/null 2>&1; then
+ AC_MSG_ERROR([failed to run `$GUILE_FOR_BUILD'])
+ fi
+
+ dnl Use MAJOR.MINOR.MICRO instead of (version) so that developers can
+ dnl freely shoot themselves in the foot by using, say, 2.0.3.80 and
+ dnl 2.0.3.42.
+ AC_CACHE_CHECK([the version of $GUILE_FOR_BUILD],
+ [ac_cv_guile_for_build_version],
+ [ac_cv_guile_for_build_version="`"$GUILE_FOR_BUILD" \
+ -c '(format #t "~a.~a.~a" (major-version) (minor-version) (micro-version))'`"
+ ])
+
+ if test "$ac_cv_guile_for_build_version" != \
+ "$GUILE_MAJOR_VERSION.$GUILE_MINOR_VERSION.$GUILE_MICRO_VERSION"
+ then
+ AC_MSG_ERROR([building Guile $PACKAGE_VERSION but `$GUILE_FOR_BUILD' has version $ac_cv_guile_for_build_version"])
+ fi
+])
+
+dnl GUILE_CHECK_GUILE_FOR_BUILD
+dnl
+dnl When cross-compiling, ensure that $GUILE_FOR_BUILD is suitable.
+AC_DEFUN([GUILE_CHECK_GUILE_FOR_BUILD], [
+ if test "$cross_compiling" = "yes"; then
+ if test "x$GUILE_FOR_BUILD" = "x"; then
+ AC_PATH_PROG([GUILE_FOR_BUILD], [guile], [not-found])
+ if test "$GUILE_FOR_BUILD" = "not-found"; then
+ AC_MSG_ERROR([a native Guile $PACKAGE_VERSION is required to cross-build Guile])
+ fi
+ fi
+ AC_MSG_CHECKING([guile for build])
+ AC_MSG_RESULT([$GUILE_FOR_BUILD])
+
+ dnl Since there is currently no distinction between the run-time
+ dnl search path, %load-path, and the compiler's search path,
+ dnl $GUILE_FOR_BUILD must be a native build of the very same version.
+ GUILE_CHECK_VERSION
+ else
+ GUILE_FOR_BUILD='this-value-will-never-be-used'
+ fi