From 42ae4f2940393e224819a244d83b632f1fa84ae6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Mon, 27 Aug 2001 00:29:49 +0000
Subject: [PATCH] Turn on plpython build by default if we have something that
 looks like a shared library, or we can do without one.

---
 src/Makefile.global.in   |  3 ++-
 src/pl/Makefile          |  9 ++++-----
 src/pl/plpython/Makefile | 24 +++++++++++++++++++++++-
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index c011469d568..8055b4f0cf2 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
 # -*-makefile-*-
-# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.133 2001/08/26 22:28:04 petere Exp $
+# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.134 2001/08/27 00:29:49 petere Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
@@ -128,6 +128,7 @@ python_includespec	= @python_includespec@
 python_moduledir	= @python_moduledir@
 python_moduleexecdir	= @python_moduleexecdir@
 python_libspec		= @python_libspec@
+python_configdir	= @python_configdir@
 
 krb_srvtab = @krb_srvtab@
 
diff --git a/src/pl/Makefile b/src/pl/Makefile
index 64882e99bc9..094221a8dcd 100644
--- a/src/pl/Makefile
+++ b/src/pl/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/pl/Makefile,v 1.20 2001/05/12 01:30:30 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/Makefile,v 1.21 2001/08/27 00:29:49 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -22,10 +22,9 @@ ifeq ($(with_perl), yes)
 DIRS += plperl
 endif
 
-# Doesn't build portably yet.
-#ifeq ($(with_python), yes)
-#DIRS += plpython
-#endif
+ifeq ($(with_python), yes)
+DIRS += plpython
+endif
 
 all install installdirs uninstall depend distprep:
 	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index b22dcf80e7e..782d07ee3f5 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -1,10 +1,21 @@
-# $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.8 2001/07/10 16:33:02 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.9 2001/08/27 00:29:49 petere Exp $
 
 subdir = src/pl/plpython
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
 
+# On some platforms we can only build PL/Python if libpython is a
+# shared library.  Since there is no official way to determine this,
+# we see if there is a file that is named like a shared library.
+ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
+shared_libpython = yes
+endif
+
+# If we don't have a shared library and the platform doesn't allow it
+# to work without, we have to skip it.
+ifneq (,$(findstring yes, $(shared_libpython)$(allow_nonpic_in_shlib)))
+
 override CPPFLAGS := -I$(srcdir) $(python_includespec) $(CPPFLAGS)
 
 override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS)
@@ -36,3 +47,14 @@ clean distclean maintainer-clean: clean-lib
 
 installcheck:
 	PATH=$(bindir):$$PATH $(SHELL) $(srcdir)/test.sh
+
+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
-- 
GitLab