From e84a39c6a5f2c80cc76b10deb5d5e46a900d823c Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Date: Sat, 17 Jan 2015 17:58:25 -0800
Subject: [PATCH 1004/1008] MacPorts Only: Relocate clang resources using llvm
 version

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
---
 lib/Headers/Makefile         |  3 ++-
 runtime/compiler-rt/Makefile | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git llvm_release_37/tools/clang/lib/Headers/Makefile macports_release_37/tools/clang/lib/Headers/Makefile
index 903acac..7c37992 100644
--- llvm_release_37/tools/clang/lib/Headers/Makefile
+++ macports_release_37/tools/clang/lib/Headers/Makefile
@@ -16,6 +16,7 @@ include $(CLANG_LEVEL)/Makefile
 
 CLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \
 	$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc))
+LLVM_VERSION := $(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)
 
 HeaderDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)/include
 
@@ -40,7 +41,7 @@ $(HeaderDir)/module.modulemap: $(PROJ_SRC_DIR)/module.modulemap $(HeaderDir)/.di
 # Hook into the standard Makefile rules.
 all-local:: $(OBJHEADERS) $(HeaderDir)/module.modulemap
 
-PROJ_headers := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)/include
+PROJ_headers := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(LLVM_VERSION)/include
 
 INSTHEADERS := $(addprefix $(PROJ_headers)/, $(HEADERS))
 INSTHEADERS += $(PROJ_headers)/arm_neon.h
diff --git llvm_release_37/tools/clang/runtime/compiler-rt/Makefile macports_release_37/tools/clang/runtime/compiler-rt/Makefile
index fc43e72..49a5b08 100644
--- llvm_release_37/tools/clang/runtime/compiler-rt/Makefile
+++ macports_release_37/tools/clang/runtime/compiler-rt/Makefile
@@ -18,9 +18,10 @@ include $(CLANG_LEVEL)/Makefile
 
 CLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \
 	$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc))
+LLVM_VERSION := $(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR)
 
 ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)
-PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)
+PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(LLVM_VERSION)
 
 ResourceLibDir := $(ResourceDir)/lib
 ResourceIncludeDir := $(ResourceDir)/include
@@ -257,9 +258,21 @@ $(PROJ_resources_include)/sanitizer: $(ResourceIncludeDir)/sanitizer $(PROJ_reso
 RuntimeHeaderInstall: $(PROJ_resources_include)/sanitizer
 .PHONY: RuntimeHeaderInstall
 
+# Make sure $(PROJ_resources) exists before creating the symlink.
+$(PROJ_resources:$(LLVM_VERSION)=$(CLANG_VERSION)):
+	$(Echo) Creating compiler runtime compatibility symlink
+	$(Verb) $(MKDIR) $(dir $@)
+	$(Verb) ln -s $(LLVM_VERSION) $@
+
+MacPortsClangResSymlinkInstall: $(PROJ_resources:$(LLVM_VERSION)=$(CLANG_VERSION))
+.PHONY: MacPortsClangResSymlinkInstall
+
 # Hook into the standard Makefile rules.
 all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) RuntimeHeader
 install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) RuntimeHeaderInstall
+ifneq ($(LLVM_VERSION),$(CLANG_VERSION))
+install-local:: MacPortsClangResSymlinkInstall
+endif
 clean-local:: CleanRuntimeLibraries
 
 endif
-- 
2.10.1

