diff --git a/Makefile b/Makefile index 85a20a9..905c5cd 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,33 @@ ASM=nasm -AFLAGS=-f bin BIN=bin CFLAGS=-ffreestanding -fno-pie -m32 CC=gcc LD=ld LDFLAGS=-melf_i386 -Ttext 0x1000 --oformat binary +OBJ=kernel/kernel_entry.o kernel/kernel.o + all: os-image -os-image: boot_sect.bin kernel.bin +os-image: boot/boot_sect.bin kernel.bin mkdir -p $(BIN) cat $^ > $(BIN)/$@ # build kernel binary file -kernel.bin: kernel_entry.o kernel.o +kernel.bin: $(OBJ) $(LD) $(LDFLAGS) $^ -o $@ -# build kernel object file -kernel.o: kernel.c +%.o: %.c ${HEADERS} $(CC) $(CFLAGS) -c $< -o $@ -# build kernel entry object file -kernel_entry.o: kernel_entry.asm - $(ASM) -f elf $< -o $@ - -boot_sect.bin: boot_sect.asm - $(ASM) $< $(AFLAGS) -o $@ - -basicos: boot_sect.bin kernel.bin - mkdir -p $(BIN) - cat boot_sect.bin kernel.bin > $(BIN)/os-image +%.o: %.asm + $(ASM) $< -f elf -o $@ +%.bin: %.asm + $(ASM) $< -f bin -I 'boot/' -o $@ .PHONY: clean clean: - rm -f *.bin *.o + rm -rf boot/*.bin boot/*.o + rm -rf kernel/*.o boot/*.o drivers/*.o diff --git a/boot_sect.asm b/boot/boot_sect.asm similarity index 100% rename from boot_sect.asm rename to boot/boot_sect.asm diff --git a/disk.asm b/boot/disk.asm similarity index 100% rename from disk.asm rename to boot/disk.asm diff --git a/gdt.asm b/boot/gdt.asm similarity index 100% rename from gdt.asm rename to boot/gdt.asm diff --git a/print.asm b/boot/print.asm similarity index 100% rename from print.asm rename to boot/print.asm diff --git a/print32.asm b/boot/print32.asm similarity index 100% rename from print32.asm rename to boot/print32.asm diff --git a/switch_prot.asm b/boot/switch_prot.asm similarity index 100% rename from switch_prot.asm rename to boot/switch_prot.asm diff --git a/kernel.c b/kernel/kernel.c similarity index 100% rename from kernel.c rename to kernel/kernel.c diff --git a/kernel_entry.asm b/kernel/kernel_entry.asm similarity index 100% rename from kernel_entry.asm rename to kernel/kernel_entry.asm