Squash commits for public release
This commit is contained in:
105
toolchains/BUILD.gn
Normal file
105
toolchains/BUILD.gn
Normal file
@@ -0,0 +1,105 @@
|
||||
import("//toolchains/COMPILERS.gni")
|
||||
|
||||
toolchain("gnu-cross-compiler") {
|
||||
tool("cc") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$gnu_cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "CC {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("cxx") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$gnu_cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "CXX {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("asm") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$gnu_asm {{source}} -o {{output}} {{asmflags}}"
|
||||
depsformat = "gcc"
|
||||
description = "ASM {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f {{output}} && $gnu_ar rcs {{output}} {{inputs}}"
|
||||
description = "AR {{output}}"
|
||||
outputs = [ "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" ]
|
||||
default_output_extension = ".a"
|
||||
output_prefix = ""
|
||||
}
|
||||
tool("link") {
|
||||
outputs = [ "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" ]
|
||||
command = "$gnu_ld -o {{output}} {{inputs}} {{ldflags}} {{solibs}} {{libs}}"
|
||||
description = "LINK {{output}}"
|
||||
}
|
||||
tool("stamp") {
|
||||
command = "touch {{output}}"
|
||||
description = "STAMP {{output}}"
|
||||
}
|
||||
tool("copy") {
|
||||
command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
|
||||
description = "COPY {{source}} {{output}}"
|
||||
}
|
||||
}
|
||||
|
||||
toolchain("llvm-cross-compiler") {
|
||||
tool("cc") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$llvm_cc -MMD -MF $depfile $llvm_ccpp_target_flag {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "CC {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("cxx") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$llvm_cxx -MMD -MF $depfile $llvm_ccpp_target_flag {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "CXX {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("objcxx") {
|
||||
depfile = "{{output}}.d"
|
||||
command = "$llvm_cxx -MMD -MF $depfile $llvm_ccpp_target_flag {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}"
|
||||
depsformat = "gcc"
|
||||
description = "OBJCXX {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("asm") {
|
||||
depfile = "{{output}}.d"
|
||||
command =
|
||||
"$llvm_asm $llvm_asm_target_flag {{source}} -o {{output}} {{asmflags}}"
|
||||
depsformat = "gcc"
|
||||
description = "ASM {{output}}"
|
||||
outputs =
|
||||
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
|
||||
}
|
||||
tool("alink") {
|
||||
command = "rm -f {{output}} && $llvm_ar rcs {{output}} {{inputs}}"
|
||||
description = "AR {{output}}"
|
||||
outputs = [ "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" ]
|
||||
default_output_extension = ".a"
|
||||
output_prefix = ""
|
||||
}
|
||||
tool("link") {
|
||||
outputs = [ "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" ]
|
||||
command =
|
||||
"$llvm_ld -o {{output}} {{inputs}} {{ldflags}} {{solibs}} {{libs}}"
|
||||
description = "LINK {{output}}"
|
||||
}
|
||||
tool("stamp") {
|
||||
command = "touch {{output}}"
|
||||
description = "STAMP {{output}}"
|
||||
}
|
||||
tool("copy") {
|
||||
command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
|
||||
description = "COPY {{source}} {{output}}"
|
||||
}
|
||||
}
|
||||
112
toolchains/COMPILERS.gni
Normal file
112
toolchains/COMPILERS.gni
Normal file
@@ -0,0 +1,112 @@
|
||||
if (target_arch == "x86") {
|
||||
gnu_ar = "i686-elf-ar"
|
||||
gnu_cc = "i686-elf-gcc"
|
||||
gnu_cxx = "i686-elf-g++"
|
||||
gnu_ld = "i686-elf-ld"
|
||||
gnu_asm = "nasm"
|
||||
gnu_target = "i686"
|
||||
}
|
||||
if (target_arch == "x86_64") {
|
||||
gnu_ar = "x86_64-elf-ar"
|
||||
gnu_cc = "x86_64-elf-gcc"
|
||||
gnu_cxx = "x86_64-elf-g++"
|
||||
gnu_ld = "x86_64-elf-ld"
|
||||
gnu_asm = "nasm"
|
||||
gnu_target = "x86_64"
|
||||
}
|
||||
|
||||
if (target_arch == "arm32") {
|
||||
gnu_ar = "arm-none-eabi-ar"
|
||||
gnu_cc = "arm-none-eabi-gcc"
|
||||
gnu_cxx = "arm-none-eabi-g++"
|
||||
gnu_ld = "arm-none-eabi-gcc"
|
||||
gnu_asm = "arm-none-eabi-as"
|
||||
gnu_target = "arm-none-eabi"
|
||||
}
|
||||
if (target_arch == "arm64") {
|
||||
gnu_ar = "aarch64-elf-ar"
|
||||
gnu_cc = "aarch64-elf-gcc"
|
||||
gnu_cxx = "aarch64-elf-g++"
|
||||
gnu_ld = "aarch64-elf-gcc"
|
||||
gnu_asm = "aarch64-elf-gcc -c"
|
||||
gnu_target = "aarch64-elf"
|
||||
}
|
||||
|
||||
if (target_arch == "riscv64") {
|
||||
gnu_ar = "riscv64-unknown-elf-ar"
|
||||
gnu_cc = "riscv64-unknown-elf-gcc"
|
||||
gnu_cxx = "riscv64-unknown-elf-g++"
|
||||
gnu_ld = "riscv64-unknown-elf-gcc"
|
||||
gnu_asm = "riscv64-unknown-elf-gcc -c"
|
||||
gnu_target = "riscv64-unknown-elf"
|
||||
}
|
||||
|
||||
if (target_arch == "x86") {
|
||||
llvm_ar = "$llvm_bin_path/llvm-ar"
|
||||
llvm_cc = "$llvm_bin_path/clang"
|
||||
llvm_cxx = "$llvm_bin_path/clang++"
|
||||
llvm_ld = "$llvm_bin_path/ld.lld"
|
||||
llvm_asm = "nasm"
|
||||
llvm_target = "i686-pc-none-elf"
|
||||
llvm_ccpp_target_flag = "-target $llvm_target"
|
||||
llvm_asm_target_flag = "" # No additinal flags are provided for nasm
|
||||
}
|
||||
if (target_arch == "x86_64") {
|
||||
llvm_ar = "$llvm_bin_path/llvm-ar"
|
||||
llvm_cc = "$llvm_bin_path/clang"
|
||||
llvm_cxx = "$llvm_bin_path/clang++"
|
||||
llvm_ld = "$llvm_bin_path/ld.lld"
|
||||
llvm_asm = "nasm"
|
||||
llvm_target = "x86_64--linux"
|
||||
llvm_ccpp_target_flag = "-target $llvm_target"
|
||||
llvm_asm_target_flag = "" # No additinal flags are provided for nasm
|
||||
}
|
||||
|
||||
if (target_arch == "arm32") {
|
||||
llvm_ar = "$llvm_bin_path/llvm-ar"
|
||||
llvm_cc = "$llvm_bin_path/clang"
|
||||
llvm_cxx = "$llvm_bin_path/clang++"
|
||||
llvm_ld = "$llvm_bin_path/ld.lld"
|
||||
llvm_asm = "$llvm_bin_path/clang"
|
||||
llvm_target = "armv7a-pc-none-elf"
|
||||
llvm_ccpp_target_flag = "-target $llvm_target"
|
||||
llvm_asm_target_flag = "-target $llvm_target -c"
|
||||
}
|
||||
if (target_arch == "arm64") {
|
||||
llvm_ar = "$llvm_bin_path/llvm-ar"
|
||||
llvm_cc = "$llvm_bin_path/clang"
|
||||
llvm_cxx = "$llvm_bin_path/clang++"
|
||||
llvm_ld = "$llvm_bin_path/ld.lld"
|
||||
llvm_asm = "$llvm_bin_path/clang"
|
||||
llvm_target = "aarch64--linux"
|
||||
llvm_ccpp_target_flag = "-target $llvm_target"
|
||||
llvm_asm_target_flag = "-target $llvm_target -c"
|
||||
}
|
||||
if (target_arch == "riscv64") {
|
||||
llvm_ar = "$llvm_bin_path/llvm-ar"
|
||||
llvm_cc = "$llvm_bin_path/clang"
|
||||
llvm_cxx = "$llvm_bin_path/clang++"
|
||||
llvm_ld = "$llvm_bin_path/ld.lld"
|
||||
llvm_asm = "$llvm_bin_path/clang"
|
||||
llvm_target = "riscv64--linux"
|
||||
llvm_ccpp_target_flag = "-target $llvm_target"
|
||||
llvm_asm_target_flag = "-target $llvm_target -c"
|
||||
}
|
||||
|
||||
if (host == "gnu") {
|
||||
toolchain_ar = gnu_ar
|
||||
toolchain_cc = gnu_cc
|
||||
toolchain_cxx = gnu_cxx
|
||||
toolchain_ld = gnu_ld
|
||||
toolchain_asm = gnu_asm
|
||||
toolchain_target = gnu_target
|
||||
}
|
||||
|
||||
if (host == "llvm") {
|
||||
toolchain_ar = llvm_ar
|
||||
toolchain_cc = llvm_cc
|
||||
toolchain_cxx = llvm_cxx
|
||||
toolchain_ld = llvm_ld
|
||||
toolchain_asm = llvm_asm
|
||||
toolchain_target = llvm_target
|
||||
}
|
||||
12
toolchains/scripts/arm-none-eabi-tools.sh
Normal file
12
toolchains/scripts/arm-none-eabi-tools.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
version="gcc-arm-none-eabi-10-2020-q4"
|
||||
arch="x86_64" # x86_64 or aarch64
|
||||
|
||||
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/${version}-major-${arch}-linux.tar.bz2
|
||||
sudo tar xjf ${version}.bz2 -C /usr/share/
|
||||
sudo ln -s /usr/share/${version}/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc
|
||||
sudo ln -s /usr/share/${version}/bin/arm-none-eabi-g++ /usr/bin/arm-none-eabi-g++
|
||||
sudo ln -s /usr/share/${version}/bin/arm-none-eabi-ar /usr/bin/arm-none-eabi-ar
|
||||
sudo ln -s /usr/share/${version}/bin/arm-none-eabi-as /usr/bin/arm-none-eabi-as
|
||||
sudo ln -s /usr/share/${version}/bin/arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb
|
||||
412
toolchains/scripts/i686-elf-tools.sh
Normal file
412
toolchains/scripts/i686-elf-tools.sh
Normal file
@@ -0,0 +1,412 @@
|
||||
#!/bin/bash
|
||||
|
||||
# i686-elf-tools.sh
|
||||
# v1.3
|
||||
|
||||
# Define Global Variables
|
||||
|
||||
BINUTILS_VERSION=2.35
|
||||
GCC_VERSION=11.1.0
|
||||
GDB_VERSION=9.2
|
||||
|
||||
BUILD_TARGET="i686-elf"
|
||||
|
||||
set -e
|
||||
|
||||
ALL_PRODUCTS=true
|
||||
|
||||
# Parse Commandline Options
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
BUILD_BINUTILS=true
|
||||
BUILD_GCC=true
|
||||
BUILD_GDB=true
|
||||
ZIP=true
|
||||
|
||||
args="binutils gcc gdb zip"
|
||||
else
|
||||
args=$@
|
||||
fi
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
binutils) BUILD_BINUTILS=true; ALL_PRODUCTS=false; shift ;;
|
||||
gcc) BUILD_GCC=true; ALL_PRODUCTS=false; shift ;;
|
||||
gdb) BUILD_GDB=true; ALL_PRODUCTS=false; shift ;;
|
||||
win) WINDOWS_ONLY=true; shift ;;
|
||||
linux) LINUX_ONLY=true; shift ;;
|
||||
zip) ZIP=true; ALL_PRODUCTS=false; shift ;;
|
||||
env) ENV_ONLY=true; shift ;;
|
||||
-64) x64=true; shift ;;
|
||||
-bv|--binutils-version) BINUTILS_VERSION="$2"; shift; shift ;;
|
||||
-gv|--gcc-version) GCC_VERSION="$2"; shift; shift ;;
|
||||
-dv|--gdb-version) GDB_VERSION="$2"; shift; shift ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $x64 == true ]]; then
|
||||
BUILD_TARGET="x86_64-elf"
|
||||
fi
|
||||
|
||||
BUILD_DIR="$HOME/build-${BUILD_TARGET}"
|
||||
export PATH="/opt/mxe/usr/bin:$BUILD_DIR/linux/output/bin:$BUILD_DIR/windows/output/bin:$PATH"
|
||||
|
||||
echo "BUILD_TARGET = ${BUILD_TARGET}"
|
||||
echo "BUILD_DIR = ${BUILD_DIR}"
|
||||
echo "BUILD_BINUTILS = ${BUILD_BINUTILS}"
|
||||
echo "BUILD_GCC = ${BUILD_GCC}"
|
||||
echo "BUILD_GDB = ${BUILD_GDB}"
|
||||
echo "ZIP = ${ZIP}"
|
||||
echo "WIN = ${WINDOWS_ONLY}"
|
||||
echo "LINUX = ${LINUX_ONLY}"
|
||||
echo "ENV = ${ENV_ONLY}"
|
||||
echo "x64 = ${x64}"
|
||||
echo "BINUTILS_VERSION = ${BINUTILS_VERSION}"
|
||||
echo "GCC_VERSION = ${GCC_VERSION}"
|
||||
echo "GDB_VERSION = ${GDB_VERSION}"
|
||||
echo "PATH = ${PATH}"
|
||||
|
||||
function main {
|
||||
|
||||
installPackages
|
||||
installMXE
|
||||
|
||||
if [[ $ENV_ONLY == true ]]; then
|
||||
echoColor "Successfully installed build environment. Exiting as 'env' only was specified"
|
||||
return
|
||||
fi
|
||||
|
||||
downloadSources
|
||||
|
||||
if [[ $WINDOWS_ONLY == true ]]; then
|
||||
echoColor "Skipping compiling Linux as 'win' was specified in commandline args '$args'"
|
||||
else
|
||||
compileAll "linux"
|
||||
fi
|
||||
|
||||
if [[ $LINUX_ONLY == true ]]; then
|
||||
echoColor "Skipping compiling Windows as 'linux' was specified in commandline args '$args'"
|
||||
else
|
||||
compileAll "windows"
|
||||
fi
|
||||
|
||||
finalize
|
||||
}
|
||||
|
||||
function installPackages {
|
||||
|
||||
echoColor "Installing packages"
|
||||
|
||||
sudo -E apt-get -qq install git \
|
||||
autoconf automake autopoint bash bison bzip2 flex gettext\
|
||||
g++ gperf intltool libffi-dev libgdk-pixbuf2.0-dev \
|
||||
libtool libltdl-dev libssl-dev libxml-parser-perl make \
|
||||
openssl p7zip-full patch perl pkg-config python ruby scons \
|
||||
sed unzip wget xz-utils libtool-bin texinfo g++-multilib lzip -y
|
||||
}
|
||||
|
||||
# MXE
|
||||
|
||||
function installMXE {
|
||||
|
||||
echoColor "Installing MXE"
|
||||
|
||||
if [ ! -d "/opt/mxe/usr/bin" ]
|
||||
then
|
||||
echoColor " Cloning MXE and compiling mingw32.static GCC"
|
||||
cd /opt
|
||||
sudo -E git clone https://github.com/mxe/mxe.git
|
||||
cd mxe
|
||||
sudo make gcc
|
||||
else
|
||||
echoColor " MXE is already installed. You'd better make sure that you've previously made MXE's gcc! (/opt/mxe/usr/bin/i686-w64-mingw32.static-gcc)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Downloads
|
||||
|
||||
function downloadSources {
|
||||
mkdir -p $BUILD_DIR
|
||||
cd $BUILD_DIR
|
||||
|
||||
echoColor "Downloading all sources"
|
||||
|
||||
if [[ $BUILD_BINUTILS == true || $ALL_PRODUCTS == true ]]; then
|
||||
downloadAndExtract "binutils" $BINUTILS_VERSION
|
||||
else
|
||||
echoColor " Skipping binutils as 'binutils' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
|
||||
if [[ $BUILD_GCC == true || $ALL_PRODUCTS == true ]]; then
|
||||
downloadAndExtract "gcc" $GCC_VERSION "http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz"
|
||||
|
||||
echoColor " Downloading GCC prerequisites"
|
||||
|
||||
# Automatically download GMP, MPC and MPFR. These will be placed into the right directories.
|
||||
# You can also download these separately, and specify their locations as arguments to ./configure
|
||||
|
||||
if [[ $WINDOWS_ONLY != true ]]; then
|
||||
echoColor " Linux"
|
||||
cd ./linux/gcc-$GCC_VERSION
|
||||
./contrib/download_prerequisites
|
||||
fi
|
||||
|
||||
cd $BUILD_DIR
|
||||
|
||||
if [[ $LINUX_ONLY != true ]]; then
|
||||
echoColor " Windows"
|
||||
cd ./windows/gcc-$GCC_VERSION
|
||||
./contrib/download_prerequisites
|
||||
fi
|
||||
|
||||
cd $BUILD_DIR
|
||||
else
|
||||
echoColor " Skipping gcc as 'gcc' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
|
||||
if [[ $BUILD_GDB == true || $ALL_PRODUCTS == true ]]; then
|
||||
downloadAndExtract "gdb" $GDB_VERSION
|
||||
else
|
||||
echoColor " Skipping gdb as 'gdb' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
}
|
||||
|
||||
function downloadAndExtract {
|
||||
name=$1
|
||||
version=$2
|
||||
override=$3
|
||||
|
||||
echoColor " Processing $name"
|
||||
|
||||
if [ ! -f $name-$version.tar.gz ]
|
||||
then
|
||||
echoColor " Downloading $name-$version.tar.gz"
|
||||
|
||||
if [ -z $3 ]
|
||||
then
|
||||
wget -q http://ftp.gnu.org/gnu/$name/$name-$version.tar.gz
|
||||
else
|
||||
wget -q $override
|
||||
fi
|
||||
else
|
||||
echoColor " $name-$version.tar.gz already exists"
|
||||
fi
|
||||
|
||||
if [[ $WINDOWS_ONLY == true ]]; then
|
||||
echoColor " Skipping extracting Linux as 'win' was specified in commandline args '$args'"
|
||||
else
|
||||
mkdir -p linux
|
||||
cd linux
|
||||
|
||||
if [ ! -d $name-$version ]
|
||||
then
|
||||
echoColor " [linux] Extracting $name-$version.tar.gz"
|
||||
tar -xf ../$name-$version.tar.gz
|
||||
else
|
||||
echoColor " [linux] Folder $name-$version already exists"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
fi
|
||||
|
||||
if [[ $LINUX_ONLY == true ]]; then
|
||||
echoColor " Skipping extracting Linux as 'win' was specified in commandline args '$args'"
|
||||
else
|
||||
mkdir -p windows
|
||||
cd windows
|
||||
|
||||
if [ ! -d $name-$version ]
|
||||
then
|
||||
echoColor " [windows] Extracting $name-$version.tar.gz"
|
||||
tar -xf ../$name-$version.tar.gz
|
||||
else
|
||||
echoColor " [windows] Folder $name-$version already exists"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
fi
|
||||
}
|
||||
|
||||
function compileAll {
|
||||
|
||||
echoColor "Compiling all $1"
|
||||
|
||||
cd $1
|
||||
|
||||
mkdir -p output
|
||||
|
||||
compileBinutils $1
|
||||
compileGCC $1
|
||||
compileGDB $1
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
function compileBinutils {
|
||||
if [[ $BUILD_BINUTILS == true || $ALL_PRODUCTS == true ]]; then
|
||||
echoColor " Compiling binutils [$1]"
|
||||
|
||||
mkdir -p build-binutils-$BINUTILS_VERSION
|
||||
cd build-binutils-$BINUTILS_VERSION
|
||||
|
||||
configureArgs="--target=${BUILD_TARGET} --with-sysroot --disable-nls --disable-werror --prefix=$BUILD_DIR/$1/output"
|
||||
|
||||
if [ $1 == "windows" ]
|
||||
then
|
||||
configureArgs="--host=i686-w64-mingw32.static $configureArgs"
|
||||
fi
|
||||
|
||||
# Configure
|
||||
echoColor " Configuring binutils (binutils_configure.log)"
|
||||
../binutils-$BINUTILS_VERSION/configure $configureArgs >> binutils_configure.log
|
||||
|
||||
# Make
|
||||
echoColor " Making (binutils_make.log)"
|
||||
make >> binutils_make.log
|
||||
|
||||
# Install
|
||||
echoColor " Installing (binutils_install.log)"
|
||||
sudo make install >> binutils_install.log
|
||||
cd ..
|
||||
else
|
||||
echoColor " Skipping binutils [$1] as 'binutils' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
}
|
||||
|
||||
function compileGCC {
|
||||
if [[ $BUILD_GCC == true || $ALL_PRODUCTS == true ]]; then
|
||||
|
||||
echoColor " Compiling gcc [$1]"
|
||||
|
||||
mkdir -p build-gcc-$GCC_VERSION
|
||||
cd build-gcc-$GCC_VERSION
|
||||
|
||||
configureArgs="--target=${BUILD_TARGET} --disable-nls --enable-languages=c,c++ --without-headers --prefix=$BUILD_DIR/$1/output"
|
||||
|
||||
if [ $1 == "windows" ]
|
||||
then
|
||||
configureArgs="--host=i686-w64-mingw32.static $configureArgs"
|
||||
fi
|
||||
|
||||
if [[ $x64 == true ]]; then
|
||||
|
||||
# https://wiki.osdev.org/Libgcc_without_red_zone#Preparations
|
||||
|
||||
echoColor " Installing config/i386/t-x86_64-elf"
|
||||
echo -e "# Add libgcc multilib variant without red-zone requirement\n\nMULTILIB_OPTIONS += mno-red-zone\nMULTILIB_DIRNAMES += no-red-zone" > ../gcc-$GCC_VERSION/gcc/config/i386/t-x86_64-elf
|
||||
|
||||
echoColor " Patching gcc/config.gcc"
|
||||
sed -i '/x86_64-\*-elf\*)/a \\ttmake_file="${tmake_file} i386/t-x86_64-elf" # include the new multilib configuration' ../gcc-$GCC_VERSION/gcc/config.gcc
|
||||
fi
|
||||
|
||||
# Configure
|
||||
echoColor " Configuring gcc (gcc_configure.log)"
|
||||
../gcc-$GCC_VERSION/configure $configureArgs >> gcc_configure.log
|
||||
|
||||
# Make GCC
|
||||
echoColor " Making gcc (gcc_make.log)"
|
||||
make all-gcc >> gcc_make.log
|
||||
|
||||
# Install GCC
|
||||
echoColor " Installing gcc (gcc_install.log)"
|
||||
sudo make install-gcc >> gcc_install.log
|
||||
|
||||
# Make libgcc
|
||||
echoColor " Making libgcc (libgcc_make.log)"
|
||||
make all-target-libgcc >> libgcc_make.log
|
||||
|
||||
# Install libgcc
|
||||
echoColor " Installing libgcc (libgcc_install.log)"
|
||||
sudo make install-target-libgcc >> libgcc_install.log
|
||||
|
||||
if [[ $x64 == true ]]; then
|
||||
|
||||
if [ $1 == "windows" ]
|
||||
then
|
||||
# no-red-zone doesn't appear to get installed by make install-target-libgcc for some reason. Manually install it ourselves
|
||||
|
||||
cd "${BUILD_TARGET}/no-red-zone/libgcc"
|
||||
sudo make install >> ../../../libgcc_install_noredzone.log
|
||||
|
||||
cd ../../..
|
||||
fi
|
||||
|
||||
if [[ ! -d "../output/lib/gcc/x86_64-elf/$GCC_VERSION/no-red-zone" ]]; then
|
||||
echoError "ERROR: no-red-zone was not created. x64 patching failed"
|
||||
exit 1
|
||||
else
|
||||
echoColor " Successfully compiled for no-red-zone"
|
||||
fi
|
||||
fi
|
||||
|
||||
cd ..
|
||||
else
|
||||
echoColor " Skipping gcc [$1] as 'gcc' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
}
|
||||
|
||||
function compileGDB {
|
||||
if [[ $BUILD_GDB == true || $ALL_PRODUCTS == true ]]; then
|
||||
|
||||
echoColor " Compiling gdb [$1]"
|
||||
|
||||
configureArgs="--target=${BUILD_TARGET} --disable-nls --disable-werror --prefix=$BUILD_DIR/$1/output"
|
||||
|
||||
if [ $1 == "windows" ]
|
||||
then
|
||||
configureArgs="--host=i686-w64-mingw32.static $configureArgs"
|
||||
fi
|
||||
|
||||
mkdir -p build-gdb-$GDB_VERSION
|
||||
cd build-gdb-$GDB_VERSION
|
||||
|
||||
# Configure
|
||||
echoColor " Configuring (gdb_configure.log)"
|
||||
../gdb-$GDB_VERSION/configure $configureArgs >> gdb_configure.log
|
||||
|
||||
# Make
|
||||
echoColor " Making (gdb_make.log)"
|
||||
make >> gdb_make.log
|
||||
|
||||
# Install
|
||||
echoColor " Installing (gdb_install.log)"
|
||||
sudo make install >> gdb_install.log
|
||||
cd ..
|
||||
else
|
||||
echoColor " Skipping gdb [$1] as 'gdb' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
}
|
||||
|
||||
function finalize {
|
||||
if [[ $ZIP == true || $ALL_PRODUCTS == true ]]; then
|
||||
echo "Zipping everything up!"
|
||||
|
||||
if [[ -d "$BUILD_DIR/windows/output" ]]; then
|
||||
cd $BUILD_DIR/windows/output
|
||||
zip -r "${BUILD_DIR}/${BUILD_TARGET}-tools-windows.zip" *
|
||||
fi
|
||||
|
||||
if [[ -d "$BUILD_DIR/linux/output" ]]; then
|
||||
cd $BUILD_DIR/linux/output
|
||||
zip -r "${BUILD_DIR}/${BUILD_TARGET}-tools-linux.zip" *
|
||||
fi
|
||||
|
||||
echo -e "\e[92mZipped everything to $BUILD_DIR/${BUILD_TARGET}-tools-[windows | linux].zip\e[39m"
|
||||
else
|
||||
echoColor " Skipping zipping 'zip' was ommitted from commandline args '$args'"
|
||||
fi
|
||||
}
|
||||
|
||||
function echoColor {
|
||||
echo -e "\e[96m$1\e[39m"
|
||||
}
|
||||
|
||||
function echoError {
|
||||
echo -e "\e[31m$1\e[39m"
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user