Browse Source

build: Uniformize library build options

Make all of them consistently follow the pattern --with-lib<name>.
Rename the m4 macros, preprocessor defines, and automake _LIBS flags.
Guillem Jover 7 years ago
parent
commit
067295e958
12 changed files with 62 additions and 60 deletions
  1. 3 3
      README
  2. 4 4
      configure.ac
  3. 2 0
      debian/changelog
  4. 3 3
      debian/rules
  5. 2 2
      dpkg-deb/Makefile.am
  6. 2 2
      lib/compat/Makefile.am
  7. 2 2
      lib/dpkg/Makefile.am
  8. 5 5
      lib/dpkg/compress.c
  9. 1 1
      lib/dpkg/libdpkg.pc.in
  10. 30 30
      m4/dpkg-libs.m4
  11. 2 2
      src/script.c
  12. 6 6
      src/selinux.c

+ 3 - 3
README

@@ -67,9 +67,9 @@ The minimum software required to configure and build dpkg from a tarball is:
 To enable optional functionality or programs, this software might be needed:
 
   libmd (used by libdpkg, currently falling back to embedded code)
-  zlib (used instead of gzip command-line tool)
-  xz's liblzma (used instead of xz command-line tool)
-  libbzip2 (used instead of bzip2 command-line tool)
+  libz (from zlib, used instead of gzip command-line tool)
+  liblzma (from xz utils, used instead of xz command-line tool)
+  libbz2 (from bzip2, used instead of bzip2 command-line tool)
   libselinux
   curses compatible library (needed on --enable-dselect)
 

+ 4 - 4
configure.ac

@@ -73,7 +73,7 @@ AC_SYS_LARGEFILE
 
 # Checks for libraries.
 DPKG_LIB_MD
-DPKG_LIB_ZLIB
+DPKG_LIB_Z
 DPKG_LIB_BZ2
 DPKG_LIB_LZMA
 DPKG_LIB_SELINUX
@@ -189,10 +189,10 @@ Configuration:
   System Libraries:
     libps . . . . . . . . . . . . : ${have_libps:-no}
     libkvm  . . . . . . . . . . . : ${have_libkvm:-no}
-    libselinux  . . . . . . . . . : $with_selinux
+    libselinux  . . . . . . . . . : $with_libselinux
     libmd . . . . . . . . . . . . : $with_libmd
-    libz  . . . . . . . . . . . . : $with_zlib
+    libz  . . . . . . . . . . . . : $with_libz
     liblzma . . . . . . . . . . . : $with_liblzma
-    libbz2  . . . . . . . . . . . : $with_bz2
+    libbz2  . . . . . . . . . . . : $with_libbz2
     libcurses . . . . . . . . . . : ${have_libcurses:-no}
 CONFIG

+ 2 - 0
debian/changelog

@@ -87,6 +87,8 @@ dpkg (1.18.8) UNRELEASED; urgency=medium
   * Build system:
     - Stop allowing to set deprecated bzip2 compressor as dpkg-deb default.
     - Use libmd automatically if available.
+    - Uniformize library build options, from --with-zlib to --with-libz,
+      --with-bz2 to --with-libbz2 and --with-selinux to --with-libselinux.
   * Test suite:
     - Bump perlcritic ValuesAndExpressions::RequireNumberSeparators minimum
       to 99999.

+ 3 - 3
debian/rules

@@ -31,7 +31,7 @@ endif
 
 # Do not enable everything on all platforms.
 ifeq ($(DEB_HOST_ARCH_OS),linux)
-	confflags += --with-selinux
+	confflags += --with-libselinux
 endif
 ifeq (,$(filter maintainer-build,$(DEB_BUILD_OPTIONS)))
 	confflags += --disable-silent-rules
@@ -60,9 +60,9 @@ build-tree/config.status: configure
 		--localstatedir=/var \
 		--with-devlibdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
 		--without-libmd \
-		--with-zlib \
+		--with-libz \
 		--with-liblzma \
-		--with-bz2
+		--with-libbz2
 
 # Build the package in build-tree
 build-indep build-arch build: build-tree/config.status

+ 2 - 2
dpkg-deb/Makefile.am

@@ -20,6 +20,6 @@ dpkg_deb_SOURCES = \
 dpkg_deb_LDADD = \
 	../lib/dpkg/libdpkg.la \
 	$(LIBINTL) \
-	$(ZLIB_LIBS) \
-	$(LIBLZMA_LIBS) \
+	$(Z_LIBS) \
+	$(LZMA_LIBS) \
 	$(BZ2_LIBS)

+ 2 - 2
lib/compat/Makefile.am

@@ -23,7 +23,7 @@ if HAVE_SYS_ERRLIST
 libcompat_test_la_SOURCES += strerror.c
 endif
 
-if WITH_SELINUX
+if WITH_LIBSELINUX
 libcompat_test_la_SOURCES += selinux.c
 endif
 
@@ -64,7 +64,7 @@ if !HAVE_STRSIGNAL
 libcompat_la_SOURCES += strsignal.c
 endif
 
-if WITH_SELINUX
+if WITH_LIBSELINUX
 if !HAVE_SETEXECFILECON
 libcompat_la_SOURCES += selinux.c
 endif

+ 2 - 2
lib/dpkg/Makefile.am

@@ -34,8 +34,8 @@ libdpkg_la_LIBADD = \
 if BUILD_SHARED
 libdpkg_la_LIBADD += \
 	$(LIBINTL) \
-	$(ZLIB_LIBS) \
-	$(LIBLZMA_LIBS) \
+	$(Z_LIBS) \
+	$(LZMA_LIBS) \
 	$(BZ2_LIBS)
 endif
 libdpkg_la_DEPENDENCIES = \

+ 5 - 5
lib/dpkg/compress.c

@@ -29,13 +29,13 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#ifdef WITH_ZLIB
+#ifdef WITH_LIBZ
 #include <zlib.h>
 #endif
 #ifdef WITH_LIBLZMA
 #include <lzma.h>
 #endif
-#ifdef WITH_BZ2
+#ifdef WITH_LIBBZ2
 #include <bzlib.h>
 #endif
 
@@ -47,7 +47,7 @@
 #include <dpkg/buffer.h>
 #include <dpkg/command.h>
 #include <dpkg/compress.h>
-#if !defined(WITH_ZLIB) || !defined(WITH_LIBLZMA) || !defined(WITH_BZ2)
+#if !defined(WITH_LIBZ) || !defined(WITH_LIBLZMA) || !defined(WITH_LIBBZ2)
 #include <dpkg/subproc.h>
 
 static void DPKG_ATTR_SENTINEL
@@ -145,7 +145,7 @@ fixup_gzip_params(struct compress_params *params)
 		params->type = COMPRESSOR_TYPE_NONE;
 }
 
-#ifdef WITH_ZLIB
+#ifdef WITH_LIBZ
 static void
 decompress_gzip(int fd_in, int fd_out, const char *desc)
 {
@@ -278,7 +278,7 @@ fixup_bzip2_params(struct compress_params *params)
 		params->level = 1;
 }
 
-#ifdef WITH_BZ2
+#ifdef WITH_LIBBZ2
 static void
 decompress_bzip2(int fd_in, int fd_out, const char *desc)
 {

+ 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: @MD_LIBS@ @ZLIB_LIBS@ @LIBLZMA_LIBS@ @BZ2_LIBS@
+Libs.private: @MD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @BZ2_LIBS@
 Cflags: -I${includedir}

+ 30 - 30
m4/dpkg-libs.m4

@@ -24,51 +24,51 @@ AC_DEFUN([DPKG_LIB_MD], [
   AM_CONDITIONAL([HAVE_LIBMD_MD5], [test "x$ac_cv_lib_md_MD5Init" = "xyes"])
 ])# DPKG_LIB_MD
 
-# DPKG_WITH_COMPRESS_LIB(NAME, HEADER, FUNC, LINK)
+# DPKG_WITH_COMPRESS_LIB(NAME, HEADER, FUNC)
 # -------------------------------------------------
 # Check for availability of a compression library.
 AC_DEFUN([DPKG_WITH_COMPRESS_LIB], [
   AC_ARG_VAR(AS_TR_CPP($1)[_LIBS], [linker flags for $1 library])
-  AC_ARG_WITH($1,
-    AS_HELP_STRING([--with-$1],
+  AC_ARG_WITH([lib]$1,
+    AS_HELP_STRING([--with-lib$1],
                    [use $1 library for compression and decompression]))
-  if test "x$with_$1" != "xno"; then
-    AC_CHECK_LIB([$4], [$3], [
-      AC_DEFINE([WITH_]AS_TR_CPP($1), 1,
-                [Define to 1 to use $1 rather than console tool])
-      if test "x$with_$1" = "xstatic"; then
-        dpkg_$1_libs="-Wl,-Bstatic -l$4 -Wl,-Bdynamic"
+  if test "x$with_lib$1" != "xno"; then
+    AC_CHECK_LIB([$1], [$3], [
+      AC_DEFINE([WITH_LIB]AS_TR_CPP($1), 1,
+                [Define to 1 to use $1 library rather than console tool])
+      if test "x$with_lib$1" = "xstatic"; then
+        dpkg_$1_libs="-Wl,-Bstatic -l$1 -Wl,-Bdynamic"
       else
-        dpkg_$1_libs="-l$4"
+        dpkg_$1_libs="-l$1"
       fi
       AS_TR_CPP($1)_LIBS="${AS_TR_CPP($1)_LIBS:+$AS_TR_CPP($1)_LIBS }$dpkg_$1_libs"
-      with_$1="yes"
+      with_lib$1="yes"
     ], [
-      if test -n "$with_$1"; then
+      if test -n "$with_lib$1"; then
         AC_MSG_FAILURE([$1 library not found])
       fi
     ])
 
     AC_CHECK_HEADER([$2], [], [
-      if test -n "$with_$1"; then
-        AC_MSG_FAILURE([$1 header not found])
+      if test -n "$with_lib$1"; then
+        AC_MSG_FAILURE([lib$1 header not found])
       fi
     ])
   fi
 ])# DPKG_WITH_COMPRESS_LIB
 
-# DPKG_LIB_ZLIB
+# DPKG_LIB_Z
 # -------------
-# Check for zlib library.
-AC_DEFUN([DPKG_LIB_ZLIB], [
-  DPKG_WITH_COMPRESS_LIB([zlib], [zlib.h], [gzdopen], [z])
-])# DPKG_LIB_ZLIB
+# Check for z library.
+AC_DEFUN([DPKG_LIB_Z], [
+  DPKG_WITH_COMPRESS_LIB([z], [zlib.h], [gzdopen])
+])# DPKG_LIB_Z
 
 # DPKG_LIB_LZMA
 # -------------
 # Check for lzma library.
 AC_DEFUN([DPKG_LIB_LZMA], [
-  DPKG_WITH_COMPRESS_LIB([liblzma], [lzma.h], [lzma_alone_decoder], [lzma])
+  DPKG_WITH_COMPRESS_LIB([lzma], [lzma.h], [lzma_alone_decoder])
   AC_CHECK_LIB([lzma], [lzma_stream_encoder_mt],
                [AC_DEFINE([HAVE_LZMA_MT], [1],
                           [xz multithreaded compression support])])
@@ -78,7 +78,7 @@ AC_DEFUN([DPKG_LIB_LZMA], [
 # ------------
 # Check for bz2 library.
 AC_DEFUN([DPKG_LIB_BZ2], [
-  DPKG_WITH_COMPRESS_LIB([bz2], [bzlib.h], [BZ2_bzdopen], [bz2])
+  DPKG_WITH_COMPRESS_LIB([bz2], [bzlib.h], [BZ2_bzdopen])
 ])# DPKG_LIB_BZ2
 
 # DPKG_LIB_SELINUX
@@ -88,12 +88,12 @@ AC_DEFUN([DPKG_LIB_SELINUX], [
 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
 m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([missing pkg-config macros])])
 AC_ARG_VAR([SELINUX_LIBS], [linker flags for selinux library])dnl
-AC_ARG_WITH(selinux,
-	AS_HELP_STRING([--with-selinux],
+AC_ARG_WITH(libselinux,
+	AS_HELP_STRING([--with-libselinux],
 		       [use selinux library to set security contexts]))
-if test "x$with_selinux" != "xno"; then
+if test "x$with_libselinux" != "xno"; then
 	AC_CHECK_LIB([selinux], [is_selinux_enabled],
-		[AC_DEFINE(WITH_SELINUX, 1,
+		[AC_DEFINE(WITH_LIBSELINUX, 1,
 			[Define to 1 to compile in SELinux support])
 		PKG_CHECK_EXISTS([libselinux], [
 			if test "x$with_selinux" = "xstatic"; then
@@ -102,15 +102,15 @@ if test "x$with_selinux" != "xno"; then
 				dpkg_selinux_libs=$($PKG_CONFIG --libs libselinux)
 			fi
 		], [
-			if test "x$with_selinux" = "xstatic"; then
+			if test "x$with_libselinux" = "xstatic"; then
 				dpkg_selinux_libs="-Wl,-Bstatic -lselinux -lsepol -Wl,-Bdynamic"
 			else
 				dpkg_selinux_libs="-lselinux"
 			fi
 		])
 		 SELINUX_LIBS="${SELINUX_LIBS:+$SELINUX_LIBS }$dpkg_selinux_libs"
-		 with_selinux="yes"],
-		[if test -n "$with_selinux"; then
+		 with_libselinux="yes"],
+		[if test -n "$with_libselinux"; then
 			AC_MSG_FAILURE([selinux library not found])
 		 fi])
 	AC_CHECK_LIB([selinux], [setexecfilecon],
@@ -119,11 +119,11 @@ if test "x$with_selinux" != "xno"; then
 	])
 
 	AC_CHECK_HEADER([selinux/selinux.h],,
-		[if test -n "$with_selinux"; then
+		[if test -n "$with_libselinux"; then
 			AC_MSG_FAILURE([selinux header not found])
 		 fi])
 fi
-AM_CONDITIONAL(WITH_SELINUX, [test "x$with_selinux" = "xyes"])
+AM_CONDITIONAL(WITH_LIBSELINUX, [test "x$with_libselinux" = "xyes"])
 AM_CONDITIONAL(HAVE_SETEXECFILECON,
                [test "x$ac_cv_lib_selinux_setexecfilecon" = "xyes"])
 ])# DPKG_LIB_SELINUX

+ 2 - 2
src/script.c

@@ -31,7 +31,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 #include <selinux/selinux.h>
 #endif
 
@@ -153,7 +153,7 @@ maintscript_set_exec_context(struct command *cmd, const char *fallback)
 {
 	int rc = 0;
 
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 	rc = setexecfilecon(cmd->filename, fallback);
 #endif
 

+ 6 - 6
src/selinux.c

@@ -31,7 +31,7 @@
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 #include <selinux/selinux.h>
 #include <selinux/avc.h>
 #include <selinux/label.h>
@@ -39,14 +39,14 @@
 
 #include "main.h"
 
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 static struct selabel_handle *sehandle;
 #endif
 
 void
 dpkg_selabel_load(void)
 {
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 	static int selinux_enabled = -1;
 
 	if (selinux_enabled < 0) {
@@ -84,7 +84,7 @@ dpkg_selabel_load(void)
 void
 dpkg_selabel_set_context(const char *matchpath, const char *path, mode_t mode)
 {
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 	security_context_t scontext = NULL;
 	int ret;
 
@@ -110,13 +110,13 @@ dpkg_selabel_set_context(const char *matchpath, const char *path, mode_t mode)
 		        path);
 
 	freecon(scontext);
-#endif /* WITH_SELINUX */
+#endif /* WITH_LIBSELINUX */
 }
 
 void
 dpkg_selabel_close(void)
 {
-#ifdef WITH_SELINUX
+#ifdef WITH_LIBSELINUX
 	if (sehandle == NULL)
 		return;