sh-elf-vhex - v1.4.0-dev2 : review all scripts
*update* > [scripts] | [all] review all scripts
This commit is contained in:
parent
3b071dbbdf
commit
e958d555d5
|
@ -1,85 +1,67 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
prefix=
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
help()
|
||||
|
||||
function help()
|
||||
{
|
||||
cat << OEF
|
||||
cat << EOF
|
||||
Script for the uninstallation of the Vhex kernel's binutils.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--verbose Display extra information during the uninstallation
|
||||
--prefix=<PREFIX> Installation prefix
|
||||
OEF
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--prefix=*) prefix=${arg#*=};;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
for arg
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
#---
|
||||
# Unistall step
|
||||
#---
|
||||
|
||||
source ../scripts/utils.sh
|
||||
source ../scripts/_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex>'
|
||||
PREFIX="$prefix"
|
||||
SYSROOT="$(get_sysroot)"
|
||||
PREFIX=$(utils_get_env 'VHEX_PREFIX_INSTALL' 'install')
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
|
||||
# Check that all tools has been generated
|
||||
|
||||
existing_gcc="$SYSROOT/bin/sh-elf-vhex-gcc"
|
||||
|
||||
if [[ ! -f "$existing_gcc" ]]; then
|
||||
echo "error: Are you sure to have built sh-elf-vhex ? it seems that" >&2
|
||||
echo " the 'as' tool is missing..." >&2
|
||||
if [[ ! -f "$SYSROOT/bin/sh-elf-vhex-gcc" ]]
|
||||
then
|
||||
echo 'error: Are you sure to have built sh-elf-vhex ? it seems that' >&2
|
||||
echo ' Missing '\''gcc'\'' tool...' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Remove symlinks
|
||||
#---
|
||||
|
||||
cd "$SYSROOT/bin"
|
||||
|
||||
echo "$TAG Removing symlinks to binaries..."
|
||||
for x in *; do
|
||||
for x in "$SYSROOT"/bin/*; do
|
||||
unlink "$PREFIX/$x"
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Remove sysroot
|
||||
#---
|
||||
|
||||
echo "$TAG Removing installed files..."
|
||||
rm -rf "$SYSROOT"
|
||||
rmdir "$SYSROOT"
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# module used to provide common variable / functions
|
||||
|
||||
## workaround to trick the linter
|
||||
# this file must not be manually invoked
|
||||
#
|
||||
# @note
|
||||
# - workaround to trick the linter
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
verbose=false
|
||||
verbose=$VHEX_VERBOSE
|
||||
fi
|
||||
|
||||
#---
|
||||
|
@ -10,8 +12,8 @@ fi
|
|||
#---
|
||||
|
||||
# select the appropriate quiet primitive
|
||||
quiet='run_normaly'
|
||||
[[ "$verbose" == "false" ]] && quiet='run_quietly vxsdk-build.log'
|
||||
quiet='utils_run_normaly'
|
||||
[[ "$verbose" == "false" ]] && quiet='utils_run_quietly vxsdk-build.log'
|
||||
export quiet
|
||||
|
||||
# Number of processor cores
|
||||
|
@ -27,7 +29,7 @@ export make_cmd
|
|||
# Functions provided
|
||||
#---
|
||||
|
||||
function run_normaly() {
|
||||
function utils_run_normaly() {
|
||||
echo "$@"
|
||||
if ! "$@"; then
|
||||
echo "$TAG error: command failed, abord"
|
||||
|
@ -35,7 +37,7 @@ function run_normaly() {
|
|||
fi
|
||||
}
|
||||
|
||||
function run_quietly() {
|
||||
function utils_run_quietly() {
|
||||
out="$1"
|
||||
shift 1
|
||||
if ! "$@" >"$out" 2>&1; then
|
||||
|
@ -54,13 +56,12 @@ function utils_find_last_version() {
|
|||
echo "$_version"
|
||||
}
|
||||
|
||||
function get_sysroot() {
|
||||
if [ -z "${VHEX_PREFIX_SYSROOT}" ]; then
|
||||
function utils_get_env() {
|
||||
if [ -v "$1" ]
|
||||
then
|
||||
echo 'error: are you sure to use the bootstrap script ?' >&2
|
||||
echo ' Missing sysroot information, abord' >&2
|
||||
echo " Missing $2 information, abord" >&2
|
||||
exit 1
|
||||
fi
|
||||
SYSROOT="${VHEX_PREFIX_SYSROOT/#\~/$HOME}"
|
||||
mkdir -p "$SYSROOT"
|
||||
echo "SYSROOT"
|
||||
echo "${!1/#\~/$HOME}"
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
help() {
|
||||
|
||||
function help() {
|
||||
cat << OEF
|
||||
Script for the building step of binutils for the Vhex kernel.
|
||||
|
||||
|
@ -13,52 +12,47 @@ Usage $0 [options...]
|
|||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--verbose Display extra information during the building step
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
for arg;
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Setup check
|
||||
#---
|
||||
|
||||
source ../../scripts/utils.sh
|
||||
source ../../scripts/_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
|
||||
# Avoid rebuilds and error
|
||||
|
||||
if [[ -f ../../build/binutils/.fini ]]; then
|
||||
if [[ -f ../../build/binutils/.fini ]]
|
||||
then
|
||||
echo "$TAG already build, skipping rebuild"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -d ../../build/binutils/build ]]; then
|
||||
if [[ ! -d ../../build/binutils/build ]]
|
||||
then
|
||||
echo "error: Are you sure to have configured binutils ? it seems that" >&2
|
||||
echo " the build directory is missing..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ../../build/binutils/build
|
||||
|
||||
|
||||
|
||||
cd ../../build/binutils/build || exit 1
|
||||
|
||||
#---
|
||||
# Build part
|
||||
|
@ -72,7 +66,6 @@ echo "$TAG Installing binutils to sysroot..."
|
|||
|
||||
$quiet $make_cmd install-strip
|
||||
|
||||
|
||||
# Indicate that the build is finished
|
||||
|
||||
touch ../.fini
|
||||
|
|
|
@ -1,94 +1,61 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
cache=true
|
||||
version='?'
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
|
||||
help() {
|
||||
cat << OEF
|
||||
Script for the configuration step of Vhex kernel's binutils.
|
||||
function help() {
|
||||
cat << EOF
|
||||
Script for the configuration step of Vhex's binutils.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--cache Keep the archive of binutils
|
||||
--verbose Display extra information during the configuration step
|
||||
--version=<VERSION> Select the binutils version. If '?' argument is passed,
|
||||
then all binutils version with Vhex patchs available
|
||||
will be displayed
|
||||
OEF
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--cache) cache=true;;
|
||||
--version=*) version=${arg#*=};;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up" >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
#---
|
||||
# check version
|
||||
#---
|
||||
|
||||
list_version=''
|
||||
for tmp in $(ls -d ../../patchs/binutils/*); do
|
||||
list_version="$list_version $(basename $tmp)"
|
||||
cache=false
|
||||
for arg;
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--cache) cache=true;;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up" >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
if [[ "$version" == '?' ]]; then
|
||||
echo "Binutils available versions:"
|
||||
for ver in $list_version; do
|
||||
echo " $ver"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
if [[ ! $list_version =~ (^|[[:space:]])$version($|[[:space:]]) ]]; then
|
||||
echo "binutils version '$version' is not supported by Vhex"
|
||||
echo 'abording...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Import some helpers
|
||||
|
||||
source ../../scripts/utils.sh
|
||||
|
||||
#---
|
||||
# Configuration part
|
||||
#---
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
VERSION=$version
|
||||
source ../../scripts/_utils.sh
|
||||
|
||||
VERSION=$(utils_get_env 'VHEX_VERSION_BINUTILS' 'binutils')
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
URL="https://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.xz"
|
||||
ARCHIVE="/tmp/sh-elf-vhex/$(basename $URL)"
|
||||
SYSROOT="$(get_sysroot)"
|
||||
ARCHIVE="/tmp/sh-elf-vhex/$(basename "$URL")"
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
|
||||
#---
|
||||
# Avoid rebuilds of the same version
|
||||
#---
|
||||
|
||||
existing_as="$SYSROOT/bin/sh-elf-vhex-as"
|
||||
as_bin="$SYSROOT/bin/sh-elf-vhex-as"
|
||||
|
||||
if [[ -f "$existing_as" ]]; then
|
||||
existing_version=$($existing_as --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ $existing_version == $VERSION ]]; then
|
||||
echo "$TAG Version $VERSION already installed, skipping rebuild"
|
||||
if [[ -f "$as_bin" ]]
|
||||
then
|
||||
as_version=$($as_bin --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ "$as_version" == "$VERSION" ]]
|
||||
then
|
||||
echo "$TAG Version $VERSION already installed, skipping rebuild" >&2
|
||||
mkdir -p ../../build/binutils/
|
||||
touch ../../build/binutils/.fini
|
||||
exit 0
|
||||
|
@ -98,28 +65,35 @@ if [[ -f "$existing_as" ]]; then
|
|||
fi
|
||||
|
||||
#---
|
||||
# Check dependencies for binutils and GCC
|
||||
# Check dependencies for binutils and GCC and offer to install them
|
||||
#---
|
||||
|
||||
if command -v pkg >/dev/null 2>&1; then
|
||||
deps="cmake libmpfr libmpc libgmp libpng flex clang git texinfo libisl bison xz-utils"
|
||||
pm=pkg
|
||||
pm_has="dpkg -s"
|
||||
pm_install="pkg install"
|
||||
elif command -v apt >/dev/null 2>&1; then
|
||||
deps="cmake libmpfr-dev libmpc-dev libgmp-dev libpng-dev libppl-dev flex g++ git texinfo xz-utils"
|
||||
pm=apt
|
||||
pm_has="dpkg -s"
|
||||
pm_install="sudo apt install"
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
deps="cmake mpfr-devel libmpc-devel gmp-devel libpng-devel ppl-devel flex gcc git texinfo xz"
|
||||
pm=dnf
|
||||
if command -v pkg >/dev/null 2>&1
|
||||
then
|
||||
deps='cmake libmpfr libmpc libgmp libpng flex clang git texinfo'
|
||||
deps="$deps libisl bison xz-utils"
|
||||
pm='pkg'
|
||||
pm_has='dpkg -s'
|
||||
pm_install='pkg install'
|
||||
elif command -v apt >/dev/null 2>&1
|
||||
then
|
||||
deps='cmake libmpfr-dev libmpc-dev libgmp-dev libpng-dev libppl-dev'
|
||||
deps="$deps flex g++ git texinfo xz-utils"
|
||||
pm='apt'
|
||||
pm_has='dpkg -s'
|
||||
pm_install='sudo apt install'
|
||||
elif command -v dnf >/dev/null 2>&1
|
||||
then
|
||||
deps='cmake mpfr-devel libmpc-devel gmp-devel libpng-devel ppl-devel'
|
||||
deps="$deps flex gcc git texinfo xz"
|
||||
pm='dnf'
|
||||
pm_has="echo '$(rpm -qa)' | grep -i "
|
||||
pm_install="sudo dnf install"
|
||||
pm_install='sudo dnf install'
|
||||
fix='-'
|
||||
elif command -v pacman >/dev/null 2>&1; then
|
||||
deps="cmake mpfr libmpc gmp libpng ppl flex gcc git texinfo xz"
|
||||
pm=pacman
|
||||
elif command -v pacman >/dev/null 2>&1
|
||||
then
|
||||
deps='cmake mpfr libmpc gmp libpng ppl flex gcc git texinfo xz'
|
||||
pm='pacman'
|
||||
pm_has="pacman -Qi"
|
||||
pm_install="sudo pacman -S"
|
||||
else
|
||||
|
@ -135,17 +109,16 @@ if [[ -z "$trust_deps" ]]; then
|
|||
done
|
||||
fi
|
||||
|
||||
#---
|
||||
# Offer to install dependencies
|
||||
#---
|
||||
|
||||
if [[ ! -z "$missing" ]]; then
|
||||
echo "$TAG Based on $pm, some dependencies are missing: $missing"
|
||||
echo -n "$TAG Do you want to run '$pm_install $missing' to install them (Y/n)? "
|
||||
|
||||
read do_install
|
||||
if [[ "$do_install" == "y" || "$do_install" == "Y" || "$do_install" == "" ]]; then
|
||||
$pm_install $missing
|
||||
if [[ -n "$missing" ]]
|
||||
then
|
||||
echo -en \
|
||||
"$TAG Based on $pm, some dependencies are missing: $missing\n" \
|
||||
"$TAG Do you want to run '$pm_install $missing' to install " \
|
||||
'them [nY]? '
|
||||
read -r do_install
|
||||
if [[ "$do_install" == "n" ]]
|
||||
then
|
||||
$pm_install "$missing"
|
||||
else
|
||||
echo "$TAG Skipping dependencies, hoping it will build anyway."
|
||||
fi
|
||||
|
@ -155,22 +128,24 @@ fi
|
|||
# Download archive
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]; then
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
rm -f "$ARCHIVE"
|
||||
fi
|
||||
fi
|
||||
mkdir -p $(dirname "$ARCHIVE")
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
[[ "$cache" == 'false' && -f "$ARCHIVE" ]] && rm -f "$ARCHIVE"
|
||||
|
||||
mkdir -p "$(dirname "$ARCHIVE")"
|
||||
if [[ -f "$ARCHIVE" ]]
|
||||
then
|
||||
echo "$TAG Found $ARCHIVE, skipping download"
|
||||
else
|
||||
echo "$TAG Downloading $URL..."
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl $URL -o $ARCHIVE
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q --show-progress $URL -O $ARCHIVE
|
||||
if command -v curl >/dev/null 2>&1
|
||||
then
|
||||
curl "$URL" -o "$ARCHIVE"
|
||||
elif command -v wget >/dev/null 2>&1
|
||||
then
|
||||
wget -q --show-progress "$URL" -O "$ARCHIVE"
|
||||
else
|
||||
echo "$TAG error: no curl or wget; install one or download archive yourself" >&2
|
||||
echo \
|
||||
"$TAG error: no curl or wget; install one or download "
|
||||
'archive yourself' >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -182,27 +157,25 @@ fi
|
|||
echo "$TAG Extracting $ARCHIVE..."
|
||||
|
||||
mkdir -p ../../build/binutils/
|
||||
cd ../../build/binutils
|
||||
cd ../../build/binutils || exit 1
|
||||
|
||||
unxz -c < $ARCHIVE | tar -xf -
|
||||
unxz -c < "$ARCHIVE" | tar -xf -
|
||||
|
||||
|
||||
# Touch intl/plural.c to avoid regenerating it from intl/plural.y with recent
|
||||
# versions of bison, which is subject to the following known bug.
|
||||
# Touch intl/plural.c to avoid regenerating it from intl/plural.y with
|
||||
# recent versions of bison, which is subject to the following known bug.
|
||||
# * https://sourceware.org/bugzilla/show_bug.cgi?id=22941
|
||||
# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92008
|
||||
touch binutils-$VERSION/intl/plural.c
|
||||
touch "binutils-$VERSION/intl/plural.c"
|
||||
|
||||
# Apply binutils patchs for Vhex
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r ../../patchs/binutils/$VERSION/* ./binutils-$VERSION/
|
||||
cp -r "../../patchs/binutils/$VERSION/*" "./binutils-$VERSION/"
|
||||
|
||||
# Create build folder
|
||||
|
||||
[[ -d "build" ]] && rm -rf build
|
||||
mkdir build && cd build
|
||||
|
||||
mkdir build && cd build || exit 1
|
||||
|
||||
#---
|
||||
# Real configuration step
|
||||
|
@ -210,20 +183,21 @@ mkdir build && cd build
|
|||
|
||||
echo "$TAG Configuring binutils..."
|
||||
|
||||
$quiet ../binutils-$VERSION/configure \
|
||||
--prefix="$SYSROOT" \
|
||||
--target='sh-elf-vhex' \
|
||||
--program-prefix='sh-elf-vhex-' \
|
||||
--with-multilib-list='m3,m4-nofpu' \
|
||||
--enable-lto \
|
||||
--enable-shared \
|
||||
$quiet "../binutils-$VERSION/configure" \
|
||||
--prefix="$SYSROOT" \
|
||||
--target='sh-elf-vhex' \
|
||||
--program-prefix='sh-elf-vhex-' \
|
||||
--with-multilib-list='m3,m4-nofpu' \
|
||||
--enable-lto \
|
||||
--enable-shared \
|
||||
--disable-nls
|
||||
|
||||
#---
|
||||
# Cache management
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]; then
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Removing $ARCHIVE..."
|
||||
rm -f "$ARCHIVE"
|
||||
fi
|
||||
|
|
|
@ -21,12 +21,14 @@ Options:
|
|||
Notes:
|
||||
|
||||
This script will use env variables:
|
||||
VHEX_VERBOSE - verbose status
|
||||
VHEX_VERSION_BINUTILS - target version of BINUTILS
|
||||
VHEX_VERSION_GCC - target version of GCC
|
||||
VHEX_PREFIX_INSTALL - installation prefix
|
||||
VHEX_PREFIX_SYSROOT - sysroot prefix
|
||||
|
||||
Default value for each configuration:
|
||||
VHEX_VERBOSE - false
|
||||
VHEX_VERSION_BINUTILS - lastest detected
|
||||
VHEX_VERSION_GCC - lastest detected
|
||||
VHEX_PREFIX_INSTALL - "~/.local/bin/"
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
help() {
|
||||
cat << OEF
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
Script for the building step of GCC for the Vhex kernel.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
@ -14,63 +13,58 @@ Usage $0 [options...]
|
|||
Configurations:
|
||||
-h, --help Display this help
|
||||
--verbose Display extra information during the building step
|
||||
OEF
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
# Import some helpers
|
||||
|
||||
source ../utils.sh
|
||||
for arg;
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Building step
|
||||
# @note:
|
||||
# We need to build GCC at least two time. This because we want to enable
|
||||
# shared version of the libgcc. But, to compile this library, we require
|
||||
# building our own standard C library, which require openlibm and the static
|
||||
# version of the libgcc.
|
||||
# building our own standard C library, which require openlibm and the
|
||||
# static version of the libgcc.
|
||||
#
|
||||
# To avoid this circular dependency, we shall build the GCC tools with the
|
||||
# static version of the libgcc. This will enable us to compile the openlibm,
|
||||
# then our custom C standard library. After that, we will rebuild GCC with,
|
||||
# this time, the shared version of the libgcc.
|
||||
# static version of the libgcc. This will enable us to compile the
|
||||
# openlibm, then our custom C standard library. After that, we will
|
||||
# rebuild GCC with, this time, the shared version of the libgcc.
|
||||
#---
|
||||
|
||||
source ../../scripts/_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
SYSROOT="$(get_sysroot)"
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
|
||||
# Avoid rebuilds and error
|
||||
|
||||
if [[ -f ../../build/gcc/.fini ]]; then
|
||||
if [[ -f ../../build/gcc/.fini ]]
|
||||
then
|
||||
echo "$TAG already build, skipping rebuild"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -d ../../build/gcc ]]; then
|
||||
echo "error: Are you sure to have built GCC ? it seems that" >&2
|
||||
echo " the build directory is missing..." >&2
|
||||
if [[ ! -d ../../build/gcc ]]
|
||||
then
|
||||
echo 'error: Are you sure to have built GCC ? it seems that' >&2
|
||||
echo ' the build directory is missing...' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ../../build/gcc/build
|
||||
|
||||
|
||||
|
||||
cd ../../build/gcc/build || exit 1
|
||||
|
||||
#---
|
||||
# Build GCC stage-1
|
||||
|
@ -93,8 +87,7 @@ $quiet ../gcc/configure \
|
|||
--enable-shared \
|
||||
--disable-threads \
|
||||
--disable-default-ssp \
|
||||
--disable-nls \
|
||||
$extra_args
|
||||
--disable-nls
|
||||
|
||||
echo "$TAG Compiling GCC (usually 10-20 minutes)..."
|
||||
|
||||
|
@ -104,27 +97,19 @@ echo "$TAG Install GCC..."
|
|||
|
||||
$quiet $make_cmd -j"$cores" install-strip-gcc
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Patch the C standar library
|
||||
#---
|
||||
|
||||
# export binaries used to build OpenLibM and fxLibc
|
||||
# also export sysroot for the fxlibc build / install steps
|
||||
|
||||
export PATH="$PATH:$SYSROOT/bin"
|
||||
export VXSDK_COMPILER_SYSROOT="$SYSROOT/sh-elf-vhex"
|
||||
export VXSDK_COMPILER_CIRCULAR_BUILD_WORKAROUND="true"
|
||||
|
||||
echo "$TAG Building Vhex's custom C standard library..."
|
||||
|
||||
$quiet vxsdk pkg clone fxlibc@dev -o ../fxlibc --yes
|
||||
$quiet vxsdk -vvv build-superh ../fxlibc --verbose
|
||||
|
||||
|
||||
|
||||
# (todo) : clone the vxlibc in local
|
||||
# (todo) : build
|
||||
# (todo) : install
|
||||
|
||||
#---
|
||||
# Finish to build GCC
|
||||
|
@ -162,7 +147,6 @@ echo "$TAG Install libsanitizer..."
|
|||
|
||||
$quiet $make_cmd -j"$cores" install-strip-target-libsanitizer
|
||||
|
||||
|
||||
#---
|
||||
# Indicate that the build is finished
|
||||
#---
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
cache=true
|
||||
version='?'
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
help() {
|
||||
cat << OEF
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
Script for the configuration step of Vhex kernel's binutils.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
@ -16,80 +13,48 @@ Usage $0 [options...]
|
|||
Configurations:
|
||||
-h, --help Display this help
|
||||
--cache Keep the archive of GCC
|
||||
--verbose Display extra information during the configuration step
|
||||
--version=<VERSION> Select the GCC version. If '?' argument is passed,
|
||||
then all GCC version with Vhex patchs available
|
||||
will be displayed
|
||||
OEF
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--cache) cache=true;;
|
||||
--version=*) version=${arg#*=};;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
#---
|
||||
# check version
|
||||
#---
|
||||
|
||||
list_version=''
|
||||
for tmp in $(ls -d ../../patchs/gcc/*); do
|
||||
list_version="$list_version $(basename $tmp)"
|
||||
cache=false
|
||||
for arg
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--cache) cache=true;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
if [[ "$version" == '?' ]]; then
|
||||
echo "GCC available versions:"
|
||||
for ver in $list_version; do
|
||||
echo " $ver"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
if [[ ! $list_version =~ (^|[[:space:]])$version($|[[:space:]]) ]]; then
|
||||
echo "GCC version '$version' is not supported by Vhex"
|
||||
echo 'abording...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#---
|
||||
# Import some helpers
|
||||
# <> get_sysroot() -> workaround with the vxsdk to fetch the sysroot path
|
||||
# <> run_quietly() -> do not display command logs and save them in log files
|
||||
#---
|
||||
|
||||
source ../../scripts/utils.sh
|
||||
|
||||
#---
|
||||
# Configuration part
|
||||
#---
|
||||
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
VERSION="$version"
|
||||
source ../../scripts/_utils.sh
|
||||
|
||||
VERSION=$(utils_get_env 'VHEX_VERSION_GCC' 'binutils')
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz"
|
||||
ARCHIVE="/tmp/sh-elf-vhex/$(basename $URL)"
|
||||
SYSROOT="$(get_sysroot)"
|
||||
ARCHIVE="/tmp/sh-elf-vhex/$(basename "$URL")"
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
|
||||
#---
|
||||
# Avoid rebuilds of the same version
|
||||
#---
|
||||
|
||||
existing_gcc="$SYSROOT/bin/sh-elf-vhex-gcc"
|
||||
gcc_bin="$SYSROOT/bin/sh-elf-vhex-gcc"
|
||||
|
||||
if [[ -f "$existing_gcc" ]]; then
|
||||
existing_version=$($existing_gcc --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ $existing_version == $VERSION ]]; then
|
||||
if [[ -f "$gcc_bin" ]]
|
||||
then
|
||||
gcc_version=$($gcc_bin --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ "$gcc_version" == "$VERSION" ]]
|
||||
then
|
||||
echo "$TAG Version $VERSION already installed, skipping rebuild"
|
||||
mkdir -p ../../build/gcc/
|
||||
touch ../../build/gcc/.fini
|
||||
|
@ -103,22 +68,24 @@ fi
|
|||
# Download archive
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]; then
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
rm -f "$ARCHIVE"
|
||||
fi
|
||||
fi
|
||||
mkdir -p $(dirname "$ARCHIVE")
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
[[ "$cache" == 'false' && -f "$ARCHIVE" ]] && rm -f "$ARCHIVE"
|
||||
|
||||
mkdir -p "$(dirname "$ARCHIVE")"
|
||||
if [[ -f "$ARCHIVE" ]]
|
||||
then
|
||||
echo "$TAG Found $ARCHIVE, skipping download"
|
||||
else
|
||||
echo "$TAG Downloading $URL..."
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl $URL -o $ARCHIVE
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q --show-progress $URL -O $ARCHIVE
|
||||
if command -v curl >/dev/null 2>&1
|
||||
then
|
||||
curl "$URL" -o "$ARCHIVE"
|
||||
elif command -v wget >/dev/null 2>&1
|
||||
then
|
||||
wget -q --show-progress "$URL" -O "$ARCHIVE"
|
||||
else
|
||||
echo "$TAG error: no curl or wget; install one or download archive yourself" >&2
|
||||
echo \
|
||||
"$TAG error: no curl or wget; install one or download archive " \
|
||||
' yourself' >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -129,23 +96,22 @@ fi
|
|||
|
||||
echo "$TAG Extracting $ARCHIVE..."
|
||||
|
||||
mkdir -p ../../build/gcc
|
||||
cd ../../build/gcc/
|
||||
mkdir -p ../../build/gcc && cd ../../build/gcc/ || exit 1
|
||||
|
||||
unxz -c < $ARCHIVE | tar -xf -
|
||||
unxz -c < "$ARCHIVE" | tar -xf -
|
||||
|
||||
#---
|
||||
# Apply GCC patchs for Vhex
|
||||
#---
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r ../../patchs/gcc/$VERSION/* ./gcc-$VERSION/
|
||||
cp -r "../../patchs/gcc/$VERSION/*" "./gcc-$VERSION/"
|
||||
|
||||
# Rename the extracted directory to avoid path deduction during building step
|
||||
# (so the build script will use explicitly ...build/gcc/... path)
|
||||
# Rename the extracted directory to avoid path deduction during building
|
||||
# step (so the build script will use explicitly ...build/gcc/... path)
|
||||
|
||||
[[ -d ./gcc ]] && rm -rf ./gcc
|
||||
mv ./gcc-$VERSION/ ./gcc
|
||||
mv "./gcc-$VERSION/" ./gcc
|
||||
|
||||
#---
|
||||
# Install dependencies
|
||||
|
@ -153,9 +119,9 @@ mv ./gcc-$VERSION/ ./gcc
|
|||
|
||||
echo "$TAG install dependencies..."
|
||||
|
||||
cd gcc
|
||||
cd gcc || exit 1
|
||||
$quiet ./contrib/download_prerequisites
|
||||
cd ..
|
||||
cd .. || exit 1
|
||||
|
||||
mkdir -p build
|
||||
|
||||
|
@ -163,9 +129,8 @@ mkdir -p build
|
|||
# Cache management
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]; then
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Removing $ARCHIVE..."
|
||||
rm -f "$ARCHIVE"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue