Move interpreter shared library detection to configure
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 2 May 2015 01:38:21 +0000 (21:38 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 2 May 2015 01:38:21 +0000 (21:38 -0400)
For building PL/Perl, PL/Python, and PL/Tcl, we need a shared library of
libperl, libpython, and libtcl, respectively.  Previously, this was
checked in the makefiles, skipping the PL build with a warning if no
shared library was available.  Now this is checked in configure, with an
error if no shared library is available.

The previous situation arose because in the olden days, the configure
options --with-perl, --with-python, and --with-tcl controlled whether
frontend interfaces for those languages would be built.  The procedural
languages were added later, and shared libraries were often not
available in the beginning.  So it was decided skip the builds of the
procedural languages in those cases.  The frontend interfaces have since
been removed from the tree, and shared libraries are now available most
of the time, so that setup makes much less sense now.

Also, the new setup allows contrib modules and pgxs users to rely on the
respective PLs being available based on configure flags.

config/python.m4
configure
configure.in
src/Makefile.global.in
src/pl/plperl/GNUmakefile
src/pl/plpython/Makefile
src/pl/tcl/Makefile

index 7012c536d796eede25f1189e5bf701812c6f1978..c8f784ed47dc360bac02c16a34b751f8e5126bed 100644 (file)
@@ -93,7 +93,6 @@ AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
 AC_SUBST(python_libdir)[]dnl
 AC_SUBST(python_libspec)[]dnl
 AC_SUBST(python_additional_libs)[]dnl
-AC_SUBST(python_enable_shared)[]dnl
 
 # threaded python is not supported on OpenBSD
 AC_MSG_CHECKING(whether Python is compiled with thread support)
index 7c0bd0c696ffa7b7e1f2df1aa50845088ac23c62..98f6516c9a8f3b22b7733558e72ef559bee6dc29 100755 (executable)
--- a/configure
+++ b/configure
@@ -641,7 +641,6 @@ TCL_SHLIB_LD_LIBS
 TCL_SHARED_BUILD
 TCL_LIB_SPEC
 TCL_LIBS
-TCL_LIB_FILE
 TCL_INCLUDE_SPEC
 TCL_CONFIG_SH
 TCLSH
@@ -662,7 +661,6 @@ HAVE_IPV6
 LIBOBJS
 UUID_LIBS
 ZIC
-python_enable_shared
 python_additional_libs
 python_libspec
 python_libdir
@@ -7384,6 +7382,12 @@ perl_useshrplib=`$PERL -MConfig -e 'print $Config{useshrplib}'`
 test "$PORTNAME" = "win32" && perl_useshrplib=`echo $perl_useshrplib | sed 's,\\\\,/,g'`
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $perl_useshrplib" >&5
 $as_echo "$perl_useshrplib" >&6; }
+  if test "$perl_useshrplib" != yes && test "$perl_useshrplib" != true; then
+    as_fn_error $? "cannot build PL/Perl because libperl is not a shared library
+You might have to rebuild your Perl installation.  Refer to the
+documentation for details.  Use --without-perl to disable building
+PL/Perl." "$LINENO" 5
+  fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl" >&5
 $as_echo_n "checking for flags to link embedded Perl... " >&6; }
@@ -7537,6 +7541,32 @@ $as_echo "no" >&6; }
 fi
 
 
+
+  # We need libpython as a shared library.  With Python >=2.5, we check
+  # the Py_ENABLE_SHARED setting.  OS X does supply a .dylib even
+  # though Py_ENABLE_SHARED does not get set.  On Debian, the setting
+  # is not correct before the jessie release
+  # (http://bugs.debian.org/695979).  We also want to support older
+  # Python versions.  So as a fallback we see if there is a file that
+  # is named like a shared library.
+
+  if test "$python_enable_shared" != 1; then
+    # We don't know the platform shared library extension here yet, so
+    # we try some candidates.
+    for dlsuffix in .so .dll .dylib .sl; do
+      if ls "$python_libdir"/libpython*${dlsuffix}* >/dev/null 2>&1; then
+        python_enable_shared=1
+        break
+      fi
+    done
+  fi
+
+  if test "$python_enable_shared" != 1; then
+    as_fn_error $? "cannot build PL/Python because libpython is not a shared library
+You might have to rebuild your Python installation.  Refer to the
+documentation for details.  Use --without-python to disable building
+PL/Python." "$LINENO" 5
+  fi
 fi
 
 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
 
     . "$TCL_CONFIG_SH"
 eval TCL_INCLUDE_SPEC=\"$TCL_INCLUDE_SPEC\"
-eval TCL_LIB_FILE=\"$TCL_LIB_FILE\"
 eval TCL_LIBS=\"$TCL_LIBS\"
 eval TCL_LIB_SPEC=\"$TCL_LIB_SPEC\"
 eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\"
 
-        # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
+        if test "$TCL_SHARED_BUILD" != 1; then
+      as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library
+Use --without-tcl to disable building PL/Tcl." "$LINENO" 5
+    fi
+    # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
     ac_save_CPPFLAGS=$CPPFLAGS
     CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
     ac_fn_c_check_header_mongrel "$LINENO" "tcl.h" "ac_cv_header_tcl_h" "$ac_includes_default"
index 1cd9e1eb46fea48a091bda9e50f50b7d47e5a094..0080515c0c622e60a7e9828969f70ecda08b7657 100644 (file)
@@ -889,12 +889,44 @@ if test "$with_perl" = yes; then
     AC_MSG_ERROR([Perl not found])
   fi
   PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
+  if test "$perl_useshrplib" != yes && test "$perl_useshrplib" != true; then
+    AC_MSG_ERROR([cannot build PL/Perl because libperl is not a shared library
+You might have to rebuild your Perl installation.  Refer to the
+documentation for details.  Use --without-perl to disable building
+PL/Perl.])
+  fi
   PGAC_CHECK_PERL_EMBED_LDFLAGS
 fi
 
 if test "$with_python" = yes; then
   PGAC_PATH_PYTHON
   PGAC_CHECK_PYTHON_EMBED_SETUP
+
+  # We need libpython as a shared library.  With Python >=2.5, we check
+  # the Py_ENABLE_SHARED setting.  OS X does supply a .dylib even
+  # though Py_ENABLE_SHARED does not get set.  On Debian, the setting
+  # is not correct before the jessie release
+  # (http://bugs.debian.org/695979).  We also want to support older
+  # Python versions.  So as a fallback we see if there is a file that
+  # is named like a shared library.
+
+  if test "$python_enable_shared" != 1; then
+    # We don't know the platform shared library extension here yet, so
+    # we try some candidates.
+    for dlsuffix in .so .dll .dylib .sl; do
+      if ls "$python_libdir"/libpython*${dlsuffix}* >/dev/null 2>&1; then
+        python_enable_shared=1
+        break
+      fi
+    done
+  fi
+
+  if test "$python_enable_shared" != 1; then
+    AC_MSG_ERROR([cannot build PL/Python because libpython is not a shared library
+You might have to rebuild your Python installation.  Refer to the
+documentation for details.  Use --without-python to disable building
+PL/Python.])
+  fi
 fi
 
 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
@@ -1942,8 +1974,12 @@ fi
 if test "$with_tcl" = yes; then
     PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
     PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
-                          [TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
+                          [TCL_INCLUDE_SPEC,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
     AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
+    if test "$TCL_SHARED_BUILD" != 1; then
+      AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
+Use --without-tcl to disable building PL/Tcl.])
+    fi
     # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
     ac_save_CPPFLAGS=$CPPFLAGS
     CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
index a0fe8e43eb967e8e075a9eedb865dad35baada95..f8b7b3541d3ae50e478dc1ef48ed332c8a2da731 100644 (file)
@@ -181,7 +181,6 @@ enable_coverage = @enable_coverage@
 enable_tap_tests   = @enable_tap_tests@
 enable_thread_safety   = @enable_thread_safety@
 
-python_enable_shared   = @python_enable_shared@
 python_includespec = @python_includespec@
 python_libdir      = @python_libdir@
 python_libspec     = @python_libspec@
@@ -192,7 +191,6 @@ python_version      = @python_version@
 krb_srvtab = @krb_srvtab@
 
 TCLSH          = @TCLSH@
-TCL_LIB_FILE       = @TCL_LIB_FILE@
 TCL_LIBS       = @TCL_LIBS@
 TCL_LIB_SPEC       = @TCL_LIB_SPEC@
 TCL_INCLUDE_SPEC   = @TCL_INCLUDE_SPEC@
@@ -283,7 +281,6 @@ else
 endif
 perl_archlibexp        = @perl_archlibexp@
 perl_privlibexp        = @perl_privlibexp@
-perl_useshrplib        = @perl_useshrplib@
 perl_embed_ldflags = @perl_embed_ldflags@
 
 # Miscellaneous
index 904a320cf6af33cbacd74725ae3633a03e6a77fb..6e1377b53de9ce1bf412efa0f2e90cd8f246ac54 100644 (file)
@@ -5,16 +5,6 @@ subdir = src/pl/plperl
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-ifeq ($(perl_useshrplib),true)
-shared_libperl = yes
-endif
-ifeq ($(perl_useshrplib),yes)
-shared_libperl = yes
-endif
-
-# If we don't have a shared library, we have to skip it.
-ifeq ($(shared_libperl),yes)
-
 ifeq ($(PORTNAME), win32)
 override CPPFLAGS += -DPLPERL_HAVE_UID_GID
 # Perl on win32 contains /* within comment all over the header file,
@@ -130,14 +120,3 @@ clean distclean maintainer-clean: clean-lib
 ifeq ($(PORTNAME), win32)
    rm -f $(perlwithver).def
 endif
-
-else # can't build
-
-all:
-   @echo ""; \
-    echo "*** Cannot build PL/Perl because libperl is not a shared library."; \
-    echo "*** You might have to rebuild your Perl installation.  Refer to"; \
-    echo "*** the documentation for details."; \
-    echo ""
-
-endif # can't build
index de97cbb780bc5c8acc4de5cb904e604a48e0a970..8b1d8908e68ab3e1aa79fe3b5f07928596aea9fb 100644 (file)
@@ -5,24 +5,6 @@ top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
 
-# We need libpython as a shared library.  In Python >=2.5, configure
-# asks Python directly.  But because this has been broken in Debian
-# for a long time (http://bugs.debian.org/695979), and to support
-# older Python versions, we see if there is a file that is named like
-# a shared library as a fallback.
-ifeq (1,$(python_enable_shared))
-shared_libpython = yes
-else
-ifeq ($(PORTNAME), darwin)
-# OS X does supply a .dylib even though Py_ENABLE_SHARED does not get set
-shared_libpython = yes
-else
-ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
-shared_libpython = yes
-endif
-endif
-endif
-
 # Windows needs to convert backslashed paths to normal slashes,
 # and we have to remove -lpython from the link since we are building our own
 ifeq ($(PORTNAME), win32)
@@ -31,8 +13,6 @@ python_includespec := $(subst \,/,$(python_includespec))
 override python_libspec =
 endif
 
-# If we don't have a shared library, we have to skip it.
-ifeq ($(shared_libpython),yes)
 
 override CPPFLAGS := -I. -I$(srcdir) $(python_includespec) $(CPPFLAGS)
 
@@ -159,18 +139,6 @@ ifeq ($(PORTNAME), win32)
    rm -f python${pytverstr}.def
 endif
 
-else # can't build
-
-all:
-   @echo ""; \
-    echo "*** Cannot build PL/Python because libpython is not a shared library." ; \
-    echo "*** You might have to rebuild your Python installation.  Refer to"; \
-    echo "*** the documentation for details."; \
-    echo ""
-
-endif # can't build
-
-# distprep and maintainer-clean rules should be run even if we can't build.
 
 # Force this dependency to be known even without dependency info built:
 plpy_plpymodule.o: spiexceptions.h
index 533d3b4efd06d20d9a08f3692197357efb9f511c..24803de79082bf1363dd8691a558329db2c7ca9d 100644 (file)
@@ -14,21 +14,6 @@ include $(top_builddir)/src/Makefile.global
 override CPPFLAGS := $(TCL_INCLUDE_SPEC) $(CPPFLAGS)
 
 
-# Find out whether Tcl was built as a shared library --- if not, we
-# can't link a shared library that depends on it, and have to forget
-# about building pltcl. In Tcl 8, tclConfig.sh sets TCL_SHARED_BUILD
-# for us, but in older Tcl releases it doesn't. In that case we guess
-# based on the name of the Tcl library.
-
-ifndef TCL_SHARED_BUILD
-ifneq (,$(findstring $(DLSUFFIX),$(TCL_LIB_FILE)))
-TCL_SHARED_BUILD=1
-else
-TCL_SHARED_BUILD=0
-endif
-endif
-
-
 # On Windows, we don't link directly with the Tcl library; see below
 ifneq ($(PORTNAME), win32)
 SHLIB_LINK = $(TCL_LIB_SPEC) $(TCL_LIBS) -lc
@@ -67,7 +52,6 @@ endif # win32
 
 include $(top_srcdir)/src/Makefile.shlib
 
-ifeq ($(TCL_SHARED_BUILD), 1)
 
 all: all-lib
    $(MAKE) -C modules $@
@@ -102,16 +86,6 @@ installcheck: submake
 submake:
    $(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-else # TCL_SHARED_BUILD = 0
-
-# Provide dummy targets for the case where we can't build the shared library.
-all:
-   @echo "*****"; \
-    echo "* Cannot build PL/Tcl because Tcl is not a shared library; skipping it."; \
-    echo "*****"
-
-endif # TCL_SHARED_BUILD = 0
-
 clean distclean maintainer-clean: clean-lib
    rm -f $(OBJS)
    rm -rf $(pg_regress_clean_files)