#!/usr/bin/sh remove_target() { rm -rf target &> /dev/null } create_target() { mkdir target &> /dev/null mkdir target/temp &> /dev/null } cleanup_temp() { rm -f target/temp/* &> /dev/null } # --------------------------------------------------- build_kernel() { create_target nasm -felf64 multiboot_header.asm -o target/temp/multiboot_header.o nasm -felf64 boot.asm -o target/temp/boot.o ld -n -o target/kernel.bin -T linker.ld target/temp/*.o cleanup_temp } build_init() { create_target } build_clean() { remove_target } build_all() { build_kernel } not_exec=true for arg in "$@"; do case "$arg" in "kernel") build_kernel;; "init") build_init;; "clean") build_clean;; "all") build_all;; *) echo "warn: ignoring unknown option '$arg'" continue;; esac not_exec=false break done print_help() { echo "usage: $0 option" echo "options: " echo " init initialise directory" echo " clean cleanup binaries" echo echo " kernel build the kernel" echo " all build kernel" } if $not_exec; then echo "error: please specify an argument" echo print_help exit -1 fi