summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-10-30 22:54:28 +0100
committerAnton Kling <anton@kling.gg>2023-10-31 00:18:38 +0100
commit6c0e142409d57c11fc03bcbc3d79a4d646f885ff (patch)
treefa925bac319193d203b8697592dc18c117ca617c
parent34342b53c39aa3f22326b6e4eda960cc20cfa0f0 (diff)
Meta: Create a simple toolchain compilation script
-rwxr-xr-xmeta/build.sh1
-rwxr-xr-xmeta/kernel.sh1
-rwxr-xr-xmeta/toolchain.sh13
-rwxr-xr-xmeta/userland.sh3
-rwxr-xr-xtoolchain/build-binutils.sh5
-rwxr-xr-xtoolchain/build-gcc.sh5
-rw-r--r--userland/libc/Makefile3
7 files changed, 22 insertions, 9 deletions
diff --git a/meta/build.sh b/meta/build.sh
index 39d778a..66b093b 100755
--- a/meta/build.sh
+++ b/meta/build.sh
@@ -1,4 +1,5 @@
#!/bin/sh
scriptdir="$(dirname "$0")"
cd "$scriptdir"
+export PATH="$PATH:$(pwd)/../toolchain/bin/bin"
./kernel.sh && ./userland.sh && ./sync.sh
diff --git a/meta/kernel.sh b/meta/kernel.sh
index 4cd02b8..dd74999 100755
--- a/meta/kernel.sh
+++ b/meta/kernel.sh
@@ -1,4 +1,5 @@
#!/bin/sh
scriptdir="$(dirname "$0")"
cd "$scriptdir"
+export PATH="$PATH:$(pwd)/../toolchain/bin/bin"
make -C ../kernel
diff --git a/meta/toolchain.sh b/meta/toolchain.sh
new file mode 100755
index 0000000..c50008f
--- /dev/null
+++ b/meta/toolchain.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# This script compiles the operating system toolchain(GCC, Binutils)
+scriptdir="$(dirname "$0")"
+cd "$scriptdir"
+cd ..
+
+# Install the headers from LibC
+mkdir -p ./sysroot/usr/include/
+cp -r ./userland/libc/include ./sysroot/usr/
+
+cd ./toolchain/
+./build-binutils.sh
+./build-gcc.sh
diff --git a/meta/userland.sh b/meta/userland.sh
index 1686023..94ab441 100755
--- a/meta/userland.sh
+++ b/meta/userland.sh
@@ -1,9 +1,12 @@
#!/bin/sh
scriptdir="$(dirname "$0")"
cd "$scriptdir"
+export PATH="$PATH:$(pwd)/../toolchain/bin/bin"
cd ..
make -C ./userland/libgui
make -C ./userland/libc
+mkdir -p ./sysroot/lib
+make install -C ./userland/libc
make -C ./userland/sh
make -C ./userland/terminal
make -C ./userland/snake
diff --git a/toolchain/build-binutils.sh b/toolchain/build-binutils.sh
index 12bcde9..abd3fce 100755
--- a/toolchain/build-binutils.sh
+++ b/toolchain/build-binutils.sh
@@ -5,9 +5,8 @@ cd ./binutils-*/
patch -f -p1 -i ../binutils-2.40.diff
cd ..
mkdir bin
-#PREFIX="/home/anton/prj/osdev/sysroot"
PREFIX="$(pwd)/bin"
mkdir build-binutils
cd build-binutils
-../binutils*/configure --target=i686-sb --prefix="$PREFIX" --with-sysroot="/home/anton/prj/osdev/sysroot" --disable-werror
-make -j8 && make install
+../binutils*/configure --target=i686-sb --prefix="$PREFIX" --with-sysroot="$(pwd)/../../sysroot" --disable-werror
+make -j$(nproc) && make install
diff --git a/toolchain/build-gcc.sh b/toolchain/build-gcc.sh
index c9af8a1..f790505 100755
--- a/toolchain/build-gcc.sh
+++ b/toolchain/build-gcc.sh
@@ -6,8 +6,7 @@ patch -f -p1 -i ../gcc-13.1.0.diff
cd ..
mkdir bin
PREFIX=$(pwd)"/bin"
-#PREFIX="/home/anton/prj/osdev/sysroot"
mkdir build-gcc
cd build-gcc
-../gcc-*/configure --target=i686-sb --prefix="$PREFIX" --with-gmp --with-mpfr --with-sysroot="/home/anton/prj/osdev/sysroot" --enable-languages=c,c++
-make -j6 all-gcc all-target-libgcc && make install-gcc install-target-libgcc
+../gcc-*/configure --target=i686-sb --prefix="$PREFIX" --with-gmp --with-mpfr --with-sysroot="$(pwd)/../../sysroot" --enable-languages=c,c++
+make -j$(nproc) all-gcc all-target-libgcc && make install-gcc install-target-libgcc
diff --git a/userland/libc/Makefile b/userland/libc/Makefile
index c755b94..2eabf80 100644
--- a/userland/libc/Makefile
+++ b/userland/libc/Makefile
@@ -18,9 +18,6 @@ install:
cp crt0.o ../../sysroot/lib/
cp libc.a ../../sysroot/lib/
cp -r include ../../sysroot/usr/
- cp crt0.o ~/prj/osdev/sysroot/lib/
- cp libc.a ~/prj/osdev/sysroot/lib/
- cp -r include ~/prj/osdev/sysroot/usr/
clean:
rm libc.a *.o */*.o */*/*.o