Daniel Dunbar | 253521b | 2010-01-19 21:12:58 +0000 | [diff] [blame] | 1 | ##===- clang/lib/Runtime/Makefile --------------------------*- Makefile -*-===## |
| 2 | # |
| 3 | # The LLVM Compiler Infrastructure |
| 4 | # |
| 5 | # This file is distributed under the University of Illinois Open Source |
| 6 | # License. See LICENSE.TXT for details. |
| 7 | # |
| 8 | ##===----------------------------------------------------------------------===## |
| 9 | # |
| 10 | # This file defines support for building the Clang runtime libraries (which are |
| 11 | # implemented by compiler-rt) and placing them in the proper locations in the |
| 12 | # Clang resources directory (i.e., where the driver expects them). |
| 13 | # |
| 14 | ##===----------------------------------------------------------------------===## |
| 15 | |
| 16 | LEVEL = ../../../.. |
| 17 | include $(LEVEL)/Makefile.common |
| 18 | |
| 19 | CLANG_VERSION := $(shell cat $(PROJ_SRC_DIR)/../../VER) |
| 20 | ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION) |
| 21 | PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION) |
| 22 | |
| 23 | ResourceLibDir := $(ResourceDir)/lib |
| 24 | PROJ_resources_lib := $(PROJ_resources)/lib |
| 25 | |
| 26 | # Expect compiler-rt to be in llvm/projects/compiler-rt |
| 27 | COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt |
| 28 | |
| 29 | ifeq ($(shell test -d $(COMPILERRT_SRC_ROOT) && echo OK),OK) |
| 30 | |
| 31 | # Select the compiler-rt configuration to use, and install directory. |
| 32 | # |
| 33 | # FIXME: Eventually, we want some kind of configure support for this. We want to |
| 34 | # build/install runtime libraries for as many targets as clang was configured to |
| 35 | # support. |
| 36 | RuntimeDirs := |
| 37 | ifeq ($(OS),Darwin) |
| 38 | RuntimeDirs += darwin |
Daniel Dunbar | c0e8f13 | 2010-03-26 19:37:38 +0000 | [diff] [blame] | 39 | RuntimeLibrary.darwin.Configs = 10.4 armv6 cc_kext |
Daniel Dunbar | 253521b | 2010-01-19 21:12:58 +0000 | [diff] [blame] | 40 | endif |
| 41 | |
Daniel Dunbar | 253521b | 2010-01-19 21:12:58 +0000 | [diff] [blame] | 42 | # Rule to build the compiler-rt libraries we need. |
| 43 | # |
| 44 | # We build all the libraries in a single shot to avoid recursive make as much as |
| 45 | # possible. |
| 46 | BuildRuntimeLibraries: |
| 47 | $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \ |
| 48 | ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \ |
| 49 | ProjObjRoot=$(PROJ_OBJ_DIR) \ |
| 50 | $(RuntimeDirs:%=clang_%) |
| 51 | .PHONY: BuildRuntimeLibraries |
| 52 | CleanRuntimeLibraries: |
| 53 | $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \ |
| 54 | ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \ |
| 55 | ProjObjRoot=$(PROJ_OBJ_DIR) \ |
| 56 | clean |
| 57 | .PHONY: CleanRuntimeLibraries |
| 58 | |
| 59 | $(PROJ_resources_lib): |
| 60 | $(Verb) $(MKDIR) $@ |
| 61 | |
| 62 | # Expand rules for copying/installing each individual library. We can't use |
| 63 | # implicit rules here because we need to match against multiple things. |
| 64 | define RuntimeLibraryTemplate |
| 65 | $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a: BuildRuntimeLibraries |
| 66 | @true |
| 67 | .PRECIOUS: $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a |
| 68 | |
| 69 | # Rule to copy the libraries to their resource directory location. |
| 70 | $(ResourceLibDir)/$1/libclang_rt.%.a: \ |
| 71 | $(PROJ_OBJ_DIR)/clang_$1/%/libcompiler_rt.a \ |
| 72 | $(ResourceLibDir)/$1/.dir |
| 73 | $(Echo) Copying runtime library $1/$$* to build dir |
| 74 | $(Verb) cp $(PROJ_OBJ_DIR)/clang_$1/$$*/libcompiler_rt.a $$@ |
| 75 | RuntimeLibrary.$1: \ |
| 76 | $(RuntimeLibrary.$1.Configs:%=$(ResourceLibDir)/$1/libclang_rt.%.a) |
| 77 | .PHONY: RuntimeLibrary.$1 |
| 78 | |
| 79 | $(PROJ_resources_lib)/$1: $(PROJ_resources_lib) |
| 80 | $(Verb) $(MKDIR) $$@ |
| 81 | |
| 82 | $(PROJ_resources_lib)/$1/libclang_rt.%.a: \ |
| 83 | $(ResourceLibDir)/$1/libclang_rt.%.a | $(PROJ_resources_lib)/$1 |
| 84 | $(Echo) Installing compiler runtime library: $1/$$* |
| 85 | $(Verb) $(DataInstall) $$< $(PROJ_resources_lib)/$1 |
| 86 | |
| 87 | # Rule to install runtime libraries. |
| 88 | RuntimeLibraryInstall.$1: \ |
| 89 | $(RuntimeLibrary.$1.Configs:%=$(PROJ_resources_lib)/$1/libclang_rt.%.a) |
| 90 | .PHONY: RuntimeLibraryInstall.$1 |
| 91 | endef |
| 92 | $(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib)))) |
| 93 | |
| 94 | # Hook into the standard Makefile rules. |
| 95 | all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) |
| 96 | install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) |
| 97 | clean-local:: CleanRuntimeLibraries |
Daniel Dunbar | 46bbbdd | 2010-01-19 21:28:04 +0000 | [diff] [blame] | 98 | |
| 99 | endif |