-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (28 loc) · 958 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
36
37
38
C_SOURCES = $(wildcard */*.c)
HEADERS = $(wildcard */*.h)
OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}
CC = /usr/local/i386elfgcc/bin/i386-elf-gcc
GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb
CFLAGS = -g -ffreestanding -Wall -Wextra -fno-exceptions -m32
os-image.bin: boot/bootsect.bin kernel.bin
cat $^ > os-image.bin
kernel.bin: boot/kernel_entry.o ${OBJ}
i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary
#i386-elf-ld -o $@ -T linker.ld $^ --oformat binary
kernel.elf: boot/kernel_entry.o ${OBJ}
i386-elf-ld -o $@ -Ttext 0x1000 $^
#i386-elf-ld -o $@ -T linker.ld $^
run: os-image.bin
qemu-system-i386 -fda os-image.bin
debug: os-image.bin kernel.elf
qemu-system-i386 -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 */*.o