]> git.lizzy.rs Git - rust.git/blob - Makefile.in
Fuzzer: first steps of making steal_exprs more generic
[rust.git] / Makefile.in
1 ######################################################################
2 # Residual auto-configuration
3 ######################################################################
4
5 include config.mk
6 MKFILES := Makefile config.mk $(wildcard $(CFG_SRC_DIR)/mk/*.mk)
7 MKFILES += $(CFG_SRC_DIR)/src/rt/libuv/Makefile
8 MKFILES += $(wildcard $(CFG_SRC_DIR)/src/rt/libuv/*.mk)
9
10 ifneq ($(MAKE_RESTARTS),)
11 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
12 endif
13
14 CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE))
15
16 ifdef CFG_DISABLE_OPTIMIZE
17   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
18   CFG_RUSTC_FLAGS :=
19 else
20   CFG_RUSTC_FLAGS := -O
21 endif
22
23 ifdef SAVE_TEMPS
24   CFG_RUSTC_FLAGS += --save-temps
25 endif
26 ifdef TIME_PASSES
27   CFG_RUSTC_FLAGS += --time-passes
28 endif
29 ifdef TIME_LLVM_PASSES
30   CFG_RUSTC_FLAGS += --time-llvm-passes
31 endif
32 ifdef NO_TYPESTATE
33   CFG_RUSTC_FLAGS += --no-typestate
34 endif
35 ifdef DEBUG
36   CFG_RUSTC_FLAGS += -g
37 endif
38
39 # platform-specific auto-configuration
40 include $(CFG_SRC_DIR)/mk/platform.mk
41
42 # Run the stage1/2 compilers under valgrind
43 ifdef VALGRIND_COMPILE
44   CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
45 else
46   CFG_VALGRIND_COMPILE :=
47 endif
48
49 CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
50 CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
51 CFG_STDLIB :=$(call CFG_LIB_NAME,std)
52 CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
53
54 ifdef CFG_DISABLE_SHAREDSTD
55   CFG_STDLIB_DEFAULT = $(1)/lib/libstd.rlib
56 else
57   CFG_STDLIB_DEFAULT = $(2)/$(CFG_STDLIB)
58 endif
59
60 # version-string calculation
61 CFG_GIT_DIR := $(CFG_SRC_DIR).git
62 CFG_VERSION = prerelease
63 ifneq ($(wildcard $(CFG_GIT)),)
64 ifneq ($(wildcard $(CFG_GIT_DIR)),)
65     CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
66                      --pretty=format:'(%h %ci)')
67 endif
68 endif
69
70 ifdef CFG_DISABLE_VALGRIND
71   $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND))
72   CFG_VALGRIND :=
73 endif
74 ifdef CFG_BAD_VALGRIND
75   $(info cfg: disabling valgrind due to its unreliability on this platform)
76   CFG_VALGRIND :=
77 endif
78
79 DOCS :=
80 ifeq ($(CFG_MAKEINFO),)
81   $(info cfg: no makeinfo found, omitting doc/rust.html)
82 else
83   DOCS += doc/rust.html
84 endif
85
86 ifeq ($(CFG_TEXI2PDF),)
87   $(info cfg: no texi2pdf found, omitting doc/rust.pdf)
88 else
89   ifeq ($(CFG_TEX),)
90     $(info cfg: no tex found, omitting doc/rust.pdf)
91   else
92     DOCS += doc/rust.pdf
93   endif
94 endif
95
96 ifdef CFG_DISABLE_DOCS
97   $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
98   DOCS :=
99 endif
100
101 ######################################################################
102 # Target-and-rule "utility variables"
103 ######################################################################
104
105 ifdef VERBOSE
106   Q :=
107   E =
108 else
109   Q := @
110   E = echo $(1)
111 endif
112
113 S := $(CFG_SRC_DIR)
114 X := $(CFG_EXE_SUFFIX)
115
116 # Look in doc and src dirs.
117 VPATH := $(S)doc $(S)src
118
119 # "Source" files we generate in builddir along the way.
120 GENERATED :=
121
122 # Delete the built-in rules.
123 .SUFFIXES:
124 %:: %,v
125 %:: RCS/%,v
126 %:: RCS/%
127 %:: s.%
128 %:: SCCS/s.%
129
130 ######################################################################
131 # Standard library variables
132 ######################################################################
133
134 STDLIB_CRATE := $(S)src/lib/std.rc
135 STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs))
136
137 ######################################################################
138 # rustc crate variables
139 ######################################################################
140
141 COMPILER_CRATE := $(S)src/comp/rustc.rc
142 COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \
143                                 rustc.rc *.rs */*.rs */*/*.rs))
144
145 ######################################################################
146 # Exports for sub-utilities
147 ######################################################################
148
149 export CFG_SRC_DIR
150 export CFG_BUILD_DIR
151 export CFG_VERSION
152 export CFG_LLVM_ROOT
153 export CFG_ENABLE_MINGW_CROSS
154
155 ######################################################################
156 # Subprograms
157 ######################################################################
158
159 LLVM_AS := $(CFG_LLVM_BINDIR)/llvm-as$(X)
160
161 LLC := $(CFG_LLVM_BINDIR)/llc$(X)
162
163 ######################################################################
164 # Per-stage targets and runner
165 ######################################################################
166
167 define SREQ
168 ifdef CFG_DISABLE_SHAREDSTD
169 SREQ$(1) = stage$(1)/rustc$(X)          \
170            stage$(1)/$$(CFG_RUNTIME)     \
171            $$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(1)) \
172            stage$(1)/$$(CFG_RUSTLLVM)    \
173            stage$(1)/lib/glue.o          \
174            stage$(1)/lib/main.o          \
175            stage$(1)/lib/$$(CFG_RUNTIME) \
176            $$(MKFILES)
177 else
178 SREQ$(1) = stage$(1)/rustc$(X)          \
179            stage$(1)/$$(CFG_RUNTIME)     \
180            $$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(1)) \
181            stage$(1)/$$(CFG_RUSTLLVM)    \
182            stage$(1)/lib/glue.o          \
183            stage$(1)/lib/main.o          \
184            stage$(1)/lib/$$(CFG_RUNTIME) \
185            stage$(1)/lib/$$(CFG_STDLIB)  \
186            $$(MKFILES)
187 endif
188
189 ifeq ($(1),0)
190 # Don't run the the stage0 compiler under valgrind - that ship has sailed
191 CFG_VALGRIND_COMPILE$(1) =
192 else
193 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
194 endif
195
196 STAGE$(1) := $$(Q)$$(call CFG_RUN_TARG,stage$(1), \
197                 $$(CFG_VALGRIND_COMPILE$(1)) stage$(1)/rustc$$(X) \
198                 $$(CFG_RUSTC_FLAGS))
199 endef
200
201 FUZZ := stage1/fuzzer$(X)
202
203 $(eval $(call SREQ,0))
204 $(eval $(call SREQ,1))
205 $(eval $(call SREQ,2))
206 $(eval $(call SREQ,3))
207
208 ######################################################################
209 # Entrypoint rule
210 ######################################################################
211
212 ifneq ($(CFG_IN_TRANSITION),)
213
214 CFG_INFO := $(info cfg:)
215 CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
216 CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
217 CFG_INFO := $(info cfg:)
218
219 all: $(SREQ0) $(SREQ1) $(GENERATED) $(DOCS) $(FUZZ)
220 else
221 all: $(SREQ0) $(SREQ1) $(SREQ2) $(SREQ3) $(GENERATED) $(DOCS) $(FUZZ)
222 endif
223
224
225 ######################################################################
226 # Re-configuration
227 ######################################################################
228
229 config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
230         @$(call E, cfg: reconfiguring)
231         $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
232
233
234 ######################################################################
235 # Primary-target makefiles
236 ######################################################################
237
238 include $(CFG_SRC_DIR)/mk/intrinsics.mk
239 include $(CFG_SRC_DIR)/mk/stageN.mk
240 include $(CFG_SRC_DIR)/mk/stage0.mk
241 include $(CFG_SRC_DIR)/mk/rt.mk
242 include $(CFG_SRC_DIR)/mk/rustllvm.mk
243 include $(CFG_SRC_DIR)/mk/autodep.mk
244 include $(CFG_SRC_DIR)/mk/fuzzer.mk
245 include $(CFG_SRC_DIR)/mk/docs.mk
246
247
248 ######################################################################
249 # Secondary makefiles, conditionalized for speed
250 ######################################################################
251
252 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS))   \
253                $(findstring check,$(MAKECMDGOALS))  \
254                $(findstring test,$(MAKECMDGOALS))   \
255                $(findstring tidy,$(MAKECMDGOALS))   \
256                $(findstring clean,$(MAKECMDGOALS))),)
257   CFG_INFO := $(info cfg: including dist rules)
258   include $(CFG_SRC_DIR)/mk/dist.mk
259 endif
260
261 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS))   \
262                $(findstring clean,$(MAKECMDGOALS))),)
263   CFG_INFO := $(info cfg: including snap rules)
264   include $(CFG_SRC_DIR)/mk/snap.mk
265 endif
266
267 ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
268   CFG_INFO := $(info cfg: including reformat rules)
269   include $(CFG_SRC_DIR)/mk/pp.mk
270 endif
271
272 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
273                $(findstring test,$(MAKECMDGOALS))  \
274                $(findstring tidy,$(MAKECMDGOALS))),)
275   CFG_INFO := $(info cfg: including test rules)
276   include $(CFG_SRC_DIR)/mk/tests.mk
277 endif
278
279 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
280   CFG_INFO := $(info cfg: including clean rules)
281   include $(CFG_SRC_DIR)/mk/clean.mk
282 endif