From 0e2fd2e555599cc88b757a40ea69ab2d70bc1811 Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Date: Sun, 18 Jan 2015 02:03:41 -0800
Subject: [PATCH 6/7] Fix dylib install name when building on Tiger

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
---
 Makefile.rules            | 11 +++++++++++
 tools/llvm-shlib/Makefile |  9 ++-------
 tools/lto/Makefile        |  9 ++-------
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git llvm_release_34/Makefile.rules macports_release_34/Makefile.rules
index fde77f9..3a9b81f 100644
--- llvm_release_34/Makefile.rules
+++ macports_release_34/Makefile.rules
@@ -581,6 +581,17 @@ ifdef SHARED_LIBRARY
 ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
 ifneq ($(HOST_OS),Darwin)
   LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
+else
+  ifeq ($(DARWIN_MAJVERS),4)
+    LD.Flags += -Wl,-dylib_install_name
+  else
+    LD.Flags += -Wl,-install_name
+  endif
+  ifdef LOADABLE_MODULE
+    LD.Flags += -Wl,"$(PROJ_libdir)/$(LIBRARYNAME)$(SHLIBEXT)"
+  else
+    LD.Flags += -Wl,"$(PROJ_libdir)/$(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)"
+  endif
 endif
 endif
 endif
diff --git llvm_release_34/tools/llvm-shlib/Makefile macports_release_34/tools/llvm-shlib/Makefile
index b912ea6..fe24c4b 100644
--- llvm_release_34/tools/llvm-shlib/Makefile
+++ macports_release_34/tools/llvm-shlib/Makefile
@@ -55,13 +55,8 @@ ifeq ($(HOST_OS),Darwin)
     LLVMLibsOptions    := $(LLVMLibsOptions)  \
                          -Wl,-dead_strip
 
-    # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
-    DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
-    ifneq ($(DARWIN_VERS),8)
-       LLVMLibsOptions    := $(LLVMLibsOptions)  \
-                            -Wl,-install_name \
-                            -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
-    endif
+    # $(LEVEL)/Makefile.rules has been patched to set the install name
+    # for all dylibs.
 endif
 
 ifeq ($(HOST_OS), $(filter $(HOST_OS), DragonFly Linux FreeBSD GNU/kFreeBSD OpenBSD GNU Bitrig))
diff --git llvm_release_34/tools/lto/Makefile macports_release_34/tools/lto/Makefile
index cedbee1..40c80f5 100644
--- llvm_release_34/tools/lto/Makefile
+++ macports_release_34/tools/lto/Makefile
@@ -41,13 +41,8 @@ ifeq ($(HOST_OS),Darwin)
     LLVMLibsOptions    := $(LLVMLibsOptions)  \
                          -Wl,-dead_strip
 
-    # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
-    DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
-    ifneq ($(DARWIN_VERS),8)
-       LLVMLibsOptions    := $(LLVMLibsOptions)  \
-                            -Wl,-install_name \
-                            -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
-    endif
+    # $(LEVEL)/Makefile.rules has been patched to set the install name
+    # for all dylibs.
 
     # If we're doing an Apple-style build, add the LTO object path.
     ifeq ($(RC_XBS),YES)
-- 
2.2.2

