From 5b62fa9ab1d8baff8400fd49c79218659edecb71 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 18 Feb 2011 21:51:23 +0900 Subject: [PATCH] Use PKG_CONFIG_PATH along with PKG_CHECK_MODULES in openssl.m4 and libz.m4. Replaced LIBZ_LIB and LIBZ_CPPFLAGS with ZLIB_LIB and ZLIB_CFLAGS respectively. --- configure.ac | 4 ++-- m4/libz.m4 | 31 +++++++++++++++++++------------ m4/openssl.m4 | 28 +++++++++------------------- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index 50081b22..46410d2f 100644 --- a/configure.ac +++ b/configure.ac @@ -144,8 +144,8 @@ fi if test "x$with_libz" = "xyes"; then AM_PATH_LIBZ if test "x$have_libz" = "xyes"; then - LIBS="$LIBZ_LIBS $LIBS" - CPPFLAGS="$LIBZ_CPPFLAGS $CPPFLAGS" + LIBS="$ZLIB_LIBS $LIBS" + CPPFLAGS="$ZLIB_CFLAGS $CPPFLAGS" elif test "x$with_libz_requested" = "xyes"; then ARIA2_DEP_NOT_MET([libz]) fi diff --git a/m4/libz.m4 b/m4/libz.m4 index 59de67c8..fd9de746 100644 --- a/m4/libz.m4 +++ b/m4/libz.m4 @@ -9,25 +9,32 @@ if test "x$libz_prefix" = "x"; then libz_prefix="/usr" fi -libz_prefix_lib=$libz_prefix/lib -libz_prefix_include=$libz_prefix/include - LIBS_save=$LIBS CPPFLAGS_save=$CPPFLAGS +PKG_CONFIG_PATH_save=$PKG_CONFIG_PATH -LIBS="-L$libz_prefix_lib $LIBS" -CPPFLAGS="-I$libz_prefix_include $CPPFLAGS" +PKG_CONFIG_PATH="$libz_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" +PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_libz=yes], [have_libz=no]) + +if test "x$have_libz" != "xyes"; then + libz_prefix_lib=$libz_prefix/lib + libz_prefix_include=$libz_prefix/include + + LIBS="-L$libz_prefix_lib $LIBS" + CPPFLAGS="-I$libz_prefix_include $CPPFLAGS" + + AC_CHECK_LIB([z], [zlibVersion], [have_libz=yes]) + if test "x$have_libz" = "xyes"; then + ZLIB_LIBS="-L$libz_prefix_lib -lz" + ZLIB_CFLAGS="-I$libz_prefix_include" + fi +fi -AC_CHECK_LIB([z], [zlibVersion], [have_libz=yes]) if test "x$have_libz" = "xyes"; then - AC_DEFINE([HAVE_LIBZ], [1], [Define to 1 if you have libz.]) - LIBZ_LIBS="-L$libz_prefix_lib -lz" - LIBZ_CPPFLAGS="-I$libz_prefix_include" - AC_SUBST(LIBZ_LIBS) - AC_SUBST(LIBZ_CPPFLAGS) + AC_DEFINE([HAVE_LIBZ], [1], [Define to 1 if you have libz.]) fi LIBS=$LIBS_save CPPFLAGS=$CPPFLAGS_save - +PKG_CONFIG_PATH=$PKG_CONFIG_PATH_save ]) diff --git a/m4/openssl.m4 b/m4/openssl.m4 index e3638e98..1df8d53e 100644 --- a/m4/openssl.m4 +++ b/m4/openssl.m4 @@ -11,24 +11,12 @@ fi LIBS_save=$LIBS CPPFLAGS_save=$CPPFLAGS +PKG_CONFIG_PATH_save=$PKG_CONFIG_PATH -PKG_CONFIG="$openssl_prefix/bin/pkg-config" -if test -x $PKG_CONFIG; then - AC_MSG_CHECKING([checking availability of openssl using pkg-config]) - $PKG_CONFIG --exists openssl - if test "$?" = "0"; then - # Use pkg-config to detect LIBS and CFLAGS - OPENSSL_LIBS=`$PKG_CONFIG --libs openssl` - OPENSSL_CFLAGS=`$PKG_CONFIG --cflags openssl` +PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" +PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8], + [have_openssl=yes], [have_openssl=no]) - LIBS="$OPENSSL_LIBS $LIBS" - CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS" - have_openssl=yes - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi -fi if test "x$have_openssl" != "xyes"; then openssl_prefix_lib=$openssl_prefix/lib openssl_prefix_include=$openssl_prefix/include @@ -40,7 +28,8 @@ if test "x$have_openssl" != "xyes"; then AC_CHECK_LIB([crypto], [main], [have_openssl=yes; LIBS="-lcrypto $LIBS"]) if test "x$have_openssl" = "xyes"; then have_openssl=no - AC_CHECK_LIB([ssl], [SSL_library_init], [have_openssl=yes LIBS="-lssl $LIBS"]) + AC_CHECK_LIB([ssl], [SSL_library_init], + [have_openssl=yes LIBS="-lssl $LIBS"]) if test "x$have_openssl" = "xyes"; then OPENSSL_LIBS="-L$openssl_prefix_lib -lssl -lcrypto" OPENSSL_CFLAGS="-I$openssl_prefix_include" @@ -50,13 +39,13 @@ fi if test "x$have_openssl" = "xyes"; then AC_DEFINE([HAVE_LIBSSL], [1], [Define to 1 if you have openssl.]) + LIBS="$OPENSSL_LIBS $LIBS" + CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS" # check whether EVP_DigestInit_ex exists. Old openssl doesn't have it. AC_CHECK_FUNCS([EVP_DigestInit_ex], [have_digestinit_ex=yes]) if test "x$have_digestinit_ex" = "x"; then AC_DEFINE([HAVE_OLD_LIBSSL], [1], [Define to 1 if you have old openssl.]) fi - AC_SUBST(OPENSSL_LIBS) - AC_SUBST(OPENSSL_CFLAGS) # search for sha224 support AC_CHECK_FUNCS([EVP_sha224]) # search for sha256 support @@ -69,4 +58,5 @@ fi LIBS=$LIBS_save CPPFLAGS=$CPPFLAGS_save +PKG_CONFIG_PATH=$PKG_CONFIG_PATH_save ])