forked from 9xbt/kiwios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (42 loc) · 1.31 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
# assembler
ASM = /usr/bin/nasm
# compiler
CC = /usr/bin/gcc
# linker
LD = /usr/bin/ld
# grub iso creator
GRUB = /usr/bin/grub-mkrescue
# sources
SRC = SRC
ASM_SRC = src/kernel/i386/asm
KERNEL_SRC = src/kernel
# objects
BIN = bin
OBJ = obj
CONFIG = config
# flags
ASM_FLAGS = -f elf32
CC_FLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra -Wno-implicit-function-declaration
all: build run
build:
mkdir -p $(BIN)/boot/grub
mkdir -p $(OBJ)
@printf "[ Assembling... ]\n"
$(ASM) -f elf32 -o $(OBJ)/entry.o $(ASM_SRC)/entry.s
$(ASM) -f elf32 -o $(OBJ)/exception.o $(ASM_SRC)/exception.s
$(ASM) -f elf32 -o $(OBJ)/irq.o $(ASM_SRC)/irq.s
$(ASM) -f elf32 -o $(OBJ)/gdt.o $(ASM_SRC)/gdt.s
$(ASM) -f elf32 -o $(OBJ)/idt.o $(ASM_SRC)/idt.s
@printf "[ Compiling... ]\n"
$(CC) -m32 -c -I include $(KERNEL_SRC)/kernel.c -o $(OBJ)/kernel.o $(CC_FLAGS)
@printf "[ Linking... ]\n"
@$(LD) -m elf_i386 -T $(CONFIG)/linker.ld $(OBJ)/kernel.o $(OBJ)/entry.o $(OBJ)/exception.o $(OBJ)/irq.o $(OBJ)/gdt.o $(OBJ)/idt.o -o $(BIN)/boot/kiwios.elf -nostdlib
@printf "[ Checking... ]\n"
grub-file --is-x86-multiboot $(BIN)/boot/kiwios.elf
cp $(CONFIG)/grub.cfg $(BIN)/boot/grub/grub.cfg
grub-mkrescue -o kiwios.iso $(BIN)/
run:
qemu-system-x86_64 -cdrom kiwios.iso
clean:
rm -rf $(BIN)
rm -f $(OBJ)/*.o