Makefile revision 230cdaaab58a2cc00012c5766e396a3eba2aa940
1da79da2a8748e4d58eeedd1b7f39bf4fb8a86d10Bob Wilson##===- clang/runtime/compiler-rt/Makefile ------------------*- Makefile -*-===##
2562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson#
3253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar#                     The LLVM Compiler Infrastructure
4253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar#
5253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar# This file is distributed under the University of Illinois Open Source
6253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar# License. See LICENSE.TXT for details.
7562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson#
8562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson##===----------------------------------------------------------------------===##
9562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson#
10562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# This file defines support for building the Clang runtime libraries (which are
11562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# implemented by compiler-rt) and placing them in the proper locations in the
12562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Clang resources directory (i.e., where the driver expects them).
13562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson#
14253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar##===----------------------------------------------------------------------===##
15253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar
16484fc57c8d2d3ba645a03f9e294dcebc5aacaf44Nick LewyckyCLANG_LEVEL := ../..
17562627d782393c0d8045625a53a97f4fbad091bcOwen Andersoninclude $(CLANG_LEVEL)/Makefile
18253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar
19562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonCLANG_VERSION := $(word 3,$(shell grep "CLANG_VERSION " \
20562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include/clang/Basic/Version.inc))
21bc817cffbca01c879f13e9290d94797f6caafc7aDaniel Dunbar
22562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)
23562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonPROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)
24562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
25562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonResourceLibDir := $(ResourceDir)/lib
26562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonPROJ_resources_lib := $(PROJ_resources)/lib
27562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
28562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Expect compiler-rt to be in llvm/projects/compiler-rt
29562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonCOMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt
30562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
31e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# We don't currently support building runtime libraries when we are
32e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# cross-compiling. The issue is that we really want to be set up so that the
33e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# available compiler targets are independent of the current build.
34e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#
35e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# Since we have to build the runtime libraries for the target, it requires we
36e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# have a cross compiler from the build machine to the target. Although in the
37e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# case where for the current build (host == target), we do have such a cross
38e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# compiler, but not defined in a way that is easy for us to reuse. Regardless,
39e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# that also wouldn't help for other possible compiler configurations.
40e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#
41e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# Thus, the simple set up we currently use is to assume that we will be using
42e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# the just built Clang to compile the compiler-rt libraries. As we grow better
43e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# cross compilation support inside Clang and tool support in LLVM, this makes it
44e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# easier for us to achieve the goal of having the compiler targets be easily
45e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# selected at configure time. However, this design does currently preclude the
46e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# building of compiler-rt libraries when the Clang itself is being cross
47e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# compiled.
48e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#
49e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# There are three possible solutions:
50e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#  1. Require building a build-target version of Clang when cross compiling. This
51e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     is simplest, but als greatly increases the build time of cross builds.
52e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#
53e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#  2. Require cross builds have a build-target version of Clang available for
54e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     use. This is a reasonable compromise on #1, as the compiler-rt libraries
55e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     are simple enough that there is not a strong desire to ensure they are
56e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     built with the exact version of Clang being used. Similarly, as Clang
57e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     becomes a better cross compiler it is also increasingly more likely that
58e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     the cross compiler being used will already be a version of Clang.
59e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#
60e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#  3. Come up with an alternate mechanism to define all the toolchain
61e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     information that compiler-rt would need to build libraries for all the
62e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     requested targets. This might be a simple short term solution, but is
63e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar#     likely to be unwieldly and irritating to maintain in the long term.
64e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbarifneq ($(LLVM_CROSS_COMPILING),1)
65562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonifneq ($(CLANG_NO_RUNTIME),1)
66562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonifeq ($(shell test -d $(COMPILERRT_SRC_ROOT) && echo OK),OK)
67562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
68562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Select the compiler-rt configuration to use, and install directory.
69562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson#
70562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# FIXME: Eventually, we want some kind of configure support for this. We want to
71562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# build/install runtime libraries for as many targets as clang was configured to
72562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# support.
73562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeDirs :=
74562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonifeq ($(OS),Darwin)
75562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeDirs += darwin
76f471487ff1e673531543576bc170898c2ab19f41Daniel DunbarRuntimeLibrary.darwin.Configs := \
777a0c064770355a4918df69f95de8dea6338a59a2Daniel Dunbar	eprintf.a 10.4.a osx.a ios.a cc_kext.a cc_kext_ios5.a \
78f8d4a6b80d3e0f19c9735fbe0be7bf5f8b21ec18Alexey Samsonov	asan_osx_dynamic.dylib \
7975fcb193aeeec5c4f10cc39df60a5ce7526b1b28Alexey Samsonov	profile_osx.a profile_ios.a \
8075fcb193aeeec5c4f10cc39df60a5ce7526b1b28Alexey Samsonov	ubsan_osx.a
81562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendif
82ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar
83ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar# On Linux, include a library which has all the runtime functions.
84ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarifeq ($(OS),Linux)
85ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel DunbarRuntimeDirs += linux
86ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel DunbarRuntimeLibrary.linux.Configs :=
87ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar
88f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# TryCompile compiler source flags
89f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# Returns exit code of running a compiler invocation.
90f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey SamsonovTryCompile = \
91f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov  $(shell \
92f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov    cflags=""; \
93f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov    for flag in $(3); do \
94f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov      cflags="$$cflags $$flag"; \
95f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov    done; \
96f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov    $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
97f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov    echo $$?)
98f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov
99230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruth# We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
100230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler CarruthRuntime32BitConfigs = \
10161a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith	full-i386.a profile-i386.a san-i386.a asan-i386.a ubsan-i386.a \
10261a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith	ubsan_cxx-i386.a
103230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruth
104230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruth# We currently only try to generate runtime libraries on x86.
105230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler Carruthifeq ($(ARCH),x86)
106230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler CarruthRuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
107ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarendif
108f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov
109ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarifeq ($(ARCH),x86_64)
1107df67e6892d74a6653473089473166a30608f416Daniel DunbarRuntimeLibrary.linux.Configs += \
11161a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith	full-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
11261a574f6a306a91fe78c39757f70f88e62b6736fRichard Smith	tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a ubsan_cxx-x86_64.a
113e0d80f1852bff0bcf8f71b73773cdff71bc94f33Alexey Samsonov# We need to build 32-bit ASan/UBsan libraries on 64-bit platform, and add them
114e0d80f1852bff0bcf8f71b73773cdff71bc94f33Alexey Samsonov# to the list of runtime libraries to make
115e0d80f1852bff0bcf8f71b73773cdff71bc94f33Alexey Samsonov# "clang -fsanitize=(address|undefined) -m32" work.
116f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# We check that Clang can produce working 32-bit binaries by compiling a simple
117f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonov# executable.
118f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonovtest_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
119f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonovifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
120230cdaaab58a2cc00012c5766e396a3eba2aa940Chandler CarruthRuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
121ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbarendif
12219baf068e8d113a242694003ba04508282804e8eEvgeniy Stepanovifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
12319baf068e8d113a242694003ba04508282804e8eEvgeniy StepanovRuntimeLibrary.linux.Configs += asan-arm-android.so
12419baf068e8d113a242694003ba04508282804e8eEvgeniy Stepanovendif
125f288d223a44fb2fa0de69b225dcdbc5f7669defdAlexey Samsonovendif
126ff9865220ccd618cab2d8fbc63e58ac6cd7357f0Daniel Dunbar
127db0ab63998eb9aad0ead03d3f76f095f9b1eb036Daniel Dunbarendif
128253521bacfc70dcc8f8205f8b1192816458beb34Daniel Dunbar
129e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar####
130e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# The build rules below are designed to be generic and should only need to be
131e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar# modified based on changes in the compiler-rt layout or build system.
132e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar####
133e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbar
134562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Rule to build the compiler-rt libraries we need.
135562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson#
136562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# We build all the libraries in a single shot to avoid recursive make as much as
137562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# possible.
138562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonBuildRuntimeLibraries:
139562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
140562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
141562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	  ProjObjRoot=$(PROJ_OBJ_DIR) \
1423518058dace8f4c9c3ed0b6a30b0bdf08a10d559Daniel Dunbar	  CC="$(ToolDir)/clang" \
14319baf068e8d113a242694003ba04508282804e8eEvgeniy Stepanov	  LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
144562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	  $(RuntimeDirs:%=clang_%)
145562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: BuildRuntimeLibraries
146562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonCleanRuntimeLibraries:
147562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
148562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	  ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
149562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	  ProjObjRoot=$(PROJ_OBJ_DIR) \
150562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	  clean
151562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: CleanRuntimeLibraries
152562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
153562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_resources_lib):
154562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Verb) $(MKDIR) $@
155562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
156562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Expand rules for copying/installing each individual library. We can't use
157562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# implicit rules here because we need to match against multiple things.
158562627d782393c0d8045625a53a97f4fbad091bcOwen Andersondefine RuntimeLibraryTemplate
159562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a: BuildRuntimeLibraries
160562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	@true
16112f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so: BuildRuntimeLibraries
16212f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	@true
16312f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib: BuildRuntimeLibraries
16412f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	@true
165562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PRECIOUS: $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a
166562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
167562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Rule to copy the libraries to their resource directory location.
168562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(ResourceLibDir)/$1/libclang_rt.%.a: \
169562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a \
170562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson		$(ResourceLibDir)/$1/.dir
171562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Echo) Copying runtime library $1/$$* to build dir
172562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.a $$@
17312f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(ResourceLibDir)/$1/libclang_rt.%.so: \
17412f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.so \
17512f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(ResourceLibDir)/$1/.dir
17612f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Echo) Copying runtime library $1/$$* to build dir
17712f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.so $$@
17812f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(ResourceLibDir)/$1/libclang_rt.%.dylib: \
17912f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.dylib \
18012f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(ResourceLibDir)/$1/.dir
18112f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Echo) Copying runtime library $1/$$* to build dir
18212f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.dylib $$@
183b626280eb16a62e32a100f0082e9ea7e496a51d7Alexander Potapenko	$(Echo) Fixing LC_ID_DYLIB of $$@
184b626280eb16a62e32a100f0082e9ea7e496a51d7Alexander Potapenko	$(Verb) install_name_tool $$@ -id $$@
185562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeLibrary.$1: \
18612f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%)
187562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: RuntimeLibrary.$1
18846bbbdd0111c386c2341919a62c5742f2519efa6Daniel Dunbar
189562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_resources_lib)/$1: $(PROJ_resources_lib)
190562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Verb) $(MKDIR) $$@
191562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
192562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(PROJ_resources_lib)/$1/libclang_rt.%.a: \
193562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson		$(ResourceLibDir)/$1/libclang_rt.%.a | $(PROJ_resources_lib)/$1
194562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Echo) Installing compiler runtime library: $1/$$*
195562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson	$(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1
19612f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_resources_lib)/$1/libclang_rt.%.so: \
19712f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(ResourceLibDir)/$1/libclang_rt.%.so | $(PROJ_resources_lib)/$1
19812f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Echo) Installing compiler runtime library: $1/$$*
19912f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1
20012f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar$(PROJ_resources_lib)/$1/libclang_rt.%.dylib: \
20112f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(ResourceLibDir)/$1/libclang_rt.%.dylib | $(PROJ_resources_lib)/$1
20212f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Echo) Installing compiler runtime library: $1/$$*
20312f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar	$(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1
204562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
205562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Rule to install runtime libraries.
206562627d782393c0d8045625a53a97f4fbad091bcOwen AndersonRuntimeLibraryInstall.$1: \
20712f5fe5f4ee9318a11e299f199f61eea05a2a450Daniel Dunbar		$(RuntimeLibrary.$1.Configs:%=$(PROJ_resources_lib)/$1/libclang_rt.%)
208562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson.PHONY: RuntimeLibraryInstall.$1
209562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendef
210562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib))))
211562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
212562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson# Hook into the standard Makefile rules.
213562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonall-local:: $(RuntimeDirs:%=RuntimeLibrary.%)
214562627d782393c0d8045625a53a97f4fbad091bcOwen Andersoninstall-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%)
215562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonclean-local:: CleanRuntimeLibraries
216562627d782393c0d8045625a53a97f4fbad091bcOwen Anderson
217562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendif
218562627d782393c0d8045625a53a97f4fbad091bcOwen Andersonendif
219e33218a3ceb3a36e4d8163cf04df0c0cae530b27Daniel Dunbarendif
220