#!/bin/sh
#
# This software is Copyright 1992 by Stan Barber. 
#
# Permission is hereby granted to copy, reproduce, redistribute or otherwise
# use this software as long as: there is no monetary profit gained
# specifically from the use or reproduction of this software, it is not
# sold, rented, traded or otherwise marketed, and this copyright notice is
# included prominently in any copy made. 
#
# The author make no claims as to the fitness or correctness of this software
# for any use whatsoever, and it is provided as is. Any use of this software
# is at the user's own risk. 
#
# If these # comments don't work, trim them.  Don't worry about the other
# shell scripts, Configure will trim # comments from them for you.
#
# $Id: Configure,v 1.6 1992/08/03 04:51:45 sob Exp sob $
#
# $Log: Configure,v $
# Revision 1.6  1992/08/03  04:51:45  sob
# Release version 1.6
#
#
#

# Yes, you may rip this off to use in other distribution packages.


echo "Beginning of configuration questions for the nntp client kit."
: Eunice requires " " instead of "", can you believe it
echo " "

: sanity checks
PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/bsd'
export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)

if test ! -t 0; then
    echo "Type 'sh Configure', not 'sh <Configure'"
    exit 1
fi

(alias) >/dev/null 2>&1 && \
    echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
    echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"

if test ! -d ../UU; then
    if test ! -d UU; then
	mkdir UU
    fi
    cd UU
fi

case "$1" in
-d) shift; fastread='yes';;
esac


bopt=''
n=''
c=''
libc=''
eunicefix=''
eunice=''
cpp=''
shsharp=''
spitshell=''
startsh=''
test=''
expr=''
sed=''
echo=''
cat=''
rm=''
cp=''
tr=''
mkdir=''
awk=''
inews=''
grep=''
chmod=''
egrep=''
nidump=''
ypmatch=''
seteuid=''
contains=''
lib=''
nametype=''
cc=''
iandd=''
include=''
jobslib=''
ndirlib=''
socketlib=''
posix=''
pager=''
nonetdb=''
internet=''
filexp=''
Log=''
Id=''
sitename=''
hostfile=''
domain=''
isadmin=''
newsadmin=''
mansrc=''
manext=''
rootid=''
strncasecmp=''
strcasecmp=''
strchr=''
memcpy=''
novoid=''
sunos4=''
portable=''
passnam=''
berknam=''
usgnam=''
dotdir=''
whoami=''
getpwent=''
gethostname=''
douname=''
phostname=''
hostcmd=''
serverfile=''
auth=''
authsimple=''
authold=''
passfile=''
decnet=''
datakit=''
CONFIG=''
rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
: some greps do not return status, grrr.
echo "grimblepritz" >grimble
if grep blurfldyick grimble >/dev/null 2>&1 ; then
    contains=contains
else
    if grep grimblepritz grimble >/dev/null 2>&1 ; then
	contains=grep
    else
	contains=contains
    fi
fi
rmlist="$rmlist grimble"
: the following should work in any shell
case $contains in
contains*)
    echo " "
    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
    cat >contains <<'EOSS'
grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
EOSS
chmod +x contains
esac

: first determine how to suppress newline on echo command
echo "Checking echo to see how to suppress newlines..."
(echo "hi there\c" ; echo " ") >.echotmp
if $contains c .echotmp >/dev/null 2>&1 ; then
    echo "...using -n."
    n='-n'
    c=''
else
    cat <<'EOM'
...using \c
EOM
    n=''
    c='\c'
fi
echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
read ans
rm .echotmp

: now set up to do reads with possible shell escape and default assignment
cat <<EOSC >myread
case "\$fastread" in
yes) ans=''; echo " " ;;
*) ans='!';;
esac
while expr "X\$ans" : "X!" >/dev/null; do
    read ans
    case "\$ans" in
    !)
	sh
	echo " "
	echo $n "\$rp $c"
	;;
    !*)
	set \`expr "X\$ans" : "X!\(.*\)\$"\`
	sh -c "\$*"
	echo " "
	echo $n "\$rp $c"
	;;
    esac
done
rp='Your answer:'
case "\$ans" in
'') ans="\$dflt";;
esac
EOSC

: general instructions
cat <<'EOH'
 
This installation shell script will examine your system and ask you questions
to determine how the nntp client kit and the nntp client inews will be
configured.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.

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)".

Much effort has been expended to ensure that this shell script will run
on any Unix system.  If despite that it blows up on you, your best bet is to
edit Configure and run it again.  Also, tell Stan Barber (nntp@tmc.edu)
how he blew it.

This installation script affects things by doing direct variable substitutions
on some of the files included in this kit. You may edit any of these files as
the need arises after running this script.

EOH
echo $n "[Type carriage return to continue] $c"
. myread
Xn=$n
Xc=$c
: get old answers, if there is a config file out there
if test -f ../config.sh; then
    echo " "
    dflt=y
    rp="I see a config.sh file.  Do you want to use it to set the defaults? [$dflt]"
    echo $n "$rp $c"
    . myread
    case "$ans" in
    n*) echo "OK, I'll ignore it.";;
    *)  echo "Fetching default answers from your old config.sh file..."
	tmp="$n"
	ans="$c"
        . ../config.sh
	n="$tmp"
	c="$ans"
	;;
    esac
fi

n=$Xn
c=$Xc

: get list of predefined functions in a handy place
echo " "
if test -f /lib/libc.a; then
    echo "Your C library is in /lib/libc.a.  You're normal."
    libc=/lib/libc.a
else
    if test -f /lib/Llibc.a; then
	echo "Your C library is in /lib/Llibc.a.  I smell Xenix!"
	libc=/lib/Llibc.a
    else
	if test -f /usr/lib/libc.a; then
	    echo "Your C library is in /usr/lib/libc.a, of all places."
	    libc=/usr/lib/libc.a
	else
	    if test -f /lib/clib; then
		echo "Your C library is in /lib/clib.  How nonstandard, must be Apollo."
		libc=/lib/clib
	    else
		if test -f "$libc"; then
		    echo "Your C library is in $libc, like you said before."
		else
		    cat <<'EOM'
 
I can't seem to find your C library.  I've looked for /lib/libc.a and
/usr/lib/libc.a, but neither of those are there. Perhaps you can find
out by reading `man 3 intro' if you have the 'man' facility installed.

EOM
		    echo $n "What is the full name of your C library? $c"
		    . myread
		    libc="$ans"
		fi
	    fi
	fi
    fi
fi

if test -d /usr/bsd43 -o -d /usr/bsd ; then
    echo " "
    echo "It appears that you might be running on a RISC/os box."
    echo $n "Should I pass the -B option to nm [y]? $c"
    . myread
    case $ans in
	n*|f*) bopt=''   ;;
	*)     bopt='-B' ;;
    esac
fi
if test -f /bin/smit ; then
    echo " "
    echo "It appears that you might be running on an IBM RS/6000 box."
    echo "We'll be using 'nm -B' to get the symbol lists."
    bopt='-B'
fi

echo " "
echo $n "Extracting names from $libc for later perusal...$c"
nm $bopt $libc > nm.list 2>/dev/null
sed -n -e 's/^.* T _//p' -e 's/^.* T //p' < nm.list > libc.list
if $contains '^printf$' libc.list >/dev/null 2>&1; then
    echo "done"
else
    sed -n -e 's/^.* D _//p' -e 's/^.* D //p' < nm.list > libc.list
    if $contains '^printf$' libc.list >/dev/null 2>&1; then
	echo "done"
    else
	 $contains .text nm.list | grep -v static | awk '{ print $1 }' > libc.list
    	if $contains '^printf$' libc.list >/dev/null 2>&1; then
		echo "done"
    	else
	     echo " "
	     echo "nm didn't seem to work right."
	     echo "Trying ar instead..."
	     if ar t $libc | sed -e 's/\.o$//' > libc.list; then
		echo "Ok."
	     else
		echo "That didn't work either.  Giving up."
		exit 1
	     fi
	 fi
    fi
fi
rm nm.list
: make some quick guesses about what we are up against
echo " "
echo $n "Hmm...  $c"
if $contains '^sigvec$' libc.list >/dev/null 2>&1 ; then
    echo "Looks kind of like a BSD system, but we'll see..."
    echo exit 0 >bsd
    echo exit 1 >usg
    echo exit 1 >v7
else
    if $contains '^dup2$' libc.list >/dev/null 2>&1 ; then
	echo "Looks sort of like a V7 system, but we'll see..."
	echo exit 1 >bsd
	echo exit 1 >usg
	echo exit 0 >v7
    else
	    echo "Looks kind of like a USG system, but we'll see..."
	    echo exit 1 >bsd
	    echo exit 0 >usg
	    echo exit 1 >v7
    fi
fi
:
if test -f /etc/inittab; then
    echo "You have an inittab file. You must be a USG system!"
    echo exit 1 >bsd
    echo exit 0 >usg
    echo exit 1 >v7
fi
if $contains '^vmssystem$' libc.list >/dev/null 2>&1 ; then
    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.
EOI
    echo "exit 0" >eunice
    eunicefix=unixtovms
    eunice=define
: it so happens the Eunice I know will not run shell scripts in Unix format
else
    echo " "
    echo "Congratulations.  You aren't running Eunice."
    eunicefix=':'
    eunice=undef
    echo "exit 1" >eunice
fi
rmlist="$rmlist libc.list bsd usg v7 eunice"
chmod +x bsd usg v7 eunice
$eunicefix bsd usg v7 eunice
: see how we invoke the C preprocessor
echo " "
echo "Checking to see how your C preprocessor is invoked..."
cat <<'EOT' >testcpp.c
#define ABC abc
#define XYZ xyz
ABC+XYZ
EOT
echo 'Maybe "cc -E" will work...'
cc -E testcpp.c >testcpp.out 2>&1
if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
    echo "Yup, it does."
    cpp='cc -E'
else
    echo 'Nope...maybe "cc -P" will work...'
    cc -P testcpp.c >testcpp.out 2>&1
    if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
	echo "Yup, that does."
	cpp='cc -P'
    else
	echo 'Nixed again...maybe "/lib/cpp" will work...'
	/lib/cpp testcpp.c >testcpp.out 2>&1
	if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
	    echo "Hooray, it works!  I was beginning to wonder."
	    cpp='/lib/cpp'
	else
	    if $contains 'abc +xyz' testcpp.out >/dev/null 2>&1 ; then
		echo "Found it!  You're on a NeXT, aren't you?"
		cpp='/lib/cpp'
	    else
		echo 'Hmm...maybe you already told me...'
		case "$cpp" in
		'') ;;
		*) $cpp testcpp.c >testcpp.out 2>&1;;
		esac
		if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
		    echo "Hooray, you did!  I was beginning to wonder."
		else
		    echo "Nope. I can't find a C preprocessor.  Name one: $c"
		    . myread
		    cpp="$ans"
		    $cpp testcpp.c >testcpp.out 2>&1
		    if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then
			echo "OK, that will do."
		    else
			echo "Sorry, I can't get that to work.  Go find one."
			exit 1
		    fi
		fi
	    fi
	fi
    fi
fi
rm -f testcpp.c testcpp.out
: 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
    echo "Your sh handles # comments correctly."
    shsharp=true
    spitshell=cat
    echo " "
    echo "Okay, let's see if #! works on this system..."
    echo "#!/bin/echo hi" > try
    $eunicefix try
    chmod +x try
    try > today
    if test -s today; then
	echo "It does."
	sharpbang='#!'
    else
	echo "#! /bin/echo hi" > try
	$eunicefix try
	chmod +x try
	try > today
	if test -s today; then
	    echo "It does."
	    sharpbang='#! '
	else
	    echo "It doesn't."
	    sharpbang=': use '
	fi
    fi
else
    echo "Your sh doesn't grok # comments--I will strip them later on."
    shsharp=false
    echo "exec grep -v '^#'" >spitshell
    chmod +x spitshell
    $eunicefix spitshell
    spitshell=`pwd`/spitshell
    echo "I presume that if # doesn't work, #! won't work either!"
    sharpbang=': use '
fi

: 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
$startsh
set abc
test "$?abc" != 1
EOSS

chmod +x try
$eunicefix try
if try; then
    echo "Yup, it does."
else
    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
fi
rm -f try today

: find out where common programs are
echo " "
echo "Locating common programs..."
pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /usr/etc /usr/5bin /usr/bsd /usr/bsd43"
cat <<EOSC >loc
$startsh
thing=\$1
shift
dflt=\$1
shift
for dir in \$*; do
    case "\$thing" in
    .)
	if test -d \$dir/\$thing; then
	    echo \$dir
	    exit 0
	fi
	;;
    *)
	if test -f \$dir/\$thing; then
	    echo \$dir/\$thing
	    exit 0
	fi
	;;
    esac
done
echo \$dflt
exit 1
EOSC
chmod +x loc
$eunicefix loc
loclist="expr sed echo cat rm cp tr mkdir grep awk chmod"
trylist="test inews egrep more pg Mcc nidump ypmatch"
for file in $loclist; do
    xxx=`loc $file $file $pth`
    eval $file=$xxx
    case "$xxx" in
    /*)
	echo $file is in $xxx.
	;;
    *)
	echo "I don't know where $file is.  I hope it's in everyone's PATH."
	;;
    esac
done
echo " "
echo "Don't worry if any of the following aren't found..."
for file in $trylist; do
    xxx=`loc $file $file $pth`
    eval $file=$xxx
    case "$xxx" in
    /*)
	echo $file is in $xxx.
	;;
    *)
	echo "I don't see $file out there, offhand."
	;;
    esac
done
rmlist="$rmlist loc"
case $egrep in
egrep)
    echo "Substituting grep for egrep."
    egrep=$grep
    ;;
esac
case $test in
test)
    echo "Hopefully test is built into your sh."
    ;;
/bin/test)
    echo " "
    echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c"
    . myread
    case $ans in
    y*) test=test ;;
    esac
    ;;
*)
    test=test
    ;;
esac
case $echo in
echo)
    echo "Hopefully echo is built into your sh."
    ;;
/bin/echo)
    echo " "
    echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
    $echo $n "hi there$c" >foo1
    echo $n "hi there$c" >foo2
    if cmp foo1 foo2 >/dev/null 2>&1; then
	echo "They are compatible.  In fact, they may be identical."
    else
	echo "They are not compatible--the echo builtin will be used."
	echo=echo
    fi
    $rm -f foo1 foo2
    ;;
*)
    echo=echo
    ;;
esac
: socket lib hack
if $test ! "X$socketlib" = X ; then
	if $test -f /usr/lib/libsocket.a ; then
		socketlib=-lsocket
	fi
fi
: check for pdp11
$echo " "
$cat <<'EOT' >pdp11.c
#ifdef pdp11
exit 0
#else
exit 1
#endif
EOT
$cpp pdp11.c | grep exit >pdp11
$chmod +x pdp11
$eunicefix pdp11
$rm pdp11.c
if pdp11; then
    $echo "This looks like a pdp11 to me."
fi
: check for ultrix
$cat <<'EOT' >ultrix.c
#ifdef ultrix
exit 0
#else
exit 1
#endif
EOT
$cpp ultrix.c | grep exit >ultrix
$chmod +x ultrix
$eunicefix ultrix
$rm ultrix.c
if ultrix; then
    echo "Running ultrix, eh?"
    if $test -f /usr/lib/libdnet.a; then
    decnetpossible=define
    fi
fi

: check for uts
$cat <<'EOT' >uts.c
#ifdef uts
exit 0
#else
exit 1
#endif
EOT
$cpp uts.c | grep exit >uts
chmod +x uts
$eunicefix uts
$rm uts.c
if uts; then
    $echo "This appears to be some kind of System370-type system running UTS."
    socketlib=-lsocket
fi

: check for sun 4.0
sunos4=undef
$cat <<'EOT' >sun.c
#ifdef sun
exit 0
#else
exit 1
#endif
EOT
$cpp sun.c | grep exit >sun
$chmod +x sun
$eunicefix sun
$rm sun.c
if sun; then
    echo "This looks like a sun to me."
    if $test -f /etc/ld.so.cache ; then
	$echo "And it appears you are running SunOS 4.0 or greater."
        sunos4=define
	socketlib=
	include=
     fi
fi
: check for hp-ux
$cat <<'EOT' >hp-ux.c
#ifdef hpux
exit 0
#else
exit 1
#endif
EOT
$cpp hp-ux.c | $grep exit >hp-ux
$chmod +x hp-ux
$eunicefix hp-ux
rm hp-ux.c
if hp-ux; then
    $echo "Hewlett-Packard must have built this..."
    socketlib=-lbsdipc
fi

: check for mips
$cat <<'EOT' >mips.c
#if defined(mips) && !defined(ultrix)
exit 0
#else
exit 1
#endif
EOT
$cpp mips.c | grep exit >mips
chmod +x mips
$eunicefix mips
$rm mips.c
if mips; then
    echo "Looks like mips RISC/os..."
	include="-I/usr/include/bsd"
	socketlib=-lbsd
fi
: check for stardent
$cat <<'EOT' >stardent.c
#if defined(stardent) || defined(ardent) || defined (steller)
exit 0
#else
exit 1
#endif
EOT
$cpp stardent.c | grep exit >stardent
$chmod +x stardent
$eunicefix stardent
$rm stardent.c
if stardent; then
    echo "This appears to be a Stardent/Steller/Ardent/Kubota Pacific..."
	socketlib=
	include=
fi

: check for DGUX
$cat <<'EOT' >DGUX.c
#ifdef DGUX
exit 0
#else
exit 1
#endif
EOT
$cpp DGUX.c | grep exit >DGUX
$chmod +x DGUX
$eunicefix DGUX
$rm DGUX.c
if DGUX; then
    echo "This appears to be a DG AViiON..."
fi

: check for sgi
$cat <<'EOT' >sgi.c
#ifdef sgi
exit 0
#else
exit 1
#endif
EOT
$cpp sgi.c | grep exit >sgi
$chmod +x sgi
$eunicefix sgi
$rm sgi.c
if sgi; then
    $echo "Silicon Graphics must have built this..."
    if test -f /usr/lib/libsun.a ; then
 	socketlib=-lsun
    fi
    if $test -f /usr/lib/libdn.a; then
    	decnetpossible=define
    fi
fi

: check for XENIX
$cat <<'EOT' >xenix
test -f /xenix; exit $?
EOT
$chmod +x xenix
$eunicefix xenix
if xenix; then
    $echo "Kinda looks like XENIX....hmmm"
	include="-DUSG -DLAI_TCP"
	socketlib=-lsocket
	rdchk=define
	dirtype=dirent
	dirinc="<dirent.h>"
else
	rdchk=undef
fi

: check for Pyramid OSx
$cat <<'EOT' >pyr.c
#ifdef pyr
exit 0
#else
exit 1
#endif
EOT
$cpp pyr.c | grep exit >pyr
$chmod +x pyr
$eunicefix pyr
$rm pyr.c
if pyr; then
    echo "This looks like a Pyramid to me."
fi

: check for NeXT
$cat <<'EOT' >next.c
#ifdef NeXT
exit 0
#else
exit 1
#endif
EOT
$cpp next.c | grep exit >next
$chmod +x next
$eunicefix next
$rm next.c
if next; then
    $echo "My, you really ARE on a NeXT."
    addcflags='-bsd'
    test=test
fi

cat <<'EOT' > s5uniq
if test -f /bin/uname
then
    case `uname -r -m` in
	"5.3 vax-"*)
		if [ -f /usr/lib/libnet.a \
		  -a -f /usr/lib/libhdb.a \
		  -a -f /usr/lib/libbbn.a \
		  -a -f /usr/lib/libstr.a ]
		then
			exit 0
		fi;;
    esac
fi
exit 1
EOT
$chmod +x s5uniq
if s5uniq; then
    $echo "This looks like Uniq.  What a pity."
    socketlib="-lnet -lhdb -lbbn -lstr"
    include="-DR_UNIQ"
fi
: check for posix
posix=''
if usg; then
    addcflags='-DUSG'
    if $test -f /lib/libcposix.a; then
    $echo "Your version of System V supports POSIX compatibility."
    $echo "We'll make use of it!"
    posix='-Xp'
    fi
fi
rmlist="$rmlist next sgi sun ultrix s5uniq pyr mips pdp11 stardent xenix"
rmlist="$rmlist uts hp-ux DGUX"
$echo " "
: test yp
case $ypmatch in
ypmatch)
    $echo "I don't see ypmatch out there, so YP is not available. We'll search the"
    $echo "passwd file the old fashioned way!"
    ;;
*)
    $ypmatch 513/tcp services > /dev/null 2>/dev/null
    status=$?
    if $test $status  -ne 0 ; then
	$echo "YP installed, but not operational. We won't use it."
	ypmatch=""
    else
    	$echo "YP installed and operational."
    fi
    
    ;;
esac
if $test "$nidump" = "nidump"; then
    nidump=""
fi
if $test "$ypmatch" = "ypmatch"; then
    ypmatch=""
fi
 
: decide how portable to be
case "$portable" in
define) dflt=y;;
*)	dflt=n;;
esac
$cat <<'EOH'
 
I can set things up so that your shell scripts and binaries are more portable,
at what may be a noticeable cost in performance.  In particular, if you
ask to be portable, the following happens:

     1) shell scripts will rely on the PATH variable rather than using
	the paths derived above.
     2) ~username interpretations will be done at run time rather than
	by Configure.
     3) the system name will be determined at run time, if at all possible.

EOH
$echo $n "Do you expect to run these scripts and binaries on multiple machines? [$dflt] $c"
. myread
case $ans in
'') ans=$dflt;;
esac
case $ans in
    y*) portable=define
	for file in $loclist; do
	    eval $file=$file
	done
	;;
    *)  portable=undef ;;
esac

: set up shell script to do ~ expansion
cat >filexp <<EOSS
$startsh
: expand filename
case \$1 in
~/*|~)
    $echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
    ;;
~*)
    if $test -f /bin/csh; then
	/bin/csh -f -c "glob \$1"
	$echo ""
    else
	name=\`$expr x\$1 : '..\([^/]*\)'\`
	if $test "$ypmatch" != ""; then
 		dir=\`$ypmatch \$name passwd 2>/dev/null | $sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/"'\`
	elif $test "$nidump" != ""; then
	    dir=\`$nidump passwd / | $sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}'\`
	fi
	if $test "\$dir" = ""; then
	    dir=\`$sed </etc/passwd -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}'\`
	fi
	if $test ! -d "\$dir"; then
	    me=\`basename \$0\`
	    $echo "\$me: can't locate home directory for: \$name" >&2
	    exit 1
	fi
	case \$1 in
	*/*)
	    $echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
	    ;;
	*)
	    $echo \$dir
	    ;;
	esac
    fi
    ;;
*)
    $echo \$1
    ;;
esac
EOSS
chmod +x filexp
$eunicefix filexp

: try to deal with domains
if $test "X$domain" = "X"; then
if $test -f /etc/resolv.conf; then
if $contains nonameserver /etc/resolv.conf >/dev/null 2>&1 ; then
domain=''
else
domain="`$contains domain /etc/resolv.conf | $awk '{ print $2 }'`"
fi
else
if $test -f /usr/etc/resolv.conf; then
if $contains nonameserver /usr/etc/resolv.conf >/dev/null 2>&1; then
domain=''
else
domain="`$contains domain /usr/etc/resolv.conf | $awk '{ print $2 }'`"
fi
fi
fi
fi
case "$domain" in
'') dflt="uucp";;
*)  dflt="$domain" ;;
esac
$cat << 'EOH'

Please enter your domain name.  This will be used in conjunction with the
site name for return addresses on news articles and mail.  If you use the
4.3ism of having your domain in your hostname, all the posting programs
will figure this out on the fly, so don't worry.

Examples of some valid domains:
	berkeley.edu
	nasa.gov
Example of an invalid domain in common use:
	uucp
EOH

$echo $n "Your domain: [$dflt] $c"
. myread
case "$ans" in
'') domain="$dflt";;
*)  domain="$ans" ;;
esac

: now get the site name
$echo " "
$echo "Figuring out site name..."
$echo 'Maybe "hostname" will work...'
if ans=`sh -c hostname 2>&1` ; then
    thissite=$ans
    hostcmd=hostname
else
    $echo 'No, maybe "uuname -l" will work...'
    if ans=`sh -c 'uuname -l' 2>&1` ; then
	thissite=$ans
	hostcmd='uuname -l'
    else
	$echo 'Strange.  Maybe "uname -n" will work...'
	if ans=`sh -c 'uname -n' 2>&1` ; then
	    thissite=$ans
	    hostcmd='uname -n'
	else
	    $echo 'Oh well, maybe I can mine it out of whoami.h...'
	    if ans=`sh -c $contains' sysname /usr/include/whoami.h' 2>&1` ; then
		thissite=`$echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'`
		hostcmd="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' </usr/include/whoami.h"
	    else
		case "$sitename" in
		'') $echo "Does this machine have an identity crisis or something?"
		    hostcmd=''
		    ;;
		*)  $echo "Well, you said $sitename before..."
		    thissite="$sitename"
		    ;;
		esac
	    fi
	fi
    fi
fi
: you do not want to know about this
set $thissite
thissite=$1

: translate upper to lower case. This is mostly to help UUCP work right.
case $thissite in
    *[A-Z]*)
	thissite=`$echo $thissite | tr '[A-Z]' '[a-z]'`
	$echo "(Normalizing case in your site name)"
	;;
esac

: verify site name and allow them to override it
if $test "$thissite" ; then
    $echo 'Your site name appears to be "'$thissite'".'
else
    thissite='unknown'
fi
case "$hostfile" in
/*) dflt="$hostfile" ;;
#*)  case "$sitename" in
#    '') dflt="$thissite" ;;
#    *)  dflt="$sitename" ;;
#    esac
*) dflt="$thissite";;
esac
$cat <<'EOM'

In some cases it is not desirable to use the actual site name in your return
addresses (if, for example, all mail gets routed first to one site).  In this
case nntp inews allows you to either hard-wire a site name or read the site
name from a file.  To indicate a file, start the name with a slash (e.g.
/etc/sitename). To use just your domain name, re-enter it here.  A period-less
site name will automatically get your domain name added to it.

EOM
while $test $dflt ; do
    $echo $n "What site name goes in return addresses? [$dflt] $c"
    . myread 
    case $ans in
    '') ans=$dflt;;
    esac
    case $ans in
    /*)
	if $test -f $ans ; then
	    hostfile="$ans"
	    hostcmd="$cat $ans"
	    sitename=`$hostcmd`
	    $echo "NNTP inews will read the site name from $ans:  $sitename."
	    dflt=''
	else
	    $echo "Unable to locate $ans."
	fi
	;;
    *)  hostfile=''
	if $test "X$thissite" = "X$ans" ; then
	    sitename="$thissite"
	    $echo "Using the site name derived by $hostcmd:  $sitename."
	else
	    hostcmd=''
	    sitename="$ans"
	    $echo "Using a hard-wired site name:  $sitename."
	fi
	dflt=''
	;;
    esac
done

if $test $portable = "undef" ; then
	case $sitename in
	*.*)	;;
	*)	sitename=$sitename.$domain
		;;
	esac
fi

: get news administrator name
case "$newsadmin" in
'')
    if $contains "^news:" /etc/passwd >/dev/null 2>&1 ; then
	dflt=news
    else
	if $contains "^usenet:" /etc/passwd >/dev/null 2>&1 ; then
	    dflt=usenet
	else
	    if eunice; then
		dflt=system
	    else
		dflt=root
	    fi
	fi
    fi
    ;;
*)  dflt="$newsadmin"
    ;;
esac
cat <<'EOM'
 
Many systems keep their news in a private directory, or have a non-superuser
in charge of administering news.  (If you don't have such a user, take the
default answer.)  What is the login name (not directory) that is used for news
EOM
$echo $n "administration? [$dflt] $c"
. myread
newsadmin="$ans"
case $newsadmin in
'') newsadmin=$dflt ;;
esac
case $newsadmin in
root) isadmin=undef ;;
*)    isadmin=define ;;
esac

: figure out news library
case "$lib" in
'')
    dflt=/usr/lib/news
    ;;
*)  dflt=$lib ;;
esac
libexp=$lib
libexp='blurfl/dyick'
while $test ! -d "$libexp"; do
    $echo " "
    case "$libexp" in
    blurfl*) ;;
    *) $echo "Directory $libexp not found";;
    esac
    $echo $n "Where is your news library (~name okay)? [$dflt] $c"
    . myread
    case "$ans" in
    '') ans="$dflt";;
    esac
    lib="$ans"
    case $lib in
    ~*)
	libexp=`filexp $lib`
	$echo "(That is $libexp on this particular system.)"
	case $portable in
	  undef) lib=$libexp ;;
	esac
	;;
    *)
	libexp=$lib
	;;
    esac
done

: determine where the nntp server file will go
case "$serverfile" in
'')
    dflt="$lib/server"
    ;;
*)  dflt="$serverfile"
    ;;
esac
$cat <<'EOM'

NNTP Clients determine the machine to use as a news server by two means:

	1. It examines the environment variable NNTPSERVER for
	   a machine name; this allows users to use server machines
	   other than the default.

	2. It looks in a file which contains the name of a server
	   machine.

You must create the file mentioned in (2), above.  Simply put the name
of the machine you wish to use as your news server in this file.
If you really want, you can use # for comments and blank lines in
this file as well.

EOM

ans='blurfl/dyick'
while $test ! -r "$ans" ; do
$echo $n "Enter the name of the news server file: [$dflt] $c"
. myread
    case "$ans" in
    '') ans="$dflt";;
    esac
    ans=`filexp "$ans"`
    if $test ! -r $ans ; then
	$echo "Can't find $ans"
	ans='blurfl/dyick'
    fi
done
serverfile="$ans"

: NNTP Version 2 Authorization
case "$auth" in
define) dflt=y;;
*)	dflt=n;;
esac
$cat << 'EOA'

The upcoming RFC for NNTP version 2 provides a feature for an NNTP server
to request the client to provide authorization before providing service.
The NNTP inews in this kit is capable of providing such an authorization
dialogue if it is requested by the server. It requires that your create
a file on your local machine that contains a line for each nntpserver
to which a posting will be sent. The format of the lines is as follows:

nntpserver username password

EOA

$echo $n "Do you want to include support for this feature? [$dflt] $c"
. myread
case $ans in
'') ans=$dflt;;
esac
case $ans in
    y*) auth=define
	authsimple=define
	;;
    *)  auth=undef
	authsimple=undef
	;;
esac

if $test $authsimple = "define" ; then
: determine where the nntp server file will go
case "$passfile" in
'')
    dflt="$lib/nntp.sys"
    ;;
*)  dflt="$passfile"
    ;;
esac
ans='blurfl/dyick'
while $test ! -r "$ans" ; do
$echo $n "Enter the name of the nntp password file: [$dflt] $c"
. myread
    case "$ans" in
    '') ans="$dflt";;
    esac
    ans=`filexp "$ans"`
    if $test ! -r $ans ; then
	$echo "Can't find $ans"
	ans='blurfl/dyick'
    fi
done
passfile="$ans"
else
passfile=''
fi
if $test $authsimple = "define" ; then
: OLD NNTP Authorization
case "$authold" in
define) dflt=y;;
*)	dflt=n;;
esac
$cat << 'EOLDAUTH'

Version 1.5.7 through version 1.5.11 of the NNTP daemon supported a
test version of the authentication protocol.

EOLDAUTH

$echo $n "Do you want to include support for the old authentication mechanism? [$dflt] $c"
. myread
case $ans in
'') ans=$dflt;;
esac
case $ans in
    y*) authold=define
	;;
    *)  authold=undef
	;;
esac
else
	authold=undef
fi


: DOT_DIR Support
case "$dotdir" in
define) dflt=y;;
*)	dflt=n;;
esac
$cat << 'EOB'

Rn and its relatives support the environmental variable DOT_DIR to provide
users with the ability to put the .signature file somewhere other than
the home directory. The NNTP inews can support this feature as well.

EOB

$echo $n "Do you want to include support for this feature? [$dflt] $c"
. myread
case $ans in
'') ans=$dflt;;
esac
case $ans in
    y*) dotdir=define ;;
    *)  dotdir=undef ;;
esac

if $test "X$decnetpossible" = "Xdefine" ; then
: DECNET support
case "$decnet" in
define) dflt=y;;
*)	dflt=n;;
esac
$cat << 'EOD'

The client library and NNTP inews can run over DECNET as well as TCP/IP.
Please see the file README.DECNET for the details of setting up the DECNET
environment after you have built and installed the NNTP inews.

EOD

$echo $n "Do you want to include support for this feature? [$dflt] $c"
. myread
case $ans in
'') ans=$dflt;;
esac
case $ans in
    y*) decnet=define
	if ultrix; then
		socketlib="-ldnet $socketlib"
		include="-DDECNET"
	fi
	if sgi; then
		socketlib="-ldn $socketlib"
		include="$include -DSGI4DDN"
	fi
	 ;;
    *)  decnet=undef ;;
esac
else
	decnet=undef
fi
: determine where manual pages go
case "$mansrc" in
'')
    dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
    ;;
*)  dflt="$mansrc"
    ;;
esac
mansrc='blurfl/dyick'
while $test ! -d "$mansrc" ; do
    case $mansrc in
      blurfl*) ;;
      *) $echo "$mansrc does not appear to exist." ;;
    esac
    $echo " "
    $echo $n "Where do the manual pages (source) go? [$dflt] $c"
    . myread
    mansrc=`filexp "$ans"`
    case $mansrc in
      '') mansrc=$dflt ;;
    esac
done
case "$mansrc" in
*l)
    manext=l
    ;;
*n)
    manext=n
    ;;
*)
    manext=1
    ;;
esac

: find out how to find out full name
$echo " "
case "$berknam" in
define)
    dflt=y;;
undef)
    dflt=n;;
*)
    if bsd || xenix; then
	dflt=y
    else
	dflt=n
    fi
    ;;
esac
$echo "Does your /etc/passwd file keep full names in Berkeley/V7 format (name first"
$echo $n "thing after ':' in GCOS field)? [$dflt] $c"
. myread
case $ans in
  '') ans=$dflt ;;
esac
case $ans in
  y*)
    passnam=define
    berknam=define
    usgnam=undef
    nametype=bsd
    ;;
  *)
    $echo " "
    case "$usgnam" in
    define)
	dflt=y;;
    undef)
	dflt=n;;
    *)
	if usg; then
	    dflt=y
	else
	    dflt=n
	fi
	;;
    esac
    $echo "Does your passwd file keep full names in USG format (name sandwiched"
    $echo $n "between a '-' and a '(')? [$dflt] $c"
    . myread
    case $ans in
      '') ans=$dflt ;;
    esac
    case $ans in
      n*)
	$echo "Full name will be taken from ~/.fullname"
	passnam=undef
	berknam=undef
	usgnam=undef
	nametype=other
	;;
      *)
	passnam=define
	berknam=undef
	usgnam=define
	nametype=usg
	;;
    esac
    ;;
esac

: see if we need a special compiler
$echo " "
if usg; then
    case "$cc" in
    '')
	case "$Mcc" in
	/*) dflt='Mcc'
	    ;;
	*)
	    if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
		dflt='cc -M'
	    else
		dflt='cc'
	    fi
	    ;;
	esac
	;;
    *)  dflt="$cc";;
    esac
    $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.  What command will force resolution on
EOM
    $echo $n "this system? [$dflt] $c"
    . myread
    cc="$ans"
    case "$cc" in
	'') cc="$dflt" ;;
    esac
else
    $echo "Not a USG system--assuming cc can resolve multiple definitions."
    cc=cc
fi

: see if we should throw a -i into the Makefile
$echo " "
if pdp11; then
    if $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1 ; then
	$echo $n "Your system appears to have separate I and D space.  Is this true? [y] $c"
	. myread
	case $ans in
	    n*|f*) iandd='' ;;
	    *)     iandd='-i' ;;
	esac
    else
	$echo "Your system appears to NOT have separate I and D space."
	$echo $n "Is this correct? [y] $c"
	. myread
	case $ans in
	    n*|f*) iandd='-i' ;;
	    *)     iandd='' ;;
	esac
    fi
else
    $echo "Not a pdp11--assuming no separate I and D."
fi

: index or strcpy
$echo " "
if $contains '^index$' libc.list >/dev/null 2>&1 ; then
    $echo "Your system appears to use index() and rindex() rather than strchr()"
    $echo $n "and strrchr().  Is this correct? [y] $c"
    . myread
    case $ans in
	n*|f*) strchr='define' ;;
	*)     strchr='undef' ;;
    esac
else
    $echo "Your system appears to use strchr() and strrchr() rather than index()"
    $echo $n "and rindex().  Is this correct? [y] $c"
    . myread
    case $ans in
	n*|f*) strchr=undef ;;
	*)     strchr=define ;;
    esac
fi

: bcopy/bzero or memcpy/memset
$echo " "
if $contains '^bcopy$' libc.list >/dev/null 2>&1 ; then
    $echo "Your system appears to use bcopy() and bzero() rather than memcpy()"
    $echo $n "and memset().  Is this correct? [y] $c"
    . myread
    case $ans in
	n*|f*) memcpy='define' ;;
	*)     memcpy='undef' ;;
    esac
else
    $echo "Your system appears to use memcpy() and memset() rather than bcopy()"
    $echo $n "and bzero().  Is this correct? [y] $c"
    . myread
    case $ans in
	n*|f*) memcpy='undef' ;;
	*)     memcpy='define' ;;
    esac
fi

: see if there is a whoami file
if $test -r /usr/include/whoami.h ; then
    whoami=define
    $echo "whoami.h found."
else
    whoami=undef
fi

: see if this system has fcntl
if $test -r /usr/include/fcntl.h ; then
    fcntl=define
    $echo "fcntl.h found."
else
    fcntl=undef
    $echo "No fcntl.h found, but that's ok."
fi

: see if YP could be running here
if $contains 'yp_master$' libc.list >/dev/null 2>&1 ; then
    $echo "YP may be running -- will use getpwent(), just in case."
    getpwent='define'
else
: see if there is a getpwent
if $contains '^getpwent$' libc.list >/dev/null 2>&1 ; then
    $echo "getpwent() found."
    getpwent='define'
else
    $echo "No getpwent() found--will use getpw() instead."
    getpwent='undef'
fi
fi

: see if there is a seteuid
if $contains '^seteuid$' libc.list >/dev/null 2>&1 ; then
    $echo "seteuid() found."
    seteuid='define'
else
    seteuid='undef'
fi

: see if there is a strncasecmp
if $contains '^strncasecmp$' libc.list >/dev/null 2>&1 ; then
    $echo "strncasecmp() found."
    strncasecmp='define'
else
    strncasecmp='undef'
fi
if stardent; then
   strncasecmp='define'
fi
: see if there is a strcasecmp
if $contains '^strcasecmp$' libc.list >/dev/null 2>&1 ; then
    $echo "strcasecmp() found."
    strcasecmp='define'
else
    strcasecmp='undef'
fi
#fi
: default
sigret=int
: determine type of signal function
if sgi; then
	sigret=void
else
if next; then
	sigret=int
else
if stardent; then
	sigret=void
else
if test -f /usr/include/signal.h ; then
	$cpp /usr/include/signal.h >sigtest
else
if test -f /usr/include/sys/signal.h ; then
	$cpp /usr/include/sys/signal.h >sigtest
fi
fi
if $contains 'void.*signal' sigtest >/dev/null
then
	sigret=void
fi
fi
fi
fi
$echo "signal() returns $sigret on this system."
: see how we will look up site name
douname=undef
gethostname=undef
phostname=undef
if hp-ux; then
    gethostname=define
else
if $test ! "X$hostfile" = X ; then
    gethostname=define
else
if $contains '^gethostnam' libc.list >/dev/null 2>&1 ; then
    $echo "gethostname() found."
    gethostname=define
else
    if $contains '^uname$' libc.list >/dev/null 2>&1 ; then
	$echo "uname() found."
	douname=define
    else
	case $hostcmd in
	  '') ;;
	  *)
	    $cat <<EOT
 
There is no gethostname() or uname() on this system.  You have two
possibilites at this point:

1)  You can have your site name ($sitename) compiled into nntp inews, which
    lets nntp inews start up faster, but makes your binaries non-portable, or
2)  you can have nntp inews use a
	
	popen("$hostcmd","r")

    which will start slower but be more portable.

Option 1 will use whoami.h if you have one.  If you want option 2 but with
a different command, you can edit config.h after this shell script is done.

EOT
	    case "$phostname" in
	    define) dflt=n;;
	    undef)  dflt=y;;
	    '')
		case $portable in
		define) dflt=n ;;
		*)      dflt=y ;;
		esac
		;;
	    esac
	    $echo $n "Do you want your site name compiled in? [$dflt] $c"
	    . myread
	    case $ans in
	    '') ans=$dflt;;
	    esac
	    case $ans in
	      n*) phostname=define ;;
	      *)  hostcmd='' phostname=undef;;
	    esac
	    ;;
	esac
	case $hostcmd in
	  '')
	    case $whoami in
	      define)
		$echo 'No hostname function--using whoami.h.'
		;;
	      undef)
		$echo 'No hostname function--hardwiring "'$sitename'".'
		;;
	    esac
	    ;;
	esac
    fi
fi
fi
fi

: set the right options for cc and include the x library for XENIX
if xenix; then
    if $test -d /lib/386 ; then
	iandd="-M3e"
    else
:	iandd="-M2let8 -LARGE -F 3000"
	iandd="-Ml2et32 -LARGE -F B000"
    fi
    jobslib=-lx
fi
: check to see if we have netdb available 
nonetdb=define
if test -f /usr/include/net/netdb.h ; then
	$echo It appears gethostbyname is available.
	nonetdb=undef
else
if test -f /usr/include/netdb.h ; then
	$echo It appears gethostbyname is available.
	nonetdb=undef
fi
fi
: hack for Unisys NET-5000 and Interactive V/386
: NET-5000
if $test -d /usr/include/NET-5000 ; then
	$echo "I sense you are on a Unisys 5000 computer...poor soul."
	include="-I/usr/include/NET-5000 -DEXCELAN"
	socketlib=-lsocket
	nonetdb=define
fi
: Interactive Unix
if $test -f /usr/lib/libinet.a ; then
	socketlib=-linet
	strncasecmp=define
	strcasecmp=define
fi
: Wollogong TCP
#if $test -f /usr/include/net/netinet/in.h ; then
#	if $contains 'TWG' /usr/include/net/netinet/in.h>/dev/null 2>&1 ; then
if $test -f /usr/include/sys/in.h ; then
	if $contains 'TWG' /usr/include/sys/in.h>/dev/null 2>&1 ; then
		socketlib='-lnet -lnsl_s'
		strncasecmp=define
		include='-DWIN_TCP'
	fi
fi

if $test -f /usr/lib/libdk.a; then
: DATAKIT support
case "$datakit" in
define) dflt=y;;
*)	dflt=n;;
esac
$cat << 'EOD'

The client library and NNTP inews can run over DATAKIT instead of TCP/IP.

EOD

$echo $n "Do you want to use DATAKIT as the transport for NNTP?  [$dflt] $c"
. myread
case $ans in
'') ans=$dflt;;
esac
case $ans in
    y*) datakit=define
	socketlib="$socketlib -ldk"
	include="-DDATAKIT"
	 ;;
    *)  datakit=undef ;;
esac
else
	datakit=undef
fi

: check for void type
$echo " "
$echo "Checking to see if your C compiler groks the void type..."
$cat >try.c <<'EOCP'
void main();
EOCP
if cc -c try.c >/dev/null 2>&1 ; then
    novoid='undef'
    $echo "Yup, it does."
else
    novoid='define'
    $echo "Nope, it doesn't (boo hiss).  I will substitute int."
fi
$rm try.*

: determine root id
rootid=`$sed </etc/passwd -e "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e "q" -e "}" -e "d"`
case $rootid in
  '') rootid=0 ;;
  *)  $echo "Root uid = $rootid" ;;
esac

: weed out incompatibilities
case $douname in
  define) whoami=undef ;;
esac

: preserve RCS keywords in files with variable substitution, grrr
Log='$Log'
Id='$Id'

: Warnings
if v7; then
    cat <<'EOM'
 
NOTE: the V7 compiler may ignore some #undefs that nntp uses.  If so, you will
get messages about redefining EXT.  Some V7 compilers also have difficulties
with #defines near buffer boundaries, so beware.  You may have to play with
the spacing in common.h.
EOM
fi

if pdp11; then
    cat <<'EOM'
 
NOTE: the PDP-11 does not have enough data space to do subject caching
reliably.  That feature will be disabled automatically.  Subject searching
will tend to be slow.
EOM
fi
$echo " "
$echo "End of configuration questions."
$echo " "
if test -d ../UU; then
    cd ..
fi

: create config.sh file
$echo " "
$echo "Creating config.sh..."
$spitshell <<EOT >config.sh
$startsh
# config.sh
# This file was produced by running the Configure script.

n='$n'
c='$c'
libc='$libc'
eunicefix='$eunicefix'
eunice='$eunice'
cpp='$cpp'
shsharp='$shsharp'
startsh='$startsh'
spitshell='$spitshell'
test='$test'
expr='$expr'
sed='$sed'
echo='$echo'
cat='$cat'
rm='$rm'
cp='$cp'
tr='$tr'
mkdir='$mkdir'
inews='$inews'
grep='$grep'
chmod='$chmod'
awk='$awk'
egrep='$egrep'
nidump='$nidump'
ypmatch='$ypmatch'
jobslib='$jobslib'
contains='$contains'
lib='$lib'
libexp='$libexp'
nametype='$nametype'
cc='$cc'
iandd='$iandd'
include='$include'
socketlib='$socketlib'
posix='$posix'
nonetdb='$nonetdb'
internet='$internet'
filexp='$filexp'
dotdir='$dotdir'
strncasecmp='$strncasecmp'
strcasecmp='$strcasecmp'
seteuid='$seteuid'
Log='$Log'
Id='$Id'
sitename='$sitename'
hostfile='$hostfile'
domain='$domain'
isadmin='$isadmin'
newsadmin='$newsadmin'
novoid='$novoid'
mansrc='$mansrc'
manext='$manext'
rootid='$rootid'
strchr='$strchr'
memcpy='$memcpy'
sunos4='$sunos4'
portable='$portable'
passnam='$passnam'
berknam='$berknam'
usgnam='$usgnam'
whoami='$whoami'
getpwent='$getpwent'
gethostname='$gethostname'
douname='$douname'
phostname='$phostname'
hostcmd='$hostcmd'
serverfile='$serverfile'
auth='$auth'
authsimple='$authsimple'
authold='$authold'
passfile='$passfile'
decnet='$decnet'
datakit='$datakit'
CONFIG=true
EOT
CONFIG=true

dflt=''
ans=''
$echo "If you didn't make any mistakes, then just type a carriage return here."
$echo $n "If you need to edit config.sh, do it as a shell escape here: $c"
. UU/myread
case "$ans" in
'') ;;
*) : in case they cannot read
    eval $ans;;
esac
. ./config.sh

$echo " "
$echo "Doing variable substitutions on .SH files..."
set x `$awk '{print $1}' <MANIFEST | $grep '\.SH'`
shift
case $# in
0) set x *.SH; shift;;
esac
if $test ! -f $1; then
    shift
fi
for file in $*; do
    case "$file" in
    */*)
	dir=`$expr X$file : 'X\(.*\)/'`
	file=`$expr X$file : 'X.*/\(.*\)'`
	(cd $dir && . $file)
	;;
    *)
	. $file
	;;
    esac
done
if $test -f config.h.SH; then
    if $test ! -f config.h; then
	: oops, they left it out of MANIFEST, probably, so do it anyway.
	. config.h.SH
    fi
fi

if $contains '^depend:' Makefile >/dev/null 2>&1; then
    dflt=n
    $cat <<EOM

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.

EOM
    rp="Run make depend now? [$dflt]"
    $echo $n "$rp $c"
    . UU/myread
    case "$ans" in
    y*) make depend
	$echo "Now you must run a make."
	;;
    *)  $echo "You must run 'make depend' then 'make'."
	;;
    esac
elif $test -f Makefile; then
    $echo " "
    $echo "Now you must run a make."
else
    $echo "Done."
fi

$rm -f kit*isdone
cd UU && $rm -f $rmlist
: end of Configure

