Cause libpq and ecpg libraries to be built as proper shared libraries

(.dylib format) on Mac OS X, while not messing up loadable modules for
the backend (which are the same kind of animal as a shared library on
every other platform, but not here).  Also get the naming convention
to match OS X practice, viz libFOO.version.so not libFOO.so.version.
In support of that last, refactor code in Makefile.shlib to make it
easier to have platform-specific shlib naming conventions.
This patch is loosely based on the Fink project's current postgresql.patch.
Tested by yours truly on OS X 10.3.4; does anyone have 10.2.* to check
it on?
This commit is contained in:
Tom Lane 2004-07-13 00:06:46 +00:00
parent 8b6f76af46
commit 9df3086972
5 changed files with 71 additions and 61 deletions

View File

@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California # Copyright (c) 1998, Regents of the University of California
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.76 2004/05/19 21:37:43 momjian Exp $ # $PostgreSQL: pgsql/src/Makefile.shlib,v 1.77 2004/07/13 00:06:46 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -71,8 +71,14 @@ LINK.static = $(AR) $(AROPT)
ifeq ($(enable_shared), yes) ifeq ($(enable_shared), yes)
# Default shlib naming convention used by the majority of platforms
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
shlib_major = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
shlib_bare = lib$(NAME)$(DLSUFFIX)
# For each platform we support shared libraries on, set shlib to the # 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, # name of the library (if default above is not right), set
# LINK.shared to the command to link the library,
# and adjust SHLIB_LINK if necessary. # and adjust SHLIB_LINK if necessary.
# Try to keep the sections in some kind of order, folks... # Try to keep the sections in some kind of order, folks...
@ -82,17 +88,28 @@ override CFLAGS += $(CFLAGS_SL)
soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
ifeq ($(PORTNAME), aix) ifeq ($(PORTNAME), aix)
shlib := lib$(NAME)$(DLSUFFIX) shlib = lib$(NAME)$(DLSUFFIX)
# SHLIB_LINK += -lc # SHLIB_LINK += -lc
endif endif
ifeq ($(PORTNAME), darwin) ifeq ($(PORTNAME), darwin)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) ifneq ($(SO_MAJOR_VERSION), 0)
LINK.shared = $(COMPILER) -bundle version_link := -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
endif
ifeq ($(DLTYPE), library)
# linkable library
DLSUFFIX := .dylib
LINK.shared = $(COMPILER) -dynamiclib -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) -multiply_defined suppress
else
# loadable module (default case)
DLSUFFIX := .so
LINK.shared = $(COMPILER) -bundle
endif
shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
endif endif
ifeq ($(PORTNAME), openbsd) ifeq ($(PORTNAME), openbsd)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
SHLIB_LINK += -lc SHLIB_LINK += -lc
@ -102,7 +119,6 @@ ifeq ($(PORTNAME), openbsd)
endif endif
ifeq ($(PORTNAME), bsdi) ifeq ($(PORTNAME), bsdi)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifeq ($(DLSUFFIX), .so) ifeq ($(DLSUFFIX), .so)
LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
SHLIB_LINK += -lc SHLIB_LINK += -lc
@ -114,16 +130,15 @@ endif
ifeq ($(PORTNAME), freebsd) ifeq ($(PORTNAME), freebsd)
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
else else
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(LD) -x -Bshareable -Bforcearchive LINK.shared = $(LD) -x -Bshareable -Bforcearchive
endif endif
endif endif
ifeq ($(PORTNAME), netbsd) ifeq ($(PORTNAME), netbsd)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
else else
@ -132,7 +147,7 @@ ifeq ($(PORTNAME), netbsd)
endif endif
ifeq ($(PORTNAME), hpux) ifeq ($(PORTNAME), hpux)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LINK.shared = $(LD) +h $(soname) -b +b $(libdir) LINK.shared = $(LD) +h $(soname) -b +b $(libdir)
ifeq ($(GCC), yes) ifeq ($(GCC), yes)
SHLIB_LINK += `$(CC) -print-libgcc-file-name` SHLIB_LINK += `$(CC) -print-libgcc-file-name`
@ -140,17 +155,15 @@ ifeq ($(PORTNAME), hpux)
endif endif
ifeq ($(PORTNAME), irix) ifeq ($(PORTNAME), irix)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LINK.shared = $(COMPILER) -shared -Wl,-set_version,sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) LINK.shared = $(COMPILER) -shared -Wl,-set_version,sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
endif endif
ifeq ($(PORTNAME), linux) ifeq ($(PORTNAME), linux)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname)
endif endif
ifeq ($(PORTNAME), solaris) ifeq ($(PORTNAME), solaris)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifeq ($(GCC), yes) ifeq ($(GCC), yes)
LINK.shared = $(CC) -shared LINK.shared = $(CC) -shared
else else
@ -164,17 +177,14 @@ ifeq ($(PORTNAME), solaris)
endif endif
ifeq ($(PORTNAME), sunos4) ifeq ($(PORTNAME), sunos4)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(LD) -assert pure-text -Bdynamic LINK.shared = $(LD) -assert pure-text -Bdynamic
endif endif
ifeq ($(PORTNAME), osf) ifeq ($(PORTNAME), osf)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(LD) -shared -expect_unresolved '*' LINK.shared = $(LD) -shared -expect_unresolved '*'
endif endif
ifeq ($(PORTNAME), sco) ifeq ($(PORTNAME), sco)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifeq ($(GCC), yes) ifeq ($(GCC), yes)
LINK.shared = $(CC) -shared LINK.shared = $(CC) -shared
else else
@ -184,17 +194,14 @@ ifeq ($(PORTNAME), sco)
endif endif
ifeq ($(PORTNAME), svr4) ifeq ($(PORTNAME), svr4)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(LD) -G LINK.shared = $(LD) -G
endif endif
ifeq ($(PORTNAME), univel) ifeq ($(PORTNAME), univel)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LINK.shared = $(LD) -G -z text LINK.shared = $(LD) -G -z text
endif endif
ifeq ($(PORTNAME), unixware) ifeq ($(PORTNAME), unixware)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifeq ($(GCC), yes) ifeq ($(GCC), yes)
LINK.shared = $(CC) -shared LINK.shared = $(CC) -shared
else else
@ -204,15 +211,15 @@ ifeq ($(PORTNAME), unixware)
endif endif
ifeq ($(PORTNAME), cygwin) ifeq ($(PORTNAME), cygwin)
shlib := $(NAME)$(DLSUFFIX) shlib = $(NAME)$(DLSUFFIX)
endif endif
ifeq ($(PORTNAME), win32) ifeq ($(PORTNAME), win32)
shlib := lib$(NAME)$(DLSUFFIX) shlib = lib$(NAME)$(DLSUFFIX)
endif endif
ifeq ($(PORTNAME), beos) ifeq ($(PORTNAME), beos)
shlib := lib$(NAME)$(DLSUFFIX) shlib = lib$(NAME)$(DLSUFFIX)
LINK.shared = $(LD) -nostart LINK.shared = $(LD) -nostart
SHLIB_LINK += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86 SHLIB_LINK += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
endif endif
@ -258,23 +265,23 @@ endif # not cygwin
ifeq ($(enable_shared), yes) ifeq ($(enable_shared), yes)
ifneq ($(PORTNAME), beos)
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32) ifneq ($(PORTNAME), win32)
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), beos)
ifneq ($(PORTNAME), aix) ifneq ($(PORTNAME), aix)
# Normal case # Normal case
$(shlib): $(OBJS) $(shlib): $(OBJS)
$(LINK.shared) $(OBJS) $(SHLIB_LINK) -o $@ $(LINK.shared) $(OBJS) $(SHLIB_LINK) -o $@
# If we're using major and minor versions, then make a symlink to major-version-only. # If we're using major and minor versions, then make a symlink to major-version-only.
ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)) ifneq ($(shlib), $(shlib_major))
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) rm -f $(shlib_major)
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) $(LN_S) $(shlib) $(shlib_major)
endif endif
# Make sure we have a link to a name without any version numbers # Make sure we have a link to a name without any version numbers
ifneq ($(shlib), lib$(NAME)$(DLSUFFIX)) ifneq ($(shlib), $(shlib_bare))
rm -f lib$(NAME)$(DLSUFFIX) rm -f $(shlib_bare)
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX) $(LN_S) $(shlib) $(shlib_bare)
endif endif
else # PORTNAME == aix else # PORTNAME == aix
@ -286,15 +293,14 @@ $(shlib): lib$(NAME).a
endif # PORTNAME == aix endif # PORTNAME == aix
else # PORTNAME == win32 else # PORTNAME == beos
# win32 case # BEOS case
$(shlib) lib$(NAME).a: $(OBJS) $(shlib): $(OBJS)
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS) ln -fs $(top_srcdir)/src/backend/postgres _APP_
$(DLLWRAP) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK) $(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
endif # PORTNAME == win32 endif # PORTNAME == beos
else # PORTNAME == cygwin else # PORTNAME == cygwin
@ -309,14 +315,15 @@ $(DLLINIT): $(DLLINIT:%.o=%.c)
endif # PORTNAME == cygwin endif # PORTNAME == cygwin
else # PORTNAME == beos else # PORTNAME == win32
# BEOS case # win32 case
$(shlib): $(OBJS) $(shlib) lib$(NAME).a: $(OBJS)
ln -fs $(top_srcdir)/src/backend/postgres _APP_ $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
$(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK) $(DLLWRAP) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
endif # PORTNAME == beos endif # PORTNAME == win32
endif # enable_shared endif # enable_shared
@ -340,17 +347,16 @@ install-lib-shared: $(shlib)
$(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib) $(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
ifneq ($(PORTNAME), cygwin) ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32) ifneq ($(PORTNAME), win32)
ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)) ifneq ($(shlib), $(shlib_major))
cd $(DESTDIR)$(libdir) && \ cd $(DESTDIR)$(libdir) && \
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) && \ rm -f $(shlib_major) && \
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) $(LN_S) $(shlib) $(shlib_major)
endif endif
ifneq ($(shlib), lib$(NAME)$(DLSUFFIX)) ifneq ($(shlib), $(shlib_bare))
cd $(DESTDIR)$(libdir) && \ cd $(DESTDIR)$(libdir) && \
rm -f lib$(NAME)$(DLSUFFIX) && \ rm -f $(shlib_bare) && \
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX) $(LN_S) $(shlib) $(shlib_bare)
endif endif
endif # not win32 endif # not win32
endif # not cygwin endif # not cygwin
endif # enable_shared endif # enable_shared
@ -364,9 +370,9 @@ endif # enable_shared
uninstall-lib: uninstall-lib:
rm -f $(DESTDIR)$(libdir)/lib$(NAME).a rm -f $(DESTDIR)$(libdir)/lib$(NAME).a
ifeq ($(enable_shared), yes) ifeq ($(enable_shared), yes)
rm -f $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX) \ rm -f $(DESTDIR)$(libdir)/$(shlib_bare) \
$(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) \ $(DESTDIR)$(libdir)/$(shlib_major) \
$(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) $(DESTDIR)$(libdir)/$(shlib)
endif # enable_shared endif # enable_shared
@ -378,7 +384,7 @@ endif # enable_shared
clean-lib: clean-lib:
rm -f lib$(NAME).a rm -f lib$(NAME).a
ifeq ($(enable_shared), yes) ifeq ($(enable_shared), yes)
rm -f lib$(NAME)$(DLSUFFIX) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) rm -f $(shlib_bare) $(shlib_major) $(shlib)
ifdef EXPSUFF ifdef EXPSUFF
rm -f lib$(NAME)$(EXPSUFF) rm -f lib$(NAME)$(EXPSUFF)
endif endif

View File

@ -1,10 +1,10 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Makefile for ecpg library # Makefile for ecpg compatibility library
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.17 2004/04/30 04:14:05 momjian Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.18 2004/07/13 00:06:39 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -15,6 +15,7 @@ include $(top_builddir)/src/Makefile.global
NAME= ecpg_compat NAME= ecpg_compat
SO_MAJOR_VERSION= 1 SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 1 SO_MINOR_VERSION= 1
DLTYPE= library
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) \ override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) \
-I$(top_srcdir)/src/include/utils $(CPPFLAGS) -I$(top_srcdir)/src/include/utils $(CPPFLAGS)

View File

@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.24 2004/05/25 21:20:44 momjian Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.25 2004/07/13 00:06:41 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -15,6 +15,7 @@ include $(top_builddir)/src/Makefile.global
NAME= ecpg NAME= ecpg
SO_MAJOR_VERSION= 4 SO_MAJOR_VERSION= 4
SO_MINOR_VERSION= 2 SO_MINOR_VERSION= 2
DLTYPE= library
override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \ override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \
-I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS) -I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)

View File

@ -1,10 +1,10 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Makefile for ecpg library # Makefile for ecpg pgtypes library
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.21 2004/05/26 17:24:07 tgl Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.22 2004/07/13 00:06:43 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -15,6 +15,7 @@ include $(top_builddir)/src/Makefile.global
NAME= pgtypes NAME= pgtypes
SO_MAJOR_VERSION= 1 SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 2 SO_MINOR_VERSION= 2
DLTYPE= library
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \ override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \
-I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS) \ -I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS) \

View File

@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.111 2004/06/19 15:14:17 momjian Exp $ # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.112 2004/07/13 00:06:44 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -17,6 +17,7 @@ include $(top_builddir)/src/Makefile.global
NAME= pq NAME= pq
SO_MAJOR_VERSION= 3 SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 2 SO_MINOR_VERSION= 2
DLTYPE= library
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port -DFRONTEND override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port -DFRONTEND
override CFLAGS += $(PTHREAD_CFLAGS) override CFLAGS += $(PTHREAD_CFLAGS)