]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
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 | ||
1a4d82fc JJ |
11 | # <help> \(^o^)/ |
12 | # | |
13 | # Greetings, adventurer! The Rust Build System is at your service. | |
14 | # | |
15 | # Whether you want a genuine copy of `rustc`, access to the latest and | |
16 | # most authoritative Rust documentation, or even to investigate the | |
17 | # most intimate workings of the compiler itself, you've come to the | |
18 | # right place. Let's see what's on the menu. | |
19 | # | |
20 | # First, start with one of these build targets: | |
21 | # | |
22 | # * all - The default. Build a complete, bootstrapped compiler. | |
23 | # `rustc` will be in `${target-triple}/stage2/bin/`. Run it | |
24 | # directly from the build directory if you like. This also | |
25 | # comes with docs in `doc/`. | |
26 | # | |
27 | # * check - Run the complete test suite | |
28 | # | |
29 | # * clean - Clean the build repertory. It is advised to run this | |
30 | # command if you want to build Rust again, after an update | |
31 | # of the git repository. | |
32 | # | |
33 | # * install - Install Rust. Note that installation is not necessary | |
34 | # to use the compiler. | |
35 | # | |
36 | # * uninstall - Uninstall the binaries | |
37 | # | |
38 | # For tips on working with The Rust Build System, just: | |
39 | # | |
40 | # run `make tips` | |
41 | # | |
42 | # Otherwise | |
43 | # | |
44 | # run `make` | |
45 | # | |
46 | # </help> | |
47 | # | |
48 | # <tips> | |
49 | # | |
50 | # # The Rust Build System Tip Line | |
51 | # | |
52 | # There are a bazillion different targets you might want to build. Here | |
53 | # are a few ideas. | |
54 | # | |
55 | # * docs - Build gobs of HTML documentation and put it into `doc/` | |
56 | # * check-$(crate) - Test a crate, e.g. `check-std` | |
57 | # * check-ref - Run the language reference tests | |
58 | # * check-docs - Test the documentation examples | |
59 | # * check-stage$(stage)-$(crate) - Test a crate in a specific stage | |
60 | # * check-stage$(stage)-{rpass,rfail,cfail,rmake,...} - Run tests in src/test/ | |
61 | # * check-stage1-T-$(target)-H-$(host) - Run cross-compiled-tests | |
85aaf69f SL |
62 | # * tidy-basic - show file / line stats |
63 | # * tidy-errors - show the highest rustc error code | |
64 | # * tidy-features - show the status of language and lib features | |
c1a9b12d | 65 | # * rustc-stage$(stage) - Only build up to a specific stage |
1a4d82fc JJ |
66 | # |
67 | # Then mix in some of these environment variables to harness the | |
68 | # ultimate power of The Rust Build System. | |
69 | # | |
70 | # * `VERBOSE=1` - Print all commands. Use this to see what's going on. | |
71 | # * `RUSTFLAGS=...` - Add compiler flags to all `rustc` invocations | |
72 | # * `JEMALLOC_FLAGS=...` - Pass flags to jemalloc's configure script | |
73 | # | |
74 | # * `TESTNAME=...` - Specify the name of tests to run | |
75 | # * `CHECK_IGNORED=1` - Run normally-ignored tests | |
76 | # * `PLEASE_BENCH=1` - Run crate benchmarks (enable `--bench` flag) | |
77 | # | |
78 | # * `CFG_ENABLE_VALGRIND=1` - Run tests under valgrind | |
79 | # * `VALGRIND_COMPILE=1` - Run the compiler itself under valgrind | |
d9579d0f | 80 | # (requires `CFG_ENABLE_VALGRIND`) |
1a4d82fc JJ |
81 | # |
82 | # * `NO_REBUILD=1` - Don't rebootstrap when testing std | |
83 | # (and possibly other crates) | |
84 | # * `NO_MKFILE_DEPS=1` - Don't rebuild for modified .mk files | |
85 | # | |
86 | # * `SAVE_TEMPS=1` - Use `--save-temps` flag on all `rustc` invocations | |
87 | # * `ASM_COMMENTS=1` - Use `-Z asm-comments` | |
88 | # * `TIME_PASSES=1` - Use `-Z time-passes` | |
89 | # * `TIME_LLVM_PASSES=1` - Use `-Z time-llvm-passes` | |
90 | # * `TRACE=1` - Use `-Z trace` | |
91 | # | |
92 | # # Rust recipes for build system success | |
93 | # | |
c1a9b12d | 94 | # // Modifying libstd? Use this command to run unit tests just on your change |
1a4d82fc JJ |
95 | # make check-stage1-std NO_REBUILD=1 NO_BENCH=1 |
96 | # | |
97 | # // Added a run-pass test? Use this to test running your test | |
98 | # make check-stage1-rpass TESTNAME=my-shiny-new-test | |
99 | # | |
100 | # // Having trouble figuring out which test is failing? Turn off parallel tests | |
c34b1796 | 101 | # make check-stage1-std RUST_TEST_THREADS=1 |
1a4d82fc JJ |
102 | # |
103 | # If you really feel like getting your hands dirty, then: | |
104 | # | |
105 | # run `make nitty-gritty` | |
106 | # | |
107 | # </tips> | |
108 | # | |
109 | # <nitty-gritty> | |
110 | # | |
111 | # # The Rust Build System | |
112 | # | |
113 | # Gosh I wish there was something useful here (TODO). | |
114 | # | |
115 | # # An (old) explanation of how the build is structured: | |
116 | # | |
117 | # *Note: Hey, like, this is probably inaccurate, and is definitely | |
118 | # an outdated and insufficient explanation of the remarkable | |
119 | # Rust Build System.* | |
223e47cc LB |
120 | # |
121 | # There are multiple build stages (0-3) needed to verify that the | |
122 | # compiler is properly self-hosting. Each stage is divided between | |
123 | # 'host' artifacts and 'target' artifacts, where the stageN host | |
124 | # compiler builds artifacts for 1 or more stageN target architectures. | |
125 | # Once the stageN target compiler has been built for the host | |
126 | # architecture it is promoted (copied) to a stageN+1 host artifact. | |
127 | # | |
128 | # The stage3 host compiler is a compiler that successfully builds | |
129 | # itself and should (in theory) be bitwise identical to the stage2 | |
130 | # host compiler. The process is bootstrapped using a stage0 host | |
131 | # compiler downloaded from a previous snapshot. | |
132 | # | |
133 | # At no time should stageN artifacts be interacting with artifacts | |
134 | # from other stages. For consistency, we use the 'promotion' logic | |
135 | # for all artifacts, even those that don't make sense on non-host | |
136 | # architectures. | |
137 | # | |
138 | # The directory layout for a stage is intended to match the layout | |
139 | # of the installed compiler, and looks like the following: | |
140 | # | |
141 | # stageN - this is the system root, corresponding to, e.g. /usr | |
142 | # bin - binaries compiled for the host | |
143 | # lib - libraries used by the host compiler | |
1a4d82fc | 144 | # rustlib - rustc's own place to organize libraries |
223e47cc LB |
145 | # $(target) - target-specific artifacts |
146 | # bin - binaries for target architectures | |
147 | # lib - libraries for target architectures | |
148 | # | |
149 | # A note about host libraries: | |
150 | # | |
151 | # The only libraries that get promoted to stageN/lib are those needed | |
152 | # by rustc. In general, rust programs, even those compiled for the | |
153 | # host architecture will use libraries from the target | |
154 | # directories. This gives rust some freedom to experiment with how | |
155 | # libraries are managed and versioned without polluting the common | |
156 | # areas of the filesystem. | |
157 | # | |
1a4d82fc | 158 | # General rust binaries may still live in the host bin directory; they |
223e47cc LB |
159 | # will just link against the libraries in the target lib directory. |
160 | # | |
161 | # Admittedly this is a little convoluted. | |
223e47cc | 162 | # |
9346a6ac AL |
163 | # If you find yourself working on the make infrastructure itself, and trying to |
164 | # find the value of a given variable after expansion, you can use: | |
165 | # | |
166 | # make print-VARIABLE_NAME | |
167 | # | |
168 | # To extract it | |
169 | # | |
1a4d82fc JJ |
170 | # </nitty-gritty> |
171 | # | |
223e47cc LB |
172 | |
173 | ###################################################################### | |
1a4d82fc | 174 | # Primary rules |
223e47cc LB |
175 | ###################################################################### |
176 | ||
1a4d82fc JJ |
177 | # Issue #9531: If you change the order of any of the following (or add |
178 | # new definitions), make sure definitions always precede their uses, | |
179 | # especially for the dependency lists of recipes. | |
223e47cc | 180 | |
1a4d82fc JJ |
181 | # First, load the variables exported by the configure script |
182 | include config.mk | |
223e47cc | 183 | |
1a4d82fc JJ |
184 | # Just a few macros used everywhere |
185 | include $(CFG_SRC_DIR)mk/util.mk | |
186 | # Reconfiguring when the makefiles or submodules change | |
187 | include $(CFG_SRC_DIR)mk/reconfig.mk | |
188 | # All crates and their dependencies | |
189 | include $(CFG_SRC_DIR)mk/crates.mk | |
190 | # Various bits of setup, common macros, and top-level rules | |
191 | include $(CFG_SRC_DIR)mk/main.mk | |
192 | # C and assembly components that are not LLVM | |
193 | include $(CFG_SRC_DIR)mk/rt.mk | |
194 | # Rules for crates in the target directories | |
223e47cc | 195 | include $(CFG_SRC_DIR)mk/target.mk |
1a4d82fc | 196 | # Rules for crates in the host directories |
223e47cc | 197 | include $(CFG_SRC_DIR)mk/host.mk |
1a4d82fc | 198 | # Special rules for bootstrapping stage0 |
223e47cc | 199 | include $(CFG_SRC_DIR)mk/stage0.mk |
1a4d82fc | 200 | # Rust-specific LLVM extensions |
223e47cc | 201 | include $(CFG_SRC_DIR)mk/rustllvm.mk |
1a4d82fc | 202 | # Documentation |
223e47cc | 203 | include $(CFG_SRC_DIR)mk/docs.mk |
1a4d82fc | 204 | # LLVM |
223e47cc | 205 | include $(CFG_SRC_DIR)mk/llvm.mk |
1a4d82fc JJ |
206 | # Rules for installing debugger scripts |
207 | include $(CFG_SRC_DIR)mk/debuggers.mk | |
223e47cc LB |
208 | |
209 | ###################################################################### | |
210 | # Secondary makefiles, conditionalized for speed | |
211 | ###################################################################### | |
212 | ||
1a4d82fc | 213 | # Binary snapshots |
223e47cc LB |
214 | ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \ |
215 | $(findstring clean,$(MAKECMDGOALS))),) | |
216 | CFG_INFO := $(info cfg: including snap rules) | |
217 | include $(CFG_SRC_DIR)mk/snap.mk | |
218 | endif | |
219 | ||
1a4d82fc | 220 | # The test suite |
223e47cc LB |
221 | ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \ |
222 | $(findstring test,$(MAKECMDGOALS)) \ | |
223 | $(findstring perf,$(MAKECMDGOALS)) \ | |
224 | $(findstring tidy,$(MAKECMDGOALS))),) | |
225 | CFG_INFO := $(info cfg: including test rules) | |
226 | include $(CFG_SRC_DIR)mk/tests.mk | |
1a4d82fc | 227 | include $(CFG_SRC_DIR)mk/grammar.mk |
223e47cc LB |
228 | endif |
229 | ||
1a4d82fc | 230 | # Performance and benchmarking |
223e47cc LB |
231 | ifneq ($(findstring perf,$(MAKECMDGOALS)),) |
232 | CFG_INFO := $(info cfg: including perf rules) | |
233 | include $(CFG_SRC_DIR)mk/perf.mk | |
234 | endif | |
235 | ||
1a4d82fc JJ |
236 | # Copy all the distributables to another directory for binary install |
237 | ifneq ($(strip $(findstring prepare,$(MAKECMDGOALS)) \ | |
238 | $(findstring dist,$(MAKECMDGOALS)) \ | |
239 | $(findstring install,$(MAKECMDGOALS))),) | |
240 | CFG_INFO := $(info cfg: including prepare rules) | |
241 | include $(CFG_SRC_DIR)mk/prepare.mk | |
223e47cc LB |
242 | endif |
243 | ||
1a4d82fc JJ |
244 | # Source and binary distribution artifacts |
245 | ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \ | |
246 | $(findstring install,$(MAKECMDGOALS)) \ | |
247 | $(findstring clean,$(MAKECMDGOALS))),) | |
248 | CFG_INFO := $(info cfg: including dist rules) | |
249 | include $(CFG_SRC_DIR)mk/dist.mk | |
250 | endif | |
223e47cc | 251 | |
1a4d82fc JJ |
252 | # (Unix) Installation from the build directory |
253 | ifneq ($(findstring install,$(MAKECMDGOALS)),) | |
223e47cc LB |
254 | CFG_INFO := $(info cfg: including install rules) |
255 | include $(CFG_SRC_DIR)mk/install.mk | |
256 | endif | |
257 | ||
1a4d82fc JJ |
258 | # Cleaning |
259 | ifneq ($(findstring clean,$(MAKECMDGOALS)),) | |
260 | CFG_INFO := $(info cfg: including clean rules) | |
261 | include $(CFG_SRC_DIR)mk/clean.mk | |
262 | endif | |
263 | ||
264 | # CTAGS building | |
223e47cc LB |
265 | ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \ |
266 | $(findstring TAGS.vi,$(MAKECMDGOALS))),) | |
267 | CFG_INFO := $(info cfg: including ctags rules) | |
268 | include $(CFG_SRC_DIR)mk/ctags.mk | |
269 | endif |