caos-with-snake/Makefile

67 lines
1.5 KiB
Makefile
Raw Normal View History

2022-11-25 09:57:00 +00:00
GDB=gdb
2022-11-25 09:18:38 +00:00
ifeq ($(shell uname -s),Darwin)
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-11-25 09:57:00 +00:00
GDB=x86_64-elf-gdb
2022-11-25 09:18:38 +00:00
endif
2022-09-21 16:53:45 +03:00
2022-09-21 18:25:06 +03:00
run: image.bin
2022-11-21 00:53:29 +03:00
qemu-system-i386 -drive format=raw,file=$< -serial mon:stdio
2022-09-21 16:53:45 +03:00
2022-11-25 09:57:00 +00:00
debug-preboot-nox: image.bin mbr.elf
qemu-system-i386 -nographic -drive format=raw,file=$< -s -S &
$(GDB) mbr.elf \
2022-11-20 22:17:13 +03:00
-ex "set architecture i8086" \
-ex "target remote localhost:1234" \
-ex "break *0x7c00" \
-ex "continue"
2022-11-18 18:33:40 +03:00
debug-boot: image.bin mbr.elf
qemu-system-i386 -drive format=raw,file=$< -s -S &
2022-11-25 09:57:00 +00:00
$(GDB) mbr.elf \
2022-11-18 18:33:40 +03:00
-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-25 09:57:00 +00:00
$(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-21 01:50:02 +03:00
fs.img: kernel.bin tools/mkfs user/false
2022-11-18 22:58:49 +03:00
tools/mkfs $@ $<
2022-11-21 01:50:02 +03:00
LDFLAGS=-m elf_i386
user/%: user/%.o user/crt.o
$(LD) $(LDFLAGS) -o $@ -Ttext 0x101000 $^
2022-11-18 22:58:49 +03:00
image.bin: mbr.bin fs.img
2022-09-21 18:25:06 +03:00
cat $^ >$@
2022-11-21 00:53:29 +03:00
kernel.bin: kernel.o console.o drivers/vga.o drivers/keyboard.o \
2022-11-22 21:24:49 +03:00
string.o drivers/ata.o cpu/vectors.o cpu/idt.o cpu/gdt.o drivers/uart.o
2022-11-21 01:50:02 +03:00
$(LD) $(LDFLAGS) -o $@ -Ttext 0x1000 $^
2022-09-21 18:25:06 +03:00
%.o: %.c
2022-11-20 19:48:55 +03:00
$(CC) -m32 -ffreestanding -Wall -Werror -c -g $< -o $@
2022-09-21 18:25:06 +03:00
2022-09-21 16:53:45 +03:00
%.o: %.S
2022-11-22 21:43:13 +03:00
$(CC) -m32 -ffreestanding -c -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-20 22:17:13 +03:00
rm -f *.elf *.img *.bin *.o */*.o tools/mkfs
2022-11-18 22:58:49 +03:00
tools/%: tools/%.c
gcc -Wall -Werror -g $^ -o $@