binutils: add 2.38 build script
Signed-off-by: PeroSar <perosar1111@gmail.com>
This commit is contained in:
parent
c53d948525
commit
d84c2df944
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
TARGET=aarch64-linux-android
|
||||
export PREFIX=/tmp/"$TARGET"-emerald
|
||||
|
||||
export CFLAGS="-O3"
|
||||
export CPPFLAGS="$CFLAGS"
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
export LDFLAGS="-s -w"
|
||||
|
||||
export CFLAGS_FOR_TARGET="$CFLAGS"
|
||||
export CPPFLAGS_FOR_TARGET="$CFLAGS"
|
||||
export CXXFLAGS_FOR_TARGET="$CFLAGS"
|
||||
export LDFLAGS_FOR_TARGET="$LDFLAGS"
|
||||
|
||||
download() {
|
||||
if [ $# != 3 ]; then
|
||||
echo "download(): Invalid arguments - expected \$URL \$DESTINATION \$CHECKSUM"
|
||||
return 1
|
||||
fi
|
||||
local URL="$1"
|
||||
local DESTINATION="$2"
|
||||
local CHECKSUM="$3"
|
||||
|
||||
if [ -f "$DESTINATION" ] && [ "$CHECKSUM" != "SKIP_CHECKSUM" ]; then
|
||||
# Keep existing file if checksum matches.
|
||||
local EXISTING_CHECKSUM
|
||||
EXISTING_CHECKSUM=$(sha256sum "$DESTINATION" | cut -f 1 -d ' ')
|
||||
if [ "$EXISTING_CHECKSUM" = "$CHECKSUM" ]; then return; fi
|
||||
fi
|
||||
|
||||
local TMPFILE
|
||||
TMPFILE=$(mktemp "${TMPDIR:-/tmp}/download.emerald-dl.XXXXXXXXX")
|
||||
echo "Downloading ${URL}"
|
||||
if curl --fail --retry 20 --retry-connrefused --retry-delay 30 --location --output "$TMPFILE" "$URL"; then
|
||||
local ACTUAL_CHECKSUM
|
||||
ACTUAL_CHECKSUM=$(sha256sum "$TMPFILE" | cut -f 1 -d ' ')
|
||||
if [ "$CHECKSUM" != "SKIP_CHECKSUM" ]; then
|
||||
if [ "$CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
|
||||
printf >&2 "Wrong checksum for %s:\nExpected: %s\nFound: %s\n" \
|
||||
"$URL" "$ACTUAL_CHECKSUM" "$CHECKSUM"
|
||||
return 1
|
||||
fi
|
||||
elif [ -z "$CHECKSUM" ]; then
|
||||
printf "WARNING: No checksum check for %s:\nExpected: %s\n" \
|
||||
"$URL" "$ACTUAL_CHECKSUM"
|
||||
fi
|
||||
mv "$TMPFILE" "$DESTINATION"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Failed to download $URL" >&2
|
||||
return 1
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
EMERALD_SCRIPT_DIR=$(dirname "$(realpath "$0")")
|
||||
|
||||
BINUTILS_VER=2.38
|
||||
BINUTILS_SHA256=e316477a914f567eccc34d5d29785b8b0f5a10208d36bbacedcc39048ecfe024
|
||||
|
||||
EMERALD_BUILD_DIR="$EMERALD_SCRIPT_DIR"/build
|
||||
EMERALD_DL_DIR="$EMERALD_SCRIPT_DIR"/dl
|
||||
source "$EMERALD_SCRIPT_DIR"/common.sh
|
||||
|
||||
# Make sure build/dl directory exists
|
||||
mkdir -vp "$EMERALD_BUILD_DIR" "$EMERALD_DL_DIR"
|
||||
|
||||
# Getting source
|
||||
download https://ftp.gnu.org/gnu/binutils/binutils-"$BINUTILS_VER".tar.xz "$EMERALD_DL_DIR"/binutils-"$BINUTILS_VER".tar.xz "$BINUTILS_SHA256"
|
||||
|
||||
if [ ! -d "$EMERALD_BUILD_DIR"/binutils-"$BINUTILS_VER" ]; then
|
||||
tar --directory="$EMERALD_BUILD_DIR" -xJf "$EMERALD_DL_DIR"/binutils-"$BINUTILS_VER".tar.xz
|
||||
fi
|
||||
|
||||
cd "$EMERALD_BUILD_DIR"/binutils-"$BINUTILS_VER"
|
||||
|
||||
# Its suggested to run configure from a seperate directory
|
||||
mkdir -vp build && cd "$_"
|
||||
|
||||
# Configuration
|
||||
../configure --target="$TARGET" --prefix="$PREFIX" \
|
||||
--disable-werror --enable-gold \
|
||||
--enable-plugins --disable-nls
|
||||
|
||||
# Building
|
||||
make -j4
|
||||
make install -j1
|
Loading…
Reference in New Issue