-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake
executable file
·54 lines (43 loc) · 1.35 KB
/
make
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/bash
gcc_args="-m32 -nostdlib -fno-stack-protector -fno-builtin -I lib -c"
ld_args="-I lib -m elf_i386 -T linker.ld"
# build dir cleaning
rm -rf bin/*
mkdir -p bin/src/lib
# libs compilation
libs=""
for file in src/lib/*; do
if [ -f $file ]; then
echo "BUILD PROCESS : compiling ${file} library ..."
extention=${file##*.}
error=0
if [ "$extention" = "c" ]; then
gcc $gcc_args $file -o "bin/${file}lib.o"
elif [ "$extention" = "asm" ]; then
nasm -f elf32 $file -o "bin/${file}lib.o"
elif [ "$extention" = "cignore" ]; then
echo -e "\033[32;1mIGNORED : ${file}\033[0m"
error=1
else
>&2 echo -e "\033[31;1mERROR : ${file}, file format not recognized !\033[0m"
error=2
fi
if [ $error = 0 ]; then
libs="${libs} bin/${file}lib.o"
fi
else
echo "BUILD PROCESS : no library found, this might be an error"
fi
done
# kernel compilation
echo "BUILD PROCESS : compiling the kernel ..."
gcc $gcc_args src/kernel.c -o bin/kernel.o
# boot_header compilation
echo "BUILD PROCESS : compiling the boot header file (boot.s) ..."
nasm -f elf32 src/boot.s -o bin/boot.o
# system linking
echo "LINKING PROCESS : linking the kernel ..."
ld $ld_args -o RoyalOS/boot/kernel bin/boot.o bin/kernel.o $libs
# image creation
echo "IMAGE CREATION PROCESS : building grub image ..."
grub-mkrescue /usr/lib/grub/i386-pc -o bin/RoyalOS.iso RoyalOS