110 lines
No EOL
3.6 KiB
Makefile
110 lines
No EOL
3.6 KiB
Makefile
kgccargs = -Wall -Wsuggest-attribute=pure -Wsuggest-attribute=const -m32 -Og -ffreestanding -fno-asynchronous-unwind-tables
|
|
ugccargs = ${kgccargs} -Isrc/user/include
|
|
ugppargs = ${kgccargs} -Isrc/user/include/cpp -Isrc/user/include
|
|
nasmargs = -f elf32
|
|
partlink = -r -m elf_i386
|
|
|
|
out/disk.vdi: out/disk.img
|
|
rm out/disk.vdi || true
|
|
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
|
|
#TODO: have this regenerate after 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
|
|
dd if=out/boot.bin of=obj/shadow.img obs=1 seek=62 conv=notrunc
|
|
dd if=out/kernel.bin of=obj/shadow.img seek=1 conv=notrunc
|
|
mv obj/shadow.img out/disk.img
|
|
mcopy -i out/disk.img -s out/fs/* ::/
|
|
|
|
debug: out/disk.img
|
|
gdb -x qemu-debug.gdb
|
|
|
|
clean:
|
|
rm -r obj out || true
|
|
|
|
out/fs/bin/%: obj/%.elf
|
|
mkdir -p $(shell dirname $@)
|
|
objcopy -S $< $@
|
|
|
|
out/fs: out/fs/bin/init out/fs/bin/meminfo out/fs/bin/highway \
|
|
out/fs/bin/hello out/fs/bin/dumptext out/fs/bin/dumphex \
|
|
out/fs/bin/dirinfo out/fs/bin/fileman
|
|
mkdir -p out/fs
|
|
cp -r fs-skel/* out/fs/
|
|
|
|
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/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 obj/kernel/kbd.ko \
|
|
obj/kernel/pmap.ko obj/kernel/paging.ko
|
|
mkdir -p out
|
|
ld -T src/kernel/elf-link.ld $^ -o obj/kernel.elf
|
|
objcopy -O binary obj/kernel.elf out/kernel.bin
|
|
|
|
out/boot.bin: src/boot.asm
|
|
mkdir -p out
|
|
nasm src/boot.asm -o out/boot.bin
|
|
|
|
obj/%.o: src/user/%.c
|
|
mkdir -p $(shell dirname $@)
|
|
gcc ${ugccargs} -c $< -o $@
|
|
|
|
obj/%.ao: src/user/%.asm
|
|
mkdir -p $(shell dirname $@)
|
|
nasm ${nasmargs} $< -o $@
|
|
|
|
obj/%.po: src/user/%.cpp
|
|
mkdir -p $(shell dirname $@)
|
|
g++ ${ugppargs} -c $< -o $@
|
|
|
|
obj/c.rto: obj/runtimes/c/entry.ao
|
|
ld ${partlink} obj/runtimes/c/* -o obj/c.rto
|
|
|
|
obj/cpp.rto:
|
|
#TODO
|
|
|
|
obj/knob.so: obj/knob/env.o obj/knob/file.o obj/knob/format.o \
|
|
obj/knob/heap.o obj/knob/user.o obj/knob/task.o \
|
|
obj/knob/block.o
|
|
ld ${partlink} $^ -o $@
|
|
|
|
obj/cove.so: obj/cove/cove.po obj/cove/buttons.po obj/cove/label.po \
|
|
obj/cove/vlist.po
|
|
ld ${partlink} $^ -o $@
|
|
|
|
obj/init.elf: obj/init/init.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|
|
|
|
obj/meminfo.elf: obj/meminfo/meminfo.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|
|
|
|
obj/highway.elf: obj/highway/main.o obj/highway/cmds.o obj/highway/line.o \
|
|
obj/highway/vars.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|
|
|
|
obj/hello.elf: obj/hello/hello.ao
|
|
ld -T src/user/runtimes/asm/elf.ld $^ -o $@
|
|
|
|
obj/dumptext.elf: obj/dumptext/dumptext.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|
|
|
|
obj/dumphex.elf: obj/dumphex/dumphex.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|
|
|
|
obj/dirinfo.elf: obj/dirinfo/dirinfo.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|
|
|
|
obj/fileman.elf: obj/fileman/fileman.o obj/knob.so obj/c.rto
|
|
ld -T src/user/runtimes/c/elf.ld $^ -o $@
|