Skip to content

Instantly share code, notes, and snippets.

@ianpreston
Created April 4, 2015 18:12
Show Gist options
  • Save ianpreston/1cd17ce125ffdbc701ef to your computer and use it in GitHub Desktop.
Save ianpreston/1cd17ce125ffdbc701ef to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
# Build the bootloader
cd src/bootloader
nasm -f bin main.asm -o ../../build/bootloader.bin
cd ../..
# Build the kernel
cd src/kernel/asm
nasm -f elf entry.asm -o ../../../build/entry.o
nasm -f elf gdt.asm -o ../../../build/gdt.a.o
nasm -f elf isr.asm -o ../../../build/isr.o
nasm -f elf usermode.asm -o ../../../build/usermode.o
cd ../../..
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/libkernel.c -o build/libkernel.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/gdt.c -o build/gdt.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/terminal.c -o build/terminal.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/keyboard.c -o build/keyboard.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/interrupt.c -o build/interrupt.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/paging.c -o build/paging.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/kheap.c -o build/kheap.o -Wall -pedantic
gcc -O0 -ffreestanding -c -std=gnu99 -m32 src/kernel/main.c -o build/main.o -Wall -pedantic
ld -m elf_i386 -Ttext 0x1000 build/entry.o build/gdt.a.o build/isr.o build/usermode.o build/libkernel.o build/gdt.o build/terminal.o build/keyboard.o build/interrupt.o build/paging.o build/kheap.o build/main.o --oformat binary -o build/kernel.bin
# Build a disk image with the boot sector and kernel
cat build/bootloader.bin build/kernel.bin > hda.img
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment