Skip to contentSkip to conversation

configure update

PATCH New Zdenek Kabelac 2 participants 12 messages Mar 2, 2010 – Mar 3, 2010

lore
Share & tools
lore
#0 lore raw

cover configure update

This patchset tries to mainly address linking problems. First few patches are rather cosmetic cleanups.

Interestings patches starts with: Readline linking update.

With this patchset libpthread and libselinux are linked only to object files which really needs this library. Tested it on Fedora & Debian distribution.

Zdenek Kabelac (9):
Help display --disable-fsadm
Fix autoconf WARNING:
For Makefile vars use $() instead of ${}
Move include before DEFS+=
Readline linking update
Pthread linking change
Remove -rdynamic
SELinux configure update
misc/configure.in modification

 configure.in                                  |   91 +++++++++++--------------
 daemons/clvmd/Makefile.in                     |    4 +-
 daemons/dmeventd/Makefile.in                  |    4 +-
 daemons/dmeventd/plugins/lvm2/Makefile.in     |    4 +-
 daemons/dmeventd/plugins/mirror/Makefile.in   |    6 +-
 daemons/dmeventd/plugins/snapshot/Makefile.in |    6 +-
 lib/misc/configure.h.in                       |    3 -
 libdm/Makefile.in                             |    4 +-
 make.tmpl.in                                  |    1 +
 man/Makefile.in                               |    4 +-
 test/api/Makefile.in                          |    2 +-
 tools/Makefile.in                             |   13 ++--
 12 files changed, 65 insertions(+), 77 deletions(-)
#1 lore raw

PATCH 1/9 Help display --disable-fsadm

As fsadm is installed by default - it's a common practice to rather print help text in '--disable' form for such case.

---
 configure.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
configure.in +2 -2
index aaa21c6..4053f7f 100644
@@ -737,8 +737,8 @@ AC_ARG_ENABLE(pkgconfig,   [  --enable-pkgconfig      Install pkgconfig support]
 ################################################################################
 dnl -- Enable fsadm
 AC_MSG_CHECKING(whether to install fsadm)
-AC_ARG_ENABLE(fsadm, [  --enable-fsadm          Enable fsadm],
-FSADM=$enableval)
+AC_ARG_ENABLE(fsadm, [AC_HELP_STRING([--disable-fsadm], [Disable fsadm])],
+	FSADM=$enableval)
 AC_MSG_RESULT($FSADM)
 
 ################################################################################
Signature · 1 line
1.7.0
#2 lore raw

PATCH 2/9 Fix autoconf WARNING:

In reply to Zdenek Kabelac

Use datarootdir and fix warning during configure process:
config.status: WARNING: 'make.tmpl.in' seems to ignore the --datarootdir setting

---
 make.tmpl.in |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
make.tmpl.in +1 -0
index 1cba3f2..61365ec 100644
@@ -47,6 +47,7 @@ libdir = $(DESTDIR)@libdir@
 usrlibdir = $(DESTDIR)@usrlibdir@
 sbindir = $(DESTDIR)@sbindir@
 usrsbindir = $(DESTDIR)@usrsbindir@
+datarootdir = $(DESTDIR)@datarootdir@
 infodir = $(DESTDIR)@infodir@
 mandir = $(DESTDIR)@mandir@
 localedir = $(DESTDIR)@LOCALEDIR@
Signature · 1 line
1.7.0
#3 lore raw

PATCH 3/9 For Makefile vars use $() instead of ${}

In reply to Zdenek Kabelac

Both definitions are correct, but we should use one form consistenly through all Makefiles.

---
 daemons/dmeventd/plugins/lvm2/Makefile.in     |    2 +-
 daemons/dmeventd/plugins/mirror/Makefile.in   |    4 ++--
 daemons/dmeventd/plugins/snapshot/Makefile.in |    4 ++--
 man/Makefile.in                               |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)
daemons/dmeventd/plugins/lvm2/Makefile.in +1 -1
index 96c60e0..af6807b 100644
@@ -16,7 +16,7 @@ top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 VPATH = @srcdir@
 
-CLDFLAGS += -L${top_builddir}/tools
+CLDFLAGS += -L$(top_builddir)/tools
 
 SOURCES = dmeventd_lvm.c
 
daemons/dmeventd/plugins/mirror/Makefile.in +2 -2
index a6af47f..bdb49d1 100644
@@ -17,8 +17,8 @@ top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 VPATH = @srcdir@
 
-INCLUDES += -I${top_srcdir}/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
-CLDFLAGS += -L${top_builddir}/tools -L${top_builddir}/daemons/dmeventd/plugins/lvm2
+INCLUDES += -I$(top_srcdir)/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
+CLDFLAGS += -L$(top_builddir)/tools -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
 
 SOURCES = dmeventd_mirror.c
 
daemons/dmeventd/plugins/snapshot/Makefile.in +2 -2
index 133459d..4b203a0 100644
@@ -17,8 +17,8 @@ top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 VPATH = @srcdir@
 
-INCLUDES += -I${top_srcdir}/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
-CLDFLAGS += -L${top_builddir}/tools -L${top_builddir}/daemons/dmeventd/plugins/lvm2
+INCLUDES += -I$(top_srcdir)/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
+CLDFLAGS += -L$(top_builddir)/tools -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
 
 SOURCES = dmeventd_snapshot.c
 
man/Makefile.in +2 -2
index dfe95e6..b1b8596 100644
@@ -43,8 +43,8 @@ ifeq ("@BUILD_CMIRRORD@", "yes")
 endif
 
 MAN8DM=dmsetup.8
-MAN5DIR=${mandir}/man5
-MAN8DIR=${mandir}/man8
+MAN5DIR=$(mandir)/man5
+MAN8DIR=$(mandir)/man8
 
 CLEAN_TARGETS=$(MAN5) $(MAN8) $(MAN8CLUSTER) $(FSADMMAN) $(MAN8DM)
 
Signature · 1 line
1.7.0
#4 lore raw

PATCH 4/9 Move include before DEFS+=

In reply to Zdenek Kabelac

This patch moves inclusion of the make.tmpl before DEFS modification, so we can have them in the same order on the in compilation line. (i.e. HAVE_CONFIG_H goes first)

---
 libdm/Makefile.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
libdm/Makefile.in +2 -2
index 6dd25ff..1884b21 100644
@@ -47,11 +47,11 @@ endif
 VERSIONED_SHLIB = libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION_DM)
 LIB_VERSION = $(LIB_VERSION_DM)
 
+include ../make.tmpl
+
 DEFS += -DDM_DEVICE_UID=@DM_DEVICE_UID@ -DDM_DEVICE_GID=@DM_DEVICE_GID@ \
 	-DDM_DEVICE_MODE=@DM_DEVICE_MODE@
 
-include ../make.tmpl
-
 device-mapper: all
 
 .PHONY: install_dynamic install_static install_include \
Signature · 1 line
1.7.0
#5 lore raw

PATCH 5/9 Readline linking update

In reply to Zdenek Kabelac

Modify linking of readline library. Create new substituted varible READLINE_LIBS - readline library is linked ONLY with tools that really use it - i.e. lvm. (Static lvm does not use readlin).
Previous behaviour put this library into the variable LIBS and thus linked it with all created object files of lvm project (i.e. plugins...).

READLINE detection is simplified.
AC_SEARCH_LIBS needs to save/restore LIBS

Extra checking for termcap should not be really needed as the readline library should have the proper dependencies compiled into the library. Do we have some cases where we have to figure and link this termcap library explicitly?

---
 configure.in      |   39 +++++++++++++++++++++------------------
 tools/Makefile.in |    2 +-
 2 files changed, 22 insertions(+), 19 deletions(-)
configure.in +21 -18
index 4053f7f..a9850a2 100644
@@ -790,19 +790,21 @@ fi;
 ################################################################################
 dnl -- Check for termcap (Shamelessly copied from parted 1.4.17)
 if test x$READLINE != xno; then
+	lvm_saved_libs=$LIBS
 	AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses termcap termlib],
-	  [tg_found=yes], [tg_found=no])
-	test x$READLINE:$tg_found = xyes:no &&
-	  AC_MSG_ERROR(
-termcap could not be found which is required for the
+		READLINE_LIBS=$ac_cv_search_tgetent, [
+		if test "$READLINE" = yes; then
+			AC_MSG_ERROR(
+[termcap could not be found which is required for the
 --enable-readline option (which is enabled by default).  Either disable readline
 support with --disable-readline or download and install termcap from:
 	ftp.gnu.org/gnu/termcap
 Note: if you are using precompiled packages you will also need the development
   package as well (which may be called termcap-devel or something similar).
 Note: (n)curses also seems to work as a substitute for termcap.  This was
-  not found either - but you could try installing that as well.
-)
+  not found either - but you could try installing that as well.])
+		fi])
+	LIBS=$lvm_saved_libs
 fi
 
 ################################################################################
@@ -887,22 +889,22 @@ AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getop
 ################################################################################
 dnl -- Check for readline (Shamelessly copied from parted 1.4.17)
 if test x$READLINE != xno; then
-	rl_found=yes
-	AC_CHECK_LIB([readline], [readline], , [rl_found=no])
-	test x$READLINE:$rl_found = xyes:no &&
-	  AC_MSG_ERROR(
-GNU Readline could not be found which is required for the
+	AC_CHECK_LIB([readline], [readline], [
+		READLINE_LIBS="-lreadline $READLINE_LIBS"
+		lvm_save_LIBS=$LIBS
+		LIBS="$READLINE_LIBS $LIBS"
+		AC_CHECK_FUNCS([rl_completion_matches])
+		LIBS=$lvm_save_LIBS
+		AC_DEFINE([READLINE_SUPPORT], 1, [Define to 1 to include the LVM readline shell.])],[
+		if test "$READLINE" = yes; then
+			AC_MSG_ERROR(
+[GNU Readline could not be found which is required for the
 --enable-readline option (which is enabled by default).  Either disable readline
 support with --disable-readline or download and install readline from:
 	ftp.gnu.org/gnu/readline
 Note: if you are using precompiled packages you will also need the development
-package as well (which may be called readline-devel or something similar).
-)
-	if test $rl_found = yes; then
-		AC_CHECK_FUNCS([rl_completion_matches])
-		AC_DEFINE([READLINE_SUPPORT], 1,
-		  [Define to 1 to include the LVM readline shell.])
-	fi
+package as well (which may be called readline-devel or something similar).])
+                fi])
 fi
 
 ################################################################################
@@ -1123,6 +1125,7 @@ AC_SUBST(PKGCONFIG)
 AC_SUBST(POOL)
 AC_SUBST(QUORUM_CFLAGS)
 AC_SUBST(QUORUM_LIBS)
+AC_SUBST(READLINE_LIBS)
 AC_SUBST(SACKPT_CFLAGS)
 AC_SUBST(SACKPT_LIBS)
 AC_SUBST(SALCK_CFLAGS)
tools/Makefile.in +1 -1
index b650c67..07fd4a6 100644
@@ -123,7 +123,7 @@ all: device-mapper
 
 lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) lvm.o \
-		$(LVMLIBS) $(LIBS) $(LIB_PTHREAD) -rdynamic
+		$(LVMLIBS) @READLINE_LIBS@ $(LIBS) $(LIB_PTHREAD) -rdynamic
 
 lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
Signature · 1 line
1.7.0
#6 lore raw

PATCH 6/9 Pthread linking change

In reply to Zdenek Kabelac

Create new substituted variable PTHREAD_LIBS and link this library only with tools/libs which really needs it - i.e. dmeventd.

Check for libpthread only for builds with clvmd or dmeventd.

Remove variable LIB_PTHREAD

---
 configure.in                                  |    9 ++++++++-
 daemons/clvmd/Makefile.in                     |    4 +++-
 daemons/dmeventd/Makefile.in                  |    2 +-
 daemons/dmeventd/plugins/lvm2/Makefile.in     |    2 +-
 daemons/dmeventd/plugins/mirror/Makefile.in   |    2 +-
 daemons/dmeventd/plugins/snapshot/Makefile.in |    2 +-
 test/api/Makefile.in                          |    2 +-
 tools/Makefile.in                             |   12 +++++-------
 8 files changed, 21 insertions(+), 14 deletions(-)
configure.in +8 -1
index a9850a2..64ef0b6 100644
@@ -829,6 +829,12 @@ Features cannot be 'shared' when building statically
 fi
 
 ################################################################################
+if [[ "$DMEVENTD" = yes -o "$CLVMD" != none ]] ; then
+	AC_CHECK_LIB([pthread], [pthread_mutex_lock], 
+		[PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR(bailing out)])
+fi
+
+################################################################################
 dnl -- Disable selinux
 AC_MSG_CHECKING(whether to enable selinux support)
 AC_ARG_ENABLE(selinux, [  --disable-selinux       Disable selinux support],
@@ -1123,6 +1129,7 @@ AC_SUBST(MSGFMT)
 AC_SUBST(OWNER)
 AC_SUBST(PKGCONFIG)
 AC_SUBST(POOL)
+AC_SUBST(PTHREAD_LIBS)
 AC_SUBST(QUORUM_CFLAGS)
 AC_SUBST(QUORUM_LIBS)
 AC_SUBST(READLINE_LIBS)
@@ -1133,10 +1140,10 @@ AC_SUBST(SALCK_LIBS)
 AC_SUBST(SELINUX_LIBS)
 AC_SUBST(SNAPSHOTS)
 AC_SUBST(STATICDIR)
+AC_SUBST(STATIC_LIBS)
 AC_SUBST(STATIC_LINK)
 AC_SUBST(UDEV_RULES)
 AC_SUBST(UDEV_SYNC)
-AC_SUBST([LIB_PTHREAD])
 AC_SUBST(interface)
 AC_SUBST(kerneldir)
 AC_SUBST(missingkernel)
daemons/clvmd/Makefile.in +3 -1
index dad568e..d6e653a 100644
@@ -75,7 +75,7 @@ endif
 TARGETS = \
 	clvmd
 
-LVMLIBS = -llvm-internal -lpthread
+LVMLIBS = -llvm-internal
 
 ifeq ("@DMEVENTD@", "yes")
 	LVMLIBS += -ldevmapper-event
@@ -83,6 +83,8 @@ endif
  
 LVMLIBS += -ldevmapper
 
+LIBS += @PTHREAD_LIBS@
+
 DEFS += -D_REENTRANT
 CFLAGS += -fno-strict-aliasing
 
daemons/dmeventd/Makefile.in +1 -1
index d185205..eaf897a 100644
@@ -54,7 +54,7 @@ all: device-mapper
 device-mapper: $(TARGETS)
 
 LIBS += -ldl
-LVMLIBS += -ldevmapper-event -lpthread -ldevmapper
+LVMLIBS += -ldevmapper-event -ldevmapper @PTHREAD_LIBS@
 
 $(VERSIONED_SHLIB): $(LIB_SHARED)
 	$(RM) -f $@
daemons/dmeventd/plugins/lvm2/Makefile.in +1 -1
index af6807b..80d6a61 100644
@@ -29,7 +29,7 @@ LIB_VERSION = $(LIB_VERSION_LVM)
 
 include $(top_builddir)/make.tmpl
 
-LIBS += -ldevmapper @LIB_PTHREAD@ @LVM2CMD_LIB@
+LIBS += @LVM2CMD_LIB@ -ldevmapper @PTHREAD_LIBS@
 
 install_lvm2: libdevmapper-event-lvm2.$(LIB_SUFFIX)
 	$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
daemons/dmeventd/plugins/mirror/Makefile.in +1 -1
index bdb49d1..e060d96 100644
@@ -32,7 +32,7 @@ LIB_VERSION = $(LIB_VERSION_LVM)
 
 include $(top_builddir)/make.tmpl
 
-LIBS += -ldevmapper @LIB_PTHREAD@ @LVM2CMD_LIB@ -ldevmapper-event-lvm2
+LIBS += @LVM2CMD_LIB@ -ldevmapper-event-lvm2 -ldevmapper @PTHREAD_LIBS@
 
 install_lvm2: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX)
 	$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
daemons/dmeventd/plugins/snapshot/Makefile.in +1 -1
index 4b203a0..ea058c3 100644
@@ -32,7 +32,7 @@ LIB_VERSION = $(LIB_VERSION_LVM)
 
 include $(top_builddir)/make.tmpl
 
-LIBS += -ldevmapper @LIB_PTHREAD@ @LVM2CMD_LIB@ -ldevmapper-event-lvm2
+LIBS += @LVM2CMD_LIB@ -ldevmapper-event-lvm2 -ldevmapper @PTHREAD_LIBS@
 
 install_lvm2: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX)
 	$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
test/api/Makefile.in +1 -1
index 2c0c62f..605da33 100644
@@ -35,7 +35,7 @@ include $(top_builddir)/make.tmpl
 LDFLAGS = -L$(top_builddir)/libdm -L$(top_builddir)/liblvm
 
 ifeq ("@DMEVENTD@", "yes")
-	LVMLIBS += -ldevmapper-event -lpthread
+	LVMLIBS += -ldevmapper-event
 	LDFLAGS += -L$(top_builddir)/daemons/dmeventd
 endif
 
tools/Makefile.in +5 -7
index 07fd4a6..974abd2 100644
@@ -17,8 +17,6 @@ top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 VPATH = @srcdir@
 
-LIB_PTHREAD = @LIB_PTHREAD@
-
 SOURCES =\
 	dumpconfig.c \
 	formats.c \
@@ -100,7 +98,7 @@ ifeq ("@CMDLIB@", "yes")
 endif
 
 ifeq ("@DMEVENTD@", "yes")
-	LVMLIBS += -ldevmapper-event -lpthread
+	LVMLIBS += -ldevmapper-event
 endif
 
 LVMLIBS += -ldevmapper
@@ -113,21 +111,21 @@ device-mapper: $(TARGETS_DM)
 
 dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
 	$(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/libdm \
-	      -o $@ dmsetup.o -ldevmapper $(LIBS) $(LIB_PTHREAD)
+	      -o $@ dmsetup.o -ldevmapper $(LIBS)
 
 dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-	      -o $@ dmsetup.o -ldevmapper $(LIBS) $(LIB_PTHREAD)
+	      -o $@ dmsetup.o -ldevmapper $(LIBS)
 
 all: device-mapper
 
 lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) lvm.o \
-		$(LVMLIBS) @READLINE_LIBS@ $(LIBS) $(LIB_PTHREAD) -rdynamic
+		$(LVMLIBS) @READLINE_LIBS@ $(LIBS) -rdynamic
 
 lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
-	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS) $(LIB_PTHREAD) \
+	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS) \
 	      -rdynamic
 
 liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
Signature · 1 line
1.7.0
#7 lore raw

PATCH 7/9 Remove -rdynamic

In reply to Zdenek Kabelac

This patch might be a bit contraversional. It removes -rdynamic from linking of lvm.statis and dmeventd.static. In my understanding this compiler flag (or "-Wl,--export-dynamic") is mainly useful for dynamic linked libraries. It should not be needed for linking of static binary. But I could be wrong here...

---
 daemons/dmeventd/Makefile.in |    2 +-
 tools/Makefile.in            |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
daemons/dmeventd/Makefile.in +1 -1
index eaf897a..aacb6a4 100644
@@ -66,7 +66,7 @@ dmeventd: $(LIB_SHARED) $(VERSIONED_SHLIB) dmeventd.o
 
 dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
-	dmeventd.o $(LVMLIBS) $(LIBS) -rdynamic
+	dmeventd.o $(LVMLIBS) $(LIBS)
 
 ifeq ("@PKGCONFIG@", "yes")
   INSTALL_LIB_TARGETS += install_pkgconfig
tools/Makefile.in +1 -2
index 974abd2..a8cb6aa 100644
@@ -125,8 +125,7 @@ lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
 
 lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
-	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS) \
-	      -rdynamic
+	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS)
 
 liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
 	cat $(top_builddir)/lib/liblvm-internal.a > $@
Signature · 1 line
1.7.0
#8 lore raw

PATCH 7/9 Remove -rdynamic

Quoted 5 lines · Zdenek Kabelac

This patch might be a bit contraversional. It removes -rdynamic from linking of lvm.statis and dmeventd.static. In my understanding this compiler flag (or "-Wl,--export-dynamic") is mainly useful for dynamic linked libraries. It should not be needed for linking of static binary. But I could be wrong here...

(1) From man: This option is needed for some uses of "dlopen" or to allow obtaining backtraces from within a program.

(2) Also according to manual, you need -rdynamic to allow dlopen'd things to use symbols from the "host" binary.

We probably need not be concerned with (2) since we don't dlopen in lvm.static as far as I can tell. As for (1), as long as debuginfo (-g) is available, this is, as far as I can tell, redundant. So it *should* be safe to remove this.

Yours,
Petr.

#9 lore raw

PATCH 8/9 SELinux configure update

In reply to Zdenek Kabelac

This patch add substituted variables SELINUX_LIBS and STATIC_LIBS.

Here we have little trouble for static builds - there is the dependency on SELinux libraries which are not bundled automagicaly to 'ar' library files. So statically compiled binaries that links with libdevmapper needs to explicitly link $(STATIC_LIBS)
(until better solution is found).
Also it looks like some static builds of selinux have dependencies on runtime glibc libraries.

Modifies SELinux detection to use 3rd & 4th parameter for Success/Fail. Also removes detection of pthread from this check as we know which version of libdevmapper we are going to link with lvm after merge.

Move SELinux header check to the SELinux test code.

---
 configure.in                 |   39 +++++++++------------------------------
 daemons/dmeventd/Makefile.in |    2 +-
 libdm/Makefile.in            |    2 ++
 tools/Makefile.in            |    4 ++--
 4 files changed, 14 insertions(+), 33 deletions(-)
configure.in +9 -30
index 64ef0b6..284323f 100644
@@ -844,35 +844,19 @@ AC_MSG_RESULT($SELINUX)
 ################################################################################
 dnl -- Check for selinux
 if test x$SELINUX = xyes; then
-	AC_CHECK_LIB(sepol, sepol_check_context, HAVE_SEPOL=yes, HAVE_SEPOL=no)
+	AC_CHECK_LIB([sepol], [sepol_check_context], [
+		AC_DEFINE([HAVE_SEPOL], 1, [Define to 1 if sepol_check_context is available.])
+		SELINUX_LIBS="-lsepol $SELINUX_LIBS"])
 
-	if test x$HAVE_SEPOL = xyes; then
-		AC_DEFINE([HAVE_SEPOL], 1,
-		  [Define to 1 if sepol_check_context is available.])
-		SELINUX_LIBS="-lsepol $SELINUX_LIBS"
-	fi
-
-	AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)
-
-	if test x$HAVE_SELINUX = xyes; then
+	AC_CHECK_LIB([selinux], [is_selinux_enabled], [
+		AC_CHECK_HEADERS([selinux/selinux.h],, [AC_MSG_ERROR(bailing out)])
 		AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
 		SELINUX_LIBS="-lselinux $SELINUX_LIBS"
-	else
+		HAVE_SELINUX=yes ], [
 		AC_MSG_WARN(Disabling selinux)
-	fi
-	LIBS="$SELINUX_LIBS $LIBS"
-
-	# With --enable-static_link and selinux enabled, linking
-	# fails on at least Debian unstable due to unsatisfied references
-	# to pthread_mutex_lock and _unlock.  See if we need -lpthread.
-	if test "$STATIC_LINK-$HAVE_SELINUX" = yes-yes; then
-		lvm_saved_libs=$LIBS
-		LIBS="$LIBS -static"
-		AC_SEARCH_LIBS([pthread_mutex_lock], [pthread],
-		  [test "$ac_cv_search_pthread_mutex_lock" = "none required" ||
-				LIB_PTHREAD=-lpthread])
-		LIBS=$lvm_saved_libs
-	fi
+		HAVE_SELINUX=no ])
+
+	STATIC_LIBS="$STATIC_LIBS $SELINUX_LIBS"
 fi
 
 ################################################################################
@@ -995,10 +979,6 @@ if test x$INTL = xyes; then
 	AC_CHECK_HEADERS(libintl.h,,AC_MSG_ERROR(bailing out))
 fi
 
-if test x$HAVE_SELINUX = xyes; then
-	AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out))
-fi
-
 if test x$UDEV_SYNC = xyes; then
 	AC_CHECK_HEADERS(sys/ipc.h sys/sem.h,,AC_MSG_ERROR(bailing out))
 fi
@@ -1107,7 +1087,6 @@ AC_SUBST(GULM_CFLAGS)
 AC_SUBST(GULM_LIBS)
 AC_SUBST(HAVE_LIBDL)
 AC_SUBST(HAVE_REALTIME)
-AC_SUBST(HAVE_SELINUX)
 AC_SUBST(INTL)
 AC_SUBST(INTL_PACKAGE)
 AC_SUBST(JOBS)
daemons/dmeventd/Makefile.in +1 -1
index aacb6a4..6355eef 100644
@@ -66,7 +66,7 @@ dmeventd: $(LIB_SHARED) $(VERSIONED_SHLIB) dmeventd.o
 
 dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
-	dmeventd.o $(LVMLIBS) $(LIBS)
+	dmeventd.o $(LVMLIBS) @STATIC_LIBS@ $(LIBS)
 
 ifeq ("@PKGCONFIG@", "yes")
   INSTALL_LIB_TARGETS += install_pkgconfig
libdm/Makefile.in +2 -0
index 1884b21..cde7077 100644
@@ -52,6 +52,8 @@ include ../make.tmpl
 DEFS += -DDM_DEVICE_UID=@DM_DEVICE_UID@ -DDM_DEVICE_GID=@DM_DEVICE_GID@ \
 	-DDM_DEVICE_MODE=@DM_DEVICE_MODE@
 
+LIBS += @SELINUX_LIBS@
+
 device-mapper: all
 
 .PHONY: install_dynamic install_static install_include \
tools/Makefile.in +2 -2
index a8cb6aa..53bc105 100644
@@ -115,7 +115,7 @@ dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
 
 dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-	      -o $@ dmsetup.o -ldevmapper $(LIBS)
+	      -o $@ dmsetup.o -ldevmapper @STATIC_LIBS@ $(LIBS)
 
 all: device-mapper
 
@@ -125,7 +125,7 @@ lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
 
 lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a  $(interfacebuilddir)/libdevmapper.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
-	      $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS)
+	      $(OBJECTS) lvm-static.o $(LVMLIBS) @STATIC_LIBS@ $(LIBS)
 
 liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
 	cat $(top_builddir)/lib/liblvm-internal.a > $@
Signature · 1 line
1.7.0
#10 lore raw

PATCH 9/9 misc/configure.in modification

In reply to Zdenek Kabelac

This is generated file from autoreconf.
We no longer define HAVE_LIBREADLINE - we have not used it before anyway.

---
 lib/misc/configure.h.in |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
lib/misc/configure.h.in +0 -3
index 4273eeb..b0af63f 100644
@@ -120,9 +120,6 @@
 /* Define to 1 if you have the <libintl.h> header file. */
 #undef HAVE_LIBINTL_H
 
-/* Define to 1 if you have the `readline' library (-lreadline). */
-#undef HAVE_LIBREADLINE
-
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
Signature · 1 line
1.7.0
#11 lore raw

cover configure update

In reply to Zdenek Kabelac
Quoted 8 lines · Zdenek Kabelac

This patchset tries to mainly address linking problems. First few patches are rather cosmetic cleanups.

Interestings patches starts with: Readline linking update.

With this patchset libpthread and libselinux are linked only to object files which really needs this library. Tested it on Fedora & Debian distribution.

Overall, looks reasonably OK to me. Could certainly benefit from further testing though.

Yours,
Petr.