blob: e7c5182fbb72b0e95fb4ca30ff06546fcedfb012 (
plain)
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
|
OSNAME = mfsos
OSBIN = $(OSNAME).bin
KERNBIN = kernel.bin
ARCH = x86
ARCH_BOOT = arch/$(ARCH)/boot
BOOTBIN = $(ARCH_BOOT)/bootloader.bin
TARGET = i686-elf
TARGET_TOOLS = $(PWD)/tools/toolchain/bin/$(TARGET)-
CC = $(TARGET_TOOLS)gcc
LD = $(TARGET_TOOLS)ld
AS = $(TARGET_TOOLS)as
OBJDUMP = $(TARGET_TOOLS)objdump
C_SOURCES = \
kernel/main.c \
kernel/string.c \
drivers/video/console/vgacon.c
OBJECTS = ${C_SOURCES:.c=.o}
export CC LD AS OBJDUMP
.PHONY: all qemu objdump-boot objdump-kernel clean
all: $(OSBIN)
$(OSBIN): $(BOOTBIN) $(KERNBIN)
cat $^ > $@
dd if=/dev/zero bs=512 count=128 >> $@ # 65536
$(BOOTBIN):
$(MAKE) -C $(ARCH_BOOT)
$(KERNBIN): $(ARCH_BOOT)/head.o $(OBJECTS)
$(CC) -Wl,--oformat binary -Ttext 0x1000 -o $@ \
-ffreestanding -nostdlib \
$^ -lgcc
printf "Kernel size: 0x%x\n" `stat -c "%s" $@`
%.o: %.s
$(AS) $< -o $@
%.o: %.c
$(CC) -std=gnu89 -Wall -ffreestanding -nostdlib \
-I arch/$(ARCH)/include \
-I kernel \
-I drivers \
-c $< -o $@ -lgcc
qemu: $(OSBIN)
qemu-system-i386 -kernel $(OSBIN)
objdump-boot: $(BOOTBIN)
$(MAKE) -C $(ARCH_BOOT) objdump-bootsect objdump-setup
objdump-kernel: $(KERNBIN)
$(OBJDUMP) -D -m i386 -b binary \
--adjust-vma=0x1000 -Maddr32,data32 $<
clean:
$(MAKE) -C $(ARCH_BOOT) clean
rm -rf $(ARCH_BOOT)/head.o kernel/main.o
rm -rf $(KERNBIN) $(OSBIN) $(OBJECTS)
|