1 # Copyright 2014 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.
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.
11 ################################################################################
12 # Rust's standard distribution of crates and tools
14 # The crates outlined below are the standard distribution of libraries provided
15 # in a rust installation. These rules are meant to abstract over the
16 # dependencies (both native and rust) of crates and basically generate all the
17 # necessary makefile rules necessary to build everything.
19 # Here's an explanation of the variables below
22 # This list of crates will be built for all targets, including
23 # cross-compiled targets
26 # This list of crates will be compiled for only host targets. Note that
27 # this set is explicitly *not* a subset of TARGET_CRATES, but rather it is
28 # a disjoint set. Nothing in the TARGET_CRATES set can depend on crates in
29 # the HOST_CRATES set, but the HOST_CRATES set can depend on target
33 # A list of all tools which will be built as part of the compilation
34 # process. It is currently assumed that most tools are built through
35 # src/driver/driver.rs with a particular configuration (there's a
36 # corresponding library providing the implementation)
39 # These lists are the dependencies of the <crate> that is to be built.
40 # Rust dependencies are listed bare (i.e. std) and native
41 # dependencies have a "native:" prefix (i.e. native:hoedown). All deps
42 # will be built before the crate itself is built.
44 # TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
45 # Similar to the DEPS variable, this is the library crate dependencies
46 # list for tool as well as the source file for the specified tool
48 # You shouldn't need to modify much other than these variables. Crates are
49 # automatically generated for all stage/host/target combinations.
50 ################################################################################
52 TARGET_CRATES := libc std term \
53 getopts collections test rand \
54 compiler_builtins core alloc \
55 std_unicode rustc_bitflags \
56 alloc_system alloc_jemalloc \
57 panic_abort panic_unwind unwind
58 RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
59 rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
60 rustc_data_structures rustc_platform_intrinsics rustc_errors \
61 rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
62 rustc_const_eval rustc_const_math rustc_incremental proc_macro
63 HOST_CRATES := syntax syntax_ext proc_macro_tokens proc_macro_plugin syntax_pos $(RUSTC_CRATES) \
64 rustdoc fmt_macros flate arena graphviz log serialize
65 TOOLS := compiletest rustdoc rustc rustbook error_index_generator
68 DEPS_compiler_builtins := core native:compiler-rt
69 DEPS_alloc := core libc alloc_system
70 DEPS_alloc_system := core libc
71 DEPS_alloc_jemalloc := core libc native:jemalloc
72 DEPS_collections := core alloc std_unicode
75 DEPS_rustc_bitflags := core
76 DEPS_std_unicode := core
77 DEPS_panic_abort := libc alloc
78 DEPS_panic_unwind := libc alloc unwind
81 RUSTFLAGS_compiler_builtins := -lstatic=compiler-rt
82 RUSTFLAGS_panic_abort := -C panic=abort
84 DEPS_std := core libc rand alloc collections compiler_builtins std_unicode \
86 alloc_system panic_abort panic_unwind unwind
89 DEPS_flate := std native:miniz
95 DEPS_serialize := std log
97 DEPS_test := std getopts term native:rust_test_helpers
99 DEPS_syntax := std term serialize log arena libc rustc_bitflags std_unicode rustc_errors syntax_pos rustc_data_structures
100 DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros proc_macro
101 DEPS_syntax_pos := serialize
102 DEPS_proc_macro_tokens := syntax syntax_pos log
103 DEPS_proc_macro_plugin := syntax syntax_pos rustc_plugin log proc_macro_tokens
105 DEPS_rustc_const_math := std syntax log serialize
106 DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
107 rustc_back graphviz syntax_pos
109 DEPS_rustc := syntax fmt_macros flate arena serialize getopts \
110 log graphviz rustc_llvm rustc_back rustc_data_structures\
111 rustc_const_math syntax_pos rustc_errors
112 DEPS_rustc_back := std syntax flate log libc
113 DEPS_rustc_borrowck := rustc log graphviz syntax syntax_pos rustc_errors rustc_mir
114 DEPS_rustc_data_structures := std log serialize libc
115 DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
116 rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
117 rustc_trans rustc_privacy rustc_lint rustc_plugin \
118 rustc_metadata syntax_ext proc_macro_plugin \
119 rustc_passes rustc_save_analysis rustc_const_eval \
120 rustc_incremental syntax_pos rustc_errors proc_macro rustc_data_structures
121 DEPS_rustc_errors := log libc serialize syntax_pos
122 DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval
123 DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
124 DEPS_proc_macro := std syntax
125 DEPS_rustc_metadata := rustc syntax syntax_pos rustc_errors rustc_const_math \
126 proc_macro syntax_ext
127 DEPS_rustc_passes := syntax syntax_pos rustc core rustc_const_eval rustc_errors
128 DEPS_rustc_mir := rustc syntax syntax_pos rustc_const_math rustc_const_eval rustc_bitflags
129 DEPS_rustc_resolve := arena rustc log syntax syntax_pos rustc_errors
130 DEPS_rustc_platform_intrinsics := std
131 DEPS_rustc_plugin := rustc rustc_metadata syntax syntax_pos rustc_errors
132 DEPS_rustc_privacy := rustc log syntax syntax_pos
133 DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
134 log syntax serialize rustc_llvm rustc_platform_intrinsics \
135 rustc_const_math rustc_const_eval rustc_incremental rustc_errors syntax_pos
136 DEPS_rustc_incremental := rustc syntax_pos serialize rustc_data_structures
137 DEPS_rustc_save_analysis := rustc log syntax syntax_pos serialize
138 DEPS_rustc_typeck := rustc syntax syntax_pos rustc_platform_intrinsics rustc_const_math \
139 rustc_const_eval rustc_errors rustc_data_structures
141 DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts test \
142 rustc_lint rustc_const_eval syntax_pos rustc_data_structures
144 TOOL_DEPS_compiletest := test getopts log serialize
145 TOOL_DEPS_rustdoc := rustdoc
146 TOOL_DEPS_rustc := rustc_driver
147 TOOL_DEPS_rustbook := std rustdoc
148 TOOL_DEPS_error_index_generator := rustdoc syntax serialize
149 TOOL_SOURCE_compiletest := $(S)src/tools/compiletest/src/main.rs
150 TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
151 TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
152 TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
153 TOOL_SOURCE_error_index_generator := $(S)src/tools/error_index_generator/main.rs
155 ONLY_RLIB_compiler_builtins := 1
160 ONLY_RLIB_collections := 1
161 ONLY_RLIB_std_unicode := 1
162 ONLY_RLIB_rustc_bitflags := 1
163 ONLY_RLIB_alloc_system := 1
164 ONLY_RLIB_alloc_jemalloc := 1
165 ONLY_RLIB_panic_unwind := 1
166 ONLY_RLIB_panic_abort := 1
167 ONLY_RLIB_unwind := 1
169 TARGET_SPECIFIC_alloc_jemalloc := 1
171 # Documented-by-default crates
172 DOC_CRATES := std alloc collections core libc std_unicode
174 ifeq ($(CFG_DISABLE_JEMALLOC),)
175 RUSTFLAGS_rustc_back := --cfg 'feature="jemalloc"'
178 ################################################################################
179 # You should not need to edit below this line
180 ################################################################################
182 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
184 # This macro creates some simple definitions for each crate being built, just
185 # some munging of all of the parameters above.
187 # $(1) is the crate to generate variables for
189 CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
190 RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
191 NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
194 $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
198 define RUST_CRATE_DEPS
199 RUST_DEPS_$(1)_T_$(2) := $$(filter-out native:%,$$(DEPS_$(1)))
202 $(foreach target,$(CFG_TARGET),\
203 $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE_DEPS,$(crate),$(target)))))
207 define DEFINE_TARGET_CRATES
208 ifndef TARGET_SPECIFIC_$(2)
209 TARGET_CRATES_$(1) += $(2)
213 $(foreach target,$(CFG_TARGET),\
214 $(foreach crate,$(TARGET_CRATES),\
215 $(eval $(call DEFINE_TARGET_CRATES,$(target),$(crate)))))
217 # Similar to the macro above for crates, this macro is for tools
219 # $(1) is the crate to generate variables for
221 TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
224 $(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
226 CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
227 RUSTFLAGS_libc := --cfg stdbuild