2021-11-14 12:14:41 +01:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
2021-11-14 12:14:41 +01:00
|
|
|
# Help screen
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
2023-12-01 18:30:01 +01:00
|
|
|
|
|
|
|
function help() {
|
2023-12-02 16:27:21 +01:00
|
|
|
cat << EOF
|
2023-12-17 17:14:44 +01:00
|
|
|
Script for the building step of binutils for the Vhex project.
|
2021-11-14 12:14:41 +01:00
|
|
|
|
|
|
|
Usage $0 [options...]
|
|
|
|
|
|
|
|
Configurations:
|
|
|
|
-h, --help Display this help
|
2023-12-02 16:27:21 +01:00
|
|
|
EOF
|
2021-11-14 12:14:41 +01:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
2021-11-16 17:43:29 +01:00
|
|
|
# Parse arguments
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
2021-11-14 12:14:41 +01:00
|
|
|
|
2023-12-01 18:30:01 +01:00
|
|
|
for arg;
|
|
|
|
do case "$arg" in
|
|
|
|
--help | -h) help;;
|
|
|
|
*)
|
2023-12-17 11:06:14 +01:00
|
|
|
echo "error: unrecognized argument '$arg', giving up." >&2
|
2023-12-01 18:30:01 +01:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
2021-11-14 12:14:41 +01:00
|
|
|
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
|
|
|
# Setup check
|
|
|
|
#---
|
|
|
|
|
2023-12-02 16:27:21 +01:00
|
|
|
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
2023-12-02 19:04:31 +01:00
|
|
|
cd "$_src" || exit 1
|
|
|
|
source ../_utils.sh
|
2021-11-14 12:14:41 +01:00
|
|
|
|
2022-01-25 10:44:34 +01:00
|
|
|
# Avoid rebuilds and error
|
|
|
|
|
2023-12-04 20:42:28 +01:00
|
|
|
if [[ -f ../../_build/binutils/.fini ]]
|
2023-12-01 18:30:01 +01:00
|
|
|
then
|
2023-12-17 11:06:14 +01:00
|
|
|
echo "$TAG already built, skipping rebuild"
|
2022-01-25 10:44:34 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
2021-11-14 12:14:41 +01:00
|
|
|
|
2023-12-04 20:42:28 +01:00
|
|
|
if [[ ! -d ../../_build/binutils/build ]]
|
2023-12-01 18:30:01 +01:00
|
|
|
then
|
2021-11-16 17:43:29 +01:00
|
|
|
echo "error: Are you sure to have configured binutils ? it seems that" >&2
|
|
|
|
echo " the build directory is missing..." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-01-25 10:44:34 +01:00
|
|
|
|
2023-12-04 20:42:28 +01:00
|
|
|
cd ../../_build/binutils/build || exit 1
|
2021-11-15 17:04:56 +01:00
|
|
|
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
2021-11-16 17:43:29 +01:00
|
|
|
# Build part
|
2023-01-08 16:59:05 +01:00
|
|
|
#---
|
2021-11-16 17:43:29 +01:00
|
|
|
|
2021-11-14 12:14:41 +01:00
|
|
|
echo "$TAG Compiling binutils (usually 5-10 minutes)..."
|
|
|
|
|
2023-12-04 18:33:11 +01:00
|
|
|
utils_makecmd
|
2021-11-15 17:04:56 +01:00
|
|
|
|
2023-01-08 16:59:05 +01:00
|
|
|
echo "$TAG Installing binutils to sysroot..."
|
2021-11-15 17:04:56 +01:00
|
|
|
|
2023-12-04 18:33:11 +01:00
|
|
|
utils_makecmd install-strip
|
2022-01-25 10:44:34 +01:00
|
|
|
|
2023-12-17 11:06:14 +01:00
|
|
|
# Indicate that the construction is finished
|
2022-01-25 10:44:34 +01:00
|
|
|
|
2023-12-22 12:41:43 +01:00
|
|
|
echo "$TAG Cleaning up..."
|
|
|
|
|
2023-12-22 11:40:26 +01:00
|
|
|
rm -rf ../build
|
|
|
|
rm -rf ../archive
|
2022-01-25 10:44:34 +01:00
|
|
|
touch ../.fini
|