sh-elf-vhex - v2.0.0-dev7 : reduce boilerplate + rename internal generated folder name
*update* > [scripts] | [_utils] centralise archive operation | [common] switch `build` generated folder name to `_build` | [common] enable archive cache per default | [gcc] use the new archive abstraction | [binutils] use the new archive abstraction *fix* > [scripts] | [_utils] fix archive cache handling
This commit is contained in:
parent
155a34acc1
commit
5b52c6c151
|
@ -55,3 +55,47 @@ function utils_makecmd()
|
|||
|| make_cmd='make'
|
||||
utils_callcmd "$make_cmd" "-j$cores" "$@"
|
||||
}
|
||||
|
||||
function utils_archive_download()
|
||||
{
|
||||
url=$1
|
||||
output=$2
|
||||
cached=$3
|
||||
archive="/tmp/sh-elf-vhex/$(basename "$url")"
|
||||
|
||||
if [[ -d "$output/archive" ]]
|
||||
then
|
||||
echo "$TAG Found archive, skipping download"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! test -f "$archive"
|
||||
then
|
||||
echo "$TAG Downloading $url..."
|
||||
mkdir -p "$(dirname "$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 at '$archive'" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$TAG Extracting $archive..."
|
||||
|
||||
mkdir -p "$output/archive" && pushd "$output/archive" > /dev/null || exit 1
|
||||
unxz -c < "$archive" | tar --strip-components 1 -xf -
|
||||
popd > /dev/null || exit 1
|
||||
|
||||
if [[ "$cached" != 'true' ]]
|
||||
then
|
||||
echo "$TAG Removing $archive..."
|
||||
rm -f "$archive"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -39,20 +39,20 @@ source ../_utils.sh
|
|||
|
||||
# Avoid rebuilds and error
|
||||
|
||||
if [[ -f ../../build/binutils/.fini ]]
|
||||
if [[ -f ../../_build/binutils/.fini ]]
|
||||
then
|
||||
echo "$TAG already build, skipping rebuild"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -d ../../build/binutils/build ]]
|
||||
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 || exit 1
|
||||
cd ../../_build/binutils/build || exit 1
|
||||
|
||||
#---
|
||||
# Build part
|
||||
|
|
|
@ -13,7 +13,7 @@ Usage $0 [options...]
|
|||
Configurations:
|
||||
-h, --help Display this help
|
||||
-v, --verbose Display extra information during operation
|
||||
--cache Keep the archive of binutils
|
||||
--no-cache Do not keep the archive of binutils
|
||||
--prefix-sysroot Sysroot (lib, header, ...) prefix
|
||||
--version Binutils version
|
||||
EOF
|
||||
|
@ -24,16 +24,16 @@ EOF
|
|||
# Parse arguments
|
||||
#---
|
||||
|
||||
cache=false
|
||||
cached='true'
|
||||
prefix_sysroot=
|
||||
version=
|
||||
for arg;
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose | -v) verbose=true;;
|
||||
--verbose | -v) verbose='true';;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--version=*) version=${arg#*=};;
|
||||
--cache) cache=true;;
|
||||
--no-cache) cached='false';;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up" >&2
|
||||
exit 1
|
||||
|
@ -56,9 +56,6 @@ fi
|
|||
|
||||
[[ "$verbose" == 'true' ]] && export VERBOSE=1
|
||||
|
||||
url="https://ftp.gnu.org/gnu/binutils/binutils-$version.tar.xz"
|
||||
archive="/tmp/sh-elf-vhex/$(basename "$url")"
|
||||
|
||||
echo "$TAG Target binutils version -> $version"
|
||||
echo "$TAG Sysroot found -> $prefix_sysroot"
|
||||
|
||||
|
@ -74,12 +71,12 @@ then
|
|||
if [[ "$as_version" == "$version" ]]
|
||||
then
|
||||
echo "$TAG Version '$version' already installed, skipping rebuild" >&2
|
||||
mkdir -p ../../build/binutils/
|
||||
touch ../../build/binutils/.fini
|
||||
mkdir -p ../../_build/binutils/
|
||||
touch ../../_build/binutils/.fini
|
||||
exit 0
|
||||
fi
|
||||
[[ -d ../../build/binutils/build ]] && rm -rf ../../build/binutils/build
|
||||
[[ -f ../../build/binutils/.fini ]] && rm -f ../../build/binutils/.fini
|
||||
[[ -d ../../_build/binutils/build ]] && rm -rf ../../_build/binutils/build
|
||||
[[ -f ../../_build/binutils/.fini ]] && rm -f ../../_build/binutils/.fini
|
||||
fi
|
||||
|
||||
#---
|
||||
|
@ -146,47 +143,27 @@ fi
|
|||
# Download 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"
|
||||
else
|
||||
echo \
|
||||
"$TAG error: no curl or wget; install one or download "
|
||||
'archive yourself' >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
utils_archive_download \
|
||||
"https://ftp.gnu.org/gnu/binutils/binutils-$version.tar.xz" \
|
||||
../../_build/binutils \
|
||||
"$cached"
|
||||
|
||||
#---
|
||||
# Extract archive (OpenBDS-compliant version)
|
||||
# Patch sources
|
||||
#---
|
||||
|
||||
echo "$TAG Extracting $archive..."
|
||||
|
||||
mkdir -p ../../build/binutils
|
||||
cd ../../build/binutils/ || exit 1
|
||||
|
||||
unxz -c < "$archive" | tar -xf -
|
||||
cd ../../_build/binutils || exit 1
|
||||
|
||||
# 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 ./archive/intl/plural.c
|
||||
|
||||
# Apply binutils patchs for Vhex
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r "$_src/../../patches/binutils/$version"/* ./binutils-"$version"/
|
||||
cp -r "$_src/../../patches/binutils/$version"/* ./archive/
|
||||
|
||||
# Create build folder
|
||||
|
||||
|
@ -200,7 +177,7 @@ mkdir build && cd build || exit 1
|
|||
echo "$TAG Configuring binutils..."
|
||||
|
||||
utils_callcmd \
|
||||
"../binutils-$version/configure" \
|
||||
../archive/configure \
|
||||
--prefix="$prefix_sysroot" \
|
||||
--target='sh-elf-vhex' \
|
||||
--program-prefix='sh-elf-vhex-' \
|
||||
|
@ -208,13 +185,3 @@ utils_callcmd \
|
|||
--enable-lto \
|
||||
--enable-shared \
|
||||
--disable-nls
|
||||
|
||||
#---
|
||||
# Cache management
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Removing $archive..."
|
||||
rm -f "$archive"
|
||||
fi
|
||||
|
|
|
@ -99,13 +99,13 @@ if [[ "$valid" != 'y' ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
[[ -d "$prefix_clone" ]] && rm -rf "$prefix_clone"
|
||||
[[ "$verbose" == 'true' ]] && export VERBOSE=1
|
||||
|
||||
#---
|
||||
# Perform install operation
|
||||
#---
|
||||
|
||||
[[ -d "$prefix_clone" ]] && rm -rf "$prefix_clone"
|
||||
utils_callcmd \
|
||||
git \
|
||||
clone \
|
||||
|
|
|
@ -37,23 +37,23 @@ _src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|||
cd "$_src" || exit 1
|
||||
source ../_utils.sh
|
||||
|
||||
if ! test -d ../../build/gcc || ! test -f ../../build/gcc/sysroot_info.txt
|
||||
if ! test -d ../../_build/gcc || ! test -f ../../_build/gcc/sysroot_info.txt
|
||||
then
|
||||
echo 'error: Are you sure to have built GCC ? it seems that' >&2
|
||||
echo ' the build directory is missing...' >&2
|
||||
exit 1
|
||||
fi
|
||||
prefix_sysroot=$(cat ../../build/gcc/sysroot_info.txt)
|
||||
prefix_sysroot=$(cat ../../_build/gcc/sysroot_info.txt)
|
||||
|
||||
|
||||
if [[ -f ../../build/gcc/.fini ]]
|
||||
if [[ -f ../../_build/gcc/.fini ]]
|
||||
then
|
||||
echo "$TAG already build, skipping rebuild"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
cd ../../build/gcc/build || exit 1
|
||||
cd ../../_build/gcc/build || exit 1
|
||||
|
||||
#---
|
||||
# Build GCC stage-1
|
||||
|
@ -64,7 +64,7 @@ echo "$TAG Configuring GCC (stage 1)..."
|
|||
# Configure GCC stage-1 (minimal build as possible for library)
|
||||
|
||||
utils_callcmd \
|
||||
../gcc/configure \
|
||||
../archive/configure \
|
||||
--prefix="$prefix_sysroot" \
|
||||
--target='sh-elf-vhex' \
|
||||
--program-prefix="sh-elf-vhex-" \
|
||||
|
|
|
@ -21,15 +21,15 @@ EOF
|
|||
# Parse arguments
|
||||
#---
|
||||
|
||||
cache=false
|
||||
cached='true'
|
||||
prefix_sysroot=
|
||||
version=
|
||||
verbose=
|
||||
for arg
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose | -v) verbose=true;;
|
||||
--cache) cache=true;;
|
||||
--verbose | -v) verbose='true';;
|
||||
--no-cache) cached='true';;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--version=*) version=${arg#*=};;
|
||||
*)
|
||||
|
@ -54,9 +54,6 @@ fi
|
|||
|
||||
[[ "$verbose" == 'true' ]] && export VERBOSE=1
|
||||
|
||||
url="https://ftp.gnu.org/gnu/gcc/gcc-$version/gcc-$version.tar.xz"
|
||||
archive="/tmp/sh-elf-vhex/$(basename "$url")"
|
||||
|
||||
echo "$TAG Target gcc version -> $version"
|
||||
echo "$TAG Sysroot found -> $prefix_sysroot"
|
||||
|
||||
|
@ -72,84 +69,46 @@ then
|
|||
if [[ "$gcc_version" == "$version" ]]
|
||||
then
|
||||
echo "$TAG Version $version already installed, skipping rebuild"
|
||||
mkdir -p ../../build/gcc/
|
||||
touch ../../build/gcc/.fini
|
||||
mkdir -p ../../_build/gcc/
|
||||
touch ../../_build/gcc/.fini
|
||||
exit 0
|
||||
fi
|
||||
[[ -d ../../build/gcc/build ]] && rm -rf ../../build/gcc/build
|
||||
[[ -f ../../build/gcc/.fini ]] && rm -f ../../build/gcc/.fini
|
||||
[[ -d ../../_build/gcc/build ]] && rm -rf ../../_build/gcc/build
|
||||
[[ -f ../../_build/gcc/.fini ]] && rm -f ../../_build/gcc/.fini
|
||||
fi
|
||||
|
||||
#---
|
||||
# Download 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"
|
||||
else
|
||||
echo \
|
||||
"$TAG error: no curl or wget; install one or download archive " \
|
||||
' yourself' >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
utils_archive_download \
|
||||
"https://ftp.gnu.org/gnu/gcc/gcc-$version/gcc-$version.tar.xz" \
|
||||
../../_build/gcc \
|
||||
"$cached"
|
||||
|
||||
#---
|
||||
# Extract archive (openBSD-compliant version)
|
||||
# Patch sources
|
||||
#---
|
||||
|
||||
echo "$TAG Extracting $archive..."
|
||||
|
||||
mkdir -p ../../build/gcc && cd ../../build/gcc/ || exit 1
|
||||
|
||||
unxz -c < "$archive" | tar -xf -
|
||||
|
||||
#---
|
||||
# Apply GCC patchs for Vhex
|
||||
#---
|
||||
cd ../../_build/gcc || exit 1
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r "../../patches/gcc/$version"/* "./gcc-$version"/
|
||||
cp -r "../../patches/gcc/$version"/* ./archive/
|
||||
|
||||
# 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
|
||||
|
||||
# also store the sysroot prefix to avoid different CLI between binutils and
|
||||
# gcc
|
||||
# Store the sysroot prefix to avoid different CLI between binutils and gcc
|
||||
|
||||
echo "$prefix_sysroot" > ./sysroot_info.txt
|
||||
|
||||
# Create build folder
|
||||
|
||||
[[ -d "./build" ]] && rm -rf build
|
||||
mkdir ./build
|
||||
|
||||
#---
|
||||
# Install dependencies
|
||||
#---
|
||||
|
||||
echo "$TAG install dependencies..."
|
||||
|
||||
cd gcc || exit 1
|
||||
cd ./archive || exit 1
|
||||
utils_callcmd ./contrib/download_prerequisites
|
||||
cd .. || exit 1
|
||||
|
||||
mkdir -p build
|
||||
|
||||
#---
|
||||
# Cache management
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Removing $archive..."
|
||||
rm -f "$archive"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue