basickernel/Makefile

34 lines
591 B
Makefile
Raw Normal View History

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-24 09:00:00 +00:00
OBJ=kernel/kernel_entry.o kernel/kernel.o kernel/ports.o
2018-02-23 17:50:05 +00:00
2018-02-23 17:11:06 +00:00
all: os-image
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
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-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