2021-11-14 12:14:41 +01:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
|
|
|
verbose=false
|
|
|
|
cache=false
|
|
|
|
prefix=
|
|
|
|
|
|
|
|
#
|
|
|
|
# Help screen
|
|
|
|
#
|
2021-11-16 17:43:29 +01:00
|
|
|
help() {
|
2021-11-14 12:14:41 +01:00
|
|
|
cat << OEF
|
2021-11-16 17:43:29 +01:00
|
|
|
Script for the installation step of binutils for the Vhex kernel.
|
2021-11-14 12:14:41 +01:00
|
|
|
|
|
|
|
Usage $0 [options...]
|
|
|
|
|
|
|
|
Configurations:
|
|
|
|
-h, --help Display this help
|
2021-11-16 17:43:29 +01:00
|
|
|
--cache Keep the build and the sources directory
|
2021-11-14 12:14:41 +01:00
|
|
|
--verbose Display extra information during the installation step
|
|
|
|
--prefix=<PREFIX> Installation prefix
|
|
|
|
OEF
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
2021-11-16 17:43:29 +01:00
|
|
|
# Parse arguments
|
2021-11-14 12:14:41 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
[[ $# -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
|
|
|
|
|
|
|
|
|
2021-11-16 17:43:29 +01:00
|
|
|
|
2021-11-14 12:14:41 +01:00
|
|
|
#
|
|
|
|
# Installation step
|
|
|
|
#
|
|
|
|
|
|
|
|
TAG='<sh-elf-vhex-binutils>'
|
|
|
|
PREFIX="$prefix"
|
|
|
|
|
2022-01-25 10:44:34 +01:00
|
|
|
# Check that all tools has been generated
|
2021-11-14 12:14:41 +01:00
|
|
|
|
2022-01-25 10:44:34 +01:00
|
|
|
existing_as="../../build/binutils/bin/sh-elf-vhex-as"
|
|
|
|
|
|
|
|
if [[ ! -f "$existing_as" ]]; then
|
|
|
|
echo "error: Are you sure to have built binutils ? it seems that" >&2
|
|
|
|
echo " the 'as' tool is missing..." >&2
|
2021-11-16 17:43:29 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-05-14 11:07:16 +02:00
|
|
|
cd ../../build/binutils/bin
|
2021-11-14 12:14:41 +01:00
|
|
|
|
|
|
|
# Symbolic link executables to $PREFIX/bin
|
|
|
|
|
|
|
|
echo "$TAG Symlinking binaries..."
|
2022-05-14 11:07:16 +02:00
|
|
|
mkdir -p $PREFIX
|
|
|
|
for x in *; do
|
2021-11-14 12:14:41 +01:00
|
|
|
ln -sf "$(pwd)/$x" "$PREFIX/$x"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Cleanup build files
|
|
|
|
|
|
|
|
if [[ "$cache" == 'false' ]]; then
|
|
|
|
echo "$TAG Cleaning up build files..."
|
|
|
|
rm -rf binutils-*/
|
|
|
|
rm -rf build/
|
|
|
|
fi
|