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