-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset-env.sh
More file actions
executable file
·84 lines (69 loc) · 1.91 KB
/
set-env.sh
File metadata and controls
executable file
·84 lines (69 loc) · 1.91 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# MAKE SURE THE SCRIPT IS RUN FROM /path/to/NullOS
# Sets up the Linux environment to use the GCC-based cross-compiler
if ! [[ -f boot.s ]]; then
echo "Please run script from /path/to/NullOS"
exit 1
fi
# Export required variables in user's current environment
export PATH=$PATH:$PWD/opt/cross/bin
export TARGET=i1686-elf
export PREFIX=$PWD/opt/cross
function help
{
printf "Usage: ./$0 [-b | --build]\n"
printf "\t-b | --build : Build the source files required for cross-compiler\n"
exit 1
}
BUILD=0
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-b|--build)
BUILD=1
shift
shift
;;
-h|--help)
help
;;
*)
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
if [ $BUILD == 1 ]; then
# File structure setup
mkdir -p src/build-binutils src/build-gcc opt/cross iso/boot/grub
cd src
# Obtaining cross-compiler sources
git clone git://sourceware.org/git/binutils-gdb.git
wget https://ftp.gnu.org/gnu/gcc/gcc-10.1.0/gcc-10.1.0.tar.gz # MAY BE DEPRECATED
tar -xzf gcc-10.1.0.tar.gz
rm gcc.10.1.0.tar.gz
# Make source (binutils)
cd build-binutils
../binutils-gdb/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --disable-nls --disable-werror
make
make install
# Make source (gcc)
cd ../build-gcc
../gcc-10.1.0/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
fi
# Make the binary kernel
mkdir -p obj
make
# Ensure valid Multiboot v1 header
grub-file --is-x86-multiboot nullOS.bin
if [ $? == 1 ]; then
echo "Error compiling - nullKernel.bin has an invalid multiboot header; Exiting..."
exit 1
fi
# Create the ISO
grub-mkrescue -o nullOS.iso iso
echo "Complete! Now run \`qemu-system-i386 -cdrom nullOS.iso\` (after installing proper dependencies, i.e. qemu-system-x86) to run nullOS!"