[pacman-dev] [PATCH 02/11] buildsys: use pkg-config for openssl detection

Dave Reisner dreisner at archlinux.org
Mon Apr 2 17:15:47 EDT 2012


Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
 configure.ac            |   21 +++++++++------------
 lib/libalpm/Makefile.am |    9 ++++++++-
 src/util/Makefile.am    |    2 +-
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index 12a6e65..824241d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,17 +157,14 @@ AC_CHECK_LIB([archive], [archive_read_data], ,
 	AC_MSG_ERROR([libarchive is needed to compile pacman!]))
 
 # Check for OpenSSL
-AC_MSG_CHECKING(whether to link with libssl)
-AS_IF([test "x$with_openssl" != "xno"],
-	[AC_MSG_RESULT(yes)
-	AC_CHECK_LIB([ssl], [MD5_Final], ,
-	[if test "x$with_openssl" != "xcheck"; then
-		AC_MSG_FAILURE([--with-openssl was given, but -lssl was not found])
-	fi],
-	[-lcrypto])
-	with_openssl=$ac_cv_lib_ssl_MD5_Final],
-	AC_MSG_RESULT(no))
-AM_CONDITIONAL([HAVE_LIBSSL], [test "x$with_openssl" = "xyes"])
+if test "x$with_openssl" != "xno"; then
+	PKG_CHECK_MODULES(LIBSSL, [libssl libcrypto],
+		[AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) with_openssl=yes], with_openssl=no)
+	if test "x$with_openssl" = xno -a "x$with_openssl" = xyes; then
+		AC_MSG_ERROR([*** openssl support requested but libraries not found])
+	fi
+fi
+AM_CONDITIONAL(HAVE_LIBSSL, [test "$with_openssl" = "yes"])
 
 # Check for gpgme
 AC_MSG_CHECKING(whether to link with libgpgme)
@@ -413,7 +410,7 @@ ${PACKAGE_NAME}:
     preprocessor flags     : ${CPPFLAGS}
     compiler flags         : ${CFLAGS}
     defines                : ${DEFS}
-    library flags          : ${LIBS}
+    library flags          : ${LIBS} ${LIBSSL_LIBS}
     linker flags           : ${LDFLAGS}
 
     Architecture           : ${CARCH}
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 61dcb87..8d1be90 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -64,6 +64,13 @@ libalpm_la_SOURCES += \
 endif
 
 libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) @LIBCURL@
-libalpm_la_LIBADD = $(LTLIBINTL)
+
+libalpm_la_CFLAGS = \
+	$(AM_CFLAGS) \
+	$(LIBSSL_CFLAGS)
+
+libalpm_la_LIBADD = \
+	$(LTLIBINTL) \
+	$(LIBSSL_LIBS)
 
 # vim:set ts=2 sw=2 noet:
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index e386d95..1465407 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -35,6 +35,6 @@ testpkg_SOURCES = testpkg.c
 testpkg_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la
 
 vercmp_SOURCES = vercmp.c
-vercmp_LDADD = $(top_builddir)/lib/libalpm/version.lo
+vercmp_LDADD = $(top_builddir)/lib/libalpm/libalpm_la-version.lo
 
 # vim:set ts=2 sw=2 noet:
-- 
1.7.9.5



More information about the pacman-dev mailing list