gdb-static-cross/activate-musl-toolchain.env

97 lines
3.0 KiB
Bash
Raw Normal View History

2017-05-03 19:37:28 -04:00
# This software is released under the terms of GPLv2 by copyright@mzpqnxow.com
# Please see LICENSE or LICENSE.md for more information on GPLv2
# This is not for you if you are not using a musl-cross-make toolchain
# This is a productivity script that should be sourced from a Bash shell
#
# It is meant to be used after making and installing a musl toolchain using
# the excellent musl-cross-make tool by Rich Felker:
#
# https://github.com/richfelker/musl-cross-make
#
# This file should be placed in /path/to/installed/toolchain/
# You should probably call it activate, but it doesn't matter
# All you need to do is source it (from anywhere) and it sets your env up for
# building software via build systems like configure or just via gcc/g++/as/ld
# commands. It helps with static linking by setting some static library paths
# also (See the XXX_STATIC variables)
#
# It makes assumptions and will try to set things up for you so you can
# conveniently build things with or without ./configure based build systems
#
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TOOLCHAIN_TARGET="$(basename $(echo $CURDIR/*-*-musl*))"
TOOLCHAIN_ROOT="$CURDIR"
2017-05-05 15:07:38 -04:00
# Commonly used/needed static libraries, put them in the
# environment for easy access
2017-05-03 19:37:28 -04:00
UTIL_STATIC=$(find $(realpath $CURDIR) -name libutil.a)
C_STATIC=$(find $(realpath $CURDIR) -name libc.a)
DL_STATIC=$(find $(realpath $CURDIR) -name libdl.a)
PTHREAD_STATIC=$(find $(realpath $CURDIR) -name libpthread.a)
STDCXX_STATIC=$(find $(realpath $CURDIR) -name libstdc++.a)
GCCEH_STATIC=$(find $(realpath $CURDIR) -name libgcc_eh.a)
TOOLCHAIN_BIN="$TOOLCHAIN_ROOT/bin"
echo "--- Build environment setup ---"
echo
echo "TOOLCHAIN_TARGET: $TOOLCHAIN_TARGET"
echo "TOOLCHAIN_BIN: $TOOLCHAIN_BIN"
echo
for TOOL in gcc \
addr2line \
ar \
as \
c++ \
cpp \
g++ \
ld \
nm \
objdump \
ranlib \
strip
do
echo " Symlinking $TOOL"
ln -sf "$TOOLCHAIN_BIN/$TOOLCHAIN_TARGET-$TOOL" "$TOOLCHAIN_BIN/$TOOL"
done
ln -sf "${TOOLCHAIN_BIN}/${TOOLCHAIN_TARGET}-gcc" "${TOOLCHAIN_BIN}/cc"
echo
export PATH="$TOOLCHAIN_BIN":"$PATH"
echo "TOOLCHAIN_TARGET: $TOOLCHAIN_TARGET"
echo "TOOLCHAIN_ROOT: $TOOLCHAIN_ROOT"
echo "TOOLCHAIN_BIN: $TOOLCHAIN_BIN"
echo
echo "GCC location: $(which gcc)"
echo "GAS location: $(which as)"
echo "GLD location: $(which ld)"
echo "G++ location: $(which g++)"
echo "CC location: $(which cc)"
echo
echo "UTIL_STATIC: $UTIL_STATIC"
echo "C_STATIC: $C_STATIC"
echo "DL_STATIC: $DL_STATIC"
echo "PTHREAD_STATIC: $PTHREAD_STATIC"
echo "STDCXX_STATIC: $STDCXX_STATIC"
echo "GCCEH_STATIC: $GCCEH_STATIC"
alias cross_configure="./configure \
--host=$TOOLCHAIN_TARGET \
--prefix=$TOOLCHAIN_ROOT"
echo
echo "Use cross_configure to invoke alias for:"
echo " $./configure --host=$TOOLCHAIN_TARGET --prefix=$TOOLCHAIN_ROOT"
echo
export UTIL_STATIC
export C_STATIC
export DL_STATIC
export PTHREAD_STATIC
export STDCXX_STATIC
export GCCEH_STATIC
export TOOLCHAIN_TARGET
export TOOLCHAIN_ROOT
2017-05-05 15:07:38 -04:00
export TOOLCHAIN_BIN