2014-10-15 17:00:21 +00:00
|
|
|
# $@ = target file
|
|
|
|
# $< = first dependency
|
|
|
|
# $^ = all dependencies
|
|
|
|
|
2014-10-15 17:03:32 +00:00
|
|
|
# First rule is the one executed when no parameters are fed to the Makefile
|
2014-10-15 17:00:21 +00:00
|
|
|
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
|