os/Makefile

39 lines
1007 B
Makefile
Raw Normal View History

2018-11-17 10:53:17 -06:00
PLAT=i386
C_SOURCES = $(wildcard kernel/*.c drivers/$(PLAT)/*.c libc/*.c cpu/$(PLAT)/*.c)
OBJ = $(C_SOURCES:.c=.o kernel/boot.o $(shell cat psinfo/$(PLAT)/o.txt))
CC = $(shell cat psinfo/$(PLAT)/cc.txt)
GDB = $(shell cat psinfo/$(PLAT)/gdb.txt)
2018-10-19 07:59:38 -05:00
CFLAGS = -g
2018-11-17 10:53:17 -06:00
run: os.iso
qemu-system-i386 -m 2G -d int -d cpu_reset -D qemu.log -boot d -cdrom os.iso
debug: os.iso kernel/kernel.elf
qemu-system-i386 -s -boot d -cdrom os.iso &
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file kernel/kernel.elf"
2018-11-05 08:36:46 -06:00
os.iso: kernel/kernel.elf initrd/*
cp kernel/kernel.elf iso/boot
cd initrd; \
tar -c -f "../iso/boot/initrd.tar" *
2018-11-04 16:12:54 -06:00
grub-mkrescue -o $@ iso
2018-11-17 10:53:17 -06:00
kernel/kernel.elf: $(OBJ)
2018-11-04 16:12:54 -06:00
i386-elf-ld -T linker.ld -o $@ $^
2018-10-19 07:59:38 -05:00
2018-11-17 10:53:17 -06:00
%.o: %.c h_files
$(CC) $(CFLAGS) -ffreestanding -c $< -o $@
2018-10-19 07:59:38 -05:00
%.o: %.asm
nasm $< -f elf -o $@
2018-10-28 13:28:45 -05:00
%.o: %.s
i386-elf-as $< -o $@
2018-11-17 10:53:17 -06:00
h_files: cpu/$(PLAT)/memory.h
rm -f cpu/memory.h
cp cpu/$(PLAT)/memory.h cpu/memory.h
2018-10-19 07:59:38 -05:00
clean:
2018-11-17 10:53:17 -06:00
rm -rf */*/*.o */*.o cpu/memory.h os.iso */*.elf iso/boot/initrd.tar