summaryrefslogtreecommitdiff
path: root/makefile
blob: 503fccad73bf172c0e56cb27bf3faa2fec79861d (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 12 -n "PORTLAND OS" -R 17 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

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

kdump: kernel
	objdump -M intel -d obj/kernel.elf > out/kernel.dasm

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