-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
35 lines (26 loc) · 916 Bytes
/
Makefile
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
C_SOURCES = $(wildcard kernel/*.c drivers/*.c x86/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h x86/*.h)
OBJ = ${C_SOURCES:.c=.o x86/interrupt.o}
CC = /usr/bin/clang
GDB = /usr/bin/gdb
CFLAGS = --target=x86_64 -g -ffreestanding -Wall -Wextra -m32
os-image.bin: boot/boot.bin kernel.bin
cat $^ > os-image.bin
kernel.bin: boot/entry.o ${OBJ}
ld.lld -o $@ -Ttext 0x1000 $^ --oformat binary
kernel.elf: boot/entry.o ${OBJ}
ld.lld -o $@ -Ttext 0x1000 $^
run: os-image.bin
qemu-system-x86_64 -fda os-image.bin
debug: os-image.bin kernel.elf
qemu-system-x86_64 -s -fda os-image.bin &
${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
%.o: %.c ${HEADERS}
${CC} ${CFLAGS} -c $< -o $@
%.o: %.asm
nasm $< -f elf -o $@
%.bin: %.asm
nasm $< -f bin -o $@
clean:
rm -rf *.bin *.dis *.o os-image.bin *.elf
rm -rf kernel/*.o boot/*.bin boot/*.o x86/*.o drivers/*.o