From: Seonah Moon Date: Fri, 21 Jul 2017 06:54:13 +0000 (+0900) Subject: Add glib2 dependency to support IDN X-Git-Tag: submit/tizen/20170731.020626~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fcurl.git;a=commitdiff_plain;h=5a2e836b77304d12730747efd8aa24c6f442c69f Add glib2 dependency to support IDN Change-Id: Ie330340da408b1cf57fca5c30c0f7dac88d85eb7 Signed-off-by: Seonah Moon --- diff --git a/configure.ac b/configure.ac index 1e76c49..417ba20 100644 --- a/configure.ac +++ b/configure.ac @@ -2953,6 +2953,134 @@ dnl Let's hope this split URL remains working: dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \ dnl genprogc/thread_quick_ref.htm +dnl ********************************************************************** +dnl Check for GLIB-2.0 (IDN support) +dnl ********************************************************************** + +AC_MSG_CHECKING([whether to build with glib-2.0]) +OPT_IDN="default" +AC_ARG_WITH(glib-2.0, +AC_HELP_STRING([--with-glib2=PATH],[Enable glib-2.0 usage]) +AC_HELP_STRING([--without-glib2],[Disable glib-2.0 usage]), + [OPT_IDN=$withval]) +case "$OPT_IDN" in + no) + dnl --without-glib2 option used + want_idn="no" + AC_MSG_RESULT([no]) + ;; + default) + dnl configure option not specified + want_idn="yes" + want_idn_path="default" + AC_MSG_RESULT([(assumed) yes]) + ;; + yes) + dnl --with-glib2 option used without path + want_idn="yes" + want_idn_path="default" + AC_MSG_RESULT([yes]) + ;; + *) + dnl --with-glib2 option used with path + want_idn="yes" + want_idn_path="$withval" + AC_MSG_RESULT([yes ($withval)]) + ;; +esac + +if test "$want_idn" = "yes"; then + dnl idn library support has been requested + clean_CPPFLAGS="$CPPFLAGS" + clean_LDFLAGS="$LDFLAGS" + clean_LIBS="$LIBS" + PKGCONFIG="no" + # + if test "$want_idn_path" != "default"; then + dnl path has been specified + IDN_PCDIR="$want_idn_path/lib$libsuff/pkgconfig" + CURL_CHECK_PKGCONFIG(glib-2.0, [$IDN_PCDIR]) + if test "$PKGCONFIG" != "no"; then + IDN_LIBS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl + $PKGCONFIG --libs-only-l glib-2.0 2>/dev/null` + IDN_LDFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl + $PKGCONFIG --libs-only-L glib-2.0 2>/dev/null` + IDN_CPPFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl + $PKGCONFIG --cflags-only-I glib-2.0 2>/dev/null` + IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'` + else + dnl pkg-config not available or provides no info + IDN_LIBS="-lglib-2.0" + IDN_LDFLAGS="-L$want_idn_path/lib$libsuff" + IDN_CPPFLAGS="-I$want_idn_path/include" + IDN_DIR="$want_idn_path/lib$libsuff" + fi + else + dnl path not specified + CURL_CHECK_PKGCONFIG(glib-2.0) + if test "$PKGCONFIG" != "no"; then + IDN_LIBS=`$PKGCONFIG --libs-only-l glib-2.0 2>/dev/null` + IDN_LDFLAGS=`$PKGCONFIG --libs-only-L glib-2.0 2>/dev/null` + IDN_CPPFLAGS=`$PKGCONFIG --cflags-only-I glib-2.0 2>/dev/null` + IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'` + else + dnl pkg-config not available or provides no info + IDN_LIBS="-lglib-2.0" + fi + fi + # + if test "$PKGCONFIG" != "no"; then + AC_MSG_NOTICE([pkg-config: IDN_LIBS: "$IDN_LIBS"]) + AC_MSG_NOTICE([pkg-config: IDN_LDFLAGS: "$IDN_LDFLAGS"]) + AC_MSG_NOTICE([pkg-config: IDN_CPPFLAGS: "$IDN_CPPFLAGS"]) + AC_MSG_NOTICE([pkg-config: IDN_DIR: "$IDN_DIR"]) + else + AC_MSG_NOTICE([IDN_LIBS: "$IDN_LIBS"]) + AC_MSG_NOTICE([IDN_LDFLAGS: "$IDN_LDFLAGS"]) + AC_MSG_NOTICE([IDN_CPPFLAGS: "$IDN_CPPFLAGS"]) + AC_MSG_NOTICE([IDN_DIR: "$IDN_DIR"]) + fi + # + CPPFLAGS="$IDN_CPPFLAGS $CPPFLAGS" + LDFLAGS="$IDN_LDFLAGS $LDFLAGS" + LIBS="$IDN_LIBS $LIBS" + # + AC_MSG_CHECKING([if g_hostname_to_ascii can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([g_hostname_to_ascii]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_glib2="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_glib2="no" + ]) + # + if test "$tst_links_glib2" = "yes"; then + AC_DEFINE(USE_GLIB2_HOSTNAME, 1, [Define to 1 if you have the `glib-2.0' library (-lglib-2.0).]) + dnl different versions of libidn have different setups of these: + + AC_SUBST([IDN_ENABLED], [1]) + curl_idn_msg="enabled (glib-2.0)" + if test -n "$IDN_DIR" -a "x$cross_compiling" != "xyes"; then + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$IDN_DIR" + export LD_LIBRARY_PATH + AC_MSG_NOTICE([Added $IDN_DIR to LD_LIBRARY_PATH]) + fi + else + AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled]) + CPPFLAGS="$clean_CPPFLAGS" + LDFLAGS="$clean_LDFLAGS" + LIBS="$clean_LIBS" + fi + +fi + +dnl Let's hope this split URL remains working: +dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \ +dnl genprogc/thread_quick_ref.htm + + dnl ********************************************************************** dnl Check for nghttp2 diff --git a/lib/curl_config.h.in b/lib/curl_config.h.in index 60e9d23..21bf76d 100644 --- a/lib/curl_config.h.in +++ b/lib/curl_config.h.in @@ -921,6 +921,9 @@ /* to enable Apple OS native SSL/TLS support */ #undef USE_DARWINSSL +/* Define to 1 if you have the `glib-2.0' library (-lglib-2.0). */ +#undef USE_GLIB2_HOSTNAME + /* if GnuTLS is enabled */ #undef USE_GNUTLS diff --git a/lib/url.c b/lib/url.c index 3282566..8692e68 100644 --- a/lib/url.c +++ b/lib/url.c @@ -65,6 +65,8 @@ #elif defined(USE_WIN32_IDN) /* prototype for curl_win32_idn_to_ascii() */ bool curl_win32_idn_to_ascii(const char *in, char **out); +#elif defined(USE_GLIB2_HOSTNAME) +#include #endif /* USE_LIBIDN2 */ #include "urldata.h" @@ -4072,6 +4074,15 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host) } else infof(data, "Failed to convert %s to ACE;\n", host->name); +#elif defined(USE_GLIB2_HOSTNAME) + gchar *ace_hostname = NULL; + ace_hostname = g_hostname_to_ascii(host->name); + if(ace_hostname) { + host->encalloc = (char *)ace_hostname; + host->name = host->encalloc; + } + else + infof(data, "Failed to convert %s to ACE;\n", host->name); #else infof(data, "IDN support not present, can't parse Unicode domains\n"); #endif diff --git a/packaging/curl.spec b/packaging/curl.spec index dc405a2..fc16745 100644 --- a/packaging/curl.spec +++ b/packaging/curl.spec @@ -9,8 +9,8 @@ URL: http://curl.haxx.se/ Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest +BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(openssl) -BuildRequires: pkgconfig(libidn) BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(libcares) BuildRequires: pkgconfig(libnghttp2) @@ -70,7 +70,7 @@ CFLAGS+=" -DTIZEN_TV_EXT" %endif --with-ca-path==/etc/ssl/certs \ --with-ca-bundle=/etc/ssl/ca-bundle.pem \ ---with-libidn \ +--with-glib2 \ --with-lber-lib=lber \ --enable-manual --enable-versioned-symbols --enable-ares --enable-debug --enable-curldebug \ --disable-static \