forked from haileys/rustboot
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
63 lines (45 loc) · 1.73 KB
/
Makefile
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
59
60
61
62
63
# TODO(ryan): I've changed as/ld to native cross compiler ones.
# Could this cause dependency problems in the future?
AS=as -march=i386 --32
LD=ld -melf_i386 -nostdlib
QEMU=qemu-system-i386
TARGET=i686-unknown-rustos-gnu
TARGET_SPEC=$(shell realpath ./$(TARGET))
QEMUARGS=-device rtl8139,vlan=0 -net user,id=net0,vlan=0 -net dump,vlan=0,file=/tmp/rustos-dump.pcap
SRC=src/
DEPS=lib/rust/cargo/std_deps
.PHONY: all clean cleanproj run debug vb target/$(TARGET)/libstd*.a rustos
all: boot.bin
run: boot.bin
$(QEMU) $(QEMUARGS) -kernel $<
debug: boot.bin
$(QEMU) $(QEMUARGS) -S -gdb tcp::3333 -kernel $< &
gdb $< -ex "target remote :3333" -ex "break _start" -ex "c"
vb: boot.iso
virtualbox --debug --startvm rustos
rustos: target/$(TARGET)/debug/libstd*.a $(SRC)/*.rs
deps: lib/rust/cargo/std_deps/Cargo.toml
ln -f -s $(shell realpath $(TARGET).json) $(DEPS) && cd $(DEPS) && cargo rustc --release --target $(TARGET) --verbose
target/$(TARGET)/debug/libstd*.a: Cargo.toml libmorestack.a libcompiler-rt.a lib_context.a deps
RUSTFLAGS="--sysroot=$(shell realpath .) -L ." cargo build --target $(TARGET) --verbose
boot.bin: $(SRC)/arch/x86/link.ld boot.o target/$(TARGET)/debug/libstd*.a interrupt.o context.o dependencies.o
$(LD) -o $@ -T $^
boot.iso: boot.bin
cp boot.bin src/isodir/boot/
grub-mkrescue -o boot.iso src/isodir
compiler-rt.o: $(SRC)/dummy-compiler-rt.s # needed for staticlib creation
$(AS) -o $@ $<
%.s: ../rust/src/rt/arch/i386/%.S
$(CPP) -o $@ $<
%.o: $(SRC)/arch/x86/%.s
$(AS) -o $@ $<
%.o: $(SRC)/%.s
$(AS) -o $@ $<
lib%.a: %.o
ar rcs $@ $<
clean: cleanproj
cargo clean
cd lib/rust/cargo/std_deps && cargo clean
cleanproj:
cargo clean
rm -f *.bin *.img *.iso *.rlib *.a *.so *.o *.s target/$(TARGET)/debug/libstd*.a