-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
58 lines (46 loc) · 1.67 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
BUILD?=debug
KERNEL_ELF=target/x86_64-kernel/$(BUILD)/kernel
KERNEL_BIN=target/x86_64-kernel/$(BUILD)/kernel.bin
KERNEL_OBJS=\
target/x86_64-kernel/start.o \
target/x86_64-kernel/isrs.o \
target/x86_64-kernel/aux.o \
ifeq ($(BUILD),release)
CARGO_FLAGS=--release
endif
default: hdd.img
.PHONY: clean
clean:
rm -f hdd.img
rm -f target/loader/stage*.bin
rm -f target/x86_64-kernel/start.o
cargo clean
make -C userland clean
hdd.img: hdd.base.img target/loader/stage0.bin target/loader/stage1.bin $(KERNEL_BIN)
make -C userland
cp hdd.base.img hdd.img
MTOOLSRC=mtoolsrc mformat C:
MTOOLSRC=mtoolsrc mcopy target/loader/stage1.bin C:/KERNEL.1
MTOOLSRC=mtoolsrc mcopy $(KERNEL_BIN) C:/KERNEL.2
MTOOLSRC=mtoolsrc mcopy userland/target/bin/* C:/
dd if=target/loader/stage0.bin of=$@ bs=446 count=1 conv=notrunc,sync
$(KERNEL_BIN): $(KERNEL_ELF)
x86_64-elf-objcopy -R .bss -R .stack -O binary $(KERNEL_ELF) $(KERNEL_BIN)
.PHONY: $(KERNEL_ELF)
$(KERNEL_ELF): kernel/linker.ld $(KERNEL_OBJS)
cargo xbuild --target=kernel/x86_64-kernel.json $(CARGO_FLAGS)
target/loader/stage0.bin: kernel/loader/stage0.asm kernel/loader/fat.asm kernel/src/consts.asm
mkdir -p target/loader
nasm -f bin -o $@ $<
target/loader/stage1.bin: kernel/loader/stage1.asm kernel/loader/fat.asm kernel/src/consts.asm
mkdir -p target/loader
nasm -f bin -o $@ $<
target/loader/stage2.bin: kernel/loader/stage2.asm kernel/src/consts.asm
mkdir -p target/loader
nasm -f bin -o $@ $<
target/x86_64-kernel/%.o: kernel/src/%.asm kernel/src/consts.asm target/loader/stage2.bin
mkdir -p target/x86_64-kernel
nasm -f elf64 -o $@ $<
target/x86_64-kernel/%.bin: kernel/src/%.asm
mkdir -p $$(dirname '$@')
nasm -f bin -o $@ $<