Index: configure
===================================================================
--- configure	(revision 373814)
+++ configure	(working copy)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 373120 .
+# From configure.ac Revision: 373234 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.68 for asterisk trunk.
 #
@@ -664,6 +664,7 @@
 PBX_IP_MTU_DISCOVER
 PBX_GLOB_BRACE
 PBX_GLOB_NOMAGIC
+AST_RPATH
 AST_NESTED_FUNCTIONS
 AST_NATIVE_ARCH
 AST_SHADOW_WARNINGS
@@ -1275,6 +1276,7 @@
 enable_largefile
 enable_internal_poll
 enable_asteriskssl
+enable_rpath
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1921,6 +1923,7 @@
   --disable-largefile     omit support for large files
   --enable-internal-poll  Use Asterisk's poll implementation
   --disable-asteriskssl   Disable Asterisk's SSL wrapper library
+  --disable-rpath         Disables rpath linker option checking
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -16165,6 +16168,34 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
+# Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; case "${enableval}" in
+		y|ye|yes) check_rpath=yes ;;
+		n|no) check_rpath=no ;;
+                *) as_fn_error $? "bad value ${enableval} for --disable-rpath" "$LINENO" 5 ;;
+	esac
+else
+  check_rpath=yes
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use rpath" >&5
+$as_echo_n "checking whether to use rpath... " >&6; }
+AST_RPATH=
+if test "${check_rpath}" != yes; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5
+$as_echo "skipped" >&6; }
+elif test ${libdir} = /lib || test ${libdir} = /usr/lib; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed" >&5
+$as_echo "not needed" >&6; }
+else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: required" >&5
+$as_echo "required" >&6; }
+	AST_RPATH="-Wl,-rpath,${libdir}"
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysinfo" >&5
 $as_echo_n "checking for sysinfo... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
Index: main/Makefile
===================================================================
--- main/Makefile	(revision 373814)
+++ main/Makefile	(working copy)
@@ -54,7 +54,7 @@
 
 ifneq ($(findstring darwin,$(OSARCH)),)
   AST_LIBS+=-lresolv
-  ASTLINK=-Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
+  ASTLINK=-Xlinker -macosx_version_min -Xlinker 10.5 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
   ifeq ($(shell if test `/usr/bin/sw_vers -productVersion | cut -c4` -gt 5; then echo 6; else echo 0; fi),6)
     ASTLINK+=/usr/lib/bundle1.o
   endif
@@ -225,6 +225,9 @@
 else # Darwin
 ASTSSL_LIB:=libasteriskssl.dylib
 
+# -install_name allows library to be found if installed somewhere other than
+# /lib or /usr/lib
+$(ASTSSL_LIB): _ASTLDFLAGS+=-dynamiclib -install_name $(ASTLIBDIR)/$(ASTSSL_LIB)
 $(ASTSSL_LIB): _ASTCFLAGS+=-fPIC -DAST_MODULE=\"asteriskssl\"
 $(ASTSSL_LIB): LIBS+=$(ASTSSL_LIBS)
 $(ASTSSL_LIB): SOLINK=$(DYLINK)
Index: makeopts.in
===================================================================
--- makeopts.in	(revision 373814)
+++ makeopts.in	(working copy)
@@ -106,6 +106,7 @@
 AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@
 AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@
 AST_NESTED_FUNCTIONS=@AST_NESTED_FUNCTIONS@
+AST_RPATH=@AST_RPATH@
 AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@
 AST_MARCH_NATIVE=@AST_MARCH_NATIVE@
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 373814)
+++ configure.ac	(working copy)
@@ -1051,6 +1051,28 @@
 )
 AC_SUBST(AST_NESTED_FUNCTIONS)
 
+dnl Check to see if rpath should be set in LDFLAGS
+AC_ARG_ENABLE(rpath,
+	[AC_HELP_STRING([--disable-rpath],
+			[Disables rpath linker option checking])],
+	[case "${enableval}" in
+		y|ye|yes) check_rpath=yes ;;
+		n|no) check_rpath=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --disable-rpath) ;;
+	esac], [check_rpath=yes])
+
+AC_MSG_CHECKING(whether to use rpath)
+AST_RPATH=
+if test "${check_rpath}" != yes; then
+	AC_MSG_RESULT(skipped)
+elif test ${libdir} = /lib || test ${libdir} = /usr/lib; then
+	AC_MSG_RESULT(not needed)
+else
+	AC_MSG_RESULT(required)
+	AST_RPATH="-Wl,-rpath,${libdir}"
+fi
+AC_SUBST(AST_RPATH)
+
 AC_MSG_CHECKING(for sysinfo)
 AC_LINK_IFELSE(
         [AC_LANG_PROGRAM([#include <sys/sysinfo.h>],
Index: Makefile
===================================================================
--- Makefile	(revision 373814)
+++ Makefile	(working copy)
@@ -252,7 +252,7 @@
 
 ifneq ($(findstring darwin,$(OSARCH)),)
   _ASTCFLAGS+=-D__Darwin__
-  _SOLINK=-Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
+  _SOLINK=-Xlinker -macosx_version_min -Xlinker 10.5 -Xlinker -undefined -Xlinker dynamic_lookup
   ifeq ($(shell if test `/usr/bin/sw_vers -productVersion | cut -c4` -gt 5; then echo 6; else echo 0; fi),6)
     _SOLINK+=/usr/lib/bundle1.o
   endif
@@ -268,6 +268,9 @@
   endif
 endif
 
+# Include rpath settings
+_ASTLDFLAGS+=$(AST_RPATH)
+
 ifeq ($(OSARCH),SunOS)
   SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
   DYLINK=$(SOLINK)
