-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (37 loc) · 1.15 KB
/
Makefile
File metadata and controls
50 lines (37 loc) · 1.15 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
TARGET = i686-minios
KERNEL = target/$(TARGET)/release/libminios.a
ISO = miniOS.iso
ISODIR = out
AS = x86_64-elf-as
LD = x86_64-elf-ld
ASFLAGS = --32
LDFLAGS = -m elf_i386 -T linker.ld -nostdlib
BOOT_ASM = src/arch/boot.s
BOOT_OBJ = target/boot.o
.PHONY: all build clean qemu iso
all: clean build iso qemu
build: $(KERNEL)
$(KERNEL): FORCE
@echo "[cargo] building kernel..."
@cargo build --release --target $(TARGET).json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem
$(BOOT_OBJ): $(BOOT_ASM)
@mkdir -p target
@echo "[as] boot.s"
@$(AS) $(ASFLAGS) -o $@ $<
target/kernel.bin: $(BOOT_OBJ) $(KERNEL)
@echo "[ld] linking kernel..."
@$(LD) $(LDFLAGS) -o $@ $(BOOT_OBJ) $(KERNEL)
iso: target/kernel.bin
@echo "[iso] creating $(ISO)..."
@mkdir -p $(ISODIR)/boot/grub
@cp target/kernel.bin $(ISODIR)/boot/miniOS.kernel
@bash ./grub_config.sh
@i686-elf-grub-mkrescue -o $(ISO) $(ISODIR) 2>/dev/null
qemu: $(ISO)
@echo "[qemu] starting..."
@qemu-system-x86_64 -cdrom $(ISO) -serial stdio -m 128M
clean:
@echo "[clean]"
@cargo clean 2>/dev/null || true
@rm -rf $(ISODIR) $(ISO) target/boot.o target/kernel.bin serial.log grub.cfg
FORCE: