]> git.lizzy.rs Git - rust.git/blob - Makefile.in
Auto merge of #33786 - birkenfeld:make-fix, r=jseyfried
[rust.git] / Makefile.in
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 # <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 repository. 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
62 #   * tidy - Basic style check, show highest rustc error code and
63 #     the status of language and lib features
64 #   * rustc-stage$(stage) - Only build up to a specific stage
65 #
66 # Then mix in some of these environment variables to harness the
67 # ultimate power of The Rust Build System.
68 #
69 #   * `VERBOSE=1` - Print all commands. Use this to see what's going on.
70 #   * `RUSTFLAGS=...` - Add compiler flags to all `rustc` invocations
71 #   * `JEMALLOC_FLAGS=...` - Pass flags to jemalloc's configure script
72 #
73 #   * `TESTNAME=...` - Specify the name of tests to run
74 #   * `CHECK_IGNORED=1` - Run normally-ignored tests
75 #   * `PLEASE_BENCH=1` - Run crate benchmarks (enable `--bench` flag)
76 #
77 #   * `CFG_ENABLE_VALGRIND=1` - Run tests under valgrind
78 #   * `VALGRIND_COMPILE=1` - Run the compiler itself under valgrind
79 #                            (requires `CFG_ENABLE_VALGRIND`)
80 #
81 #   * `NO_REBUILD=1` - Don't rebootstrap when testing std
82 #                      (and possibly other crates)
83 #   * `NO_MKFILE_DEPS=1` - Don't rebuild for modified .mk files
84 #
85 #   * `SAVE_TEMPS=1` - Use `--save-temps` flag on all `rustc` invocations
86 #   * `ASM_COMMENTS=1` - Use `-Z asm-comments`
87 #   * `TIME_PASSES=1` - Use `-Z time-passes`
88 #   * `TIME_LLVM_PASSES=1` - Use `-Z time-llvm-passes`
89 #   * `TRACE=1` - Use `-Z trace`
90 #
91 # # Rust recipes for build system success
92 #
93 #     // Modifying libstd? Use this command to run unit tests just on your change
94 #     make check-stage1-std NO_REBUILD=1 NO_BENCH=1
95 #
96 #     // Added a run-pass test? Use this to test running your test
97 #     make check-stage1-rpass TESTNAME=my-shiny-new-test
98 #
99 #     // Having trouble figuring out which test is failing? Turn off parallel tests
100 #     make check-stage1-std RUST_TEST_THREADS=1
101 #
102 #     // To make debug!() and other logging calls visible, reconfigure:
103 #     ./configure --enable-debug-assertions
104 #     make ....
105 #
106 # If you really feel like getting your hands dirty, then:
107 #
108 #     run `make nitty-gritty`
109 #
110 # # Make command examples
111 #
112 # ## Docs linked commands
113 #
114 # * make check-stage1-rustdocck: Builds rustdoc. It has the advantage to compile
115 #                                quite quickly since we're only using stage1
116 #                                executables.
117 # * make doc/error-index.md: Gets all doc blocks from doc comments and error
118 #                            explanations to put them in a markdown file. You
119 #                            can then test them by running
120 #                            "rustdoc --test error-index.md".
121 #
122 # And of course, the wonderfully useful 'make tidy'! Always run it before opening a pull request to rust!
123 #
124 # </tips>
125 #
126 # <nitty-gritty>
127 #
128 # # The Rust Build System
129 #
130 # Gosh I wish there was something useful here (TODO).
131 #
132 # # An (old) explanation of how the build is structured:
133 #
134 # *Note: Hey, like, this is probably inaccurate, and is definitely
135 # an outdated and insufficient explanation of the remarkable
136 # Rust Build System.*
137 #
138 # There are multiple build stages (0-3) needed to verify that the
139 # compiler is properly self-hosting. Each stage is divided between
140 # 'host' artifacts and 'target' artifacts, where the stageN host
141 # compiler builds artifacts for 1 or more stageN target architectures.
142 # Once the stageN target compiler has been built for the host
143 # architecture it is promoted (copied) to a stageN+1 host artifact.
144 #
145 # The stage3 host compiler is a compiler that successfully builds
146 # itself and should (in theory) be bitwise identical to the stage2
147 # host compiler. The process is bootstrapped using a stage0 host
148 # compiler downloaded from a previous snapshot.
149 #
150 # At no time should stageN artifacts be interacting with artifacts
151 # from other stages. For consistency, we use the 'promotion' logic
152 # for all artifacts, even those that don't make sense on non-host
153 # architectures.
154 #
155 # The directory layout for a stage is intended to match the layout
156 # of the installed compiler, and looks like the following:
157 #
158 # stageN - this is the system root, corresponding to, e.g. /usr
159 #   bin - binaries compiled for the host
160 #   lib - libraries used by the host compiler
161 #     rustlib - rustc's own place to organize libraries
162 #       $(target) - target-specific artifacts
163 #         bin - binaries for target architectures
164 #         lib - libraries for target architectures
165 #
166 # A note about host libraries:
167 #
168 # The only libraries that get promoted to stageN/lib are those needed
169 # by rustc. In general, rust programs, even those compiled for the
170 # host architecture will use libraries from the target
171 # directories. This gives rust some freedom to experiment with how
172 # libraries are managed and versioned without polluting the common
173 # areas of the filesystem.
174 #
175 # General rust binaries may still live in the host bin directory; they
176 # will just link against the libraries in the target lib directory.
177 #
178 # Admittedly this is a little convoluted.
179 #
180 # If you find yourself working on the make infrastructure itself, and trying to
181 # find the value of a given variable after expansion, you can use:
182 #
183 # make print-VARIABLE_NAME
184 #
185 # To extract it
186 #
187 # </nitty-gritty>
188 #
189
190 ######################################################################
191 # Primary rules
192 ######################################################################
193
194 # Issue #9531: If you change the order of any of the following (or add
195 # new definitions), make sure definitions always precede their uses,
196 # especially for the dependency lists of recipes.
197
198 # First, load the variables exported by the configure script
199 include config.mk
200
201 # Just a few macros used everywhere
202 include $(CFG_SRC_DIR)mk/util.mk
203 # Reconfiguring when the makefiles or submodules change
204 include $(CFG_SRC_DIR)mk/reconfig.mk
205 # All crates and their dependencies
206 include $(CFG_SRC_DIR)mk/crates.mk
207 # Various bits of setup, common macros, and top-level rules
208 include $(CFG_SRC_DIR)mk/main.mk
209 # C and assembly components that are not LLVM
210 include $(CFG_SRC_DIR)mk/rt.mk
211 # Rules for crates in the target directories
212 include $(CFG_SRC_DIR)mk/target.mk
213 # Rules for crates in the host directories
214 include $(CFG_SRC_DIR)mk/host.mk
215 # Special rules for bootstrapping stage0
216 include $(CFG_SRC_DIR)mk/stage0.mk
217 # Rust-specific LLVM extensions
218 include $(CFG_SRC_DIR)mk/rustllvm.mk
219 # Documentation
220 include $(CFG_SRC_DIR)mk/docs.mk
221 # LLVM
222 include $(CFG_SRC_DIR)mk/llvm.mk
223 # Rules for installing debugger scripts
224 include $(CFG_SRC_DIR)mk/debuggers.mk
225
226 ######################################################################
227 # Secondary makefiles, conditionalized for speed
228 ######################################################################
229
230 # The test suite
231 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
232                $(findstring test,$(MAKECMDGOALS))  \
233                $(findstring tidy,$(MAKECMDGOALS))),)
234   CFG_INFO := $(info cfg: including test rules)
235   include $(CFG_SRC_DIR)mk/tests.mk
236   include $(CFG_SRC_DIR)mk/grammar.mk
237 endif
238
239 # Copy all the distributables to another directory for binary install
240 ifneq ($(strip $(findstring prepare,$(MAKECMDGOALS)) \
241                $(findstring dist,$(MAKECMDGOALS)) \
242                $(findstring install,$(MAKECMDGOALS))),)
243   CFG_INFO := $(info cfg: including prepare rules)
244   include $(CFG_SRC_DIR)mk/prepare.mk
245 endif
246
247 # Source and binary distribution artifacts
248 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
249                $(findstring install,$(MAKECMDGOALS)) \
250                $(findstring clean,$(MAKECMDGOALS))),)
251   CFG_INFO := $(info cfg: including dist rules)
252   include $(CFG_SRC_DIR)mk/dist.mk
253 endif
254
255 # (Unix) Installation from the build directory
256 ifneq ($(findstring install,$(MAKECMDGOALS)),)
257   CFG_INFO := $(info cfg: including install rules)
258   include $(CFG_SRC_DIR)mk/install.mk
259 endif
260
261 # Cleaning
262 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
263   CFG_INFO := $(info cfg: including clean rules)
264   include $(CFG_SRC_DIR)mk/clean.mk
265 endif
266
267 # CTAGS building
268 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
269                $(findstring TAGS.vi,$(MAKECMDGOALS))),)
270   CFG_INFO := $(info cfg: including ctags rules)
271   include $(CFG_SRC_DIR)mk/ctags.mk
272 endif
273
274 .DEFAULT:
275         @echo
276         @echo "======================================================"
277         @echo "== If you need help, run 'make help' or 'make tips' =="
278         @echo "======================================================"
279         @echo
280         exit 1