# Variables ASM = nasm CC = gcc LD = ld QEMU = qemu-system-x86_64 # Flags CFLAGS = -m32 -ffreestanding -fno-pie -fno-stack-protector -mno-sse -mno-mmx -mno-sse2 -c LDFLAGS = -m elf_i386 -T link.ld --oformat binary # Objects OBJS = entry.o kmain.o idt.o interrupts.o keyboard.o shell.o # Targets all: os-image.bin os-image.bin: boot.bin kernel.bin cat $^ > $@ truncate -s 10k $@ boot.bin: boot.asm $(ASM) $< -f bin -o $@ kernel.bin: $(OBJS) $(LD) $(LDFLAGS) -o $@ $^ entry.o: entry.asm $(ASM) $< -f elf -o $@ interrupts.o: interrupts.asm $(ASM) $< -f elf -o $@ %.o: %.c $(CC) $(CFLAGS) $< -o $@ run: os-image.bin $(QEMU) -drive format=raw,file=$< clean: rm -f *.bin *.o