aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-10-21 17:48:50 +0000
committerChristian Grothoff <christian@grothoff.org>2018-10-25 12:01:28 +0200
commit0a97ba60f4f09558b0c2a4b8d2c09e6ff7bfd112 (patch)
treece9503de2771a0a41016c870014ff2ac108e8e7b
parent70b9b7a3845340c2ea67c115fd81215dee59e870 (diff)
downloadgnunet-0a97ba60f4f09558b0c2a4b8d2c09e6ff7bfd112.tar.gz
gnunet-0a97ba60f4f09558b0c2a4b8d2c09e6ff7bfd112.zip
libidn + libidn2 support, as proposed by WJ Liu / multiSnow in a github gist.
Signed-off-by: Nils Gillmann <ng0@n0.is>
-rw-r--r--README5
-rw-r--r--configure.ac139
-rw-r--r--src/util/Makefile.am12
-rw-r--r--src/util/dnsparser.c6
4 files changed, 141 insertions, 21 deletions
diff --git a/README b/README
index 0498e3def..3a2870279 100644
--- a/README
+++ b/README
@@ -36,7 +36,10 @@ These are the direct dependencies for running GNUnet:
36- libcurl >= 7.35.0 (alternative to libgnurl) 36- libcurl >= 7.35.0 (alternative to libgnurl)
37- libunistring >= 0.9.2 37- libunistring >= 0.9.2
38- gnutls >= 3.2.12 (highly recommended a gnutls linked against libunbound) 38- gnutls >= 3.2.12 (highly recommended a gnutls linked against libunbound)
39- libidn >= 1.0 39- libidn:
40 - libidn2 (prefered)
41 or
42 - libidn >= 1.0
40- libextractor >= 0.6.1 (highly recommended) 43- libextractor >= 0.6.1 (highly recommended)
41- openssl >= 1.0 (binary, used to generate X.509 certificate) 44- openssl >= 1.0 (binary, used to generate X.509 certificate)
42- libltdl >= 2.2 (part of GNU libtool) 45- libltdl >= 2.2 (part of GNU libtool)
diff --git a/configure.ac b/configure.ac
index e9e540419..e36d0b2d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -827,28 +827,131 @@ fi
827# restore LIBS 827# restore LIBS
828LIBS=$SAVE_LIBS 828LIBS=$SAVE_LIBS
829 829
830# libidn and libidn2. The ideal goal is this:
831# check for libidn2, if it doesn't exist check for libidn
832# if both exist, prefer libidn2
833# if none exist, fail and message that libidn or libidn2
834# is required with a preference for libidn2.
835# TODO: What we have right here can probably be improved.
836my_with_libidn=1
837AC_ARG_WITH(libidn,
838 AS_HELP_STRING([--with-libidn=pathname],
839 [Support IDN (needs libidn)]),
840 [],
841 [withval="yes"])
842if test x_$withval = x_yes; then
843 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
844 if test -f "$dir/include/idna.h"; then
845 CFLAGS="$CFLAGS -I$dir/include"
846 LDFLAGS="$LDFLAGS -L$dir/lib"
847 AC_MSG_NOTICE([Found libidn in $dir])
848 break
849 fi
850 if test -f "$dir/include/idn/idna.h"; then
851 CFLAGS="$CFLAGS -I$dir/include/idn"
852 LDFLAGS="$LDFLAGS -L$dir/lib"
853 AC_MSG_NOTICE([Found libidn in $dir])
854 break
855 fi
856 done
857 if test -f "/usr/include/idn/idna.h"; then
858 CFLAGS="$CFLAGS -I/usr/include/idn"
859 #LDFLAGS="$LDFLAGS -L/usr/lib"
860 AC_MSG_NOTICE([Found libidn in /usr])
861 fi
862else
863 if test x_$withval != x_no; then
864 CFLAGS="$CFLAGS -I$withval/include"
865 LDFLAGS="$LDFLAGS -L$withval/lib"
866 else
867 my_with_libidn=0
868 fi
869fi
830 870
831# libidn 871my_with_libidn2=1
832AC_MSG_CHECKING([if Libidn can be used]) 872AC_ARG_WITH(libidn2,
833AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]], 873 AS_HELP_STRING([--with-libidn2=pathname],
834 [Support IDN (needs GNU Libidn)]), 874 [Support IDN (needs libidn2)]),
835libidn=$withval, libidn=yes) 875 [],
836if test "$libidn" != "no"; then 876 [withval="yes"])
837 if test "$libidn" != "yes"; then 877if test x_$withval = x_yes; then
838 LDFLAGS="${LDFLAGS} -L$libidn/lib" 878 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
839 CPPFLAGS="${CPPFLAGS} -I$libidn/include" 879 if test -f "$dir/include/idn2.h"; then
840 fi 880 CFLAGS="$CFLAGS -I$dir/include"
881 LDFLAGS="$LDFLAGS -L$dir/lib"
882 AC_MSG_NOTICE([Found libidn2 in $dir])
883 break
884 fi
885 if test -f "$dir/include/idn2/idn2.h"; then
886 CFLAGS="$CFLAGS -I$dir/include/idn2"
887 LDFLAGS="$LDFLAGS -L$dir/lib"
888 AC_MSG_NOTICE([Found libidn2 in $dir])
889 break
890 fi
891 done
892 if test -f "/usr/include/idn2/idn2.h"; then
893 CFLAGS="$CFLAGS -I/usr/include/idn2"
894 #LDFLAGS="$LDFLAGS -L/usr/lib"
895 AC_MSG_NOTICE([Found libidn2 in /usr])
896 fi
897else
898 if test x_$withval != x_no; then
899 CFLAGS="$CFLAGS -I$withval/include"
900 LDFLAGS="$LDFLAGS -L$withval/lib"
901 else
902 my_with_libidn2=0
903 fi
841fi 904fi
842libidn=no 905
843AC_CHECK_HEADER(idna.h, 906AC_MSG_CHECKING([if libidn can be used])
844 AC_CHECK_LIB(idn, stringprep_check_version, 907# Check for LIBIDNs
845 [libidn=yes LIBS="${LIBS} -lidn"], []), []) 908there_can_only_be_one=1
846if test "$libidn" != "yes"; then 909
847 AC_MSG_FAILURE([GNUnet requires libidn. 910working_libidn2=0
848libidn-1.13 should be sufficient, newer versions work too.]) 911if test $my_with_libidn2 = 1
912then
913 AC_MSG_NOTICE([Checking for libidn2])
914 AC_CHECK_LIB([idn2],
915 [idn2_to_unicode_8z8z],
916 [working_libidn2=1
917 LIBS="-lidn2 $LIBS"
918 AC_DEFINE_UNQUOTED([HAVE_LIBIDN2],
919 [1],
920 [Define to 1 if you have 'libidn2' (-lidn).])],
921 [MISSING_DEPS="${MISSING_DEPS}${MISSING_SEP}libidn2"
922 MISSING_SEP=", "])
923fi
924if test $working_libidn2 = 0
925then
926 if test $my_with_libidn = 1
927 then
928 AC_MSG_NOTICE([Checking for libidn])
929 AC_CHECK_LIB([idn],
930 [idna_to_ascii_8z],
931 [LIBS="-lidn $LIBS"
932 AC_DEFINE_UNQUOTED([HAVE_LIBIDN],
933 [1],
934 [Define to 1 if you have 'libidn' (-lidn).])],
935 [there_can_only_be_one=0])
936 else
937 if test $my_with_libidn2 = 1
938 then
939 there_can_only_be_one=0
940 AC_MSG_FAILURE([* There can only be one libidn.
941 * Provide either libidn >= 1.13
942 * or
943 * libidn2 to the configure
944 * script via
945 * --with-libidn2
946 * --with-libidn])
947 fi
948 fi
849fi 949fi
850AC_MSG_RESULT($libidn)
851 950
951if test $there_can_only_be_one = 0
952then
953 AC_MSG_FAILURE([Missing dependencies: $MISSING_DEPS])
954fi
852 955
853# test for zlib 956# test for zlib
854SAVE_LDFLAGS=$LDFLAGS 957SAVE_LDFLAGS=$LDFLAGS
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index b0f45b1da..165d41d01 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -122,12 +122,22 @@ libgnunetutil_la_SOURCES = \
122 tun.c \ 122 tun.c \
123 speedup.c speedup.h 123 speedup.c speedup.h
124 124
125if HAVE_LIBIDN
126 LIBIDN= -lidn
127else
128 LIBIDN=
129
130if HAVE_LIBIDN2
131 LIBIDN2= -lidn2
132else
133 LIBIDN2=
134
125libgnunetutil_la_LIBADD = \ 135libgnunetutil_la_LIBADD = \
126 $(GCLIBADD) $(WINLIB) \ 136 $(GCLIBADD) $(WINLIB) \
127 $(LIBGCRYPT_LIBS) \ 137 $(LIBGCRYPT_LIBS) \
128 $(LTLIBICONV) \ 138 $(LTLIBICONV) \
129 $(LTLIBINTL) \ 139 $(LTLIBINTL) \
130 -lltdl -lidn $(Z_LIBS) -lunistring $(XLIB) $(PTHREAD) 140 -lltdl $(LIBIDN) $(LIBIDN2) $(Z_LIBS) -lunistring $(XLIB) $(PTHREAD)
131 141
132libgnunetutil_la_LDFLAGS = \ 142libgnunetutil_la_LDFLAGS = \
133 $(GN_LIB_LDFLAGS) \ 143 $(GN_LIB_LDFLAGS) \
diff --git a/src/util/dnsparser.c b/src/util/dnsparser.c
index 24f1b18cf..79d723f12 100644
--- a/src/util/dnsparser.c
+++ b/src/util/dnsparser.c
@@ -17,13 +17,17 @@
17 */ 17 */
18 18
19/** 19/**
20 * @file dns/dnsparser.c 20 * @file util/dnsparser.c
21 * @brief helper library to parse DNS packets. 21 * @brief helper library to parse DNS packets.
22 * @author Philipp Toelke 22 * @author Philipp Toelke
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#if defined(HAVE_LIBIDN2)
27#include <idn2.h>
28#elif defined(HAVE_LIBIDN)
26#include <idna.h> 29#include <idna.h>
30#endif
27#if WINDOWS 31#if WINDOWS
28#include <idn-free.h> 32#include <idn-free.h>
29#endif 33#endif