Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 1 | ###################################################################### |
| 2 | # Residual auto-configuration |
| 3 | ###################################################################### |
| 4 | |
| 5 | include config.mk |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 6 | MKFILES := Makefile config.mk $(wildcard $(CFG_SRC_DIR)/mk/*.mk) |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 7 | |
| 8 | ifneq ($(MAKE_RESTARTS),) |
| 9 | CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) |
| 10 | endif |
| 11 | |
| 12 | CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE)) |
| 13 | |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 14 | ifdef CFG_DISABLE_OPTIMIZE |
Graydon Hoare | 19ebc0f | 2011-04-08 23:29:19 | [diff] [blame] | 15 | $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) |
Patrick Walton | c52fb52 | 2011-04-29 17:23:07 | [diff] [blame] | 16 | CFG_RUSTC_FLAGS := |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 17 | else |
Patrick Walton | c52fb52 | 2011-04-29 17:23:07 | [diff] [blame] | 18 | CFG_RUSTC_FLAGS := -O |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 19 | endif |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 20 | |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 21 | ifdef SAVE_TEMPS |
Marijn Haverbeke | 6b11f6c | 2011-04-26 18:32:08 | [diff] [blame] | 22 | CFG_RUSTC_FLAGS += --save-temps |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 23 | endif |
Patrick Walton | 648c4ae | 2011-04-29 18:55:32 | [diff] [blame] | 24 | ifdef TIME_PASSES |
| 25 | CFG_RUSTC_FLAGS += --time-passes |
| 26 | endif |
Patrick Walton | 9aeb679 | 2011-04-29 19:16:14 | [diff] [blame] | 27 | ifdef NO_TYPESTATE |
| 28 | CFG_RUSTC_FLAGS += --no-typestate |
| 29 | endif |
Patrick Walton | 404db4d | 2011-05-11 00:48:49 | [diff] [blame] | 30 | ifdef DEBUG |
| 31 | CFG_RUSTC_FLAGS += -g |
| 32 | endif |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 33 | |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 34 | # platform-specific auto-configuration |
| 35 | include $(CFG_SRC_DIR)/mk/platform.mk |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 36 | |
| 37 | CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt) |
Graydon Hoare | 7ac885e | 2011-03-22 06:06:42 | [diff] [blame] | 38 | CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 39 | CFG_STDLIB :=$(call CFG_LIB_NAME,std) |
Brian Anderson | 9a12ad6 | 2011-05-06 01:32:58 | [diff] [blame] | 40 | CFG_RUSTCLIB :=$(call CFG_LIB_NAME,rustc) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 41 | |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 42 | # version-string calculation |
| 43 | CFG_GIT_DIR := $(CFG_SRC_DIR).git |
| 44 | CFG_VERSION := prerelease |
| 45 | ifneq ($(wildcard $(CFG_GIT_DIR)),) |
| 46 | CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \ |
| 47 | --pretty=format:'(%h %ci)') |
| 48 | endif |
| 49 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 50 | ifdef CFG_OCAMLC_OPT |
| 51 | $(info cfg: have ocaml native compiler) |
| 52 | OPT=.opt |
Ralph Giles | 0b2cfca | 2011-05-04 23:24:47 | [diff] [blame] | 53 | else ifdef CFG_OCAMLC |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 54 | $(info cfg: have only ocaml bytecode compiler) |
| 55 | endif |
| 56 | |
Graydon Hoare | 94731fa | 2011-03-30 04:45:09 | [diff] [blame] | 57 | ifdef CFG_DISABLE_VALGRIND |
| 58 | $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND)) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 59 | CFG_VALGRIND := |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 60 | endif |
Patrick Walton | 518e2d2 | 2011-05-06 01:11:40 | [diff] [blame] | 61 | ifdef CFG_BAD_VALGRIND |
| 62 | $(info cfg: disabling valgrind due to its unreliability on this platform) |
| 63 | CFG_VALGRIND := |
| 64 | endif |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 65 | |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 66 | DOCS := |
| 67 | ifeq ($(CFG_MAKEINFO),) |
| 68 | $(info cfg: no makeinfo found, omitting doc/rust.html) |
| 69 | else |
| 70 | DOCS += doc/rust.html |
| 71 | endif |
| 72 | |
| 73 | ifeq ($(CFG_TEXI2PDF),) |
| 74 | $(info cfg: no texi2pdf found, omitting doc/rust.pdf) |
| 75 | else |
Graydon Hoare | f740747 | 2011-03-23 20:31:51 | [diff] [blame] | 76 | ifeq ($(CFG_TEX),) |
| 77 | $(info cfg: no tex found, omitting doc/rust.pdf) |
| 78 | else |
| 79 | DOCS += doc/rust.pdf |
| 80 | endif |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 81 | endif |
| 82 | |
Graydon Hoare | 94731fa | 2011-03-30 04:45:09 | [diff] [blame] | 83 | ifdef CFG_DISABLE_DOCS |
| 84 | $(info cfg: disabling doc build (CFG_DISABLE_DOCS)) |
| 85 | DOCS := |
| 86 | endif |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 87 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 88 | ###################################################################### |
| 89 | # Target-and-rule "utility variables" |
| 90 | ###################################################################### |
| 91 | |
| 92 | ifdef VERBOSE |
| 93 | Q := |
| 94 | E = |
| 95 | else |
| 96 | Q := @ |
| 97 | E = echo $(1) |
| 98 | endif |
| 99 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 100 | S := $(CFG_SRC_DIR) |
| 101 | X := $(CFG_EXE_SUFFIX) |
| 102 | |
| 103 | # Look in doc and src dirs. |
| 104 | VPATH := $(S)doc $(S)src |
| 105 | |
| 106 | # Compilers we build, we now know how to run. |
Graydon Hoare | 73ba2dd | 2011-04-30 18:44:27 | [diff] [blame] | 107 | STAGE0 := $(Q)$(call CFG_RUN_TARG,stage0,\ |
| 108 | stage0/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage1) |
| 109 | STAGE1 := $(Q)$(call CFG_RUN_TARG,stage1, \ |
| 110 | stage1/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage2) |
| 111 | STAGE2 := $(Q)$(call CFG_RUN_TARG,stage2, \ |
| 112 | stage2/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage3) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 113 | |
| 114 | # "Source" files we generate in builddir along the way. |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 115 | GENERATED := |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 116 | |
| 117 | # Delete the built-in rules. |
| 118 | .SUFFIXES: |
| 119 | %:: %,v |
| 120 | %:: RCS/%,v |
| 121 | %:: RCS/% |
| 122 | %:: s.% |
| 123 | %:: SCCS/s.% |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 124 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 125 | ###################################################################### |
| 126 | # Standard library variables |
| 127 | ###################################################################### |
| 128 | |
Graydon Hoare | 6597439 | 2011-03-21 20:42:29 | [diff] [blame] | 129 | STDLIB_CRATE := $(S)src/lib/std.rc |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 130 | STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs)) |
| 131 | |
| 132 | ###################################################################### |
| 133 | # rustc crate variables |
| 134 | ###################################################################### |
| 135 | |
Graydon Hoare | 6597439 | 2011-03-21 20:42:29 | [diff] [blame] | 136 | COMPILER_CRATE := $(S)src/comp/rustc.rc |
Graydon Hoare | 874a7bf | 2011-03-19 00:30:06 | [diff] [blame] | 137 | COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \ |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 138 | rustc.rc *.rs */*.rs)) |
| 139 | |
| 140 | ###################################################################### |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 141 | # Main target dependency variables |
Graydon Hoare | 4691a75 | 2011-03-20 08:12:26 | [diff] [blame] | 142 | ###################################################################### |
| 143 | |
Graydon Hoare | 7ac885e | 2011-03-22 06:06:42 | [diff] [blame] | 144 | LREQ := rt/$(CFG_RUNTIME) rustllvm/$(CFG_RUSTLLVM) |
Graydon Hoare | 73ba2dd | 2011-04-30 18:44:27 | [diff] [blame] | 145 | SREQ0 := stage0/rustc$(X) $(LREQ) stage1/glue.o stage1/$(CFG_STDLIB) |
| 146 | SREQ1 := stage1/rustc$(X) $(LREQ) stage2/glue.o stage2/$(CFG_STDLIB) |
| 147 | SREQ2 := stage2/rustc$(X) $(LREQ) stage3/glue.o stage3/$(CFG_STDLIB) |
Graydon Hoare | 4691a75 | 2011-03-20 08:12:26 | [diff] [blame] | 148 | |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 149 | |
Graydon Hoare | 4691a75 | 2011-03-20 08:12:26 | [diff] [blame] | 150 | ###################################################################### |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 151 | # Exports for sub-utilities |
| 152 | ###################################################################### |
| 153 | |
| 154 | export CFG_SRC_DIR |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 155 | export CFG_VERSION |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 156 | |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 157 | ###################################################################### |
| 158 | # Subprograms |
| 159 | ###################################################################### |
| 160 | |
| 161 | LLVM_AS := $(CFG_LLVM_BINDIR)/llvm-as |
| 162 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 163 | |
| 164 | ###################################################################### |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 165 | # Single-target rules |
| 166 | ###################################################################### |
| 167 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame^] | 168 | ifneq ($(CFG_IN_TRANSITION),) |
| 169 | |
| 170 | CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***) |
| 171 | CFG_INFO := $(info cfg: *** stage2 and later will not be built ***) |
| 172 | |
| 173 | all: rt/$(CFG_RUNTIME) \ |
| 174 | rustllvm/$(CFG_RUSTLLVM) \ |
| 175 | stage0/$(CFG_STDLIB) \ |
| 176 | stage0/intrinsics.bc \ |
| 177 | stage0/rustc$(X) \ |
| 178 | $(GENERATED) \ |
| 179 | $(DOCS) \ |
| 180 | stage1/$(CFG_STDLIB) \ |
| 181 | stage1/intrinsics.bc \ |
| 182 | stage1/glue.o \ |
| 183 | stage1/rustc$(X) \ |
| 184 | |
| 185 | else |
| 186 | |
Graydon Hoare | 4f52ab5 | 2011-05-03 22:51:21 | [diff] [blame] | 187 | all: rt/$(CFG_RUNTIME) \ |
Graydon Hoare | 7ac885e | 2011-03-22 06:06:42 | [diff] [blame] | 188 | rustllvm/$(CFG_RUSTLLVM) \ |
Graydon Hoare | 4691a75 | 2011-03-20 08:12:26 | [diff] [blame] | 189 | stage0/$(CFG_STDLIB) \ |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 190 | stage0/intrinsics.bc \ |
Graydon Hoare | 73ba2dd | 2011-04-30 18:44:27 | [diff] [blame] | 191 | stage0/rustc$(X) \ |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 192 | $(GENERATED) \ |
Graydon Hoare | 73ba2dd | 2011-04-30 18:44:27 | [diff] [blame] | 193 | $(DOCS) \ |
| 194 | stage1/$(CFG_STDLIB) \ |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 195 | stage1/intrinsics.bc \ |
Graydon Hoare | 5d1c8db | 2011-05-03 00:56:15 | [diff] [blame] | 196 | stage1/glue.o \ |
| 197 | stage1/rustc$(X) \ |
| 198 | stage2/$(CFG_STDLIB) \ |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 199 | stage2/intrinsics.bc \ |
Graydon Hoare | 5d1c8db | 2011-05-03 00:56:15 | [diff] [blame] | 200 | stage2/glue.o \ |
Graydon Hoare | 4f52ab5 | 2011-05-03 22:51:21 | [diff] [blame] | 201 | stage2/rustc$(X) \ |
| 202 | stage3/$(CFG_STDLIB) \ |
| 203 | stage3/glue.o \ |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 204 | stage3/intrinsics.bc \ |
Graydon Hoare | 4f52ab5 | 2011-05-03 22:51:21 | [diff] [blame] | 205 | stage3/rustc$(X) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 206 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame^] | 207 | endif |
| 208 | |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 209 | |
| 210 | ###################################################################### |
| 211 | # Re-configuration |
| 212 | ###################################################################### |
| 213 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame^] | 214 | config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 215 | @$(call E, cfg: reconfiguring) |
| 216 | $(S)configure $(CFG_CONFIGURE_ARGS) |
| 217 | |
| 218 | |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 219 | ###################################################################### |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 220 | # Additional makefiles |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 221 | ###################################################################### |
| 222 | |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 223 | include $(CFG_SRC_DIR)/mk/intrinsics.mk |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 224 | include $(CFG_SRC_DIR)/mk/stage0.mk |
| 225 | include $(CFG_SRC_DIR)/mk/stage1.mk |
| 226 | include $(CFG_SRC_DIR)/mk/stage2.mk |
Graydon Hoare | 4f52ab5 | 2011-05-03 22:51:21 | [diff] [blame] | 227 | include $(CFG_SRC_DIR)/mk/stage3.mk |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 228 | include $(CFG_SRC_DIR)/mk/rt.mk |
| 229 | include $(CFG_SRC_DIR)/mk/rustllvm.mk |
| 230 | include $(CFG_SRC_DIR)/mk/docs.mk |
| 231 | include $(CFG_SRC_DIR)/mk/tests.mk |
| 232 | include $(CFG_SRC_DIR)/mk/dist.mk |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 233 | include $(CFG_SRC_DIR)/mk/snap.mk |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 234 | include $(CFG_SRC_DIR)/mk/clean.mk |
| 235 | include $(CFG_SRC_DIR)/mk/autodep.mk |
Brian Anderson | a5ea56c | 2011-05-06 00:56:02 | [diff] [blame] | 236 | include $(CFG_SRC_DIR)/mk/fuzzer.mk |