diff --git a/configure.ac b/configure.ac index 3a59b6c25..2ad693ce6 100644 --- a/configure.ac +++ b/configure.ac @@ -185,6 +185,14 @@ AC_ARG_ENABLE(static_link, STATIC_LINK=$enableval, STATIC_LINK="no") AC_MSG_RESULT([$STATIC_LINK]) +################################################################################ +dnl -- Disables shared linking +AC_MSG_CHECKING([whether to use dynamic linking]) +AC_ARG_ENABLE(shared, + AS_HELP_STRING([--disable-shared], [disable dynamic linking]), + SHARED_LINK=$enableval, SHARED_LINK="yes") +AC_MSG_RESULT([$SHARED_LINK]) + ################################################################################ dnl -- Check if compiler/linker supports PIE and RELRO AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], []) @@ -1218,7 +1226,10 @@ AC_ARG_ENABLE(cmdlib, CMDLIB=$enableval, CMDLIB="no") AC_MSG_RESULT([$CMDLIB]) AC_SUBST([LVM2CMD_LIB]) -AS_IF([test "$CMDLIB" = "yes"], [LVM2CMD_LIB="-llvm2cmd"], [LVM2CMD_LIB=]) +AS_IF([test "$CMDLIB" = "yes"], + [AS_IF([test "$SHARED_LINK" = "no"], + [AC_MSG_ERROR([--enable-cmdlib requires dynamic linking.])]) + LVM2CMD_LIB="-llvm2cmd"], [LVM2CMD_LIB=]) ################################################################################ dnl -- Enable D-Bus service @@ -1892,6 +1903,7 @@ AC_SUBST(SBINDIR) AC_SUBST(SELINUX_LIBS) AC_SUBST(SELINUX_PC) AC_SUBST(SELINUX_STATIC_LIBS) +AC_SUBST(SHARED_LINK) AC_SUBST(SILENT_RULES) AC_SUBST(SNAPSHOTS) AC_SUBST(STATICDIR) diff --git a/libdm/Makefile.in b/libdm/Makefile.in index 2758648e6..8bf1eacfc 100644 --- a/libdm/Makefile.in +++ b/libdm/Makefile.in @@ -47,7 +47,9 @@ endif LIB_SHARED = $(interface)/libdevmapper.$(LIB_SUFFIX) LIB_VERSION = $(LIB_VERSION_DM) +ifeq ("@SHARED_LINK@", "yes") TARGETS = libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION) .symver_check +endif CFLOW_LIST = $(SOURCES) CFLOW_LIST_TARGET = libdevmapper.cflow @@ -103,7 +105,12 @@ install_dynamic: install_@interface@ install_static: install_@interface@_static +ifeq ("@SHARED_LINK@", "yes") install_ioctl: install_lib_shared +endif +ifeq ("@STATIC_LINK@", "yes") +install_ioctl: install_ioctl_static +endif install_pkgconfig: libdevmapper.pc @echo " [INSTALL] $<" diff --git a/libdm/dm-tools/Makefile.in b/libdm/dm-tools/Makefile.in index 78d2d719d..2f4514bd5 100644 --- a/libdm/dm-tools/Makefile.in +++ b/libdm/dm-tools/Makefile.in @@ -19,13 +19,15 @@ top_builddir = @top_builddir@ all: device-mapper SOURCES2 = dmsetup.c -TARGETS_DM = dmsetup CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES2)) CFLOW_TARGET := $(TARGETS_DM) -include $(top_builddir)/libdm/libdevmapper.cflow -install_device-mapper: install_dmsetup_dynamic +ifeq ("@SHARED_LINK@", "yes") + TARGETS_DM += dmsetup + install_device-mapper: install_dmsetup_dynamic +endif ifeq ("@STATIC_LINK@", "yes") TARGETS_DM += dmsetup.static @@ -35,8 +37,11 @@ endif # dmfilemapd support ifeq ("@BUILD_DMFILEMAPD@", "yes") SOURCES2 += dmfilemapd.c - TARGETS_DM += dmfilemapd - install_dmfilemapd: install_dmfilemapd_dynamic + + ifeq ("@SHARED_LINK@", "yes") + TARGETS_DM += dmfilemapd + install_dmfilemapd: install_dmfilemapd_dynamic + endif ifeq ("@STATIC_LINK@", "yes") TARGETS_DM += dmfilemapd.static diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in index cc28e73cb..1b68ea26b 100644 --- a/libdm/make.tmpl.in +++ b/libdm/make.tmpl.in @@ -318,7 +318,12 @@ SUBDIRS.cflow := $(SUBDIRS:=.cflow) SUBDIRS.clean := $(SUBDIRS:=.clean) SUBDIRS.distclean := $(SUBDIRS:=.distclean) -TARGETS += $(LIB_SHARED) $(LIB_STATIC) +ifeq ("@SHARED_LINK@", "yes") + TARGETS += $(LIB_SHARED) +endif +ifeq ("@STATIC_LINK@", "yes") + TARGETS += $(LIB_STATIC) +endif all: $(SUBDIRS) $(TARGETS) diff --git a/make.tmpl.in b/make.tmpl.in index 52903000d..459bc4624 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -373,7 +373,12 @@ SUBDIRS.cflow := $(SUBDIRS:=.cflow) SUBDIRS.clean := $(SUBDIRS:=.clean) SUBDIRS.distclean := $(SUBDIRS:=.distclean) -TARGETS += $(LIB_SHARED) $(LIB_STATIC) +ifeq ("@SHARED_LINK@", "yes") + TARGETS += $(LIB_SHARED) +endif +ifeq ("@STATIC_LINK@", "yes") + TARGETS += $(LIB_STATIC) +endif INTERNAL_LIBS = \ $(top_builddir)/libdaemon/client/libdaemonclient.a \ diff --git a/tools/Makefile.in b/tools/Makefile.in index 545b94f23..4b1bba984 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -100,10 +100,12 @@ CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) $(TARGETS_DM) \ $(LDDEPS) .exported_symbols_generated cmds.h \ command-lines-input.h command-count.h man-generator.c +ifeq ("@SHARED_LINK@", "yes") ifeq ("@CMDLIB@", "yes") TARGETS += liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) INSTALL_LVM_TARGETS += $(INSTALL_CMDLIB_TARGETS) endif +endif EXPORTED_HEADER = $(srcdir)/lvm2cmd.h EXPORTED_FN_PREFIX = lvm2