forked from cfenollosa/os-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
32 lines (23 loc) · 686 Bytes
/
Makefile
File metadata and controls
32 lines (23 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# $@ = target file
# $< = first dependency
# $^ = all dependencies
# First rule is the one executed when no parameters 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 $^ > $@
run: os-image.bin
qemu-system-i386 -fda $<
clean:
rm *.bin *.o *.dis