Try to use pkg-config for finding openssl

If using pkg-config fails, we fall back to the old method with AC_CHECK_LIB().


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2018 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-06-07 19:34:20 +00:00
parent 39a215f35b
commit 68c5ee5909
2 changed files with 265 additions and 75 deletions
Vendored
+254 -70
View File
@@ -569,6 +569,8 @@ LIBZNCDIR
LIBZNC
MODFLAGS
PERL_BINARY
openssl_LIBS
openssl_CFLAGS
c_ares_LIBS
c_ares_CFLAGS
PKG_CONFIG
@@ -656,7 +658,9 @@ CPPFLAGS
CCC
PKG_CONFIG
c_ares_CFLAGS
c_ares_LIBS'
c_ares_LIBS
openssl_CFLAGS
openssl_LIBS'
# Initialize some variables set by options.
@@ -1307,6 +1311,10 @@ Some influential environment variables:
c_ares_CFLAGS
C compiler flags for c_ares, overriding pkg-config
c_ares_LIBS linker flags for c_ares, overriding pkg-config
openssl_CFLAGS
C compiler flags for openssl, overriding pkg-config
openssl_LIBS
linker flags for openssl, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -2896,71 +2904,6 @@ if test "x$ac_cv_func_lstat" = x""yes; then :
fi
# ----- Check for dlopen
FOUND_DL=no
# Don't use any libs like -lssl -lcrypto when checking for dlopen(),
# because they might change the test results
SAVED_LIBS="$LIBS"
LIBS=""
ac_fn_cxx_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
if test "x$ac_cv_func_dlopen" = x""yes; then :
FOUND_DL=yes
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $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 dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
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_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
FOUND_DL=yes ; appendLib -ldl
fi
appendLib "$SAVED_LIBS"
if test $FOUND_DL = "no" ; then
as_fn_error "Could not find dlopen. Try --disable-modules" "$LINENO" 5
fi
# ----- Check for c-ares
if test "x$ARES" != "xno"; then
old_ARES=$ARES
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
if test -n "$ac_tool_prefix"; then
@@ -3076,6 +3019,71 @@ $as_echo "no" >&6; }
fi
fi
# ----- Check for dlopen
FOUND_DL=no
# Don't use any libs like -lssl -lcrypto when checking for dlopen(),
# because they might change the test results
SAVED_LIBS="$LIBS"
LIBS=""
ac_fn_cxx_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
if test "x$ac_cv_func_dlopen" = x""yes; then :
FOUND_DL=yes
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $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 dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
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_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
FOUND_DL=yes ; appendLib -ldl
fi
appendLib "$SAVED_LIBS"
if test $FOUND_DL = "no" ; then
as_fn_error "Could not find dlopen. Try --disable-modules" "$LINENO" 5
fi
# ----- Check for c-ares
if test "x$ARES" != "xno"; then
old_ARES=$ARES
if test -z "$PKG_CONFIG"
then
ARES=no
@@ -3192,9 +3200,73 @@ if test "x$SSL" != "xno"; then
fi
old_SSL=$SSL
# Don't reorder this!
# On some arches libssl depends on libcrypto without linking to it :(
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_new in -lcrypto" >&5
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl" >&5
$as_echo_n "checking for openssl... " >&6; }
if test -n "$PKG_CONFIG"; then
if test -n "$openssl_CFLAGS"; then
pkg_cv_openssl_CFLAGS="$openssl_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
($PKG_CONFIG --exists --print-errors "openssl") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_openssl_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$openssl_LIBS"; then
pkg_cv_openssl_LIBS="$openssl_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
($PKG_CONFIG --exists --print-errors "openssl") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_openssl_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
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
openssl_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "openssl"`
else
openssl_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "openssl"`
fi
# Put the nasty error message in config.log where it belongs
echo "$openssl_PKG_ERRORS" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
# Don't reorder this!
# On some arches libssl depends on libcrypto without linking to it :(
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_new in -lcrypto" >&5
$as_echo_n "checking for BIO_new in -lcrypto... " >&6; }
if test "${ac_cv_lib_crypto_BIO_new+set}" = set; then :
$as_echo_n "(cached) " >&6
@@ -3241,7 +3313,7 @@ else
SSL=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_shutdown in -lssl" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_shutdown in -lssl" >&5
$as_echo_n "checking for SSL_shutdown in -lssl... " >&6; }
if test "${ac_cv_lib_ssl_SSL_shutdown+set}" = set; then :
$as_echo_n "(cached) " >&6
@@ -3289,6 +3361,118 @@ else
fi
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
# Don't reorder this!
# On some arches libssl depends on libcrypto without linking to it :(
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_new in -lcrypto" >&5
$as_echo_n "checking for BIO_new in -lcrypto... " >&6; }
if test "${ac_cv_lib_crypto_BIO_new+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcrypto $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 BIO_new ();
int
main ()
{
return BIO_new ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_lib_crypto_BIO_new=yes
else
ac_cv_lib_crypto_BIO_new=no
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_crypto_BIO_new" >&5
$as_echo "$ac_cv_lib_crypto_BIO_new" >&6; }
if test "x$ac_cv_lib_crypto_BIO_new" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCRYPTO 1
_ACEOF
LIBS="-lcrypto $LIBS"
else
SSL=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_shutdown in -lssl" >&5
$as_echo_n "checking for SSL_shutdown in -lssl... " >&6; }
if test "${ac_cv_lib_ssl_SSL_shutdown+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lssl $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 SSL_shutdown ();
int
main ()
{
return SSL_shutdown ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_cv_lib_ssl_SSL_shutdown=yes
else
ac_cv_lib_ssl_SSL_shutdown=no
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_ssl_SSL_shutdown" >&5
$as_echo "$ac_cv_lib_ssl_SSL_shutdown" >&6; }
if test "x$ac_cv_lib_ssl_SSL_shutdown" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSSL 1
_ACEOF
LIBS="-lssl $LIBS"
else
SSL=no
fi
else
openssl_CFLAGS=$pkg_cv_openssl_CFLAGS
openssl_LIBS=$pkg_cv_openssl_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
appendLib "$openssl_LIBS"
appendCXX "$openssl_CFLAGS"
fi
if test "x$SSL" = "xno" ; then
# This looks better in the summary at the end
+11 -5
View File
@@ -135,6 +135,7 @@ fi
AC_CHECK_LIB( gnugetopt, getopt_long,)
AC_CHECK_FUNC([lstat], [appendCXX -DHAVE_LSTAT])
PKG_PROG_PKG_CONFIG()
# ----- Check for dlopen
@@ -157,7 +158,6 @@ fi
if test "x$ARES" != "xno"; then
old_ARES=$ARES
PKG_PROG_PKG_CONFIG()
if test -z "$PKG_CONFIG"
then
ARES=no
@@ -190,10 +190,16 @@ if test "x$SSL" != "xno"; then
fi
old_SSL=$SSL
# Don't reorder this!
# On some arches libssl depends on libcrypto without linking to it :(
AC_CHECK_LIB( crypto, BIO_new,, SSL=no )
AC_CHECK_LIB( ssl, SSL_shutdown,, SSL=no )
PKG_CHECK_MODULES([openssl], [openssl], [
appendLib "$openssl_LIBS"
appendCXX "$openssl_CFLAGS"
], [
AC_MSG_RESULT([no])
# Don't reorder this!
# On some arches libssl depends on libcrypto without linking to it :(
AC_CHECK_LIB( crypto, BIO_new,, SSL=no )
AC_CHECK_LIB( ssl, SSL_shutdown,, SSL=no )
])
if test "x$SSL" = "xno" ; then
ZNC_AUTO_FAIL([SSL],