luxos/build.sh

78 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/sh
# ----------------- lux Operating System -----------------
OBJ=build
COMPILER=i586-elf-gcc
LINKER=i586-elf-ld
BUILD_VER="0.1.0"
BuildC()
{
Percent=10
while read descript
do
read line
read empty
echo "[ $Percent%] KERNEL :: $descript"
File=${line##*/}
File=${File%%.*}
$COMPILER -Wall -Wextra -O -nostdinc -fno-builtin -I./Kernel/include -c -o $OBJ/$File.o $line -nostdlib -nostartfiles -nodefaultlibs
Percent=$(($Percent + 1)) #Increase PERCENT
done < $1
return 0
}
BuildAsm()
{
Percent=85
while read descript
do
read line
read empty
echo "[ $Percent%] KERNEL :: $descript"
File=${line##*/}
File=${File%%.*}
nasm -f elf -o $OBJ/$File.o $line
Percent=$(($Percent + 1)) #Increase PERCENT
done < $1
return 0
}
# Calculate version number
read buildno < ./scripts/version.txt
buildno=$(($buildno + 1))
echo $buildno > ./scripts/version.txt
echo "#define OS_BUILD \"$BUILD_VER.$buildno\"" > ./Kernel/include/version.h
# On the screen
echo "========================================================"
echo "LUX Operating System build $BUILD_VER.$buildno"
echo "========================================================"
# Clean up
echo "[ 1%] CLEANUP"
rm $OBJ/* 2>/dev/null
# Build kernel
BuildC "filelistC.txt"
BuildAsm "filelistAsm.txt"
# Link
echo "[ 95%] LINKING..."
$LINKER -T link.ld $OBJ/*.o
# Make floppy image
echo "[ 97%] WRITING FLOPPY IMAGE..."
mount A: /mnt/floppy 2>/dev/null >/dev/null
cp kernel.bin /mnt/floppy/
# DONE
echo "[100%] DONE!"
exit 0