Browse Source

build: Use system libmd if available

This fixes a build failure on at least FreeBSD, and possibly other
BSD systems, where the md5.h header provided by libmd maps the md5
functions to namespaced ones, and then there is a mismatch between
the always included functions from libcompat and from libmd.
Guillem Jover 9 years ago
parent
commit
d54b2f1ce6
6 changed files with 23 additions and 4 deletions
  1. 1 0
      configure.ac
  2. 1 0
      debian/changelog
  3. 2 1
      lib/compat/Makefile.am
  4. 3 1
      lib/dpkg/Makefile.am
  5. 1 1
      lib/dpkg/libdpkg.pc.in
  6. 15 1
      m4/dpkg-libs.m4

+ 1 - 0
configure.ac

@@ -62,6 +62,7 @@ DPKG_CODE_COVERAGE
 AC_SYS_LARGEFILE
 
 # Checks for libraries.
+DPKG_LIB_MD
 DPKG_LIB_ZLIB
 DPKG_LIB_BZ2
 DPKG_LIB_LZMA

+ 1 - 0
debian/changelog

@@ -12,6 +12,7 @@ dpkg (1.18.1) UNRELEASED; urgency=low
     DEB_BUILD_OPTIONS. Regression introduced in dpkg 1.14.15.
   * Honor Pre-Depends, Conflicts and Breaks for packages in unpacked and
     half states. Thanks to Ian Jackson <iwj@ubuntu.com>. Closes: #377860
+  * Fix build failure on FreeBSD by actually using libmd if available.
   * Perl modules:
     - Add missing strict and warnings pragmas for submodules.
     - Use non-destructive substitutions inside map.

+ 2 - 1
lib/compat/Makefile.am

@@ -32,8 +32,9 @@ libcompat_la_SOURCES = \
 	compat.h \
 	gettext.h
 
-# FIXME: unconditionally include these for now.
+if !HAVE_LIBMD_MD5
 libcompat_la_SOURCES += md5.c md5.h
+endif
 
 if !HAVE_GETOPT
 libcompat_la_SOURCES += getopt.c getopt.h

+ 3 - 1
lib/dpkg/Makefile.am

@@ -23,10 +23,12 @@ pkgconfig_DATA = libdpkg.pc
 
 lib_LTLIBRARIES = libdpkg.la
 
+libdpkg_la_LDFLAGS =
 if HAVE_LINKER_VERSION_SCRIPT
-libdpkg_la_LDFLAGS = \
+libdpkg_la_LDFLAGS += \
 	-Wl,--version-script=$(srcdir)/libdpkg.map
 endif
+libdpkg_la_LDFLAGS += $(MD_LIBS)
 libdpkg_la_LIBADD = \
 	../compat/libcompat.la
 if BUILD_SHARED

+ 1 - 1
lib/dpkg/libdpkg.pc.in

@@ -7,5 +7,5 @@ Name: libdpkg
 Description: Debian package management system library
 Version: @VERSION@
 Libs: -L${libdir} -ldpkg
-Libs.private: @ZLIB_LIBS@ @LIBLZMA_LIBS@ @BZ2_LIBS@
+Libs.private: @MD_LIBS@ @ZLIB_LIBS@ @LIBLZMA_LIBS@ @BZ2_LIBS@
 Cflags: -I${includedir}

+ 15 - 1
m4/dpkg-libs.m4

@@ -1,6 +1,20 @@
 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>
 # Copyright © 2007 Nicolas François <nicolas.francois@centraliens.net>
-# Copyright © 2006, 2009 Guillem Jover <guillem@debian.org>
+# Copyright © 2006, 2009-2012, 2014-2015 Guillem Jover <guillem@debian.org>
+
+# DPKG_LIB_MD
+# -----------
+# Check for the message digest library.
+AC_DEFUN([DPKG_LIB_MD], [
+  AC_ARG_VAR([MD_LIBS], [linker flags for md library])
+  AC_CHECK_HEADERS([md5.h], [
+    AC_CHECK_LIB([md], [MD5Init], [have_libmd=yes], [
+      AC_MSG_FAILURE([md5 digest not found in libmd])
+    ])
+  ])
+  AS_IF([test "x$have_libmd" = "xyes"], [MD_LIBS="-lmd"])
+  AM_CONDITIONAL([HAVE_LIBMD_MD5], [test "x$ac_cv_lib_md_MD5Init" = "xyes"])
+])# DPKG_LIB_MD
 
 # DPKG_WITH_COMPRESS_LIB(NAME, HEADER, FUNC, LINK)
 # -------------------------------------------------