-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (43 loc) · 1.26 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
TARGET = boot-floppy
KERNEL = k/k/k
KERNEL_PATH = k
SOURCE_FS ?= ./k/iso
CPPFLAGS = -DKERNEL_PATH=$(KERNEL_PATH)
COMMON = -static -m32 -ggdb
ASFLAGS = $(COMMON) -ffreestanding -fno-asynchronous-unwind-tables
CFLAGS = $(ASFLAGS) -Os -fno-stack-protector
LDFLAGS = $(COMMON) -nostdlib -Tlinker.ld -n -Wl,--build-id=none -nostartfiles
OBJS = boot.o gdt.o panic.o bios.o elf_loader.o
all: $(TARGET)-emu.iso
$(TARGET): $(TARGET).o $(OBJS)
$(SOURCE_FS):
$(MAKE) -C k
$(KERNEL):
$(MAKE) -C k
%.bin: %
objcopy -O binary $^ $@
%.img: %.bin $(KERNEL)
dd if=/dev/zero of=$@ bs=1024 count=1440
mkfs.fat -f1 -R1 -F16 $@
mcopy -i $@ $(KERNEL) "::$(KERNEL_PATH)"
dd if=$< of=$@ bs=1 count=448 seek=62 conv=notrunc
%-emu.iso: %.img $(SOURCE_FS)
xorriso -as mkisofs -U -b $< -o $@ $^
%.iso: %.bin $(SOURCE_FS)
xorriso -as mkisofs -U -no-emul-boot -b $< -o $@ $^
run-img-%: %.img
qemu-system-i386 -fda $^ $(QEMU_FLAGS)
run-iso-%: %.iso
qemu-system-i386 -cdrom $^ $(QEMU_FLAGS)
run-iso-emu-%: %-emu.iso
qemu-system-i386 -cdrom $^ $(QEMU_FLAGS)
kvm-%: QEMU_FLAGS = -enable-kvm
kvm-%: run-%
#
dbg-%: QEMU_FLAGS = -s -S
dbg-%: run-%
#
clean:
$(RM) -f $(OBJS) $(TARGET).o $(TARGET) $(TARGET).bin $(TARGET).img $(TARGET).iso $(TARGET)-emu.iso
$(MAKE) -C k clean
.PHONY: all clean