#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 19 (of 19)."
# Contents:  Configure
# Wrapped by cek@oyoy on Mon Oct 28 20:03:42 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Configure' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Configure'\"
else
echo shar: Extracting \"'Configure'\" \(49296 characters\)
sed "s/^X//" >'Configure' <<'END_OF_FILE'
X#! /bin/sh
X#
X# If these # comments don't work, trim them.  Don't worry about any
X# other shell scripts, Configure will trim # comments from them for you.
X#
X# (If you are trying to port this package to a machine without sh, I'd
X# suggest you cut out the prototypical config.h from the end of this
X# file and edit it to reflect your system.  Some packages may include
X# samples of config.h for certain machines, so you might look for one
X# of those.)
X#
X# Yes, you may rip this off to use in other distribution packages.
X# (Note: this Configure script was generated automatically.  Rather than
X# working with this copy of Configure, you may wish to get metaconfig.
X# Write to ram@educ.emse.fr (Raphael Manfredi) and I will send you
X# my version which slightly differs from the original written by
X# Larry Wall.)
X
X# $Id: Configure,v 4.0.1.1 1991/10/10 18:39:55 cek Exp cek $
X
X: save PATH defined by user
Xuser_path=$PATH
X
X: sanity checks
XPATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin'
XPATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
XPATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
XPATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd'
Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
X
Xif test ! -t 0; then
X    echo "Say 'sh Configure', not 'sh <Configure'"
X    exit 1
Xfi
X
X(alias) >/dev/null 2>&1 && \
X    echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
X    echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
X
Xif test ! -d ../UU; then
X    if test ! -d UU; then
X	mkdir UU
X    fi
X    cd UU
Xfi
X
Xcase "$1" in
X-d) shift; fastread='yes';;
Xesac
X
Xd_eunice=''
Xd_xenix=''
Xd_bsd=''
Xdefine=''
Xeunicefix=''
Xloclist=''
Xexpr=''
Xawk=''
Xsed=''
Xecho=''
Xcat=''
Xchgrp=''
Xchmod=''
Xchown=''
Xrm=''
Xmv=''
Xcp=''
Xtail=''
Xtr=''
Xmkdir=''
Xsort=''
Xuniq=''
Xgrep=''
Xtrylist=''
Xtest=''
Xinews=''
Xegrep=''
Xmore=''
Xpg=''
XMcc=''
Xvi=''
Xmail=''
Xbison=''
Xcpp=''
Xperl=''
XLog=''
XHeader=''
XId=''
Xbin=''
Xcontains=''
Xcppstdin=''
Xcppminus=''
Xd_bzero=''
Xd_cbrt=''
Xd_index=''
Xd_memset=''
Xd_popen=''
Xd_rusage=''
Xd_times=''
Xclocktype=''
Xi_string=''
Xstrings=''
Xi_sysresrc=''
Xi_systypes=''
Xi_time=''
Xi_systime=''
Xi_systimek=''
Xtimeincl=''
Xinhdr=''
Xinlibc=''
Xlibs=''
Xmodels=''
Xsplit=''
Xsmall=''
Xmedium=''
Xlarge=''
Xhuge=''
Xccflags=''
Xldflags=''
Xcc=''
Xcppflags=''
Xoptimize=''
Xn=''
Xc=''
Xorderlib=''
Xranlib=''
Xpackage=''
Xrandfunc=''
Xmrand=''
Xseedfunc=''
Xnrandbits=''
Xspitshell=''
Xshsharp=''
Xsharpbang=''
Xstartsh=''
Xsysman=''
Xvoidflags=''
Xdefvoidused=''
Xyacc=''
Xd_urt=''
Xurtinc=''
Xurtlib=''
Xi_stdlib=''
Xlibc=''
Xmkdep=''
XCONFIG=''
X: set package name
Xpackage=rayshade
X
Xecho " "
Xecho "Beginning of configuration questions for $package kit."
X: Eunice requires " " instead of "", can you believe it
Xecho " "
X
Xdefine='define'
Xundef='undef'
X: change the next line if compiling for Xenix/286 on Xenix/386
Xxlibpath='/usr/lib/386 /lib/386'
Xlibpth='/usr/lib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large'
Xlibpth=$libpth' /usr/lib/small /lib/small'
Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286'
Xrmlist='ark[1-9]isdone ark[1-9][0-9]isdone'
Xtrap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 15
X
X: We must find out about Eunice early
Xeunicefix=':'
Xif test -f /etc/unixtovms; then
X    eunicefix=/etc/unixtovms
Xfi
Xif test -f /etc/unixtovms.exe; then
X    eunicefix=/etc/unixtovms.exe
Xfi
X
Xif ls blurfl >/dev/null 2>&1; then
X	if awk '' blurfl >/dev/null 2>&1; then
X		check='cat'
X	else
X		check='awk ""'
X	fi
Xelse
X	check='ls'
Xfi
X
X: Now test for existence of everything in MANIFEST
Xif test -f ../MANIFEST; then
X	echo "First let's make sure your kit is complete.  Checking..."
X	: some grep do not return a proper exit status
X	grep '^---' ../MANIFEST > .grepmani 2>/dev/null
X	if test -s .grepmani; then
X(cd ..; eval $check `awk '!/^.*\/$/{if (b) print $1}
X/^---/{b=1}' MANIFEST` || kill $$) >/dev/null
X	else
X(cd ..; eval $check `awk '!/^.*\/$/{print $1}' MANIFEST` || kill $$) >/dev/null
X	fi
X	echo "Looks good..."
Xelse
X	echo "No MANIFEST found. Hope your kit is complete !"
Xfi
Xrm -f .grepmani
X
Xpth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/5bin"
Xpth=$pth" /usr/lbin /etc /usr/new /usr/new/bin /usr/nbin /usr/gnu/bin"
Xpth=$pth" /usr/plx /vol/local/bin /usr/lib /lib /usr/local/lib"
Xpth=$pth" /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin"
Xpth=$pth" /bsd4.3/usr/ucb /usr/bsd"
X: add PATH from user
Xpth=$pth" "`echo $user_path | sed -e 's/:/ /g'`
Xinclwanted=''
Xdefvoidused=15
Xlibswanted='m malloc c_s'
Xdefvoidused=11
X: some greps do not return status, grrr.
Xecho "grimblepritz" >grimble
Xif grep blurfldyick grimble >/dev/null 2>&1 ; then
X    contains=contains
Xelif grep grimblepritz grimble >/dev/null 2>&1 ; then
X    contains=grep
Xelse
X    contains=contains
Xfi
Xrm -f grimble
X: the following should work in any shell
Xcase "$contains" in
Xcontains*)
X    echo " "
X    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
X    cat >contains <<'EOSS'
Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
XEOSS
Xchmod +x contains
Xesac
X
X: see if sh knows # comments
Xecho " "
Xecho "Checking your sh to see if it knows about # comments..."
Xif sh -c '#' >/dev/null 2>&1 ; then
X	echo "Your sh handles # comments correctly."
X	shsharp=true
X	spitshell=cat
X	echo " "
X	echo "Okay, let's see if #! works on this system..."
X	echo "#!/bin/echo hi" > try
X	$eunicefix try
X	chmod +x try
X	try > today
X	if $contains hi today >/dev/null 2>&1; then
X		echo "It does."
X		sharpbang='#!'
X	else
X		echo "#! /bin/echo hi" > try
X		$eunicefix try
X		chmod +x try
X		try > today
X		if test -s today; then
X			echo "It does."
X			sharpbang='#! '
X		else
X			echo "#!/bin/cat" > try
X			$eunicefix try
X			chmod +x try
X			try >today
X			if test -s today; then
X				echo "It does, without processing parameters."
X				sharpbang='#!'
X			else
X				echo "It doesn't."
X				sharpbang=': use '
X			fi
X		fi
X	fi
Xelse
X	echo "Your sh doesn't grok # comments--I will strip them later on."
X	shsharp=false
X	echo "exec grep -v '^[ 	]*#'" >spitshell
X	chmod +x spitshell
X	$eunicefix spitshell
X	spitshell=`pwd`/spitshell
X	echo "I presume that if # doesn't work, #! won't work either!"
X	sharpbang=': use '
Xfi
Xrm -f try today
X
X: figure out how to guarantee sh startup
Xecho " "
Xecho "Checking out how to guarantee sh startup..."
Xstartsh=$sharpbang'/bin/sh'
Xecho "Let's see if '$startsh' works..."
Xcat >try <<EOSS
X$startsh
Xset abc
Xtest "$?abc" != 1
XEOSS
X
Xchmod +x try
X$eunicefix try
Xif try; then
X    echo "Yup, it does."
Xelse
X    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
Xfi
Xrm -f try
X
X: first determine how to suppress newline on echo command
Xecho " "
Xecho "Checking echo to see how to suppress newlines..."
X(echo "hi there\c" ; echo " ") >.echotmp
Xif $contains c .echotmp >/dev/null 2>&1 ; then
X    echo "...using -n."
X    n='-n'
X    c=''
Xelse
X    cat <<'EOM'
X...using \c
XEOM
X    n=''
X    c='\c'
Xfi
Xecho $n "The star should be here-->$c"
Xecho '*'
Xrm -f .echotmp
X
X: now set up to do reads with possible shell escape and default assignment
Xcat <<EOSC >myread
Xcase "\$fastread" in
Xyes) ans=''; echo " " ;;
X*) ans='!';;
Xesac
Xwhile expr "X\$ans" : "X!" >/dev/null; do
X    read ans
X    case "\$ans" in
X    !)
X	sh
X	echo " "
X	echo $n "\$rp $c"
X	;;
X    !*)
X	set \`expr "X\$ans" : "X!\(.*\)\$"\`
X	sh -c "\$*"
X	echo " "
X	echo $n "\$rp $c"
X	;;
X    esac
Xdone
Xrp='Your answer:'
Xcase "\$ans" in
X'') ans="\$dflt";;
Xesac
XEOSC
X
X: general instructions
Xcat <<EOH
X 
XThis installation shell script will examine your system and ask you questions
Xto determine how the $package package should be installed.  If you get stuck
Xon a question, you may use a ! shell escape to start a subshell or execute
Xa command.  Many of the questions will have default answers in square
Xbrackets--typing carriage return will give you the default.
X
XOn some of the questions which ask for file or directory names you are
Xallowed to use the ~name construct to specify the login directory belonging
Xto "name", even if you don't have a shell which knows about that.  Questions
Xwhere this is allowed will be marked "(~name ok)".
X
XEOH
Xrp="[Type carriage return to continue]"
Xecho $n "$rp $c"
X. myread
Xcat <<EOH
X
XMuch effort has been expended to ensure that this shell script will run on
Xany Unix system. If despite that it blows up on you, your best bet is to edit
XConfigure and run it again. Also, let me (rayshade-request@cs.princeton.edu)
Xknow how I blew it. If you can't run Configure for some reason, you'll have
Xto generate a config.sh file by hand.
X
XThis installation script affects things in two ways:
X1) it may do direct variable substitutions on some of the files included
X   in this kit.
X2) it builds a config.h file for inclusion in C programs.  You may edit
X   any of these files as the need arises after running this script.
X
XIf you make a mistake on a question, there is no easy way to back up to it
Xcurrently.  The easiest thing to do is to edit config.sh and rerun all the
XSH files.  Configure will offer to let you do this before it runs the SH files.
X
XEOH
Xrp="[Type carriage return to continue]"
Xecho $n "$rp $c"
X. myread
X
X: get old answers, if there is a config file out there
Xif test -f ../config.sh; then
X    echo " "
X    dflt=y
X    rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
X    echo $n "$rp $c"
X    . myread
X    case "$ans" in
X    n*|N*) echo "OK, I'll ignore it.";;
X    *)  echo "Fetching default answers from your old config.sh file..."
X	tmp="$n"
X	ans="$c"
X        . ../config.sh
X	n="$tmp"
X	c="$ans"
X	;;
X    esac
Xfi
X
X: find out where common programs are
Xecho " "
Xecho "Locating common programs..."
Xcat <<EOSC >loc
X$startsh
Xcase \$# in
X0) exit 1;;
Xesac
Xthing=\$1
Xshift
Xdflt=\$1
Xshift
Xfor dir in \$*; do
X    case "\$thing" in
X    .)
X	if test -d \$dir/\$thing; then
X	    echo \$dir
X	    exit 0
X	fi
X	;;
X    *)
X	if test -f \$dir/\$thing; then
X	    echo \$dir/\$thing
X	    exit 0
X	elif test -f \$dir/\$thing.exe; then
X	    : on Eunice apparently
X	    echo \$dir/\$thing
X	    exit 0
X	fi
X	;;
X    esac
Xdone
Xecho \$dflt
Xexit 1
XEOSC
Xchmod +x loc
X$eunicefix loc
Xloclist="
Xcat
Xecho
Xexpr
Xgrep
Xrm
Xsed
Xsort
Xuniq
X"
Xtrylist="
Xbison
Xcpp
Xtest
X"
Xfor file in $loclist; do
X    xxx=`loc $file $file $pth`
X    eval $file=$xxx
X    eval _$file=$xxx
X    case "$xxx" in
X    /*)
X	echo $file is in $xxx.
X	;;
X    *)
X	echo "I don't know where $file is.  I hope it's in everyone's PATH."
X	;;
X    esac
Xdone
Xecho " "
Xecho "Don't worry if any of the following aren't found..."
Xans=offhand
Xfor file in $trylist; do
X    xxx=`loc $file $file $pth`
X    eval $file=$xxx
X    eval _$file=$xxx
X    case "$xxx" in
X    /*)
X	echo $file is in $xxx.
X	;;
X    *)
X	echo "I don't see $file out there, $ans."
X	ans=either
X	;;
X    esac
Xdone
Xcase "$egrep" in
Xegrep)
X    echo "Substituting grep for egrep."
X    egrep=$grep
X    ;;
Xesac
Xcase "$test" in
Xtest)
X    echo "Hopefully test is built into your sh."
X    ;;
X/bin/test)
X    if sh -c "PATH= test true" >/dev/null 2>&1; then
X	echo "Using the test built into your sh."
X	test=test
X    fi
X    ;;
X*)
X    test=test
X    ;;
Xesac
Xcase "$echo" in
Xecho)
X    echo "Hopefully echo is built into your sh."
X    ;;
X/bin/echo)
X    echo " "
X    echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
X    $echo $n "hi there$c" >foo1
X    echo $n "hi there$c" >foo2
X    if cmp foo1 foo2 >/dev/null 2>&1; then
X	echo "They are compatible.  In fact, they may be identical."
X    else
X	case "$n" in
X	'-n') n='' c='\c' ans='\c' ;;
X	*) n='-n' c='' ans='-n' ;;
X	esac
X	cat <<FOO
XThey are not compatible!  You are probably running ksh on a non-USG system.
XI'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
Xhave echo built in and we may have to run some Bourne shell scripts.  That
Xmeans I'll have to use $ans to suppress newlines now.  Life is ridiculous.
X
XFOO
X	rp="The star should be here-->"
X	$echo $n "$rp$c"
X	$echo "*"
X    fi
X    $rm -f foo1 foo2
X    ;;
X*)
X    : cross your fingers
X    echo=echo
X    ;;
Xesac
Xrmlist="$rmlist loc"
X
X: Looking for optional libraries
Xecho " "
Xecho "Checking for optional libraries..."
Xdflt=''
Xcase "$libswanted" in
X'') libswanted='c_s';;
Xesac
Xfor thislib in $libswanted; do
X    case "$thislib" in
X    dbm) thatlib=ndbm;;
X    *_s) thatlib=NONE;;
X    *) thatlib="${thislib}_s";;
X    *) thatlib=NONE;;
X    esac
X    xxx=`loc lib$thislib.a X /usr/lib /usr/local/lib /lib`
X    if $test -f $xxx; then
X	echo "Found -l$thislib."
X	case "$dflt" in
X	*-l$thislib*|*-l$thatlib*);;
X	*) dflt="$dflt -l$thislib";;
X	esac
X    else
X	xxx=`loc lib$thislib.a X $libpth`
X	if $test -f $xxx; then
X	    echo "Found $xxx."
X	    case "$dflt" in
X	    *$xxx*);;
X	    *) dflt="$dflt $xxx";;
X	    esac
X	else
X	    xxx=`loc Slib$thislib.a X $xlibpth`
X	    if $test -f $xxx; then
X		echo "Found -l$thislib."
X		case "$dflt" in
X		*-l$thislib*|*-l$thatlib*);;
X		*) dflt="$dflt -l$thislib";;
X		esac
X	    else
X		echo "No -l$thislib."
X	    fi
X	fi
X    fi
Xdone
Xset X $dflt
Xshift
Xdflt="$*"
Xcase "$libs" in
X'') dflt="$dflt";;
X*) dflt="$libs";;
Xesac
Xcase "$dflt" in
X'') dflt='none';;
Xesac
X
X$cat <<EOM
X 
XSome versions of Unix support shared libraries, which make
Xexecutables smaller but make load time slightly longer.
X
XOn some systems, mostly newer Unix System V's, the shared library
Xis included by putting the option "-lc_s" as the last thing on the
Xcc command line when linking.  Other systems use shared libraries
Xby default.  There may be other libraries needed to compile $package
Xon your machine as well.  If your system needs the "-lc_s" option,
Xinclude it here.  Include any other special libraries here as well.
XSay "none" for none.
XEOM
X
Xecho " "
Xrp="Any additional libraries? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xcase "$ans" in
Xnone) ans='';
Xesac
Xlibs="$ans"
X
X: get list of predefined functions in a handy place
Xecho " "
Xcase "$libc" in
X'') libc=unknown;;
Xesac
Xcase "$libpth" in
X'') libpth='/lib /usr/lib /usr/local/lib';;
Xesac
Xcase "$libs" in
X*-lc_s*) libc=`loc libc_s.a $libc $libpth`
Xesac
Xlibnames='';
Xcase "$libs" in
X'') ;;
X*)  for thislib in $libs; do
X	case "$thislib" in
X	-l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
X	    try=`loc lib$thislib.a blurfl/dyick $libpth`
X	    if test ! -f $try; then
X		try=`loc lib$thislib blurfl/dyick $libpth`
X		if test ! -f $try; then
X		    try=`loc $thislib blurfl/dyick $libpth`
X		    if test ! -f $try; then
X			try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
X			if test ! -f $try; then
X			    try=''
X			fi
X		    fi
X		fi
X	    fi
X	    libnames="$libnames $try"
X	    ;;
X	*) libnames="$libnames $thislib" ;;
X	esac
X    done
X    ;;
Xesac
Xset /usr/ccs/lib/libc.so
Xtest -f $1 || set /usr/lib/libc.so
Xtest -f $1 || set /usr/lib/libc.so.[0-9]*
Xeval set \$$#
Xif test -f "$1"; then
X    echo "Your shared C library is in $1."
X    libc="$1"
Xelif test -f /lib/libc && test -f /lib/clib; then
X    echo "Your C library is in both /lib/clib and /lib/libc."
X    libc='/lib/clib /lib/libc'
X	if test -f /lib/syslib; then
X		echo "(Your math library is in /lib/syslib.)"
X		libc="$libc /lib/syslib"
X	fi
Xelif test -f $libc; then
X    echo "Your C library is in $libc, like you said before."
Xelif test -f /lib/libc.a; then
X    echo "Your C library is in /lib/libc.a.  You're normal."
X    libc=/lib/libc.a
Xelse
X    ans=`loc libc.a blurfl/dyick $libpth`
X    if test ! -f "$ans"; then
X	ans=`loc Slibc.a blurfl/dyick $xlibpth`
X    fi
X    if test ! -f "$ans"; then
X	ans=`loc Mlibc.a blurfl/dyick $xlibpth`
X    fi
X    if test ! -f "$ans"; then
X	ans=`loc Llibc.a blurfl/dyick $xlibpth`
X    fi
X    if test ! -f "$ans"; then
X	ans=`loc libc blurfl/dyick $libpth`
X    fi
X    if test ! -f "$ans"; then
X	ans=`loc clib blurfl/dyick $libpth`
X    fi
X    if test ! -f "$ans"; then
X         ans=`loc libsys_s.a blurfl/dyick $libpth`
X    fi
X    if test -f "$ans"; then
X	echo "Your C library is in $ans, of all places."
X	libc=$ans
X    else
X	cat <<EOM
X 
XI can't seem to find your C library.  I've looked in the following places:
X
X	$libpth
X
XNone of these seems to contain your C library.  What is the full name
XEOM
X	dflt=None
X	$echo $n "of your C library? $c"
X	rp='C library full name?'
X	. myread
X	libc="$ans"
X    fi
Xfi
Xecho " "
Xset `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
X$echo $n "Extracting names from $* for later perusal...$c"
Xnm $* 2>/dev/null >libc.tmp
X$grep printf libc.tmp > libc.ptf
Xcom="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'"
Xeval "$com <libc.ptf >libc.list"
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	:
Xelse
X	com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'"
X	eval "$com <libc.ptf >libc.list"
Xfi
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	:
Xelse
X	com="$sed -n -e '/|Undef/d' -e '/|Proc/s/ .*//p'"
X	eval "$com <libc.ptf >libc.list"
Xfi
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	:
Xelse
X	com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'"
X	eval "$com <libc.ptf >libc.list"
Xfi
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	:
Xelse
X	com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'"
X	eval "$com <libc.ptf >libc.list"
Xfi
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	:
Xelse
X	com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'"
X	eval "$com <libc.ptf >libc.list"
Xfi
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	:
Xelse
X	com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'"
X	eval "$com <libc.ptf >libc.list"
Xfi
Xif $contains '^printf$' libc.list >/dev/null 2>&1; then
X	eval "$com <libc.tmp >libc.list"
X	echo "done"
Xelse
X	echo " "
X	echo "nm didn't seem to work right."
X	echo "Trying ar instead..."
X	if ar t $libc > libc.tmp; then
X		for thisname in $libnames; do
X			ar t $thisname >>libc.tmp
X		done
X		$sed -e 's/\.o$//' < libc.tmp > libc.list
X		echo "Ok."
X	else
X		echo "ar didn't seem to work right."
X		echo "Maybe this is a Cray...trying bld instead..."
X		if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
X			for thisname in $libnames; do
X				bld t $libnames | \
X				$sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
X				ar t $thisname >>libc.tmp
X			done
X			echo "Ok."
X		else
X			echo "That didn't work either.  Giving up."
X			exit 1
X		fi
X	fi
Xfi
X
X: define an in-header-list? function
Xinhdr='echo " ";
Xxxx=`loc $1 x /usr/include /usr/local/include $inclwanted`;
Xif $test -f $xxx;
Xthen echo "<$1> found."; eval "$2=$define";
Xelse echo "No <$1> found."; eval "$2=$undef"; fi'
X
X: see if sys/types.h has to be included
Xset sys/types.h i_systypes
Xeval $inhdr
X
X: see if times exists
Xecho " "
Xif $contains '^times$' libc.list >/dev/null 2>&1; then
X    echo 'times() found.'
X    d_times="$define"
X	case "$clocktype" in
X	'')
X		if $contains 'clock_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
X			dflt='clock_t';
X		elif $contains 'clock_t;' /usr/include/sys/times.h >/dev/null 2>&1; then
X			dflt='clock_t';
X		else
X			dflt='long';
X		fi
X		;;
X	*)  dflt="$clocktype"
X		;;
X	esac
X	cont=true
X	echo " "
X	rp="What type is returned by times() on this sytem? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	clocktype="$ans"
Xelse
X    echo 'times() not found, hope that will do.'
X    d_times="$undef"
X	clocktype='int'
Xfi
X
X: set up shell script to do ~ expansion
Xcat >filexp <<EOSS
X$startsh
X: expand filename
Xcase "\$1" in
X ~/*|~)
X    echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
X    ;;
X ~*)
X    if $test -f /bin/csh; then
X	/bin/csh -f -c "glob \$1"
X	echo ""
X    else
X	name=\`$expr x\$1 : '..\([^/]*\)'\`
X	dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
X	if $test ! -d "\$dir"; then
X	    me=\`basename \$0\`
X	    echo "\$me: can't locate home directory for: \$name" >&2
X	    exit 1
X	fi
X	case "\$1" in
X	*/*)
X	    echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
X	    ;;
X	*)
X	    echo \$dir
X	    ;;
X	esac
X    fi
X    ;;
X*)
X    echo \$1
X    ;;
Xesac
XEOSS
Xchmod +x filexp
X$eunicefix filexp
X
X: determine where manual pages are on this system
Xecho " "
Xcase "$sysman" in
X	'') sysman=`loc . /usr/man/man1 /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/share/man/man1 /usr/catman/u_man/man1 /usr/man/l_man/man1 /usr/local/man/u_man/man1 /usr/local/man/l_man/man1 /usr/man/man.L`
X    ;;
Xesac
Xif test -d "$sysman"; then
X	echo "System manual is in $sysman."
Xfi
X
X: make some quick guesses about what we are up against
Xecho " "
X$echo $n "Hmm...  $c"
Xcat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
Xif test `echo abc | tr a-z A-Z` = Abc ; then
X	if $contains SIGTSTP foo >/dev/null 2>&1 ; then
X	echo "Looks kind of like an USG system with BSD features, but we'll see..."
X		echo exit 0 >bsd
X		echo exit 0 >usg
X		echo exit 1 >v7
X	else
X    echo "Looks kind of like an USG system, but we'll see..."
X		echo exit 1 >bsd
X		echo exit 0 >usg
X		echo exit 1 >v7
X	fi
X	d_bsd="$undef"
Xelif $contains SIGTSTP foo >/dev/null 2>&1 ; then
X    echo "Looks kind of like a BSD system, but we'll see..."
X	d_bsd="$define"
X    echo exit 0 >bsd
X    echo exit 1 >usg
X    echo exit 1 >v7
Xelse
X    echo "Looks kind of like a Version 7 system, but we'll see..."
X	d_bsd="$undef"
X    echo exit 1 >bsd
X    echo exit 1 >usg
X    echo exit 0 >v7
Xfi
Xcase "$eunicefix" in
X*unixtovms*)
X    cat <<'EOI'
XThere is, however, a strange, musty smell in the air that reminds me of
Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
XEOI
X    echo "exit 0" >eunice
X    eunicefix=unixtovms
X    d_eunice="$define"
X: it so happens the Eunice I know will not run shell scripts in Unix format
X	;;
X*)
X    echo " "
X    echo "Congratulations.  You aren't running Eunice."
X    eunicefix=':'
X    d_eunice="$undef"
X    echo "exit 1" >eunice
X	;;
Xesac
Xif test -f /xenix; then
X    echo "Actually, this looks more like a XENIX system..."
X    echo "exit 0" >xenix
X	d_xenix="$define"
Xelse
X    echo " "
X    echo "It's not Xenix..."
X    echo "exit 1" >xenix
X	d_xenix="$undef"
Xfi
Xchmod +x xenix
X$eunicefix xenix
Xif test -f /venix; then
X    echo "Actually, this looks more like a VENIX system..."
X    echo "exit 0" >venix
Xelse
X    echo " "
X    if xenix; then
X	: null
X    else
X	echo "Nor is it Venix..."
X    fi
X    echo "exit 1" >venix
Xfi
Xchmod +x bsd usg v7 eunice venix
X$eunicefix bsd usg v7 eunice venix
Xrm -f foo
Xrmlist="$rmlist bsd usg v7 eunice venix xenix"
X
X: see what memory models we can support
Xcase "$models" in
X'')
X    cat >pdp11.c <<'EOP'
Xmain() {
X#ifdef pdp11
X    exit(0);
X#else
X    exit(1);
X#endif
X}
XEOP
X	cc -o pdp11 pdp11.c >/dev/null 2>&1
X	if pdp11 2>/dev/null; then
X		dflt='unsplit split'
X	else
X		ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
X		case "$ans" in
X		X) dflt='none';;
X		*) if $test -d /lib/small || $test -d /usr/lib/small; then
X				dflt='small'
X			else
X				dflt=''
X			fi
X			if $test -d /lib/medium || $test -d /usr/lib/medium; then
X				dflt="$dflt medium"
X			fi
X			if $test -d /lib/large || $test -d /usr/lib/large; then
X				dflt="$dflt large"
X			fi
X			if $test -d /lib/huge || $test -d /usr/lib/huge; then
X				dflt="$dflt huge"
X			fi
X		esac
X	fi;;
X*) dflt="$models";;
Xesac
X$cat <<EOM
X 
XSome systems have different model sizes.  On most systems they are called
Xsmall, medium, large, and huge.  On the PDP11 they are called unsplit and
Xsplit.  If your system doesn't support different memory models, say "none".
XIf you wish to force everything to one memory model, say "none" here and
Xput the appropriate flags later when it asks you for other cc and ld flags.
XVenix systems may wish to put "none" and let the compiler figure things out.
X(In the following question multiple model names should be space separated.)
X
XEOM
Xrp="Which models are supported? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xmodels="$ans"
X
Xcase "$models" in
Xnone)
X	small=''
X	medium=''
X	large=''
X	huge=''
X	unsplit=''
X	split=''
X	;;
X*split)
X	case "$split" in
X	'') if $contains '\-i' $mansrc/ld.1 >/dev/null 2>&1 || \
X			 $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1; then
X			dflt='-i'
X		else
X			dflt='none'
X		fi;;
X	*) dflt="$split";;
X	esac
X	rp="What flag indicates separate I and D space? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	case "$ans" in
X	none) ans='';;
X	esac
X	split="$ans"
X	unsplit='';;
X*large*|*small*|*medium*|*huge*)
X	case "$model" in
X	*large*)
X		case "$large" in
X		'') dflt='-Ml';;
X		*) dflt="$large";;
X		esac
X	rp="What flag indicates large model? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	case "$ans" in
X	none) ans='';
X	esac
X	large="$ans";;
X	*) large='';;
X	esac
X	case "$model" in
X	*huge*) case "$huge" in
X		'') dflt='-Mh';;
X		*) dflt="$huge";;
X		esac
X		rp="What flag indicates huge model? [$dflt]"
X		$echo $n "$rp $c"
X		. myread
X		case "$ans" in
X		none) ans='';
X		esac
X		huge="$ans";;
X    *) huge="$large";;
X	esac
X	case "$model" in
X	*medium*) case "$medium" in
X		'') dflt='-Mm';;
X		*) dflt="$medium";;
X		esac
X		rp="What flag indicates medium model? [$dflt]"
X		$echo $n "$rp $c"
X		. myread
X		case "$ans" in
X		none) ans='';
X		esac
X		medium="$ans";;
X    *) medium="$large";;
X	esac
X	case "$model" in
X	*small*) case "$small" in
X		'') dflt='none';;
X		*) dflt="$small";;
X		esac
X		rp="What flag indicates small model? [$dflt]"
X		$echo $n "$rp $c"
X		. myread
X		case "$ans" in
X		none) ans='';
X		esac
X		small="$ans";;
X	*) small='';;
X	esac
X	;;
X*)
X	echo "Unrecognized memory models--you may have to edit Makefile.SH"
X	;;
Xesac
X
X: see if we need a special compiler
Xecho " "
Xif usg; then
X    case "$cc" in
X    '')
X	case "$Mcc" in
X	/*) dflt='Mcc'
X	    ;;
X	*)
X	    case "$large" in
X	    -M*)
X		dflt='cc'
X		;;
X	    *)
X		if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
X		    dflt='cc -M'
X		else
X		    dflt='cc'
X		fi
X		;;
X	    esac
X	    ;;
X	esac
X	;;
X    *)  dflt="$cc";;
X    esac
X    $cat <<'EOM'
X 
XOn some systems the default C compiler will not resolve multiple global
Xreferences that happen to have the same name.  On some such systems the
X"Mcc" command may be used to force these to be resolved.  On other systems
Xa "cc -M" command is required.  (Note that the -M flag on other systems
Xindicates a memory model to use!)  If you have the Gnu C compiler, you
Xmight wish to use that instead.  What command will force resolution on
XEOM
X	$echo $n "this system? [$dflt] $c"
X	rp="Command to resolve multiple refs? [$dflt]"
X	. myread
X	cc="$ans"
Xelse
X	case "$cc" in
X	'') dflt=cc;;
X	*) dflt="$cc";;
X	esac
X	rp="Use which C compiler? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	cc="$ans"
Xfi
Xcase "$cc" in
Xgcc*) cpp=`loc gcc-cpp $cpp $pth`;;
Xesac
X
X: determine optimize, if desired, or use for debug flag also
Xcase "$optimize" in
X' ') dflt="none";;
X'') dflt="-O";;
X*) dflt="$optimize";;
Xesac
Xcat <<EOH
X
XSome C compilers have problems with their optimizers, by default, $package
Xcompiles with the -O flag to use the optimizer.  Alternately, you might
Xwant to use the symbolic debugger, which uses the -g flag (on traditional
XUnix systems).  Either flag can be specified here.  To use neither flag,
Xspecify the word "none".
X  
XEOH
Xrp="What optimizer/debugger flag should be used? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xoptimize="$ans"
Xcase "$optimize" in
X'none') optimize=" ";;
Xesac
X
Xcase "$ccflags" in
X'') case "$cc" in
X	*gcc*) dflt='-fpcc-struct-return';;
X	*) dflt='';;
X	esac
X	;;
X*) dflt="$ccflags";;
Xesac
Xfor thisincl in $inclwanted; do
X	if $test -d $thisincl; then
X		case "$dflt" in
X		*$thisincl*);;
X		*) dflt="$dflt -I$thisincl";;
X		esac
X	fi
Xdone
Xcase "$optimize" in
X-g*)
X	case "$dflt" in
X	*DEBUG*);;
X	*) dflt="$dflt -DDEBUG";;
X	esac
X	;;
Xesac
Xif $contains 'LANGUAGE_C' /usr/include/signal.h >/dev/null 2>&1; then
X	case "$dflt" in
X	*LANGUAGE_C*);;
X	*) dflt="$dflt -DLANGUAGE_C";;
X	esac
Xfi
Xcase "$dflt" in
X'') dflt=none;;
Xesac
Xcat <<EOH
X
XYour C compiler may want other flags.  For this question you should
Xinclude -I/whatever and -DWHATEVER flags and any other flags used by
Xthe C compiler, but you should NOT include libraries or ld flags like
X-lwhatever.  To use no flags, specify the word "none".
X  
XEOH
Xrp="Any additional cc flags? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xcase "$ans" in
Xnone) ans='';
Xesac
Xccflags="$ans"
X
X: the following weeds options from ccflags that are of no interest to cpp
Xcppflags="$ccflags"
Xcase "$cc" in
X*gcc*) cppflags="$cppflags -D__GNUC__";;
Xesac
Xcase "$cppflags" in
X'');;
X*)  set X $cppflags
X	cppflags=''
X	for flag do
X		case $flag in
X		-D*|-I*) cppflags="$cppflags $flag";;
X		esac
X	done
X	case "$cppflags" in
X	*-*)  echo "(C preprocessor flags: $cppflags)";;
X	esac
X	;;
Xesac
X
Xcase "$ldflags" in
X'') if venix; then
X		dflt='-i -z'
X	else
X		dflt='none'
X	fi
X	;;
X*) dflt="$ldflags";;
Xesac
Xecho " "
Xrp="Any additional ld flags (NOT including libraries)? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xcase "$ans" in
Xnone) ans='';
Xesac
Xldflags="$ans"
Xrmlist="$rmlist pdp11"
X
X: see how we invoke the C preprocessor
Xecho " "
Xecho "Now, how can we feed standard input to your C preprocessor..."
Xcat <<'EOT' >testcpp.c
X#define ABC abc
X#define XYZ xyz
XABC.XYZ
XEOT
Xecho 'Maybe "'"$cc"' -E" will work...'
X$cc -E <testcpp.c >testcpp.out 2>&1
Xif $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X    echo "Yup, it does."
X    cppstdin="$cc -E"
X    cppminus='';
Xelse
X    echo 'Nope, maybe "'$cpp'" will work...'
X    $cpp <testcpp.c >testcpp.out 2>&1
X    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "Yup, it does."
X	cppstdin="$cpp"
X	cppminus='';
X    else
X	echo 'No such luck...maybe "'$cpp' -" will work...'
X	$cpp - <testcpp.c >testcpp.out 2>&1
X	if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	    echo "It works!"
X	    cppstdin="$cpp"
X	    cppminus='-';
X	else
X	    echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
X	    $cc -E - <testcpp.c >testcpp.out 2>&1
X	    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X		echo "Hooray, it works!  I was beginning to wonder."
X		cppstdin="$cc -E"
X		cppminus='-';
X	    else
X		echo 'Nope...maybe "'"$cc"' -P" will work...'
X		$cc -P <testcpp.c >testcpp.out 2>&1
X		if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X		    echo "Yup, that does."
X		    cppstdin="$cc -P"
X		    cppminus='';
X		else
X		    echo 'Nope...maybe "'"$cc"' -P -" will work...'
X		    $cc -P - <testcpp.c >testcpp.out 2>&1
X		    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X			echo "Yup, that does."
X			cppstdin="$cc -P"
X			cppminus='-';
X		    else
X			echo 'Hmm...perhaps you already told me...'
X			case "$cppstdin" in
X			'') ;;
X			*) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
X			esac
X			if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X			    echo "Hooray, you did!  I was beginning to wonder."
X			else
X			    echo 'Uh-uh.  Time to get fancy...'
X			    cd ..
X			    echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
X			    echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
X			    chmod 755 cppstdin
X			    cppstdin=`pwd`/cppstdin
X			    cppminus='';
X			    cd UU
X			    $cppstdin <testcpp.c >testcpp.out 2>&1
X			    if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X				echo "Eureka!."
X			    else
X				dflt=blurfl
X				$echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
X				rp='Name a C preprocessor:'
X				. myread
X				cppstdin="$ans"
X				$cppstdin <testcpp.c >testcpp.out 2>&1
X				if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X				    echo "OK, that will do."
X				else
X				    echo "Sorry, I can't get that to work.  Go find one."
X				    exit 1
X				fi
X			    fi
X			fi
X		    fi
X		fi
X	    fi
X	fi
X    fi
Xfi
Xrm -f testcpp.c testcpp.out
X
X: define an is-in-libc? function and set rmlist
Xinlibc='echo " ";
Xif $contains "^$1\$" libc.list >/dev/null 2>&1;
Xthen echo "$1() found."; eval "$2=$define";
Xelse echo "$1() not found."; eval "$2=$undef"; fi'
X
Xrmlist="$rmlist libc.tmp libc.list"
X
X: see if memset exists
Xset memset d_memset
Xeval $inlibc
X
X: see if bzero exists
Xecho " "
Xif $contains '^bzero$' libc.list >/dev/null 2>&1; then
X    echo 'bzero() found.'
X    d_bzero="$undef"
Xelif $test $d_memset = "$define" ; then
X	echo "bzero() not found -- Will use memset() instead."
X	d_bzero="$define"
Xelse
X	echo "bzero() not found."
X	d_bzero="$define"
Xfi
X
X: see if cbrt exists
Xset cbrt d_cbrt
Xeval $inlibc
X
X: see which of string.h or strings.h is needed
Xecho " "
Xstrings=`loc string.h "" /usr/include $inclwanted`
Xi_string="$undef"
Xif $test -r "$strings"; then
X	echo "Using <string.h> instead of <strings.h>."
X	if bsd; then
X		echo "(Actually, this looks more like it were an USG system)"
X	fi
X	i_string="$define"
Xelse
X	strings=`loc strings.h "" /usr/include $inclwanted`
X	if $test -r "$strings"; then
X		echo "Using <strings.h> instead of <string.h>."
X		if usg; then
X			echo "(Actually, this looks more like it were a BSD system)"
X		fi
X	else
X		echo "No string header found--You'll surely have problems."
X	fi
Xfi
X
X: index or strchr
Xecho " "
Xcase "$d_index" in
Xn) dflt=n;;
X*) dflt=y;;
Xesac
Xif $contains '^index$' libc.list >/dev/null 2>&1 ; then
X	if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
X		if $contains strchr "$strings" >/dev/null 2>&1 ; then
X			if $contains index "$strings" >/dev/null 2>&1 ; then
X				echo "Your system has both index() and strchr().  Shall I use"
X				rp="index() rather than strchr()? [$dflt]"
X				$echo $n "$rp $c"
X				. myread
X				case "$ans" in
X					n*) d_index="$define" ;;
X					*)  d_index="$undef" ;;
X				esac
X			else
X				d_index="$define"
X				echo "strchr() found."
X			fi
X		else
X			d_index="$undef"
X			echo "index() found."
X		fi
X	else
X		d_index="$undef"
X		echo "index() found."
X	fi
Xelse
X	if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
X		d_index="$define"
X		echo "strchr() found."
X	else
X		echo "No index() or strchr() found!"
X		d_index="$undef"
X	fi
Xfi
X
X: see if popen exists
Xset popen d_popen
Xeval $inlibc
X
X: see if sys/resource.h has to be included
Xset sys/resource.h i_sysresrc
Xeval $inhdr
X
X: see if we should include time.h, sys/time.h, or both
Xcat <<'EOM'
X  
XTesting to see if we should include <time.h>, <sys/time.h> or both.
XI'm now running the test program...
XEOM
X$cat >try.c <<'EOCP'
X#include <sys/types.h>
X#ifdef I_TIME
X#include <time.h>
X#endif
X#ifdef I_SYSTIME
X#ifdef SYSTIMEKERNEL
X#define KERNEL
X#endif
X#include <sys/time.h>
X#endif
Xmain()
X{
X    struct tm foo;
X#ifdef S_TIMEVAL
X    struct timeval bar;
X#endif
X    if (foo.tm_sec == foo.tm_sec)
X	exit(0);
X#ifdef S_TIMEVAL
X    if (bar.tv_sec == bar.tv_sec)
X	exit(0);
X#endif
X    exit(1);
X}
XEOCP
Xflags=''
Xfor s_timeval in '-DS_TIMEVAL' ''; do
X    for i_systimek in '' '-DSYSTIMEKERNEL'; do
X	for i_time in '' '-DI_TIME'; do
X	    for i_systime in '-DI_SYSTIME' ''; do
X		case "$flags" in
X		'') echo Trying $i_time $i_systime $i_systimek $s_timeval
X		    if $cc $ccflags \
X			    $i_time $i_systime $i_systimek $s_timeval \
X			    try.c -o try >/dev/null 2>&1 ; then
X			set X $i_time $i_systime $i_systimek $s_timeval
X			shift
X			flags="$*"
X			echo Succeeded with $flags
X		    fi
X		    ;;
X		esac
X	    done
X	done
X    done
Xdone
Xtimeincl=''
Xcase "$flags" in
X*SYSTIMEKERNEL*) i_systimek="$define"
X	timeincl='/usr/include/sys/time.h'
X	echo "We'll include <sys/time.h> with KERNEL defined.";;
X*) i_systimek="$undef";;
Xesac
Xcase "$flags" in
X*I_TIME*) i_time="$define"
X	timeincl='/usr/include/time.h'
X	echo "We'll include <time.h>.";;
X*) i_time="$undef";;
Xesac
Xcase "$flags" in
X*I_SYSTIME*) i_systime="$define"
X	timeincl='/usr/include/sys/time.h'
X	echo "We'll include <sys/time.h>.";;
X*) i_systime="$undef";;
Xesac
X$rm -f try.c try
X
X: see if getrusage exists
Xecho " "
Xif $contains getrusage libc.list >/dev/null 2>&1; then
X    echo 'getrusage() found.'
X    d_rusage="$define"
Xelse
X    echo 'getrusage() not found--cpu accounting may be less accurate.'
X    d_rusage="$undef"
Xfi
X
X
X: determine if we want to use the URT
Xcase "$urtinc" in
X'')
X    dflt='none'
X    ;;
X*)  dflt=`echo $urtinc | $sed -e 's/-I//'`
X    ;;
Xesac
X
Xecho " "
Xecho "$package works best when linked with the Utah Raster Toolkit."
Xecho "If you don't have the URT, $package will compile, but with many"
X
X$cat << EOT
Xuseful features disabled.
X
XIn addition to providing a library for reading and writing compact
Ximage files, the URT offers a host of useful image-maniuplation tools.
XYou are strongly encouraged to get a copy.
X
XIf you do not have a copy of the URT, answer 'none' below.
X
XEOT
X
Xrp="What directory holds the Utah Raster Toolkit include files? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xcase "$ans" in
X'none')
X    urtinc=''
X    urtlib=''
X    d_urt="$undef"
X    ;;
X*)
X    urtinc="$ans"
X    d_urt="$define"
X    case "$urtlib" in
X    '')
X        dflt=`$echo $urtinc | $sed -e 's/include/lib\/librle.a/g'`
X        if test ! -f "$dflt"; then
X            dflt="/usr/local/lib/librle.a"
X        fi
X        ;;
X    *)
X        dflt="$urtlib"
X        ;;
X    esac
X    echo " "
X    rp="Where is the Utah Raster Toolkit library? [$dflt]"
X    $echo $n "$rp $c"
X    . myread
X    urtlib="$ans"
X    urtinc="-I$urtinc"
X    ;;
Xesac
X: see if this is a stdlib.h
Xecho " "
Xif $test -r /usr/include/stdlib.h ; then
X    i_stdlib="$define"
X    echo "<stdlib.h> found."
Xelse
X    i_stdlib="$undef"
Xfi
X
X: How can we generate normalized random numbers ?
Xecho " "
Xcase "$randfunc" in
X'')
X	if $contains "^drand48\$" libc.list >/dev/null 2>&1; then
X		dflt="drand48"
X		echo "Good, found drand48()."
X	elif $contains "^random\$" libc.list >/dev/null 2>&1; then
X		dflt="random"
X		echo "OK, found random()."
X	else
X		dflt="rand"
X		echo "Yick, looks like I have to use rand()."
X	fi
X	echo " "
X	;;
X*)
X	dflt="$randfunc"
X	;;
Xesac
Xcont=true
Xwhile $test "$cont"; do
X	rp="Use which function to generate random numbers? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	if $test "$ans" = "$dflt"; then
X		: null
X	else
X		nrandbits=''
X	fi
X	randfunc="$ans"
X	if $contains "^$ans\$" libc.list >/dev/null 2>&1; then
X		cont=''
X	else
X		dflt=n
X		rp="Function $ans does not exists. Use that name anyway? [$dflt]"
X		$echo $n "$rp $c"
X		. myread
X		dflt=rand
X		case "$ans" in
X			[yY]*) cont='';;
X		esac
X	fi
X	case "$cont" in
X	'')
X		case "$randfunc" in
X		drand48)
X			mrand="drand48()"
X			seedfunc="srand48"
X			;;
X		rand*)
X			case "$nrandbits" in
X			'')
X			echo "Checking to see how many bits your $randfunc() function produces..."
X			$cat >try.c <<EOCP
X#include <stdio.h>
Xmain()
X{
X	register int i;
X	register unsigned long tmp;
X	register unsigned long max = 0L;
X	extern long random();
X
X	for (i=1000; i; i--) {
X		tmp = (unsigned long)$randfunc();
X		if (tmp > max) max = tmp;
X	}
X	for (i=0; max; i++)
X		max /= 2;
X	printf("%d\n",i);
X}
XEOCP
X			if $cc try.c -o try >/dev/null 2>&1 ; then
X			dflt=`try`
X			else
X			dflt='?'
X			echo "(I can't seem to compile the test program...)"
X			fi
X			;;
X			*)
X				dflt="$nrandbits"
X				;;
X			esac
X			rp="How many bits does your $randfunc() function produce? [$dflt]"
X			$echo $n "$rp $c"
X			. myread
X			nrandbits="$ans"
X			$rm -f try.c try
X			mrand="($randfunc() / (double) ((1 << $nrandbits) -1))"
X			seedfunc="srand"
X			;;
X		*)
X			dflt="31"
X			rp="How many bits does your $randfunc() function produce? [$dflt]"
X			$echo $n "$rp $c"
X			. myread
X			nrandbits="$ans"
X			seedfunc="s$randfunc"
X			mrand="($randfunc() / (double) ((1 << $nrandbits) -1))"
X			if $contains "^$seedfunc\$" libc.list >/dev/null 2>&1; then
X				echo "(Using $seedfunc() to seed random generator)"
X			else
X				echo "(Warning: no $seedfunc() to seed random generator)"
X				seedfunc=rand
X			fi
X			;;
X		esac
X		;;
X	esac
Xdone
X
X: check for void type
Xecho " "
X$cat <<EOM
XChecking to see how well your C compiler groks the void type...
X
X  Support flag bits are:
X    1: basic void declarations.
X    2: arrays of pointers to functions returning void.
X    4: operations between pointers to and addresses of void functions.
X    8: generic void pointers.
X
XEOM
Xcase "$voidflags" in
X'')
X    $cat >try.c <<'EOCP'
X#if TRY & 1
Xvoid main() {
X#else
Xmain() {
X#endif
X	extern void moo();	/* function returning void */
X	void (*goo)();		/* ptr to func returning void */
X#if TRY & 8
X	void *hue;		/* generic ptr */
X#endif
X#if TRY & 2
X	void (*foo[10])();
X#endif
X
X#if TRY & 4
X	if(goo == moo) {
X		exit(0);
X	}
X#endif
X	exit(0);
X}
XEOCP
X    if $cc -S -DTRY=$defvoidused try.c >.out 2>&1 ; then
X		voidflags=$defvoidused
X		echo "It appears to support void."
X		if $contains warning .out >/dev/null 2>&1; then
X			echo "However, you might get some warnings that look like this:"
X			$cat .out
X		fi
X    else
X		echo "Hmm, your compiler has some difficulty with void.  Checking further..."
X		if $cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
X			echo "It supports 1..."
X			if $cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
X				echo "It also supports 2..."
X				if $cc -S -DTRY=7 try.c >/dev/null 2>&1 ; then
X					voidflags=7
X					echo "And it supports 4 but not 8 definitely."
X				else
X					echo "It doesn't support 4..."
X					if $cc -S -DTRY=11 try.c >/dev/null 2>&1 ; then
X						voidflags=11
X						echo "But it supports 8."
X					else
X						voidflags=3
X						echo "Neither does it support 8."
X					fi
X				fi
X			else
X				echo "It does not support 2..."
X				if $cc -S -DTRY=13 try.c >/dev/null 2>&1 ; then
X					voidflags=13
X					echo "But it supports 4 and 8."
X				else
X					if $cc -S -DTRY=5 try.c >/dev/null 2>&1 ; then
X						voidflags=5
X						echo "And it supports 4 but haven't heard about 8."
X					else
X						echo "However it supports 8 but not 4."
X					fi
X				fi
X			fi
X		else
X			echo "There is no support at all for void."
X			voidflags=0
X		fi
X    fi
Xesac
Xdflt="$voidflags";
Xrp="Your void support flags add up to what? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xvoidflags="$ans"
X$rm -f try.* .out
X
X: preserve RCS keywords in files with variable substitution, grrr
XLog='$Log'
XHeader='$Header'
XId='$Id'
X
X: determine where public executables go
Xcase "$bin" in
X'')
X    dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
X    ;;
X*)  dflt="$bin"
X    ;;
Xesac
Xcont=true
Xwhile $test "$cont" ; do
X    echo " "
X    rp="Where do you want to put the public executables? (~name ok) [$dflt]"
X    $echo $n "$rp $c"
X    . myread
X    bin="$ans"
X    bin=`filexp $bin`
X    if test -d $bin; then
X	cont=''
X    else
X	dflt=n
X	rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	dflt=''
X	case "$ans" in
X	y*) cont='';;
X	esac
X    fi
Xdone
X
X: find out how to generate dependencies
Xecho " "
Xecho "Checking how to generate makefile dependencies on your machine..."
Xtoplev=`cd ..;pwd`
Xccinc="-I. -I$toplev -I$toplev/libray -I$toplev/libshade $urtinc"
X$cat >dep.c <<'EOCP'
X#include "dep.h"
XEOCP
X$cat >dep.h <<'EOCP'
X
XEOCP
Xcase "$mkdep" in
X'')
X	;;
X*)
X	if test -x "$mkdep" &&
X		$mkdep dep.c >dep.out 2>/dev/null &&
X		$contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X	then
X		echo "$mkdep works."
X	else
X		mkdep=
X	fi
Xesac
X
Xcase "$mkdep" in
X'')
X	$spitshell > ../mkdep <<EOM
X$startsh
Xfor srcfile
Xdo
X	$cpp -M $ccinc $cppflags \$srcfile
Xdone
XEOM
X	mkdep=$toplev/mkdep
X	chmod +x $mkdep
X	$eunicefix $mkdep
X	if $mkdep dep.c >dep.out 2>/dev/null &&
X		$contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X	then
X		echo "Looks like we can use $cpp -M."
X	else
X		mkdep=
X	fi
X	;;
Xesac
X
Xcase "$mkdep" in
X'')
X	$spitshell >../mkdep <<EOS
X$startsh
Xfor srcfile
Xdo
X	case "\$srcfile" in
X	*.c) c='.c';;
X	*.y) c='.y';;
X	*.l) c='.l';;
X	esac
X	filebase=\`basename \$srcfile \$c\`
X	< \$srcfile $cpp $cppminus $cppflags $ccinc | \\
X	$sed -e '/^# *[0-9]/!d' \\
X		-e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
X		-e 's|: \./|: |' \\
X		-e 's|: *$|: '\$srcfile'|' | \\
X	$grep -v '^#' | $sort | $uniq
Xdone
XEOS
X	mkdep=$toplev/mkdep
X	chmod +x $mkdep
X	$eunicefix $mkdep
X	if $mkdep dep.c >dep.out 2>/dev/null &&
X		$contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X	then
X		echo "A shell script using $cpp does the trick."
X	else
X		echo "$cpp doesn't seem to be any use at all."
X		$spitshell >../mkdep <<EOS
X$startsh
Xfor srcfile
Xdo
X	case "\$srcfile" in
X	*.c) c='.c';;
X	*.y) c='.y';;
X	*.l) c='.l';;
X	esac
X	filebase=\`basename \$srcfile \$c\`
X	echo \$filebase.o: \$srcfile
X	$grep '^#[  ]*include' \$srcfile /dev/null |
X	$sed -e 's/#[   ]*include[  ]*//' \\
X		-e 's,<\(.*\)>,"/usr/include/\1",' \\
X		-e 's/:[^"]*"\([^"]*\)".*/: \1/' \\
X		-e 's/\.c:/\.o:/'
Xdone
XEOS
X		mkdep=$toplev/mkdep
X		chmod +x $mkdep
X		$eunicefix $mkdep
X		if $mkdep dep.c >dep.out 2>/dev/null &&
X		    $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X		then
X			cat << EOM
X
XI can use a script with grep instead, but it will make some incorrect
Xdependencies, since it doesn't understand about conditional compilation.
XMoreover, some dependencies may be missing, because scanning won't be
Xa recursive process.
XIf you have a program which generates makefile dependencies, you may want
Xto use it.  If not, you can use the script and edit the Makefile by hand
Xif you need to.
XEOM
X		else
X			mkdep=
X			cat << EOM
X
XI can't seem to generate makefile dependencies at all!  Perhaps you have a
Xprogram that does?  If you don't, you might look at the mkdep script to
Xsee if you can create one which works.
XEOM
X		fi
X	fi
Xesac
Xcont=true
Xdflt="$mkdep"
Xwhile $test "$cont" ; do
X	echo " "
Xrp="Name of program to make makefile dependencies? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xmkdep="$ans"
Xmkdep=`filexp $mkdep`
Xif test -f "$mkdep"; then
X	cont=''
Xelse
X	dflt=n
X	rp="$mkdep doesn't exist.  Use that name anyway? [$dflt]"
X	$echo $n "$rp $c"
X	. myread
X	dflt=''
X	case "$ans" in
X	y*) cont='';;
X	esac
Xfi
Xdone
X$rm -f dep.c dep.h dep.o dep.out
X: see if ar generates random libraries by itself
Xecho " "
Xecho "Checking how to generate random libraries on your machine..."
Xar rc ran.a /dev/null
Xif ar ts ran.a >/dev/null 2>&1; then
X	echo "ar appears to generate random libraries itself."
X	orderlib=false
X	ranlib=":"
Xelse
X	if test -f /usr/bin/ranlib; then
X		ranlib=/usr/bin/ranlib
X	elif test -f /bin/ranlib; then
X		ranlib=/bin/ranlib
X	fi
X
X	if test -n "$ranlib"; then
X		echo "your system has $ranlib; we'll use that."
X		orderlib=false
X	else
X		echo "your system doesn't seem to support random libraries"
X		echo "so we'll use lorder and tsort to order the libraries."
X		orderlib=true
X		ranlib=":"
X	fi
Xfi
X
X: determine compiler compiler
Xcase "$bison" in
X/*) dflt="bison -y";;
X*) case "$yacc" in
X		'') dflt=yacc;;
X		*)  dflt="$yacc";;
X	esac
X	;;
Xesac
Xcont=true
X    echo " "
Xrp="Which compiler compiler (yacc or bison -y) will you use? [$dflt]"
X$echo $n "$rp $c"
X. myread
Xcase "$ans" in
X'') ans="$dflt";;
X*bis*) ans="bison -y";;
X*yac*) ans="yacc";;
Xesac
Xyacc="$ans"
X
Xecho " "
Xecho "End of configuration questions."
Xecho " "
X
X: create config.sh file
Xecho " "
Xif test -d ../UU; then
X    cd ..
Xfi
Xecho "Creating config.sh..."
X$spitshell <<EOT >config.sh
X$startsh
X# config.sh
X# This file was produced by running the Configure script.
X
Xd_eunice='$d_eunice'
Xd_xenix='$d_xenix'
Xd_bsd='$d_bsd'
Xdefine='$define'
Xeunicefix='$eunicefix'
Xloclist='$loclist'
Xexpr='$expr'
Xawk='$awk'
Xsed='$sed'
Xecho='$echo'
Xcat='$cat'
Xchgrp='$chgrp'
Xchmod='$chmod'
Xchown='$chown'
Xrm='$rm'
Xmv='$mv'
Xcp='$cp'
Xtail='$tail'
Xtr='$tr'
Xmkdir='$mkdir'
Xsort='$sort'
Xuniq='$uniq'
Xgrep='$grep'
Xtrylist='$trylist'
Xtest='$test'
Xinews='$inews'
Xegrep='$egrep'
Xmore='$more'
Xpg='$pg'
XMcc='$Mcc'
Xvi='$vi'
Xmail='$mail'
Xbison='$bison'
Xcpp='$cpp'
Xperl='$perl'
XLog='$Log'
XHeader='$Header'
XId='$Id'
Xbin='$bin'
Xcontains='$contains'
Xcppstdin='$cppstdin'
Xcppminus='$cppminus'
Xd_bzero='$d_bzero'
Xd_cbrt='$d_cbrt'
Xd_index='$d_index'
Xd_memset='$d_memset'
Xd_popen='$d_popen'
Xd_rusage='$d_rusage'
Xd_times='$d_times'
Xclocktype='$clocktype'
Xi_string='$i_string'
Xstrings='$strings'
Xi_sysresrc='$i_sysresrc'
Xi_systypes='$i_systypes'
Xi_time='$i_time'
Xi_systime='$i_systime'
Xi_systimek='$i_systimek'
Xtimeincl='$timeincl'
Xinhdr='$inhdr'
Xinlibc='$inlibc'
Xlibs='$libs'
Xmodels='$models'
Xsplit='$split'
Xsmall='$small'
Xmedium='$medium'
Xlarge='$large'
Xhuge='$huge'
Xccflags='$ccflags'
Xldflags='$ldflags'
Xcc='$cc'
Xcppflags='$cppflags'
Xoptimize='$optimize'
Xn='$n'
Xc='$c'
Xorderlib='$orderlib'
Xranlib='$ranlib'
Xpackage='$package'
Xrandfunc='$randfunc'
Xmrand='$mrand'
Xseedfunc='$seedfunc'
Xnrandbits='$nrandbits'
Xspitshell='$spitshell'
Xshsharp='$shsharp'
Xsharpbang='$sharpbang'
Xstartsh='$startsh'
Xsysman='$sysman'
Xvoidflags='$voidflags'
Xdefvoidused='$defvoidused'
Xyacc='$yacc'
Xd_urt='$d_urt'
Xurtinc='$urtinc'
Xurtlib='$urtlib'
Xi_stdlib='$i_stdlib'
Xlibc='$libc'
Xmkdep='$mkdep'
XCONFIG=true
XEOT
X
XCONFIG=true
X
Xecho " "
Xdflt=''
Xfastread=''
Xecho "If you didn't make any mistakes, then just type a carriage return here."
Xrp="If you need to edit config.sh, do it as a shell escape here:"
X$echo $n "$rp $c"
X. UU/myread
Xcase "$ans" in
X'') ;;
X*) : in case they cannot read
X    eval $ans;;
Xesac
X. ./config.sh
X
Xecho " "
Xecho "Doing variable substitutions on .SH files..."
Xif test -f MANIFEST; then
X	set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
Xelse
X	set x `find . -name "*.SH" -print`
Xfi
Xshift
Xcase $# in
X0) set x *.SH; shift;;
Xesac
Xif test ! -f $1; then
X    shift
Xfi
Xfor file in $*; do
X    case "$file" in
X    */*)
X	dir=`$expr X$file : 'X\(.*\)/'`
X	file=`$expr X$file : 'X.*/\(.*\)'`
X	(cd $dir && . $file)
X	;;
X    *)
X	. $file
X	;;
X    esac
Xdone
Xif test -f config.h.SH; then
X    if test ! -f config.h; then
X	: oops, they left it out of MANIFEST, probably, so do it anyway.
X	. config.h.SH
X    fi
Xfi
X
Xif $contains '^depend:' Makefile >/dev/null 2>&1; then
X    dflt=n
X    $cat <<EOM
X
XNow you need to generate make dependencies by running "make depend".
XYou might prefer to run it in background: "make depend > makedepend.out &"
XIt can take a while, so you might not want to run it right now.
X
XEOM
X    rp="Run make depend now? [$dflt]"
X    $echo $n "$rp $c"
X    . UU/myread
X    case "$ans" in
X    y*) make depend
X	echo "Now you must run a make."
X	;;
X    *)  echo "You must run 'make depend' then 'make'."
X	;;
X    esac
Xelif test -f Makefile; then
X    echo " "
X    echo "Now you must run a make."
Xelse
X    echo "Done."
Xfi
X
X$rm -f kit*isdone
X: the following is currently useless
Xcd UU && $rm -f $rmlist
X: since this removes it all anyway
Xcd .. && $rm -rf UU
X: end of Configure
END_OF_FILE
if test 49296 -ne `wc -c <'Configure'`; then
    echo shar: \"'Configure'\" unpacked with wrong size!
fi
chmod +x 'Configure'
# end of 'Configure'
fi
echo shar: End of archive 19 \(of 19\).
cp /dev/null ark19isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 19 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
