osxcross/build_binutils.sh

78 lines
1.5 KiB
Bash
Raw Normal View History

2015-02-08 10:17:41 +01:00
#!/usr/bin/env bash
#
# Build and install the GNU binutils and the GNU Debugger (gdb) for
# target OS X.
#
# You may want to run this script if you want to build software using
# gcc. Please refer to the README.md for details.
#
2015-02-08 10:17:41 +01:00
pushd "${0%/*}" &>/dev/null
DESC=binutils
USESYSTEMCOMPILER=1
source tools/tools.sh
2015-07-20 21:13:36 +02:00
eval $(tools/osxcross_conf.sh)
2015-02-08 10:17:41 +01:00
# binutils version to build
2015-08-29 12:47:48 +02:00
if [ -z "$BINUTILS_VERSION" ]; then
2019-06-02 10:11:43 +02:00
BINUTILS_VERSION=2.32
2015-08-29 12:47:48 +02:00
fi
2015-02-08 10:17:41 +01:00
# gdb version to build
2015-08-29 12:47:48 +02:00
if [ -z "$GDB_VERSION" ]; then
2019-06-02 10:11:43 +02:00
GDB_VERSION=8.3
2015-08-29 12:47:48 +02:00
fi
2015-02-08 10:17:41 +01:00
# mirror
2019-10-09 11:34:47 +02:00
MIRROR="https://ftp.gnu.org/gnu"
2015-02-08 10:17:41 +01:00
pushd $BUILD_DIR &>/dev/null
2015-02-08 10:17:41 +01:00
function remove_locks()
{
rm -rf $BUILD_DIR/have_binutils*
2015-02-08 10:17:41 +01:00
}
function build_and_install()
{
if [ ! -f "have_$1_$2_${TARGET}" ]; then
pushd $TARBALL_DIR &>/dev/null
download "$MIRROR/$1/$1-$2.tar.gz"
2015-02-08 10:17:41 +01:00
popd &>/dev/null
echo "cleaning up ..."
rm -rf $1* 2>/dev/null
extract "$TARBALL_DIR/$1-$2.tar.gz" 1
2015-02-08 10:17:41 +01:00
pushd $1*$2* &>/dev/null
mkdir -p build
pushd build &>/dev/null
../configure \
--target=x86_64-apple-$TARGET \
--program-prefix=x86_64-apple-$TARGET- \
--prefix=$TARGET_DIR/binutils \
2015-02-08 10:17:41 +01:00
--disable-nls \
--disable-werror
$MAKE -j$JOBS
$MAKE install
popd &>/dev/null
popd &>/dev/null
touch "have_$1_$2_${TARGET}"
2015-02-08 10:17:41 +01:00
fi
}
source $BASE_DIR/tools/trap_exit.sh
build_and_install binutils $BINUTILS_VERSION
build_and_install gdb $GDB_VERSION
echo ""
echo "installed binutils and gdb to $TARGET_DIR/binutils"
2015-02-08 10:17:41 +01:00
echo ""