5 kx #!/bin/bash
5 kx
5 kx CWD=`pwd`
5 kx
5 kx BUILDSYSTEM=${BUILDSYSTEM:-$CWD}
5 kx
5 kx CONFIG=${CONFIG:-targets-config.mk}
5 kx CONSTANTS=${CONSTANTS:-config.mk}
5 kx
5 kx if [ ! -r $CONFIG ] ; then
5 kx echo "$0: ERROR: There is no $CONFIG file for configuring target HW."
5 kx echo ""
5 kx exit 1
5 kx fi
5 kx
5 kx : ${DIALOG=$BUILDSYSTEM/sbin/dialog}
5 kx : ${DIALOGRC=$BUILDSYSTEM/etc/dialogrc}
5 kx
5 kx export DIALOGRC
5 kx
5 kx : ${DIALOG_OK=0}
5 kx : ${DIALOG_CANCEL=1}
5 kx : ${DIALOG_HELP=2}
5 kx : ${DIALOG_EXTRA=3}
5 kx : ${DIALOG_ITEM_HELP=4}
5 kx : ${DIALOG_ESC=255}
5 kx
5 kx : ${SIG_NONE=0}
5 kx : ${SIG_HUP=1}
5 kx : ${SIG_INT=2}
5 kx : ${SIG_QUIT=3}
5 kx : ${SIG_KILL=9}
5 kx : ${SIG_TERM=15}
5 kx
5 kx
5 kx umask 002
5 kx if [ ! -z "$TMPDIR" ] ; then mkdir -p $TMPDIR ; fi
5 kx TMP=$(mkdir -p /tmp/radix && mktemp -d -p /tmp/radix build-system.XXXXXXXX) || { echo "Cannot create '/tmp/...' directory" ; exit 92; }
5 kx trap "rm -rf $TMP" 0 $SIG_NONE $SIG_HUP $SIG_INT $SIG_QUIT $SIG_TERM
5 kx
5 kx
5 kx hwlist=`cat $CONFIG | grep "^BUILD_.*[ \t]*=.*" | sed "s,^BUILD_\(.*\)[ \t]*=.*,\1," | tr 'A-Z' 'a-z' | tr '\n' ' ' | sed 's/host//g' | tr -s ' ' | sed 's/^[ \t]//' | sed 's/[ \t]$//'`
5 kx
5 kx for hw in $hwlist ; do
5 kx hh=`echo $hw | tr 'a-z' 'A-Z'`
5 kx spec=`cat $CONSTANTS | grep "^${hh}_SPEC[ \t]*=.*" | sed "s,^${hh}_SPEC[ \t]*=[ \t]*\(.*\),\1," | sed "s,\\\\\,,g"`
5 kx enabled=`cat $CONFIG | grep "^BUILD_${hh}[ \t]*=.*" | sed "s,^BUILD_${hh}[ \t]*=[ \t]*\(.*\),\1,"`
5 kx if [ "$enabled" == "true" ] ; then
5 kx en="on"
5 kx else
5 kx en="off"
5 kx fi
5 kx echo "\"$hw\" \"$spec\" \"$en\"" >> $TMP/sel$$
5 kx done
5 kx
5 kx $DIALOG --colors \
5 kx --backtitle "\Z7Build System\Zn" \
5 kx --title " \Z1SELECTING TOOLCHAINS TO BUILD\Zn " \
5 kx --clear \
5 kx --checklist "\n\
5 kx \Zb\Z4Please confirm the toolchains you want to build\Zn\ZB.\n\n\
5 kx Use the UP/DOWN keys to scroll through the list, and the SPACE key\n\
5 kx to deselect any items you don't want to build.\n\n\
5 kx Press ENTER when you are done." \
5 kx 21 72 8 \
5 kx --file $TMP/sel$$ 2> $TMP/ret$$
5 kx
5 kx retval=$?
5 kx
5 kx case $retval in
5 kx $DIALOG_OK)
5 kx enabled="`cat $TMP/ret$$`"
5 kx for hw in $hwlist ; do
5 kx hh=`echo $hw | tr 'a-z' 'A-Z'`
5 kx sed -i "s,^\(BUILD_${hh}[ \t]*=[ \t]*\).*,\1false," $CONFIG
5 kx done
5 kx for hw in $enabled ; do
5 kx hh=`echo $hw | tr 'a-z' 'A-Z'`
5 kx sed -i "s,^\(BUILD_${hh}[ \t]*=[ \t]*\).*,\1true," $CONFIG
5 kx done
5 kx ;;
5 kx esac