summaryrefslogtreecommitdiff
path: root/m4/libunistring.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-05-18 20:11:42 +0200
committerBruno Haible <bruno@clisp.org>2010-05-18 20:13:13 +0200
commit1495c20d059a7bf8cae0ad51bc576f4c458674e1 (patch)
tree0fb4950e04afb6de2fde50902330d04ecafaeb1f /m4/libunistring.m4
parent68e3d00f99416b0d007e9ef9c7841488ea696e3d (diff)
downloadgnulib-1495c20d059a7bf8cae0ad51bc576f4c458674e1.tar.gz
New module 'libunistring-optional'.
Diffstat (limited to 'm4/libunistring.m4')
-rw-r--r--m4/libunistring.m491
1 files changed, 87 insertions, 4 deletions
diff --git a/m4/libunistring.m4 b/m4/libunistring.m4
index 0faedb9476..7a10efec79 100644
--- a/m4/libunistring.m4
+++ b/m4/libunistring.m4
@@ -1,4 +1,4 @@
-# libunistring.m4 serial 5
+# libunistring.m4 serial 6
dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,12 +7,48 @@ dnl with or without modifications, as long as this notice is preserved.
dnl gl_LIBUNISTRING
dnl Searches for an installed libunistring.
dnl If found, it sets and AC_SUBSTs HAVE_LIBUNISTRING=yes and the LIBUNISTRING
-dnl and LTLIBUNISTRING variables and augments the CPPFLAGS variable, and
-dnl #defines HAVE_LIBUNISTRING to 1. Otherwise, it sets and AC_SUBSTs
-dnl HAVE_LIBUNISTRING=no and LIBUNISTRING and LTLIBUNISTRING to empty.
+dnl and LTLIBUNISTRING variables, sets the LIBUNISTRING_VERSION variable, and
+dnl augments the CPPFLAGS variable, and #defines HAVE_LIBUNISTRING to 1.
+dnl Otherwise, it sets and AC_SUBSTs HAVE_LIBUNISTRING=no and LIBUNISTRING and
+dnl LTLIBUNISTRING to empty.
AC_DEFUN([gl_LIBUNISTRING],
[
+ AC_BEFORE([$0], [gl_LIBUNISTRING_LIBSOURCE])
+ AC_BEFORE([$0], [gl_LIBUNISTRING_LIBHEADER])
+ AC_BEFORE([$0], [gl_LIBUNISTRING_LIB_PREPARE])
+
+ m4_ifdef([gl_LIBUNISTRING_OPTIONAL],
+ [
+ AC_MSG_CHECKING([whether included libunistring is requested])
+ AC_ARG_WITH([included-libunistring],
+ [ --with-included-libunistring use the libunistring parts included here],
+ [gl_libunistring_force_included=$withval],
+ [gl_libunistring_force_included=no])
+ AC_MSG_RESULT([$gl_libunistring_force_included])
+ gl_libunistring_use_included="$gl_libunistring_force_included"
+ if test "$gl_libunistring_use_included" = yes; then
+ dnl Assume that libunistring is not installed until some other macro
+ dnl explicitly invokes gl_LIBUNISTRING_CORE.
+ if test -z "$HAVE_LIBUNISTRING"; then
+ HAVE_LIBUNISTRING=no
+ fi
+ LIBUNISTRING=
+ LTLIBUNISTRING=
+ else
+ gl_LIBUNISTRING_CORE
+ if test $HAVE_LIBUNISTRING = no; then
+ gl_libunistring_use_included=yes
+ LIBUNISTRING=
+ LTLIBUNISTRING=
+ fi
+ fi
+ ],
+ [gl_LIBUNISTRING_CORE])
+])
+
+AC_DEFUN([gl_LIBUNISTRING_CORE],
+[
AC_REQUIRE([AM_ICONV])
if test -n "$LIBICONV"; then
dnl First, try to link without -liconv. libunistring often depends on
@@ -42,4 +78,51 @@ AC_DEFUN([gl_LIBUNISTRING],
[#include <uniconv.h>], [u8_strconv_from_locale((char*)0);],
[no, consider installing GNU libunistring])
fi
+ if test $HAVE_LIBUNISTRING = yes; then
+ dnl Determine the installed version.
+ AC_CACHE_CHECK([for libunistring version], [gl_cv_libunistring_version],
+ [AC_COMPUTE_INT([gl_libunistring_hexversion],
+ [_LIBUNISTRING_VERSION],
+ [#include <unistring/version.h>])
+ dnl Versions <= 0.9.3 had a hexversion of 0x0009.
+ dnl Use other tests to distinguish them.
+ if test $gl_libunistring_hexversion = 9; then
+ dnl Version 0.9.2 introduced the header <unistring/cdefs.h>.
+ AC_TRY_COMPILE([#include <unistring/cdefs.h>], ,
+ [gl_cv_libunistring_version092=true],
+ [gl_cv_libunistring_version092=false]);
+ if $gl_cv_libunistring_version092; then
+ dnl Version 0.9.3 changed a comment in <unistr.h>.
+ gl_ABSOLUTE_HEADER_ONE([unistr.h])
+ if test -n "$gl_cv_absolute_unistr_h" \
+ && grep 'Copy no more than N units of SRC to DEST. Return a pointer' $gl_cv_absolute_unistr_h > /dev/null; then
+ dnl Detected version 0.9.3.
+ gl_libunistring_hexversion=2307
+ else
+ dnl Detected version 0.9.2.
+ gl_libunistring_hexversion=2306
+ fi
+ else
+ dnl Version 0.9.1 introduced the type casing_suffix_context_t.
+ AC_TRY_COMPILE([#include <unicase.h>
+ casing_suffix_context_t ct;], ,
+ [gl_cv_libunistring_version091=true],
+ [gl_cv_libunistring_version091=false])
+ if $gl_cv_libunistring_version091; then
+ dnl Detected version 0.9.1.
+ gl_libunistring_hexversion=2305
+ else
+ dnl Detected version 0.9.
+ gl_libunistring_hexversion=2304
+ fi
+ fi
+ fi
+ dnl Transform into the usual major.minor.subminor notation.
+ gl_libunistring_major=`expr $gl_libunistring_hexversion / 65536`
+ gl_libunistring_minor=`expr $gl_libunistring_hexversion / 256 % 256`
+ gl_libunistring_subminor=`expr $gl_libunistring_hexversion % 256`
+ gl_cv_libunistring_version="$gl_libunistring_major.$gl_libunistring_minor.$gl_libunistring_subminor"
+ ])
+ LIBUNISTRING_VERSION="$gl_cv_libunistring_version"
+ fi
])