-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (37 loc) · 1.53 KB
/
Copy pathMakefile
File metadata and controls
53 lines (37 loc) · 1.53 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# $@ = target file
# $< = first dependency
# $^ = all dependencies
C_SOURCES = $(wildcard kernel/*.c kernel/*/*.c kernel/*/*/*.c drivers/*.c drivers/*/*.c cpu/*.c)
HEADERS = $(wildcard kernel/*.h kernel/*/*.h kernel/*/*/*.h drivers/*.h drivers/*/*.h cpu/*.h)
OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}
GCC = /usr/local/i386elfgcc/bin/i386-elf-gcc
LD = /usr/local/i386elfgcc/bin/i386-elf-ld
GDB = gdb
CFLAGS = -g
# First rule is the one executed when no parameters are fed to the Makefile
all: run
%.o: %.c ${HEADERS}
${GCC} ${CFLAGS} -ffreestanding -c $< -o $@
%.o: %.asm
nasm $< -f elf -o $@
%.bin: %.asm
nasm $< -f bin -o $@
kernel/kernel.bin: boot_sector/32bit/kernel_entry.o ${OBJ}
${LD} -o $@ -Ttext 0x1000 $^ --oformat binary
# debugging
kernel/kernel.elf: boot_sector/32bit/kernel_entry.o ${OBJ}
${LD} -o $@ -Ttext 0x1000 $^
boot_sector/boot_sector.bin: ./boot_sector/boot_sector.asm
nasm -f bin $^ -o $@
os-image.bin: boot_sector/boot_sector.bin kernel/kernel.bin
rm $@ &
cp empty_hhd.bin $@ &
cat $^ > $@
run: os-image.bin
qemu-system-i386 -drive id=disk,file=$<,if=none,format=raw -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0
debug: os-image.bin kernel/kernel.elf
qemu-system-i386 -s -drive id=disk,file=$<,if=none,format=raw -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -d guest_errors,int &
${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel/kernel.elf"
clean:
rm -rf *.o *.dis os-image.bin *.elf
rm -rf kernel/*.o boot_sector/*.bin drivers/*.o drivers/*/*.o boot/*.o cpu/*.o