diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-01 12:07:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-01 12:07:49 +0000 |
commit | 5bc254646f2683c22851ea82f2a9fe40b02f3f93 (patch) | |
tree | 76f6280a5a1b4a8c074b50c4a36da3b213bfa173 /m4 | |
parent | 733b4a4947f50dee6c570ea7f5fe11d4cee807a4 (diff) | |
download | gnunet-5bc254646f2683c22851ea82f2a9fe40b02f3f93.tar.gz gnunet-5bc254646f2683c22851ea82f2a9fe40b02f3f93.zip |
-use test for libunistring from gnulib
Diffstat (limited to 'm4')
-rw-r--r-- | m4/absolute-header.m4 | 77 | ||||
-rw-r--r-- | m4/libunistring.m4 | 150 |
2 files changed, 227 insertions, 0 deletions
diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4 new file mode 100644 index 000000000..f576d3427 --- /dev/null +++ b/m4/absolute-header.m4 | |||
@@ -0,0 +1,77 @@ | |||
1 | # absolute-header.m4 serial 12 | ||
2 | dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl From Derek Price. | ||
8 | |||
9 | # gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...) | ||
10 | # --------------------------------------- | ||
11 | # Find the absolute name of a header file, testing first if the header exists. | ||
12 | # If the header were sys/inttypes.h, this macro would define | ||
13 | # ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h | ||
14 | # in config.h | ||
15 | # (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"'). | ||
16 | # The three "///" are to pacify Sun C 5.8, which otherwise would say | ||
17 | # "warning: #include of /usr/include/... may be non-portable". | ||
18 | # Use `""', not `<>', so that the /// cannot be confused with a C99 comment. | ||
19 | # Note: This macro assumes that the header file is not empty after | ||
20 | # preprocessing, i.e. it does not only define preprocessor macros but also | ||
21 | # provides some type/enum definitions or function/variable declarations. | ||
22 | AC_DEFUN([gl_ABSOLUTE_HEADER], | ||
23 | [AC_REQUIRE([AC_CANONICAL_HOST]) | ||
24 | AC_LANG_PREPROC_REQUIRE()dnl | ||
25 | m4_foreach_w([gl_HEADER_NAME], [$1], | ||
26 | [AS_VAR_PUSHDEF([gl_absolute_header], | ||
27 | [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl | ||
28 | AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>], | ||
29 | m4_defn([gl_absolute_header]), | ||
30 | [AS_VAR_PUSHDEF([ac_header_exists], | ||
31 | [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl | ||
32 | AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl | ||
33 | if test AS_VAR_GET(ac_header_exists) = yes; then | ||
34 | gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME])) | ||
35 | fi | ||
36 | AS_VAR_POPDEF([ac_header_exists])dnl | ||
37 | ])dnl | ||
38 | AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])), | ||
39 | ["AS_VAR_GET(gl_absolute_header)"], | ||
40 | [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.]) | ||
41 | AS_VAR_POPDEF([gl_absolute_header])dnl | ||
42 | ])dnl | ||
43 | ])# gl_ABSOLUTE_HEADER | ||
44 | |||
45 | # gl_ABSOLUTE_HEADER_ONE(HEADER) | ||
46 | # ------------------------------ | ||
47 | # Like gl_ABSOLUTE_HEADER, except that: | ||
48 | # - it assumes that the header exists, | ||
49 | # - it uses the current CPPFLAGS, | ||
50 | # - it does not cache the result, | ||
51 | # - it is silent. | ||
52 | AC_DEFUN([gl_ABSOLUTE_HEADER_ONE], | ||
53 | [ | ||
54 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])]) | ||
55 | dnl AIX "xlc -E" and "cc -E" omit #line directives for header files | ||
56 | dnl that contain only a #include of other header files and no | ||
57 | dnl non-comment tokens of their own. This leads to a failure to | ||
58 | dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h> | ||
59 | dnl and others. The workaround is to force preservation of comments | ||
60 | dnl through option -C. This ensures all necessary #line directives | ||
61 | dnl are present. GCC supports option -C as well. | ||
62 | case "$host_os" in | ||
63 | aix*) gl_absname_cpp="$ac_cpp -C" ;; | ||
64 | *) gl_absname_cpp="$ac_cpp" ;; | ||
65 | esac | ||
66 | dnl eval is necessary to expand gl_absname_cpp. | ||
67 | dnl Ultrix and Pyramid sh refuse to redirect output of eval, | ||
68 | dnl so use subshell. | ||
69 | AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]), | ||
70 | [`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | | ||
71 | sed -n '\#/$1#{ | ||
72 | s#.*"\(.*/$1\)".*#\1# | ||
73 | s#^/[^/]#//&# | ||
74 | p | ||
75 | q | ||
76 | }'`]) | ||
77 | ]) | ||
diff --git a/m4/libunistring.m4 b/m4/libunistring.m4 new file mode 100644 index 000000000..c1bf4d553 --- /dev/null +++ b/m4/libunistring.m4 | |||
@@ -0,0 +1,150 @@ | |||
1 | # libunistring.m4 serial 11 | ||
2 | dnl Copyright (C) 2009-2012 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl gl_LIBUNISTRING | ||
8 | dnl Searches for an installed libunistring. | ||
9 | dnl If found, it sets and AC_SUBSTs HAVE_LIBUNISTRING=yes and the LIBUNISTRING | ||
10 | dnl and LTLIBUNISTRING variables, sets the LIBUNISTRING_VERSION variable, and | ||
11 | dnl augments the CPPFLAGS variable, and #defines HAVE_LIBUNISTRING to 1. | ||
12 | dnl Otherwise, it sets and AC_SUBSTs HAVE_LIBUNISTRING=no and LIBUNISTRING and | ||
13 | dnl LTLIBUNISTRING to empty. | ||
14 | |||
15 | dnl Define gl_LIBUNISTRING using AC_DEFUN_ONCE for Autoconf >= 2.64, in order | ||
16 | dnl to avoid warnings like | ||
17 | dnl "warning: AC_REQUIRE: `gl_LIBUNISTRING' was expanded before it was required". | ||
18 | dnl This is tricky because of the way 'aclocal' is implemented: | ||
19 | dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. | ||
20 | dnl Otherwise aclocal's initial scan pass would miss the macro definition. | ||
21 | dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. | ||
22 | dnl Otherwise aclocal would emit many "Use of uninitialized value $1" | ||
23 | dnl warnings. | ||
24 | m4_define([gl_libunistring_AC_DEFUN], | ||
25 | m4_version_prereq([2.64], | ||
26 | [[AC_DEFUN_ONCE( | ||
27 | [$1], [$2])]], | ||
28 | [m4_ifdef([gl_00GNULIB], | ||
29 | [[AC_DEFUN_ONCE( | ||
30 | [$1], [$2])]], | ||
31 | [[AC_DEFUN( | ||
32 | [$1], [$2])]])])) | ||
33 | gl_libunistring_AC_DEFUN([gl_LIBUNISTRING], | ||
34 | [ | ||
35 | AC_BEFORE([$0], [gl_LIBUNISTRING_MODULE]) | ||
36 | AC_BEFORE([$0], [gl_LIBUNISTRING_LIBHEADER]) | ||
37 | AC_BEFORE([$0], [gl_LIBUNISTRING_LIB_PREPARE]) | ||
38 | |||
39 | m4_ifdef([gl_LIBUNISTRING_OPTIONAL], | ||
40 | [ | ||
41 | AC_MSG_CHECKING([whether included libunistring is requested]) | ||
42 | AC_ARG_WITH([included-libunistring], | ||
43 | [ --with-included-libunistring use the libunistring parts included here], | ||
44 | [gl_libunistring_force_included=$withval], | ||
45 | [gl_libunistring_force_included=no]) | ||
46 | AC_MSG_RESULT([$gl_libunistring_force_included]) | ||
47 | gl_libunistring_use_included="$gl_libunistring_force_included" | ||
48 | if test "$gl_libunistring_use_included" = yes; then | ||
49 | dnl Assume that libunistring is not installed until some other macro | ||
50 | dnl explicitly invokes gl_LIBUNISTRING_CORE. | ||
51 | if test -z "$HAVE_LIBUNISTRING"; then | ||
52 | HAVE_LIBUNISTRING=no | ||
53 | fi | ||
54 | LIBUNISTRING= | ||
55 | LTLIBUNISTRING= | ||
56 | else | ||
57 | gl_LIBUNISTRING_CORE | ||
58 | if test $HAVE_LIBUNISTRING = no; then | ||
59 | gl_libunistring_use_included=yes | ||
60 | LIBUNISTRING= | ||
61 | LTLIBUNISTRING= | ||
62 | fi | ||
63 | fi | ||
64 | ], | ||
65 | [gl_LIBUNISTRING_CORE]) | ||
66 | ]) | ||
67 | |||
68 | AC_DEFUN([gl_LIBUNISTRING_CORE], | ||
69 | [ | ||
70 | AC_REQUIRE([AM_ICONV]) | ||
71 | if test -n "$LIBICONV"; then | ||
72 | dnl First, try to link without -liconv. libunistring often depends on | ||
73 | dnl libiconv, but we don't know (and often don't need to know) where | ||
74 | dnl libiconv is installed. | ||
75 | AC_LIB_HAVE_LINKFLAGS([unistring], [], | ||
76 | [#include <uniconv.h>], [u8_strconv_from_locale((char*)0);], | ||
77 | [no, trying again together with libiconv]) | ||
78 | if test "$ac_cv_libunistring" != yes; then | ||
79 | dnl Second try, with -liconv. | ||
80 | dnl We have to erase the cached result of the first AC_LIB_HAVE_LINKFLAGS | ||
81 | dnl invocation, otherwise the second one will not be run. | ||
82 | unset ac_cv_libunistring | ||
83 | glus_save_LIBS="$LIBS" | ||
84 | LIBS="$LIBS $LIBICONV" | ||
85 | AC_LIB_HAVE_LINKFLAGS([unistring], [], | ||
86 | [#include <uniconv.h>], [u8_strconv_from_locale((char*)0);], | ||
87 | [no, consider installing GNU libunistring]) | ||
88 | if test -n "$LIBUNISTRING"; then | ||
89 | LIBUNISTRING="$LIBUNISTRING $LIBICONV" | ||
90 | LTLIBUNISTRING="$LTLIBUNISTRING $LTLIBICONV" | ||
91 | fi | ||
92 | LIBS="$glus_save_LIBS" | ||
93 | fi | ||
94 | else | ||
95 | AC_LIB_HAVE_LINKFLAGS([unistring], [], | ||
96 | [#include <uniconv.h>], [u8_strconv_from_locale((char*)0);], | ||
97 | [no, consider installing GNU libunistring]) | ||
98 | fi | ||
99 | if test $HAVE_LIBUNISTRING = yes; then | ||
100 | dnl Determine the installed version. | ||
101 | AC_CACHE_CHECK([for libunistring version], [gl_cv_libunistring_version], | ||
102 | [AC_COMPUTE_INT([gl_libunistring_hexversion], | ||
103 | [_LIBUNISTRING_VERSION], | ||
104 | [#include <unistring/version.h>]) | ||
105 | dnl Versions <= 0.9.3 had a hexversion of 0x0009. | ||
106 | dnl Use other tests to distinguish them. | ||
107 | if test $gl_libunistring_hexversion = 9; then | ||
108 | dnl Version 0.9.2 introduced the header <unistring/cdefs.h>. | ||
109 | AC_COMPILE_IFELSE( | ||
110 | [AC_LANG_PROGRAM([[#include <unistring/cdefs.h>]], [[]])], | ||
111 | [gl_cv_libunistring_version092=true], | ||
112 | [gl_cv_libunistring_version092=false]) | ||
113 | if $gl_cv_libunistring_version092; then | ||
114 | dnl Version 0.9.3 changed a comment in <unistr.h>. | ||
115 | gl_ABSOLUTE_HEADER_ONE([unistr.h]) | ||
116 | if test -n "$gl_cv_absolute_unistr_h" \ | ||
117 | && grep 'Copy no more than N units of SRC to DEST. Return a pointer' $gl_cv_absolute_unistr_h > /dev/null; then | ||
118 | dnl Detected version 0.9.3. | ||
119 | gl_libunistring_hexversion=2307 | ||
120 | else | ||
121 | dnl Detected version 0.9.2. | ||
122 | gl_libunistring_hexversion=2306 | ||
123 | fi | ||
124 | else | ||
125 | dnl Version 0.9.1 introduced the type casing_suffix_context_t. | ||
126 | AC_COMPILE_IFELSE( | ||
127 | [AC_LANG_PROGRAM( | ||
128 | [[#include <unicase.h> | ||
129 | casing_suffix_context_t ct;]], | ||
130 | [[]])], | ||
131 | [gl_cv_libunistring_version091=true], | ||
132 | [gl_cv_libunistring_version091=false]) | ||
133 | if $gl_cv_libunistring_version091; then | ||
134 | dnl Detected version 0.9.1. | ||
135 | gl_libunistring_hexversion=2305 | ||
136 | else | ||
137 | dnl Detected version 0.9. | ||
138 | gl_libunistring_hexversion=2304 | ||
139 | fi | ||
140 | fi | ||
141 | fi | ||
142 | dnl Transform into the usual major.minor.subminor notation. | ||
143 | gl_libunistring_major=`expr $gl_libunistring_hexversion / 65536` | ||
144 | gl_libunistring_minor=`expr $gl_libunistring_hexversion / 256 % 256` | ||
145 | gl_libunistring_subminor=`expr $gl_libunistring_hexversion % 256` | ||
146 | gl_cv_libunistring_version="$gl_libunistring_major.$gl_libunistring_minor.$gl_libunistring_subminor" | ||
147 | ]) | ||
148 | LIBUNISTRING_VERSION="$gl_cv_libunistring_version" | ||
149 | fi | ||
150 | ]) | ||