1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-29 15:22:30 +03:00

configure.ac: handle --disable-shared flag

Since LVM 2.02 it appears that compiling LVM on a platform which
lacks a shared library linker/loader will fail to produce any
binaries (dmsetup, lvm2, etc).

Adds support for the standard --disable-shared flag, and
use it to disable attempts at building shared libraries.

Modified-by: zkabelac
This commit is contained in:
Adam Joseph 2023-09-21 23:47:38 -07:00 committed by Zdenek Kabelac
parent fb124f0839
commit dc8837f079
6 changed files with 43 additions and 7 deletions

View File

@ -185,6 +185,14 @@ AC_ARG_ENABLE(static_link,
STATIC_LINK=$enableval, STATIC_LINK="no") STATIC_LINK=$enableval, STATIC_LINK="no")
AC_MSG_RESULT([$STATIC_LINK]) 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 dnl -- Check if compiler/linker supports PIE and RELRO
AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], []) AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], [])
@ -1218,7 +1226,10 @@ AC_ARG_ENABLE(cmdlib,
CMDLIB=$enableval, CMDLIB="no") CMDLIB=$enableval, CMDLIB="no")
AC_MSG_RESULT([$CMDLIB]) AC_MSG_RESULT([$CMDLIB])
AC_SUBST([LVM2CMD_LIB]) 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 dnl -- Enable D-Bus service
@ -1892,6 +1903,7 @@ AC_SUBST(SBINDIR)
AC_SUBST(SELINUX_LIBS) AC_SUBST(SELINUX_LIBS)
AC_SUBST(SELINUX_PC) AC_SUBST(SELINUX_PC)
AC_SUBST(SELINUX_STATIC_LIBS) AC_SUBST(SELINUX_STATIC_LIBS)
AC_SUBST(SHARED_LINK)
AC_SUBST(SILENT_RULES) AC_SUBST(SILENT_RULES)
AC_SUBST(SNAPSHOTS) AC_SUBST(SNAPSHOTS)
AC_SUBST(STATICDIR) AC_SUBST(STATICDIR)

View File

@ -47,7 +47,9 @@ endif
LIB_SHARED = $(interface)/libdevmapper.$(LIB_SUFFIX) LIB_SHARED = $(interface)/libdevmapper.$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_DM) LIB_VERSION = $(LIB_VERSION_DM)
ifeq ("@SHARED_LINK@", "yes")
TARGETS = libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION) .symver_check TARGETS = libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION) .symver_check
endif
CFLOW_LIST = $(SOURCES) CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = libdevmapper.cflow CFLOW_LIST_TARGET = libdevmapper.cflow
@ -103,7 +105,12 @@ install_dynamic: install_@interface@
install_static: install_@interface@_static install_static: install_@interface@_static
ifeq ("@SHARED_LINK@", "yes")
install_ioctl: install_lib_shared install_ioctl: install_lib_shared
endif
ifeq ("@STATIC_LINK@", "yes")
install_ioctl: install_ioctl_static
endif
install_pkgconfig: libdevmapper.pc install_pkgconfig: libdevmapper.pc
@echo " [INSTALL] $<" @echo " [INSTALL] $<"

View File

@ -19,13 +19,15 @@ top_builddir = @top_builddir@
all: device-mapper all: device-mapper
SOURCES2 = dmsetup.c SOURCES2 = dmsetup.c
TARGETS_DM = dmsetup
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES2)) CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES2))
CFLOW_TARGET := $(TARGETS_DM) CFLOW_TARGET := $(TARGETS_DM)
-include $(top_builddir)/libdm/libdevmapper.cflow -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") ifeq ("@STATIC_LINK@", "yes")
TARGETS_DM += dmsetup.static TARGETS_DM += dmsetup.static
@ -35,8 +37,11 @@ endif
# dmfilemapd support # dmfilemapd support
ifeq ("@BUILD_DMFILEMAPD@", "yes") ifeq ("@BUILD_DMFILEMAPD@", "yes")
SOURCES2 += dmfilemapd.c 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") ifeq ("@STATIC_LINK@", "yes")
TARGETS_DM += dmfilemapd.static TARGETS_DM += dmfilemapd.static

View File

@ -318,7 +318,12 @@ SUBDIRS.cflow := $(SUBDIRS:=.cflow)
SUBDIRS.clean := $(SUBDIRS:=.clean) SUBDIRS.clean := $(SUBDIRS:=.clean)
SUBDIRS.distclean := $(SUBDIRS:=.distclean) 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) all: $(SUBDIRS) $(TARGETS)

View File

@ -373,7 +373,12 @@ SUBDIRS.cflow := $(SUBDIRS:=.cflow)
SUBDIRS.clean := $(SUBDIRS:=.clean) SUBDIRS.clean := $(SUBDIRS:=.clean)
SUBDIRS.distclean := $(SUBDIRS:=.distclean) 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 = \ INTERNAL_LIBS = \
$(top_builddir)/libdaemon/client/libdaemonclient.a \ $(top_builddir)/libdaemon/client/libdaemonclient.a \

View File

@ -100,10 +100,12 @@ CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) $(TARGETS_DM) \
$(LDDEPS) .exported_symbols_generated cmds.h \ $(LDDEPS) .exported_symbols_generated cmds.h \
command-lines-input.h command-count.h man-generator.c command-lines-input.h command-count.h man-generator.c
ifeq ("@SHARED_LINK@", "yes")
ifeq ("@CMDLIB@", "yes") ifeq ("@CMDLIB@", "yes")
TARGETS += liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) TARGETS += liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION)
INSTALL_LVM_TARGETS += $(INSTALL_CMDLIB_TARGETS) INSTALL_LVM_TARGETS += $(INSTALL_CMDLIB_TARGETS)
endif endif
endif
EXPORTED_HEADER = $(srcdir)/lvm2cmd.h EXPORTED_HEADER = $(srcdir)/lvm2cmd.h
EXPORTED_FN_PREFIX = lvm2 EXPORTED_FN_PREFIX = lvm2