blob: 753f84feea567190d48663b3af7d919d9558b4db (
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
|
OSNAME = mfsos
OSBIN = $(OSNAME).bin
ARCH = x86
ARCH_BOOT = arch/$(ARCH)/boot
BOOTBIN = $(ARCH_BOOT)/bootloader.bin
OBJECTS = kernel/main.o
LINKER = kernel/linker.ld
BOOT_SRC = kernel/boot.s
BOOT_OBJ = ${BOOT_SRC:.s=.o}
TARGET_TOOLS = $(HOME)/path/to/cross/compiler/i686-elf-
CC = $(TARGET_TOOLS)gcc
export CC
LD = $(TARGET_TOOLS)ld
export LD
AS = $(TARGET_TOOLS)as
export AS
OBJDUMP = $(TARGET_TOOLS)objdump
export OBJDUMP
.PHONY: all qemu clean
all: $(OSBIN)
$(OSBIN): $(BOOT_OBJ) $(OBJECTS)
$(CC) -T $(LINKER) -o $(OSBIN) -ffreestanding -O2 -nostdlib \
$(OBJECTS) $(BOOT_OBJ) -lgcc
$(BOOTBIN):
$(MAKE) -C $(ARCH_BOOT)
%.o: %.s
$(AS) $< -o $@
%.o: %.c
$(CC) -c $< -o $@ \
-std=gnu89 -ffreestanding -O2 -Wall \
-Wpedantic -Wextra
qemu: $(OSBIN)
qemu-system-i386 -kernel $(OSBIN)
clean:
$(MAKE) -C $(ARCH_BOOT) clean
rm -rf $(BOOT_OBJ) $(OBJECTS)
rm -rf $(OSBIN)
|