-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
31 lines (22 loc) · 1.12 KB
/
Makefile
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
build/os21.bin: build/boot.bin build/kernel.bin
cat $^ > $@
dd if=/dev/zero of=$@ bs=1 count=0 seek=16384 status=none
cp build/os21.bin build/os21bochs.bin
dd if=/dev/zero of=build/os21bochs.bin bs=1 count=0 seek=10321920 status=none
build/kernel.bin: link.ld build/entry.o build_kernel build_programs
ld -m elf_i386 -o $@ -T link.ld build/entry.o $(wildcard build/kernel/*.o $(wildcard build/programs/*.o)) --oformat binary
build/entry.o: entry.asm |build
nasm $< -f elf -o $@
build_kernel: $(wildcard kernel/*.c) $(wildcard kernel/*.h) |build
@for f in $(basename $(notdir $(wildcard kernel/*.c))); do gcc -Wall -Wextra -m32 -ffreestanding -fno-pie -c -o build/kernel/$${f}.o kernel/$${f}.c; done;
build_programs: $(wildcard programs/*.c) $(wildcard programs/*.h) |build
@for f in $(basename $(notdir $(wildcard programs/*.c))); do gcc -Wall -Wextra -m32 -ffreestanding -fno-pie -c -o build/programs/$${f}.o programs/$${f}.c; done;
build/boot.bin: boot.asm |build
nasm $< -f bin -o $@
run: build/os21.bin
qemu-system-x86_64 -drive file=$<,format=raw
build:
mkdir -p build/kernel
mkdir -p build/programs
clean:
rm -r build