#!/bin/sh
#
# $Id: mklns,v 1.3 1993/11/24 01:13:49 root Exp $
#
FORCE=${1:-dont}

#
# determines gcc version and specs directory
#

gcc -v 2> /tmp/$$
GCCV=`fgrep version /tmp/$$ | awk '{print $3}'`
SPECS_FILE=`fgrep Reading /tmp/$$ | awk '{print $4}'`
SPECS_DIR1=`dirname $SPECS_FILE`
SPECS_DIR2=`dirname $SPECS_DIR1`
GCC_LIB_DIR=`dirname $SPECS_DIR2`
ARCH=`basename $SPECS_DIR2`

SPECS_DIR=${GCC_LIB_DIR}/`echo $ARCH | sed 's/linux/go32/'`
rm -f /tmp/$$

if [ ! -d $SPECS_DIR/$GCCV -o $FORCE = "-f" ]; then
  if [ ! -d $SPECS_DIR ]; then
    mkdir $SPECS_DIR
  fi
  if [ ! -d $SPECS_DIR/$GCCV ]; then
    mkdir $SPECS_DIR/$GCCV
  fi
  cp -f /usr/local/go32/lib/*.o $SPECS_DIR/$GCCV
  cp -f /usr/local/go32/etc/specs $SPECS_DIR/$GCCV
  ln -fs /usr/local/go32/bin/ld $SPECS_DIR/$GCCV
  (cd $SPECS_DIR/$GCCV;
   for i in cc1 cc1obj cc1plus cpp; do
     ln -fs ../../$ARCH/$GCCV/$i $i
   done
  )

  sed -e 's/XX/'${GCCV}'/g' \
	-e 's/YY/$*/' \
	-e 's/ZZ/'${ARCH}'/' << _EOF_ > /usr/local/bin/go32gcc
#!/bin/sh
exec gcc -b ZZ -V XX YY
_EOF_


  sed -e 's/XX/'${GCCV}'/g' \
	-e 's/YY/$*/' \
	-e 's/ZZ/'${ARCH}'/' << _EOF_ > /usr/local/bin/go32g++
#!/bin/sh
echo "Sorry: C++ cross-compiling doesn't work yet"
exit 1
# exec g++ -b ZZ -V XX YY
_EOF_


fi

exit 0
