2018-02-23 16:20:31 +00:00
|
|
|
ASM=nasm
|
|
|
|
BIN=bin
|
2018-02-24 09:00:00 +00:00
|
|
|
CFLAGS=-ffreestanding -fno-pie -m32 -ansi
|
2018-02-23 16:20:31 +00:00
|
|
|
CC=gcc
|
|
|
|
LD=ld
|
|
|
|
LDFLAGS=-melf_i386 -Ttext 0x1000 --oformat binary
|
|
|
|
|
2018-02-26 14:02:25 +00:00
|
|
|
OBJ=kernel/kernel_entry.o kernel/kernel.o kernel/ports.o kernel/util.o drivers/screen.o
|
2018-02-23 17:50:05 +00:00
|
|
|
|
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-26 15:53:13 +00:00
|
|
|
%.o: %.c
|
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-24 09:00:00 +00:00
|
|
|
rm -rf boot/*.bin kernel/*.bin
|
2018-02-23 17:50:05 +00:00
|
|
|
rm -rf kernel/*.o boot/*.o drivers/*.o
|