mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2026-03-02 03:49:21 +00:00
lesson 13, first kernel
This commit is contained in:
32
13-kernel-barebones/Makefile
Normal file
32
13-kernel-barebones/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
# $@ = target file
|
||||
# $< = first dependency
|
||||
# $^ = all dependencies
|
||||
|
||||
# First rule is the one executed when no paramaters are fed to the Makefile
|
||||
all: run
|
||||
|
||||
# Notice how dependencies are built as needed
|
||||
kernel.bin: kernel_entry.o kernel.o
|
||||
i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary
|
||||
|
||||
kernel_entry.o: kernel_entry.asm
|
||||
nasm $< -f elf -o $@
|
||||
|
||||
kernel.o: kernel.c
|
||||
i386-elf-gcc -ffreestanding -c $< -o $@
|
||||
|
||||
# Rule to disassemble the kernel - may be useful to debug
|
||||
kernel.dis: kernel.bin
|
||||
ndisasm -b 32 $< > $@
|
||||
|
||||
bootsect.bin: bootsect.asm
|
||||
nasm $< -f bin -o $@
|
||||
|
||||
os-image.bin: bootsect.bin kernel.bin
|
||||
cat $^ > os-image.bin
|
||||
|
||||
run: os-image.bin
|
||||
qemu-system-i386 -fda $<
|
||||
|
||||
clean:
|
||||
rm *.bin *.o *.dis
|
||||
Reference in New Issue
Block a user