update scripts architecture

This commit is contained in:
Yann MAGNIN 2021-11-15 17:04:56 +01:00
parent 536139dc5f
commit 084d6119dd
11 changed files with 91 additions and 105 deletions

View File

@ -1,25 +1,25 @@
# giteapc: version=1
PREFIX ?= $(GITEAPC_PREFIX)
VERSION_BINUTILS = 2.37
VERSION_GCC = 11.2
VERSION_BINUTILS := 2.37
VERSION_GCC := 11.2
-include giteapc-config.make
configure:
@ ./configure.sh --binutils $(VERSION_BINUTILS) "$(PREFIX)"
@ ./configure.sh --gcc $(VERSION_GCC) "$(PREFIX)"
@ ./scripts/binutils/configure --version=$(VERSION_BINUTILS)
@ ./scripts/gcc/configure.sh --version=$(VERSION_GCC)
build:
@ ./build.sh --binutils
@ ./build.sh --gcc
@ ./scripts/binutils/build.sh
@ ./scripts/gcc/build.sh
install:
@ ./install.sh --binutils "$(PREFIX)"
@ ./install.sh --gcc "$(PREFIX)"
@ ./scripts/binutils/install.sh --prefix="$(PREFIX)"
@ ./scripts/gcc/install.sh --prefix="$(PREFIX)"
uninstall:
@ ./uninstall.sh --binutils "$(PREFIX)"
@ ./uninstall.sh --gcc "$(PREFIX)"
@ ./scripts/binutils/uninstall.sh --prefix="$(PREFIX)"
@ ./scripts/gcc/uninstall.sh --prefix="$(PREFIX)"
.PHONY: configure build install uninstall

View File

@ -47,17 +47,16 @@ TAG='<sh-elf-vhex-binutils>'
[[ ! -d ../../build/binutils/build ]] && exit 0
cd ../../build/binutils/build
# Number of processor cores
[[ $(uname) == "OpenBSD" ]] && cores=$(sysctl -n hw.ncpu) || cores=$(nproc)
# selecte make utility
[[ $(command -v gmake >/dev/null 2>&1) ]] && make_cmd=gmake || make_cmd=make
# import some utility
source ../../../scripts/utils.sh
# build part
echo "$TAG Compiling binutils (usually 5-10 minutes)..."
if [[ "$verbose" == 'false' ]]; then
source ../../../scripts/util.sh
run_quietly giteapc-build.log $make_cmd -j"$cores"
else
$make_cmd -j"$cores"
fi
$quiet $make_cmd -j"$cores"
echo "$TAG Installing to local folder..."
$quiet $make_cmd install-strip

View File

@ -2,7 +2,7 @@
verbose=false
no_cache=false
cache=false
version='?'
prefix=
@ -20,9 +20,8 @@ Usage $0 [options...]
Configurations:
-h, --help Display this help
--no-cache Do not keep the archive of binutils
--cache Keep the archive of binutils
--verbose Display extra information during the configuration step
--prefix=<PREFIX> Installation prefix
--version=<VERSION> Select the binutils version. If the '?' argument is
passed then all binutils version with Vhex patch
availables will be printed
@ -41,7 +40,7 @@ OEF
for arg; do case "$arg" in
--help | -h) help;;
--verbose) verbose=true;;
--no-cache) no_cache=true;;
--cache) cache=true;;
--prefix=*) prefix=${arg#*=};;
--version=*) version=${arg#*=};;
*)
@ -77,13 +76,12 @@ fi
TAG='<sh-elf-vhex-binutils>'
VERSION=$version
PREFIX="$prefix"
URL="https://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.xz"
ARCHIVE="../../cache/$(basename $URL)"
# Avoid rebuilds of the same version
existing_as="$PREFIX/bin/sh-elf-vhex-as"
existing_as="../../build/binutils/bin/sh-elf-vhex-as"
if [[ -f "$existing_as" ]]; then
existing_version=$($existing_as --version | head -n 1 | grep -Eo '[0-9.]+$')
@ -209,21 +207,16 @@ if command -v termux-setup-storage >/dev/null 2>&1; then
CXXFLAGS="-D__ANDROID_API__=$(getprop ro.build.version.sdk) -g -O2"
fi
# Real configuration step
if [[ "$verbose" == "true" ]]; then
../binutils-$VERSION/configure --prefix="$PREFIX" --target=sh-elf-vhex \
--with-multilib-list=m3,m4-nofpu --disable-nls --enable-lto
else
source ../../../scripts/util.sh
run_quietly giteapc-configure.log \
../binutils-$VERSION/configure --prefix="$PREFIX" --target=sh-elf-vhex \
--with-multilib-list=m3,m4-nofpu --disable-nls --enable-lto
fi
cd ..
# check quiet mode
source ../../../scripts/utils.sh
# Real configuration step
$quiet ../binutils-$VERSION/configure --prefix="$PREFIX" --target=sh-elf-vhex \
--with-multilib-list=m3,m4-nofpu --disable-nls --enable-lto
# cache management
if [[ "$no_cache" == 'true' ]]; then
if [[ "$cache" == 'false' ]]; then
echo "$TAG Removing $ARCHIVE..."
rm -f $ARCHIVE
fi

View File

@ -57,30 +57,7 @@ PREFIX="$prefix"
# Avoid rebuilds of the same version
[[ ! -d ../../build/binutils/build ]] && exit 0
cd ../../build/binutils/build
# add utilities
source ../../../scripts/util.sh
# check gmake or make (macos support)
if command -v gmake >/dev/null 2>&1; then
make_command=gmake
else
make_command=make
fi
# build part
echo "$TAG Installing to local folder..."
if [[ "$verbose" == 'true' ]]; then
$make_command install-strip
else
run_quietly giteapc-install.log $make_command install-strip
fi
cd ..
cd ../../build/binutils
# Symbolic link executables to $PREFIX/bin

View File

@ -46,6 +46,11 @@ esac; done
TAG='<sh-elf-vhex-binutils>'
PREFIX="$prefix"
# Avoid rebuilds of the same version
[[ ! -d ../../build/binutils ]] && exit 0
cd ../../build/binutils
# Remove symlinks
echo "$TAG Removing symlinks to binaries..."
for x in bin/*; do
@ -54,4 +59,4 @@ done
# Remove local files
echo "$TAG Removing installed files..."
rm -rf ../../build/binutils
rm -rf ../binutils

View File

@ -2,12 +2,8 @@
echo "Compil and install binutils"
cd binutils
./configure.sh --version=2.37 --prefix=/tmp \
&& ./build.sh \
&& ./install.sh --prefix=/tmp
./configure.sh --version=2.37 && ./build.sh && ./install.sh --prefix=/tmp
echo "Compil and install GCC"
cd ../gcc
./configure.sh --version=11.2.0 --prefix=/tmp \
&& ./build.sh
#&& ./install.sh --prefix=/home/yann/CASIO/vhex-compiler/sh-elf-vhex/scripts
./configure.sh --version=11.2.0 && ./build.sh && ./install.sh --prefix=/tmp

View File

@ -56,16 +56,7 @@ esac; done
TAG='<sh-elf-vhex-gcc>'
# import utility
source ../util.sh
# Number of processor cores
[[ $(uname) == "OpenBSD" ]] && cores=$(sysctl -n hw.ncpu) || cores=$(nproc)
# check macos make utility
[[ $(command -v gmake >/dev/null 2>&1) ]] && make_cmd=gmake || make_cmd=make
# check quiet build
[[ "$verbose" == "true" ]] && quiet='' || quiet='run_quietly giteapc-build.log'
source ../utils.sh
# OpenBSD apparently installs these in /usr/local
extra_args=

View File

@ -1,9 +1,8 @@
#! /usr/bin/env bash
verbose=false
no_cache=false
cache=false
version='?'
prefix=
#
@ -21,7 +20,6 @@ Configurations:
-h, --help Display this help
--no-cache Do not keep the archive of binutils
--verbose Display extra information during the configuration step
--prefix=<PREFIX> Installation prefix
--version=<VERSION> Select the GCC version. If the '?' argument is
passed then all binutils version with Vhex patch
availables will be printed
@ -40,8 +38,7 @@ OEF
for arg; do case "$arg" in
--help | -h) help;;
--verbose) verbose=true;;
--no-cache) no_cache=true;;
--prefix=*) prefix=${arg#*=};;
--cache) cache=true;;
--version=*) version=${arg#*=};;
*)
echo "error: unreconized argument '$arg', giving up." >&2
@ -74,20 +71,19 @@ fi
TAG='<sh-elf-vhex-gcc>'
VERSION="$version"
PREFIX="$prefix"
URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz"
ARCHIVE="../../cache/$(basename $URL)"
# Avoid rebuilds of the same version
existing_gcc="$PREFIX/bin/sh-elf-vhex-gcc"
existing_gcc="../../build/gcc/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
echo "$TAG Version $VERSION already installed, skipping rebuild"
if [[ -e build ]]; then
rm -rf build
if [[ -e ../../build/gcc/build ]]; then
rm -rf ../../build/gcc/build
fi
exit 0
fi
@ -132,15 +128,15 @@ mv ./gcc-$VERSION/ ./gcc
# Symlink as, ld, ar and ranlib, which gcc will not find by itself (we renamed
# them from sh3eb-elf-* to sh-elf-* with --program-prefix).
mkdir -p sh-elf-vhex/bin
ln -sf $PREFIX/bin/sh-elf-vhex-as sh-elf-vhex/bin/as
ln -sf $PREFIX/bin/sh-elf-vhex-ld sh-elf-vhex/bin/ld
ln -sf $PREFIX/bin/sh-elf-vhex-ar sh-elf-vhex/bin/ar
ln -sf $PREFIX/bin/sh-elf-vhex-ranlib sh-elf-vhex/bin/ranlib
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-as sh-elf-vhex/bin/as
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ld sh-elf-vhex/bin/ld
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ar sh-elf-vhex/bin/ar
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ranlib sh-elf-vhex/bin/ranlib
# patch OpenLibM building error (find for sh-elf-vhex-ar)
ln -sf $PREFIX/bin/sh-elf-vhex-ar sh-elf-vhex/bin/sh-elf-vhex-ar
# patch OpenLibM building error (which search for sh-elf-vhex-ar)
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ar sh-elf-vhex/bin/sh-elf-vhex-ar
if [[ "$no_cache" == 'true' ]]; then
if [[ "$cache" == 'false' ]]; then
echo "$TAG Removing $ARCHIVE..."
rm -f $ARCHIVE
fi

View File

@ -29,6 +29,8 @@ OEF
# Parse argument
#
[[ $# -eq 0 ]] && help
for arg; do case "$arg" in
--help | -h) help;;
--verbose) verbose=true;;
@ -46,6 +48,11 @@ esac; done
TAG='<sh-elf-vhex-gcc>'
PREFIX="$prefix"
# Avoid rebuilds of the same version
[[ ! -d ../../build/gcc ]] && exit 0
cd ../../build/gcc
# Remove symlinks
echo "$TAG Removing symlinks to binaries..."
for x in bin/*; do
@ -54,4 +61,5 @@ done
# Remove local files
echo "$TAG Removing installed files..."
rm -rf ../../build/gcc
rm -rf ../gcc
exit 0

View File

@ -1,9 +0,0 @@
run_quietly() {
out="$1"
shift 1
"$@" >$out 2>&1
if [[ "$?" != 0 ]]; then
echo "$TAG error: build failed, please check $(pwd)/$out o(x_x)o"
exit 1
fi
}

30
scripts/utils.sh Normal file
View File

@ -0,0 +1,30 @@
# select the appropriate quiet primitive
quiet='run_normaly'
[[ "$verbose" == "false" ]] && quiet='run_quietly giteapc-build.log'
# Number of processor cores
[[ $(uname) == "OpenBSD" ]] && cores=$(sysctl -n hw.ncpu) || cores=$(nproc)
# selecte make utility
[[ $(command -v gmake >/dev/null 2>&1) ]] && make_cmd=gmake || make_cmd=make
## functions privided
run_normaly() {
bash -c "$@"
if [[ "$?" != 0 ]]; then
echo "$TAG error: command failed, abord"
exit 1
fi
}
run_quietly() {
out="$1"
shift 1
"$@" >$out 2>&1
if [[ "$?" != 0 ]]; then
echo "$TAG error: command failed, please check $(pwd)/$out o(x_x)o"
exit 1
fi
}