sh-elf-vhex - v1.4.0-dev4 : fix binutils build and GCC build (stage 1)
*update* > [scripts] | [_install] support the new architecture | [gcc] display sysroot and version information | [binutils] display sysroot and version information *fix* > [patches] | [binutils] remove hazardous v2.38 patches | [gcc] remove broken v1.3.0 patches > [scripts] | [all] fix path handling | [_utils] fix exit during function error | [_utils] fix bad env var check | [gcc] fix user input check for dependencies install | [gcc] fix dependencies install | [bootstrap] fix missing verbose information in verbose mode | [bootstrap] fix error handling during operation | [bootstrap] fix end message
This commit is contained in:
parent
1928260997
commit
5eccfc8669
|
@ -1 +0,0 @@
|
|||
2.37
|
|
@ -9,7 +9,7 @@ prefix=
|
|||
#---
|
||||
|
||||
function help() {
|
||||
cat << OEF
|
||||
cat << EOF
|
||||
Script for the installation step of binutils/GCC tools for the Vhex kernel.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
@ -17,9 +17,7 @@ Usage $0 [options...]
|
|||
Configurations:
|
||||
-h, --help Display this help
|
||||
--cache Keep the build and the sources directory
|
||||
--verbose Display extra information during the installation step
|
||||
--prefix=<PREFIX> Installation prefix
|
||||
OEF
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
@ -27,33 +25,32 @@ OEF
|
|||
# Parse arguments
|
||||
#---
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--cache) cache=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;;
|
||||
--cache) cache=true;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Installation step
|
||||
#---
|
||||
|
||||
source ../scripts/_utils.sh
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd "$_src" || exit 1
|
||||
source ./_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex>'
|
||||
PREFIX="$prefix"
|
||||
SYSROOT="$(get_sysroot)"
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
INSTALL=$(utils_get_env 'VHEX_PREFIX_INSTALL' 'install')
|
||||
|
||||
# Check that all tools has been generated
|
||||
|
||||
existing_gcc="$SYSROOT/bin/sh-elf-vhex-gcc"
|
||||
|
||||
if [[ ! -f "$existing_gcc" ]]; then
|
||||
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 " the 'as' tool is missing..." >&2
|
||||
exit 1
|
||||
|
@ -61,7 +58,8 @@ fi
|
|||
|
||||
# Cleanup build files
|
||||
|
||||
if [[ "$cache" == 'false' ]]; then
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Cleaning up build files..."
|
||||
rm -rf ../../build
|
||||
fi
|
||||
|
@ -72,7 +70,7 @@ fi
|
|||
|
||||
echo "$TAG Symlinking binaries..."
|
||||
|
||||
mkdir -p "$PREFIX"
|
||||
for x in *; do
|
||||
ln -sf "$SYSROOT/bin/$x" "$PREFIX/$x"
|
||||
mkdir -p "$INSTALL"
|
||||
for x in "$SYSROOT/bin"/*; do
|
||||
ln -s "$x" "$INSTALL/$x"
|
||||
done
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# module used to provide common variable / functions
|
||||
# this file must not be manually invoked
|
||||
#
|
||||
# @note
|
||||
# - workaround to trick the linter
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
verbose=$VHEX_VERBOSE
|
||||
fi
|
||||
|
||||
#---
|
||||
# Internals
|
||||
#---
|
||||
|
||||
# workaround used to self-kill the current process if an error is detected
|
||||
# in function
|
||||
trap 'exit 1' TERM
|
||||
export TOP_PID=$$
|
||||
|
||||
#---
|
||||
# Exposed vars
|
||||
|
@ -13,7 +16,7 @@ fi
|
|||
|
||||
# select the appropriate quiet primitive
|
||||
quiet='utils_run_normaly'
|
||||
[[ "$verbose" == "false" ]] && quiet='utils_run_quietly vxsdk-build.log'
|
||||
[[ ! -v 'VHEX_VERBOSE' ]] && quiet='utils_run_quietly vxsdk-build.log'
|
||||
export quiet
|
||||
|
||||
# Number of processor cores
|
||||
|
@ -31,19 +34,21 @@ export make_cmd
|
|||
|
||||
function utils_run_normaly() {
|
||||
echo "$@"
|
||||
if ! "$@"; then
|
||||
if ! "$@"
|
||||
then
|
||||
echo "$TAG error: command failed, abord"
|
||||
exit 1
|
||||
kill -s TERM $TOP_PID
|
||||
fi
|
||||
}
|
||||
|
||||
function utils_run_quietly() {
|
||||
out="$1"
|
||||
shift 1
|
||||
if ! "$@" >"$out" 2>&1; then
|
||||
>&2 echo "$TAG error: command failed, please check $(pwd)/$out o(x_x)o"
|
||||
>&2 echo "$@"
|
||||
exit 1
|
||||
if ! "$@" >"$out" 2>&1
|
||||
then
|
||||
echo "$TAG error: command failed, please check $(pwd)/$out o(x_x)o" >&2
|
||||
echo "$@" >&2
|
||||
kill -s TERM $TOP_PID
|
||||
fi
|
||||
rm -f "$out"
|
||||
}
|
||||
|
@ -57,11 +62,11 @@ function utils_find_last_version() {
|
|||
}
|
||||
|
||||
function utils_get_env() {
|
||||
if [ -v "$1" ]
|
||||
if [ ! -v "$1" ]
|
||||
then
|
||||
echo 'error: are you sure to use the bootstrap script ?' >&2
|
||||
echo " Missing $2 information, abord" >&2
|
||||
exit 1
|
||||
kill -s TERM $TOP_PID
|
||||
fi
|
||||
echo "${!1/#\~/$HOME}"
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ done
|
|||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
source "$_src/../_utils.sh"
|
||||
cd "$_src" || exit 1
|
||||
source ../_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ done
|
|||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
source "$_src/../_utils.sh"
|
||||
cd "$_src" || exit 1
|
||||
source ../_utils.sh
|
||||
|
||||
VERSION=$(utils_get_env 'VHEX_VERSION_BINUTILS' 'binutils')
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
|
@ -45,6 +46,9 @@ URL="https://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.xz"
|
|||
ARCHIVE="/tmp/sh-elf-vhex/$(basename "$URL")"
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
|
||||
echo "$TAG Target binutils version -> $VERSION"
|
||||
echo "$TAG Sysroot found -> $SYSROOT"
|
||||
|
||||
#---
|
||||
# Avoid rebuilds of the same version
|
||||
#---
|
||||
|
@ -101,7 +105,7 @@ else
|
|||
trust_deps=1
|
||||
fi
|
||||
|
||||
missing=""
|
||||
missing=''
|
||||
if [[ -z "$trust_deps" ]]; then
|
||||
for d in $deps; do
|
||||
if ! bash -c "$pm_has $d$fix" >/dev/null 2>&1; then
|
||||
|
@ -117,9 +121,9 @@ then
|
|||
"$TAG Do you want to run '$pm_install $missing' to install " \
|
||||
'them [nY]? '
|
||||
read -r do_install
|
||||
if [[ "$do_install" == "n" ]]
|
||||
if [[ "$do_install" != 'n' ]]
|
||||
then
|
||||
$pm_install "$missing"
|
||||
bash -c "$pm_install $missing"
|
||||
else
|
||||
echo "$TAG Skipping dependencies, hoping it will build anyway."
|
||||
fi
|
||||
|
@ -157,8 +161,8 @@ fi
|
|||
|
||||
echo "$TAG Extracting $ARCHIVE..."
|
||||
|
||||
mkdir -p ../../build/binutils/
|
||||
cd ../../build/binutils || exit 1
|
||||
mkdir -p ../../build/binutils
|
||||
cd ../../build/binutils/ || exit 1
|
||||
|
||||
unxz -c < "$ARCHIVE" | tar -xf -
|
||||
|
||||
|
@ -171,7 +175,7 @@ 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 "$_src/../../patches/binutils/$VERSION"/* ./binutils-"$VERSION"/
|
||||
|
||||
# Create build folder
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ done
|
|||
# Preliminary check
|
||||
#---
|
||||
|
||||
|
||||
if [ -d "$VHEX_PREFIX_CLONE" ]; then
|
||||
echo "It seems that the project is already existing :pouce:" >&2
|
||||
echo \
|
||||
|
@ -77,12 +76,13 @@ fi
|
|||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
source "$_src/_utils.sh"
|
||||
|
||||
VHEX_VERSION_GCC=$(utils_find_last_version "$_src/../patchs/gcc")
|
||||
VHEX_VERSION_BINUTILS=$(utils_find_last_version "$_src/../patchs/binutils")
|
||||
VHEX_VERSION_GCC=$(utils_find_last_version "$_src/../patches/gcc")
|
||||
VHEX_VERSION_BINUTILS=$(utils_find_last_version "$_src/../patches/binutils")
|
||||
|
||||
if [[ "$VHEX_VERBOSE" == 'true' ]]
|
||||
then
|
||||
echo "Debug fetched information:"
|
||||
echo " - VHEX_VERBOSE = $VHEX_VERBOSE"
|
||||
echo " - VHEX_VERSION_BINUTILS = $VHEX_VERSION_BINUTILS"
|
||||
echo " - VHEX_VERSION_GCC = $VHEX_VERSION_GCC"
|
||||
echo " - VHEX_PREFIX_INSTALL = $VHEX_PREFIX_INSTALL"
|
||||
|
@ -114,6 +114,7 @@ git clone \
|
|||
--depth=1 \
|
||||
https://github.com/YannMagnin/sh-elf-vhex.git \
|
||||
"$VHEX_PREFIX_CLONE"
|
||||
|
||||
cd "$VHEX_PREFIX_CLONE" || exit 1
|
||||
|
||||
export VHEX_VERSION_BINUTILS
|
||||
|
@ -123,17 +124,28 @@ export VHEX_PREFIX_INSTALL
|
|||
export VHEX_PREFIX_SYSROOT
|
||||
export VHEX_PREFIX_CLONE
|
||||
|
||||
success='true'
|
||||
if [[ "$action" == 'install' ]]
|
||||
then
|
||||
./scripts/binutils/configure.sh
|
||||
./scripts/binutils/build.sh
|
||||
./scripts/gcc/configure.sh
|
||||
./scripts/gcc/build.sh
|
||||
./scripts/_install.sh
|
||||
./scripts/binutils/configure.sh \
|
||||
&& ./scripts/binutils/build.sh \
|
||||
&& ./scripts/gcc/configure.sh \
|
||||
&& ./scripts/gcc/build.sh \
|
||||
&& ./scripts/_install.sh \
|
||||
|| success='false'
|
||||
if [[ "$success" == 'true' ]]
|
||||
then
|
||||
echo 'Error during bootstraping operation' >&2
|
||||
exit 1
|
||||
fi
|
||||
echo 'Successfully installed sh-elf-vhex !'
|
||||
echo "Do not forget to export the binary path '$VHEX_PREFIX_INSTALL'"
|
||||
else
|
||||
./scripts/_uninstall.sh
|
||||
./scripts/_uninstall.sh || success='false'
|
||||
if [[ "$success" != 'true' ]]
|
||||
then
|
||||
echo 'Error during unstallation step, abord' >&2
|
||||
exit 1
|
||||
fi
|
||||
echo 'Successfully uninstalled sh-elf-vhex'
|
||||
fi
|
||||
|
||||
echo 'Successfully installed sh-elf-vhex !'
|
||||
echo "Do not forget to export the binary path '$VHEX_PREFIX_INSTALL'"
|
||||
exit 0
|
||||
|
|
|
@ -38,14 +38,15 @@ done
|
|||
# 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
|
||||
# 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.
|
||||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
source "$_src/../_utils.sh"
|
||||
cd "$_src" || exit 1
|
||||
source ../_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
|
@ -73,7 +74,7 @@ cd ../../build/gcc/build || exit 1
|
|||
|
||||
echo "$TAG Configuring GCC (stage 1)..."
|
||||
|
||||
# Configure GCC stage-1 (force disable shared version of the libgcc)
|
||||
# Configure GCC stage-1 (minimal build as possible for library)
|
||||
|
||||
$quiet ../gcc/configure \
|
||||
--prefix="$SYSROOT" \
|
||||
|
|
|
@ -37,7 +37,8 @@ done
|
|||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
source "$_src/../_utils.sh"
|
||||
cd "$_src" || exit 1
|
||||
source ../_utils.sh
|
||||
|
||||
VERSION=$(utils_get_env 'VHEX_VERSION_GCC' 'binutils')
|
||||
SYSROOT=$(utils_get_env 'VHEX_PREFIX_SYSROOT' 'sysroot')
|
||||
|
@ -45,6 +46,9 @@ URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz"
|
|||
ARCHIVE="/tmp/sh-elf-vhex/$(basename "$URL")"
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
|
||||
echo "$TAG Target gcc version -> $VERSION"
|
||||
echo "$TAG Sysroot found -> $SYSROOT"
|
||||
|
||||
#---
|
||||
# Avoid rebuilds of the same version
|
||||
#---
|
||||
|
@ -106,7 +110,7 @@ unxz -c < "$ARCHIVE" | tar -xf -
|
|||
#---
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r "../../patchs/gcc/$VERSION/*" "./gcc-$VERSION/"
|
||||
cp -r "../../patches/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)
|
||||
|
|
Loading…
Reference in New Issue