From 7a2618dd4db101d9c740660e4a8feaa7790da2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 23 Feb 2018 18:11:06 +0100 Subject: [PATCH] More complete Makefile. --- Makefile | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3f9e2aa..85a20a9 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,29 @@ CC=gcc LD=ld LDFLAGS=-melf_i386 -Ttext 0x1000 --oformat binary -basicos: +all: os-image + +os-image: boot_sect.bin kernel.bin + mkdir -p $(BIN) + cat $^ > $(BIN)/$@ + +# build kernel binary file +kernel.bin: kernel_entry.o kernel.o + $(LD) $(LDFLAGS) $^ -o $@ + +# build kernel object file +kernel.o: kernel.c + $(CC) $(CFLAGS) -c $< -o $@ + +# build kernel entry object file +kernel_entry.o: kernel_entry.asm + $(ASM) -f elf $< -o $@ + +boot_sect.bin: boot_sect.asm + $(ASM) $< $(AFLAGS) -o $@ + +basicos: boot_sect.bin kernel.bin mkdir -p $(BIN) - $(ASM) boot_sect.asm $(AFLAGS) -o boot_sect.bin - $(ASM) kernel_entry.asm -f elf -o kernel_entry.o - $(CC) $(CFLAGS) -c kernel.c -o kernel.o - $(LD) $(LDFLAGS) -o kernel.bin kernel_entry.o kernel.o cat boot_sect.bin kernel.bin > $(BIN)/os-image