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