CC = i686-elf-gcc CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I src/include LD = i686-elf-ld LD_FLAGS = -z max-page-size=0x1000 -T linker.ld AS = nasm ASFlAGS = -felf32 GENISO = genisoimage GENISOFLAGS = -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -input-charset utf8 -quiet -boot-info-table -A tree-os EMU = qemu-system-x86_64 EMUFLAGS = -m 256M -cdrom BUILD_FOLDER = build SOURCE_FILES := $(shell find src -name *.c -or -name *.asm -or -name *.s) OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) default: run run: tree-os.iso $(EMU) $(EMUFLAGS) $^ tree-os.iso: iso/boot/tree-os.bin grub-mkrescue -o $@ iso iso/boot/tree-os.bin: linker.ld $(OBJS) $(LD) $(LD_FLAGS) -o $@ $(OBJS) $(BUILD_FOLDER)/%.asm.o: %.asm mkdir -p $(dir $@) $(AS) $(ASFlAGS) $< -o $@ $(BUILD_FOLDER)/%.c.o: %.c mkdir -p $(dir $@) $(CC) $(CCFLAGS) -r $< -o $@ $(BUILD_FOLDER)/%.s.o: %.s mkdir -p $(dir $@) $(CC) $(CCFLAGS) -r $< -o $@ clean: rm -r $(BUILD_FOLDER) tree-os.iso iso/boot/tree-os.elf cleanELF: rm iso/boot/tree-os.elf