diff --git a/Makefile b/Makefile index 5f0234a..fd03b5d 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,10 @@ export CCFLAGS = -fno-builtin -m32 -Wall -nostartfiles -nostdlib -nostdinc -std= export ASFLAGS = -f elf32 export LDFLAGS = -melf_i386 -Ttext 0x1000 --oformat binary # -T linker.ld -.PHONY: all run debug qemu bochs clean libc zbos kernel bootloader +export KERNEL_INCDIR = $(shell pwd)/kernel/include +export LIBC_INCDIR = $(shell pwd)/libc/include + +.PHONY: all run debug qemu bochs clean libc zbos kernel bootloader prereq all: libc zbos @@ -19,18 +22,19 @@ bochs: all clean: find . -iname "*.img" -o -iname "*.bin" -o -iname "*.o" -o -iname "*.a" | xargs rm -v -libc: +prereq: + mkdir -p build + +libc: prereq cd libc; make -zbos: kernel bootloader - mkdir -p build +zbos: kernel bootloader prereq dd if=/dev/zero of=build/zero.img bs=64K count=1 - cat boot/boot.img kernel/kernel.bin build/zero.img > build/zbos.img - rm build/zero.img + cat build/boot.img build/kernel.bin build/zero.img > build/zbos.img -kernel: +kernel: prereq cd kernel; make -bootloader: +bootloader: prereq cd boot; make diff --git a/boot/Makefile b/boot/Makefile index cc906eb..adad43a 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -6,4 +6,5 @@ all: boot.img boot.img: ${SOURCES} nasm -f bin -o $@ main.asm + cp $@ ../build diff --git a/kernel/Makefile b/kernel/Makefile index c14d68c..10cb03a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -10,7 +10,9 @@ entry.o: entry.asm nasm $(ASFLAGS) -o entry.o entry.asm %.o: %.c ${HEADERS} - gcc $(CCFLAGS) -o $@ $< -I../libc + gcc $(CCFLAGS) -o $@ $< -I$(KERNEL_INCDIR) -I$(LIBC_INCDIR) kernel.bin: entry.o kernel.o ${OBJ} - ld $(LDFLAGS) -o $@ $^ -L../libc -lc + ld $(LDFLAGS) -o $@ $^ -L../build -lc + cp $@ ../build + diff --git a/kernel/def.h b/kernel/include/def.h similarity index 100% rename from kernel/def.h rename to kernel/include/def.h diff --git a/kernel/idt.h b/kernel/include/idt.h similarity index 100% rename from kernel/idt.h rename to kernel/include/idt.h diff --git a/kernel/io.h b/kernel/include/io.h similarity index 100% rename from kernel/io.h rename to kernel/include/io.h diff --git a/kernel/irq.h b/kernel/include/irq.h similarity index 100% rename from kernel/irq.h rename to kernel/include/irq.h diff --git a/kernel/isr.h b/kernel/include/isr.h similarity index 100% rename from kernel/isr.h rename to kernel/include/isr.h diff --git a/kernel/kbd.h b/kernel/include/kbd.h similarity index 100% rename from kernel/kbd.h rename to kernel/include/kbd.h diff --git a/kernel/scr.h b/kernel/include/scr.h similarity index 100% rename from kernel/scr.h rename to kernel/include/scr.h diff --git a/kernel/timer.h b/kernel/include/timer.h similarity index 100% rename from kernel/timer.h rename to kernel/include/timer.h diff --git a/kernel/vga.h b/kernel/include/vga.h similarity index 100% rename from kernel/vga.h rename to kernel/include/vga.h diff --git a/libc/Makefile b/libc/Makefile index a36ad3f..dfd851b 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -11,7 +11,8 @@ clean: libc.a: $(OBJ) ar rcs $@ $(OBJ) + cp $@ ../build %.o: %.c ${HEADERS} - gcc $(CCFLAGS) -o $@ $< -I../kernel/ + gcc $(CCFLAGS) -o $@ $< -I$(KERNEL_INCDIR) -I$(LIBC_INCDIR) diff --git a/libc/ctype.h b/libc/include/ctype.h similarity index 100% rename from libc/ctype.h rename to libc/include/ctype.h diff --git a/libc/stdarg.h b/libc/include/stdarg.h similarity index 100% rename from libc/stdarg.h rename to libc/include/stdarg.h diff --git a/libc/stdbool.h b/libc/include/stdbool.h similarity index 100% rename from libc/stdbool.h rename to libc/include/stdbool.h diff --git a/libc/stdio.h b/libc/include/stdio.h similarity index 100% rename from libc/stdio.h rename to libc/include/stdio.h diff --git a/libc/stdlib.h b/libc/include/stdlib.h similarity index 100% rename from libc/stdlib.h rename to libc/include/stdlib.h diff --git a/libc/string.h b/libc/include/string.h similarity index 100% rename from libc/string.h rename to libc/include/string.h diff --git a/libc/utils.h b/libc/include/utils.h similarity index 100% rename from libc/utils.h rename to libc/include/utils.h