Added "generic" environment script tool

This commit is contained in:
Adam Greene 2017-05-05 12:20:39 -04:00
parent 620efd26d3
commit b6e692dbbe

90
activate-generic.env Normal file
View File

@ -0,0 +1,90 @@
# This software is released under the terms of GPLv2 by copyright@mzpqnxow.com
# Please see LICENSE or LICENSE.md for more information on GPLv2
# If you aren't using musl-cross-make toolchain or an OpenWrt pre-built toolchain
# then you can possibly use this. It has worked for me on, for example, NETGEAR
# provided toolchains.
#
# As the first argument, provide the path to the root of the toolchain
# As the second argument, provide part of a pattern to match the libc
#
# For argument two, you can usually be pretty vague, i.e. "libc" instead of "uclibc"
# because it's matching a pattern that usually only has one possible match anyway.
# Just make sure it's more specific than "lib" :>
#
# Example that works with HNDTOOLS from NETGEAR:
# $ source activate-generic.env /opt/brcm/mipsel-uclibc libc
#
CURDIR="$1"
TOOLCHAIN_TARGET="$(basename $(echo $CURDIR/*-*-${2}*))"
TOOLCHAIN_ROOT="$CURDIR"
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
export TOOLCHAIN_BIN