More complete Makefile.

This commit is contained in:
Nicolás Ortega Froysa 2018-02-23 18:11:06 +01:00
parent b8fe2bd8a3
commit 7a2618dd4d
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF

View File

@ -6,12 +6,29 @@ CC=gcc
LD=ld LD=ld
LDFLAGS=-melf_i386 -Ttext 0x1000 --oformat binary 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) 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 cat boot_sect.bin kernel.bin > $(BIN)/os-image