1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Pthread linking change

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
This commit is contained in:
Zdenek Kabelac 2010-03-04 11:21:05 +00:00
parent 539f4a7728
commit f30875dbc6
11 changed files with 100 additions and 15 deletions

View File

@ -1,5 +1,9 @@
Version 2.02.62 - Version 2.02.62 -
==================================== ====================================
Update check for pthread library and link it only when needed.
Define and use internal makefile variable PTHREAD_LIBS.
Update check for readline library and link it only when needed.
Define and use internal makefile variable READLINE_LIBS.
Define and use internal makefile variable LVMINTERNAL_LIBS. Define and use internal makefile variable LVMINTERNAL_LIBS.
Help for configure prints --disable-fsadm. Help for configure prints --disable-fsadm.
Use consistently $() instead of ${} for all Makefile variables. Use consistently $() instead of ${} for all Makefile variables.

77
configure vendored
View File

@ -646,7 +646,6 @@ kernelvsn
missingkernel missingkernel
kerneldir kerneldir
interface interface
LIB_PTHREAD
UDEV_SYNC UDEV_SYNC
UDEV_RULES UDEV_RULES
STATIC_LINK STATIC_LINK
@ -654,6 +653,7 @@ STATICDIR
SNAPSHOTS SNAPSHOTS
SELINUX_LIBS SELINUX_LIBS
READLINE_LIBS READLINE_LIBS
PTHREAD_LIBS
POOL POOL
PKGCONFIG PKGCONFIG
OWNER OWNER
@ -12710,6 +12710,81 @@ $as_echo "$as_me: error: Features cannot be 'shared' when building statically
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
################################################################################
if [ "$DMEVENTD" = yes -o "$CLVMD" != none ] ; then
{ $as_echo "$as_me:$LINENO: checking for pthread_mutex_lock in -lpthread" >&5
$as_echo_n "checking for pthread_mutex_lock in -lpthread... " >&6; }
if test "${ac_cv_lib_pthread_pthread_mutex_lock+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pthread_mutex_lock ();
int
main ()
{
return pthread_mutex_lock ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_lib_pthread_pthread_mutex_lock=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_pthread_pthread_mutex_lock=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_lock" >&5
$as_echo "$ac_cv_lib_pthread_pthread_mutex_lock" >&6; }
if test "x$ac_cv_lib_pthread_pthread_mutex_lock" = x""yes; then
PTHREAD_LIBS="-lpthread"
else
hard_bailout
fi
fi
################################################################################ ################################################################################
{ $as_echo "$as_me:$LINENO: checking whether to enable selinux support" >&5 { $as_echo "$as_me:$LINENO: checking whether to enable selinux support" >&5
$as_echo_n "checking whether to enable selinux support... " >&6; } $as_echo_n "checking whether to enable selinux support... " >&6; }

View File

@ -808,6 +808,12 @@ Features cannot be 'shared' when building statically
) )
fi fi
################################################################################
if [[ "$DMEVENTD" = yes -o "$CLVMD" != none ]] ; then
AC_CHECK_LIB([pthread], [pthread_mutex_lock],
[PTHREAD_LIBS="-lpthread"], hard_bailout)
fi
################################################################################ ################################################################################
dnl -- Disable selinux dnl -- Disable selinux
AC_MSG_CHECKING(whether to enable selinux support) AC_MSG_CHECKING(whether to enable selinux support)
@ -1125,6 +1131,7 @@ AC_SUBST(MSGFMT)
AC_SUBST(OWNER) AC_SUBST(OWNER)
AC_SUBST(PKGCONFIG) AC_SUBST(PKGCONFIG)
AC_SUBST(POOL) AC_SUBST(POOL)
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(QUORUM_CFLAGS) AC_SUBST(QUORUM_CFLAGS)
AC_SUBST(QUORUM_LIBS) AC_SUBST(QUORUM_LIBS)
AC_SUBST(READLINE_LIBS) AC_SUBST(READLINE_LIBS)
@ -1138,7 +1145,6 @@ AC_SUBST(STATICDIR)
AC_SUBST(STATIC_LINK) AC_SUBST(STATIC_LINK)
AC_SUBST(UDEV_RULES) AC_SUBST(UDEV_RULES)
AC_SUBST(UDEV_SYNC) AC_SUBST(UDEV_SYNC)
AC_SUBST([LIB_PTHREAD])
AC_SUBST(interface) AC_SUBST(interface)
AC_SUBST(kerneldir) AC_SUBST(kerneldir)
AC_SUBST(missingkernel) AC_SUBST(missingkernel)

View File

@ -75,13 +75,14 @@ endif
TARGETS = \ TARGETS = \
clvmd clvmd
LVMLIBS = $(LVMINTERNAL_LIBS) -lpthread LVMLIBS = $(LVMINTERNAL_LIBS)
ifeq ("@DMEVENTD@", "yes") ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event LVMLIBS += -ldevmapper-event
endif endif
LVMLIBS += -ldevmapper LVMLIBS += -ldevmapper
LIBS += $(PTHREAD_LIBS)
DEFS += -D_REENTRANT DEFS += -D_REENTRANT
CFLAGS += -fno-strict-aliasing CFLAGS += -fno-strict-aliasing

View File

@ -54,7 +54,7 @@ all: device-mapper
device-mapper: $(TARGETS) device-mapper: $(TARGETS)
LIBS += -ldl LIBS += -ldl
LVMLIBS += -ldevmapper-event -lpthread -ldevmapper LVMLIBS += -ldevmapper-event -ldevmapper $(PTHREAD_LIBS)
$(VERSIONED_SHLIB): $(LIB_SHARED) $(VERSIONED_SHLIB): $(LIB_SHARED)
$(RM) -f $@ $(RM) -f $@

View File

@ -29,7 +29,7 @@ LIB_VERSION = $(LIB_VERSION_LVM)
include $(top_builddir)/make.tmpl 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_lvm2: libdevmapper-event-lvm2.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \

View File

@ -32,7 +32,7 @@ LIB_VERSION = $(LIB_VERSION_LVM)
include $(top_builddir)/make.tmpl 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_lvm2: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \

View File

@ -32,7 +32,7 @@ LIB_VERSION = $(LIB_VERSION_LVM)
include $(top_builddir)/make.tmpl 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_lvm2: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \

View File

@ -37,6 +37,7 @@ LDDEPS += @LDDEPS@
LDFLAGS += @LDFLAGS@ LDFLAGS += @LDFLAGS@
LIB_SUFFIX = @LIB_SUFFIX@ LIB_SUFFIX = @LIB_SUFFIX@
LVMINTERNAL_LIBS = -llvm-internal LVMINTERNAL_LIBS = -llvm-internal
PTHREAD_LIBS = @PTHREAD_LIBS@
READLINE_LIBS = @READLINE_LIBS@ READLINE_LIBS = @READLINE_LIBS@
# Setup directory variables # Setup directory variables

View File

@ -35,7 +35,7 @@ include $(top_builddir)/make.tmpl
LDFLAGS = -L$(top_builddir)/libdm -L$(top_builddir)/liblvm LDFLAGS = -L$(top_builddir)/libdm -L$(top_builddir)/liblvm
ifeq ("@DMEVENTD@", "yes") ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event -lpthread LVMLIBS += -ldevmapper-event
LDFLAGS += -L$(top_builddir)/daemons/dmeventd LDFLAGS += -L$(top_builddir)/daemons/dmeventd
endif endif

View File

@ -17,8 +17,6 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
VPATH = @srcdir@ VPATH = @srcdir@
LIB_PTHREAD = @LIB_PTHREAD@
SOURCES =\ SOURCES =\
dumpconfig.c \ dumpconfig.c \
formats.c \ formats.c \
@ -100,7 +98,7 @@ ifeq ("@CMDLIB@", "yes")
endif endif
ifeq ("@DMEVENTD@", "yes") ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event -lpthread LVMLIBS += -ldevmapper-event
endif endif
LVMLIBS += -ldevmapper LVMLIBS += -ldevmapper
@ -113,21 +111,21 @@ device-mapper: $(TARGETS_DM)
dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX) dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
$(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/libdm \ $(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 dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \ $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-o $@ dmsetup.o -ldevmapper $(LIBS) $(LIB_PTHREAD) -o $@ dmsetup.o -ldevmapper $(LIBS)
all: device-mapper all: device-mapper
lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) lvm.o \ $(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 lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a $(interfacebuilddir)/libdevmapper.a
$(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \ $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
$(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS) $(LIB_PTHREAD) \ $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS) \
-rdynamic -rdynamic
liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o