-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
32 lines (23 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
C_SOURCES = $(wildcard kernel/*.c kernel/include/*.c)
HEADERS = $(wildcard kernel/*.h kernel/include/*.h)
OBJ = ${C_SOURCES:.c=.o}
CC = i386elf-gcc/bin/i386-elf-gcc
LD = i386elf-gcc/bin/i386-elf-ld
CFLAGS = -g
boot.img: bootloader/boot.bin bootloader/loader.bin kernel.bin
dd if=bootloader/boot.bin of=boot.img bs=512 count=1 conv=notrunc
dd if=bootloader/loader.bin of=boot.img bs=512 count=5 seek=1 conv=notrunc
dd if=kernel.bin of=boot.img bs=512 count=100 seek=6 conv=notrunc
kernel.bin: kernel/kernel_entry.o kernel/include/interrupt.o kernel/include/graphic_asm.o ${OBJ}
${LD} -o $@ -Ttext 0x10000 $^ --oformat binary
run: boot.img
qemu-system-i386 -drive file=boot.img -soundhw pcspk
%.o: %.c ${HEADERS}
${CC} ${CFLAGS} -ffreestanding -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 bootloader/*.bin kernel/include/*.o bootloader/*.o