From aab0953240f44d72b960db66db544337a4008c76 Mon Sep 17 00:00:00 2001 From: Viren Nadkarni Date: Wed, 15 Jun 2016 14:29:02 +0530 Subject: [PATCH] move headers to separate directories also update makefiles to reflect the change --- Makefile | 20 ++++++++++++-------- boot/Makefile | 1 + kernel/Makefile | 6 ++++-- kernel/{ => include}/def.h | 0 kernel/{ => include}/idt.h | 0 kernel/{ => include}/io.h | 0 kernel/{ => include}/irq.h | 0 kernel/{ => include}/isr.h | 0 kernel/{ => include}/kbd.h | 0 kernel/{ => include}/scr.h | 0 kernel/{ => include}/timer.h | 0 kernel/{ => include}/vga.h | 0 libc/Makefile | 3 ++- libc/{ => include}/ctype.h | 0 libc/{ => include}/stdarg.h | 0 libc/{ => include}/stdbool.h | 0 libc/{ => include}/stdio.h | 0 libc/{ => include}/stdlib.h | 0 libc/{ => include}/string.h | 0 libc/{ => include}/utils.h | 0 20 files changed, 19 insertions(+), 11 deletions(-) rename kernel/{ => include}/def.h (100%) rename kernel/{ => include}/idt.h (100%) rename kernel/{ => include}/io.h (100%) rename kernel/{ => include}/irq.h (100%) rename kernel/{ => include}/isr.h (100%) rename kernel/{ => include}/kbd.h (100%) rename kernel/{ => include}/scr.h (100%) rename kernel/{ => include}/timer.h (100%) rename kernel/{ => include}/vga.h (100%) rename libc/{ => include}/ctype.h (100%) rename libc/{ => include}/stdarg.h (100%) rename libc/{ => include}/stdbool.h (100%) rename libc/{ => include}/stdio.h (100%) rename libc/{ => include}/stdlib.h (100%) rename libc/{ => include}/string.h (100%) rename libc/{ => include}/utils.h (100%) 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