Debian Codegraph @

ext/charconv/charconv.ac

raw
1 dnl
2 dnl Configure ext/charconv
3 dnl This file is included by the toplevel configure.ac
4 dnl
5
6 # ext/charconv --------------------------------------------
7
8 dnl
9 dnl process with-iconv, with-iconv-lib
10 dnl
11
12 dnl Use iconv unless explicitly specified otherwise
13 ac_cv_use_iconv=yes
14 ICONV_NAME=iconv
15 ICONV_LIB=
16 ICONV_CPPFLAGS=
17 ICONV_LDFLAGS=
18
19 AC_ARG_WITH(iconv,
20 AS_HELP_STRING([--with-iconv=PATH],
21 [Use iconv library installed under PATH.
22 Gauche's charconv module uses iconv if it is available.
23 If your system has iconv library in non-trivial location,
24 specify this option. The include file is looked for in PATH/include,
25 and the library file is looked for in PATH/lib.
26 If you don't want to use iconv for some reason, say --without-iconv. ]),
27 [
28 AS_CASE([$with_iconv],
29 [no], [ac_cv_use_iconv=no],
30 [yes], [],
31 [ICONV_CPPFLAGS="-I$with_iconv/include"
32 ICONV_LDFLAGS="-L$with_iconv/lib"])
33 ])
34
35 AC_ARG_WITH(iconv-lib,
36 AS_HELP_STRING([--with-iconv-lib=LIB],
37 [If your system needs to use external library for iconv
38 and whose name is not libiconv, specify it.
39 For example, if you need -lconv to use iconv, say --with-iconv-lib=conv]),
40 [
41 ICONV_NAME="$with_iconv_lib"; ICONV_LIB="-l$with_iconv_lib"
42 ])
43
44 dnl
45 dnl Check iconv.h
46 dnl
47
48 AS_IF([test "$ac_cv_use_iconv" != no], [
49 save_cppflags=$CPPFLAGS
50 CPPFLAGS="$CPPFLAGS $ICONV_CPPFLAGS"
51 AC_CHECK_HEADER($ICONV_NAME.h,
52 AC_DEFINE(HAVE_ICONV_H,1,[Define if you have iconv.h and want to use it]),
53 [AC_MSG_WARN("Can't find $ICONV_NAME.h so I turned off using iconv; you may want to use --with-iconv=PATH.")
54 ac_cv_use_iconv=no])
55 CPPFLAGS=$save_cppflags])
56
57 dnl
58 dnl Check iconv library, if it is not specified by --with-iconv-lib.
59 dnl
60
61 AS_IF([test "$ac_cv_use_iconv" = yes], [
62 AS_IF([test "$ICONV_LIB" = ""], [
63 save_cflags="$CFLAGS"
64 save_ldflags="$LDFLAGS"
65 save_libs="$LIBS"
66 CFLAGS="$CFLAGS $ICONV_CPPFLAGS"
67 LDFLAGS="$LDFLAGS $ICONV_LDFLAGS"
68 AC_LINK_IFELSE(
69 [AC_LANG_PROGRAM([@%:@include <$ICONV_NAME.h>],
70 [[iconv_t r = iconv_open("", "");]])],
71 [dont_need_iconv=yes],
72 [dont_need_iconv=no]
73 )
74 AS_IF([test "$dont_need_iconv" = no], [
75 LIBS="$LIBS -liconv"
76 AC_LINK_IFELSE(
77 [AC_LANG_PROGRAM([@%:@include <$ICONV_NAME.h>],
78 [[iconv_t r = iconv_open("", "");]])],
79 [ICONV_LIB="-liconv"],
80 [AC_MSG_WARN("Can't find library of iconv_open so I turned off using iconv; you may want to use --with-iconv-lib")
81 ac_cv_use_iconv=no])
82 ])
83 CFLAGS="$save_cflags"
84 LDFLAGS="$save_ldflags"
85 LIBS="$save_libs"
86 ])
87 ])
88
89 AS_IF([test "$ac_cv_use_iconv" = yes], [
90 dnl Force static linking on MinGW
91 AS_CASE(["$target"],
92 [*mingw*], [ICONV_LIB="-Wl,-dn,$ICONV_LIB,-dy"])
93
94 AC_DEFINE(USE_ICONV, [], [Define if uses iconv])
95 EXT_LIBS="$EXT_LIBS $ICONV_LIB"
96 ])
97 AC_SUBST(ICONV_NAME)
98 AC_SUBST(ICONV_LIB)
99 AC_SUBST(ICONV_CPPFLAGS)
100 AC_SUBST(ICONV_LDFLAGS)
101
102 dnl Local variables:
103 dnl mode: autoconf
104 dnl end: