From f5f14f28449cec7faf0599ca94afab3bd557827a Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 12 Aug 2021 12:47:49 +0200 Subject: [PATCH] compile.sh refactor --- compile.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/compile.sh b/compile.sh index ad0984d..28b61b3 100755 --- a/compile.sh +++ b/compile.sh @@ -1,16 +1,27 @@ #!/usr/bin/bash -done="[OK]" -fail="[FAIL]" +option=$1 srcDir=src binDir=bin -echo "Compiling bootloader... " -nasm -f bin $srcDir/bootloader/bootloader.asm -i $srcDir/bootloader -o $binDir/bootloader.bin +compile_bootloader() { + echo "Compiling bootloader... " + nasm -f bin $srcDir/bootloader/bootloader.asm -i $srcDir/bootloader -o $binDir/bootloader.bin +} -echo "Compiling kernel... " -gcc -fno-pie -m32 -Os -ffreestanding -c $srcDir/kernel/kernel.c -o $binDir/kernel.o && gcc -o $binDir/kernel.bin $binDir/kernel.o -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 +compile_kernel() { + echo "Compiling kernel... " + gcc -fno-pie -m32 -Os -ffreestanding -c $srcDir/kernel/kernel.c -o $binDir/kernel.o && gcc -o $binDir/kernel.bin $binDir/kernel.o -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 +} -echo "Creating OS image... " -cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image +create_os_image() { + echo "Creating OS image... " + cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image +} + + + +compile_bootloader +compile_kernel +create_os_image