Added checks for GNU libidn.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 27 Mar 2005 16:52:14 +0000 (16:52 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 27 Mar 2005 16:52:14 +0000 (16:52 +0000)
CHANGES
INSTALL
configure.in.pre

diff --git a/CHANGES b/CHANGES
index ecfaf6728465a6ed26f48db656fe0c64b4048818..114813a906df587d34b7ee9d1298f1997b186dd0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,8 @@ Sun Mar 27 19:02:48 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
          GNU Libidn's stringprep, for now, so it is required now to
          compile SILC sources.  Added lib/silcutil/silcstringprep.[ch].
 
+       * Added checking for GNU Libidn and --with-libidn to configure.
+
 Wed Mar 23 11:20:33 CET 2005  Jochen Eisinger <jochen@penguin-breeder.org>
 
        * If the passphrases entered do not match while generating a new key,
diff --git a/INSTALL b/INSTALL
index 25b5ea0464df3caf400658aba5d3891200bef981..acfbb37f9ac9a75d1f9407f1f39a48cb8938a2c4 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -32,6 +32,14 @@ path in your system which contains lib/ and include/ for GMP library.
 GMP can be used as a fall-back if you have problems with the MPI library
 included within this package.
 
+'--with-libidn[=DIR]'
+
+   The SILC requires GNU Libidn for the stringprep() function.  If your
+system does not have it installed by default you will need to install it
+and possibly give this option to specify its location.  The DIR is the
+upper path in your system which contains lib/ and include/ for libidn
+(e.g. /usr/local).
+
 '--with-iconv[=DIR]'
 
    If your system doesn't provide iconv() function in its native libraries
index b463546dbdb7a7da658cf7fc170c79a6564ff365..f1973afea4376d9c15d421d463c14f9380b2a58e 100644 (file)
@@ -704,6 +704,141 @@ if test x$mp_gmp = xfalse; then
   AC_MSG_RESULT(Using NSS MPI as a MP library.)
 fi
 
+# GNU Libidn (for stringprep) support
+#
+check_libidn=true
+has_libidn=false
+SAVE_LIBS="$LIBS"
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+SAVE_CPPFLAGS="$CPPFLAGS"
+AC_MSG_CHECKING(whether to implicit search for libidn)
+AC_ARG_WITH(libidn,
+  [[  --with-libidn[=DIR]     use libidn [search in DIR/include and DIR/lib]]],
+  [
+    case "${withval}" in
+      no)
+        AC_MSG_RESULT(no)
+        AC_CHECK_HEADERS(stringprep.h,
+          [
+            AC_CHECK_FUNC(stringprep, has_libidn=true)
+          ])
+        check_libidn=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(stringprep.h,
+      [
+        AC_CHECK_FUNCS(stringprep,
+          [
+            has_libidn=true
+            check_libidn=false
+          ])
+      ])
+  ])
+
+if test x$check_libidn = xtrue; then
+  AC_MSG_RESULT(Searching for libidn...)
+
+  AC_CHECK_HEADERS(stringprep.h,
+    [
+      LIBS="$LIBS -lidn"
+      AC_MSG_CHECKING(for stringprep in -lidn)
+      AC_TRY_LINK(
+        [
+          #include <stdlib.h>
+          #include <stringprep.h>
+        ],
+        [
+         (void)stringprep_locale_charset();
+        ],
+        [
+          echo "yes"
+          AC_DEFINE(HAVE_LIBIDN, 1, [Define if you have the stringprep() function.])
+          has_libidn=true
+          check_libidn=false
+        ],
+        [
+          echo "no"
+          LIBS="$SAVE_LIBS"
+          CFLAGS="$SAVE_CFLAGS"
+          LDFLAGS="$SAVE_LDFLAGS"
+          CPPFLAGS="$SAVE_CPPFLAGS"
+        ])
+     ])
+fi
+
+if test x$check_libidn = xtrue; then
+  # search for idn 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_libidn = 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__stringprep_h_ ac_cv_header_stringprep_h || true
+
+      AC_CHECK_HEADERS(stringprep.h,
+        [
+          LIBS="$LIBS -lidn"
+          AC_MSG_CHECKING(for stringprep in -lidn)
+          AC_TRY_LINK(
+            [
+              #include <stdlib.h>
+              #include <stringprep.h>
+            ],
+            [
+             (void)stringprep_locale_charset();
+            ],
+            [
+              echo "yes"
+              has_libidn=true
+              AC_DEFINE(HAVE_LIBIDN, 1, [Define if you have the stringprep() function.])
+            ],
+            [
+              echo "no"
+              has_libidn=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
+
+
 # iconv support
 #
 check_iconv=true
@@ -750,7 +885,7 @@ AC_ARG_WITH(iconv,
   ])
 
 if test x$check_iconv = xtrue; then
-  AC_MSG_RESULT(starting search...)
+  AC_MSG_RESULT(Searching for iconv...)
 
   # XXX
   unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
@@ -884,6 +1019,7 @@ if test x$has_iconv = xtrue; then
   fi
 fi
 
+
 # POSIX threads support
 #
 has_threads=false
@@ -1252,9 +1388,15 @@ if test x$has_iconv = xfalse; then
 else
   iconv_support="yes"
 fi
+if test x$has_libidn = xfalse; then
+  libidn_support="no"
+else
+  libidn_support="yes"
+fi
 echo " SIM support ...................: $sim_support"
 echo " IPv6 support ..................: $summary_ipv6"
 echo " Iconv support .................: $iconv_support"
+echo " Idn support ...................: $libidn_support"
 if test x$want_asm = xfalse; then
   summary_asm="no"
 else