The attached patch implements a few changes to how shared libraries and
dynamically loadable modules are built. Foremost, it creates a solid
distinction between these two types of targets based on what had already been
implemented and duplicated in ad hoc ways before. Specifically,
- Dynamically loadable modules no longer get a soname. The numbers previously
set in the makefiles were dummy numbers anyway, and the presence of a soname
upset a few packaging tools, so it is nicer not to have one.
- The cumbersome detour taken on installation (build a libfoo.so.0.0.0 and
then override the rule to install foo.so instead) is removed.
- Lots of duplicated code simplified.
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index ba488d5..75b2494 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -19,13 +19,18 @@
# variables:
#
# NAME Name of library to build (no suffix nor lib prefix)
-# SO_MAJOR_VERSION Major version number to use for shared library
-# SO_MINOR_VERSION Minor version number to use for shared library
# OBJS List of object files to include in library
# SHLIB_LINKIf shared library relies on other libraries,
# additional stuff to put in its link command
# SHLIB_EXPORTS (optional) Name of file containing list of symbols to
# export
+#
+# When building a shared library, the following version information
+# must also be set. It should be omitted when building a dynamically
+# loadable module.
+#
+# SO_MAJOR_VERSION Major version number to use for shared library
+# SO_MINOR_VERSION Minor version number to use for shared library
# (If you want a patchlevel, include it in SO_MINOR_VERSION, e.g., 6.2.)
#
# Optional flags when building DLL's (only applicable to win32 and cygwin
@@ -42,6 +47,7 @@
#
# all-lib build the static and shared (if applicable) libraries
# install-lib install the libraries into $(libdir)
+# installdirs-lib create installation directory $(libdir)
# uninstall-lib remove the libraries from $(libdir)
# clean-lib delete the static and shared libraries from the build dir
# maintainer-clean-lib delete .def files built for win32
@@ -72,18 +78,34 @@ LINK.static = $(AR) $(AROPT)
-ifeq ($(enable_shared), yes)
-
# Insert -L from LDFLAGS after any -L already present in SHLIB_LINK
SHLIB_LINK := $(filter -L%, $(SHLIB_LINK)) $(filter -L%, $(LDFLAGS)) $(filter-out -L%, $(SHLIB_LINK))
# Need a -L-free version of LDFLAGS to use in combination with SHLIB_LINK
LDFLAGS_NO_L = $(filter-out -L%, $(LDFLAGS))
-# Default shlib naming convention used by the majority of platforms
+ifdef SO_MAJOR_VERSION
+# Default library naming convention used by the majority of platforms
+ifeq ($(enable_shared), yes)
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
shlib_major = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
shlib_bare = lib$(NAME)$(DLSUFFIX)
+endif
+# Testing the soname variable is a reliable way to determine whether a
+# linkable library is being built.
+soname = $(shlib_major)
+stlib = lib$(NAME).a
+else
+# Naming convention for dynamically loadable modules
+ifeq ($(enable_shared), yes)
+shlib = $(NAME)$(DLSUFFIX)
+endif
+endif
+
+ifndef soname
+# additional flags for backend modules
+SHLIB_LINK := $(BE_DLLLIBS) $(SHLIB_LINK)
+endif
# For each platform we support shared libraries on, set shlib to the
# name of the library (if default above is not right), set
@@ -94,29 +116,29 @@ shlib_bare = lib$(NAME)$(DLSUFFIX)
override CFLAGS += $(CFLAGS_SL)
-soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
-
ifeq ($(PORTNAME), aix)
- shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ ifdef SO_MAJOR_VERSION
+shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ endif
haslibarule = yes
exports_file = lib$(NAME).exp
endif
ifeq ($(PORTNAME), darwin)
- ifneq ($(SO_MAJOR_VERSION), 0)
-version_link = -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
- endif
- ifeq ($(DLTYPE), library)
+ ifdef soname
# linkable library
DLSUFFIX = .dylib
+ifneq ($(SO_MAJOR_VERSION), 0)
+ version_link = -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+endif
LINK.shared = $(COMPILER) -dynamiclib -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) $(exported_symbols_list) -multiply_defined suppress
+shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
+shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
else
-# loadable module (default case)
+# loadable module
DLSUFFIX = .so
LINK.shared = $(COMPILER) -bundle -multiply_defined suppress
endif
- shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
- shlib_major =