-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
34 lines (27 loc) · 879 Bytes
/
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
MAIN := kernel.elf
ISO := kernel.iso
LINKFLAGS := -nostdlib -m32 -Wl,-T,$(shell pwd)/src/link.ld,--build-id=none
QEMU := qemu-system-i386
QEMUFLAGS := -no-reboot -no-shutdown -m 4096
$(MAIN): $(shell find src | grep .cr) Makefile src/link.ld
@echo Creating $@...
@crystal build src/main.cr --target=i386 --prelude=empty --link-flags "$(LINKFLAGS)" -o $@
.PHONY: clean
clean:
@rm -rf $(MAIN) $(ISO) iso
.PHONY: run
run: $(MAIN)
@$(QEMU) $(QEMUFLAGS) -kernel $(MAIN)
.PHONY: runiso
runiso: $(iso)
@$(QEMU) $(QEMUFLAGS) -cdrom $(ISO)
.PHONY: iso
iso: $(ISO)
$(ISO): $(MAIN) Makefile
@mkdir -p iso/boot/grub
@cp $(MAIN) iso/boot/
@echo "set timeout=0" > iso/boot/grub/grub.cfg
@echo "menuentry \"crystal kernel\" {" >> iso/boot/grub/grub.cfg
@echo " multiboot /boot/$(MAIN)" >> iso/boot/grub/grub.cfg
@echo "}" >> iso/boot/grub/grub.cfg
@grub2-mkrescue iso -o $@