Organizing the kernel code.
This commit is contained in:
parent
7a2618dd4d
commit
78c1155430
27
Makefile
27
Makefile
@ -1,38 +1,33 @@
|
||||
ASM=nasm
|
||||
AFLAGS=-f bin
|
||||
BIN=bin
|
||||
CFLAGS=-ffreestanding -fno-pie -m32
|
||||
CC=gcc
|
||||
LD=ld
|
||||
LDFLAGS=-melf_i386 -Ttext 0x1000 --oformat binary
|
||||
|
||||
OBJ=kernel/kernel_entry.o kernel/kernel.o
|
||||
|
||||
all: os-image
|
||||
|
||||
os-image: boot_sect.bin kernel.bin
|
||||
os-image: boot/boot_sect.bin kernel.bin
|
||||
mkdir -p $(BIN)
|
||||
cat $^ > $(BIN)/$@
|
||||
|
||||
# build kernel binary file
|
||||
kernel.bin: kernel_entry.o kernel.o
|
||||
kernel.bin: $(OBJ)
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
# build kernel object file
|
||||
kernel.o: kernel.c
|
||||
%.o: %.c ${HEADERS}
|
||||
$(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)
|
||||
cat boot_sect.bin kernel.bin > $(BIN)/os-image
|
||||
%.o: %.asm
|
||||
$(ASM) $< -f elf -o $@
|
||||
|
||||
%.bin: %.asm
|
||||
$(ASM) $< -f bin -I 'boot/' -o $@
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f *.bin *.o
|
||||
rm -rf boot/*.bin boot/*.o
|
||||
rm -rf kernel/*.o boot/*.o drivers/*.o
|
||||
|
Loading…
Reference in New Issue
Block a user