Polish shared library build to reduce number of special hacks. In

particular, allow linking with arbitrary commands rather than only $(AR) or
$(LD), and treat C++ without hacks.

Add option to disable shared libraries.  This takes the place of the
BSD_SHLIB variable.  The regression test driver ignores the plpgsql test
if there are no shared libraries available.
This commit is contained in:
Peter Eisentraut 2000-10-23 21:44:12 +00:00
parent bc083d3d90
commit 7b021ce17c
10 changed files with 513 additions and 499 deletions

751
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -227,6 +227,14 @@ AC_DEFINE_UNQUOTED([DEF_MAXBACKENDS], [$with_maxbackends],
[The default soft limit on the number of concurrent connections, i.e., the default for the postmaster -N switch (--with-maxbackends)])
#
# Option to disable shared libraries
#
PGAC_ARG_BOOL(enable, shared, yes,
[ --disable-shared do not build shared libraries])
AC_SUBST(enable_shared)
#
# C compiler
#

View File

@ -1,5 +1,5 @@
# -*-makefile-*-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.103 2000/10/21 22:36:11 petere Exp $
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.104 2000/10/23 21:43:56 petere Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
@ -114,6 +114,7 @@ with_tcl = @with_tcl@
with_tk = @with_tk@
enable_odbc = @enable_odbc@
MULTIBYTE = @MULTIBYTE@
enable_shared = @enable_shared@
python_extmakefile = @python_extmakefile@
python_moduledir = @python_moduledir@
@ -206,11 +207,6 @@ host_cpu = @host_cpu@
HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
HPUXMATHLIB= @HPUXMATHLIB@
# Ignore BSD_SHLIB if you're not using one of the BSD ports. But if you
# are, and it's one that doesn't have shared libraries (NetBSD/vax is an
# example of this), set BSD_SHLIB to null in Makefile.custom.
BSD_SHLIB= true
# This is mainly for use on FreeBSD, where we have both a.out and elf
# systems now. May be applicable to other systems to?
ELF_SYSTEM= @ELF_SYS@

View File

@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.26 2000/10/20 21:03:38 petere Exp $
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.27 2000/10/23 21:43:56 petere Exp $
#
#-------------------------------------------------------------------------
@ -51,154 +51,157 @@
#
# Got that? Look at src/interfaces/libpq/Makefile for an example.
ifndef cplusplus
COMPILER = $(CC)
else
COMPILER = $(CXX)
endif
# shlib is empty by default. If we know how to build a shared library
# it will contain the name of the file, otherwise it will remain
# empty. Thus `ifdef shlib' could be used in the containing make file
# to test whether shared libraries are available.
shlib :=
# For each platform we support shared libraries on, set shlib and
# update flags as needed to build a shared lib. Note we depend on
# Makefile.global (or really Makefile.port) to supply DLSUFFIX and
# other symbols.
# First, a few hacks for building *static* libraries.
LINK.static = $(AR) $(AROPT)
ifdef cplusplus
ifeq ($(PORTNAME), irix5)
ifneq ($(GXX), yes)
LINK.static = $(CXX) -ar -o
endif
endif
ifeq ($(PORTNAME), solaris)
ifneq ($(GXX), yes)
LINK.static = $(CXX) -xar -o
endif
endif
endif # cplusplus
ifeq ($(enable_shared), yes)
# For each platform we support shared libraries on, set shlib to the
# name of the library, LINK.shared to the command to link the library,
# and adjust SHLIB_LINK if necessary.
# Try to keep the sections in some kind of order, folks...
# XXX fix Makefile.aix
ifneq ($(PORTNAME), aix)
ifndef cplusplus
override CFLAGS += $(CFLAGS_SL)
else
override CXXFLAGS += $(CFLAGS_SL)
endif
endif
ifeq ($(PORTNAME), aix)
shlib := lib$(NAME)$(DLSUFFIX)
SHLIB_LINK += -lc
endif
ifeq ($(PORTNAME), openbsd)
ifdef BSD_SHLIB
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM
LDFLAGS_SL := -x -Bshareable -soname $(shlib)
else
LDFLAGS_SL := -x -Bshareable -Bforcearchive
endif
override CFLAGS += $(CFLAGS_SL)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM
LINK.shared = $(LD) -x -Bshareable -soname $(shlib)
else
LINK.shared = $(LD) -x -Bshareable -Bforcearchive
endif
endif
ifeq ($(PORTNAME), bsdi)
ifdef BSD_SHLIB
ifeq ($(DLSUFFIX), .so)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL += -shared -soname $(shlib)
override CFLAGS += $(CFLAGS_SL)
endif
ifeq ($(DLSUFFIX), .o)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LD := shlicc
LDFLAGS_SL += -O $(LDREL)
override CFLAGS += $(CFLAGS_SL)
endif
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifeq ($(DLSUFFIX), .so)
LINK.shared = $(LD) -shared -soname $(shlib)
endif
ifeq ($(DLSUFFIX), .o)
LINK.shared = shlicc -O $(LDREL)
endif
endif
ifeq ($(PORTNAME), freebsd)
ifdef BSD_SHLIB
ifdef ELF_SYSTEM
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LDFLAGS_SL := -x -shared -soname $(shlib)
else
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL := -x -Bshareable -Bforcearchive
endif
override CFLAGS += $(CFLAGS_SL)
ifdef ELF_SYSTEM
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LINK.shared = $(LD) -x -shared -soname $(shlib)
else
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(LD) -x -Bshareable -Bforcearchive
endif
endif
ifeq ($(PORTNAME), netbsd)
ifdef BSD_SHLIB
soname := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM
LD := $(CC)
LDFLAGS_SL := -shared -Wl,-soname -Wl,$(soname)
ifneq ($(SHLIB_LINK),)
LDFLAGS_SL += -Wl,-R$(libdir)
endif
else
LDFLAGS_SL := -x -Bshareable -Bforcearchive
soname := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM
LINK.shared = $(COMPILER) -shared -Wl,-soname -Wl,$(soname)
ifneq ($(SHLIB_LINK),)
LINK.shared += -Wl,-R$(libdir)
endif
override CFLAGS += $(CFLAGS_SL)
else
LINK.shared = $(LD) -x -Bshareable -Bforcearchive
endif
endif
ifeq ($(PORTNAME), hpux)
# HPUX doesn't believe in version numbers for shlibs
shlib := lib$(NAME)$(DLSUFFIX)
LDFLAGS_SL := -b
override CFLAGS += $(CFLAGS_SL)
LINK.shared = $(LD) -b
endif
ifeq ($(PORTNAME), irix5)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LDFLAGS_SL := -shared -rpath $(libdir) -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
override CFLAGS += $(CFLAGS_SL)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LINK.shared := $(COMPILER) -shared -rpath $(libdir) -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
endif
ifeq ($(PORTNAME), linux)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LD := $(CC)
LDFLAGS_SL := -shared -Wl,-soname,$(shlib)
LDFLAGS_ODBC := -lm
override CFLAGS += $(CFLAGS_SL)
LINK.shared = $(COMPILER) -shared -Wl,-soname,$(shlib)
endif
ifeq ($(PORTNAME), solaris)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL := -G
LINK.shared = $(COMPILER) -G
SHLIB_LINK += -ldl -lsocket -lresolv -lnsl -lm -lc
override CFLAGS += $(CFLAGS_SL)
endif
ifeq ($(PORTNAME), osf)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL += -shared -expect_unresolved '*'
LINK.shared = $(LD) -shared -expect_unresolved '*'
endif
ifeq ($(PORTNAME), svr4)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL := -G
override CFLAGS += $(CFLAGS_SL)
LINK.shared = $(LD) -G
endif
ifeq ($(PORTNAME), univel)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL := -G -z text
override CFLAGS += $(CFLAGS_SL)
ifeq ($(CXX), CC)
override CXXFLAGS += -Xw
COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
endif
LINK.shared = $(LD) -G -z text
endif
ifeq ($(PORTNAME), unixware)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL := -G -z text
override CFLAGS += $(CFLAGS_SL)
ifeq ($(CXX), CC)
override CXXFLAGS += -Xw
COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
endif
LINK.shared = $(LD) -G -z text
endif
ifeq ($(PORTNAME), win)
shlib := $(NAME)$(DLSUFFIX)
ifdef cplusplus
SHLIB_LINK += --driver-name g++
endif
endif
ifeq ($(PORTNAME), beos)
install-shlib-dep := install-shlib
shlib := lib$(NAME)$(DLSUFFIX)
LDFLAGS_SL := -nostart -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
shlib := lib$(NAME)$(DLSUFFIX)
LINK.shared = $(LD) -nostart
SHLIB_LINK += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
endif
# Note that in what follows, shlib is empty when not building a shared
# library.
endif # enable_shared
##
@ -208,8 +211,6 @@ endif
.PHONY: all-lib
all-lib: lib$(NAME).a $(shlib)
# Rules to build regular and shared libraries
ifneq ($(PORTNAME), win)
ifndef LORDER
@ -218,22 +219,23 @@ endif
lib$(NAME).a: $(OBJS)
ifdef MK_NO_LORDER
$(AR) $(AROPT) $@ $^
$(LINK.static) $@ $^
else
$(AR) $(AROPT) $@ `$(LORDER) $^ | tsort`
$(LINK.static) $@ `$(LORDER) $^ | tsort`
endif
$(RANLIB) $@
endif # not win
ifdef shlib
ifeq ($(enable_shared), yes)
ifneq ($(PORTNAME), beos)
ifneq ($(PORTNAME), win)
ifneq ($(PORTNAME), aix)
# Normal case
$(shlib): $(OBJS)
$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(SHLIB_LINK)
$(LINK.shared) -o $@ $(OBJS) $(SHLIB_LINK)
# If we're using major and minor versions, then make a symlink to major-version-only.
ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
@ -275,7 +277,8 @@ $(shlib): $(OBJS)
$(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
endif # PORTNAME == beos
endif # shlib
endif # enable_shared
##
@ -288,7 +291,7 @@ install-lib: install-lib-static install-lib-shared
install-lib-static: lib$(NAME).a
$(INSTALL_DATA) $< $(DESTDIR)$(libdir)/lib$(NAME).a
ifdef shlib
ifeq ($(enable_shared), yes)
install-lib-shared: $(shlib)
$(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
ifneq ($(PORTNAME), win)
@ -304,7 +307,7 @@ ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
endif
endif # not win
endif # shlib
endif # enable_shared
##
@ -314,11 +317,11 @@ endif # shlib
.PHONY: uninstall-lib
uninstall-lib:
rm -f $(DESTDIR)$(libdir)/lib$(NAME).a
ifdef shlib
ifeq ($(enable_shared), yes)
rm -f $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX) \
$(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) \
$(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
endif # shlib
endif # enable_shared
##
@ -328,7 +331,9 @@ endif # shlib
.PHONY: clean-lib
clean-lib:
rm -f lib$(NAME).a
ifeq ($(enable_shared), yes)
rm -f $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX)
endif
ifeq ($(PORTNAME), win)
rm -rf $(NAME).def
endif

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile,v 1.26 2000/10/20 21:04:12 petere Exp $
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile,v 1.27 2000/10/23 21:43:57 petere Exp $
#
#-------------------------------------------------------------------------
@ -20,28 +20,10 @@ override CPPFLAGS += -I$(libpq_srcdir)
OBJS = pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o pglobject.o
ifeq ($(PORTNAME), win)
SHLIB_LINK+= --driver-name g++ $(libpq)
else
SHLIB_LINK= $(libpq)
endif
# For CC on IRIX, must use CC as linker/archiver of C++ libraries
ifeq ($(PORTNAME), irix5)
ifneq ($(GXX), yes)
AR := CC
AROPT := -ar -o
LD := CC
endif
endif
# Same for Solaris with native compiler
ifeq ($(PORTNAME), solaris)
ifneq ($(GXX), yes)
AR := CC
AROPT := -xar -o
LD := CC
endif
endif
# communicate with Makefile.shlib
cplusplus := yes
all: all-lib
@ -49,9 +31,6 @@ all: all-lib
# Shared library stuff
include $(top_srcdir)/src/Makefile.shlib
# Pull shared-lib CFLAGS into CXXFLAGS
override CXXFLAGS+= $(CFLAGS_SL)
.PHONY: examples
examples:

View File

@ -2,7 +2,7 @@
#
# GNUMakefile for psqlodbc (Postgres ODBC driver)
#
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.5 2000/10/20 21:04:13 petere Exp $
# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.6 2000/10/23 21:43:58 petere Exp $
#
#-------------------------------------------------------------------------
@ -23,15 +23,13 @@ OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
gpps.o tuple.o tuplelist.o dlg_specific.o $(OBJX)
SHLIB_LINK= $(LD_FLAGS)
SHLIB_LINK= -lm
all: all-lib
# Shared library stuff
include $(top_srcdir)/src/Makefile.shlib
LDFLAGS_SL+= $(LDFLAGS_ODBC)
odbc_headers = isql.h isqlext.h iodbc.h
odbc_includedir = $(includedir)/iodbc

View File

@ -8,6 +8,7 @@ LDOUT=
LIBS= -lunix
LDFLAGS= $(LIBS)
enable_shared = no
DLSUFFIX = .so
CFLAGS_SL =

View File

@ -2,7 +2,7 @@
#
# Makefile for the plpgsql shared object
#
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.8 2000/10/20 21:04:16 petere Exp $
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.9 2000/10/23 21:44:03 petere Exp $
#
#-------------------------------------------------------------------------
@ -32,7 +32,7 @@ include $(top_srcdir)/src/Makefile.shlib
# rule and do this instead:
install: installdirs all
ifdef shlib
ifeq ($(enable_shared), yes)
$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(libdir)/plpgsql$(DLSUFFIX)
else
@echo "*****"; \

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.28 2000/10/20 21:04:25 petere Exp $
# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.29 2000/10/23 21:44:07 petere Exp $
#
#-------------------------------------------------------------------------
@ -36,6 +36,7 @@ pg_regress: pg_regress.sh GNUmakefile
-e 's/@VERSION@/$(VERSION)/g' \
-e 's/@host_tuple@/$(host_tuple)/g' \
-e 's,@GMAKE@,$(MAKE),g' \
-e 's/@enable_shared@/$(enable_shared)/g' \
$< >$@
chmod a+x $@

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.8 2000/10/22 22:15:09 petere Exp $
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.9 2000/10/23 21:44:12 petere Exp $
me=`basename $0`
: ${TMPDIR=/tmp}
@ -73,6 +73,7 @@ libdir='@libdir@'
bindir='@bindir@'
datadir='@datadir@'
host_platform='@host_tuple@'
enable_shared='@enable_shared@'
unset mode
unset schedule
@ -406,17 +407,14 @@ fi
# Install the PL/pgSQL language in it
# ----------
case $host_platform in
*-*-qnx*) : ;;
*)
if [ "$enable_shared" = yes ]; then
message "installing PL/pgSQL"
"$bindir/createlang" -L "$libdir" $psql_options plpgsql $dbname
if [ $? -ne 0 ] && [ $? -ne 2 ]; then
echo "$me: createlang failed"
(exit 2); exit
fi
;;
esac
fi
# ----------
@ -436,6 +434,7 @@ cat /dev/null >"$diff_file"
lno=0
(
[ "$enable_shared" != yes ] && echo "ignore: plpgsql"
cat $schedule
for x in $extra_tests; do
echo "test: $x"
@ -472,7 +471,7 @@ do
$PSQL -d "$dbname" <"$inputdir/sql/$1.sql" >"$outputdir/results/$1.out" 2>&1
else
# Start a parallel group
$ECHO_N "parallel group ($# tests): " $ECHO_C
$ECHO_N "parallel group ($# tests): $ECHO_C"
for name do
( $PSQL -d $dbname <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1
$ECHO_N " $name$ECHO_C"