mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
Initial commit: SUB-OS 64-Bit Production Monolithic Operating System with LazyBox userland suite
This commit is contained in:
commit
cd9c786d14
88 files changed
+7132
No files matched your search
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# SUB-OS Cross-Compiler Build Script
|
||||
# Builds x86_64-elf-gcc and x86_64-elf-binutils from source
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
export TARGET=x86_64-elf
|
||||
export PREFIX="/usr/local/cross"
|
||||
export PATH="$PREFIX/bin:$PATH"
|
||||
|
||||
BINUTILS_VERSION="2.42"
|
||||
GCC_VERSION="13.3.0"
|
||||
|
||||
BUILD_DIR="/tmp/cross-compiler-build"
|
||||
JOBS=$(nproc)
|
||||
|
||||
echo "============================================"
|
||||
echo " Building x86_64-elf Cross-Compiler"
|
||||
echo "============================================"
|
||||
echo " Target: $TARGET"
|
||||
echo " Prefix: $PREFIX"
|
||||
echo " Binutils: $BINUTILS_VERSION"
|
||||
echo " GCC: $GCC_VERSION"
|
||||
echo " Jobs: $JOBS"
|
||||
echo "============================================"
|
||||
|
||||
# Create directories
|
||||
sudo mkdir -p "$PREFIX"
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# ---- Step 1: Download sources ----
|
||||
echo ""
|
||||
echo "[1/4] Downloading sources..."
|
||||
|
||||
if [ ! -f "binutils-${BINUTILS_VERSION}.tar.xz" ]; then
|
||||
curl -LO "https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz"
|
||||
fi
|
||||
|
||||
if [ ! -f "gcc-${GCC_VERSION}.tar.xz" ]; then
|
||||
curl -LO "https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz"
|
||||
fi
|
||||
|
||||
# ---- Step 2: Extract sources ----
|
||||
echo ""
|
||||
echo "[2/4] Extracting sources..."
|
||||
|
||||
if [ ! -d "binutils-${BINUTILS_VERSION}" ]; then
|
||||
tar xf "binutils-${BINUTILS_VERSION}.tar.xz"
|
||||
fi
|
||||
|
||||
if [ ! -d "gcc-${GCC_VERSION}" ]; then
|
||||
tar xf "gcc-${GCC_VERSION}.tar.xz"
|
||||
fi
|
||||
|
||||
# ---- Step 3: Build Binutils ----
|
||||
echo ""
|
||||
echo "[3/4] Building binutils for ${TARGET}..."
|
||||
|
||||
mkdir -p build-binutils
|
||||
cd build-binutils
|
||||
|
||||
../binutils-${BINUTILS_VERSION}/configure \
|
||||
--target=$TARGET \
|
||||
--prefix="$PREFIX" \
|
||||
--with-sysroot \
|
||||
--disable-nls \
|
||||
--disable-werror
|
||||
|
||||
make -j$JOBS
|
||||
sudo make install
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# ---- Step 4: Build GCC ----
|
||||
echo ""
|
||||
echo "[4/4] Building GCC for ${TARGET}..."
|
||||
|
||||
mkdir -p build-gcc
|
||||
cd build-gcc
|
||||
|
||||
../gcc-${GCC_VERSION}/configure \
|
||||
--target=$TARGET \
|
||||
--prefix="$PREFIX" \
|
||||
--disable-nls \
|
||||
--enable-languages=c \
|
||||
--without-headers
|
||||
|
||||
make -j$JOBS all-gcc
|
||||
make -j$JOBS all-target-libgcc
|
||||
sudo make install-gcc
|
||||
sudo make install-target-libgcc
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# ---- Verify ----
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo " Cross-Compiler Build Complete!"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
$PREFIX/bin/$TARGET-gcc --version
|
||||
$PREFIX/bin/$TARGET-ld --version | head -1
|
||||
echo ""
|
||||
echo "Installed to: $PREFIX/bin/"
|
||||
echo ""
|
||||
echo "Add to your PATH:"
|
||||
echo " export PATH=\"$PREFIX/bin:\$PATH\""
|
||||
echo ""
|
||||
echo "Or add to ~/.bashrc for persistence:"
|
||||
echo " echo 'export PATH=\"$PREFIX/bin:\$PATH\"' >> ~/.bashrc"
|
||||
echo "============================================"
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Setting up SUB-OS build environment..."
|
||||
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
else
|
||||
echo "Cannot detect OS. Please manually install dependencies."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $OS in
|
||||
ubuntu|debian)
|
||||
echo "Detected Debian/Ubuntu-based OS."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nasm gcc binutils make qemu-system-x86
|
||||
;;
|
||||
fedora)
|
||||
echo "Detected Fedora."
|
||||
sudo dnf install -y nasm gcc binutils make qemu-system-x86
|
||||
;;
|
||||
arch)
|
||||
echo "Detected Arch Linux."
|
||||
sudo pacman -Sy --noconfirm nasm gcc binutils make qemu-system-x86
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OS: $OS. Please install: nasm, gcc, binutils, make, qemu-system-x86."
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! command -v x86_64-elf-gcc &> /dev/null; then
|
||||
echo ""
|
||||
echo "WARNING: x86_64-elf-gcc (cross-compiler) not found in PATH."
|
||||
echo "The Makefile will fallback to the default gcc."
|
||||
echo "For the best results, it is highly recommended to build an x86_64-elf GCC cross-compiler."
|
||||
echo "Instructions to build a cross-compiler: https://wiki.osdev.org/GCC_Cross-Compiler"
|
||||
fi
|
||||
|
||||
echo "Setup script finished!"
|
||||
Reference in new issue
Block a user