summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile117
1 files changed, 53 insertions, 64 deletions
diff --git a/makefile b/makefile
index 07e10f2..8ddce57 100644
--- a/makefile
+++ b/makefile
@@ -1,5 +1,13 @@
-disk: kernel boot skel init hello
- mkdir -p obj out
+kgccargs = -Wall -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -m32 -Og -ffreestanding -fno-asynchronous-unwind-tables
+ugccargs = ${kgccargs} -Isrc/user/include
+nasmargs = -f elf32
+partlink = -r -m elf_i386
+
+out/disk.vdi: out/disk.img
+ VBoxManage convertfromraw out/disk.img out/disk.vdi --uuid a61929ed-3bf2-45ff-b98a-44f87c616dba
+
+out/disk.img: out/kernel.bin out/boot.bin out/fs
+ mkdir -p obj
/sbin/mkfs.fat -C -f 1 -F 16 -n "PORTLAND OS" -R 65 -s 1 -S 512 obj/shadow.img 8192
echo -n -e '\xeb\x3c' > obj/jmp.bin
dd if=obj/jmp.bin of=obj/shadow.img obs=2 conv=notrunc
@@ -8,78 +16,59 @@ disk: kernel boot skel init hello
mv obj/shadow.img out/disk.img
mcopy -i out/disk.img -s out/fs/* ::/
-vdi-file: disk
- VBoxManage convertfromraw out/disk.img out/disk.vdi --uuid a61929ed-3bf2-45ff-b98a-44f87c616dba
-
-debug: disk
+debug: out/disk.img
gdb -x qemu-debug.gdb
clean:
rm -r obj out || true
-skel:
- mkdir -p out/fs
+out/fs: obj/hello.elf obj/init.elf obj/meminfo.elf
+ mkdir -p out/fs/bin
cp -r fs-skel/* out/fs/
+ objcopy -S obj/hello.elf out/fs/bin/hello.elf
+ objcopy -S obj/init.elf out/fs/bin/init.elf
+ objcopy -S obj/meminfo.elf out/fs/bin/meminfo.elf
+
+obj/kernel/%.ko: src/kernel/%.c
+ mkdir -p $(shell dirname $@)
+ gcc ${kgccargs} -c $< -o $@
+
+obj/kernel/%.kao: src/kernel/%.asm
+ mkdir -p $(shell dirname $@)
+ nasm ${nasmargs} $< -o $@
+
+out/kernel.bin: obj/kernel/drive.ko obj/kernel/fat.ko obj/kernel/ide.ko \
+ obj/kernel/idt.ko obj/kernel/log.ko obj/kernel/main.ko \
+ obj/kernel/main2.ko obj/kernel/pmap.ko obj/kernel/paging.ko \
+ obj/kernel/panic.ko obj/kernel/pci.ko obj/kernel/elf.ko \
+ obj/kernel/serial.ko obj/kernel/task.ko obj/kernel/util.ko \
+ obj/kernel/vga.ko obj/kernel/isrs.kao
+ mkdir -p out
+ ld -T src/kernel/elf-link.ld obj/kernel/* -o obj/kernel.elf
+ objcopy -O binary obj/kernel.elf out/kernel.bin
-kgccargs = -Wall -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -m32 -Og -ffreestanding -fno-asynchronous-unwind-tables
-ugccargs = ${kgccargs} -Isrc/user/include
-nasmargs = -f elf32
-partlink = -r -m elf_i386
-
-init: knob
- mkdir -p obj/init out/fs/bin
-
- gcc ${ugccargs} -c src/user/init/main.c -o obj/init/main.o
-
- ld -T src/user/elf.ld obj/init/main.o obj/knob.o -o obj/init.elf
- objcopy -S obj/init.elf out/fs/bin/init.elf
-
-hello: knob
- mkdir -p obj/hello out/fs/bin
-
- gcc ${ugccargs} -c src/user/hello/hello.c -o obj/hello/hello.o
-
- ld -T src/user/elf.ld obj/hello/hello.o obj/knob.o -o obj/hello.elf
- objcopy -S obj/hello.elf out/fs/bin/hello.elf
-
-knob:
- mkdir -p obj/knob
+out/boot.bin: src/boot.asm
+ mkdir -p out
+ nasm src/boot.asm -o out/boot.bin
- gcc ${ugccargs} -c src/user/knob/env.c -o obj/knob/env.o
- gcc ${ugccargs} -c src/user/knob/file.c -o obj/knob/file.o
- gcc ${ugccargs} -c src/user/knob/format.c -o obj/knob/format.o
- gcc ${ugccargs} -c src/user/knob/heap.c -o obj/knob/heap.o
- gcc ${ugccargs} -c src/user/knob/quit.c -o obj/knob/quit.o
- gcc ${ugccargs} -c src/user/knob/user.c -o obj/knob/user.o
- gcc ${ugccargs} -c src/user/knob/task.c -o obj/knob/task.o
- nasm ${nasmargs} src/user/knob/entry.asm -o obj/knob/entry.o
+obj/%.o: src/user/%.c
+ mkdir -p $(shell dirname $@)
+ gcc ${ugccargs} -c $< -o $@
- ld ${partlink} obj/knob/*.o -o obj/knob.o
+obj/%.ao: src/user/%.asm
+ mkdir -p $(shell dirname $@)
+ nasm ${nasmargs} $< -o $@
-kernel:
- mkdir -p obj/kernel out
+obj/knob.so: obj/knob/env.o obj/knob/file.o obj/knob/format.o \
+ obj/knob/heap.o obj/knob/quit.o obj/knob/user.o \
+ obj/knob/task.o obj/knob/entry.ao
+ ld ${partlink} obj/knob/* -o obj/knob.so
- gcc ${kgccargs} -c src/kernel/drive.c -o obj/kernel/drive.o
- gcc ${kgccargs} -c src/kernel/fat.c -o obj/kernel/fat.o
- gcc ${kgccargs} -c src/kernel/ide.c -o obj/kernel/ide.o
- gcc ${kgccargs} -c src/kernel/idt.c -o obj/kernel/idt.o
- gcc ${kgccargs} -c src/kernel/log.c -o obj/kernel/log.o
- gcc ${kgccargs} -c src/kernel/main.c -o obj/kernel/main.o
- gcc ${kgccargs} -c src/kernel/main2.c -o obj/kernel/main2.o
- gcc ${kgccargs} -c src/kernel/pmap.c -o obj/kernel/pmap.o
- gcc ${kgccargs} -c src/kernel/paging.c -o obj/kernel/paging.o
- gcc ${kgccargs} -c src/kernel/panic.c -o obj/kernel/panic.o
- gcc ${kgccargs} -c src/kernel/pci.c -o obj/kernel/pci.o
- gcc ${kgccargs} -c src/kernel/elf.c -o obj/kernel/elf.o
- gcc ${kgccargs} -c src/kernel/serial.c -o obj/kernel/serial.o
- gcc ${kgccargs} -c src/kernel/task.c -o obj/kernel/task.o
- gcc ${kgccargs} -c src/kernel/util.c -o obj/kernel/util.o
- gcc ${kgccargs} -c src/kernel/vga.c -o obj/kernel/vga.o
- nasm ${nasmargs} src/kernel/isrs.asm -o obj/kernel/isrs.o
+obj/hello.elf: obj/hello/hello.o obj/knob.so
+ ld -T src/user/elf.ld obj/hello/* obj/knob.so -o obj/hello.elf
- ld -T src/kernel/elf-link.ld obj/kernel/*.o -o obj/kernel.elf
- objcopy -O binary obj/kernel.elf out/kernel.bin
+obj/init.elf: obj/init/init.o obj/knob.so
+ ld -T src/user/elf.ld obj/init/* obj/knob.so -o obj/init.elf
-boot:
- mkdir -p out
- nasm src/boot.asm -o out/boot.bin
+obj/meminfo.elf: obj/meminfo/meminfo.o obj/knob.so
+ ld -T src/user/elf.ld obj/meminfo/* obj/knob.so -o obj/meminfo.elf \ No newline at end of file