Use PKG_CHECK_MODULES() to test for libcurl in configure

This is simpler and better (supports cross-compiling, manual override,
...) than doing it manually.

Also disable wxWebRequest completely under Unix if libcurl was not
found, as it's the only backend which can be used on non-MSW/Mac
platforms.
This commit is contained in:
Vadim Zeitlin 2020-12-12 19:00:11 +01:00
parent 64a3801160
commit f35c2d9e58
2 changed files with 114 additions and 65 deletions

146
configure vendored
View File

@ -983,6 +983,8 @@ DIRECTFB_CFLAGS
GTK_CONFIG
GTK_LIBS
GTK_CFLAGS
LIBCURL_LIBS
LIBCURL_CFLAGS
subdirs
wxCFLAGS_C99
LIBTIFF_LIBS
@ -1388,6 +1390,8 @@ CCC
PKG_CONFIG
LIBTIFF_CFLAGS
LIBTIFF_LIBS
LIBCURL_CFLAGS
LIBCURL_LIBS
DIRECTFB_CFLAGS
DIRECTFB_LIBS
XMKMF
@ -2402,6 +2406,10 @@ Some influential environment variables:
C compiler flags for LIBTIFF, overriding pkg-config
LIBTIFF_LIBS
linker flags for LIBTIFF, overriding pkg-config
LIBCURL_CFLAGS
C compiler flags for LIBCURL, overriding pkg-config
LIBCURL_LIBS
linker flags for LIBCURL, overriding pkg-config
DIRECTFB_CFLAGS
C compiler flags for DIRECTFB, overriding pkg-config
DIRECTFB_LIBS
@ -22961,64 +22969,98 @@ if test "$wxUSE_LIBMSPACK" != "no"; then
fi
if test "$wxUSE_WEBREQUEST_CURL" != "no"; then
ac_fn_c_check_header_mongrel "$LINENO" "curl/curl.h" "ac_cv_header_curl_curl_h" "$ac_includes_default"
if test "x$ac_cv_header_curl_curl_h" = xyes; then :
if test "$wxUSE_WEBREQUEST_LIBCURL" != "no"; then
fi
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBCURL" >&5
$as_echo_n "checking for LIBCURL... " >&6; }
if test "$ac_cv_header_curl_curl_h" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl_easy_init in -lcurl" >&5
$as_echo_n "checking for curl_easy_init in -lcurl... " >&6; }
if ${ac_cv_lib_curl_curl_easy_init+:} false; then :
$as_echo_n "(cached) " >&6
if test -n "$PKG_CONFIG"; then
if test -n "$LIBCURL_CFLAGS"; then
pkg_cv_LIBCURL_CFLAGS="$LIBCURL_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcurl\""; } >&5
($PKG_CONFIG --exists --print-errors "libcurl") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBCURL_CFLAGS=`$PKG_CONFIG --cflags "libcurl" 2>/dev/null`
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcurl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char curl_easy_init ();
int
main ()
{
return curl_easy_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_curl_curl_easy_init=yes
else
ac_cv_lib_curl_curl_easy_init=no
pkg_failed=yes
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curl_curl_easy_init" >&5
$as_echo "$ac_cv_lib_curl_curl_easy_init" >&6; }
if test "x$ac_cv_lib_curl_curl_easy_init" = xyes; then :
CURL_LINK="-lcurl"
LIBS="$CURL_LINK $LIBS"
$as_echo "#define wxUSE_WEBREQUEST_CURL 1" >>confdefs.h
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$LIBCURL_LIBS"; then
pkg_cv_LIBCURL_LIBS="$LIBCURL_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcurl\""; } >&5
($PKG_CONFIG --exists --print-errors "libcurl") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBCURL_LIBS=`$PKG_CONFIG --libs "libcurl" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -z "$CURL_LINK"; then
wxUSE_WEBREQUEST_CURL=no
if test $pkg_failed = yes; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
LIBCURL_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libcurl"`
else
LIBCURL_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libcurl"`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBCURL_PKG_ERRORS" >&5
wxUSE_WEBREQUEST_LIBCURL=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
elif test $pkg_failed = untried; then
wxUSE_WEBREQUEST_LIBCURL=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
else
LIBCURL_CFLAGS=$pkg_cv_LIBCURL_CFLAGS
LIBCURL_LIBS=$pkg_cv_LIBCURL_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
CXXFLAGS="$LIBCURL_CFLAGS $CXXFLAGS"
LIBS="$LIBCURL_LIBS $LIBS"
$as_echo "#define wxUSE_WEBREQUEST_LIBCURL 1" >>confdefs.h
fi
if test "$wxUSE_WEBREQUEST_LIBCURL" = "no"; then
if test "$USE_WIN32" != 1 -a "$USE_DARWIN" != 1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcurl not found, wxWebRequest won't be available" >&5
$as_echo "$as_me: WARNING: libcurl not found, wxWebRequest won't be available" >&2;}
wxUSE_WEBREQUEST=no
fi
fi
fi

View File

@ -2924,20 +2924,27 @@ dnl ------------------------------------------------------------------------
dnl Check for libcurl
dnl ------------------------------------------------------------------------
if test "$wxUSE_WEBREQUEST_CURL" != "no"; then
AC_CHECK_HEADER(curl/curl.h,,,[])
if test "$wxUSE_WEBREQUEST_LIBCURL" != "no"; then
PKG_CHECK_MODULES(LIBCURL, [libcurl],
[
CXXFLAGS="$LIBCURL_CFLAGS $CXXFLAGS"
LIBS="$LIBCURL_LIBS $LIBS"
AC_DEFINE(wxUSE_WEBREQUEST_LIBCURL)
],
[
wxUSE_WEBREQUEST_LIBCURL=no
AC_MSG_RESULT([not found])
]
)
if test "$ac_cv_header_curl_curl_h" = "yes"; then
AC_CHECK_LIB(curl, curl_easy_init,
[
CURL_LINK="-lcurl"
LIBS="$CURL_LINK $LIBS"
AC_DEFINE(wxUSE_WEBREQUEST_CURL)
])
fi
if test -z "$CURL_LINK"; then
wxUSE_WEBREQUEST_CURL=no
if test "$wxUSE_WEBREQUEST_LIBCURL" = "no"; then
dnl Under these platforms we have other, always available, backends for
dnl wxWebRequest, but under the others (i.e. generic Unix) libcurl is
dnl the only way to implement wxWebRequest.
if test "$USE_WIN32" != 1 -a "$USE_DARWIN" != 1; then
AC_MSG_WARN([libcurl not found, wxWebRequest won't be available])
wxUSE_WEBREQUEST=no
fi
fi
fi