caos-with-snake/Makefile

48 lines
969 B
Makefile
Raw Normal View History

2022-09-21 16:53:45 +03:00
AS=x86_64-elf-as
LD=x86_64-elf-ld
2022-09-21 18:25:06 +03:00
CC=x86_64-elf-gcc
2022-09-21 16:53:45 +03:00
2022-09-21 18:25:06 +03:00
run: image.bin
2022-09-21 16:53:45 +03:00
qemu-system-i386 -drive format=raw,file=$<
2022-11-18 18:33:40 +03:00
debug-boot: image.bin mbr.elf
qemu-system-i386 -drive format=raw,file=$< -s -S &
x86_64-elf-gdb mbr.elf \
-ex "target remote localhost:1234" \
-ex "break init_32bit" \
-ex "continue"
2022-09-21 18:25:06 +03:00
debug: image.bin
2022-09-21 17:37:27 +03:00
qemu-system-i386 -drive format=raw,file=$< -s -S &
2022-11-18 18:33:40 +03:00
x86_64-elf-gdb kernel.bin \
2022-09-21 17:37:27 +03:00
-ex "target remote localhost:1234" \
2022-11-18 18:33:40 +03:00
-ex "break _start" \
2022-09-21 17:37:27 +03:00
-ex "continue"
2022-11-18 22:58:49 +03:00
fs.img: kernel.bin tools/mkfs
tools/mkfs $@ $<
image.bin: mbr.bin fs.img
2022-09-21 18:25:06 +03:00
cat $^ >$@
2022-11-17 23:16:57 +03:00
kernel.bin: kernel.o vga.o string.o drivers/ata.o
$(LD) -m elf_i386 -o $@ -Ttext 0x1000 $^
2022-09-21 18:25:06 +03:00
%.o: %.c
2022-11-18 18:33:40 +03:00
$(CC) -m32 -ffreestanding -c -g $< -o $@
2022-09-21 18:25:06 +03:00
2022-09-21 16:53:45 +03:00
%.o: %.S
2022-11-18 22:58:49 +03:00
$(AS) --32 -g $^ -o $@
2022-09-21 16:53:45 +03:00
mbr.bin: mbr.o
2022-11-18 19:27:04 +03:00
$(LD) -m elf_i386 -Ttext=0x7c00 --oformat=binary $^ -o $@
2022-09-21 16:53:45 +03:00
2022-11-18 18:33:40 +03:00
mbr.elf: mbr.o
2022-11-18 19:27:04 +03:00
$(LD) -m elf_i386 -Ttext=0x7c00 $^ -o $@
2022-11-18 18:33:40 +03:00
2022-09-21 17:37:27 +03:00
clean:
2022-11-18 22:58:49 +03:00
rm -f *.bin *.o tools/mkfs
tools/%: tools/%.c
gcc -Wall -Werror -g $^ -o $@