]> git.lizzy.rs Git - rust.git/blob - mk/llvm.mk
librustc: Don't try to perform the magical
[rust.git] / mk / llvm.mk
1 # Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11
12 ifdef CFG_ENABLE_FAST_MAKE
13 LLVM_DEPS := $(S)/.gitmodules
14 else
15
16 # This is just a rough approximation of LLVM deps
17 LLVM_DEPS_SRC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)lib,*cpp *hpp)
18 LLVM_DEPS_INC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)include,*cpp *hpp)
19 LLVM_DEPS=$(LLVM_DEPS_SRC) $(LLVM_DEPS_INC)
20 endif
21
22 define DEF_LLVM_RULES
23
24 # If CFG_LLVM_ROOT is defined then we don't build LLVM ourselves
25 ifeq ($(CFG_LLVM_ROOT),)
26
27 LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
28
29 $$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS) $$(LLVM_STAMP_$(1))
30         @$$(call E, make: llvm)
31         $$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV_$(1)) ONLY_TOOLS="$$(LLVM_TOOLS)"
32         $$(Q)touch $$(LLVM_CONFIG_$(1))
33 endif
34
35 # This is used to independently force an LLVM clean rebuild
36 # when we changed something not otherwise captured by builtin
37 # dependencies. In these cases, commit a change that touches
38 # the stamp in the source dir.
39 $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
40         @$$(call E, make: cleaning llvm)
41         $(Q)$(MAKE) clean-llvm
42         @$$(call E, make: done cleaning llvm)
43         touch $$@
44
45 ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
46 LLVM_STDCPP_LOCATION_$(1) = $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
47                                         -print-file-name=libstdc++.a)
48 else
49 LLVM_STDCPP_LOCATION_$(1) =
50 endif
51
52 endef
53
54 $(foreach host,$(CFG_HOST), \
55  $(eval $(call DEF_LLVM_RULES,$(host))))
56
57 $(foreach host,$(CFG_HOST), \
58  $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
59
60 $(S)src/librustc/lib/llvmdeps.rs: \
61                     $(LLVM_CONFIGS) \
62                     $(S)src/etc/mklldeps.py \
63                     $(MKFILE_DEPS)
64         $(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \
65                 "$@" "$(LLVM_COMPONENTS)" "$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
66                 $(LLVM_CONFIGS)