File: iconv.m4

package info (click to toggle)
netatalk 2.0.3-4
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 9,004 kB
  • ctags: 6,109
  • sloc: ansic: 67,633; sh: 8,424; perl: 1,187; makefile: 1,001
file content (119 lines) | stat: -rw-r--r-- 3,426 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
AC_DEFUN([AC_CHECK_ICONV],
[

dnl	#################################################
dnl	# check for libiconv support
        savedcflags="$CFLAGS"
        savedldflags="$LDFLAGS"
	ICONV_CFLAGS=""
	ICONV_LIBS=""

	AC_ARG_WITH(libiconv,
	[  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include [[default=auto]]],
	[ case "$withval" in
	  no)
	    ;;
	  yes)
	    ;;
	  *)
	    ICONV_CFLAGS="-I$withval/include"
	    ICONV_LIBS="-L$withval/$atalk_libname"
	    ;;
	  esac ],
	  withval="no"
	)	

	CFLAGS="$ICONV_CFLAGS $CFLAGS"
        LDFLAGS="$LDFLAGS $ICONV_LIBS -liconv"

	AC_CACHE_CHECK([for libiconv],netatalk_cv_iconv,[
          AC_TRY_LINK([
#include <stdlib.h>
#include <iconv.h>
],[
	iconv_t cd = iconv_open("","");
        iconv(cd,NULL,NULL,NULL,NULL);
        iconv_close(cd);
], netatalk_cv_iconv=yes, netatalk_cv_iconv=no, netatalk_cv_iconv=cross)])

	if test x"$netatalk_cv_iconv" = x"yes"; then
	    ICONV_LIBS="$ICONV_LIBS -liconv"
        else
dnl	    # unset C-/LDFLAGS so we can detect glibc iconv, if available
	    CFLAGS="$savedcflags"
	    LDFLAGS="$savedldflags"
	    ICONV_LIBS=""
	    ICONV_CFLAGS=""
	    if test x"$withval" != x"no"; then
	        AC_MSG_ERROR([libiconv not found])
	    fi
	fi


	CFLAGS_REMOVE_USR_INCLUDE(ICONV_CFLAGS)
	LIB_REMOVE_USR_LIB(ICONV_LIBS)
	AC_SUBST(ICONV_CFLAGS)
	AC_SUBST(ICONV_LIBS)

dnl	############
dnl	# check for iconv usability

	AC_CACHE_CHECK([for working iconv],netatalk_cv_HAVE_USABLE_ICONV,[
		AC_TRY_RUN([\
#include <iconv.h>
main() {
       iconv_t cd = iconv_open("ASCII", "UTF-8");
       if (cd == 0 || cd == (iconv_t)-1) return -1;
       return 0;
}
], netatalk_cv_HAVE_USABLE_ICONV=yes,netatalk_cv_HAVE_USABLE_ICONV=no,netatalk_cv_HAVE_USABLE_ICONV=cross)])

	if test x"$netatalk_cv_HAVE_USABLE_ICONV" = x"yes"; then
	    AC_DEFINE(HAVE_USABLE_ICONV,1,[Whether to use native iconv])
	fi

dnl	###########
dnl	# check if iconv needs const
  	if test x"$netatalk_cv_HAVE_USABLE_ICONV" = x"yes"; then
    		AC_CACHE_VAL(am_cv_proto_iconv, [
      		AC_TRY_COMPILE([\
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
	      	am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
    		AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
      			[Define as const if the declaration of iconv() needs const.])
  	fi

dnl     ###########
dnl     # check if (lib)iconv supports UCS-2-INTERNAL
	if test x"$netatalk_cv_HAVE_USABLE_ICONV" = x"yes"; then
	    AC_CACHE_CHECK([whether iconv supports UCS-2-INTERNAL],netatalk_cv_HAVE_UCS2INTERNAL,[
		AC_TRY_RUN([\
#include <iconv.h>
int main() {
       iconv_t cd = iconv_open("ASCII", "UCS-2-INTERNAL");
       if (cd == 0 || cd == (iconv_t)-1) return -1;
       return 0;
}
], netatalk_cv_HAVE_UCS2INTERNAL=yes,netatalk_cv_HAVE_UCS2INTERNAL=no,netatalk_cv_HAVEUCS2INTERNAL=cross)])

	if test x"$netatalk_cv_HAVE_UCS2INTERNAL" = x"yes"; then
		AC_DEFINE(HAVE_UCS2INTERNAL,1,[Whether UCS-2-INTERNAL is supported])
	fi
	fi

        CFLAGS="$savedcflags"
        LDFLAGS="$savedldflags"
	CPPFLAGS="$saved_CPPFLAGS"
	
])