]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Rework libidn2 detection
authorMichał Kępień <michal@isc.org>
Tue, 10 Jul 2018 12:34:35 +0000 (14:34 +0200)
committerMichał Kępień <michal@isc.org>
Tue, 10 Jul 2018 12:34:35 +0000 (14:34 +0200)
Clean up the parts of configure.in responsible for handling libidn2
detection and adjust other pieces of the build system to match these
cleanups:

  - use pkg-config when --with-libidn2 is used without an explicit path,

  - look for idn2_to_ascii_lz() rather than idn2_to_ascii_8z() as the
    former is used in BIND while the latter is not,

  - do not look for idn2_to_unicode_8zlz() as it is present in all
    libidn2 versions which have idn2_to_ascii_lz(),

  - check whether the <idn2.h> header is usable,

  - set LDFLAGS in the Makefile for dig so that, if specified, the
    requested libidn2 path is used when linking with libidn2,

  - override CPPFLAGS when looking for libidn2 components so that the
    configure script does not produce warnings when libidn2 is not
    installed system-wide,

  - merge the AS_CASE() call into the AS_IF() call below it to simplify
    code,

  - indicate the default value of --with-libidn2 in "./configure --help"
    output,

  - use $with_libidn2 rather than $use_libidn2 to better match the name
    of the configure script argument,

  - stop differentiating between IDN "in" and "out" support, i.e. make
    dig either support libidn2 or not; remove WITH_* Autoconf macros and
    use a new one, HAVE_LIBIDN2, to determine whether libidn2 support
    should be enabled.

bin/dig/Makefile.in
bin/dig/dig.c
bin/dig/dighost.c
bin/tests/system/feature-test.c
config.h.in
configure
configure.in

index 69d540ffe8b756c86e76ca7821bfde09dbfcf327..62cd72361e93946750bd1715ede1ec26f635335d 100644 (file)
@@ -64,6 +64,8 @@ MANOBJS =     ${MANPAGES} ${HTMLPAGES}
 
 @BIND9_MAKE_RULES@
 
+LDFLAGS =      @LIBIDN2_LDFLAGS@
+
 dig@EXEEXT@: dig.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
        export BASEOBJS="dig.@O@ dighost.@O@ ${UOBJS}"; \
        export LIBS0="${DNSLIBS} ${IRSLIBS}"; \
index 320d2490d1ecb38ae94e6f2c967214dee63c9226..5b4e8a78c267a16b67c4e79ebd7654bc75888b74 100644 (file)
@@ -1051,7 +1051,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                                switch (cmd[3]) {
                                case 'i':
                                        FULLCHECK("idnin");
-#ifndef WITH_IDN_SUPPORT
+#ifndef HAVE_LIBIDN2
                                        fprintf(stderr, ";; IDN input support"
                                                " not enabled\n");
 #else
@@ -1060,7 +1060,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                                break;
                                case 'o':
                                        FULLCHECK("idnout");
-#ifndef WITH_IDN_OUT_SUPPORT
+#ifndef HAVE_LIBIDN2
                                        fprintf(stderr, ";; IDN output support"
                                                " not enabled\n");
 #else
index 5928392a679eb189cbd205bd0842dd93ed80ec79..5c447f60f4de035b22bdda01f9208f8729bba07a 100644 (file)
 #include <locale.h>
 #endif
 
-#ifdef WITH_IDN_SUPPORT
-
-#ifdef WITH_LIBIDN2
+#ifdef HAVE_LIBIDN2
 #include <idn2.h>
-#endif
-#endif /* WITH_IDN_SUPPORT */
+#endif /* HAVE_LIBIDN2 */
 
 #include <dns/byaddr.h>
 #include <dns/fixedname.h>
@@ -135,14 +132,11 @@ int lookup_counter = 0;
 
 static char servercookie[256];
 
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
 static void idn_initialize(void);
 static isc_result_t idn_locale_to_ace(const char *from,
                char *to,
                size_t tolen);
-#endif /* WITH_IDN_SUPPORT */
-
-#ifdef WITH_IDN_OUT_SUPPORT
 static isc_result_t idn_ace_to_locale(const char *from,
                char *to,
                size_t tolen);
@@ -150,8 +144,7 @@ static isc_result_t output_filter(isc_buffer_t *buffer,
                unsigned int used_org,
                isc_boolean_t absolute);
 #define MAXDLEN 256
-
-#endif /* WITH_IDN_OUT_SUPPORT */
+#endif /* HAVE_LIBIDN2 */
 
 isc_socket_t *keep = NULL;
 isc_sockaddr_t keepaddr;
@@ -638,16 +631,13 @@ make_empty_lookup(void) {
        looknew->ttlunits = ISC_FALSE;
        looknew->ttlunits = ISC_FALSE;
        looknew->qr = ISC_FALSE;
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
        looknew->idnin = ISC_TRUE;
-#else
-       looknew->idnin = ISC_FALSE;
-#endif
-#ifdef WITH_IDN_OUT_SUPPORT
        looknew->idnout = ISC_TRUE;
 #else
+       looknew->idnin = ISC_FALSE;
        looknew->idnout = ISC_FALSE;
-#endif
+#endif /* HAVE_LIBIDN2 */
        looknew->udpsize = 0;
        looknew->edns = -1;
        looknew->recurse = ISC_TRUE;
@@ -1301,15 +1291,13 @@ setup_system(isc_boolean_t ipv4only, isc_boolean_t ipv6only) {
        (void)setlocale(LC_ALL, "");
 #endif
 
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
        idn_initialize();
-#endif
 
-#ifdef WITH_IDN_OUT_SUPPORT
        /* Set domain name -> text post-conversion filter. */
        result = dns_name_settotextfilter(output_filter);
        check_result(result, "dns_name_settotextfilter");
-#endif
+#endif /* HAVE_LIBIDN2 */
 
        if (keyfile[0] != 0)
                setup_file_key();
@@ -2033,15 +2021,13 @@ setup_lookup(dig_lookup_t *lookup) {
        char cookiebuf[256];
        char *origin = NULL;
        char *textname = NULL;
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
        char idn_origin[MXNAME], idn_textname[MXNAME];
-#endif
 
-#ifdef WITH_IDN_OUT_SUPPORT
        result = dns_name_settotextfilter(lookup->idnout ?
                                          output_filter : NULL);
        check_result(result, "dns_name_settotextfilter");
-#endif
+#endif /* HAVE_LIBIDN2 */
 
        REQUIRE(lookup != NULL);
        INSIST(!free_now);
@@ -2076,14 +2062,14 @@ setup_lookup(dig_lookup_t *lookup) {
         * TLD.
         */
        textname = lookup->textname;
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
        if (lookup->idnin) {
                result = idn_locale_to_ace(textname, idn_textname, sizeof(idn_textname));
                check_result(result, "convert textname to IDN encoding");
                debug("idn_textname: %s", idn_textname);
                textname = idn_textname;
        }
-#endif
+#endif /* HAVE_LIBIDN2 */
 
        /*
         * If the name has too many dots, force the origin to be NULL
@@ -2112,14 +2098,14 @@ setup_lookup(dig_lookup_t *lookup) {
                dns_name_init(lookup->oname, NULL);
                /* XXX Helper funct to conv char* to name? */
                origin = lookup->origin->origin;
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
                if (lookup->idnin) {
                        result = idn_locale_to_ace(origin, idn_origin, sizeof(idn_origin));
                        check_result(result, "convert origin to IDN encoding");
                        debug("trying idn origin %s", idn_origin);
                        origin = idn_origin;
                }
-#endif
+#endif /* HAVE_LIBIDN2 */
                len = (unsigned int) strlen(origin);
                isc_buffer_init(&b, origin, len);
                isc_buffer_add(&b, len);
@@ -4144,9 +4130,9 @@ cancel_all(void) {
  */
 void
 destroy_libs(void) {
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
        isc_result_t result;
-#endif
+#endif /* HAVE_LIBIDN2 */
 
        if (keep != NULL)
                isc_socket_detach(&keep);
@@ -4178,10 +4164,10 @@ destroy_libs(void) {
 
        clear_searchlist();
 
-#ifdef WITH_IDN_SUPPORT
+#ifdef HAVE_LIBIDN2
        result = dns_name_settotextfilter(NULL);
        check_result(result, "dns_name_settotextfilter");
-#endif
+#endif /* HAVE_LIBIDN2 */
        dns_name_destroy();
 
        if (commctx != NULL) {
@@ -4221,7 +4207,7 @@ destroy_libs(void) {
                isc_mem_destroy(&mctx);
 }
 
-#ifdef WITH_IDN_OUT_SUPPORT
+#ifdef HAVE_LIBIDN2
 static isc_result_t
 output_filter(isc_buffer_t *buffer, unsigned int used_org,
              isc_boolean_t absolute)
@@ -4274,10 +4260,7 @@ output_filter(isc_buffer_t *buffer, unsigned int used_org,
 
        return (ISC_R_SUCCESS);
 }
-#endif
 
-#ifdef WITH_IDN_SUPPORT
-#ifdef WITH_LIBIDN2
 static void
 idn_initialize(void) {
 }
@@ -4325,7 +4308,6 @@ idn_locale_to_ace(const char *from, char *to, size_t tolen) {
        return ISC_R_FAILURE;
 }
 
-#ifdef WITH_IDN_OUT_SUPPORT
 static isc_result_t
 idn_ace_to_locale(const char *from, char *to, size_t tolen) {
        int res;
@@ -4350,6 +4332,4 @@ idn_ace_to_locale(const char *from, char *to, size_t tolen) {
        fatal("'%s' is not a legal IDN name (%s), use +noidnout", from, idn2_strerror(res));
        return ISC_R_FAILURE;
 }
-#endif /* WITH_IDN_OUT_SUPPORT */
-#endif /* WITH_LIBIDN2 */
-#endif /* WITH_IDN_SUPPORT */
+#endif /* HAVE_LIBIDN2 */
index 0c20930cc4088e3a715534949a8ca25c3d969a31..f95ce4742a5de09751cc2be83f2da7f2ec1970f2 100644 (file)
@@ -153,7 +153,7 @@ main(int argc, char **argv) {
        }
 
        if (strcmp(argv[1], "--with-idn") == 0) {
-#ifdef WITH_LIBIDN2
+#ifdef HAVE_LIBIDN2
                return (0);
 #else
                return (1);
index 94f5aab4d0b0e5727d7fc7981afdbc119e614ec0..deee256e1b81e85e7aa0a35832118027aba4ebde 100644 (file)
@@ -293,6 +293,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to 1 if you have the <gssapi_krb5.h> header file. */
 #undef HAVE_GSSAPI_KRB5_H
 
+/* Define to 1 if you have the <idn2.h> header file. */
+#undef HAVE_IDN2_H
+
 /* Define to 1 if you have the if_nametoindex function. */
 #undef HAVE_IF_NAMETOINDEX
 
@@ -323,6 +326,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to 1 if you have the `c_r' library (-lc_r). */
 #undef HAVE_LIBC_R
 
+/* Define if libidn2 was found */
+#undef HAVE_LIBIDN2
+
 /* Define to 1 if you have the `nsl' library (-lnsl). */
 #undef HAVE_LIBNSL
 
@@ -620,15 +626,6 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to enable very verbose query trace logging. */
 #undef WANT_QUERYTRACE
 
-/* define if IDN output support is to be included. */
-#undef WITH_IDN_OUT_SUPPORT
-
-/* define if IDN input support is to be included. */
-#undef WITH_IDN_SUPPORT
-
-/* define if libidn2 support is to be included. */
-#undef WITH_LIBIDN2
-
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
    significant byte first (like Motorola and SPARC, unlike Intel). */
 #if defined AC_APPLE_UNIVERSAL_BUILD
index 4c48cb51c80002786ff87106223336df113af184..258b61b62f798b194dc044387c42fbe793676068 100755 (executable)
--- a/configure
+++ b/configure
@@ -676,6 +676,7 @@ ATFBUILD
 LD_WRAP_TESTS
 CMOCKA_LIBS
 CMOCKA_CFLAGS
+LIBIDN2_LDFLAGS
 LIBIDN2_LIBS
 LIBIDN2_CFLAGS
 XSLT_DBLATEX_FASTBOOK
@@ -1059,6 +1060,8 @@ CPP
 PKG_CONFIG
 PKG_CONFIG_PATH
 PKG_CONFIG_LIBDIR
+LIBIDN2_CFLAGS
+LIBIDN2_LIBS
 CMOCKA_CFLAGS
 CMOCKA_LIBS'
 
@@ -1762,7 +1765,8 @@ Optional Packages:
   --with-protobuf-c=path  Path where protobuf-c is installed, for dnstap
   --with-libfstrm=path    Path where libfstrm is installed, for dnstap
   --with-docbook-xsl=PATH specify path for Docbook-XSL stylesheets
-  --with-libidn2=PATH     enable IDN support using GNU libidn2 [yes|no|path]
+  --with-libidn2=PATH     enable IDN support using GNU libidn2
+                          [yes|no(default)|path]
   --with-cmocka=no        enable cmocka based tests (default is no)
   --with-atf              support Automated Test Framework
   --with-tuning=ARG       Specify server tuning (large or default)
@@ -1801,6 +1805,10 @@ Some influential environment variables:
               directories to add to pkg-config's search path
   PKG_CONFIG_LIBDIR
               path overriding pkg-config's built-in search path
+  LIBIDN2_CFLAGS
+              C compiler flags for LIBIDN2, overriding pkg-config
+  LIBIDN2_LIBS
+              linker flags for LIBIDN2, overriding pkg-config
   CMOCKA_CFLAGS
               C compiler flags for CMOCKA, overriding pkg-config
   CMOCKA_LIBS linker flags for CMOCKA, overriding pkg-config
@@ -22416,34 +22424,135 @@ LIBIDN2_LIBS=
 
 # Check whether --with-libidn2 was given.
 if test "${with_libidn2+set}" = set; then :
-  withval=$with_libidn2; use_libidn2="$withval"
+  withval=$with_libidn2; with_libidn2="$withval"
 else
-  use_libidn2="no"
+  with_libidn2="no"
 fi
 
-case $use_libidn2 in #(
-  no) :
-    : ;; #(
+case $with_libidn2 in #(
   yes) :
-    : ;; #(
-  *) :
 
-           LIBIDN2_CFLAGS="-I$use_libidn2/include"
-           LIBIDN2_LDFLAGS="-L$use_libidn2/lib"
-        ;; #(
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libidn2" >&5
+$as_echo_n "checking for libidn2... " >&6; }
+
+if test -n "$LIBIDN2_CFLAGS"; then
+    pkg_cv_LIBIDN2_CFLAGS="$LIBIDN2_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libidn2\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libidn2") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_LIBIDN2_CFLAGS=`$PKG_CONFIG --cflags "libidn2" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$LIBIDN2_LIBS"; then
+    pkg_cv_LIBIDN2_LIBS="$LIBIDN2_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libidn2\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libidn2") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_LIBIDN2_LIBS=`$PKG_CONFIG --libs "libidn2" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+               LIBIDN2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libidn2" 2>&1`
+        else
+               LIBIDN2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libidn2" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$LIBIDN2_PKG_ERRORS" >&5
+
+       as_fn_error $? "Package requirements (libidn2) were not met:
+
+$LIBIDN2_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables LIBIDN2_CFLAGS
+and LIBIDN2_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables LIBIDN2_CFLAGS
+and LIBIDN2_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.
+See \`config.log' for more details" "$LINENO" 5; }
+else
+       LIBIDN2_CFLAGS=$pkg_cv_LIBIDN2_CFLAGS
+       LIBIDN2_LIBS=$pkg_cv_LIBIDN2_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_LIBIDN2 1" >>confdefs.h
+
+fi ;; #(
+  no) :
+     ;; #(
   *) :
-     ;;
-esac
+    save_CFLAGS="$CFLAGS"
+                save_CPPFLAGS="$CPPFLAGS"
+                save_LDFLAGS="$LDFLAGS"
+                save_LIBS="$LIBS"
+                LIBIDN2_CFLAGS="-I$with_libidn2/include"
+                LIBIDN2_LDFLAGS="-L$with_libidn2/lib"
+                CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
+                CPPFLAGS="$LIBIDN2_CFLAGS $CPPFLAGS"
+                LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
+                for ac_header in idn2.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "idn2.h" "ac_cv_header_idn2_h" "$ac_includes_default"
+if test "x$ac_cv_header_idn2_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_IDN2_H 1
+_ACEOF
 
-if test "$use_libidn2" != "no"; then :
-  save_CFLAGS="$CFLAGS"
-       save_LIBS="$LIBS"
-       save_LDFLAGS="$LDFLAGS"
-       CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
-       LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing idn2_to_ascii_8z" >&5
-$as_echo_n "checking for library containing idn2_to_ascii_8z... " >&6; }
-if ${ac_cv_search_idn2_to_ascii_8z+:} false; then :
+else
+  as_fn_error $? "idn2.h not found" "$LINENO" 5
+fi
+
+done
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing idn2_to_ascii_lz" >&5
+$as_echo_n "checking for library containing idn2_to_ascii_lz... " >&6; }
+if ${ac_cv_search_idn2_to_ascii_lz+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -22456,11 +22565,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char idn2_to_ascii_8z ();
+char idn2_to_ascii_lz ();
 int
 main ()
 {
-return idn2_to_ascii_8z ();
+return idn2_to_ascii_lz ();
   ;
   return 0;
 }
@@ -22473,66 +22582,42 @@ for ac_lib in '' idn2; do
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
   if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_idn2_to_ascii_8z=$ac_res
+  ac_cv_search_idn2_to_ascii_lz=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if ${ac_cv_search_idn2_to_ascii_8z+:} false; then :
+  if ${ac_cv_search_idn2_to_ascii_lz+:} false; then :
   break
 fi
 done
-if ${ac_cv_search_idn2_to_ascii_8z+:} false; then :
+if ${ac_cv_search_idn2_to_ascii_lz+:} false; then :
 
 else
-  ac_cv_search_idn2_to_ascii_8z=no
+  ac_cv_search_idn2_to_ascii_lz=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_idn2_to_ascii_8z" >&5
-$as_echo "$ac_cv_search_idn2_to_ascii_8z" >&6; }
-ac_res=$ac_cv_search_idn2_to_ascii_8z
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_idn2_to_ascii_lz" >&5
+$as_echo "$ac_cv_search_idn2_to_ascii_lz" >&6; }
+ac_res=$ac_cv_search_idn2_to_ascii_lz
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+  LIBIDN2_LIBS="$ac_cv_search_idn2_to_ascii_lz"
 
-$as_echo "#define WITH_IDN_SUPPORT 1" >>confdefs.h
-
+$as_echo "#define HAVE_LIBIDN2 1" >>confdefs.h
 
-$as_echo "#define WITH_LIBIDN2 1" >>confdefs.h
-
-                       LIBIDN2_LIBS="$LIBIDN2_LDFLAGS -lidn2"
 else
   as_fn_error $? "libidn2 requested, but not found" "$LINENO" 5
 fi
 
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <idn2.h>
-int
-main ()
-{
-idn2_to_unicode_8zlz(".", NULL, IDN2_NONTRANSITIONAL|IDN2_NFC_INPUT);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-$as_echo "#define WITH_IDN_OUT_SUPPORT 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-       CFLAGS="$save_CFLAGS"
-       LIBS="$save_LIBS"
-       LDFLAGS="$save_LDFLAGS"
-
-fi
+                CFLAGS="$save_CFLAGS"
+                CPPFLAGS="$save_CPPFLAGS"
+                LDFLAGS="$save_LDFLAGS"
+                LIBS="$save_LIBS" ;; #(
+  *) :
+     ;;
+esac
 
 
 
@@ -26684,7 +26769,7 @@ report() {
        test "X$JSONSTATS" = "X" || echo "    JSON statistics (--with-libjson)"
        test "X$ZLIB" = "X" || echo "    HTTP zlib compression (--with-zlib)"
        test "X$NZD_TOOLS" = "X" || echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
-       test "no" = "$use_libidn2" || echo "    IDN support (--with-libidn2)"
+       test "no" = "$with_libidn2" || echo "    IDN support (--with-libidn2)"
     fi
 
     if test "no" != "$use_pkcs11"; then
@@ -26781,7 +26866,7 @@ report() {
     test "X$JSONSTATS" = "X" && echo "    JSON statistics (--with-libjson)"
     test "X$ZLIB" = "X" && echo "    HTTP zlib compression (--with-zlib)"
     test "X$NZD_TOOLS" = "X" && echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
-    test "no" = "$use_libidn2" && echo "    IDN support (--with-libidn2)"
+    test "no" = "$with_libidn2" && echo "    IDN support (--with-libidn2)"
 
     echo "-------------------------------------------------------------------------------"
     echo "Configured paths:"
index 7824531d2b161ba39a16635c2a832b2748fa623d..17506d2e9aa6cfed3548fc0bd0fe8924caceb441 100644 (file)
@@ -4521,38 +4521,35 @@ NOM_PATH_FILE(XSLT_DBLATEX_FASTBOOK, xsl/latex_book_fast.xsl, $dblatex_xsl_trees
 LIBIDN2_CFLAGS=
 LIBIDN2_LDFLAGS=
 LIBIDN2_LIBS=
-AC_ARG_WITH(libidn2,
-       AS_HELP_STRING([--with-libidn2[=PATH]], [enable IDN support using GNU libidn2 [yes|no|path]]),
-       use_libidn2="$withval", use_libidn2="no")
-AS_CASE([$use_libidn2],
-       [no],[:],
-       [yes],[:],
-       [*],[
-           LIBIDN2_CFLAGS="-I$use_libidn2/include"
-           LIBIDN2_LDFLAGS="-L$use_libidn2/lib"
-       ])
-
-AS_IF([test "$use_libidn2" != "no"],
-      [save_CFLAGS="$CFLAGS"
-       save_LIBS="$LIBS"
-       save_LDFLAGS="$LDFLAGS"
-       CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
-       LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
-       AC_SEARCH_LIBS([idn2_to_ascii_8z], [idn2],
-                     [AC_DEFINE(WITH_IDN_SUPPORT, 1, [define if IDN input support is to be included.])
-                       AC_DEFINE(WITH_LIBIDN2, 1, [define if libidn2 support is to be included.])
-                       LIBIDN2_LIBS="$LIBIDN2_LDFLAGS -lidn2"],
-                     [AC_MSG_ERROR([libidn2 requested, but not found])])
-       AC_TRY_LINK([#include <idn2.h>],
-                  [idn2_to_unicode_8zlz(".", NULL, IDN2_NONTRANSITIONAL|IDN2_NFC_INPUT);],
-                  [AC_MSG_RESULT(yes)
-                   AC_DEFINE(WITH_IDN_OUT_SUPPORT, 1, [define if IDN output support is to be included.])],
-                  [AC_MSG_RESULT([no])])
-       CFLAGS="$save_CFLAGS"
-       LIBS="$save_LIBS"
-       LDFLAGS="$save_LDFLAGS"
-      ])
+AC_ARG_WITH([libidn2],
+           [AS_HELP_STRING([--with-libidn2[=PATH]], [enable IDN support using GNU libidn2 [yes|no(default)|path]])],
+           [with_libidn2="$withval"], [with_libidn2="no"])
+AS_CASE([$with_libidn2],
+       [yes],  [PKG_CHECK_MODULES([LIBIDN2], [libidn2],
+                                  [AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 was found])])],
+       [no],   [],
+       [*],    [save_CFLAGS="$CFLAGS"
+                save_CPPFLAGS="$CPPFLAGS"
+                save_LDFLAGS="$LDFLAGS"
+                save_LIBS="$LIBS"
+                LIBIDN2_CFLAGS="-I$with_libidn2/include"
+                LIBIDN2_LDFLAGS="-L$with_libidn2/lib"
+                CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
+                CPPFLAGS="$LIBIDN2_CFLAGS $CPPFLAGS"
+                LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
+                AC_CHECK_HEADERS([idn2.h],
+                                 [],
+                                 [AC_MSG_ERROR([idn2.h not found])])
+                AC_SEARCH_LIBS([idn2_to_ascii_lz], [idn2],
+                               [LIBIDN2_LIBS="$ac_cv_search_idn2_to_ascii_lz"
+                                AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 was found])],
+                               [AC_MSG_ERROR([libidn2 requested, but not found])])
+                CFLAGS="$save_CFLAGS"
+                CPPFLAGS="$save_CPPFLAGS"
+                LDFLAGS="$save_LDFLAGS"
+                LIBS="$save_LIBS"])
 AC_SUBST([LIBIDN2_CFLAGS])
+AC_SUBST([LIBIDN2_LDFLAGS])
 AC_SUBST([LIBIDN2_LIBS])
 
 #
@@ -5313,7 +5310,7 @@ report() {
        test "X$JSONSTATS" = "X" || echo "    JSON statistics (--with-libjson)"
        test "X$ZLIB" = "X" || echo "    HTTP zlib compression (--with-zlib)"
        test "X$NZD_TOOLS" = "X" || echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
-       test "no" = "$use_libidn2" || echo "    IDN support (--with-libidn2)"
+       test "no" = "$with_libidn2" || echo "    IDN support (--with-libidn2)"
     fi
 
     if test "no" != "$use_pkcs11"; then
@@ -5410,7 +5407,7 @@ report() {
     test "X$JSONSTATS" = "X" && echo "    JSON statistics (--with-libjson)"
     test "X$ZLIB" = "X" && echo "    HTTP zlib compression (--with-zlib)"
     test "X$NZD_TOOLS" = "X" && echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
-    test "no" = "$use_libidn2" && echo "    IDN support (--with-libidn2)"
+    test "no" = "$with_libidn2" && echo "    IDN support (--with-libidn2)"
 
     echo "-------------------------------------------------------------------------------"
     echo "Configured paths:"