2012-12-10 19:32:48 -06:00
|
|
|
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
# file at the top-level directory of this distribution and at
|
|
|
|
# http://rust-lang.org/COPYRIGHT.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
# option. This file may not be copied, modified, or distributed
|
|
|
|
# except according to those terms.
|
|
|
|
|
2014-02-13 23:22:08 -06:00
|
|
|
# <help>
|
|
|
|
#
|
|
|
|
# # The Rust Build System
|
|
|
|
#
|
|
|
|
# Start with these these build targets:
|
|
|
|
#
|
|
|
|
# * all - The default rule. Builds a complete stage2 compiler, std,
|
|
|
|
# and extra for all hosts and targets
|
|
|
|
# * docs - Generate HTML documentation for the std and extra libraries
|
|
|
|
# from source code comments
|
|
|
|
# * rustc - The stage 2 compiler for the build platform with standard
|
|
|
|
# and extra libraries
|
|
|
|
# * install
|
|
|
|
# * uninstall
|
|
|
|
# * check - Run tests
|
|
|
|
# * check-stage1-$(crate) - Run tests for a crate, e.g. `check-stage1-std`
|
|
|
|
# * check-stage1-rpass - Run the language tests
|
|
|
|
# * check-docs - Run the doc tests
|
|
|
|
#
|
|
|
|
# Then mix in some of these environment variables to harness the
|
|
|
|
# ultimate power of Rust Build System.
|
|
|
|
#
|
|
|
|
# * `VERBOSE=1` - Print all commands. Use this to see what's going on.
|
|
|
|
# * `RUSTFLAGS=...` - Add compiler flags to all `rustc` invocations
|
|
|
|
# * `CFG_ENABLE_VALGRIND=1` - Run tests under valgrind
|
|
|
|
# * `VALGRIND_COMPILE=1` - Run the compiler itself under valgrind
|
|
|
|
# (may require `CFG_ENABLE_VALGRIND`)
|
|
|
|
# * `NO_REBUILD=1` - Don't rebootstrap when testing std
|
|
|
|
# (and possibly other crates)
|
2014-02-14 02:10:06 -06:00
|
|
|
# * `NO_MKFILE_DEPS=1` - Don rebuild for modified .mk files
|
2014-02-13 23:22:08 -06:00
|
|
|
# * `SAVE_TEMPS=1` - Use `--save-temps` flag on all `rustc` invocations
|
|
|
|
# * `ASM_COMMENTS=1` - Use `-Z asm-comments`
|
|
|
|
# * `TIME_PASSES=1` - Use `-Z time-passes`
|
|
|
|
# * `TIME_LLVM_PASSES=1` - Use `-Z time-llvm-passes`
|
|
|
|
# * `TRACE=1` - Use `-Z trace`
|
|
|
|
#
|
|
|
|
# This is hardly all there is to know of The Rust Build System's
|
|
|
|
# mysteries. Your journey continues on the wiki[1][2].
|
|
|
|
#
|
|
|
|
# [1]: https://github.com/mozilla/rust/wiki/Note-build-system
|
|
|
|
# [2]: https://github.com/mozilla/rust/wiki/Note-testsuite
|
|
|
|
#
|
|
|
|
# </help>
|
|
|
|
#
|
|
|
|
# # An (old) explanation of how the build is structured:
|
|
|
|
#
|
|
|
|
# *Note: Hey, like, this is probably inaccurate, and is definitely
|
|
|
|
# an outdated and insufficient explanation of the remarkable
|
|
|
|
# and discomfiting Rust Build System.*
|
2011-10-01 22:12:08 -05:00
|
|
|
#
|
|
|
|
# There are multiple build stages (0-3) needed to verify that the
|
|
|
|
# compiler is properly self-hosting. Each stage is divided between
|
|
|
|
# 'host' artifacts and 'target' artifacts, where the stageN host
|
|
|
|
# compiler builds artifacts for 1 or more stageN target architectures.
|
|
|
|
# Once the stageN target compiler has been built for the host
|
|
|
|
# architecture it is promoted (copied) to a stageN+1 host artifact.
|
|
|
|
#
|
|
|
|
# The stage3 host compiler is a compiler that successfully builds
|
|
|
|
# itself and should (in theory) be bitwise identical to the stage2
|
|
|
|
# host compiler. The process is bootstrapped using a stage0 host
|
|
|
|
# compiler downloaded from a previous snapshot.
|
|
|
|
#
|
|
|
|
# At no time should stageN artifacts be interacting with artifacts
|
|
|
|
# from other stages. For consistency, we use the 'promotion' logic
|
|
|
|
# for all artifacts, even those that don't make sense on non-host
|
|
|
|
# architectures.
|
|
|
|
#
|
|
|
|
# The directory layout for a stage is intended to match the layout
|
|
|
|
# of the installed compiler, and looks like the following:
|
|
|
|
#
|
|
|
|
# stageN - this is the system root, corresponding to, e.g. /usr
|
|
|
|
# bin - binaries compiled for the host
|
|
|
|
# lib - libraries used by the host compiler
|
2014-01-04 19:55:20 -06:00
|
|
|
# rustlib - rustc's own place to organize libraries
|
2011-10-01 22:12:08 -05:00
|
|
|
# $(target) - target-specific artifacts
|
|
|
|
# bin - binaries for target architectures
|
|
|
|
# lib - libraries for target architectures
|
|
|
|
#
|
|
|
|
# A note about host libraries:
|
|
|
|
#
|
|
|
|
# The only libraries that get promoted to stageN/lib are those needed
|
2011-11-03 12:53:49 -05:00
|
|
|
# by rustc. In general, rust programs, even those compiled for the
|
2011-10-01 22:12:08 -05:00
|
|
|
# host architecture will use libraries from the target
|
|
|
|
# directories. This gives rust some freedom to experiment with how
|
|
|
|
# libraries are managed and versioned without polluting the common
|
|
|
|
# areas of the filesystem.
|
|
|
|
#
|
|
|
|
# General rust binaries may stil live in the host bin directory; they
|
|
|
|
# will just link against the libraries in the target lib directory.
|
|
|
|
#
|
|
|
|
# Admittedly this is a little convoluted.
|
|
|
|
|
2013-03-02 06:25:12 -06:00
|
|
|
######################################################################
|
2014-02-14 01:55:49 -06:00
|
|
|
# Primary rules
|
2011-03-21 13:23:19 -05:00
|
|
|
######################################################################
|
|
|
|
|
2013-09-26 16:56:53 -05:00
|
|
|
# Issue #9531: If you change the order of any of the following (or add
|
|
|
|
# new definitions), make sure definitions always precede their uses,
|
|
|
|
# especially for the dependency lists of recipes.
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# First, load the variables exported by the configure script
|
|
|
|
include config.mk
|
|
|
|
|
|
|
|
# Just a few macros used everywhere
|
|
|
|
include $(CFG_SRC_DIR)mk/util.mk
|
|
|
|
# All crates and their dependencies
|
|
|
|
include $(CFG_SRC_DIR)mk/crates.mk
|
|
|
|
# Reconfiguring when the makefiles or submodules change
|
|
|
|
include $(CFG_SRC_DIR)mk/reconfig.mk
|
|
|
|
# Various bits of setup, common macros, and top-level rules
|
|
|
|
include $(CFG_SRC_DIR)mk/main.mk
|
|
|
|
# C and assembly components that are not LLVM
|
2013-10-31 01:57:27 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/rt.mk
|
2014-02-14 01:55:49 -06:00
|
|
|
# Rules for crates in the target directories
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/target.mk
|
2014-02-14 01:55:49 -06:00
|
|
|
# Rules for crates in the host directories
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/host.mk
|
2014-02-14 01:55:49 -06:00
|
|
|
# Special rules for bootstrapping stage0
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/stage0.mk
|
2014-02-14 01:55:49 -06:00
|
|
|
# Rust-specific LLVM extensions
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/rustllvm.mk
|
2014-02-14 01:55:49 -06:00
|
|
|
# Documentation
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/docs.mk
|
2014-02-14 01:55:49 -06:00
|
|
|
# LLVM
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/llvm.mk
|
2011-06-25 14:23:27 -05:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Secondary makefiles, conditionalized for speed
|
|
|
|
######################################################################
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# Source and binary distribution artifacts
|
2011-06-30 15:41:20 -05:00
|
|
|
ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
|
|
|
|
$(findstring check,$(MAKECMDGOALS)) \
|
|
|
|
$(findstring test,$(MAKECMDGOALS)) \
|
2011-07-13 17:44:09 -05:00
|
|
|
$(findstring tidy,$(MAKECMDGOALS)) \
|
2011-06-30 15:41:20 -05:00
|
|
|
$(findstring clean,$(MAKECMDGOALS))),)
|
|
|
|
CFG_INFO := $(info cfg: including dist rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/dist.mk
|
2011-06-25 14:23:27 -05:00
|
|
|
endif
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# Binary snapshots
|
2011-06-30 15:41:20 -05:00
|
|
|
ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
|
|
|
|
$(findstring clean,$(MAKECMDGOALS))),)
|
|
|
|
CFG_INFO := $(info cfg: including snap rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/snap.mk
|
2011-06-25 14:23:27 -05:00
|
|
|
endif
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# The test suite
|
2011-06-30 15:41:20 -05:00
|
|
|
ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
|
|
|
|
$(findstring test,$(MAKECMDGOALS)) \
|
2011-09-13 17:06:21 -05:00
|
|
|
$(findstring perf,$(MAKECMDGOALS)) \
|
2011-06-30 15:41:20 -05:00
|
|
|
$(findstring tidy,$(MAKECMDGOALS))),)
|
|
|
|
CFG_INFO := $(info cfg: including test rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/tests.mk
|
2011-06-25 14:23:27 -05:00
|
|
|
endif
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# Performance and benchmarking
|
2011-09-13 17:06:21 -05:00
|
|
|
ifneq ($(findstring perf,$(MAKECMDGOALS)),)
|
|
|
|
CFG_INFO := $(info cfg: including perf rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/perf.mk
|
2011-09-13 17:06:21 -05:00
|
|
|
endif
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# Cleaning
|
2011-06-25 14:23:27 -05:00
|
|
|
ifneq ($(findstring clean,$(MAKECMDGOALS)),)
|
2011-06-30 15:41:20 -05:00
|
|
|
CFG_INFO := $(info cfg: including clean rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/clean.mk
|
2011-07-21 13:58:01 -05:00
|
|
|
endif
|
2011-09-30 21:00:19 -05:00
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# Installation from the build directory
|
2011-09-30 21:00:19 -05:00
|
|
|
ifneq ($(findstring install,$(MAKECMDGOALS)),)
|
|
|
|
CFG_INFO := $(info cfg: including install rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/install.mk
|
2011-10-12 14:10:21 -05:00
|
|
|
endif
|
|
|
|
|
2014-02-14 01:55:49 -06:00
|
|
|
# CTAGS building
|
2011-10-12 14:10:21 -05:00
|
|
|
ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
|
|
|
|
$(findstring TAGS.vi,$(MAKECMDGOALS))),)
|
|
|
|
CFG_INFO := $(info cfg: including ctags rules)
|
2012-03-26 18:05:33 -05:00
|
|
|
include $(CFG_SRC_DIR)mk/ctags.mk
|
2011-10-12 14:10:21 -05:00
|
|
|
endif
|
2012-06-14 13:07:19 -05:00
|
|
|
|
|
|
|
# Find all of the .d files and include them to add information about
|
|
|
|
# header file dependencies.
|
|
|
|
ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
|
|
|
|
-include $(ALL_DEP_FILES)
|