set -x
set -e


if [ -z "$ATHENA_SYS" ]
then echo no ATHENA_SYS
false
fi


if [ -z "$1" ]
then false
fi

            ffname=$1
if [ -z "$2" ]
then false
fi

            shortname=$2
if [ -z "$3" ]
then false
fi
            suffix=$3

            cd /mit/gcc-3.2/arch/$ATHENA_SYS/real/$ffname/bin
            for i in *
            do pushd ../../../bin/ > /dev/null
                  if [ -L $i -o -e $i ]
                  then echo already exists $i
                  ls -l $i
                  fi

                  if [ -L "$i$suffix" -o -e "$i$suffix" ]
                  then echo already exists with suffix $i$suffix
                  ls -l $i$suffix
                  fi

            popd > /dev/null
            done

            echo Kenta relink $ffname
            pwd -P
            for i in *
            do pushd ../../../bin/ > /dev/null
            #make sure what to link to
                  ls -ld ../sym/$shortname/bin/$i
                  if [ -L $i -o -e $i ]
                  then false
                  fi
                  ln -s ../sym/$shortname/bin/$i $i

                  ls -ld ../real/$ffname/bin/$i
                  if [ -L "$i$suffix" -o -e "$i$suffix" ]
                  then false
                  fi
                  ln -s ../real/$ffname/bin/$i $i$suffix

            popd > /dev/null
            done
