-#endif SILC_DIST_MATH
-
-# iconv support
-#
-check_iconv=true
-has_iconv=false
-SAVE_LIBS="$LIBS"
-SAVE_CFLAGS="$CFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-SAVE_CPPFLAGS="$CPPFLAGS"
-AC_MSG_CHECKING(whether to implicit search for libiconv)
-AC_ARG_WITH(iconv,
- [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
- [
- case "${withval}" in
- no)
- AC_MSG_RESULT(no)
- AC_CHECK_HEADERS(iconv.h,
- [
- AC_CHECK_FUNC(iconv, has_iconv=true)
- ])
- check_iconv=false
- ;;
- *)
- AC_MSG_RESULT(yes)
- if test -d $withval/include; then
- CPPFLAGS="$CPPFLAGS -I$withval/include"
- CFLAGS="$CFLAGS -I$withval/include"
- fi
- if test -d $withval/lib; then
- LDFLAGS="$LDFLAGS -L$withval/lib"
- fi
- ;;
- esac
- ],
- [
- AC_MSG_RESULT(no)
- AC_CHECK_HEADERS(iconv.h,
- [
- AC_CHECK_FUNCS(iconv,
- [
- has_iconv=true
- check_iconv=false
- ])
- ])
- ])
-
-if test x$check_iconv = xtrue; then
- AC_MSG_RESULT(Searching for iconv...)
-
- # XXX
- unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
-
- AC_CHECK_HEADERS(iconv.h,
- [
- LIBS="$LIBS -liconv"
- AC_MSG_CHECKING(for iconv in -liconv)
- AC_TRY_LINK(
- [
- #include <stdlib.h>
- #include <iconv.h>
- ],
- [
- iconv_t cd = iconv_open("", "");
- iconv(cd, NULL, NULL, NULL, NULL);
- iconv_close(cd);
- ],
- [
- echo "yes"
- AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
- has_iconv=true
- check_iconv=false
- ],
- [
- echo "no"
- LIBS="$SAVE_LIBS"
- CFLAGS="$SAVE_CFLAGS"
- LDFLAGS="$SAVE_LDFLAGS"
- CPPFLAGS="$SAVE_CPPFLAGS"
- ])
- ])
-fi
-
-if test x$check_iconv = xtrue; then
- # search for iconv library..
- SAVE_LIBS="$LIBS"
- SAVE_CFLAGS="$CFLAGS"
- SAVE_LDFLAGS="$LDFLAGS"
- SAVE_CPPFLAGS="$CPPFLAGS"
-
- for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
- if test x$has_iconv = xfalse; then
- AC_MSG_RESULT(searching in $dir...)
-
- if test -d $dir/include; then
- CPPFLAGS="$CPPFLAGS -I$dir/include"
- CFLAGS="$CFLAGS -I$dir/include"
- fi
- if test -d $dir/lib; then
- LDFLAGS="$LDFLAGS -L$dir/lib"
- fi
-
- # XXX
- unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
-
- AC_CHECK_HEADERS(iconv.h,
- [
- LIBS="$LIBS -liconv"
- AC_MSG_CHECKING(for iconv in -liconv)
- AC_TRY_LINK(
- [
- #include <stdlib.h>
- #include <iconv.h>
- ],
- [
- iconv_t cd = iconv_open("", "");
- iconv(cd, NULL, NULL, NULL, NULL);
- iconv_close(cd);
- ],
- [
- echo "yes"
- has_iconv=true
- AC_DEFINE([HAVE_ICONV], [], [Define if you have the iconv() function.])
- ],
- [
- echo "no"
- has_iconv=false
-
- LIBS="$SAVE_LIBS"
- CFLAGS="$SAVE_CFLAGS"
- LDFLAGS="$SAVE_LDFLAGS"
- CPPFLAGS="$SAVE_CPPFLAGS"
- ])
- ],
- [
- CFLAGS="$SAVE_CFLAGS"
- LDFLAGS="$SAVE_LDFLAGS"
- CPPFLAGS="$SAVE_CPPFLAGS"
- ])
- fi
- done
-fi
-
-if test x$has_iconv = xtrue; then
- # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
- # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
- # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
- #
- AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
- AC_TRY_RUN(
- [
- #include <iconv.h>
- int main() {
- iconv_t cd;
- changequote(, )dnl
- char buf[4];
- changequote([, ])dnl
- char *ob;
- size_t obl;
- ob = buf, obl = sizeof(buf);
- return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
- (iconv(cd, 0, 0, &ob, &obl) ||
- !(ob == buf && obl == sizeof(buf)) ||
- iconv_close(cd)));
- }
- ],
- [
- ac_iconv_good=yes
- ],
- [
- ac_iconv_good=no
- ],
- [
- ac_iconv_good=yes
- ])
- )
-
- if test x$ac_iconv_good = xno; then
- AC_MSG_RESULT(Try using libiconv instead.)
- fi
-fi
-
-# POSIX threads support
-#
-AC_MSG_CHECKING(whether to search for POSIX threads)
-AC_ARG_WITH(pthreads,
- [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]],
- [
- case "${withval}" in
- no)
- check_threads=false
- ;;
- *)
- if test -d $withval/include; then
- CPPFLAGS="$CPPFLAGS -I$withval/include"
- CFLAGS="$CFLAGS -I$withval/include"
- fi
- if test -d $withval/lib; then
- LDFLAGS="$LDFLAGS -L$withval/lib"
- fi
-
- check_threads=true
- ;;
- esac
- ])
-
-if test x$check_threads = xtrue; then
- has_threads=false
- SAVE_LIBS="$LIBS"
- SAVE_CFLAGS="$CFLAGS"
- SAVE_LDFLAGS="$LDFLAGS"
- SAVE_CPPFLAGS="$CPPFLAGS"
-
- AC_MSG_RESULT(yes)
- AC_CHECK_HEADERS(pthread.h,
- [
- LIBS="$LIBS -lpthread"
- AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
- [
- # FreeBSD
- case "${target}" in
- *-*-freebsd*)
- LIBS="$SAVE_LIBS -pthread"
- AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true, LIBS="$SAVE_LIBS")
- ;;
- *)
- LIBS="$SAVE_LIBS"
- ;;
- esac
- ])
- ],
- [
- # search for pthread library..
- for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
- if test x$has_threads = xfalse; then
- AC_MSG_RESULT(searching in $dir...)
-
- if test -d $dir/include; then
- CPPFLAGS="$CPPFLAGS -I$dir/include"
- CFLAGS="$CFLAGS -I$dir/include"
- fi
- if test -d $dir/lib; then
- LDFLAGS="$LDFLAGS -L$dir/lib"
- fi
-
- # XXX
- unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
-
- AC_CHECK_HEADERS(pthread.h,
- [
- LIBS="$LIBS -lpthread"
- AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
- [
- has_threads=false
-
- LIBS="$SAVE_LIBS"
- CFLAGS="$SAVE_CFLAGS"
- LDFLAGS="$SAVE_LDFLAGS"
- CPPFLAGS="$SAVE_CPPFLAGS"
- ])
- ],
- [
- CFLAGS="$SAVE_CFLAGS"
- LDFLAGS="$SAVE_LDFLAGS"
- CPPFLAGS="$SAVE_CPPFLAGS"
- ])
- fi
- done
- ])
-else
- AC_MSG_RESULT(no)
- has_threads=false
-fi
-
-__SILC_HAVE_PTHREAD=""
-AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
-if test x$has_threads = xtrue; then
- CFLAGS="$CFLAGS -D_REENTRANT"
-
- # XXX possibly incomplete
- case "${target}" in
- *-*-aix*)
- CFLAGS="$CFLAGS -D_THREAD_SAFE"
- if test x"$GCC" = xyes; then
- CFLAGS="$CFLAGS -mthreads"
- fi
- ;;
- *-*-freebsd*)
- CFLAGS="$CFLAGS -D_THREAD_SAFE"
- ;;
- *-*-sysv5uw7*) # UnixWare 7
- if test "$GCC" != "yes"; then
- CFLAGS="$CFLAGS -Kthread"
- else
- CFLAGS="$CFLAGS -pthread"
- fi
- ;;
- *-dg-dgux*) # DG/UX
- CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
- ;;
- esac