1998-10-19 02:00:51 +02:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Makefile.shlib
|
|
|
|
# Common rules for building shared libraries
|
|
|
|
#
|
|
|
|
# Copyright (c) 1998, Regents of the University of California
|
|
|
|
#
|
|
|
|
# IDENTIFICATION
|
2010-09-20 22:08:53 +02:00
|
|
|
# src/Makefile.shlib
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
# This file should be included by any Postgres module Makefile that
|
|
|
|
# wants to build a shared library (if possible for the current
|
|
|
|
# platform). A static library is also built from the same object
|
|
|
|
# files. Only one library can be built per makefile.
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
2000-06-28 20:30:16 +02:00
|
|
|
# Before including this file, the module Makefile must define these
|
|
|
|
# variables:
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
2000-06-28 20:30:16 +02:00
|
|
|
# NAME Name of library to build (no suffix nor "lib" prefix)
|
|
|
|
# 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
|
2010-11-12 21:15:16 +01:00
|
|
|
# SHLIB_PREREQS Order-only prerequisites for library build target
|
2008-02-26 07:41:24 +01:00
|
|
|
# SHLIB_EXPORTS (optional) Name of file containing list of symbols to
|
2009-08-27 19:55:53 +02:00
|
|
|
# export, in the format "function_name number"
|
2008-04-07 16:15:58 +02:00
|
|
|
#
|
|
|
|
# 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
|
2000-06-28 20:30:16 +02:00
|
|
|
# (If you want a patchlevel, include it in SO_MINOR_VERSION, e.g., "6.2".)
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
2000-06-28 20:30:16 +02:00
|
|
|
# The module Makefile must also include
|
|
|
|
# $(top_builddir)/src/Makefile.global before including this file.
|
|
|
|
# (Makefile.global sets PORTNAME and other needed symbols.)
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
2000-06-28 20:30:16 +02:00
|
|
|
# This makefile provides the following (phony) targets:
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
2000-06-28 20:30:16 +02:00
|
|
|
# all-lib build the static and shared (if applicable) libraries
|
|
|
|
# install-lib install the libraries into $(libdir)
|
2008-04-07 16:15:58 +02:00
|
|
|
# installdirs-lib create installation directory $(libdir)
|
2000-06-28 20:30:16 +02:00
|
|
|
# uninstall-lib remove the libraries from $(libdir)
|
|
|
|
# clean-lib delete the static and shared libraries from the build dir
|
2008-02-26 07:41:24 +01:00
|
|
|
# maintainer-clean-lib delete .def files built for win32
|
1998-10-19 02:00:51 +02:00
|
|
|
#
|
2016-10-01 19:45:16 +02:00
|
|
|
# Typically you would add `all-lib' to the `all' target so that `make all'
|
|
|
|
# builds the libraries. In the most simple case it would look like this:
|
2000-06-28 20:30:16 +02:00
|
|
|
#
|
|
|
|
# all: all-lib
|
|
|
|
#
|
|
|
|
# Similarly, the install rule might look like
|
|
|
|
#
|
|
|
|
# install: install-lib
|
|
|
|
#
|
|
|
|
# plus any additional things you want to install. Et cetera.
|
|
|
|
#
|
|
|
|
# Got that? Look at src/interfaces/libpq/Makefile for an example.
|
2001-02-10 19:46:34 +01:00
|
|
|
#
|
|
|
|
# While the linker allows creation of most shared libraries,
|
|
|
|
# -Bsymbolic requires resolution of all symbols, making the
|
|
|
|
# compiler a better choice for shared library creation on ELF platforms.
|
|
|
|
# With the linker, -Bsymbolic requires the crt1.o startup object file.
|
|
|
|
# bjm 2001-02-10
|
|
|
|
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2000-10-31 20:55:20 +01:00
|
|
|
COMPILER = $(CC) $(CFLAGS)
|
2000-10-23 23:44:12 +02:00
|
|
|
LINK.static = $(AR) $(AROPT)
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
# Default library naming convention used by the majority of platforms
|
2004-07-13 02:06:46 +02:00
|
|
|
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
|
|
|
|
shlib_major = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
|
|
|
|
shlib_bare = lib$(NAME)$(DLSUFFIX)
|
2008-04-07 16:15:58 +02:00
|
|
|
# Testing the soname variable is a reliable way to determine whether a
|
|
|
|
# linkable library is being built.
|
|
|
|
soname = $(shlib_major)
|
2013-03-31 22:58:40 +02:00
|
|
|
pkgconfigdir = $(libdir)/pkgconfig
|
2008-04-07 16:15:58 +02:00
|
|
|
else
|
|
|
|
# Naming convention for dynamically loadable modules
|
|
|
|
shlib = $(NAME)$(DLSUFFIX)
|
|
|
|
endif
|
2008-04-08 01:08:15 +02:00
|
|
|
stlib = lib$(NAME).a
|
2008-04-07 16:15:58 +02:00
|
|
|
|
|
|
|
ifndef soname
|
|
|
|
# additional flags for backend modules
|
2010-07-05 20:54:38 +02:00
|
|
|
SHLIB_LINK += $(BE_DLLLIBS)
|
2008-04-07 16:15:58 +02:00
|
|
|
endif
|
2004-07-13 02:06:46 +02:00
|
|
|
|
2000-10-23 23:44:12 +02:00
|
|
|
# For each platform we support shared libraries on, set shlib to the
|
2004-07-13 02:06:46 +02:00
|
|
|
# name of the library (if default above is not right), set
|
|
|
|
# LINK.shared to the command to link the library,
|
2000-10-23 23:44:12 +02:00
|
|
|
# and adjust SHLIB_LINK if necessary.
|
1998-10-19 02:00:51 +02:00
|
|
|
|
1999-07-17 00:56:01 +02:00
|
|
|
# Try to keep the sections in some kind of order, folks...
|
1999-07-08 02:15:03 +02:00
|
|
|
|
2002-09-05 00:54:18 +02:00
|
|
|
override CFLAGS += $(CFLAGS_SL)
|
2008-12-11 08:34:09 +01:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
# libraries ought to use this to refer to versioned gettext domain names
|
|
|
|
override CPPFLAGS += -DSO_MAJOR_VERSION=$(SO_MAJOR_VERSION)
|
|
|
|
endif
|
2000-10-23 23:44:12 +02:00
|
|
|
|
1999-07-17 00:56:01 +02:00
|
|
|
ifeq ($(PORTNAME), aix)
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
|
|
|
|
endif
|
2006-09-19 17:36:08 +02:00
|
|
|
haslibarule = yes
|
2015-07-16 03:00:26 +02:00
|
|
|
# $(exports_file) is also usable as an import file
|
2008-02-26 11:45:24 +01:00
|
|
|
exports_file = lib$(NAME).exp
|
1998-10-31 04:58:55 +01:00
|
|
|
endif
|
|
|
|
|
2000-10-31 20:55:20 +01:00
|
|
|
ifeq ($(PORTNAME), darwin)
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef soname
|
2004-07-13 02:06:46 +02:00
|
|
|
# linkable library
|
2007-02-09 16:56:00 +01:00
|
|
|
DLSUFFIX = .dylib
|
2008-04-07 16:15:58 +02:00
|
|
|
ifneq ($(SO_MAJOR_VERSION), 0)
|
|
|
|
version_link = -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
|
|
|
|
endif
|
2011-06-16 03:45:23 +02:00
|
|
|
LINK.shared = $(COMPILER) -dynamiclib -install_name '$(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)' $(version_link) $(exported_symbols_list) -multiply_defined suppress
|
2008-04-07 16:15:58 +02:00
|
|
|
shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
|
|
|
|
shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
|
2004-07-13 02:06:46 +02:00
|
|
|
else
|
2008-04-07 16:15:58 +02:00
|
|
|
# loadable module
|
2007-02-09 16:56:00 +01:00
|
|
|
DLSUFFIX = .so
|
2016-10-06 05:03:55 +02:00
|
|
|
LINK.shared = $(COMPILER) -bundle -multiply_defined suppress
|
2004-07-13 02:06:46 +02:00
|
|
|
endif
|
2008-02-26 11:30:06 +01:00
|
|
|
BUILD.exports = $(AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
|
2008-02-26 11:45:24 +01:00
|
|
|
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
|
|
|
|
ifneq (,$(exports_file))
|
|
|
|
exported_symbols_list = -exported_symbols_list $(exports_file)
|
2008-02-26 07:41:24 +01:00
|
|
|
endif
|
2000-10-31 20:55:20 +01:00
|
|
|
endif
|
|
|
|
|
2000-10-10 23:22:29 +02:00
|
|
|
ifeq ($(PORTNAME), openbsd)
|
2000-10-23 23:44:12 +02:00
|
|
|
ifdef ELF_SYSTEM
|
2008-04-07 16:15:58 +02:00
|
|
|
LINK.shared = $(COMPILER) -shared
|
|
|
|
ifdef soname
|
|
|
|
LINK.shared += -Wl,-x,-soname,$(soname)
|
|
|
|
endif
|
2001-02-10 18:17:39 +01:00
|
|
|
SHLIB_LINK += -lc
|
2000-10-23 23:44:12 +02:00
|
|
|
else
|
|
|
|
LINK.shared = $(LD) -x -Bshareable -Bforcearchive
|
1998-10-19 02:00:51 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
1999-07-17 00:56:01 +02:00
|
|
|
ifeq ($(PORTNAME), freebsd)
|
2000-10-23 23:44:12 +02:00
|
|
|
ifdef ELF_SYSTEM
|
2008-04-07 16:15:58 +02:00
|
|
|
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
|
2000-10-23 23:44:12 +02:00
|
|
|
else
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
|
|
|
|
endif
|
2000-10-23 23:44:12 +02:00
|
|
|
LINK.shared = $(LD) -x -Bshareable -Bforcearchive
|
1999-07-17 00:56:01 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2000-03-08 02:58:46 +01:00
|
|
|
ifeq ($(PORTNAME), netbsd)
|
2000-10-23 23:44:12 +02:00
|
|
|
ifdef ELF_SYSTEM
|
2008-04-07 16:15:58 +02:00
|
|
|
LINK.shared = $(COMPILER) -shared
|
|
|
|
ifdef soname
|
|
|
|
LINK.shared += -Wl,-x,-soname,$(soname)
|
|
|
|
endif
|
2000-10-23 23:44:12 +02:00
|
|
|
else
|
|
|
|
LINK.shared = $(LD) -x -Bshareable -Bforcearchive
|
2000-03-08 02:58:46 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
1998-10-19 02:00:51 +02:00
|
|
|
ifeq ($(PORTNAME), hpux)
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
|
|
|
|
endif
|
2004-09-03 01:06:43 +02:00
|
|
|
ifeq ($(with_gnu_ld), yes)
|
2010-07-05 20:54:38 +02:00
|
|
|
LINK.shared = $(CC) -shared
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef soname
|
|
|
|
LINK.shared += -Wl,-h -Wl,$(soname)
|
|
|
|
endif
|
2004-09-03 01:06:43 +02:00
|
|
|
else
|
2008-04-07 16:15:58 +02:00
|
|
|
LINK.shared = $(LD) -b
|
|
|
|
ifdef soname
|
|
|
|
LINK.shared += +h $(soname)
|
|
|
|
endif
|
2010-07-05 20:54:38 +02:00
|
|
|
# can't use the CC-syntax rpath pattern here, so instead:
|
|
|
|
rpath =
|
2004-11-19 22:27:42 +01:00
|
|
|
ifeq ($(enable_rpath), yes)
|
Fix cross-shlib linking in temporary installs on HPUX 10.
Turns out this has been broken for years and we'd not noticed. The one
case that was getting exercised in the buildfarm, or probably anywhere
else, was postgres_fdw.sl's reference to libpq.sl; and it turns out that
that was always going to libpq.sl in the actual installation directory
not the temporary install. We'd not noticed because the buildfarm script
does "make install" before it tests contrib. However, the recent addition
of a logical-replication test to the core regression scripts resulted in
trying to use libpqwalreceiver.sl before "make install" happens, and that
failed for lack of finding libpq.sl, as shown by failures on buildfarm
members gaur and pademelon.
There are two changes needed to fix it: the magic environment variable to
specify shlib search path at runtime is SHLIB_PATH not LD_LIBRARY_PATH,
and the shlib link command needs to specify the +s switch else the library
will not honor SHLIB_PATH.
I'm not quite sure why buildfarm members anole and gharial (HPUX 11) didn't
show the same failure. Consulting man pages on the web says that HPUX 11
honors both LD_LIBRARY_PATH and SHLIB_PATH, which would explain half of it,
and the rather confusing wording I've been able to find suggests that +s
might effectively be the default in HPUX 11. But it seems at least as
likely that there's just a libpq.so installed in /usr/lib on that machine;
as long as it's not too ancient, that would satisfy the test. In any case
I do not think this patch will break HPUX 11.
At the moment I don't see a need to back-patch this, since it only matters
for testing purposes, not to mention that HPUX 10 is probably dead in the
real world anyway.
2017-01-21 21:15:39 +01:00
|
|
|
LINK.shared += +s +b '$(rpathdir)'
|
2004-11-19 22:27:42 +01:00
|
|
|
endif
|
2005-07-13 01:06:48 +02:00
|
|
|
# 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
|
|
|
|
# ld can find the same libraries gcc does. Make sure it goes after any
|
|
|
|
# -L switches provided explicitly.
|
|
|
|
ifeq ($(GCC), yes)
|
2010-07-05 20:54:38 +02:00
|
|
|
SHLIB_LINK += -L/usr/local/lib
|
2005-07-13 01:06:48 +02:00
|
|
|
endif
|
2004-09-03 01:06:43 +02:00
|
|
|
endif
|
2010-07-05 20:54:38 +02:00
|
|
|
# And we need to link with libgcc, too
|
2005-07-13 19:00:44 +02:00
|
|
|
ifeq ($(GCC), yes)
|
|
|
|
SHLIB_LINK += `$(CC) $(LDFLAGS) -print-libgcc-file-name`
|
|
|
|
endif
|
1998-10-19 02:00:51 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(PORTNAME), linux)
|
2008-04-07 16:15:58 +02:00
|
|
|
LINK.shared = $(COMPILER) -shared
|
|
|
|
ifdef soname
|
|
|
|
LINK.shared += -Wl,-soname,$(soname)
|
|
|
|
endif
|
2008-02-26 07:41:24 +01:00
|
|
|
BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
|
2008-02-26 11:45:24 +01:00
|
|
|
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
|
|
|
|
ifneq (,$(exports_file))
|
|
|
|
LINK.shared += -Wl,--version-script=$(exports_file)
|
2008-02-26 07:41:24 +01:00
|
|
|
endif
|
1998-10-19 02:00:51 +02:00
|
|
|
endif
|
|
|
|
|
2000-10-10 23:22:29 +02:00
|
|
|
ifeq ($(PORTNAME), solaris)
|
2002-09-05 00:54:18 +02:00
|
|
|
ifeq ($(GCC), yes)
|
2008-09-01 10:50:10 +02:00
|
|
|
LINK.shared = $(COMPILER) -shared
|
2001-09-12 01:20:41 +02:00
|
|
|
else
|
2008-09-01 10:50:10 +02:00
|
|
|
LINK.shared = $(COMPILER) -G
|
2001-09-12 01:20:41 +02:00
|
|
|
endif
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef soname
|
|
|
|
ifeq ($(with_gnu_ld), yes)
|
|
|
|
LINK.shared += -Wl,-soname,$(soname)
|
|
|
|
else
|
|
|
|
LINK.shared += -h $(soname)
|
|
|
|
endif
|
2000-11-08 21:18:49 +01:00
|
|
|
endif
|
1998-10-19 02:00:51 +02:00
|
|
|
endif
|
|
|
|
|
2003-03-21 18:18:34 +01:00
|
|
|
ifeq ($(PORTNAME), cygwin)
|
2014-02-01 22:08:33 +01:00
|
|
|
LINK.shared = $(CC) -shared
|
2008-04-08 11:50:29 +02:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
shlib = cyg$(NAME)$(DLSUFFIX)
|
|
|
|
endif
|
2004-11-16 22:51:13 +01:00
|
|
|
haslibarule = yes
|
1999-01-17 07:20:06 +01:00
|
|
|
endif
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2003-12-01 23:23:06 +01:00
|
|
|
ifeq ($(PORTNAME), win32)
|
2008-04-08 11:50:29 +02:00
|
|
|
ifdef SO_MAJOR_VERSION
|
|
|
|
shlib = lib$(NAME)$(DLSUFFIX)
|
|
|
|
endif
|
2004-11-16 22:51:13 +01:00
|
|
|
haslibarule = yes
|
2003-12-01 23:23:06 +01:00
|
|
|
endif
|
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
## BUILD
|
|
|
|
##
|
|
|
|
|
2002-09-04 17:45:50 +02:00
|
|
|
.PHONY: all-lib all-static-lib all-shared-lib
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
all-lib: all-shared-lib
|
|
|
|
ifdef soname
|
|
|
|
# no static library when building a dynamically loadable module
|
|
|
|
all-lib: all-static-lib
|
2013-03-31 22:58:40 +02:00
|
|
|
all-lib: lib$(NAME).pc
|
2008-04-07 16:15:58 +02:00
|
|
|
endif
|
2002-09-04 17:45:50 +02:00
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
all-static-lib: $(stlib)
|
2002-09-04 17:45:50 +02:00
|
|
|
|
2004-11-20 22:13:06 +01:00
|
|
|
all-shared-lib: $(shlib)
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2004-11-16 22:51:13 +01:00
|
|
|
ifndef haslibarule
|
2010-11-12 21:15:16 +01:00
|
|
|
$(stlib): $(OBJS) | $(SHLIB_PREREQS)
|
2015-03-01 19:05:23 +01:00
|
|
|
rm -f $@
|
2000-10-23 23:44:12 +02:00
|
|
|
$(LINK.static) $@ $^
|
1998-10-19 02:00:51 +02:00
|
|
|
$(RANLIB) $@
|
2004-11-16 22:51:13 +01:00
|
|
|
endif #haslibarule
|
1999-07-17 00:56:01 +02:00
|
|
|
|
2000-10-23 23:44:12 +02:00
|
|
|
|
2008-02-26 11:45:24 +01:00
|
|
|
ifeq (,$(filter cygwin win32,$(PORTNAME)))
|
1999-07-17 00:56:01 +02:00
|
|
|
ifneq ($(PORTNAME), aix)
|
1999-07-01 01:54:18 +02:00
|
|
|
|
1999-07-17 00:56:01 +02:00
|
|
|
# Normal case
|
2010-11-12 21:15:16 +01:00
|
|
|
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
|
2010-07-06 05:55:33 +02:00
|
|
|
$(LINK.shared) -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK)
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef shlib_major
|
2000-06-28 20:30:16 +02:00
|
|
|
# If we're using major and minor versions, then make a symlink to major-version-only.
|
2004-07-13 02:06:46 +02:00
|
|
|
ifneq ($(shlib), $(shlib_major))
|
|
|
|
rm -f $(shlib_major)
|
|
|
|
$(LN_S) $(shlib) $(shlib_major)
|
2000-06-28 20:30:16 +02:00
|
|
|
endif
|
|
|
|
# Make sure we have a link to a name without any version numbers
|
2004-07-13 02:06:46 +02:00
|
|
|
ifneq ($(shlib), $(shlib_bare))
|
|
|
|
rm -f $(shlib_bare)
|
|
|
|
$(LN_S) $(shlib) $(shlib_bare)
|
2000-06-28 20:30:16 +02:00
|
|
|
endif
|
2008-04-07 16:15:58 +02:00
|
|
|
endif # shlib_major
|
1999-07-01 01:54:18 +02:00
|
|
|
|
2008-02-26 07:41:24 +01:00
|
|
|
# Where possible, restrict the symbols exported by the library to just the
|
Refer to OS X as "macOS", except for the port name which is still "darwin".
We weren't terribly consistent about whether to call Apple's OS "OS X"
or "Mac OS X", and the former is probably confusing to people who aren't
Apple users. Now that Apple has rebranded it "macOS", follow their lead
to establish a consistent naming pattern. Also, avoid the use of the
ancient project name "Darwin", except as the port code name which does not
seem desirable to change. (In short, this patch touches documentation and
comments, but no actual code.)
I didn't touch contrib/start-scripts/osx/, either. I suspect those are
obsolete and due for a rewrite, anyway.
I dithered about whether to apply this edit to old release notes, but
those were responsible for quite a lot of the inconsistencies, so I ended
up changing them too. Anyway, Apple's being ahistorical about this,
so why shouldn't we be?
2016-09-25 21:40:57 +02:00
|
|
|
# official list, so as to avoid unintentional ABI changes. On recent macOS
|
2008-02-26 07:41:24 +01:00
|
|
|
# this also quiets multiply-defined-symbol warnings in programs that use
|
|
|
|
# libpgport along with libpq.
|
|
|
|
ifneq (,$(SHLIB_EXPORTS))
|
|
|
|
ifdef BUILD.exports
|
|
|
|
$(shlib): $(SHLIB_EXPORTS:%.txt=%.list)
|
|
|
|
|
|
|
|
$(SHLIB_EXPORTS:%.txt=%.list): %.list: %.txt
|
|
|
|
$(BUILD.exports)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
else # PORTNAME == aix
|
1999-07-01 01:54:18 +02:00
|
|
|
|
1999-07-17 00:56:01 +02:00
|
|
|
# AIX case
|
2016-07-24 02:30:03 +02:00
|
|
|
|
|
|
|
# There is no correct way to write a rule that generates two files.
|
|
|
|
# Rules with two targets don't have that meaning, they are merely
|
|
|
|
# shorthand for two otherwise separate rules. To be safe for parallel
|
|
|
|
# make, we must chain the dependencies like this. The semicolon is
|
|
|
|
# important, otherwise make will choose some built-in rule.
|
|
|
|
|
|
|
|
$(stlib): $(shlib) ;
|
|
|
|
|
|
|
|
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
|
2015-03-01 19:05:23 +01:00
|
|
|
rm -f $(stlib)
|
2008-04-07 16:15:58 +02:00
|
|
|
$(LINK.static) $(stlib) $^
|
|
|
|
$(RANLIB) $(stlib)
|
2015-07-16 03:00:26 +02:00
|
|
|
$(MKLDEXPORT) $(stlib) $(shlib) >$(exports_file)
|
2010-07-06 05:55:33 +02:00
|
|
|
$(COMPILER) -o $(shlib) $(stlib) -Wl,-bE:$(exports_file) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK)
|
2008-04-07 16:15:58 +02:00
|
|
|
rm -f $(stlib)
|
|
|
|
$(AR) $(AROPT) $(stlib) $(shlib)
|
2008-02-26 07:41:24 +01:00
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
endif # PORTNAME == aix
|
1999-07-17 00:56:01 +02:00
|
|
|
|
2008-02-26 11:45:24 +01:00
|
|
|
else # PORTNAME == cygwin || PORTNAME == win32
|
1999-07-17 00:56:01 +02:00
|
|
|
|
2014-02-01 22:08:33 +01:00
|
|
|
ifeq ($(PORTNAME), cygwin)
|
2014-02-11 18:56:20 +01:00
|
|
|
|
|
|
|
# Cygwin case
|
|
|
|
|
2014-02-01 22:08:33 +01:00
|
|
|
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
|
|
|
|
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) $(LDAP_LIBS_BE)
|
|
|
|
|
|
|
|
$(stlib): $(OBJS) | $(SHLIB_PREREQS)
|
2015-03-01 19:05:23 +01:00
|
|
|
rm -f $@
|
2014-02-01 22:08:33 +01:00
|
|
|
$(LINK.static) $@ $^
|
|
|
|
$(RANLIB) $@
|
|
|
|
|
|
|
|
else
|
2000-10-07 16:39:21 +02:00
|
|
|
|
2014-02-11 18:56:20 +01:00
|
|
|
# Win32 case
|
|
|
|
|
|
|
|
# There is no correct way to write a rule that generates two files.
|
|
|
|
# Rules with two targets don't have that meaning, they are merely
|
|
|
|
# shorthand for two otherwise separate rules. To be safe for parallel
|
|
|
|
# make, we must chain the dependencies like this. The semicolon is
|
|
|
|
# important, otherwise make will choose some built-in rule.
|
|
|
|
|
|
|
|
$(stlib): $(shlib) ;
|
|
|
|
|
2014-10-22 04:55:47 +02:00
|
|
|
# XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
|
|
|
|
# uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers
|
|
|
|
# from i686-4.9.1-release-win32-dwarf-rt_v3-rev1.) Shared libgcc has better
|
|
|
|
# support for C++/Java exceptions; while core PostgreSQL does not use them, it
|
|
|
|
# would be nice to support shared libgcc for the benefit of extensions.
|
|
|
|
#
|
2014-02-11 18:56:20 +01:00
|
|
|
# If SHLIB_EXPORTS is set, the rules below will build a .def file from that.
|
|
|
|
# Else we just use --export-all-symbols.
|
|
|
|
ifeq (,$(SHLIB_EXPORTS))
|
|
|
|
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
|
2014-10-22 04:55:47 +02:00
|
|
|
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
|
2009-01-05 10:27:20 +01:00
|
|
|
else
|
2009-08-28 22:26:19 +02:00
|
|
|
DLL_DEFFILE = lib$(NAME)dll.def
|
2008-02-26 07:41:24 +01:00
|
|
|
|
2010-11-12 21:15:16 +01:00
|
|
|
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
|
2014-10-22 04:55:47 +02:00
|
|
|
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
|
2014-02-11 18:56:20 +01:00
|
|
|
endif
|
2000-10-07 16:39:21 +02:00
|
|
|
|
2017-02-06 10:33:58 +01:00
|
|
|
endif # PORTNAME == cygwin
|
2008-02-26 11:45:24 +01:00
|
|
|
endif # PORTNAME == cygwin || PORTNAME == win32
|
2000-10-23 23:44:12 +02:00
|
|
|
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2013-03-31 22:58:40 +02:00
|
|
|
%.pc: $(MAKEFILE_LIST)
|
|
|
|
echo 'Name: lib$(NAME)' >$@
|
|
|
|
echo 'Description: PostgreSQL lib$(NAME) library' >>$@
|
|
|
|
echo 'Url: http://www.postgresql.org/' >>$@
|
|
|
|
echo 'Version: $(VERSION)' >>$@
|
|
|
|
echo 'Requires: ' >>$@
|
|
|
|
echo 'Requires.private: $(PKG_CONFIG_REQUIRES_PRIVATE)' >>$@
|
|
|
|
echo 'Cflags: -I$(includedir)' >>$@
|
|
|
|
echo 'Libs: -L$(libdir) -l$(NAME)' >>$@
|
|
|
|
# Record -L flags that the user might have passed in to the PostgreSQL
|
|
|
|
# build to locate third-party libraries (e.g., ldap, ssl). Filter out
|
|
|
|
# those that point inside the build or source tree. Use sort to
|
|
|
|
# remove duplicates. Also record the -l flags necessary for static
|
|
|
|
# linking, but not those already covered by Requires.private.
|
|
|
|
echo 'Libs.private: $(sort $(filter-out -L.% -L$(top_srcdir)/%,$(filter -L%,$(LDFLAGS) $(SHLIB_LINK)))) $(filter-out $(PKG_CONFIG_REQUIRES_PRIVATE:lib%=-l%),$(filter -l%,$(SHLIB_LINK)))' >>$@
|
|
|
|
|
|
|
|
|
2008-02-26 07:41:24 +01:00
|
|
|
# We need several not-quite-identical variants of .DEF files to build
|
|
|
|
# DLLs for Windows. These are made from the single source file
|
|
|
|
# exports.txt. Since we can't assume that Windows boxes will have
|
|
|
|
# sed, the .DEF files are always built and included in distribution
|
|
|
|
# tarballs.
|
|
|
|
|
|
|
|
ifneq (,$(SHLIB_EXPORTS))
|
2017-04-11 15:14:26 +02:00
|
|
|
distprep: lib$(NAME)dll.def lib$(NAME)ddll.def
|
2008-02-26 07:41:24 +01:00
|
|
|
|
|
|
|
UC_NAME = $(shell echo $(NAME) | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
|
|
|
|
2009-08-28 22:26:19 +02:00
|
|
|
lib$(NAME)dll.def: $(SHLIB_EXPORTS)
|
2017-04-11 15:14:26 +02:00
|
|
|
echo '; DEF file for Makefile.shlib (MinGW)' >$@
|
MinGW: Include .dll extension in .def file LIBRARY commands.
Newer toolchains append the extension implicitly if missing, but
buildfarm member narwhal (gcc 3.4.2, ld 2.15.91 20040904) does not.
This affects most core libraries having an exports.txt file, namely
libpq and the ECPG support libraries. On Windows Server 2003, Windows
API functions that load and unload DLLs internally will mistakenly
unload a libpq whose DLL header reports "LIBPQ" instead of "LIBPQ.dll".
When, subsequently, control would return to libpq, the backend crashes.
Back-patch to 9.4, like commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027.
Before that commit, we used a different linking technique that yielded
"libpq.dll" in the DLL header.
Commit 53566fc0940cf557416b13252df57350a4511ce4 worked around this by
eliminating a call to a function that loads and unloads DLLs internally.
That commit is no longer necessary for correctness, but its improving
consistency with the MSVC build remains valid.
2014-10-28 00:59:39 +01:00
|
|
|
echo 'LIBRARY LIB$(UC_NAME).dll' >>$@
|
2008-02-26 07:41:24 +01:00
|
|
|
echo 'EXPORTS' >>$@
|
2009-08-27 19:55:53 +02:00
|
|
|
sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
|
2008-02-26 07:41:24 +01:00
|
|
|
|
2009-08-28 22:26:19 +02:00
|
|
|
lib$(NAME)ddll.def: $(SHLIB_EXPORTS)
|
2017-04-11 15:14:26 +02:00
|
|
|
echo '; DEF file for Makefile.shlib (MinGW)' >$@
|
MinGW: Include .dll extension in .def file LIBRARY commands.
Newer toolchains append the extension implicitly if missing, but
buildfarm member narwhal (gcc 3.4.2, ld 2.15.91 20040904) does not.
This affects most core libraries having an exports.txt file, namely
libpq and the ECPG support libraries. On Windows Server 2003, Windows
API functions that load and unload DLLs internally will mistakenly
unload a libpq whose DLL header reports "LIBPQ" instead of "LIBPQ.dll".
When, subsequently, control would return to libpq, the backend crashes.
Back-patch to 9.4, like commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027.
Before that commit, we used a different linking technique that yielded
"libpq.dll" in the DLL header.
Commit 53566fc0940cf557416b13252df57350a4511ce4 worked around this by
eliminating a call to a function that loads and unloads DLLs internally.
That commit is no longer necessary for correctness, but its improving
consistency with the MSVC build remains valid.
2014-10-28 00:59:39 +01:00
|
|
|
echo 'LIBRARY LIB$(UC_NAME)D.dll' >>$@
|
2008-02-26 07:41:24 +01:00
|
|
|
echo 'EXPORTS' >>$@
|
2009-08-27 19:55:53 +02:00
|
|
|
sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
|
2008-02-26 07:41:24 +01:00
|
|
|
|
|
|
|
endif # SHLIB_EXPORTS
|
|
|
|
|
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
##
|
|
|
|
## INSTALL
|
|
|
|
##
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
.PHONY: install-lib install-lib-static install-lib-shared installdirs-lib
|
|
|
|
install-lib: install-lib-shared
|
|
|
|
ifdef soname
|
|
|
|
install-lib: install-lib-static
|
2013-03-31 22:58:40 +02:00
|
|
|
install-lib: install-lib-pc
|
2008-04-07 16:15:58 +02:00
|
|
|
endif
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2013-03-31 22:58:40 +02:00
|
|
|
install-lib-pc: lib$(NAME).pc installdirs-lib
|
|
|
|
$(INSTALL_DATA) $< '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
install-lib-static: $(stlib) installdirs-lib
|
|
|
|
$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
|
2003-09-20 23:26:20 +02:00
|
|
|
ifeq ($(PORTNAME), darwin)
|
2005-12-09 22:19:36 +01:00
|
|
|
cd '$(DESTDIR)$(libdir)' && \
|
2008-04-07 16:15:58 +02:00
|
|
|
ranlib $(stlib)
|
2003-09-20 23:26:20 +02:00
|
|
|
endif
|
1998-10-19 02:00:51 +02:00
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
install-lib-shared: $(shlib) installdirs-lib
|
|
|
|
ifdef soname
|
2007-01-07 09:49:31 +01:00
|
|
|
# we don't install $(shlib) on AIX
|
2008-11-24 12:59:37 +01:00
|
|
|
# (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at)
|
2007-01-07 09:49:31 +01:00
|
|
|
ifneq ($(PORTNAME), aix)
|
2005-12-09 22:19:36 +01:00
|
|
|
$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
|
2003-03-21 18:18:34 +01:00
|
|
|
ifneq ($(PORTNAME), cygwin)
|
2003-12-01 23:23:06 +01:00
|
|
|
ifneq ($(PORTNAME), win32)
|
2004-07-13 02:06:46 +02:00
|
|
|
ifneq ($(shlib), $(shlib_major))
|
2005-12-09 22:19:36 +01:00
|
|
|
cd '$(DESTDIR)$(libdir)' && \
|
2004-07-13 02:06:46 +02:00
|
|
|
rm -f $(shlib_major) && \
|
|
|
|
$(LN_S) $(shlib) $(shlib_major)
|
1999-01-17 07:20:06 +01:00
|
|
|
endif
|
2004-07-13 02:06:46 +02:00
|
|
|
ifneq ($(shlib), $(shlib_bare))
|
2005-12-09 22:19:36 +01:00
|
|
|
cd '$(DESTDIR)$(libdir)' && \
|
2004-07-13 02:06:46 +02:00
|
|
|
rm -f $(shlib_bare) && \
|
|
|
|
$(LN_S) $(shlib) $(shlib_bare)
|
2000-06-28 20:30:16 +02:00
|
|
|
endif
|
2003-12-01 23:23:06 +01:00
|
|
|
endif # not win32
|
2003-03-21 18:18:34 +01:00
|
|
|
endif # not cygwin
|
2006-09-19 17:36:08 +02:00
|
|
|
endif # not aix
|
2015-01-19 04:36:40 +01:00
|
|
|
ifneq (,$(findstring $(PORTNAME),win32 cygwin))
|
|
|
|
$(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
|
|
|
|
endif
|
2008-04-07 16:15:58 +02:00
|
|
|
else # no soname
|
|
|
|
$(INSTALL_SHLIB) $< '$(DESTDIR)$(pkglibdir)/$(shlib)'
|
|
|
|
endif
|
2000-06-28 20:30:16 +02:00
|
|
|
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
installdirs-lib:
|
|
|
|
ifdef soname
|
2015-01-19 04:36:40 +01:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)' $(if $(findstring $(PORTNAME),win32 cygwin),'$(DESTDIR)$(bindir)')
|
2008-04-07 16:15:58 +02:00
|
|
|
else
|
2009-08-27 00:24:44 +02:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
|
2008-04-07 16:15:58 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
##
|
|
|
|
## UNINSTALL
|
|
|
|
##
|
|
|
|
|
|
|
|
.PHONY: uninstall-lib
|
|
|
|
uninstall-lib:
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef soname
|
|
|
|
rm -f '$(DESTDIR)$(libdir)/$(stlib)'
|
2005-12-09 22:19:36 +01:00
|
|
|
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
|
|
|
|
'$(DESTDIR)$(libdir)/$(shlib_major)' \
|
2015-01-19 04:36:40 +01:00
|
|
|
'$(DESTDIR)$(libdir)/$(shlib)' $(if $(findstring $(PORTNAME),win32 cygwin),'$(DESTDIR)$(bindir)/$(shlib)') \
|
2013-03-31 22:58:40 +02:00
|
|
|
'$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
|
2008-04-07 16:15:58 +02:00
|
|
|
else # no soname
|
|
|
|
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'
|
|
|
|
endif # no soname
|
1999-07-01 01:54:18 +02:00
|
|
|
|
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
##
|
|
|
|
## CLEAN
|
|
|
|
##
|
1999-07-01 01:54:18 +02:00
|
|
|
|
2000-06-28 20:30:16 +02:00
|
|
|
.PHONY: clean-lib
|
|
|
|
clean-lib:
|
2013-03-31 22:58:40 +02:00
|
|
|
rm -f $(shlib) $(shlib_bare) $(shlib_major) $(stlib) $(exports_file) lib$(NAME).pc
|
2008-02-26 07:41:24 +01:00
|
|
|
|
|
|
|
ifneq (,$(SHLIB_EXPORTS))
|
|
|
|
maintainer-clean-lib:
|
2017-04-11 15:14:26 +02:00
|
|
|
rm -f lib$(NAME)dll.def lib$(NAME)ddll.def
|
2008-02-26 07:41:24 +01:00
|
|
|
endif
|