[PATCH 4/4] Update/improve the way we check for libraries

Sergio Durigan Junior sergiodj en sergiodj.net
Lun Abr 14 06:10:37 UTC 2014


Using PKG_CHECK_MODULES is not very neat because the user might want to
be able to provide a different $LDFLAGS, and this would break the build.
Instead, we should be using autoconf's default
AC_CHECK_LIB/AC_SEARCH_LIBS (in our case, I chosed the latter).  This
way, we don't need to modify $LIBS inside configure.ac.

This patch also adds a check for zlib, and updates $CFLAGS accordingly
based on the output of 'pkg-config' for both GNUTLS and zlib libraries.
---
 configure.ac | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 77fc984..0aa6155 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,15 +31,23 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_LANG_WERROR
 
-dnl Checking for GNUTLS and libgcrypt.
-PKG_CHECK_MODULES(GNUTLS, gnutls >= 1.4.0, , AC_MSG_ERROR(Could not find gnutls))
-AM_PATH_LIBGCRYPT(,,AC_MSG_ERROR(Could not find gcrypt))
+dnl Checking for GNUTLS.
+AC_SEARCH_LIBS([gnutls_init], [gnutls],	[],
+	AC_MSG_ERROR([could not find gnutls]))
+
+dnl Checking for libgcrypt.
+AC_SEARCH_LIBS([gcry_cipher_open], [gcrypt], [],
+	AC_MSG_ERROR([could not find libgcrypt]))
+
+dnl Checking for zlib.
+AC_SEARCH_LIBS([zlibVersion], [z], [],
+	AC_MSG_ERROR([could not find zlib]))
 
 dnl Setting useful flags.
-LIBS="$LIBGCRYPT_LIBS $GNUTLS_LIBS $LIBS -lz"
-CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS \
-	-Wall -Werror -Wextra -Wunused -Wunused-variable \
-	$CFLAGS"
+CFLAGS="`pkg-config --cflags gnutls 2> /dev/null` \
+`pkg-config --cflags zlib 2> /dev/null` \
+-Wall -Werror -Wextra -Wunused -Wunused-variable \
+$CFLAGS"
 
 dnl Outputting the necessary files for the build.
 AC_CONFIG_HEADERS([config.h])
-- 
1.9.0



Más información sobre la lista de distribución Softwares-impostos