2018-02-23 16:20:31 +00:00
|
|
|
ASM=nasm
|
|
|
|
BIN=bin
|
|
|
|
CFLAGS=-ffreestanding -fno-pie -m32
|
|
|
|
CC=gcc
|
|
|
|
LD=ld
|
|
|
|
LDFLAGS=-melf_i386 -Ttext 0x1000 --oformat binary
|
|
|
|
|
2018-02-23 17:50:05 +00:00
|
|
|
OBJ=kernel/kernel_entry.o kernel/kernel.o
|
|
|
|
|
2018-02-23 17:11:06 +00:00
|
|
|
all: os-image
|
|
|
|
|
2018-02-23 17:52:17 +00:00
|
|
|
os-image: boot/boot_sect.bin kernel/kernel.bin
|
2018-02-23 17:11:06 +00:00
|
|
|
mkdir -p $(BIN)
|
|
|
|
cat $^ > $(BIN)/$@
|
|
|
|
|
|
|
|
# build kernel binary file
|
2018-02-23 17:52:17 +00:00
|
|
|
kernel/kernel.bin: $(OBJ)
|
2018-02-23 17:11:06 +00:00
|
|
|
$(LD) $(LDFLAGS) $^ -o $@
|
|
|
|
|
2018-02-23 17:50:05 +00:00
|
|
|
%.o: %.c ${HEADERS}
|
2018-02-23 17:11:06 +00:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2018-02-23 17:50:05 +00:00
|
|
|
%.o: %.asm
|
|
|
|
$(ASM) $< -f elf -o $@
|
2018-02-23 16:20:31 +00:00
|
|
|
|
2018-02-23 17:50:05 +00:00
|
|
|
%.bin: %.asm
|
|
|
|
$(ASM) $< -f bin -I 'boot/' -o $@
|
2018-02-23 16:20:31 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean:
|
2018-02-23 17:50:05 +00:00
|
|
|
rm -rf boot/*.bin boot/*.o
|
|
|
|
rm -rf kernel/*.o boot/*.o drivers/*.o
|