Unify DLSUFFIX on Darwin
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 6 Jul 2022 05:30:16 +0000 (07:30 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 6 Jul 2022 05:41:33 +0000 (07:41 +0200)
macOS has traditionally used extension .dylib for shared libraries
(used at build time) and .so for dynamically loaded modules (used by
dlopen()).  This complicates the build system a bit.  Also, Meson uses
.dylib for both, so it would be worth unifying this in order to be
able to get equal build output.

There doesn't appear to be any reason to use any particular extension
for dlopened modules, since dlopen() will accept anything and
PostgreSQL is well-factored to be able to deal with any extension.
Other software packages that I have handy appear to be about 50/50
split on which extension they use for their plugins.  So it seems
possible to change this safely.

Discussion: https://www.postgresql.org/message-id/flat/bcc45f78-e3c3-8fb3-7c42-5371b48b5266%40enterprisedb.com

config/python.m4
configure
src/Makefile.shlib
src/makefiles/Makefile.darwin
src/template/darwin

index e500873ff3ce4f777daf0901a5d4623744c21ef2..b295ad3d3a4515dee35a9df1b8add0e311c750cc 100644 (file)
@@ -120,16 +120,11 @@ else
    found_shlib=0
    for d in "${python_libdir}" "${python_configdir}" /usr/lib64 /usr/lib
    do
-       # Note: DLSUFFIX is for loadable modules, not shared
-       # libraries, so cannot be used here portably.  Just
-       # check all known possibilities.
-       for e in .so .dll .dylib .sl; do
-           if test -e "$d/lib${ldlibrary}$e"; then
-               python_libdir="$d"
-               found_shlib=1
-               break 2
-           fi
-       done
+       if test -e "$d/lib${ldlibrary}${DLSUFFIX}"; then
+           python_libdir="$d"
+           found_shlib=1
+           break 2
+       fi
    done
    # Some platforms (OpenBSD) require us to accept a bare versioned shlib
    # (".so.n.n") as well. However, check this only after failing to find
index fb07cd27d99bb765e7e9487ec572f30ce3b5e117..da177403ef2c6f17fe2c1289c58c2c6f59ae108b 100755 (executable)
--- a/configure
+++ b/configure
@@ -10570,16 +10570,11 @@ else
    found_shlib=0
    for d in "${python_libdir}" "${python_configdir}" /usr/lib64 /usr/lib
    do
-       # Note: DLSUFFIX is for loadable modules, not shared
-       # libraries, so cannot be used here portably.  Just
-       # check all known possibilities.
-       for e in .so .dll .dylib .sl; do
-           if test -e "$d/lib${ldlibrary}$e"; then
-               python_libdir="$d"
-               found_shlib=1
-               break 2
-           fi
-       done
+       if test -e "$d/lib${ldlibrary}${DLSUFFIX}"; then
+           python_libdir="$d"
+           found_shlib=1
+           break 2
+       fi
    done
    # Some platforms (OpenBSD) require us to accept a bare versioned shlib
    # (".so.n.n") as well. However, check this only after failing to find
index 551023c6fb0665034971fa08f9aa11266300ed46..d0ec325bf15ec7f9cde3088d7ff5160070ce2c18 100644 (file)
@@ -118,7 +118,6 @@ endif
 ifeq ($(PORTNAME), darwin)
   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
@@ -127,7 +126,6 @@ ifeq ($(PORTNAME), darwin)
     shlib_major        = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
   else
     # loadable module
-    DLSUFFIX       = .so
     LINK.shared        = $(COMPILER) -bundle -multiply_defined suppress
   endif
   BUILD.exports        = $(AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
index 4fc81c1584a6daa12473da89f2725a04c01d0976..45f253a5b4326839b5f693bd74eb692d30b4e8b7 100644 (file)
@@ -10,5 +10,5 @@ else
 endif
 
 # Rule for building a shared library from a single .o file
-%.so: %.o
+%$(DLSUFFIX): %.o
    $(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_SL) -bundle $(BE_DLLLIBS) -o $@
index e14d53b601acfca5fb62680a342cafd320391c25..fd30e19b6a787581ad1e89c3897c2af5c209800d 100644 (file)
@@ -55,3 +55,5 @@ case $host_os in
     USE_SYSV_SEMAPHORES=1
     ;;
 esac
+
+DLSUFFIX=".dylib"