]> jfr.im git - irc/atheme/atheme.git/commitdiff
Build System: Improve library tests
authorAaron Jones <redacted>
Thu, 9 Jan 2020 19:48:38 +0000 (19:48 +0000)
committerAaron Jones <redacted>
Thu, 9 Jan 2020 19:56:11 +0000 (19:56 +0000)
For libraries that use pkg-config to detect their presence, make
pkg-config optional. This allows the user to set LIBFOO_CFLAGS and
LIBFOO_LIBS and still have it work, whether they have pkg-config
installed or not.

Also make it possible to specify the (full) path to the library
installation directory as an argument to the --with-foo= option.
This assumes that there are "include" and "lib" directories under
it, so use this as a last resort; override pkg-config (as described
above) instead if at all possible.

configure
configure.ac
include/atheme/sysconf.h.in
m4/atheme-libtest-argon2.m4
m4/atheme-libtest-crypto.m4
m4/atheme-libtest-idn.m4
m4/atheme-libtest-mowgli.m4
m4/atheme-libtest-nettle.m4
m4/atheme-libtest-pcre.m4
m4/atheme-libtest-qrencode.m4
m4/atheme-libtest-sodium.m4

index d3e8f6a332316c4cc715831a71bffed82f26f61d..6e9013919650851015f67edd0655cb024cc6aae2 100755 (executable)
--- a/configure
+++ b/configure
@@ -4552,9 +4552,6 @@ $as_echo "no" >&6; }
                PKG_CONFIG=""
        fi
 fi
-if test -z "${PKG_CONFIG}"; then :
-  as_fn_error $? "pkg-config not found" "$LINENO" 5
-fi
 
 
        # Extract the first word of "tput", so it can be a program name with args.
@@ -9777,6 +9774,7 @@ rm -f core conftest.err conftest.$ac_objext \
 
 
        LIBARGON2="No"
+       LIBARGON2_PATH=""
 
 
 # Check whether --with-libargon2 was given.
@@ -9790,6 +9788,10 @@ fi
        case "x${with_libargon2}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBARGON2_PATH="${with_libargon2}"
+                       with_libargon2="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-libargon2" "$LINENO" 5
                        ;;
@@ -9800,40 +9802,20 @@ fi
 
        if test "${with_libargon2}" != "no"; then :
 
-               LIBARGON2="Yes"
-
-                               for ac_func in sigfillset sigprocmask
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
+               if test -n "${LIBARGON2_PATH}"; then :
 
-else
-
-                       LIBARGON2="No"
-                       if test "${with_libargon2}" = "yes"; then :
-
-                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "--with-libargon2 was given but required signal functions are not available
-See \`config.log' for more details" "$LINENO" 5; }
-
-fi
-
-fi
-done
+                                               if test -d "${LIBARGON2_PATH}/include" -a -d "${LIBARGON2_PATH}/lib"; then :
 
+                               LIBARGON2_CFLAGS="-I${LIBARGON2_PATH}/include"
+                               LIBARGON2_LIBS="-L${LIBARGON2_PATH}/lib"
 
 else
 
-               LIBARGON2="No"
+                               as_fn_error $? "${LIBARGON2_PATH} is not a suitable directory for libargon2" "$LINENO" 5
 
 fi
 
-       if test "${LIBARGON2}" = "Yes"; then :
+elif test -n "${PKG_CONFIG}"; then :
 
 
 pkg_failed=no
        # Put the nasty error message in config.log where it belongs
        echo "$LIBARGON2_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (libargon2) were not met:
 
-                       LIBARGON2="No"
-                       if test "${with_libargon2}" = "yes"; then :
-
-                               as_fn_error $? "--with-libargon2 was given but libargon2 could not be found" "$LINENO" 5
+$LIBARGON2_PKG_ERRORS
 
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBARGON2_CFLAGS
+and LIBARGON2_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.
 
-                       LIBARGON2="No"
-                       if test "${with_libargon2}" = "yes"; then :
-
-                               as_fn_error $? "--with-libargon2 was given but libargon2 could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBARGON2_CFLAGS
+and LIBARGON2_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
        LIBARGON2_CFLAGS=$pkg_cv_LIBARGON2_CFLAGS
        LIBARGON2_LIBS=$pkg_cv_LIBARGON2_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBARGON2_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBARGON2_LIBS} ${LIBS}"
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libargon2 appears to be usable" >&5
+fi
+
+fi
+               if test -n "${LIBARGON2_CFLAGS+set}" -a -n "${LIBARGON2_LIBS+set}"; then :
+
+                                               LIBARGON2="Yes"
+
+else
+
+                       LIBARGON2="No"
+                       if test "${with_libargon2}" != "auto"; then :
+
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-libargon2 was given but libargon2 could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+
+fi
+
+fi
+
+fi
+
+       if test "${LIBARGON2}" = "Yes"; then :
+
+               CPPFLAGS="${LIBARGON2_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBARGON2_LIBS} ${LIBS}"
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libargon2 appears to be usable" >&5
 $as_echo_n "checking if libargon2 appears to be usable... " >&6; }
-                       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <argon2.h>
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #ifdef HAVE_SIGNAL_H
+                               #  include <signal.h>
+                               #endif
+                               #include <argon2.h>
 
 int
 main ()
 {
 
-                                       argon2_context ctx = {
-                                               .out = NULL,
-                                               .outlen = 0,
-                                               .pwd = NULL,
-                                               .pwdlen = 0,
-                                               .salt = NULL,
-                                               .saltlen = 0,
-                                               .secret = NULL,
-                                               .secretlen = 0,
-                                               .ad = NULL,
-                                               .adlen = 0,
-                                               .t_cost = ARGON2_MAX_TIME,
-                                               .m_cost = ARGON2_MAX_MEMORY,
-                                               .lanes = 1,
-                                               .threads = 1,
-                                               .version = ARGON2_VERSION_13,
-                                               .allocate_cbk = NULL,
-                                               .free_cbk = NULL,
-                                               .flags = 0,
-                                       };
-                                       (void) argon2_ctx(&ctx, Argon2_d);
-                                       (void) argon2_ctx(&ctx, Argon2_i);
-                                       (void) argon2_ctx(&ctx, Argon2_id);
-                                       (void) argon2_error_message(0);
-                                       (void) argon2_type2string(0, 0);
+                               // POSIX.1-2001 Signal-blocking functions are necessary for thread-safety
+                               sigset_t oldset;
+                               sigset_t newset;
+                               (void) sigfillset(&newset);
+                               (void) sigprocmask(SIG_BLOCK, &newset, &oldset);
+
+                               argon2_context ctx = {
+                                       .out = NULL,
+                                       .outlen = 0,
+                                       .pwd = NULL,
+                                       .pwdlen = 0,
+                                       .salt = NULL,
+                                       .saltlen = 0,
+                                       .t_cost = ARGON2_MAX_TIME,
+                                       .m_cost = ARGON2_MAX_MEMORY,
+                                       .lanes = 1,
+                                       .threads = 1,
+                                       .version = ARGON2_VERSION_NUMBER,
+                               };
+                               (void) argon2_ctx(&ctx, Argon2_d);
+                               (void) argon2_ctx(&ctx, Argon2_i);
+                               (void) argon2_ctx(&ctx, Argon2_id);
+                               (void) argon2_error_message(0);
+                               (void) argon2_type2string(0, 0);
 
   ;
   return 0;
@@ -9969,21 +9985,21 @@ main ()
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-                               LIBARGON2="Yes"
+                       LIBARGON2="Yes"
 
 $as_echo "#define HAVE_LIBARGON2 1" >>confdefs.h
 
 
 else
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                               LIBARGON2="No"
-                               if test "${with_libargon2}" = "yes"; then :
+                       LIBARGON2="No"
+                       if test "${with_libargon2}" != "auto"; then :
 
-                                       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "--with-libargon2 was given but libargon2 appears to be unusable
 See \`config.log' for more details" "$LINENO" 5; }
@@ -9994,8 +10010,6 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-fi
-
 fi
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
@@ -10344,6 +10358,7 @@ fi
 
 
        LIBCRYPTO="No"
+       LIBCRYPTO_PATH=""
        LIBCRYPTO_NAME=""
        LIBCRYPTO_USABLE="No"
        LIBCRYPTO_DIGEST="No"
        case "x${with_openssl}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBCRYPTO_PATH="${with_openssl}"
+                       with_openssl="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-openssl" "$LINENO" 5
                        ;;
 
        if test "${with_openssl}" != "no"; then :
 
+               if test -n "${LIBCRYPTO_PATH}"; then :
+
+                                               if test -d "${LIBCRYPTO_PATH}/include" -a -d "${LIBCRYPTO_PATH}/lib"; then :
+
+                               LIBCRYPTO_CFLAGS="-I${LIBCRYPTO_PATH}/include"
+                               LIBCRYPTO_LIBS="-L${LIBCRYPTO_PATH}/lib"
+
+else
+
+                               as_fn_error $? "${LIBCRYPTO_PATH} is not a suitable directory for OpenSSL" "$LINENO" 5
+
+fi
+
+elif test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBCRYPTO" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$LIBCRYPTO_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (libcrypto) were not met:
 
-                       LIBCRYPTO="No"
-                       if test "${with_openssl}" = "yes"; then :
+$LIBCRYPTO_PKG_ERRORS
 
-                               as_fn_error $? "--with-openssl was given but libcrypto could not be found" "$LINENO" 5
-
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBCRYPTO_CFLAGS
+and LIBCRYPTO_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.
 
-                       LIBCRYPTO="No"
-                       if test "${with_openssl}" = "yes"; then :
-
-                               as_fn_error $? "--with-openssl was given but libcrypto could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBCRYPTO_CFLAGS
+and LIBCRYPTO_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
        LIBCRYPTO_CFLAGS=$pkg_cv_LIBCRYPTO_CFLAGS
        LIBCRYPTO_LIBS=$pkg_cv_LIBCRYPTO_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBCRYPTO_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBCRYPTO_LIBS} ${LIBS}"
-                       LIBCRYPTO="Yes"
-                       for ac_header in openssl/opensslv.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "openssl/opensslv.h" "ac_cv_header_openssl_opensslv_h" "$ac_includes_default"
-if test "x$ac_cv_header_openssl_opensslv_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_OPENSSL_OPENSSLV_H 1
-_ACEOF
-
-else
-
-                               LIBCRYPTO="No"
-                               if test "${with_openssl}" = "yes"; then :
-
-                                       as_fn_error $? "--with-openssl was given but a required header file is missing" "$LINENO" 5
-
 fi
 
 fi
+               if test -n "${LIBCRYPTO_CFLAGS+set}" -a -n "${LIBCRYPTO_LIBS+set}"; then :
 
-done
+                                               LIBCRYPTO="Yes"
 
+else
 
-fi
+                       LIBCRYPTO="No"
+                       if test "${with_openssl}" != "auto"; then :
 
-else
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-openssl was given but OpenSSL could not be found
+See \`config.log' for more details" "$LINENO" 5; }
 
-               LIBCRYPTO="No"
+fi
+
+fi
 
 fi
 
        if test "${LIBCRYPTO}" = "Yes"; then :
 
+               CPPFLAGS="${LIBCRYPTO_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBCRYPTO_LIBS} ${LIBS}"
+
                { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libcrypto has usable MD5/SHA1/SHA2/HMAC/PBKDF2 functions" >&5
 $as_echo_n "checking if libcrypto has usable MD5/SHA1/SHA2/HMAC/PBKDF2 functions... " >&6; }
                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -10501,6 +10534,7 @@ $as_echo_n "checking if libcrypto has usable MD5/SHA1/SHA2/HMAC/PBKDF2 functions
                                #endif
                                #include <openssl/evp.h>
                                #include <openssl/hmac.h>
+                               #include <openssl/opensslv.h>
 
 int
 main ()
@@ -10543,6 +10577,7 @@ $as_echo_n "checking if libcrypto has HMAC_CTX_new() & HMAC_CTX_free()... " >&6;
                                        #  include <stddef.h>
                                        #endif
                                        #include <openssl/hmac.h>
+                                       #include <openssl/opensslv.h>
 
 int
 main ()
@@ -10593,6 +10628,7 @@ $as_echo_n "checking if libcrypto has a usable random number generator... " >&6;
                                #endif
                                #include <openssl/err.h>
                                #include <openssl/rand.h>
+                               #include <openssl/opensslv.h>
 
 int
 main ()
@@ -10635,6 +10671,7 @@ $as_echo_n "checking if libcrypto has a usable constant-time memory comparison f
                                #  include <stddef.h>
                                #endif
                                #include <openssl/crypto.h>
+                               #include <openssl/opensslv.h>
 
 int
 main ()
@@ -10675,6 +10712,7 @@ $as_echo_n "checking if libcrypto can provide SASL ECDH-X25519-CHALLENGE... " >&
                                #  include <stddef.h>
                                #endif
                                #include <openssl/curve25519.h>
+                               #include <openssl/opensslv.h>
 
 int
 main ()
@@ -10727,6 +10765,7 @@ $as_echo_n "checking if libcrypto can provide SASL ECDSA-NIST256P-CHALLENGE... "
                                #include <openssl/ec.h>
                                #include <openssl/ecdsa.h>
                                #include <openssl/evp.h>
+                               #include <openssl/opensslv.h>
 
 int
 main ()
@@ -10813,7 +10852,7 @@ $as_echo "#define HAVE_LIBCRYPTO 1" >>confdefs.h
 else
 
                LIBCRYPTO="No"
-               if test "${with_openssl}" = "yes"; then :
+               if test "${with_openssl}" != "auto"; then :
 
                        { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -10840,6 +10879,7 @@ fi
 
 
        LIBIDN="No"
+       LIBIDN_PATH=""
 
 
 # Check whether --with-libidn was given.
        case "x${with_libidn}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBIDN_PATH="${with_libidn}"
+                       with_libidn="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-libidn" "$LINENO" 5
                        ;;
 
        if test "${with_libidn}" != "no"; then :
 
+               if test -n "${LIBIDN_PATH}"; then :
+
+                                               if test -d "${LIBIDN_PATH}/include" -a -d "${LIBIDN_PATH}/lib"; then :
+
+                               LIBIDN_CFLAGS="-I${LIBIDN_PATH}/include"
+                               LIBIDN_LIBS="-L${LIBIDN_PATH}/lib"
+
+else
+
+                               as_fn_error $? "${LIBIDN_PATH} is not a suitable directory for GNU libidn" "$LINENO" 5
+
+fi
+
+elif test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBIDN" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$LIBIDN_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (libidn) were not met:
 
-                       LIBIDN="No"
-                       if test "${with_libidn}" = "yes"; then :
+$LIBIDN_PKG_ERRORS
 
-                               as_fn_error $? "--with-libidn was given but libidn could not be found" "$LINENO" 5
-
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBIDN_CFLAGS
+and LIBIDN_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.
 
-                       LIBIDN="No"
-                       if test "${with_libidn}" = "yes"; then :
-
-                               as_fn_error $? "--with-libidn was given but libidn could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBIDN_CFLAGS
+and LIBIDN_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
        LIBIDN_CFLAGS=$pkg_cv_LIBIDN_CFLAGS
        LIBIDN_LIBS=$pkg_cv_LIBIDN_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBIDN_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBIDN_LIBS} ${LIBS}"
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libidn appears to be usable" >&5
-$as_echo_n "checking if libidn appears to be usable... " >&6; }
-                       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+fi
+
+fi
+               if test -n "${LIBIDN_CFLAGS+set}" -a -n "${LIBIDN_LIBS+set}"; then :
+
+                                               LIBIDN="Yes"
+
+else
+
+                       LIBIDN="No"
+                       if test "${with_libidn}" != "auto"; then :
+
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-libidn was given but GNU libidn could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+
+fi
+
+fi
+
+fi
+
+       if test "${LIBIDN}" = "Yes"; then :
+
+               CPPFLAGS="${LIBIDN_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBIDN_LIBS} ${LIBS}"
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GNU libidn appears to be usable" >&5
+$as_echo_n "checking if GNU libidn appears to be usable... " >&6; }
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <stringprep.h>
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #include <stringprep.h>
 
 int
 main ()
 {
 
-                                       (void) stringprep_locale_to_utf8(NULL);
-                                       (void) stringprep(NULL, 0, (Stringprep_profile_flags) 0, stringprep_saslprep);
+                               (void) stringprep_locale_to_utf8(NULL);
+                               (void) stringprep(NULL, 0, (Stringprep_profile_flags) 0, stringprep_saslprep);
 
   ;
   return 0;
@@ -10974,23 +11065,23 @@ main ()
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-                               LIBIDN="Yes"
+                       LIBIDN="Yes"
 
 $as_echo "#define HAVE_LIBIDN 1" >>confdefs.h
 
 
 else
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                               LIBIDN="No"
-                               if test "${with_libidn}" = "yes"; then :
+                       LIBIDN="No"
+                       if test "${with_libidn}" != "auto"; then :
 
-                                       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "--with-libidn was given but libidn appears to be unusable
+as_fn_error $? "--with-libidn was given but GNU libidn appears to be unusable
 See \`config.log' for more details" "$LINENO" 5; }
 
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-fi
-
-else
-
-               LIBIDN="No"
-
 fi
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
@@ -11685,6 +11770,7 @@ fi
 
 
        LIBNETTLE="No"
+       LIBNETTLE_PATH=""
        LIBNETTLE_USABLE="No"
        LIBNETTLE_DIGEST="No"
 
        case "x${with_nettle}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBNETTLE_PATH="${with_nettle}"
+                       with_nettle="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-nettle" "$LINENO" 5
                        ;;
 
        if test "${with_nettle}" != "no"; then :
 
+               if test -n "${LIBNETTLE_PATH}"; then :
+
+                                               if test -d "${LIBNETTLE_PATH}/include" -a -d "${LIBNETTLE_PATH}/lib"; then :
+
+                               LIBNETTLE_CFLAGS="-I${LIBNETTLE_PATH}/include"
+                               LIBNETTLE_LIBS="-L${LIBNETTLE_PATH}/lib"
+
+else
+
+                               as_fn_error $? "${LIBNETTLE_PATH} is not a suitable directory for GNU Nettle" "$LINENO" 5
+
+fi
+
+elif test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNETTLE" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$LIBNETTLE_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (nettle) were not met:
 
-                       LIBNETTLE="No"
-                       if test "${with_nettle}" = "yes"; then :
-
-                               as_fn_error $? "--with-nettle was given but libnettle could not be found" "$LINENO" 5
+$LIBNETTLE_PKG_ERRORS
 
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBNETTLE_CFLAGS
+and LIBNETTLE_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.
 
-                       LIBNETTLE="No"
-                       if test "${with_nettle}" = "yes"; then :
-
-                               as_fn_error $? "--with-nettle was given but libnettle could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBNETTLE_CFLAGS
+and LIBNETTLE_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
        LIBNETTLE_CFLAGS=$pkg_cv_LIBNETTLE_CFLAGS
        LIBNETTLE_LIBS=$pkg_cv_LIBNETTLE_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBNETTLE_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBNETTLE_LIBS} ${LIBS}"
-                       LIBNETTLE="Yes"
+fi
 
 fi
+               if test -n "${LIBNETTLE_CFLAGS+set}" -a -n "${LIBNETTLE_LIBS+set}"; then :
+
+                                               LIBNETTLE="Yes"
 
 else
 
-               LIBNETTLE="No"
+                       LIBNETTLE="No"
+                       if test "${with_nettle}" != "auto"; then :
+
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-nettle was given but GNU Nettle could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+
+fi
+
+fi
 
 fi
 
        if test "${LIBNETTLE}" = "Yes"; then :
 
-               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libnettle has usable MD5/SHA1/SHA2 functions" >&5
-$as_echo_n "checking if libnettle has usable MD5/SHA1/SHA2 functions... " >&6; }
+               CPPFLAGS="${LIBNETTLE_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBNETTLE_LIBS} ${LIBS}"
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GNU Nettle has usable MD5/SHA1/SHA2 functions" >&5
+$as_echo_n "checking if GNU Nettle has usable MD5/SHA1/SHA2 functions... " >&6; }
                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -11864,8 +11989,8 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libnettle has a usable constant-time memory comparison function" >&5
-$as_echo_n "checking if libnettle has a usable constant-time memory comparison function... " >&6; }
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GNU Nettle has a usable constant-time memory comparison function" >&5
+$as_echo_n "checking if GNU Nettle has a usable constant-time memory comparison function... " >&6; }
                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -11904,8 +12029,8 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libnettle can provide SASL ECDH-X25519-CHALLENGE" >&5
-$as_echo_n "checking if libnettle can provide SASL ECDH-X25519-CHALLENGE... " >&6; }
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GNU Nettle can provide SASL ECDH-X25519-CHALLENGE" >&5
+$as_echo_n "checking if GNU Nettle can provide SASL ECDH-X25519-CHALLENGE... " >&6; }
                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -11980,11 +12105,11 @@ done
 else
 
                LIBNETTLE="No"
-               if test "${with_nettle}" = "yes"; then :
+               if test "${with_nettle}" != "auto"; then :
 
                        { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "--with-nettle was given but libnettle appears to be unusable
+as_fn_error $? "--with-nettle was given but GNU Nettle appears to be unusable
 See \`config.log' for more details" "$LINENO" 5; }
 
 fi
@@ -12172,6 +12297,7 @@ fi
 
 
        LIBPCRE="No"
+       LIBPCRE_PATH=""
 
 
 # Check whether --with-pcre was given.
        case "x${with_pcre}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBPCRE_PATH="${with_pcre}"
+                       with_pcre="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-pcre" "$LINENO" 5
                        ;;
 
        if test "${with_pcre}" != "no"; then :
 
+               if test -n "${LIBPCRE_PATH}"; then :
+
+                                               if test -d "${LIBPCRE_PATH}/include" -a -d "${LIBPCRE_PATH}/lib"; then :
+
+                               LIBPCRE_CFLAGS="-I${LIBPCRE_PATH}/include"
+                               LIBPCRE_LIBS="-L${LIBPCRE_PATH}/lib"
+
+else
+
+                               as_fn_error $? "${LIBPCRE_PATH} is not a suitable directory for libpcre" "$LINENO" 5
+
+fi
+
+elif test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBPCRE" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$LIBPCRE_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (libpcre) were not met:
 
-                       LIBPCRE="No"
-                       if test "${with_pcre}" = "yes"; then :
-
-                               as_fn_error $? "--with-pcre was given but libpcre could not be found" "$LINENO" 5
+$LIBPCRE_PKG_ERRORS
 
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBPCRE_CFLAGS
+and LIBPCRE_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.
 
-                       LIBPCRE="No"
-                       if test "${with_pcre}" = "yes"; then :
-
-                               as_fn_error $? "--with-pcre was given but libpcre could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBPCRE_CFLAGS
+and LIBPCRE_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
        LIBPCRE_CFLAGS=$pkg_cv_LIBPCRE_CFLAGS
        LIBPCRE_LIBS=$pkg_cv_LIBPCRE_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBPCRE_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBPCRE_LIBS} ${LIBS}"
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libpcre appears to be usable" >&5
+fi
+
+fi
+               if test -n "${LIBPCRE_CFLAGS+set}" -a -n "${LIBPCRE_LIBS+set}"; then :
+
+                                               LIBPCRE="Yes"
+
+else
+
+                       LIBPCRE="No"
+                       if test "${with_pcre}" != "auto"; then :
+
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-pcre was given but libpcre could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+
+fi
+
+fi
+
+fi
+
+       if test "${LIBPCRE}" = "Yes"; then :
+
+               CPPFLAGS="${LIBPCRE_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBPCRE_LIBS} ${LIBS}"
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libpcre appears to be usable" >&5
 $as_echo_n "checking if libpcre appears to be usable... " >&6; }
-                       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <pcre.h>
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #include <pcre.h>
 
 int
 main ()
 {
 
-                                       (void) pcre_compile(NULL, 0, NULL, NULL, NULL);
-                                       (void) pcre_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0);
-                                       (void) pcre_free(NULL);
+                               (void) pcre_compile(NULL, 0, NULL, NULL, NULL);
+                               (void) pcre_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0);
+                               (void) pcre_free(NULL);
 
   ;
   return 0;
@@ -12307,21 +12484,21 @@ main ()
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-                               LIBPCRE="Yes"
+                       LIBPCRE="Yes"
 
 $as_echo "#define HAVE_LIBPCRE 1" >>confdefs.h
 
 
 else
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                               LIBPCRE="No"
-                               if test "${with_pcre}" = "yes"; then :
+                       LIBPCRE="No"
+                       if test "${with_pcre}" != "auto"; then :
 
-                                       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "--with-pcre was given but libpcre does not appear to be usable
 See \`config.log' for more details" "$LINENO" 5; }
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-fi
-
-else
-
-               LIBPCRE="No"
-
 fi
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
@@ -12356,6 +12527,7 @@ fi
 
 
        LIBQRENCODE="No"
+       LIBQRENCODE_PATH=""
 
 
 # Check whether --with-qrencode was given.
        case "x${with_qrencode}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBQRENCODE_PATH="${with_qrencode}"
+                       with_qrencode="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-qrencode" "$LINENO" 5
                        ;;
 
        if test "${with_qrencode}" != "no"; then :
 
+               if test -n "${LIBQRENCODE_PATH}"; then :
+
+                                               if test -d "${LIBQRENCODE_PATH}/include" -a -d "${LIBQRENCODE_PATH}/lib"; then :
+
+                               LIBQRENCODE_CFLAGS="-I${LIBQRENCODE_PATH}/include"
+                               LIBQRENCODE_LIBS="-L${LIBQRENCODE_PATH}/lib"
+
+else
+
+                               as_fn_error $? "${LIBQRENCODE_PATH} is not a suitable directory for libqrencode" "$LINENO" 5
+
+fi
+
+elif test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBQRENCODE" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$LIBQRENCODE_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (libqrencode) were not met:
 
-                       LIBQRENCODE="No"
-                       if test "${with_qrencode}" = "yes"; then :
-
-                               as_fn_error $? "--with-qrencode was given but libqrencode could not be found" "$LINENO" 5
+$LIBQRENCODE_PKG_ERRORS
 
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBQRENCODE_CFLAGS
+and LIBQRENCODE_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.
 
-                       LIBQRENCODE="No"
-                       if test "${with_qrencode}" = "yes"; then :
-
-                               as_fn_error $? "--with-qrencode was given but libqrencode could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBQRENCODE_CFLAGS
+and LIBQRENCODE_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
        LIBQRENCODE_CFLAGS=$pkg_cv_LIBQRENCODE_CFLAGS
        LIBQRENCODE_LIBS=$pkg_cv_LIBQRENCODE_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBQRENCODE_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBQRENCODE_LIBS} ${LIBS}"
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libqrencode appears to be usable" >&5
+fi
+
+fi
+               if test -n "${LIBQRENCODE_CFLAGS+set}" -a -n "${LIBQRENCODE_LIBS+set}"; then :
+
+                                               LIBQRENCODE="Yes"
+
+else
+
+                       LIBQRENCODE="No"
+                       if test "${with_qrencode}" != "auto"; then :
+
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-qrencode was given but libqrencode could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+
+fi
+
+fi
+
+fi
+
+       if test "${LIBQRENCODE}" = "Yes"; then :
+
+               CPPFLAGS="${LIBQRENCODE_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBQRENCODE_LIBS} ${LIBS}"
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libqrencode appears to be usable" >&5
 $as_echo_n "checking if libqrencode appears to be usable... " >&6; }
-                       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <qrencode.h>
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #include <qrencode.h>
 
 int
 main ()
 {
 
-                                       (void) QRcode_encodeData(0, NULL, 0, (QRecLevel) 0);
-                                       (void) QRcode_free(NULL);
+                               (void) QRcode_encodeData(0, NULL, 0, (QRecLevel) 0);
+                               (void) QRcode_free(NULL);
 
   ;
   return 0;
@@ -12490,9 +12713,9 @@ main ()
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-                               LIBQRENCODE="Yes"
+                       LIBQRENCODE="Yes"
 
 $as_echo "#define HAVE_LIBQRENCODE 1" >>confdefs.h
 
@@ -12504,12 +12727,12 @@ $as_echo "#define HAVE_LIBQRENCODE 1" >>confdefs.h
 
 else
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                               LIBQRENCODE="No"
-                               if test "${with_qrencode}" = "yes"; then :
+                       LIBQRENCODE="No"
+                       if test "${with_qrencode}" != "auto"; then :
 
-                                       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "--with-qrencode was given but libqrencode does not appear to be usable
 See \`config.log' for more details" "$LINENO" 5; }
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-fi
-
-else
-
-               LIBQRENCODE="No"
-
 fi
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
@@ -12544,6 +12761,7 @@ fi
 
 
        LIBSODIUM="No"
+       LIBSODIUM_PATH=""
        LIBSODIUM_USABLE="No"
        LIBSODIUM_MEMORY="No"
        LIBSODIUM_RANDOM="No"
        case "x${with_sodium}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBSODIUM_PATH="${with_sodium}"
+                       with_sodium="yes"
+                       ;;
                *)
                        as_fn_error $? "invalid option for --with-sodium" "$LINENO" 5
                        ;;
 
        if test "${with_sodium}" != "no"; then :
 
+               if test -n "${LIBSODIUM_PATH}"; then :
+
+                                               if test -d "${LIBSODIUM_PATH}/include" -a -d "${LIBSODIUM_PATH}/lib"; then :
+
+                               LIBSODIUM_CFLAGS="-I${LIBSODIUM_PATH}/include"
+                               LIBSODIUM_LIBS="-L${LIBSODIUM_PATH}/lib"
+
+else
+
+                               as_fn_error $? "${LIBSODIUM_PATH} is not a suitable directory for libsodium" "$LINENO" 5
+
+fi
+
+elif test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBSODIUM" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$LIBSODIUM_PKG_ERRORS" >&5
 
+       as_fn_error $? "Package requirements (libsodium) were not met:
 
-                       LIBSODIUM="No"
-                       if test "${with_sodium}" = "yes"; then :
+$LIBSODIUM_PKG_ERRORS
 
-                               as_fn_error $? "--with-sodium was given but libsodium could not be found" "$LINENO" 5
-
-fi
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
 
+Alternatively, you may set the environment variables LIBSODIUM_CFLAGS
+and LIBSODIUM_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.
 
-                       LIBSODIUM="No"
-                       if test "${with_sodium}" = "yes"; then :
-
-                               as_fn_error $? "--with-sodium was given but libsodium could not be found" "$LINENO" 5
-
-fi
+Alternatively, you may set the environment variables LIBSODIUM_CFLAGS
+and LIBSODIUM_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
        LIBSODIUM_CFLAGS=$pkg_cv_LIBSODIUM_CFLAGS
        LIBSODIUM_LIBS=$pkg_cv_LIBSODIUM_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       CPPFLAGS="${LIBSODIUM_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBSODIUM_LIBS} ${LIBS}"
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libsodium appears to be usable" >&5
+fi
+
+fi
+               if test -n "${LIBSODIUM_CFLAGS+set}" -a -n "${LIBSODIUM_LIBS+set}"; then :
+
+                                               LIBSODIUM="Yes"
+
+else
+
+                       LIBSODIUM="No"
+                       if test "${with_sodium}" != "auto"; then :
+
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "--with-sodium was given but libsodium could not be found
+See \`config.log' for more details" "$LINENO" 5; }
+
+fi
+
+fi
+
+fi
+
+       if test "${LIBSODIUM}" = "Yes"; then :
+
+               CPPFLAGS="${LIBSODIUM_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBSODIUM_LIBS} ${LIBS}"
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libsodium appears to be usable" >&5
 $as_echo_n "checking if libsodium appears to be usable... " >&6; }
-                       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
-                                       #include <sodium/core.h>
-                                       #include <sodium/utils.h>
-                                       #include <sodium/version.h>
+                               #include <sodium/core.h>
+                               #include <sodium/utils.h>
+                               #include <sodium/version.h>
 
 int
 main ()
 {
 
-                                       (void) sodium_init();
+                               (void) sodium_init();
 
   ;
   return 0;
@@ -12679,18 +12948,18 @@ main ()
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-                               LIBSODIUM="Yes"
+                       LIBSODIUM="Yes"
 
 else
 
-                               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                               LIBSODIUM="No"
-                               if test "${with_sodium}" = "yes"; then :
+                       LIBSODIUM="No"
+                       if test "${with_sodium}" != "auto"; then :
 
-                                       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+                               { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "--with-sodium was given but libsodium appears to be unusable
 See \`config.log' for more details" "$LINENO" 5; }
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-fi
-
-else
-
-               LIBSODIUM="No"
-
 fi
 
        if test "${LIBSODIUM}" = "Yes"; then :
@@ -12985,7 +13248,7 @@ $as_echo "#define HAVE_LIBSODIUM 1" >>confdefs.h
 else
 
                LIBSODIUM="No"
-               if test "${with_sodium}" = "yes"; then :
+               if test "${with_sodium}" != "auto"; then :
 
                        { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -18179,8 +18442,20 @@ else
 fi
 
 
+       case "x${with_libmowgli}" in
+               xno | xyes)
+                       ;;
+               x/*)
+                       ;;
+               *)
+                       as_fn_error $? "invalid option for --with-libmowgli" "$LINENO" 5
+                       ;;
+       esac
+
        if test "x${with_libmowgli}" = "xyes"; then :
 
+               if test -n "${PKG_CONFIG}"; then :
+
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MOWGLI" >&5
        # Put the nasty error message in config.log where it belongs
        echo "$MOWGLI_PKG_ERRORS" >&5
 
-
-                       with_libmowgli="no"
-
+       with_libmowgli="no"
 elif test $pkg_failed = untried; then
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-
-                       with_libmowgli="no"
-
+       with_libmowgli="no"
 else
        MOWGLI_CFLAGS=$pkg_cv_MOWGLI_CFLAGS
        MOWGLI_LIBS=$pkg_cv_MOWGLI_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-                       MOWGLI_SOURCE="System"
-                       CPPFLAGS="${CPPFLAGS} ${MOWGLI_CFLAGS}"
-                       LIBS="${LIBS} ${MOWGLI_LIBS}"
+fi
+
+else
+
+                       with_libmowgli="no"
 
 fi
 
 
        if test "x${with_libmowgli}" = "xyes"; then :
 
+               MOWGLI_SOURCE="System"
+               CPPFLAGS="${CPPFLAGS} ${MOWGLI_CFLAGS}"
+               LIBS="${LIBS} ${MOWGLI_LIBS}"
+
 elif test "x${with_libmowgli}" = "xno"; then :
 
                MOWGLI_SOURCE="Internal"
@@ -18277,13 +18554,17 @@ elif test "x${with_libmowgli}" = "xno"; then :
 
 
 
-else
+elif test -d "${with_libmowgli}/include/libmowgli-2" -a -d "${with_libmowgli}/lib"; then :
 
                MOWGLI_SOURCE="System"
                CPPFLAGS="${CPPFLAGS} -I${with_libmowgli}/include/libmowgli-2"
                LDFLAGS="${LDFLAGS} -L${with_libmowgli}/lib"
                LIBS="${LIBS} -lmowgli-2"
 
+else
+
+               as_fn_error $? "${with_libmowgli} is not a suitable directory for libmowgli" "$LINENO" 5
+
 fi
 
 
index 88346e33ced58b59b105842e83ef128db5242474..3989a11f301d443cbe20a2930913085b3fd409d1 100644 (file)
@@ -78,7 +78,6 @@ AC_PATH_PROG([RM], [rm])
 AC_PROG_SED
 AC_PATH_PROG([TAR], [tar])
 PKG_PROG_PKG_CONFIG
-AS_IF([test -z "${PKG_CONFIG}"], [AC_MSG_ERROR([pkg-config not found])])
 
 dnl Initialise our build system
 BUILDSYS_INIT
index 00ae85fec3d7e82f9af8dd80d370c902013971c1..9da89ccb948ec5aaa89775b93f6d1ad69ea1ceb0 100644 (file)
 /* Define to 1 if libmbedcrypto has usable HMAC-DRBG functions */
 #undef HAVE_LIBMBEDCRYPTO_HMAC_DRBG
 
-/* Define to 1 if libnettle appears to be usable */
+/* Define to 1 if GNU Nettle appears to be usable */
 #undef HAVE_LIBNETTLE
 
-/* Define to 1 if libnettle can provide SASL ECDH-X25519-CHALLENGE */
+/* Define to 1 if GNU Nettle can provide SASL ECDH-X25519-CHALLENGE */
 #undef HAVE_LIBNETTLE_ECDH_X25519
 
-/* Define to 1 if libnettle has a usable constant-time memory comparison
+/* Define to 1 if GNU Nettle has a usable constant-time memory comparison
    function */
 #undef HAVE_LIBNETTLE_MEMEQL
 
 /* Define to 1 if you have the <nettle/version.h> header file. */
 #undef HAVE_NETTLE_VERSION_H
 
-/* Define to 1 if you have the <openssl/opensslv.h> header file. */
-#undef HAVE_OPENSSL_OPENSSLV_H
-
 /* Define to 1 if the system has the type `ptrdiff_t'. */
 #undef HAVE_PTRDIFF_T
 
 /* Define to 1 if you have the `setlocale' function. */
 #undef HAVE_SETLOCALE
 
-/* Define to 1 if you have the `sigfillset' function. */
-#undef HAVE_SIGFILLSET
-
 /* Define to 1 if you have the <signal.h> header file. */
 #undef HAVE_SIGNAL_H
 
-/* Define to 1 if you have the `sigprocmask' function. */
-#undef HAVE_SIGPROCMASK
-
 /* Define to 1 if you have a C99 compliant `snprintf' function. */
 #undef HAVE_SNPRINTF
 
index fdaeefa070d4d70602250a67c5a4d7093aa5d0da..2fe1a346e378bbdb3927798f3dabe76fb5b4702e 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_ARGON2], [
 
        LIBARGON2="No"
+       LIBARGON2_PATH=""
 
        AC_ARG_WITH([libargon2],
                [AS_HELP_STRING([--without-libargon2], [Do not attempt to detect libargon2 (for modules/crypto/argon2)])],
@@ -9,6 +10,10 @@ AC_DEFUN([ATHEME_LIBTEST_ARGON2], [
        case "x${with_libargon2}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBARGON2_PATH="${with_libargon2}"
+                       with_libargon2="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-libargon2])
                        ;;
@@ -18,72 +23,78 @@ AC_DEFUN([ATHEME_LIBTEST_ARGON2], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_libargon2}" != "no"], [
-               LIBARGON2="Yes"
-
-               dnl Signal blocking functions are necessary for thread-safety    -- amdj
-               AC_CHECK_FUNCS([sigfillset sigprocmask], [], [
+               AS_IF([test -n "${LIBARGON2_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBARGON2_PATH}/include" -a -d "${LIBARGON2_PATH}/lib"], [
+                               LIBARGON2_CFLAGS="-I${LIBARGON2_PATH}/include"
+                               LIBARGON2_LIBS="-L${LIBARGON2_PATH}/lib"
+                       ], [
+                               AC_MSG_ERROR([${LIBARGON2_PATH} is not a suitable directory for libargon2])
+                       ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBARGON2], [libargon2], [], [])
+               ])
+               AS_IF([test -n "${LIBARGON2_CFLAGS+set}" -a -n "${LIBARGON2_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
+                       LIBARGON2="Yes"
+               ], [
                        LIBARGON2="No"
-                       AS_IF([test "${with_libargon2}" = "yes"], [
-                               AC_MSG_FAILURE([--with-libargon2 was given but required signal functions are not available])
+                       AS_IF([test "${with_libargon2}" != "auto"], [
+                               AC_MSG_FAILURE([--with-libargon2 was given but libargon2 could not be found])
                        ])
                ])
-       ], [
-               LIBARGON2="No"
        ])
 
        AS_IF([test "${LIBARGON2}" = "Yes"], [
-               PKG_CHECK_MODULES([LIBARGON2], [libargon2], [
-                       CPPFLAGS="${LIBARGON2_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBARGON2_LIBS} ${LIBS}"
-                       AC_MSG_CHECKING([if libargon2 appears to be usable])
-                       AC_LINK_IFELSE([
-                               AC_LANG_PROGRAM([[
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <argon2.h>
-                               ]], [[
-                                       argon2_context ctx = {
-                                               .out = NULL,
-                                               .outlen = 0,
-                                               .pwd = NULL,
-                                               .pwdlen = 0,
-                                               .salt = NULL,
-                                               .saltlen = 0,
-                                               .secret = NULL,
-                                               .secretlen = 0,
-                                               .ad = NULL,
-                                               .adlen = 0,
-                                               .t_cost = ARGON2_MAX_TIME,
-                                               .m_cost = ARGON2_MAX_MEMORY,
-                                               .lanes = 1,
-                                               .threads = 1,
-                                               .version = ARGON2_VERSION_13,
-                                               .allocate_cbk = NULL,
-                                               .free_cbk = NULL,
-                                               .flags = 0,
-                                       };
-                                       (void) argon2_ctx(&ctx, Argon2_d);
-                                       (void) argon2_ctx(&ctx, Argon2_i);
-                                       (void) argon2_ctx(&ctx, Argon2_id);
-                                       (void) argon2_error_message(0);
-                                       (void) argon2_type2string(0, 0);
-                               ]])
-                       ], [
-                               AC_MSG_RESULT([yes])
-                               LIBARGON2="Yes"
-                               AC_DEFINE([HAVE_LIBARGON2], [1], [Define to 1 if libargon2 appears to be usable])
-                       ], [
-                               AC_MSG_RESULT([no])
-                               LIBARGON2="No"
-                               AS_IF([test "${with_libargon2}" = "yes"], [
-                                       AC_MSG_FAILURE([--with-libargon2 was given but libargon2 appears to be unusable])
-                               ])
-                       ])
+               CPPFLAGS="${LIBARGON2_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBARGON2_LIBS} ${LIBS}"
+
+               AC_MSG_CHECKING([if libargon2 appears to be usable])
+               AC_LINK_IFELSE([
+                       AC_LANG_PROGRAM([[
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #ifdef HAVE_SIGNAL_H
+                               #  include <signal.h>
+                               #endif
+                               #include <argon2.h>
+                       ]], [[
+                               // POSIX.1-2001 Signal-blocking functions are necessary for thread-safety
+                               sigset_t oldset;
+                               sigset_t newset;
+                               (void) sigfillset(&newset);
+                               (void) sigprocmask(SIG_BLOCK, &newset, &oldset);
+
+                               argon2_context ctx = {
+                                       .out = NULL,
+                                       .outlen = 0,
+                                       .pwd = NULL,
+                                       .pwdlen = 0,
+                                       .salt = NULL,
+                                       .saltlen = 0,
+                                       .t_cost = ARGON2_MAX_TIME,
+                                       .m_cost = ARGON2_MAX_MEMORY,
+                                       .lanes = 1,
+                                       .threads = 1,
+                                       .version = ARGON2_VERSION_NUMBER,
+                               };
+                               (void) argon2_ctx(&ctx, Argon2_d);
+                               (void) argon2_ctx(&ctx, Argon2_i);
+                               (void) argon2_ctx(&ctx, Argon2_id);
+                               (void) argon2_error_message(0);
+                               (void) argon2_type2string(0, 0);
+                       ]])
+               ], [
+                       AC_MSG_RESULT([yes])
+                       LIBARGON2="Yes"
+                       AC_DEFINE([HAVE_LIBARGON2], [1], [Define to 1 if libargon2 appears to be usable])
                ], [
+                       AC_MSG_RESULT([no])
                        LIBARGON2="No"
-                       AS_IF([test "${with_libargon2}" = "yes"], [
-                               AC_MSG_ERROR([--with-libargon2 was given but libargon2 could not be found])
+                       AS_IF([test "${with_libargon2}" != "auto"], [
+                               AC_MSG_FAILURE([--with-libargon2 was given but libargon2 appears to be unusable])
                        ])
                ])
        ])
index f0a253dcf150cd238b7bb5b11d3244279c6f6a67..e91bf326308e367f99912ac52899def003c10f5d 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
 
        LIBCRYPTO="No"
+       LIBCRYPTO_PATH=""
        LIBCRYPTO_NAME=""
        LIBCRYPTO_USABLE="No"
        LIBCRYPTO_DIGEST="No"
@@ -13,6 +14,10 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
        case "x${with_openssl}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBCRYPTO_PATH="${with_openssl}"
+                       with_openssl="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-openssl])
                        ;;
@@ -22,27 +27,33 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_openssl}" != "no"], [
-               PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [
-                       CPPFLAGS="${LIBCRYPTO_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBCRYPTO_LIBS} ${LIBS}"
+               AS_IF([test -n "${LIBCRYPTO_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBCRYPTO_PATH}/include" -a -d "${LIBCRYPTO_PATH}/lib"], [
+                               LIBCRYPTO_CFLAGS="-I${LIBCRYPTO_PATH}/include"
+                               LIBCRYPTO_LIBS="-L${LIBCRYPTO_PATH}/lib"
+                       ], [
+                               AC_MSG_ERROR([${LIBCRYPTO_PATH} is not a suitable directory for OpenSSL])
+                       ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [], [])
+               ])
+               AS_IF([test -n "${LIBCRYPTO_CFLAGS+set}" -a -n "${LIBCRYPTO_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
                        LIBCRYPTO="Yes"
-                       AC_CHECK_HEADERS([openssl/opensslv.h], [], [
-                               LIBCRYPTO="No"
-                               AS_IF([test "${with_openssl}" = "yes"], [
-                                       AC_MSG_ERROR([--with-openssl was given but a required header file is missing])
-                               ])
-                       ], [])
                ], [
                        LIBCRYPTO="No"
-                       AS_IF([test "${with_openssl}" = "yes"], [
-                               AC_MSG_ERROR([--with-openssl was given but libcrypto could not be found])
+                       AS_IF([test "${with_openssl}" != "auto"], [
+                               AC_MSG_FAILURE([--with-openssl was given but OpenSSL could not be found])
                        ])
                ])
-       ], [
-               LIBCRYPTO="No"
        ])
 
        AS_IF([test "${LIBCRYPTO}" = "Yes"], [
+               CPPFLAGS="${LIBCRYPTO_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBCRYPTO_LIBS} ${LIBS}"
+
                AC_MSG_CHECKING([if libcrypto has usable MD5/SHA1/SHA2/HMAC/PBKDF2 functions])
                AC_LINK_IFELSE([
                        AC_LANG_PROGRAM([[
@@ -51,6 +62,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                                #endif
                                #include <openssl/evp.h>
                                #include <openssl/hmac.h>
+                               #include <openssl/opensslv.h>
                        ]], [[
                                (void) EVP_MD_size(NULL);
                                (void) EVP_DigestInit_ex(NULL, EVP_md5(), NULL);
@@ -79,6 +91,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                                        #  include <stddef.h>
                                        #endif
                                        #include <openssl/hmac.h>
+                                       #include <openssl/opensslv.h>
                                ]], [[
                                        (void) HMAC_CTX_new();
                                        (void) HMAC_CTX_free(NULL);
@@ -101,6 +114,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                                #endif
                                #include <openssl/err.h>
                                #include <openssl/rand.h>
+                               #include <openssl/opensslv.h>
                        ]], [[
                                (void) ERR_get_error();
                                (void) ERR_get_error_line_data(NULL, NULL, NULL, NULL);
@@ -123,6 +137,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                                #  include <stddef.h>
                                #endif
                                #include <openssl/crypto.h>
+                               #include <openssl/opensslv.h>
                        ]], [[
                                (void) CRYPTO_memcmp(NULL, NULL, 0);
                        ]])
@@ -141,6 +156,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                                #  include <stddef.h>
                                #endif
                                #include <openssl/curve25519.h>
+                               #include <openssl/opensslv.h>
                        ]], [[
                                (void) X25519_keypair(NULL, NULL);
                                (void) X25519(NULL, NULL, NULL);
@@ -163,6 +179,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                                #include <openssl/ec.h>
                                #include <openssl/ecdsa.h>
                                #include <openssl/evp.h>
+                               #include <openssl/opensslv.h>
                        ]], [[
                                EC_KEY *pubkey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
                                (void) EC_KEY_set_conv_form(pubkey, POINT_CONVERSION_COMPRESSED);
@@ -201,7 +218,7 @@ AC_DEFUN([ATHEME_LIBTEST_CRYPTO], [
                AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if libcrypto appears to be usable])
        ], [
                LIBCRYPTO="No"
-               AS_IF([test "${with_openssl}" = "yes"], [
+               AS_IF([test "${with_openssl}" != "auto"], [
                        AC_MSG_FAILURE([--with-openssl was given but libcrypto appears to be unusable])
                ])
        ])
index fb5f2c13777fb970c80f1725a8ceafbe3787427c..ba022782fa4a5325171af775a840bfbabb3e6a8c 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_IDN], [
 
        LIBIDN="No"
+       LIBIDN_PATH=""
 
        AC_ARG_WITH([libidn],
                [AS_HELP_STRING([--without-libidn], [Do not attempt to detect GNU libidn (for modules/saslserv/scram-sha -- SASLprep normalization)])],
@@ -9,6 +10,10 @@ AC_DEFUN([ATHEME_LIBTEST_IDN], [
        case "x${with_libidn}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBIDN_PATH="${with_libidn}"
+                       with_libidn="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-libidn])
                        ;;
@@ -18,39 +23,55 @@ AC_DEFUN([ATHEME_LIBTEST_IDN], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_libidn}" != "no"], [
-               PKG_CHECK_MODULES([LIBIDN], [libidn], [
-                       CPPFLAGS="${LIBIDN_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBIDN_LIBS} ${LIBS}"
-                       AC_MSG_CHECKING([if libidn appears to be usable])
-                       AC_LINK_IFELSE([
-                               AC_LANG_PROGRAM([[
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <stringprep.h>
-                               ]], [[
-                                       (void) stringprep_locale_to_utf8(NULL);
-                                       (void) stringprep(NULL, 0, (Stringprep_profile_flags) 0, stringprep_saslprep);
-                               ]])
-                       ], [
-                               AC_MSG_RESULT([yes])
-                               LIBIDN="Yes"
-                               AC_DEFINE([HAVE_LIBIDN], [1], [Define to 1 if libidn appears to be usable])
+               AS_IF([test -n "${LIBIDN_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBIDN_PATH}/include" -a -d "${LIBIDN_PATH}/lib"], [
+                               LIBIDN_CFLAGS="-I${LIBIDN_PATH}/include"
+                               LIBIDN_LIBS="-L${LIBIDN_PATH}/lib"
                        ], [
-                               AC_MSG_RESULT([no])
-                               LIBIDN="No"
-                               AS_IF([test "${with_libidn}" = "yes"], [
-                                       AC_MSG_FAILURE([--with-libidn was given but libidn appears to be unusable])
-                               ])
+                               AC_MSG_ERROR([${LIBIDN_PATH} is not a suitable directory for GNU libidn])
+                       ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBIDN], [libidn], [], [])
+               ])
+               AS_IF([test -n "${LIBIDN_CFLAGS+set}" -a -n "${LIBIDN_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
+                       LIBIDN="Yes"
+               ], [
+                       LIBIDN="No"
+                       AS_IF([test "${with_libidn}" != "auto"], [
+                               AC_MSG_FAILURE([--with-libidn was given but GNU libidn could not be found])
                        ])
+               ])
+       ])
+
+       AS_IF([test "${LIBIDN}" = "Yes"], [
+               CPPFLAGS="${LIBIDN_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBIDN_LIBS} ${LIBS}"
+
+               AC_MSG_CHECKING([if GNU libidn appears to be usable])
+               AC_LINK_IFELSE([
+                       AC_LANG_PROGRAM([[
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #include <stringprep.h>
+                       ]], [[
+                               (void) stringprep_locale_to_utf8(NULL);
+                               (void) stringprep(NULL, 0, (Stringprep_profile_flags) 0, stringprep_saslprep);
+                       ]])
+               ], [
+                       AC_MSG_RESULT([yes])
+                       LIBIDN="Yes"
+                       AC_DEFINE([HAVE_LIBIDN], [1], [Define to 1 if libidn appears to be usable])
                ], [
+                       AC_MSG_RESULT([no])
                        LIBIDN="No"
-                       AS_IF([test "${with_libidn}" = "yes"], [
-                               AC_MSG_ERROR([--with-libidn was given but libidn could not be found])
+                       AS_IF([test "${with_libidn}" != "auto"], [
+                               AC_MSG_FAILURE([--with-libidn was given but GNU libidn appears to be unusable])
                        ])
                ])
-       ], [
-               LIBIDN="No"
        ])
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
index e08d0e8db5e2b8c03a95eb6e30b95f0bf7a60065..e8f68a3fb5262a8f60941f9d936e74adedc4903d 100644 (file)
@@ -6,26 +6,40 @@ AC_DEFUN([ATHEME_LIBTEST_MOWGLI], [
                [AS_HELP_STRING([--with-libmowgli@<:@=prefix@:>@], [Specify location of system libmowgli install, "yes" to ask pkg-config, or "no" to force use of internal libmowgli submodule (default)])],
                [], [with_libmowgli="no"])
 
+       case "x${with_libmowgli}" in
+               xno | xyes)
+                       ;;
+               x/*)
+                       ;;
+               *)
+                       AC_MSG_ERROR([invalid option for --with-libmowgli])
+                       ;;
+       esac
+
        AS_IF([test "x${with_libmowgli}" = "xyes"], [
-               PKG_CHECK_MODULES([MOWGLI], [libmowgli-2 >= 2.0.0], [
-                       MOWGLI_SOURCE="System"
-                       CPPFLAGS="${CPPFLAGS} ${MOWGLI_CFLAGS}"
-                       LIBS="${LIBS} ${MOWGLI_LIBS}"
+               AS_IF([test -n "${PKG_CONFIG}"], [
+                       PKG_CHECK_MODULES([MOWGLI], [libmowgli-2 >= 2.0.0], [], [with_libmowgli="no"])
                ], [
                        with_libmowgli="no"
                ])
        ])
 
-       AS_IF([test "x${with_libmowgli}" = "xyes"], [], [test "x${with_libmowgli}" = "xno"], [
+       AS_IF([test "x${with_libmowgli}" = "xyes"], [
+               MOWGLI_SOURCE="System"
+               CPPFLAGS="${CPPFLAGS} ${MOWGLI_CFLAGS}"
+               LIBS="${LIBS} ${MOWGLI_LIBS}"
+       ], [test "x${with_libmowgli}" = "xno"], [
                MOWGLI_SOURCE="Internal"
                CPPFLAGS="${CPPFLAGS} -I$(pwd)/libmowgli-2/src/libmowgli"
                LDFLAGS="${LDFLAGS} -L$(pwd)/libmowgli-2/src/libmowgli"
                LIBS="${LIBS} -lmowgli-2"
                ATHEME_COND_LIBMOWGLI_SUBMODULE_ENABLE
-       ], [
+       ], [test -d "${with_libmowgli}/include/libmowgli-2" -a -d "${with_libmowgli}/lib"], [
                MOWGLI_SOURCE="System"
                CPPFLAGS="${CPPFLAGS} -I${with_libmowgli}/include/libmowgli-2"
                LDFLAGS="${LDFLAGS} -L${with_libmowgli}/lib"
                LIBS="${LIBS} -lmowgli-2"
+       ], [
+               AC_MSG_ERROR([${with_libmowgli} is not a suitable directory for libmowgli])
        ])
 ])
index 1d6c3b495c87683ae40e35a970f717305f5b1dbf..d4798f1dd5b3901d656b5a60095871771eb3dd9b 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
 
        LIBNETTLE="No"
+       LIBNETTLE_PATH=""
        LIBNETTLE_USABLE="No"
        LIBNETTLE_DIGEST="No"
 
@@ -11,6 +12,10 @@ AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
        case "x${with_nettle}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBNETTLE_PATH="${with_nettle}"
+                       with_nettle="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-nettle])
                        ;;
@@ -20,22 +25,34 @@ AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_nettle}" != "no"], [
-               PKG_CHECK_MODULES([LIBNETTLE], [nettle], [
-                       CPPFLAGS="${LIBNETTLE_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBNETTLE_LIBS} ${LIBS}"
+               AS_IF([test -n "${LIBNETTLE_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBNETTLE_PATH}/include" -a -d "${LIBNETTLE_PATH}/lib"], [
+                               LIBNETTLE_CFLAGS="-I${LIBNETTLE_PATH}/include"
+                               LIBNETTLE_LIBS="-L${LIBNETTLE_PATH}/lib"
+                       ], [
+                               AC_MSG_ERROR([${LIBNETTLE_PATH} is not a suitable directory for GNU Nettle])
+                       ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBNETTLE], [nettle], [], [])
+               ])
+               AS_IF([test -n "${LIBNETTLE_CFLAGS+set}" -a -n "${LIBNETTLE_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
                        LIBNETTLE="Yes"
                ], [
                        LIBNETTLE="No"
-                       AS_IF([test "${with_nettle}" = "yes"], [
-                               AC_MSG_ERROR([--with-nettle was given but libnettle could not be found])
+                       AS_IF([test "${with_nettle}" != "auto"], [
+                               AC_MSG_FAILURE([--with-nettle was given but GNU Nettle could not be found])
                        ])
                ])
-       ], [
-               LIBNETTLE="No"
        ])
 
        AS_IF([test "${LIBNETTLE}" = "Yes"], [
-               AC_MSG_CHECKING([if libnettle has usable MD5/SHA1/SHA2 functions])
+               CPPFLAGS="${LIBNETTLE_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBNETTLE_LIBS} ${LIBS}"
+
+               AC_MSG_CHECKING([if GNU Nettle has usable MD5/SHA1/SHA2 functions])
                AC_LINK_IFELSE([
                        AC_LANG_PROGRAM([[
                                #ifdef HAVE_STDDEF_H
@@ -71,7 +88,7 @@ AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
                        AC_MSG_RESULT([no])
                ])
 
-               AC_MSG_CHECKING([if libnettle has a usable constant-time memory comparison function])
+               AC_MSG_CHECKING([if GNU Nettle has a usable constant-time memory comparison function])
                AC_LINK_IFELSE([
                        AC_LANG_PROGRAM([[
                                #ifdef HAVE_STDDEF_H
@@ -83,13 +100,13 @@ AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
                        ]])
                ], [
                        AC_MSG_RESULT([yes])
-                       AC_DEFINE([HAVE_LIBNETTLE_MEMEQL], [1], [Define to 1 if libnettle has a usable constant-time memory comparison function])
+                       AC_DEFINE([HAVE_LIBNETTLE_MEMEQL], [1], [Define to 1 if GNU Nettle has a usable constant-time memory comparison function])
                        LIBNETTLE_USABLE="Yes"
                ], [
                        AC_MSG_RESULT([no])
                ])
 
-               AC_MSG_CHECKING([if libnettle can provide SASL ECDH-X25519-CHALLENGE])
+               AC_MSG_CHECKING([if GNU Nettle can provide SASL ECDH-X25519-CHALLENGE])
                AC_LINK_IFELSE([
                        AC_LANG_PROGRAM([[
                                #ifdef HAVE_STDDEF_H
@@ -105,7 +122,7 @@ AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
                        ]])
                ], [
                        AC_MSG_RESULT([yes])
-                       AC_DEFINE([HAVE_LIBNETTLE_ECDH_X25519], [1], [Define to 1 if libnettle can provide SASL ECDH-X25519-CHALLENGE])
+                       AC_DEFINE([HAVE_LIBNETTLE_ECDH_X25519], [1], [Define to 1 if GNU Nettle can provide SASL ECDH-X25519-CHALLENGE])
                        ATHEME_COND_ECDH_X25519_TOOL_ENABLE
                        LIBNETTLE_USABLE="Yes"
                ], [
@@ -114,12 +131,12 @@ AC_DEFUN([ATHEME_LIBTEST_NETTLE], [
        ])
 
        AS_IF([test "${LIBNETTLE_USABLE}" = "Yes"], [
-               AC_DEFINE([HAVE_LIBNETTLE], [1], [Define to 1 if libnettle appears to be usable])
+               AC_DEFINE([HAVE_LIBNETTLE], [1], [Define to 1 if GNU Nettle appears to be usable])
                AC_CHECK_HEADERS([nettle/version.h], [], [], [])
        ], [
                LIBNETTLE="No"
-               AS_IF([test "${with_nettle}" = "yes"], [
-                       AC_MSG_FAILURE([--with-nettle was given but libnettle appears to be unusable])
+               AS_IF([test "${with_nettle}" != "auto"], [
+                       AC_MSG_FAILURE([--with-nettle was given but GNU Nettle appears to be unusable])
                ])
        ])
 
index 8abe2cdcd7b312886a0b9faf998a89eb974b378d..a0ffd12967d0868a5dac3b915be4afdc0eddb174 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_PCRE], [
 
        LIBPCRE="No"
+       LIBPCRE_PATH=""
 
        AC_ARG_WITH([pcre],
                [AS_HELP_STRING([--without-pcre], [Do not attempt to detect libpcre (Perl-Compatible Regular Expressions)])],
@@ -9,6 +10,10 @@ AC_DEFUN([ATHEME_LIBTEST_PCRE], [
        case "x${with_pcre}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBPCRE_PATH="${with_pcre}"
+                       with_pcre="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-pcre])
                        ;;
@@ -18,40 +23,56 @@ AC_DEFUN([ATHEME_LIBTEST_PCRE], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_pcre}" != "no"], [
-               PKG_CHECK_MODULES([LIBPCRE], [libpcre], [
-                       CPPFLAGS="${LIBPCRE_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBPCRE_LIBS} ${LIBS}"
-                       AC_MSG_CHECKING([if libpcre appears to be usable])
-                       AC_LINK_IFELSE([
-                               AC_LANG_PROGRAM([[
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <pcre.h>
-                               ]], [[
-                                       (void) pcre_compile(NULL, 0, NULL, NULL, NULL);
-                                       (void) pcre_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0);
-                                       (void) pcre_free(NULL);
-                               ]])
-                       ], [
-                               AC_MSG_RESULT([yes])
-                               LIBPCRE="Yes"
-                               AC_DEFINE([HAVE_LIBPCRE], [1], [Define to 1 if libpcre appears to be usable])
+               AS_IF([test -n "${LIBPCRE_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBPCRE_PATH}/include" -a -d "${LIBPCRE_PATH}/lib"], [
+                               LIBPCRE_CFLAGS="-I${LIBPCRE_PATH}/include"
+                               LIBPCRE_LIBS="-L${LIBPCRE_PATH}/lib"
                        ], [
-                               AC_MSG_RESULT([no])
-                               LIBPCRE="No"
-                               AS_IF([test "${with_pcre}" = "yes"], [
-                                       AC_MSG_FAILURE([--with-pcre was given but libpcre does not appear to be usable])
-                               ])
+                               AC_MSG_ERROR([${LIBPCRE_PATH} is not a suitable directory for libpcre])
+                       ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBPCRE], [libpcre], [], [])
+               ])
+               AS_IF([test -n "${LIBPCRE_CFLAGS+set}" -a -n "${LIBPCRE_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
+                       LIBPCRE="Yes"
+               ], [
+                       LIBPCRE="No"
+                       AS_IF([test "${with_pcre}" != "auto"], [
+                               AC_MSG_FAILURE([--with-pcre was given but libpcre could not be found])
                        ])
+               ])
+       ])
+
+       AS_IF([test "${LIBPCRE}" = "Yes"], [
+               CPPFLAGS="${LIBPCRE_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBPCRE_LIBS} ${LIBS}"
+
+               AC_MSG_CHECKING([if libpcre appears to be usable])
+               AC_LINK_IFELSE([
+                       AC_LANG_PROGRAM([[
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #include <pcre.h>
+                       ]], [[
+                               (void) pcre_compile(NULL, 0, NULL, NULL, NULL);
+                               (void) pcre_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0);
+                               (void) pcre_free(NULL);
+                       ]])
+               ], [
+                       AC_MSG_RESULT([yes])
+                       LIBPCRE="Yes"
+                       AC_DEFINE([HAVE_LIBPCRE], [1], [Define to 1 if libpcre appears to be usable])
                ], [
+                       AC_MSG_RESULT([no])
                        LIBPCRE="No"
-                       AS_IF([test "${with_pcre}" = "yes"], [
-                               AC_MSG_ERROR([--with-pcre was given but libpcre could not be found])
+                       AS_IF([test "${with_pcre}" != "auto"], [
+                               AC_MSG_FAILURE([--with-pcre was given but libpcre does not appear to be usable])
                        ])
                ])
-       ], [
-               LIBPCRE="No"
        ])
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
index 934c3663292ef69844f9387ebbf685c05d690062..6b48204325a2af1776c13918c7583258f0a17ba2 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_QRENCODE], [
 
        LIBQRENCODE="No"
+       LIBQRENCODE_PATH=""
 
        AC_ARG_WITH([qrencode],
                [AS_HELP_STRING([--without-qrencode], [Do not attempt to detect libqrencode (for generating QR codes)])],
@@ -9,6 +10,10 @@ AC_DEFUN([ATHEME_LIBTEST_QRENCODE], [
        case "x${with_qrencode}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBQRENCODE_PATH="${with_qrencode}"
+                       with_qrencode="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-qrencode])
                        ;;
@@ -18,40 +23,56 @@ AC_DEFUN([ATHEME_LIBTEST_QRENCODE], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_qrencode}" != "no"], [
-               PKG_CHECK_MODULES([LIBQRENCODE], [libqrencode], [
-                       CPPFLAGS="${LIBQRENCODE_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBQRENCODE_LIBS} ${LIBS}"
-                       AC_MSG_CHECKING([if libqrencode appears to be usable])
-                       AC_LINK_IFELSE([
-                               AC_LANG_PROGRAM([[
-                                       #ifdef HAVE_STDDEF_H
-                                       #  include <stddef.h>
-                                       #endif
-                                       #include <qrencode.h>
-                               ]], [[
-                                       (void) QRcode_encodeData(0, NULL, 0, (QRecLevel) 0);
-                                       (void) QRcode_free(NULL);
-                               ]])
-                       ], [
-                               AC_MSG_RESULT([yes])
-                               LIBQRENCODE="Yes"
-                               AC_DEFINE([HAVE_LIBQRENCODE], [1], [Define to 1 if libqrencode appears to be usable])
-                               ATHEME_COND_QRCODE_ENABLE
+               AS_IF([test -n "${LIBQRENCODE_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBQRENCODE_PATH}/include" -a -d "${LIBQRENCODE_PATH}/lib"], [
+                               LIBQRENCODE_CFLAGS="-I${LIBQRENCODE_PATH}/include"
+                               LIBQRENCODE_LIBS="-L${LIBQRENCODE_PATH}/lib"
                        ], [
-                               AC_MSG_RESULT([no])
-                               LIBQRENCODE="No"
-                               AS_IF([test "${with_qrencode}" = "yes"], [
-                                       AC_MSG_FAILURE([--with-qrencode was given but libqrencode does not appear to be usable])
-                               ])
+                               AC_MSG_ERROR([${LIBQRENCODE_PATH} is not a suitable directory for libqrencode])
+                       ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBQRENCODE], [libqrencode], [], [])
+               ])
+               AS_IF([test -n "${LIBQRENCODE_CFLAGS+set}" -a -n "${LIBQRENCODE_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
+                       LIBQRENCODE="Yes"
+               ], [
+                       LIBQRENCODE="No"
+                       AS_IF([test "${with_qrencode}" != "auto"], [
+                               AC_MSG_FAILURE([--with-qrencode was given but libqrencode could not be found])
                        ])
+               ])
+       ])
+
+       AS_IF([test "${LIBQRENCODE}" = "Yes"], [
+               CPPFLAGS="${LIBQRENCODE_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBQRENCODE_LIBS} ${LIBS}"
+
+               AC_MSG_CHECKING([if libqrencode appears to be usable])
+               AC_LINK_IFELSE([
+                       AC_LANG_PROGRAM([[
+                               #ifdef HAVE_STDDEF_H
+                               #  include <stddef.h>
+                               #endif
+                               #include <qrencode.h>
+                       ]], [[
+                               (void) QRcode_encodeData(0, NULL, 0, (QRecLevel) 0);
+                               (void) QRcode_free(NULL);
+                       ]])
+               ], [
+                       AC_MSG_RESULT([yes])
+                       LIBQRENCODE="Yes"
+                       AC_DEFINE([HAVE_LIBQRENCODE], [1], [Define to 1 if libqrencode appears to be usable])
+                       ATHEME_COND_QRCODE_ENABLE
                ], [
+                       AC_MSG_RESULT([no])
                        LIBQRENCODE="No"
-                       AS_IF([test "${with_qrencode}" = "yes"], [
-                               AC_MSG_ERROR([--with-qrencode was given but libqrencode could not be found])
+                       AS_IF([test "${with_qrencode}" != "auto"], [
+                               AC_MSG_FAILURE([--with-qrencode was given but libqrencode does not appear to be usable])
                        ])
                ])
-       ], [
-               LIBQRENCODE="No"
        ])
 
        CPPFLAGS="${CPPFLAGS_SAVED}"
index 2b50a984c831f8b453faee77814a558c663e26a0..6a825ea6d65ce4ad8f28882ed5f9781cb41b76e1 100644 (file)
@@ -1,6 +1,7 @@
 AC_DEFUN([ATHEME_LIBTEST_SODIUM], [
 
        LIBSODIUM="No"
+       LIBSODIUM_PATH=""
        LIBSODIUM_USABLE="No"
        LIBSODIUM_MEMORY="No"
        LIBSODIUM_RANDOM="No"
@@ -12,6 +13,10 @@ AC_DEFUN([ATHEME_LIBTEST_SODIUM], [
        case "x${with_sodium}" in
                xno | xyes | xauto)
                        ;;
+               x/*)
+                       LIBSODIUM_PATH="${with_sodium}"
+                       with_sodium="yes"
+                       ;;
                *)
                        AC_MSG_ERROR([invalid option for --with-sodium])
                        ;;
@@ -21,36 +26,52 @@ AC_DEFUN([ATHEME_LIBTEST_SODIUM], [
        LIBS_SAVED="${LIBS}"
 
        AS_IF([test "${with_sodium}" != "no"], [
-               PKG_CHECK_MODULES([LIBSODIUM], [libsodium], [
-                       CPPFLAGS="${LIBSODIUM_CFLAGS} ${CPPFLAGS}"
-                       LIBS="${LIBSODIUM_LIBS} ${LIBS}"
-                       AC_MSG_CHECKING([if libsodium appears to be usable])
-                       AC_LINK_IFELSE([
-                               AC_LANG_PROGRAM([[
-                                       #include <sodium/core.h>
-                                       #include <sodium/utils.h>
-                                       #include <sodium/version.h>
-                               ]], [[
-                                       (void) sodium_init();
-                               ]])
-                       ], [
-                               AC_MSG_RESULT([yes])
-                               LIBSODIUM="Yes"
+               AS_IF([test -n "${LIBSODIUM_PATH}"], [
+                       dnl Allow for user to provide custom installation directory
+                       AS_IF([test -d "${LIBSODIUM_PATH}/include" -a -d "${LIBSODIUM_PATH}/lib"], [
+                               LIBSODIUM_CFLAGS="-I${LIBSODIUM_PATH}/include"
+                               LIBSODIUM_LIBS="-L${LIBSODIUM_PATH}/lib"
                        ], [
-                               AC_MSG_RESULT([no])
-                               LIBSODIUM="No"
-                               AS_IF([test "${with_sodium}" = "yes"], [
-                                       AC_MSG_FAILURE([--with-sodium was given but libsodium appears to be unusable])
-                               ])
+                               AC_MSG_ERROR([${LIBSODIUM_PATH} is not a suitable directory for libsodium])
                        ])
+               ], [test -n "${PKG_CONFIG}"], [
+                       dnl Allow for the user to "override" pkg-config without it being installed
+                       PKG_CHECK_MODULES([LIBSODIUM], [libsodium], [], [])
+               ])
+               AS_IF([test -n "${LIBSODIUM_CFLAGS+set}" -a -n "${LIBSODIUM_LIBS+set}"], [
+                       dnl Only proceed with library tests if custom paths were given or pkg-config succeeded
+                       LIBSODIUM="Yes"
                ], [
                        LIBSODIUM="No"
-                       AS_IF([test "${with_sodium}" = "yes"], [
-                               AC_MSG_ERROR([--with-sodium was given but libsodium could not be found])
+                       AS_IF([test "${with_sodium}" != "auto"], [
+                               AC_MSG_FAILURE([--with-sodium was given but libsodium could not be found])
+                       ])
+               ])
+       ])
+
+       AS_IF([test "${LIBSODIUM}" = "Yes"], [
+               CPPFLAGS="${LIBSODIUM_CFLAGS} ${CPPFLAGS}"
+               LIBS="${LIBSODIUM_LIBS} ${LIBS}"
+
+               AC_MSG_CHECKING([if libsodium appears to be usable])
+               AC_LINK_IFELSE([
+                       AC_LANG_PROGRAM([[
+                               #include <sodium/core.h>
+                               #include <sodium/utils.h>
+                               #include <sodium/version.h>
+                       ]], [[
+                               (void) sodium_init();
+                       ]])
+               ], [
+                       AC_MSG_RESULT([yes])
+                       LIBSODIUM="Yes"
+               ], [
+                       AC_MSG_RESULT([no])
+                       LIBSODIUM="No"
+                       AS_IF([test "${with_sodium}" != "auto"], [
+                               AC_MSG_FAILURE([--with-sodium was given but libsodium appears to be unusable])
                        ])
                ])
-       ], [
-               LIBSODIUM="No"
        ])
 
        AS_IF([test "${LIBSODIUM}" = "Yes"], [
@@ -186,7 +207,7 @@ AC_DEFUN([ATHEME_LIBTEST_SODIUM], [
                AC_DEFINE([HAVE_LIBSODIUM], [1], [Define to 1 if libsodium appears to be usable])
        ], [
                LIBSODIUM="No"
-               AS_IF([test "${with_sodium}" = "yes"], [
+               AS_IF([test "${with_sodium}" != "auto"], [
                        AC_MSG_FAILURE([--with-sodium was given but libsodium appears to be unusable])
                ])
        ])