summaryrefslogtreecommitdiff
path: root/makefile
blob: 03ab19a4c6c0c6917469ba85d13a71330be6a8d4 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
disk: kernel boot skel hello
	mkdir -p obj out
	/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/* ::/

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

debug: disk
	gdb -x qemu-debug.gdb

clean:
	rm -r obj out

skel:
	mkdir -p out/fs
	cp -r fs-skel/* out/fs/

kgccargs = -Wall -m32 -Og -ffreestanding -fno-asynchronous-unwind-tables
ugccargs = ${kgccargs} -Isrc/libc/inc
nasmargs = -f elf32

hello:
	mkdir -p obj/hello out/fs/bin
	nasm ${nasmargs} src/user/hello/hello.asm -o obj/hello/hello.o
	ld -T src/user-elf.ld obj/hello/hello.o -o obj/hello.elf
	objcopy -O binary obj/hello.elf out/fs/bin/hello.ple

init:
	#TODO

kernel:
	mkdir -p obj/kernel out
	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/main.c   -o obj/kernel/main.o
	gcc ${kgccargs} -c src/kernel/mem.c    -o obj/kernel/mem.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/plef.c   -o obj/kernel/plef.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/vesa.c   -o obj/kernel/vesa.o
	gcc ${kgccargs} -c src/kernel/vga.c    -o obj/kernel/vga.o
	ld -T src/kernel/elf-link.ld obj/kernel/*.o -o obj/kernel.elf
	objcopy -O binary obj/kernel.elf out/kernel.bin

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