ARCHDIR=arch/i686 CFLAGS?= ASFLAGS?= INCLUDEDIR=include CFLAGS:=\ -O2 \ -std=gnu99 \ -ffreestanding \ -Wall -Wextra \ -I$(INCLUDEDIR) \ $(CFLAGS) ASFLAGS:=\ -I$(INCLUDEDIR) \ -I$(ARCHDIR) \ $(ASFLAGS) KERNEL_OBJS=\ kernel/kernel.o \ kernel/debugging.o \ kernel/elf.o \ kernel/syscall.o \ kernel/io/keyboard.o \ kernel/heap.o \ kernel/task.o \ LIB_OBJS=\ $(ARCHDIR)/bootstrap.o \ $(ARCHDIR)/tty.o \ $(ARCHDIR)/strlib.o \ $(ARCHDIR)/paging.o \ $(ARCHDIR)/gdt.o \ $(ARCHDIR)/interrupts/idt.o \ $(ARCHDIR)/interrupts/interrupt.o \ $(ARCHDIR)/interrupts/irq0.o \ $(ARCHDIR)/interrupts/syscall.o \ $(ARCHDIR)/interrupts/pic.o \ OBJS=$(KERNEL_OBJS) $(LIB_OBJS) LDFLAGS=$(OBJS) \ -ffreestanding \ -O2 \ -nostdlib \ -lgcc .PHONY: all clean myos.iso .SUFFIXES: .c .o .s all: myos.iso clean: rm -f $(OBJS) rm -f myos.kernel rm -f myos.iso rm -f isodir/boot/myos.kernel $(ARCHDIR)/interrupts/interrupt.o: CFLAGS += -mgeneral-regs-only # kernel/elf.o: CFLAGS += -masm=intel %.o : %.c i686-elf-gcc -c $< -o $@ $(CFLAGS) %.o : %.s i686-elf-as $< -o $@ $(ASFLAGS) myos.kernel: $(OBJS) i686-elf-gcc -T $(ARCHDIR)/linker.ld -o myos.kernel $(LDFLAGS) grub-file --is-x86-multiboot myos.kernel myos.iso: myos.kernel cp myos.kernel isodir/boot/myos.kernel grub-mkrescue -o myos.iso isodir debug: CFLAGS += -g -O0 debug: ASFLAGS += -g debug: all run: all qemu-system-i386 myos.iso run-debug: debug qemu-system-i386 -S -gdb tcp::9000 myos.iso