Newsgroups: comp.sources.unix
From: ram@eiffel.com (Raphael Manfredi)
Subject: v25i052: kit - the ultimate mailing kit, Part04/04
Sender: sources-moderator@pa.dec.com
Approved: vixie@pa.dec.com

Submitted-By: ram@eiffel.com (Raphael Manfredi)
Posting-Number: Volume 25, Issue 52
Archive-Name: kit/part04

#! /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 4 (of 4)."
# Contents:  Configure
# Wrapped by vixie@cognition.pa.dec.com on Thu Dec 19 21:18:31 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'\" \(53615 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,
X# I would suggest you have a look at the prototypical config.h.SH file
X# and edit it to reflect your system. Some packages may include samples
X# of config.h for certain machines, so you might look for one of those.)
X#
X# Yes, you may rip this off to use in other distribution packages. This
X# script belongs to the public domain and cannot be copyrighted.
X#
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@eiffel.com (Raphael Manfredi) and I will send you the
X# latest revision of the dist package, which includes metaconfig.)
X
X# $Id: Configure,v 2.0.1.4 91/11/25 15:48:25 ram Exp $
X#
X# Generated on Mon Nov 25 15:43:33 PST 1991 [metaconfig 2.8 PL11]
X
cat >/tmp/c1$$ <<EOF
X
ARGGGHHHH!!!!!
X
SCO csh still thinks true is false.  Write to SCO today and tell them that next
year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
X
X(Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
we'd have to do is go in and swap the && and || tokens, wherever they are.)
X
X[End of diatribe.  We now return you to your regularly scheduled programming...]
XEOF
cat >/tmp/c2$$ <<EOF
X
OOPS!  You naughty creature!  You didn't run Configure with sh!
I will attempt to remedy the situation by running sh for you...
XEOF
X
true || cat /tmp/c1$$ /tmp/c2$$
true || exec sh $0
X
export PATH || cat /tmp/c2$$
export PATH || exec sh $0
rm -f /tmp/c1$$ /tmp/c2$$
X
X: sanity checks
PATH=".:$PATH:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin"
PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd:/bsd43/bin'
export PATH
X
if test ! -t 0; then
X    echo "Say 'sh Configure', not 'sh <Configure'"
X    exit 1
fi
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
test -d UU || mkdir UU
cd UU && rm -f *
X
case "$1" in
X-d) shift; fastread='yes';;
esac
X
d_eunice=''
d_xenix=''
d_bsd=''
define=''
eunicefix=''
Mcc=''
awk=''
bison=''
cat=''
chgrp=''
chmod=''
chown=''
compress=''
cp=''
cpio=''
cpp=''
csh=''
date=''
echo=''
egrep=''
emacs=''
expr=''
grep=''
inews=''
less=''
line=''
lint=''
ln=''
lp=''
lpr=''
ls=''
mail=''
mailx=''
make=''
mkdir=''
more=''
mv=''
nroff=''
perl=''
pg=''
pmake=''
pr=''
rm=''
rmail=''
sed=''
sendmail=''
sleep=''
smail=''
sort=''
submit=''
tail=''
tar=''
tbl=''
test=''
touch=''
tr=''
troff=''
uname=''
uniq=''
uuname=''
vi=''
zcat=''
Author=''
Date=''
Header=''
Id=''
Locker=''
Log=''
RCSfile=''
Revision=''
Source=''
State=''
bin=''
byteorder=''
cc=''
ccflags=''
ldflags=''
cppflags=''
optimize=''
contains=''
cppstdin=''
cppminus=''
d_getopt=''
d_index=''
d_memcpy=''
d_memset=''
d_portable=''
d_voidsig=''
signal_t=''
defeditor=''
i_string=''
strings=''
i_sysioctl=''
i_bsdioctl=''
i_syssockio=''
d_voidtty=''
i_termio=''
i_sgtty=''
i_termios=''
libc=''
nm_opt=''
libpth=''
plibpth=''
libs=''
mailer=''
mansrc=''
manext=''
n=''
c=''
package=''
privlib=''
scriptdir=''
spitshell=''
shsharp=''
sharpbang=''
startsh=''
sysman=''
usrinc=''
mips=''
incpath=''
mips_type=''
voidflags=''
defvoidused=''
d_taropt_o=''
large=''
d_whoami=''
i_sysselct=''
CONFIG=''
X: set package name
package=kit
X
X: Eunice requires " " instead of "", can you believe it
echo " "
X: Here we go...
echo "Beginning of configuration questions for $package kit."
X
define='define'
undef='undef'
smallmach='pdp11 i8086 z8000 i80286 iAPX286'
rmlist='ark[1-9]isdone ark[1-9][0-9]isdone'
trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 15
X
X: We must find out about Eunice early
eunicefix=':'
if test -f /etc/unixtovms; then
X    eunicefix=/etc/unixtovms
fi
if test -f /etc/unixtovms.exe; then
X    eunicefix=/etc/unixtovms.exe
fi
X
X: Find out which program gives a meaningful exit status
if 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
else
X	check='ls'
fi
X
X: Now test for existence of everything in MANIFEST
echo " "
if 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..."
else
X	echo "No MANIFEST found. Hope your kit is complete !"
fi
rm -f .grepmani
X
X: list of known cpp symbols
attrlist="DGUX M_I186 M_I286 M_I386 M_I8086 M_XENIX UTS __DGUX__"
attrlist="$attrlist _AIX __STDC__ __m88k__ ansi bsd4_2 gcos gimpel"
attrlist="$attrlist hp9000s300 hp9000s500 hp9000s800 hpux"
attrlist="$attrlist i186 i386 i486 i8086 iAPX286 ibm interdata"
attrlist="$attrlist m88k mc300 mc500 mc68000 mc68k mc700 mert"
attrlist="$attrlist mips ns16000 ns32000 nsc32000 os pdp11 posix pyr"
attrlist="$attrlist sinix sony sparc sun tower tower32 tower32_600"
attrlist="$attrlist tower32_800 tss u3b2 u3b20 u3b200 u3b5 ultrix unix"
attrlist="$attrlist vax venix xenix z8000"
X
X: no include file wanted by default
inclwanted=''
X
X: change the next line if compiling for Xenix/286 on Xenix/386
xlibpath='/usr/lib/386 /lib/386'
libpth='/usr/lib/large /lib '$xlibpth' /lib/large'
libpth=$libpth' /usr/lib/small /lib/small'
X
X: full support for void wanted by default
defvoidused=15
X
X
X: some greps do not return status, grrr.
echo "grimblepritz" >grimble
if grep blurfldyick grimble >/dev/null 2>&1 ; then
X    contains=contains
elif grep grimblepritz grimble >/dev/null 2>&1 ; then
X    contains=grep
else
X    contains=contains
fi
rm -f grimble
X: the following should work in any shell
case "$contains" in
contains*)
X    echo " "
X    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
X    cat >contains <<'EOSS'
grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
XEOSS
chmod +x contains
esac
X
X: first determine how to suppress newline on echo command
echo " "
echo "Checking echo to see how to suppress newlines..."
X(echo "hi there\c" ; echo " ") >.echotmp
if $contains c .echotmp >/dev/null 2>&1 ; then
X    echo "...using -n."
X    n='-n'
X    c=''
else
X    cat <<'EOM'
X...using \c
XEOM
X    n=''
X    c='\c'
fi
echo $n "The star should be here-->$c"
echo '*'
rm -f .echotmp
X
X: set up the echo used in my read
myecho="case \"\$xxxm\" in
X'') echo $n \"\$rp $c\";;
X*) case \"\$rp\" in
X	'') echo $n \"[\$xxxm] $c\";;
X	*) echo $n \"\$rp [\$xxxm] $c\";;
X	esac;;
esac"
X
X: now set up to do reads with possible shell escape and default assignment
cat <<EOSC >myread
xxxm=\$dflt
X$myecho
case "\$fastread" in
yes) case "\$dflt" in
X	'') ans='!';;
X	*) ans=''; echo " " ;;
X	esac;;
X*) ans='!';;
esac
while expr "X\$ans" : "X!" >/dev/null; do
X	read answ
X	set x \$xxxm
X	shift
X	aok=''; eval "ans=\"\$answ\"" && aok=y
X	case  "\$answ" in
X	"\$ans")
X		case "\$ans" in
X		!)
X			sh
X			echo " "
X			$myecho
X			;;
X		!*)
X			set x \`expr "X\$ans" : "X!\(.*\)\$"\`
X			shift
X			sh -c "\$*"
X			echo " "
X			$myecho
X			;;
X		esac;;
X	*)
X		case "\$aok" in
X		y)
X			echo "*** Substitution done -- please confirm."
X			xxxm="\$ans"
X			ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
X			xxxm="\$ans"
X			ans=!
X			;;
X		*)
X			echo "*** Error -- try again."
X			ans=!
X			;;
X		esac
X		$myecho
X		;;
X	esac
done
case "\$ans" in
X'') ans="\$xxxm";;
esac
XEOSC
X
X: general instructions
cat <<EOH
X 
This installation shell script will examine your system and ask you questions
to determine how the kit package should be installed.  If you get stuck
on a question, you may use a ! shell escape to start a subshell or execute a
command.  Many of the questions will have default answers in square brackets;
typing carriage return will give you the default.
X
On some of the questions which ask for file or directory names you are allowed
to use the ~name construct to specify the login directory belonging to "name",
even if you don't have a shell which knows about that.  Questions where this is
allowed will be marked "(~name ok)".
X
XEOH
rp=''
dflt="Type carriage return to continue"
X. myread
cat <<'EOH'
X
The prompter used in this script allows you to use shell variables and
backticks in your answers.  You may use $1, $2, etc...  to refer to the words
in the default answer, as if the default line was a set of arguments given to a
script shell.  This means you may also use $* to repeat the whole default line,
so you do not have to re-type everything to add something to the default.
X
XEverytime there is a substitution, you will have to confirm.  If there is an
error (e.g. an unmatched backtick), the default answer will remain unchanged
and you will be prompted again.
X
If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
the questions and use the computed defaults (or the previous answers if there
was already a config.sh file).
X
XEOH
X. myread
cat <<EOH
X
Much effort has been expended to ensure that this shell script will run on any
Unix system.  If despite that it blows up on yours, your best bet is to edit
Configure and run it again.  Also, let me (ram@eiffel.com)
know how I blew it.  If you can't run Configure for some reason, you'll have to
generate a config.sh file by hand.
X
This installation script affects things in two ways:
X
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
If you make a mistake on a question, there is no easy way to back up to it
currently.  The easiest thing to do is to edit config.sh and rerun all the SH
files.  Configure will offer to let you do this before it runs the SH files.
X
XEOH
dflt="Type carriage return to continue"
X. myread
X
X: see if sh knows # comments
echo " "
echo "Checking your sh to see if it knows about # comments..."
if 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/cat" >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."
X			sharpbang='#! '
X		else
X			echo "It doesn't."
X			sharpbang=': use '
X		fi
X	fi
else
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 '
fi
rm -f try today
X
X: figure out how to guarantee sh startup
echo " "
echo "Checking out how to guarantee sh startup..."
startsh=$sharpbang'/bin/sh'
echo "Let's see if '$startsh' works..."
cat >try <<EOSS
X$startsh
set abc
test "$?abc" != 1
XEOSS
X
chmod +x try
X$eunicefix try
if try; then
X    echo "Yup, it does."
else
X    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
fi
rm -f try
X
X: find out where common programs are
echo " "
echo "Locating common programs..."
cat <<EOSC >loc
X$startsh
case \$# in
X0) exit 1;;
esac
thing=\$1
shift
dflt=\$1
shift
for 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
done
echo \$dflt
exit 1
XEOSC
chmod +x loc
X$eunicefix loc
loclist="
awk
cat
chgrp
chmod
chown
echo
expr
grep
mv
rm
sed
tr
X"
trylist="
Mcc
cpp
mail
nroff
rmail
sendmail
tar
test
uname
vi
X"
pth=`echo $PATH | sed -e 's/:/ /g'`
pth="$pth /lib /usr/lib"
for 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
done
echo " "
echo "Don't worry if any of the following aren't found..."
ans=offhand
for 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
done
case "$egrep" in
egrep)
X    echo "Substituting grep for egrep."
X    egrep=$grep
X    ;;
esac
case "$test" in
test)
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    ;;
esac
case "$echo" in
echo)
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';;
X	*) n='-n' c='';;
X	esac
X	cat <<FOO
They are not compatible!  You are probably running ksh on a non-USG system.
I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
have echo built in and we may have to run some Bourne shell scripts.  That
means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
X
XFOO
X	$echo $n "The star should be here-->$c"
X	$echo "*"
X    fi
X    $rm -f foo1 foo2
X    ;;
X*)
X    : cross your fingers
X    echo=echo
X    ;;
esac
rmlist="$rmlist loc"
X
X: get old answers, if there is a config file out there
hint=default
if 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?"
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		cp ../config.sh .
X		n="$tmp"
X		c="$ans"
X		;;
X	esac
fi
X
X: Restore computed paths
for file in $loclist $trylist; do
X	eval $file="\$_$file"
done
X
X: set up shell script to do ~ expansion
cat >filexp <<EOSS
X$startsh
X: expand filename
case "\$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    ;;
esac
XEOSS
chmod +x filexp
X$eunicefix filexp
X
X: determine where manual pages are on this system
echo " "
case "$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    ;;
esac
if test -d "$sysman"; then
X	echo "System manual is in $sysman."
else
X	echo "Could not find manual pages in source form."
fi
X
X: make some quick guesses about what we are up against
echo " "
X$echo $n "Hmm...  $c"
X$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
if test `echo abc | tr a-z A-Z` = Abc ; then
X	xxx=`./loc addbib blurfl $pth`
X	if $test -f $xxx; then
X		echo "Looks kind of like a 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		if $contains SIGTSTP foo >/dev/null 2>&1 ; then
X			echo "Looks kind of like an extended USG system, but we'll see..."
X		else
X			echo "Looks kind of like a USG system, but we'll see..."
X		fi
X		echo exit 1 >bsd
X		echo exit 0 >usg
X		echo exit 1 >v7
X	fi
X	d_bsd="$undef"
elif $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
else
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
fi
case "$eunicefix" in
X*unixtovms*)
X    cat <<'EOI'
There is, however, a strange, musty smell in the air that reminds me of
something...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	;;
esac
if test -f /xenix; then
X    echo "Actually, this looks more like a XENIX system..."
X    echo "exit 0" >xenix
X	d_xenix="$define"
else
X    echo " "
X    echo "It's not Xenix..."
X    echo "exit 1" >xenix
X	d_xenix="$undef"
fi
chmod +x xenix
X$eunicefix xenix
if test -f /venix; then
X    echo "Actually, this looks more like a VENIX system..."
X    echo "exit 0" >venix
else
X    echo " "
X    if xenix; then
X	: null
X    else
X	echo "Nor is it Venix..."
X    fi
X    echo "exit 1" >venix
fi
chmod +x bsd usg v7 eunice venix
X$eunicefix bsd usg v7 eunice venix
X$rm -f foo
rmlist="$rmlist bsd usg v7 eunice venix xenix"
X
X: see if we need a special compiler
echo " "
if usg; then
X	case "$cc" in
X	'') case "$Mcc" in
X		/*) dflt='Mcc';;
X		*) case "$large" in
X			-M*) dflt='cc';;
X			*)	if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
X					if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
X						dflt='cc'
X					else
X						dflt='cc -M'
X					fi
X				else
X					dflt='cc'
X				fi;;
X			esac;;
X		esac;;
X    *)  dflt="$cc";;
X    esac
X    $cat <<'EOM'
On some systems the default C compiler will not resolve multiple global
references that happen to have the same name.  On some such systems the "Mcc"
command may be used to force these to be resolved.  On other systems a "cc -M"
command is required.  (Note that the -M flag on other systems indicates a
memory model to use!) If you have the Gnu C compiler, you might wish to use
that instead.
X
XEOM
X	rp="What command will force resolution on this system?"
X	. myread
X	cc="$ans"
else
X	case "$cc" in
X	'') dflt=cc;;
X	*) dflt="$cc";;
X	esac
X	rp="Use which C compiler?"
X	. myread
X	cc="$ans"
fi
case "$cc" in
gcc*) cpp=`loc gcc-cpp $cpp $pth`;;
esac
X
X: What should the include directory be ?
echo " "
X$echo $n "Hmm...  $c"
case "$usrinc" in
X'') dflt='/usr/include';;
X*) dflt=$usrinc;;
esac
incpath=''
mips_type=''
if $test -f /bin/mips && /bin/mips; then
X	echo "Looks like a MIPS system..."
X	$cat >usr.c <<'EOCP'
X#ifdef SYSTYPE_BSD43
X/bsd43
X#endif
XEOCP
X	if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
X		dflt='/bsd43/usr/include'
X		incpath='/bsd43'
X		mips_type='BSD 4.3'
X	else
X		mips_type='System V'
X	fi
X	echo "and you're compiling with the $mips_type compiler and libraries."
else
X	echo "Doesn't look like a MIPS system."
X	echo "exit 1" >mips
X	chmod +x mips
X	$eunicefix mips
fi
cont=true
while $test "$cont"; do
X	echo " "
X	rp="Where are the include files you want to use?"
X	. myread
X	usrinc="$ans"
X	if $test -d "$ans"; then
X		cont=''
X	else
X		if $test "$fastread" = yes; then
X			dflt=y
X		else
X			dflt=n
X		fi
X		rp="Directory $ans doesn't exist.  Use that name anyway?"
X		. myread
X		dflt=''
X		case "$ans" in
X		y*) cont='';;
X		esac
X	fi
done
X$rm -f usr.c usr.out
X
X: determine optimize, if desired, or use for debug flag also
case "$optimize" in
X' ') dflt="none";;
X'') dflt="-O";;
X*) dflt="$optimize";;
esac
X$cat <<EOH
X
Some C compilers have problems with their optimizers, by default, $package
compiles with the -O flag to use the optimizer.  Alternately, you might want to
use the symbolic debugger, which uses the -g flag (on traditional Unix systems).
XEither flag can be specified here. To use neither flag, specify the word "none".
X
XEOH
rp="What optimizer/debugger flag should be used?"
X. myread
optimize="$ans"
case "$optimize" in
X'none') optimize=" ";;
esac
X
case "$ccflags" in
X'') case "$cc" in
X	*gcc*) dflt='-fpcc-struct-return';;
X	*) dflt='';;
X	esac
X	;;
X*) dflt="$ccflags"
X	case "$cc" in
X	*gcc*) case "$dflt" in
X		*-fpcc-struct-return*) ;;
X		*) dflt="$dflt -fpcc-struct-return";;
X		esac;;
X	esac;;
esac
X
case "$mips_type" in
X*BSD*) ;;
X'') ;;
X*) inclwanted="$inclwanted $usrinc/bsd";;
esac
for thisincl in $inclwanted; do
X	if $test -d $thisincl; then
X		if $test x$thisincl != x$usrinc; then
X			case "$dflt" in
X			*$thisincl*);;
X			*) dflt="$dflt -I$thisincl";;
X			esac
X		fi
X	fi
done
X
case "$optimize" in
X-g*)
X	case "$dflt" in
X	*DEBUG*);;
X	*) dflt="$dflt -DDEBUG";;
X	esac
X	;;
esac
if $contains 'LANGUAGE_C' $usrinc/signal.h >/dev/null 2>&1; then
X	case "$dflt" in
X	*LANGUAGE_C*);;
X	*) dflt="$dflt -DLANGUAGE_C";;
X	esac
elif $contains 'LANGUAGE_C' $usrinc/sys/signal.h >/dev/null 2>&1; then
X	case "$dflt" in
X	*LANGUAGE_C*);;
X	*) dflt="$dflt -DLANGUAGE_C";;
X	esac
fi
if $contains '_NO_PROTO' $usrinc/signal.h >/dev/null 2>&1; then
X	case "$dflt" in
X	*_NO_PROTO*);;
X	*) dflt="$dflt -D_NO_PROTO";;
X	esac
elif $contains '_NO_PROTO' $usrinc/sys/signal.h >/dev/null 2>&1; then
X	case "$dflt" in
X	*_NO_PROTO*);;
X	*) dflt="$dflt -D_NO_PROTO";;
X	esac
fi
case "$dflt" in
X'') dflt=none;;
esac
X$cat <<EOH
X
Your C compiler may want other flags.  For this question you should include
X-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
but you should NOT include libraries or ld flags like -lwhatever.  To use no
flags, specify the word "none".
X
XEOH
set X $dflt
shift
dflt=${1+"$@"}
rp="Any additional cc flags?"
X. myread
case "$ans" in
none) ans='';
esac
ccflags="$ans"
X
X: the following weeds options from ccflags that are of no interest to cpp
cppflags="$ccflags"
case "$cc" in
X*gcc*) cppflags="$cppflags -D__GNUC__";;
esac
case "$mips_type" in
X'');;
X*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
esac
case "$cppflags" in
X'');;
X*)  set X $cppflags
X	cppflags=''
X	for flag do
X		case $flag in
X		-D*|-I*|-traditional|-ansi|-nostdinc) cppflags="$cppflags $flag";;
X		esac
X	done
X	case "$cppflags" in
X	*-*)  echo "(C preprocessor flags: $cppflags)";;
X	esac
X	;;
esac
X
case "$ldflags" in
X'') if venix; then
X		dflt='-i -z'
X	else
X		dflt='none'
X	fi
X	;;
X*) dflt="$ldflags";;
esac
echo " "
rp="Any additional ld flags (NOT including libraries)?"
X. myread
case "$ans" in
none) ans='';
esac
ldflags="$ans"
rmlist="$rmlist pdp11"
X
X: check for ordering of bytes in a long
case "$byteorder" in
X'')
X$cat <<'EOM'
X  
In the following, larger digits indicate more significance.  A big-endian
machine like a Pyramid or a Motorola 680?0 chip will come out to 4321.  A
little-endian machine like a Vax or an Intel 80?86 chip would be 1234.  Other
machines may have weird orders like 3412.  A Cray will report 87654321.  If
the test program works the default is probably right.
I'm now running the test program...
XEOM
X    $cat >try.c <<'EOCP'
X#include <stdio.h>
main()
X{
X    int i;
X    union {
X	unsigned long l;
X	char c[sizeof(long)];
X    } u;
X
X    if (sizeof(long) > 4)
X	u.l = (0x08070605<<32) | 0x04030201;
X    else
X	u.l = 0x04030201;
X    for (i=0; i < sizeof(long); i++)
X	printf("%c",u.c[i]+'0');
X    printf("\n");
X}
XEOCP
X    if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
X	dflt=`./try`
X	case "$dflt" in
X	????|????????) echo "(The test program ran ok.)";;
X	*) echo "(The test program didn't run right for some reason.)";;
X	esac
X    else
X	dflt='4321'
X	echo "(I can't seem to compile the test program.  Guessing big-endian...)"
X    fi
X    ;;
X*)
X    echo " "
X    dflt="$byteorder"
X    ;;
esac
rp="What is the order of bytes in a long?"
X. myread
byteorder="$ans"
X$rm -f try.c try
X
X: Set private lib path
case "$plibpth" in
X'') if mips; then
X		plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
X	else
X		plibpth="/usr/ccs/lib /usr/lib /usr/ucblib /usr/local/lib"
X	fi;;
esac
libpth="$plibpth $libpth"
X
X: Looking for optional libraries
echo " "
echo "Checking for optional libraries..."
case "$libs" in
X'') dflt='';;
X*) dflt="$libs";;
esac
case "$libswanted" in
X'') libswanted='c_s';;
esac
for 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	yyy="$incpath/usr/ccs/lib $incpath/usr/lib $incpath/usr/ucblib"
X	yyy="$yyy $incpath/usr/local/lib $incpath/lib"
X	xxx=`loc lib$thislib.a X $yyy`
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
done
set X $dflt
shift
dflt="$*"
case "$libs" in
X'') dflt="$dflt";;
X*) dflt="$libs";;
esac
case "$dflt" in
X'') dflt='none';;
esac
X
X$cat <<EOM
X 
Some versions of Unix support shared libraries, which make executables smaller
but make load time slightly longer.
X
On some systems, mostly newer Unix System V's, the shared library is included
by putting the option "-lc_s" as the last thing on the cc command line when
linking.  Other systems use shared libraries by default.  There may be other
libraries needed to compile $package on your machine as well.  If your system
needs the "-lc_s" option, include it here.  Include any other special libraries
here as well.  Say "none" for none.
XEOM
X
echo " "
rp="Any additional libraries?"
X. myread
case "$ans" in
none) ans='';
esac
libs="$ans"
X
X: get list of predefined functions in a handy place
echo " "
case "$libc" in
X'') libc=unknown;;
esac
case "$nm_opt" in
X'') if $test -f /mach_boot; then
X		nm_opt=''
X	elif $test -d /usr/ccs/lib; then
X		nm_opt='-p'
X	else
X		nm_opt=''
X	fi;;
esac
libpth="$plibpth $libpth"
case "$libs" in
X*-lc_s*) libc=`loc libc_s.a $libc $libpth`
esac
libnames='';
case "$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    ;;
esac
set /usr/ccs/lib/libc.so
X$test -f $1 || set /usr/lib/libc.so
X$test -f $1 || set /usr/lib/libc.so.[0-9]*
X$test -f $1 || set /lib/libsys_s.a
eval set \$$#
if test -f "$1"; then
X    echo "Your (shared) C library seems to be in $1."
X    libc="$1"
elif test -f /lib/libc && test -f /lib/clib; then
X    echo "Your C library seems to be 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
elif test -f "$libc"; then
X    echo "Your C library seems to be in $libc, as you said before."
elif test -f $incpath/usr/lib/libc.a; then
X	libc=$incpath/usr/lib/libc.a;
X    echo "Your C library seems to be in $libc.  That's fine."
elif test -f /lib/libc.a; then
X	libc=/lib/libc.a;
X    echo "Your C library seems to be in $libc.  You're normal."
else
X    if ans=`./loc libc.a blurfl/dyick $libpth`; test -f "$ans"; then
X		:
X	elif ans=`./loc libc blurfl/dyick $libpth`; test -f "$ans"; then
X		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
X	elif ans=`./loc clib blurfl/dyick $libpth`; test -f "$ans"; then
X		:
X	elif ans=`./loc Slibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then
X		:
X	elif ans=`./loc Mlibc.a blurfl/dyick $xlibpth`; test -f "$ans"; then
X		:
X	else
X		ans=`./loc Llibc.a blurfl/dyick $xlibpth`
X    fi
X    if test -f "$ans"; then
X		echo "Your C library seems to be in $ans, of all places."
X		libc=$ans
X	else
X		libc='blurfl'
X	fi
fi
if $test -f "$libc"; then
X	dflt="$libc"
X	cat <<EOM
X
If the guess above is wrong (which it might be if you're using a strange
compiler, or your machine supports multiple models), you can override it here.
X
XEOM
else
X	dflt=''
X	echo $libpth | tr ' ' '\012' | sort | uniq > libpath
X	cat <<EOM
I can't seem to find your C library.  I've looked in the following places:
X
XEOM
X	$sed 's/^/	/' libpath
X	cat <<EOM
X
None of these seems to contain your C library. I need to get its name...
X
XEOM
fi
cont=true
while $test "$cont"; do
X	rp="Where is your C library?"
X	. myread
X	libc="$ans"
X	if $test -f "$libc"; then
X		cont=''
X	else
X		case "$fastread" in
X		yes) dflt=y;;
X		*) dflt=n;;
X		esac
X		rp="File $libc does not exist. Use that name anyway?"
X		. myread
X		case "$ans" in
X		y*) cont='';;
X		esac
X		dflt=''
X	fi
done
echo " "
echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
set X `cat libnames`
shift
xxx=files
case $# in 1) xxx=file; esac
echo "Extracting names from the following $xxx for later perusal:"
echo " "
X$sed 's/^/	/' libnames
echo " "
X$echo $n "This may take a while...$c"
nm $nm_opt $* 2>/dev/null >libc.tmp
X$echo $n ".$c"
X$grep fprintf libc.tmp > libc.ptf
xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c"'
xrun='eval "<libc.tmp $com >libc.list"; echo "done"'
if com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
X				-e '/ file/d' -e 's/^\([^ 	]*\).*/\1/p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
X	eval $xscan;\
X	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		eval $xrun
else
X	nm -p $* 2>/dev/null >libc.tmp
X	com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
X	eval "<libc.tmp $com >libc.list"
X	if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
X		nm_opt='-p'
X		echo "done"
X	else
X		echo " "
X		echo "nm didn't seem to work right. Trying ar instead..."
X		com=''
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
X	fi
fi
nm_extract="$com"
if test -f /lib/syscalls.exp; then
X	echo " "
X	echo "Also extracting names from /lib/syscalls.exp for good ole AIX..."
X	$sed -n 's/^\([^ 	]*\)[ 	]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
fi
X$rm -f libnames libpath
X
X: set up the script used to warn in case of inconsistency
cat <<'EOSC' >whoa
dflt=y
echo ' '
echo "*** WHOA THERE!!! ***"
echo "    The $hint value for \$$var on this machine was \"$was\"!"
rp="    Keep the $hint value?"
X. myread
case "$ans" in
y) td=$was; tu=$was;;
esac
XEOSC
X
X: define an is-in-libc? function
inlibc='echo " "; td=$define; tu=$undef;
var=$2; eval "was=\$$2";
if $contains "^$1\$" libc.list >/dev/null 2>&1;
then echo "$1() found.";
X	eval "case \"\$$var\" in $undef) . whoa; esac"; eval "$var=\$td";
else echo "$1() not found.";
X	eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu"; fi'
X
X: see if getopt exists
set getopt d_getopt
eval $inlibc
X
X: function used to set $1 to $val
setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
case "$val$was" in
X$define$undef) . whoa; eval "$var=\$td";;
X$undef$define) . whoa; eval "$var=\$tu";;
X*) eval "$var=$val";;
esac'
X
X: see which of string.h or strings.h is needed
echo " "
strings=`loc string.h "" $usrinc $inclwanted`
val="$undef"
if $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	val="$define"
else
X	strings=`loc strings.h "" $usrinc $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
fi
set i_string
eval $setvar
X
X: index or strchr
echo " "
case "$d_index" in
n) dflt=n;;
X*) dflt=y;;
esac
if $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()."
X				rp="Shall I use index() rather than strchr()?"
X				. myread
X				case "$ans" in
X					n*) val="$define" ;;
X					*)  val="$undef" ;;
X				esac
X			else
X				val="$define"
X				echo "strchr() found."
X			fi
X		else
X			val="$undef"
X			echo "index() found."
X		fi
X	else
X		val="$undef"
X		echo "index() found."
X	fi
else
X	if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
X		val="$define"
X		echo "strchr() found."
X	else
X		echo "No index() or strchr() found!"
X		val="$undef"
X	fi
fi
set d_index
eval $setvar
X
X: see if memcpy exists
set memcpy d_memcpy
eval $inlibc
X
X: see if memset exists
set memset d_memset
eval $inlibc
X
X: see how we invoke the C preprocessor
echo " "
echo "Now, how can we feed standard input to your C preprocessor..."
cat <<'EOT' >testcpp.c
X#define ABC abc
X#define XYZ xyz
ABC.XYZ
XEOT
cd ..
echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
chmod 755 cppstdin
wrapper=`pwd`/cppstdin
cd UU
if test "X$cppstdin" != "X" && \
X	$cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "You used to use $cppstdin $cppminus so we'll use that again."
elif test "$cc" = gcc && \
X	(echo "Using gcc, eh?  We'll try to force gcc -E using a wrapper..."; \
X	$wrapper <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1) ; then
X	echo "Yup, we can."
X	cppstdin="$wrapper"
X	cppminus='';
elif echo 'Maybe "'"$cc"' -E" will work...'; \
X	$cc -E <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "Yup, it does."
X	cppstdin="$cc -E"
X	cppminus='';
elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
X	$cc -E - <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "Yup, it does."
X	cppstdin="$cc -E"
X	cppminus='-';
elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
X	$wrapper <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	cppstdin="$wrapper"
X	cppminus=''
X	echo "Eureka!"
elif echo 'No such luck, maybe "'$cpp'" will work...'; \
X	$cpp <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "It works!"
X	cppstdin="$cpp"
X	cppminus='';
elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
X	$cpp - <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "Hooray, it works!  I was beginning to wonder."
X	cppstdin="$cpp"
X	cppminus='-';
elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
X	$cc -P <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "Yipee, that works!"
X	cppstdin="$cc -P"
X	cppminus='';
elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
X	$cc -P - <testcpp.c >testcpp.out 2>&1; \
X	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
X	echo "At long last!"
X	cppstdin="$cc -P"
X	cppminus='-';
else
X	dflt=''
X	rp="No dice.  I can't find a C preprocessor.  Name one:"
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 and rerun Configure."
X		exit 1
X	fi
fi
X$rm -f testcpp.c testcpp.out
X
X: get C preprocessor symbols handy
echo " "
echo $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know
X$cat <<EOSS >Cppsym
X$startsh
case "\$1" in
X-l) list=true
X    shift
X    ;;
esac
unknown=''
case "\$list\$#" in
X1|2)
X    for sym do
X	if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
X	    exit 0
X	elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
X		:
X	else
X	    unknown="\$unknown \$sym"
X	fi
X    done
X    set X \$unknown
X    shift
X    ;;
esac
case \$# in
X0) exit 1;;
esac
echo \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\
X#ifdef \1\\
exit 0; _ _ _ _\1\\	 \1\\
X#endif\\
X/' >Cppsym\$\$
echo exit 1 >>Cppsym\$\$
X$cppstdin $cppminus <Cppsym\$\$ >Cppsym2\$\$
case "\$list" in
true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
X*)
X    sh Cppsym2\$\$
X    status=\$?
X    ;;
esac
X$rm -f Cppsym\$\$ Cppsym2\$\$
exit \$status
XEOSS
chmod +x Cppsym
X$eunicefix Cppsym
echo "Your C preprocessor defines the following symbols:"
Cppsym -l $attrlist >Cppsym.true
X$cat Cppsym.true
rmlist="$rmlist Cppsym Cppsym.know Cppsym.true"
X
X: see if this is a termio system
val="$undef"
val2="$undef"
val3="$undef"
if $test -r $usrinc/termios.h ; then
X	set tcsetattr i_termios
X	eval $inlibc
X	val3="$i_termios"
fi
echo " "
case "$val3" in
X"$define") echo "You have POSIX termios.h... good!";;
X*) if Cppsym pyr; then
X		case "`bin/universe`" in
X		ucb) if $test -r $usrinc/sgtty.h; then
X				val2="$define"
X				echo "<sgtty.h> found."
X			else
X				echo "System is pyramid with BSD universe."
X				echo "<sgtty.h> not found--you could have problems."
X			fi;;
X		*) if $test -r $usrinc/termio.h; then
X				val="$define"
X				echo "<termio.h> found."
X			else
X				echo "System is pyramid with USG universe."
X				echo "<termio.h> not found--you could have problems."
X			fi;;
X		esac
X	elif usg; then
X		if $test -r $usrinc/termio.h ; then
X			echo "<termio.h> found."
X			val="$define"
X		elif $test -r $usrinc/sgtty.h ; then
X			echo "<sgtty.h> found."
X			val2="$define"
X		else
X			echo "Neither <termio.h> nor <sgtty.h> found--you could have problems."
X		fi
X	else
X		if $test -r $usrinc/sgtty.h ; then
X			echo "<sgtty.h> found."
X			val2="$define"
X		elif $test -r $usrinc/termio.h ; then
X			echo "<termio.h> found."
X			val="$define"
X		else
X			echo "Neither <sgtty.h> nor <termio.h> found--you could have problems."
X		fi
X	fi;;
esac
set i_termio; eval $setvar
val=$val2; set i_sgtty; eval $setvar
val=$val3; set i_termios; eval $setvar
X
X: see if ioctl defs are in sgtty/termio or sys/ioctl
echo " "
if $test -r $usrinc/sys/ioctl.h ; then
X    val="$define"
X    echo "<sys/ioctl.h> found."
else
X    val="$undef"
X	$test $i_termio = "$define" && xxx="termio.h"
X	$test $i_termios = "$define" && xxx="termios.h"
X	$test $i_sgtty = "$define" && xxx="sgtty.h"
X	echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>."
fi
set i_sysioctl
eval $setvar
X
X: see if signal is declared as pointer to function returning int or void
echo " "
X$cppstdin $cppminus $cppflags < $usrinc/signal.h >$$.tmp
if $contains 'int.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
X    echo "You have int (*signal())() instead of void."
X	val="$undef"
X	signal_t="int"
elif $contains 'void.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
X    echo "You have void (*signal())() instead of int."
X    val="$define"
X	signal_t="void"
elif $contains 'extern[ 	]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
X    echo "You have int (*signal())() instead of void."
X	val="$undef"
X	signal_t="int"
else
X	case "$d_voidsig" in
X	'') echo "I can't determine whether signal handler returns void or int..."
X		dflt=void
X		rp="What type does your signal handler returns?"
X		. myread
X		case "$ans" in
X		void) val="$define"; signal_t="void";;
X		*) val="$undef"; signal_t="int";;
X		esac;;
X	*) echo "As you already told me, signal handler returns $signal_t.";;
X	esac
fi
set d_voidsig
eval $setvar
X$rm -f $$.tmp
X
X: check for void type
echo " "
X$cat <<EOM
Checking 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
case "$voidflags" in
X'')
X    $cat >try.c <<'EOCP'
X#if TRY & 1
void main() {
X#else
main() {
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 to the level $package wants ($defvoidused)."
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 has not 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
esac
dflt="$voidflags";
rp="Your void support flags add up to what?"
X. myread
voidflags="$ans"
X$rm -f try.* .out
X
X: preserve RCS keywords in files with variable substitution, grrr
Id='$Id'
Log='$Log'
X
X: determine where public executables go
case "$bin" in
X'')
X    dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
X    ;;
X*)  dflt="$bin"
X    ;;
esac
cont=true
while $test "$cont" ; do
X    echo " "
X    rp="Where do you want to put the public executables? (~name ok)"
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?"
X	. myread
X	dflt=''
X	case "$ans" in
X	y*) cont='';;
X	esac
X    fi
done
X
X: see if we need -o option for tar
echo " "
case "$d_taropt_o" in
X'') if $test -f "$tar"; then
X		if $tar -cf - /dev/null 2>/dev/null | $tar -xof - >/dev/null 2>&1; then
X			val="$define"
X		else
X			val="$undef"
X		fi
X	else
X		val="$undef"
X	fi;;
X*) val="$d_taropt_o";;
esac
case "$val" in
X"$define") echo "I'll use the -o option with tar upon archive extraction.";;
X*) echo "Your tar does not seem to support the -o option. I'll ignore it then.";;
esac
set d_taropt_o
eval $setvar
X
X: determine default editor
case "$defeditor" in
X'')
X    case "$_vi" in
X    */*) dflt="$_vi";;
X    *) dflt=/usr/ucb/vi;;
X    esac
X    ;;
X*)  dflt="$defeditor"
X    ;;
esac
cont=true
while $test "$cont" ; do
X	echo " "
X	rp="What is the default editor on your system?"
X	. myread
X	defeditor="$ans"
X	if test -f $ans; then
X		cont=''
X	else
X		dflt=n
X		rp="File $ans doesn't exist.  Use that name anyway?"
X		. myread
X		dflt=''
X		case "$ans" in
X		y*) cont='';;
X		esac
X	fi
done
X
X: determine the name of a reasonable mailer
case "$mailer" in
X'')
X	if $test -f "$sendmail"; then
X		dflt="$sendmail"
X	elif $test -f "$rmail"; then
X		dflt="$rmail"
X	elif $test -f /bin/mail; then
X		dflt=/bin/mail
X	else
X		dflt=$mail
X	fi
X	;;
X*)  dflt="$mailer";;
esac
cont=true
while $test "$cont" ; do
X	cat <<EOM
X
I need the full pathname of the program used to deliver mail on your system.
A typical answer would be /usr/lib/sendmail or /bin/rmail, but you may choose
any other program, as long as $package can feed its standard input.
X
XEOM
X	rp="Mail transport agent to be used?"
X	. myread
X	mailer="$ans"
X	if test -f $ans; then
X		cont=''
X	else
X		dflt=n
X		rp="File $ans doesn't exist.  Use that name anyway?"
X		. myread
X		dflt=''
X		case "$ans" in
X		y*) cont='';;
X		esac
X	fi
done
X
X: determine where manual pages go
X$cat <<EOM
X
X$package has manual pages available in source form.
XEOM
case "$nroff" in
nroff)
X	echo "However, you don't have nroff, so they're probably useless to you."
X	case "$mansrc" in
X	'') mansrc="none";;
X	esac;;
esac
echo "If you don't want the manual sources installed, answer 'none'."
case "$mansrc" in
X'')
X    dflt="$sysman"
X    ;;
X*)  dflt="$mansrc"
X    ;;
esac
cont=true
while $test "$cont" ; do
X    echo " "
X    rp="Where do the manual pages (source) go? (~name ok)"
X    . myread
X	case "$ans" in
X	'none') mansrc=''
X		cont='';;
X	*)
X		mansrc=`filexp "$ans"`
X		if test -d "$mansrc"; then
X			cont=''
X		else
X			dflt=n
X			rp="Directory $mansrc doesn't exist.  Use that name anyway?"
X			. myread
X			dflt=''
X			case "$ans" in
X			y*) cont='';;
X			esac
X		fi;;
X	esac
done
case "$mansrc" in
X'') manext='0';;
X*l) manext=l;;
X*n) manext=n;;
X*o) manext=l;;
X*p) manext=n;;
X*C) manext=C;;
X*L) manext=L;;
X*) manext=1;;
esac
X
X: decide how portable to be
case "$d_portable" in
X"$define") dflt=y;;
X*)	dflt=n;;
esac
X$cat <<'EOH'
X 
I can set things up so that your shell scripts and binaries are more portable,
at what may be a noticable cost in performance.  In particular, if you
ask to be portable, the following happens:
X
X     1) Shell scripts will rely on the PATH variable rather than using
X	the paths derived above.
X     2) ~username interpretations will be done at run time rather than
X	by Configure.
X
XEOH
rp="Do you expect to run these scripts and binaries on multiple machines?"
X. myread
case "$ans" in
X    y*) d_portable="$define"
X	for file in $loclist; do
X	    eval $file=$file
X	done
X	;;
X    *)  d_portable="$undef" ;;
esac
X
X: determine where private executables go
case "$privlib" in
X'')
X    dflt=/usr/lib/$package
X    test -d /usr/local/lib && dflt=/usr/local/lib/$package
X    ;;
X*)  dflt="$privlib"
X    ;;
esac
X$cat <<EOM
X
The $package package has some auxiliary files that should be put in a library
that is accessible by everyone.  Where do you want to put these "private" but
accessible files?
X
XEOM
rp="Private library path? (~name ok)"
X. myread
privlib="$ans"
case "$d_portable" in
X"$undef")
X    privlib=`filexp $privlib`
X    ;;
esac
X
X: determine where public executables go
case "$scriptdir" in
X'')
X    dflt="$bin"
X    : guess some guesses
X    $test -d /usr/share/scripts && dflt=/usr/share/scripts
X    $test -d /usr/share/bin && dflt=/usr/share/bin
X    ;;
X*)  dflt="$scriptdir"
X    ;;
esac
cont=true
X$cat <<EOM
X 
Some installations have a separate directory just for executable scripts so
that they can mount it across multiple architectures but keep the scripts in
one spot.  You might, for example, have a subdirectory of /usr/share for this.
Or you might just lump your scripts in with all your other executables.
X 
XEOM
while $test "$cont" ; do
X    rp="Where do you keep publicly executable scripts? (~name ok)"
X    . myread
X    scriptdir="$ans"
X    scriptdir=`./filexp "$scriptdir"`
X    if $test -d $scriptdir; then
X	cont=''
X    else
X	case "$fastread" in
X	yes) dflt=y;;
X	*) dflt=n;;
X	esac
X	rp="Directory $scriptdir doesn't exist.  Use that name anyway?"
X	. myread
X	dflt=''
X	case "$ans" in
X	y*) cont='';;
X	esac
X    fi
done
X
echo " "
echo "End of configuration questions."
echo " "
X
X: create config.sh file
echo " "
if test -d ../UU; then
X    cd ..
fi
echo "Creating config.sh..."
X$spitshell <<EOT >config.sh
X$startsh
X#
X# This file was produced by running the Configure script. It holds all the
X# definitions figured out by Configure. Should you modify one of these values,
X# do not forget to propagate your changes by running "Configure -d". You may
X# instead choose to run each of the .SH files by yourself.
X#
X
d_eunice='$d_eunice'
d_xenix='$d_xenix'
d_bsd='$d_bsd'
define='$define'
eunicefix='$eunicefix'
Mcc='$Mcc'
awk='$awk'
bison='$bison'
cat='$cat'
chgrp='$chgrp'
chmod='$chmod'
chown='$chown'
compress='$compress'
cp='$cp'
cpio='$cpio'
cpp='$cpp'
csh='$csh'
date='$date'
echo='$echo'
egrep='$egrep'
emacs='$emacs'
expr='$expr'
grep='$grep'
inews='$inews'
less='$less'
line='$line'
lint='$lint'
ln='$ln'
lp='$lp'
lpr='$lpr'
ls='$ls'
mail='$mail'
mailx='$mailx'
make='$make'
mkdir='$mkdir'
more='$more'
mv='$mv'
nroff='$nroff'
perl='$perl'
pg='$pg'
pmake='$pmake'
pr='$pr'
rm='$rm'
rmail='$rmail'
sed='$sed'
sendmail='$sendmail'
sleep='$sleep'
smail='$smail'
sort='$sort'
submit='$submit'
tail='$tail'
tar='$tar'
tbl='$tbl'
test='$test'
touch='$touch'
tr='$tr'
troff='$troff'
uname='$uname'
uniq='$uniq'
uuname='$uuname'
vi='$vi'
zcat='$zcat'
Author='$Author'
Date='$Date'
Header='$Header'
Id='$Id'
Locker='$Locker'
Log='$Log'
RCSfile='$RCSfile'
Revision='$Revision'
Source='$Source'
State='$State'
bin='$bin'
byteorder='$byteorder'
cc='$cc'
ccflags='$ccflags'
ldflags='$ldflags'
cppflags='$cppflags'
optimize='$optimize'
contains='$contains'
cppstdin='$cppstdin'
cppminus='$cppminus'
d_getopt='$d_getopt'
d_index='$d_index'
d_memcpy='$d_memcpy'
d_memset='$d_memset'
d_portable='$d_portable'
d_voidsig='$d_voidsig'
signal_t='$signal_t'
defeditor='$defeditor'
i_string='$i_string'
strings='$strings'
i_sysioctl='$i_sysioctl'
i_bsdioctl='$i_bsdioctl'
i_syssockio='$i_syssockio'
d_voidtty='$d_voidtty'
i_termio='$i_termio'
i_sgtty='$i_sgtty'
i_termios='$i_termios'
libc='$libc'
nm_opt='$nm_opt'
libpth='$libpth'
plibpth='$plibpth'
libs='$libs'
mailer='$mailer'
mansrc='$mansrc'
manext='$manext'
n='$n'
c='$c'
package='$package'
privlib='$privlib'
scriptdir='$scriptdir'
spitshell='$spitshell'
shsharp='$shsharp'
sharpbang='$sharpbang'
startsh='$startsh'
sysman='$sysman'
usrinc='$usrinc'
mips='$mips'
incpath='$incpath'
mips_type='$mips_type'
voidflags='$voidflags'
defvoidused='$defvoidused'
d_taropt_o='$d_taropt_o'
XEOT
X
X: add special variables
test -f patchlevel.h && \
awk '/^#define/ {printf "%s=%s\n",$2,$3}' patchlevel.h >>config.sh
echo "CONFIG=true" >>config.sh
X
X: propagate old symbols
if test -f UU/config.sh; then
X	<UU/config.sh sort | uniq >UU/oldconfig.sh
X	sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
X	sort | uniq -u >UU/oldsyms
X	set X `cat UU/oldsyms`
X	shift
X	case $# in
X	0) ;;
X	*)	echo "Hmm...You had some extra variables I don't know about...I'll try to keep 'em..."
X	for sym in `cat UU/oldsyms`; do
X		echo "    Propagating $hint variable "'$'"$sym..."
X		eval 'tmp="$'"${sym}"'"'
X		echo "$tmp" | \
X		sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
X	done
X	;;
X	esac
fi
X
X: Finish up
CONFIG=true
X
echo " "
dflt=''
echo "If you didn't make any mistakes, then just type a carriage return here."
rp="If you need to edit config.sh, do it as a shell escape here:"
X. UU/myread
case "$ans" in
X'') ;;
X*) : in case they cannot read
X    eval $ans;;
esac
X. ./config.sh
X
echo " "
echo "Doing variable substitutions on .SH files..."
if test -f MANIFEST; then
X	set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
else
X	set x `find . -name "*.SH" -print`
fi
shift
case $# in
X0) set x *.SH; shift;;
esac
if test ! -f $1; then
X    shift
fi
for 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
done
if 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
fi
X
if $contains '^depend:' Makefile >/dev/null 2>&1; then
X    dflt=n
X    $cat <<EOM
X
Now you need to generate make dependencies by running "make depend".
You might prefer to run it in background: "make depend > makedepend.out &"
It can take a while, so you might not want to run it right now.
X
XEOM
X    rp="Run make depend now?"
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
elif test -f [Mm]akefile; then
X    echo " "
X    echo "Now you must run a make."
else
X    echo "Done."
fi
X
X$rm -f kit*isdone
X$rm -rf UU
X: end of Configure
END_OF_FILE
if test 53615 -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 4 \(of 4\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
