File:  [gforth] / gforth / Attic / configure
Revision 1.4: download - view: text, annotated - select for diffs
Thu Nov 17 16:48:26 1994 UTC (29 years, 5 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
* bug fix in configure

#!/bin/sh
# Configuration script for GNU FORTH
#   Copyright (C) 1994 Free Software Foundation, Inc.

#This file is part of GNU CC.

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

#GNU FORTH 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 General Public License for more details.

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

# This file is a derivate of configure for GNU CC

#
# Shell script to create proper links to machine-dependent files in
# preparation for compiling gcc.
#
# Options: --srcdir=DIR		specifies directory where sources are.
# 	   --host=HOST		specifies host configuration.
#	   --target=TARGET	specifies target configuration.
#	   --build=TARGET	specifies configuration of machine you are
#				using to compile GCC.
#	   --prefix=DIR		specifies directory to install in.
#	   --exec-prefix=DIR	specifies directory to install executables in.
#	   --direct-threade  specifies direct threading
#
# If configure succeeds, it leaves its status in config.status.
# If configure fails after disturbing the status quo, 
# 	config.status is removed.
#

progname=$0

# Default --srcdir to the directory where the script is found, 
# if a directory was specified.
# The second sed call is to convert `.//configure' to `./configure'.
srcdir=`echo $0 | sed 's|//|/|' | sed 's|/[^/]*$||'`
if [ x$srcdir = x$0 ]
then
srcdir=
fi

host=
threading=

# Default prefix to /usr/local.
prefix=/usr/local

# local_prefix specifies where to find the directory /usr/local/include
# We don't use $(prefix) for this
# because we always want GCC to search /usr/local/include
# even if GCC is installed somewhere other than /usr/local.
# Think THREE TIMES before specifying any other value for this!
# DO NOT make this use $prefix!
local_prefix=/usr/local
# Default is to let the Makefile set exec_prefix from $(prefix)
exec_prefix='$(prefix)'
#

remove=rm
hard_link=ln
symbolic_link='ln -s'
copy=cp

# Record all the arguments, to write them in config.status.
arguments=$*

#for Test
#remove="echo rm"
#hard_link="echo ln"
#symbolic_link="echo ln -s"

target=
host=
build=
name1=
name2=
debugging=-g

for arg in $*;
do
  case $next_arg in
  --srcdir)
    srcdir=$arg
    next_arg=
    ;;
  --host)
    host=$arg
    next_arg=
    ;;
  --target)
    target=$arg
    next_arg=
    ;;
  --build)
    build=$arg
    next_arg=
    ;;
  --prefix)
    prefix=$arg
    next_arg=
    ;;
  --exec-prefix)
    exec_prefix=$arg
    next_arg=
    ;;
  --direct-threaded)
    threading=-DDIRECT_THREADED
    next_arg=
    ;;
  *)
    case $arg in
      -*)
	if [ x$name1 != x ]
	then
		echo "Positional arguments must be last." 1>&2
		exit 1
	fi
	;;
    esac

    case $arg in
     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
	next_arg=--srcdir
	;;
     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
	srcdir=`echo $arg | sed 's/-*s[a-z]*=//'`
	;;
     -host | --host | --hos | --ho)
	next_arg=--host
	;;
     -host=* | --host=* | --hos=* | --ho=*)
	host=`echo $arg | sed 's/-*h[a-z]*=//'`
	;; 
     -target | --target | --targe | --targ | --tar | --ta | --t)
	next_arg=--target
	;;
     -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
	target=`echo $arg | sed 's/-*t[a-z]*=//'`
	;; 
     -build | --build | --buil | --bui | --bu | --b)
	next_arg=--build
	;;
     -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*)
	build=`echo $arg | sed 's/-*b[a-z]*=//'`
	;; 
     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
	next_arg=--prefix
	;;
     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
	prefix=`echo $arg | sed 's/-*p[a-z]*=//'`
	;;
     -exec-prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre \
	| --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
	next_arg=--exec-prefix
	;;
     -exec-prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* \
	| --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* \
	| --exe=* | --ex=* | --e=*)
	exec_prefix=`echo $arg | sed 's/-*e[-a-z]*=//'`
   ;;
     -direct-threaded | --direct-threade | --direct-thread | --direct-threa \
   | --direct-thre | --direct-thr | --direct-th | --direct-t | --direct- \
   | --direct | --direc | --dire | --dir | --di | --d)
    threading=-DDIRECT_THREADED
   ;;
     -without-debug | --without-debu | --without-deb | --without-de \
   | --without-d)
    debugging=
   ;;
     -with-* | --with-*) ;; #ignored
     -without-* | --without-*) ;; #ignored
     -enable-* | --enable-*) ;; #ignored
     -x | --x) ;; # ignored
     --he*) ;; # ignored for now (--help)
     --vers*) ;; # ignored for now (--version)
     --verb*) ;; # ignored for now (--verbose)
     --program-*) ;; #ignored (--program-prefix, --program-suffix)
     --c*) ;; #ignored (--cache-file)
     --q*) ;; #ignored (--quiet)
     --si*) ;; #ignored (--silent)
     -*)
	echo "Invalid option \`$arg'" 1>&2
	exit 1
	;;
     *)
# Allow configure HOST TARGET.  If just one name is given, it is used
# as both unless a host was previously given, in which case it is
# just the target.
	if [ x$name1 != x ]
	then
		if [ x$name2 != x ]
		then
			echo "More than two configuration names." 1>&2
			exit 1
		fi
		name2=$arg
	elif [ x$host != x ]
	then
		name1=$host
		name2=$arg
		host=
	else
		name1=$arg
	fi
	;;
    esac
  esac
done

if [ x$name1 != x ]
then
	if [ x$name2 = x ]
	then
		name2=$name1
	fi

	if [ x$host != x ]
	then
		echo "Duplicate specification of host." 1>&2
		exit 1
	fi

	if [ x$target != x ]
	then
		echo "Duplicate specification of target." 1>&2
		exit 1
	fi

	host=$name1
	build=$name1
	target=$name2
fi

# Find the source files, if location was not specified.
if [ x$srcdir = x ]
then
	srcdirdefaulted=1
	srcdir=.
	if [ ! -r tree.c ]
	then
		srcdir=..
	fi
fi

if [ ! -r ${srcdir}/engine.c ]
then
	if [ x$srcdirdefaulted = x ]
	then
	  echo "$progname: Can't find compiler sources in \`${srcdir}'" 1>&2
	else
	  echo "$progname: Can't find compiler sources in \`.' or \`..'" 1>&2
	fi
	exit 1
fi

if [ -r ${srcdir}/config.status ] && [ x$srcdir != x. ]
then
	echo "$progname: \`configure' has been run in \`${srcdir}'" 1>&2
	exit 1
fi

# Complain if an arg is missing
if [ x$build = x ]
then
	# If host was specified, always use it for build also to avoid
	# confusion.  If someone wants a cross compiler where build != host,
	# then they must specify build explicitly.  Since this case is
	# extremely rare, it does not matter that it is slightly inconvenient.
	if [ x$host != x ]
	then
		build=$host
	
	# This way of testing the result of a command substitution is
	# defined by Posix.2 (section 3.9.1) as well as traditional shells.
	elif build=`${srcdir}/config.guess`
	then
		echo "This appears to be a ${build} system." 1>&2

	elif [ x$target != x ]
	then
		echo 'Config.guess failed to determine the host type.  Defaulting to target.'
		build=$target
	else
		echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
		echo "\
Usage: `basename $progname` [--host=HOST] [--build=BUILD]
       [--prefix=DIR] [--exec-pref=DIR] TARGET" 1>&2
	echo "Where HOST, TARGET and BUILD are three-part configuration names " 1>&2
		if [ -r config.status ]
		then
			tail +2 config.status 1>&2
		fi
		exit 1
	fi
fi

# If $host was not specified, use $build.
if [ x$host = x ]
then
	host=$build
fi

# If $target was not specified, use $host.
if [ x$target = x ]
then
	target=$host
fi

# Validate the specs, and canonicalize them.
canon_build=`/bin/sh $srcdir/config.sub $build` || exit 1
canon_host=`/bin/sh $srcdir/config.sub $host` || exit 1
canon_target=`/bin/sh $srcdir/config.sub $target` || exit 1

# Decode the host machine, then the target machine.
# For the host machine, we save the xm_file variable as host_xm_file;
# then we decode the target machine and forget everything else
# that came from the host machine.

cpu=
bigendian=
extra_lib=
extra_obs=

case $target in
	# Support site-specific machine types.
	hppa*)
		cpu=hppa.h
		bigendian=1
		if [ x$threading = x ]
		then
			extra_obs="getopt1.o getopt.o"
		else
			extra_obs="getopt1.o getopt.o cache.o"
		fi
		flags="-fforce-mem -fforce-addr -fomit-frame-pointer -fno-defer-pop -fcaller-saves"
		defines="-DUSE_TOS -DUSE_FTOS -D_POSIX_VERSION -DUSE_GETOPT $threading"
		;;
	sparc*)
		cpu=sparc.h
		bigendian=1
		extra_obs="getopt1.o getopt.o"
		flags="-fforce-mem -fforce-addr -fomit-frame-pointer -fno-defer-pop -fcaller-saves"
		defines="-DUSE_TOS -DUSE_FTOS -D_POSIX_VERSION -DUSE_GETOPT $threading"
		;;
	i[345]86*)
		cpu=386.h
		bigendian=0
		extra_obs="getopt1.o getopt.o"
		flags="-fforce-mem -fforce-addr -fomit-frame-pointer -fno-defer-pop -fcaller-saves"
		defines="-D_POSIX_VERSION -DUSE_GETOPT $threading"
		;;
	mips-dec-ultrix*)
		cpu=decstation.h
		bigendian=0
		extra_obs="getopt1.o getopt.o"
		flags="-fforce-mem -fforce-addr -fomit-frame-pointer -fno-defer-pop -fcaller-saves"
		defines="-DUSE_TOS -DUSE_FTOS -D_POSIX_VERSION -DUSE_GETOPT $threading"
		;;
	m68k*)
		cpu=apollo68k.h
		bigendian=1
		extra_obs="getopt1.o getopt.o"
		flags="-fforce-mem -fforce-addr -fomit-frame-pointer -fno-defer-pop -fcaller-saves"
		defines="-DUSE_TOS -DUSE_FTOS -D_POSIX_VERSION -DUSE_GETOPT $threading"
		;;
	*)
		;;
esac

if [ x$cpu = x ]
then
	echo "Unknown Machine $machine"
	exit 1
fi

rm -f machine.h
rm -f gforth.fi
ln -s $cpu machine.h
if [ x$bigendian = x1 ]
then
	ln -s kernl32b.fi gforth.fi
else
	ln -s kernl32l.fi gforth.fi
fi

if [ x$bigendian = x1 ]
then
  sed -e "s|^XCFLAGS[	 ]*=*\(.*\)$|XCFLAGS	= \1 $flags|" \
      -e "s|^XDEFINES[	 ]*=*\(.*\)$|XDEFINES	= \1 $defines|" \
      -e "s|^OBJECTS[	 ]*=*\(.*\)$|OBJECTS	= \1 $extra_obs|" \
      -e "s|^CFLAGS[	 ]*=*\(.*\)$|CFLAGS	= $debugging\1|" \
      -e "s|^LDFLAGS[	 ]*=*\(.*\)$|LDFLAGS	= $debugging\1|" \
      -e "s|kernl32l.fi kernl32b.fi|kernl32b.fi kernl32l.fi|" \
      Makefile.in > Makefile
else
  sed -e "s|^XCFLAGS[	 ]*=*\(.*\)$|XCFLAGS	= \1 $flags|" \
      -e "s|^XDEFINES[	 ]*=*\(.*\)$|XDEFINES	= \1 $defines|" \
      -e "s|^OBJECTS[	 ]*=*\(.*\)$|OBJECTS	= \1 $extra_obs|" \
      -e "s|^CFLAGS[	 ]*=*\(.*\)$|CFLAGS	= $debugging\1|" \
      -e "s|^LDFLAGS[	 ]*=*\(.*\)$|LDFLAGS	= $debugging\1|" \
      Makefile.in > Makefile
fi


exit 0


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>