@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.113 2008/02/26 14:26:16 petere Exp $
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.114 2008/04/07 14:15:58 petere Exp $
#
#-------------------------------------------------------------------------
@ -19,13 +19,18 @@
# variables:
#
# NAME Name of library to build (no suffix nor "lib" prefix)
# SO_MAJOR_VERSION Major version number to use for shared library
# SO_MINOR_VERSION Minor version number to use for shared library
# OBJS List of object files to include in library
# SHLIB_LINK If shared library relies on other libraries,
# additional stuff to put in its link command
# SHLIB_EXPORTS (optional) Name of file containing list of symbols to
# export
#
# When building a shared library, the following version information
# must also be set. It should be omitted when building a dynamically
# loadable module.
#
# SO_MAJOR_VERSION Major version number to use for shared library
# SO_MINOR_VERSION Minor version number to use for shared library
# (If you want a patchlevel, include it in SO_MINOR_VERSION, e.g., "6.2".)
#
# Optional flags when building DLL's (only applicable to win32 and cygwin
@ -42,6 +47,7 @@
#
# all-lib build the static and shared (if applicable) libraries
# install-lib install the libraries into $(libdir)
# installdirs-lib create installation directory $(libdir)
# uninstall-lib remove the libraries from $(libdir)
# clean-lib delete the static and shared libraries from the build dir
# maintainer-clean-lib delete .def files built for win32
@ -72,18 +78,34 @@ LINK.static = $(AR) $(AROPT)
i f e q ( $( enable_shared ) , y e s )
# Insert -L from LDFLAGS after any -L already present in SHLIB_LINK
SHLIB_LINK := $( filter -L%, $( SHLIB_LINK) ) $( filter -L%, $( LDFLAGS) ) $( filter-out -L%, $( SHLIB_LINK) )
# Need a -L-free version of LDFLAGS to use in combination with SHLIB_LINK
LDFLAGS_NO_L = $( filter-out -L%, $( LDFLAGS) )
# Default shlib naming convention used by the majority of platforms
i f d e f S O _ M A J O R _ V E R S I O N
# Default library naming convention used by the majority of platforms
i f e q ( $( enable_shared ) , y e s )
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION)
shlib_major = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
shlib_bare = lib$( NAME) $( DLSUFFIX)
e n d i f
# Testing the soname variable is a reliable way to determine whether a
# linkable library is being built.
soname = $( shlib_major)
stlib = lib$( NAME) .a
e l s e
# Naming convention for dynamically loadable modules
i f e q ( $( enable_shared ) , y e s )
shlib = $( NAME) $( DLSUFFIX)
e n d i f
e n d i f
i f n d e f s o n a m e
# additional flags for backend modules
SHLIB_LINK := $( BE_DLLLIBS) $( SHLIB_LINK)
e n d i f
# For each platform we support shared libraries on, set shlib to the
# name of the library (if default above is not right), set
@ -94,29 +116,29 @@ shlib_bare = lib$(NAME)$(DLSUFFIX)
o v e r r i d e CFLAGS += $( CFLAGS_SL)
soname = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
i f e q ( $( PORTNAME ) , a i x )
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
ifdef SO_MAJOR_VERSION
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
endif
haslibarule = yes
exports_file = lib$( NAME) .exp
e n d i f
i f e q ( $( PORTNAME ) , d a r w i n )
ifneq ( $( SO_MAJOR_VERSION) , 0)
version_link = -compatibility_version $( SO_MAJOR_VERSION) -current_version $( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION)
endif
ifeq ( $( DLTYPE) , library)
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
LINK.shared = $( COMPILER) -dynamiclib -install_name $( libdir) /lib$( NAME) .$( SO_MAJOR_VERSION) $( DLSUFFIX) $( version_link) $( exported_symbols_list) -multiply_defined suppress
shlib = lib$( NAME) .$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION) $( DLSUFFIX)
shlib_major = lib$( NAME) .$( SO_MAJOR_VERSION) $( DLSUFFIX)
else
# loadable module (default case)
# loadable module
DLSUFFIX = .so
LINK.shared = $( COMPILER) -bundle -multiply_defined suppress
endif
shlib = lib$( NAME) .$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION) $( DLSUFFIX)
shlib_major = lib$( NAME) .$( SO_MAJOR_VERSION) $( DLSUFFIX)
BUILD.exports = $( AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
exports_file = $( SHLIB_EXPORTS:%.txt= %.list)
ifneq ( ,$( exports_file) )
@ -126,7 +148,10 @@ endif
i f e q ( $( PORTNAME ) , o p e n b s d )
ifdef ELF_SYSTEM
LINK.shared = $( COMPILER) -shared -Wl,-x,-soname,$( soname)
LINK.shared = $( COMPILER) -shared
ifdef soname
LINK.shared += -Wl,-x,-soname,$( soname)
endif
SHLIB_LINK += -lc
else
LINK.shared = $( LD) -x -Bshareable -Bforcearchive
@ -135,7 +160,10 @@ endif
i f e q ( $( PORTNAME ) , b s d i )
ifeq ( $( DLSUFFIX) , .so)
LINK.shared = $( COMPILER) -shared -Wl,-x,-soname,$( soname)
LINK.shared = $( COMPILER) -shared
ifdef soname
LINK.shared += -Wl,-x,-soname,$( soname)
endif
SHLIB_LINK += -lc
endif
ifeq ( $( DLSUFFIX) , .o)
@ -145,33 +173,50 @@ endif
i f e q ( $( PORTNAME ) , f r e e b s d )
ifdef ELF_SYSTEM
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
LINK.shared = $( COMPILER) -shared -Wl,-x,-soname,$( soname)
ifdef SO_MAJOR_VERSION
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
endif
LINK.shared = $( COMPILER) -shared
ifdef soname
LINK.shared += -Wl,-x,-soname,$( soname)
endif
else
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION)
ifdef SO_MAJOR_VERSION
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION)
endif
LINK.shared = $( LD) -x -Bshareable -Bforcearchive
endif
e n d i f
i f e q ( $( PORTNAME ) , n e t b s d )
ifdef ELF_SYSTEM
LINK.shared = $( COMPILER) -shared -Wl,-x,-soname,$( soname)
LINK.shared = $( COMPILER) -shared
ifdef soname
LINK.shared += -Wl,-x,-soname,$( soname)
endif
else
LINK.shared = $( LD) -x -Bshareable -Bforcearchive
endif
e n d i f
i f e q ( $( PORTNAME ) , h p u x )
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
ifdef SO_MAJOR_VERSION
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
endif
ifeq ( $( with_gnu_ld) , yes)
LINK.shared = $( CC) $( LDFLAGS_NO_L) -shared -Wl,-h -Wl,$( soname)
LINK.shared = $( CC) $( LDFLAGS_NO_L) -shared
ifdef soname
LINK.shared += -Wl,-h -Wl,$( soname)
endif
else
# can't use the CC-syntax rpath pattern here
rpath =
LINK.shared = $( LD) -b
ifdef soname
LINK.shared += +h $( soname)
endif
ifeq ( $( enable_rpath) , yes)
LINK.shared = $( LD) +h $( soname) -b +b '$(rpathdir)'
else
LINK.shared = $( LD) +h $( soname) -b
LINK.shared += +b '$(rpathdir)'
endif
# On HPUX platforms, gcc is usually configured to search for libraries
# in /usr/local/lib, but ld won't do so. Add an explicit -L switch so
@ -188,12 +233,20 @@ ifeq ($(PORTNAME), hpux)
e n d i f
i f e q ( $( PORTNAME ) , i r i x )
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
LINK.shared = $( COMPILER) -shared -Wl,-set_version,sgi$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION)
ifdef SO_MAJOR_VERSION
shlib = lib$( NAME) $( DLSUFFIX) .$( SO_MAJOR_VERSION)
endif
LINK.shared = $( COMPILER) -shared
ifdef soname
LINK.shared += -Wl,-set_version,sgi$( SO_MAJOR_VERSION) .$( SO_MINOR_VERSION)
endif
e n d i f
i f e q ( $( PORTNAME ) , l i n u x )
LINK.shared = $( COMPILER) -shared -Wl,-soname,$( soname)
LINK.shared = $( COMPILER) -shared
ifdef soname
LINK.shared += -Wl,-soname,$( soname)
endif
BUILD.exports = ( echo '{ global:' ; $( AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
exports_file = $( SHLIB_EXPORTS:%.txt= %.list)
ifneq ( ,$( exports_file) )
@ -208,10 +261,12 @@ ifeq ($(PORTNAME), solaris)
# CFLAGS added for X86_64
LINK.shared = $( CC) -G $( CFLAGS)
endif
ifeq ( $( with_gnu_ld) , yes)
LINK.shared += -Wl,-soname,$( soname)
else
LINK.shared += -h $( soname)
ifdef soname
ifeq ( $( with_gnu_ld) , yes)
LINK.shared += -Wl,-soname,$( soname)
else
LINK.shared += -h $( soname)
endif
endif
e n d i f
@ -229,7 +284,10 @@ ifeq ($(PORTNAME), sco)
else
LINK.shared = $( CC) -G
endif
LINK.shared += -Wl,-z,text -Wl,-h,$( soname)
LINK.shared += -Wl,-z,text
ifdef soname
LINK.shared += -Wl,-h,$( soname)
endif
e n d i f
i f e q ( $( PORTNAME ) , s v r 4 )
@ -246,7 +304,10 @@ ifeq ($(PORTNAME), unixware)
else
LINK.shared = $( CC) -G
endif
LINK.shared += -Wl,-z,text -Wl,-h,$( soname)
LINK.shared += -Wl,-z,text
ifdef soname
LINK.shared += -Wl,-h,$( soname)
endif
e n d i f
i f e q ( $( PORTNAME ) , c y g w i n )
@ -263,8 +324,6 @@ ifeq ($(enable_rpath), yes)
SHLIB_LINK += $( rpath)
e n d i f
e n d i f # enable_shared
##
@ -273,14 +332,18 @@ endif # enable_shared
.PHONY : all -lib all -static -lib all -shared -lib
all-lib : all -static -lib all -shared -lib
all-lib : all -shared -lib
i f d e f s o n a m e
# no static library when building a dynamically loadable module
all-lib : all -static -lib
e n d i f
all-static-lib : lib $( NAME ) .a
all-static-lib : $( stlib )
all-shared-lib : $( shlib )
i f n d e f h a s l i b a r u l e
lib$(NAME ).a : $( OBJS )
$(st lib): $( OBJS )
$( LINK.static) $@ $^
$( RANLIB) $@
e n d i f #haslibarule
@ -293,6 +356,7 @@ ifneq ($(PORTNAME), aix)
# Normal case
$(shlib) : $( OBJS )
$( LINK.shared) $( LDFLAGS_SL) $( OBJS) $( SHLIB_LINK) -o $@
i f d e f s h l i b _ m a j o r
# If we're using major and minor versions, then make a symlink to major-version-only.
i f n e q ( $( shlib ) , $( shlib_major ) )
rm -f $( shlib_major)
@ -303,6 +367,7 @@ ifneq ($(shlib), $(shlib_bare))
rm -f $( shlib_bare)
$( LN_S) $( shlib) $( shlib_bare)
e n d i f
e n d i f # shlib_major
# Where possible, restrict the symbols exported by the library to just the
# official list, so as to avoid unintentional ABI changes. On recent Darwin
@ -320,13 +385,13 @@ endif
e l s e # PORTNAME == aix
# AIX case
$(shlib) lib$(NAME ).a : $( OBJS )
$( LINK.static) lib$( NAME) .a $^
$( RANLIB) lib$( NAME) .a
$( MKLDEXPORT) lib$( NAME) .a >$( exports_file)
$( COMPILER) $( LDFLAGS_NO_L) $( LDFLAGS_SL) -o $( shlib) lib$( NAME) .a -Wl,-bE:$( exports_file) $( SHLIB_LINK)
rm -f lib$( NAME) .a
$( AR) $( AROPT) lib$( NAME) .a $( shlib)
$(shlib) $(st lib) : $( OBJS )
$( LINK.static) $( stlib) $^
$( RANLIB) $( stlib)
$( MKLDEXPORT) $( stlib) >$( exports_file)
$( COMPILER) $( LDFLAGS_NO_L) $( LDFLAGS_SL) -o $( shlib) $( stlib) -Wl,-bE:$( exports_file) $( SHLIB_LINK)
rm -f $( stlib)
$( AR) $( AROPT) $( stlib) $( shlib)
e n d i f # PORTNAME == aix
@ -348,7 +413,7 @@ endif
$(shlib) : $( OBJS ) $( DLL_DEFFILE )
$( DLLWRAP) $( LDFLAGS_SL) -o $@ --dllname $( shlib) $( DLLWRAP_FLAGS) --def $( DLL_DEFFILE) $( OBJS) $( SHLIB_LINK)
lib$(NAME ).a : $( shlib ) $( DLL_DEFFILE )
$(st lib): $( shlib ) $( DLL_DEFFILE )
$( DLLTOOL) --dllname $( shlib) $( DLLTOOL_LIBFLAGS) --def $( DLL_DEFFILE) --output-lib $@
e n d i f # PORTNAME == cygwin || PORTNAME == win32
@ -394,18 +459,22 @@ endif # SHLIB_EXPORTS
## INSTALL
##
.PHONY : install -lib install -lib -static install -lib -shared
install-lib : install -lib -static install -lib -shared
.PHONY : install -lib install -lib -static install -lib -shared installdirs -lib
install-lib : install -lib -shared
i f d e f s o n a m e
install-lib : install -lib -static
e n d i f
install-lib-static : lib $( NAME ) .a
$( INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/lib$(NAME).a'
install-lib-static : $( stlib ) installdirs -lib
$( INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(st lib)'
i f e q ( $( PORTNAME ) , d a r w i n )
cd '$(DESTDIR)$(libdir)' && \
ranlib lib$( NAME) .a
ranlib $( stlib)
e n d i f
i f e q ( $( enable_shared ) , y e s )
install-lib-shared : $( shlib )
install-lib-shared : $( shlib ) installdirs -lib
i f d e f s o n a m e
# we don't install $(shlib) on AIX
i f n e q ( $( PORTNAME ) , a i x )
$( INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
@ -424,21 +493,43 @@ endif
e n d i f # not win32
e n d i f # not cygwin
e n d i f # not aix
e l s e # no soname
$( INSTALL_SHLIB) $< '$(DESTDIR)$(pkglibdir)/$(shlib)'
e n d i f
e l s e # not enable_shared
i f n d e f s o n a m e
install-lib-shared :
@echo "*****" ; \
echo " * Module $( NAME) was not installed due to lack of shared library support. " ; \
echo "*****"
e n d i f
e n d i f # enable_shared
installdirs-lib :
i f d e f s o n a m e
$( mkinstalldirs) '$(DESTDIR)$(libdir)'
e l s e
$( mkinstalldirs) '$(DESTDIR)$(pkglibdir)'
e n d i f
##
## UNINSTALL
##
.PHONY : uninstall -lib
uninstall-lib :
rm -f '$(DESTDIR)$(libdir)/lib$(NAME).a'
i f d e f s o n a m e
rm -f '$(DESTDIR)$(libdir)/$(stlib)'
i f e q ( $( enable_shared ) , y e s )
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
'$(DESTDIR)$(libdir)/$(shlib_major)' \
'$(DESTDIR)$(libdir)/$(shlib)'
e n d i f # enable_shared
e l s e # no soname
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'
e n d i f # no soname
##
@ -447,10 +538,7 @@ endif # enable_shared
.PHONY : clean -lib
clean-lib :
rm -f lib$( NAME) .a
i f e q ( $( enable_shared ) , y e s )
rm -f $( shlib_bare) $( shlib_major) $( shlib) $( exports_file)
e n d i f
rm -f $( shlib) $( shlib_bare) $( shlib_major) $( stlib) $( exports_file)
i f n e q ( , $( SHLIB_EXPORTS ) )
maintainer-clean-lib :