summaryrefslogtreecommitdiff
path: root/run_rustc/Makefile
blob: 19a87a38d37df330b2f658b2937aff76a419143c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Makefile that builds libstd using the mrustc-built rustc

RUSTC := ../output/rustc
RUST_SRC := ../rustc-1.19.0-src/src/

PREFIX := prefix/
BINDIR := $(PREFIX)bin/
LIBDIR := $(PREFIX)lib/

V ?= @


all: $(LIBDIR)libstd.rlib $(BINDIR)hello_world

RUSTFLAGS_liblibc := --cfg stdbuild
RUSTFLAGS_libstd := -l dl -l rt -l pthread
RUSTFLAGS_libunwind := -l gcc_s

$(RUSTC):
	make -C ../ output/rustc -j 3
../output/cargo:
	make -C ../ output/cargo -j 3

$(BINDIR)rustc: $(RUSTC)
	@mkdir -p $(dir $@)
	$Vcp $@ $<
$(BINDIR)cargo: ../output/cargo
	@mkdir -p $(dir $@)
	$Vcp $@ $<

#$(LIBDIR)libstd.rlib: $(RUSTC) $(BINDIR)cargo
#	$(BINDIR)cargo 

$(LIBDIR)%.rlib: $(RUST_SRC)%/lib.rs $(RUSTC)
	@mkdir -p $(dir $@)
	@echo "[RUSTC] -o $@"
	$Vtime $(DBG) $(RUSTC) $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@ $(RUSTFLAGS_$*)
$(LIBDIR)%.rlib: $(RUST_SRC)%/src/lib.rs $(RUSTC)
	@mkdir -p $(dir $@)
	@echo "[RUSTC] -o $@"
	$Vtime $(DBG) $(RUSTC) $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@ $(RUSTFLAGS_$*)

$(BINDIR)hello_world: $(RUST_SRC)test/run-pass/hello.rs $(LIBDIR)libstd.rlib $(RUSTC) 
	$Vmkdir -p $(dir $@)
	@echo "[RUSTC] -o $@"
	$Vtime $(DBG) $(RUSTC) $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@

fcn_extcrate = $(patsubst %,$(LIBDIR)lib%.rlib,$(1))

$(LIBDIR)libarena.rlib: $(call fcn_extcrate, std)
$(LIBDIR)liballoc.rlib: $(call fcn_extcrate, core)
$(LIBDIR)libstd_unicode.rlib: $(call fcn_extcrate, core)
$(LIBDIR)libcollections.rlib: $(call fcn_extcrate, core alloc std_unicode)
$(LIBDIR)librand.rlib: $(call fcn_extcrate, core)
$(LIBDIR)liblibc.rlib: $(call fcn_extcrate, core)
$(LIBDIR)libcompiler_builtins.rlib: $(call fcn_extcrate, core)
$(LIBDIR)libstd.rlib: $(call fcn_extcrate, core collections rand libc unwind compiler_builtins alloc_system panic_unwind)
$(LIBDIR)libunwind.rlib: $(call fcn_extcrate, core libc)