summaryrefslogtreecommitdiff
path: root/makefile
blob: afac8089e0898ada173b962c6def9007b0de1cc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
disk: kernel boot
	mkdir -p obj out
	/sbin/mkfs.fat -C -f 1 -F 16 -n "PORTLAND OS" -R 17 -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

vdi-file: disk
	VBoxManage convertfromraw out/disk.img out/disk.vdi --uuid a61929ed-3bf2-45ff-b98a-44f87c616dba

debug: vdi-file
	gdb -x qemu-debug.gdb

kgccargs = -m32 -ffreestanding -fno-asynchronous-unwind-tables
kernel:
	mkdir -p obj/kernel out
	gcc ${kgccargs} -c src/kernel/main.c   -o obj/kernel/main.o
	gcc ${kgccargs} -c src/kernel/vga.c    -o obj/kernel/vga.o
	gcc ${kgccargs} -c src/kernel/fat.c    -o obj/kernel/fat.o
	gcc ${kgccargs} -c src/kernel/fs.c     -o obj/kernel/fs.o
	gcc ${kgccargs} -c src/kernel/ata.c    -o obj/kernel/ata.o
	gcc ${kgccargs} -c src/kernel/util.c   -o obj/kernel/utilc.o
	gcc ${kgccargs} -c src/kernel/panic.c  -o obj/kernel/panic.o
	gcc ${kgccargs} -c src/kernel/serial.c -o obj/kernel/serial.o
	nasm -f elf32 src/kernel/util.asm -o obj/kernel/utila.o
	ld -T src/kernel/link.ld obj/kernel/main.o obj/kernel/vga.o obj/kernel/fat.o obj/kernel/fs.o obj/kernel/ata.o obj/kernel/utilc.o obj/kernel/panic.o obj/kernel/utila.o obj/kernel/serial.o -o obj/kernel.elf
	objcopy -O binary -j .entry -j .bin obj/kernel.elf out/kernel.bin

boot:
	mkdir -p out
	nasm src/boot.asm -o out/boot.bin

clean:
	rm -r obj out