Commit 6707ede8 authored by Peter Eisentraut's avatar Peter Eisentraut

Make use of system-specific linker option to embed shared library search

path into executables and shared libraries (-rpath or -R for most).  Can be
disabled with --disable-rpath, since some binary packaging standards do not
like this option.
parent 81024e7d
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -234,6 +234,13 @@ PGAC_ARG_BOOL(enable, shared, yes, ...@@ -234,6 +234,13 @@ PGAC_ARG_BOOL(enable, shared, yes,
[ --disable-shared do not build shared libraries]) [ --disable-shared do not build shared libraries])
AC_SUBST(enable_shared) AC_SUBST(enable_shared)
#
# '-rpath'-like feature can be disabled
#
PGAC_ARG_BOOL(enable, rpath, yes,
[ --disable-rpath do not embed shared library search path in executables])
AC_SUBST(enable_rpath)
# #
# C compiler # C compiler
......
# -*-makefile-*- # -*-makefile-*-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.105 2000/10/25 16:13:52 petere Exp $ # $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.106 2000/10/27 23:59:39 petere Exp $
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets, # All PostgreSQL makefiles include this file and use the variables it sets,
...@@ -115,6 +115,7 @@ with_tk = @with_tk@ ...@@ -115,6 +115,7 @@ with_tk = @with_tk@
enable_odbc = @enable_odbc@ enable_odbc = @enable_odbc@
MULTIBYTE = @MULTIBYTE@ MULTIBYTE = @MULTIBYTE@
enable_shared = @enable_shared@ enable_shared = @enable_shared@
enable_rpath = @enable_rpath@
python_extmakefile = @python_extmakefile@ python_extmakefile = @python_extmakefile@
python_moduledir = @python_moduledir@ python_moduledir = @python_moduledir@
...@@ -213,6 +214,9 @@ ELF_SYSTEM= @ELF_SYS@ ...@@ -213,6 +214,9 @@ ELF_SYSTEM= @ELF_SYS@
# Pull in platform-specific magic # Pull in platform-specific magic
include $(top_builddir)/src/Makefile.port include $(top_builddir)/src/Makefile.port
ifeq ($(enable_rpath), yes)
LDFLAGS += $(rpath)
endif
########################################################################## ##########################################################################
# #
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California # Copyright (c) 1998, Regents of the University of California
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.29 2000/10/27 20:09:48 petere Exp $ # $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.30 2000/10/27 23:59:39 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -137,9 +137,6 @@ ifeq ($(PORTNAME), netbsd) ...@@ -137,9 +137,6 @@ ifeq ($(PORTNAME), netbsd)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
LINK.shared = $(COMPILER) -shared -Wl,-soname -Wl,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-soname -Wl,$(soname)
ifneq ($(SHLIB_LINK),)
LINK.shared += -Wl,-R$(libdir)
endif
else else
LINK.shared = $(LD) -x -Bshareable -Bforcearchive LINK.shared = $(LD) -x -Bshareable -Bforcearchive
endif endif
...@@ -148,12 +145,12 @@ endif ...@@ -148,12 +145,12 @@ endif
ifeq ($(PORTNAME), hpux) ifeq ($(PORTNAME), hpux)
# HPUX doesn't believe in version numbers for shlibs # HPUX doesn't believe in version numbers for shlibs
shlib := lib$(NAME)$(DLSUFFIX) shlib := lib$(NAME)$(DLSUFFIX)
LINK.shared = $(LD) -b LINK.shared = $(LD) -b +b $(libdir)
endif endif
ifeq ($(PORTNAME), irix5) ifeq ($(PORTNAME), irix5)
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
LINK.shared := $(COMPILER) -shared -rpath $(libdir) -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) LINK.shared = $(COMPILER) -shared -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
endif endif
ifeq ($(PORTNAME), linux) ifeq ($(PORTNAME), linux)
...@@ -197,6 +194,7 @@ ifeq ($(PORTNAME), unixware) ...@@ -197,6 +194,7 @@ ifeq ($(PORTNAME), unixware)
LINK.shared = $(CXX) -G LINK.shared = $(CXX) -G
endif endif
endif endif
LINK.shared += -Wl,-z,text
endif endif
ifeq ($(PORTNAME), win) ifeq ($(PORTNAME), win)
...@@ -215,6 +213,10 @@ endif ...@@ -215,6 +213,10 @@ endif
# Pull in any extra -L options that the user might have specified. # Pull in any extra -L options that the user might have specified.
SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK) SHLIB_LINK := $(filter -L%, $(LDFLAGS)) $(SHLIB_LINK)
ifeq ($(enable_rpath), yes)
SHLIB_LINK += $(rpath)
endif
endif # enable_shared endif # enable_shared
......
...@@ -2,6 +2,7 @@ AROPT = cq ...@@ -2,6 +2,7 @@ AROPT = cq
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
export_dynamic = -export-dynamic export_dynamic = -export-dynamic
rpath = -R$(libdir)
endif endif
DLSUFFIX = .so DLSUFFIX = .so
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
# which we do by linking -lc before -lcurses. (Unfortunately we can't # which we do by linking -lc before -lcurses. (Unfortunately we can't
# just not use libcurses.) This also ensures that we get the POSIX signal # just not use libcurses.) This also ensures that we get the POSIX signal
# routines in libc, not the BSD-like ones in libBSD. # routines in libc, not the BSD-like ones in libBSD.
LDFLAGS:= -lc $(LDFLAGS) LIBS := -lc $(LIBS)
# On the other hand, if we don't have POSIX signals, we need to use the # On the other hand, if we don't have POSIX signals, we need to use the
# libBSD signal routines. (HPUX 9 and early HPUX 10 releases don't have # libBSD signal routines. (HPUX 9 and early HPUX 10 releases don't have
# POSIX signals.) Make sure libBSD comes before libc in that case. # POSIX signals.) Make sure libBSD comes before libc in that case.
ifeq ($(HAVE_POSIX_SIGNALS), no) ifeq ($(HAVE_POSIX_SIGNALS), no)
LDFLAGS:= -lBSD $(LDFLAGS) LIBS := -lBSD $(LIBS)
endif endif
# On HPUX 9, rint() is provided only in the PA1.1 version of libm. # On HPUX 9, rint() is provided only in the PA1.1 version of libm.
...@@ -19,11 +19,15 @@ ifneq ($(HPUXMATHLIB),) ...@@ -19,11 +19,15 @@ ifneq ($(HPUXMATHLIB),)
LDFLAGS:= -L /lib/pa1.1 $(LDFLAGS) LDFLAGS:= -L /lib/pa1.1 $(LDFLAGS)
endif endif
# On all HPUX versions, embed `libdir' as the shared library search path # Embed 'libdir' as the shared library search path so that the executables
# so that the executables don't need SHLIB_PATH to be set, specify -z # don't need SHLIB_PATH to be set. (We do not observe the --enable-rpath
# to catch null pointer dereferences, and specify -E to make all symbols # switch here because you'd get rather bizarre behavior if you leave this
# visible to dynamically linked shared libraries. # option off.)
LDFLAGS+= -Wl,+b -Wl,$(libdir) -Wl,-z LDFLAGS += -Wl,+b -Wl,$(libdir)
# catch null pointer dereferences
LDFLAGS += -Wl,-z
export_dynamic = -Wl,-E export_dynamic = -Wl,-E
AROPT = crs AROPT = crs
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
RANLIB= touch RANLIB= touch
MK_NO_LORDER= true MK_NO_LORDER= true
AROPT = crs AROPT = crs
rpath = -Wl,-rpath,$(libdir)
DLSUFFIX = .so DLSUFFIX = .so
CFLAGS_SL = CFLAGS_SL =
......
AROPT = crs AROPT = crs
export_dynamic = -export-dynamic export_dynamic = -export-dynamic
rpath = -Wl,-rpath,$(libdir)
DLSUFFIX = .so DLSUFFIX = .so
CFLAGS_SL = -fpic CFLAGS_SL = -fpic
......
...@@ -2,6 +2,7 @@ AROPT = cq ...@@ -2,6 +2,7 @@ AROPT = cq
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
export_dynamic = -Wl,-E export_dynamic = -Wl,-E
rpath = -Wl,-R$(libdir)
endif endif
DLSUFFIX = .so DLSUFFIX = .so
......
...@@ -2,6 +2,7 @@ AROPT = cq ...@@ -2,6 +2,7 @@ AROPT = cq
ifdef ELF_SYSTEM ifdef ELF_SYSTEM
export_dynamic = -Wl,-E export_dynamic = -Wl,-E
rpath = -R$(libdir)
endif endif
DLSUFFIX = .so DLSUFFIX = .so
......
AROPT = crs AROPT = crs
DLSUFFIX = .so DLSUFFIX = .so
CFLAGS_SL = CFLAGS_SL =
rpath = -rpath $(libdir)
%.so: %.o %.so: %.o
$(LD) -shared -expect_unresolved '*' -o $@ $< $(LD) -shared -expect_unresolved '*' -o $@ $<
LDFLAGS += -rpath $(libdir)
# $Header: /cvsroot/pgsql/src/makefiles/Makefile.solaris,v 1.3 2000/10/21 22:36:13 petere Exp $ # $Header: /cvsroot/pgsql/src/makefiles/Makefile.solaris,v 1.4 2000/10/27 23:59:39 petere Exp $
AROPT = crs AROPT = crs
ifeq ($(with_gnu_ld), yes) ifeq ($(with_gnu_ld), yes)
export_dynamic = -Wl,-E export_dynamic = -Wl,-E
rpath = -Wl,-rpath,$(libdir)
else
rpath = -Wl,-R$(libdir)
endif endif
DLSUFFIX = .so DLSUFFIX = .so
ifeq ($(GCC), yes) ifeq ($(GCC), yes)
CFLAGS_SL = -fPIC CFLAGS_SL = -fPIC
......
AROPT = crs AROPT = crs
export_dynamic = -Wl,-Bexport export_dynamic = -Wl,-Bexport
rpath = -Wl,-R$(libdir)
DLSUFFIX = .so DLSUFFIX = .so
ifeq ($(GCC), yes) ifeq ($(GCC), yes)
CFLAGS_SL = -fpic CFLAGS_SL = -fpic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment