#! /bin/sh

# Configuration script for the GNU C Library.

# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.

# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB.  If
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.

#
#	Configure the GNU C Library.
#

prog="`basename $0`"

if [ $# -ne 1 -a $# -ne 2 ]; then
  if [ $# -eq 0 -a "${ARCH-${machine}}" != "" ]; then
    set "${ARCH-${machine}}"
  else
    echo "Usage: $prog [-nfp] system [objdir]" >&2
    exit 1
  fi
fi

nfp=

case $1 in
-nfp | --nfp | --nf | --n)
  nfp=yes
  shift ;;
esac

case $1 in
vax)
  sysnames='unix/bsd/vax' ;;
tahoe)
  sysnames='unix/bsd/tahoe' ;;
sequent-i386 | seq386)
  sysnames='unix/bsd/seq386' ;;
i386-sysv | i386v)
  sysnames='unix/i386/sysv' ;;
i386-mach | i386-mach3 | i386_mach)
  sysnames='mach/i386' ;;
sun4-os3 | sun-4-os3)
  sysnames='unix/bsd/sun/sun4 unix/bsd/sun/sunos3' ;;
sun3-os3 | sun-3-os3)
  sysnames='unix/bsd/sun/sun3/os3' ;;
sun4 | sun-4 | sun4-os4 | sun-4-os4)
  sysnames='unix/bsd/sun/sun4 unix/bsd/sun/sunos4' ;;
sun3 | sun-3 | sun3-os4 | sun-3-os4)
  fpu=m68k/68881
  sysnames='unix/bsd/sun/sun3 unix/bsd/sun/sunos4' ;;
news | news800)
  fpu=m68k/68881
  sysnames='unix/bsd/news' ;;
hp300 | hp9k3bsd)
  fpu=m68k/68881
  sysnames='unix/bsd/hp9k3bsd' ;;
hp800 | hp9k8)
  sysnames='unix/bsd/hp9k8' ;;
*)
  echo ${prog}: System \`$1\' unrecognized. >&2
  exit 1 ;;
esac

if [ ! "$nfp" ]; then
  sysnames="$fpu $sysnames"
fi

if [ $# -eq 2 ]; then
  objdir=$2
else
  objdir=$1
fi

if [ ! -d $objdir ]; then
  if mkdir $objdir; then
    true;
  else
    echo "$prog: Couldn't make directory $objdir" >&2
    exit 1
  fi
fi

echo $sysnames > $objdir/Sysnames

cat - $objdir/Sysnames <<END
Configuring the GNU C Library for \`$1'.
Object files, etc. will go in the directory \`$objdir'.
Using system-dependent files from directories:
END

rm -f $objdir/sysdirs

ARCH=$objdir
export ARCH

echo "#define LIBC_MACHINE \"$1\"" > $objdir/config-name.h

echo "ARCH=$ARCH" > config.status

exit 0
