-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (88 loc) · 3.42 KB
/
Makefile
File metadata and controls
105 lines (88 loc) · 3.42 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
define ALL_HELP_INFO
########################################################
# A simple Makefile to help with common tasks. #
########################################################
#
#
# Global targets:
#
# post-create # run the post-create.sh of the devcontainer
# build # build TacOS
# kernel # build the kernel
# boot # assemble the bootloader
# link # link the kernel and bootloader
# iso # create an ISO image of the kernel
# run # run the kernel in QEMU
# clean # clean build artifacts
# fclean # clean build artifacts and cargo cache
# check-tools # check if all required tools are installed
# setup-42-linux # setup the 42 Linux environment (compile and install everything fine...except grub-pc still missing)
# vm-42-start # start the Vagrant VM
# vm-42-delete # delete the Vagrant VM
#
# format # format the code using rustfmt
# test # run unit tests on host
endef
.PHONY: all
all: iso
.PHONY: help
help:
${ALL_HELP_INFO}
CARGO_KERNEL = cargo -Z build-std=core,compiler_builtins -Z build-std-features=compiler-builtins-mem
KERNEL_TARGET = target-specs/i686-custom.json
.PHONY: build
build:
@cargo clean -p tacos --release --target $(KERNEL_TARGET) 2>/dev/null || true
RUSTFLAGS="-C force-frame-pointers=yes" $(CARGO_KERNEL) rustc --release --target $(KERNEL_TARGET) --lib -- --emit=obj
RUSTFLAGS="-C force-frame-pointers=yes" $(CARGO_KERNEL) rustc --release --target $(KERNEL_TARGET) --bin tacos -- --emit=obj
.PHONY: kernel
kernel:
RUSTFLAGS="-C force-frame-pointers=yes" $(CARGO_KERNEL) build --release --target $(KERNEL_TARGET)
.PHONY: boot
boot:
as --32 boot/boot.s -o boot/boot.o
.PHONY: link
link: build boot
ld -m elf_i386 -T linker.ld -o kernel.elf boot/boot.o target/i686-custom/release/deps/tacos-*.o
.PHONY: iso
iso: link
mkdir -p iso/boot/grub
cp kernel.elf iso/boot/kernel.bin
cp grub.cfg iso/boot/grub/grub.cfg
grub-mkrescue -o tacos.iso iso
.PHONY: run
run: iso
@qemu-system-i386 -cdrom tacos.iso -display curses -boot d -device isa-debug-exit,iobase=0xf4,iosize=0x04 || true
.PHONY: clean
clean:
rm -rf boot/boot.o iso/ kernel.elf tacos.iso
.PHONY: fclean
fclean: clean
cargo clean
.PHONY: check-tools
check-tools:
@command -v cargo >/dev/null 2>&1 || { echo >&2 "cargo is not installed. Aborting."; exit 1; }
@command -v as >/dev/null 2>&1 || { echo >&2 "GNU as is not installed. Aborting."; exit 1; }
@command -v ld >/dev/null 2>&1 || { echo >&2 "ld is not installed. Aborting."; exit 1; }
@command -v grub-mkrescue >/dev/null 2>&1 || { echo >&2 "grub-mkrescue is not installed. Aborting."; exit 1; }
@command -v qemu-system-i386 >/dev/null 2>&1 || { echo >&2 "qemu-system-i386 is not installed. Aborting."; exit 1; }
.PHONY: setup-42-linux
setup-42-linux:
@./setup-42-linux.sh
.PHONY: vm-42-start
vm-42-start:
# @vboxmanage setproperty machinefolder ~/sgoinfre
@VBoxManage list systemproperties | grep "Default machine folder:"
@vboxmanage setproperty machinefolder ~/goinfre
@VBoxManage list systemproperties | grep "Default machine folder:"
@vagrant up
.PHONY: vm-42-delete
vm-42-delete:
@vagrant destroy -f
rm -rf ./vagrant/
.PHONY: format
format:
cargo fmt
.PHONY: test
test:
cargo test --lib --target i686-unknown-linux-gnu