home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume42
/
c2man-2.0
/
part03
< prev
next >
Wrap
Internet Message Format
|
1994-05-06
|
52KB
From: greyham@research.canon.oz.au (Graham Stoney)
Newsgroups: comp.sources.misc
Subject: v42i057: c2man-2.0 - automatic C documentation generator, Part03/09
Date: 25 Apr 1994 22:30:12 -0500
Organization: Canon Information Systems Research Australia
Sender: kent@sparky.sterling.com
Approved: kent@sparky.sterling.com
Message-ID: <2pi1s4$jl4@sparky.sterling.com>
References: <csm-v42i055=c2man-2.0.222803@sparky.sterling.com>
Summary: a complete posting of the latest c2man: version 2.0 patchlevel 27
X-Md4-Signature: efdbf00c3993eb95c3f9608678c2bf23
Submitted-by: greyham@research.canon.oz.au (Graham Stoney)
Posting-number: Volume 42, Issue 57
Archive-name: c2man-2.0/part03
Environment: UNIX, DOS, OS/2, lex, yacc
#! /bin/sh
#
# This is c2man version 2.0 at patchlevel 27.
# Make a new directory for the c2man sources, cd to it, and run kits 1 up
# to 9 through sh. When all 9 kits have been run, read README.
#
echo " "
cat <<EOM
This is c2man 2.0 at patchlevel 27, kit 3 (of 9):
If this shell archive is complete, the line "End of kit 3 (of 9)"
will echo at the end.
EOM
export PATH || (echo "Please use sh to unpack this archive." ; kill $$)
mkdir 2>/dev/null
echo Extracting Configure:AB
sed >Configure:AB <<'!STUFFY!FUNK!' -e 's/X//'
Xset access d_access
Xeval $inlibc
X
X: locate the flags for 'access()'
Xcase "$d_access" in
X"$define")
X echo " "
X $cat >access.c <<'EOCP'
X#include <sys/types.h>
X#ifdef I_FCNTL
X#include <fcntl.h>
X#endif
X#ifdef I_SYS_FILE
X#include <sys/file.h>
X#endif
X#ifdef I_UNISTD
X#include <unistd.h>
X#endif
Xmain() {
X exit(R_OK);
X}
XEOCP
X : check sys/file.h first, no particular reason here
X if $test `./findhdr sys/file.h` && \
X $cc $cppflags -DI_SYS_FILE access.c -o access >/dev/null 2>&1 ; then
X h_sysfile=true;
X echo "<sys/file.h> defines the *_OK access constants." >&4
X elif $test `./findhdr fcntl.h` && \
X $cc $cppflags -DI_FCNTL access.c -o access >/dev/null 2>&1 ; then
X h_fcntl=true;
X echo "<fcntl.h> defines the *_OK access constants." >&4
X elif $test `./findhdr unistd.h` && \
X $cc $cppflags -DI_UNISTD access.c -o access >/dev/null 2>&1 ; then
X echo "<unistd.h> defines the *_OK access constants." >&4
X else
X echo "I can't find the four *_OK access constants--I'll use mine." >&4
X fi
X ;;
Xesac
X$rm -f access*
X
X: function used to set $1 to $val
Xsetvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
Xcase "$val$was" in
X$define$undef) . whoa; eval "$var=\$td";;
X$undef$define) . whoa; eval "$var=\$tu";;
X*) eval "$var=$val";;
Xesac'
X
X: check for const keyword
Xecho " "
Xecho 'Checking to see if your C compiler knows about "const"...' >&4
X$cat >const.c <<'EOCP'
Xtypedef struct spug { int drokk; } spug;
Xmain()
X{
X const char *foo;
X const spug y;
X}
XEOCP
Xif $cc -c $ccflags const.c >/dev/null 2>&1 ; then
X val="$define"
X echo "Yup, it does."
Xelse
X val="$undef"
X echo "Nope, it doesn't."
Xfi
Xset d_const
Xeval $setvar
X
X: see how we invoke the C preprocessor
X$cat <<EOM
X
X$package needs to be able to preprocess its input files in a mode which
Xpreserves comments, which is often not the default behaviour. It should run
Xthe C preprocessor you will use when compiling your own source code, which
Xshould be ISO/ANSI C compliant if you want $package to handle the latest
Xstandard C. I will try to guess, but I might guess wrongly because it is not
Xnecessarily the same preprocessor used to build $package.
X
XEOM
X$cat <<'EOT' >testcpp.c
X#define ABC abc
X#define XYZ xyz
XABC.XYZ
X/* comment */
XEOT
X:
Xif $test "X$cppfilecom" != "X" && \
X $cppfilecom testcpp.c </dev/null >testcpp.out 2>/dev/null && \
X $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
Xthen
X echo "You used to use $cppfilecom so we'll use that again."
Xelif echo 'Maybe "'$cc' -E -C" will work...' && \
X $cc -E -C testcpp.c </dev/null >testcpp.out 2>/dev/null && \
X $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
Xthen
X echo "It works!"
X cppfilecom="$cc -E -C"
Xelif echo 'Nope...maybe "'"$cc"' -P -C" will work...' && \
X $cc -P -C testcpp.c </dev/null >testcpp.out 2>/dev/null && \
X $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
Xthen
X echo "Yup, that does."
X cppfilecom="$cc -P -C"
Xelif echo 'No such luck, maybe "'"$cpp"' -C" will work...' && \
X $cpp -C testcpp.c </dev/null >testcpp.out 2>/dev/null && \
X $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
Xthen
X echo "Yup, it does."
X cppfilecom="$cpp -C"
Xelse
X cppfilecom=''
X $cat <<'EOM'
XI can't find a C preprocessor that will preserve comments. Please name one.
XEOM
Xfi
X:
Xdflt="$cppfilecom"
Xcont=true
Xwhile $test "$cont" ; do
X echo " "
X rp="How should $package run your preprocessor preserving comments?"
X . ./myread
X cppfilecom="$ans"
X $cppfilecom testcpp.c >testcpp.out 2>&1
X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
X then
X echo "OK, that will do."
X cont=''
X else
X echo "Sorry, I can't get that to work."
X fi
Xdone
X
X: Now see if it ignores header files.
Xcp testcpp.c testcpp.h
X$cppfilecom testcpp.h >testcpp.out 2>&1
Xif $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
Xthen
X echo "Terrific; it processes .h files passed on the command line too."
X val="$undef"
Xelse
X echo "It ignores .h files on the command line; pity."
X val="$define"
Xfi
Xset d_cppignhdrs
Xeval $setvar
X
X: Now see how to send stdin to it.
Xecho " "
Xcp testcpp.c testcpp.h
X$cppfilecom <testcpp.h >testcpp.out 2>&1
Xif $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
Xthen
X echo "Great; and it will read stdin if passed no arguments."
X val="$define"
X cppstdinflags=''
Xelse
X $cppfilecom - <testcpp.h >testcpp.out 2>&1
X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
X then
X echo "Great; and it can read stdin by passing it '-'."
X val="$define"
X cppstdinflags='-'
X else
X $cat <<FOO
XUnfortunately, I can't find an easy way to get that preprocessor to read from
Xstandard input. Do you know any flags I can pass it to get it to do so?
XIf that preprocessor can't read directly form standard input, answer 'none'.
X
XFOO
X val='dunno'
X while $test "$val" = "dunno"; do
X rp='Flags to get preprocessor to read stdin?'
X dflt='none'
X . ./myread
X if $test $ans = 'none'; then
X echo "Oh well, if $package wants it done, it will do it for itself."
X val="$undef"
X else
X $cppfilecom $ans <testcpp.h >testcpp.out 2>&1
X if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 && \
X $contains comment testcpp.out >/dev/null 2>&1
X then
X echo "Good; that works fine."
X val="$define"
X cppstdinflags="$ans"
X else
X echo "Sorry, I couldn't get that to work."
X fi
X fi
X done
X fi
Xfi
Xset d_cppcanstdin
Xeval $setvar
X
X: cleanup cpp test files anyway
X$rm -f testcpp.*
X
X: see if we can have long filenames
Xecho " "
Xrmlist="$rmlist /tmp/cf$$"
X$test -d /tmp/cf$$ || mkdir /tmp/cf$$
Xfirst=123456789abcdef
Xsecond=/tmp/cf$$/$first
X$rm -f $first $second
Xif (echo hi >$first) 2>/dev/null; then
X if $test -f 123456789abcde; then
X echo 'You cannot have filenames longer than 14 characters. Sigh.' >&4
X val="$undef"
X else
X if (echo hi >$second) 2>/dev/null; then
X if $test -f /tmp/cf$$/123456789abcde; then
X $cat <<'EOM'
XThat's peculiar... You can have filenames longer than 14 characters, but only
Xon some of the filesystems. Maybe you are using NFS. Anyway, to avoid problems
XI shall consider your system cannot support long filenames at all.
XEOM
X val="$undef"
X else
X echo 'You can have filenames longer than 14 characters.' >&4
X val="$define"
X fi
X else
X $cat <<'EOM'
XHow confusing! Some of your filesystems are sane enough to allow filenames
Xlonger than 14 characters but some others like /tmp can't even think about them.
XSo, for now on, I shall assume your kernel does not allow them at all.
XEOM
X val="$undef"
X fi
X fi
Xelse
X $cat <<'EOM'
XYou can't have filenames longer than 14 chars. You can't even think about them!
XEOM
X val="$undef"
Xfi
Xset d_flexfnam
Xeval $setvar
X$rm -rf /tmp/cf$$ 123456789abcde*
X
X: see which of string.h or strings.h is needed
Xecho " "
Xstrings=`./findhdr string.h`
Xif $test "$strings" && $test -r "$strings"; then
X echo "Using <string.h> instead of <strings.h>." >&4
X val="$define"
Xelse
X val="$undef"
X strings=`./findhdr strings.h`
X if $test "$strings" && $test -r "$strings"; then
X echo "Using <strings.h> instead of <string.h>." >&4
X else
X echo "No string header found -- You'll surely have problems." >&4
X fi
Xfi
Xset i_string
Xeval $setvar
Xcase "$i_string" in
X"$undef") strings=`./findhdr strings.h`;;
X*) strings=`./findhdr string.h`;;
Xesac
X
X: index or strchr
Xecho " "
Xif set index val -f; eval $csym; $val; then
X if set strchr val -f d_strchr; eval $csym; $val; then
X if $contains strchr "$strings" >/dev/null 2>&1 ; then
X val="$define"
X vali="$undef"
X echo "strchr() found." >&4
X else
X val="$undef"
X vali="$define"
X echo "index() found." >&4
X fi
X else
X val="$undef"
X vali="$define"
X echo "index() found." >&4
X fi
Xelse
X if set strchr val -f d_strchr; eval $csym; $val; then
X val="$define"
X vali="$undef"
X echo "strchr() found." >&4
X else
X echo "No index() or strchr() found!" >&4
X val="$undef"
X vali="$undef"
X fi
Xfi
Xset d_strchr; eval $setvar
Xval="$vali"
Xset d_index; eval $setvar
X
X: see if link exists
Xset link d_link
Xeval $inlibc
X
X: Locate the flags for 'open()'
Xecho " "
X$cat >open3.c <<'EOCP'
X#include <sys/types.h>
X#ifdef I_FCNTL
X#include <fcntl.h>
X#endif
X#ifdef I_SYS_FILE
X#include <sys/file.h>
X#endif
Xmain() {
X if(O_RDONLY);
X#ifdef O_TRUNC
X exit(0);
X#else
X exit(1);
X#endif
X}
XEOCP
X: check sys/file.h first to get FREAD on Sun
Xif $test `./findhdr sys/file.h` && \
X $cc $cppflags "-DI_SYS_FILE" open3.c -o open3 >/dev/null 2>&1 ; then
X h_sysfile=true;
X echo "<sys/file.h> defines the O_* constants..." >&4
X if ./open3; then
X echo "and you have the 3 argument form of open()." >&4
X val="$define"
X else
X echo "but not the 3 argument form of open(). Oh, well." >&4
X val="$undef"
X fi
Xelif $test `./findhdr fcntl.h` && \
X $cc "-DI_FCNTL" open3.c -o open3 >/dev/null 2>&1 ; then
X h_fcntl=true;
X echo "<fcntl.h> defines the O_* constants..." >&4
X if ./open3; then
X echo "and you have the 3 argument form of open()." >&4
X val="$define"
X else
X echo "but not the 3 argument form of open(). Oh, well." >&4
X val="$undef"
X fi
Xelse
X val="$undef"
X echo "I can't find the O_* constant definitions! You got problems." >&4
Xfi
Xset d_open3
Xeval $setvar
X$rm -f open3*
X
X: see if strftime exists
Xset strftime d_strftime
Xeval $inlibc
X
X: see if strstr exists
Xset strstr d_strstr
Xeval $inlibc
X
X: see if symlink exists
Xset symlink d_symlink
Xeval $inlibc
X
X: check for volatile keyword
Xecho " "
Xecho 'Checking to see if your C compiler knows about "volatile"...' >&4
X$cat >try.c <<'EOCP'
Xmain()
X{
X typedef struct _goo_struct goo_struct;
X goo_struct * volatile goo = ((goo_struct *)0);
X struct _goo_struct {
X long long_int;
X int reg_int;
X char char_var;
X };
X typedef unsigned short foo_t;
X char *volatile foo;
X volatile int bar;
X volatile foo_t blech;
X foo = foo;
X}
XEOCP
Xif $cc -c $ccflags try.c >/dev/null 2>&1 ; then
X val="$define"
X echo "Yup, it does."
Xelse
X val="$undef"
X echo "Nope, it doesn't."
Xfi
Xset d_volatile
Xeval $setvar
X$rm -f try.*
X
X: preserve RCS keywords in files with variable substitution, grrr
XId='$Id'
X
X: is AFS running?
Xecho " "
Xif test -d /afs; then
X echo "AFS may be running... I'll be extra cautious then..." >&4
X afs=true
Xelse
X echo "AFS does not seem to be running..." >&4
X afs=false
Xfi
X
X: determine where public executables go
Xecho " "
Xcase "$bin" in
X'')
X dflt=`./loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
X ;;
X*)
X dflt="$bin"
X ;;
Xesac
Xfn=d~
Xrp='Pathname where the public executables will reside?'
X. ./getfile
Xbin="$ans"
Xbinexp="$ansexp"
Xif $afs; then
X $cat <<EOM
X
XSince you are running AFS, I need to distinguish the directory in which
Xexecutables reside from the directory in which they are installed (and from
Xwhich they are presumably copied to the former directory by occult means).
X
XEOM
X case "$installbin" in
X '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
X *) dflt="$installbin";;
X esac
X fn=de~
X rp='Where will public executables be installed?'
X . ./getfile
X installbin="$ans"
Xelse
X installbin="$binexp"
Xfi
X
X: check for void type
Xecho " "
X$cat >&4 <<EOM
XChecking to see how well your C compiler groks the void type...
X
X Support flag bits are:
X 1: basic void declarations.
X 2: arrays of pointers to functions returning void.
X 4: operations between pointers to and addresses of void functions.
X 8: generic void pointers.
X
XEOM
Xcase "$voidflags" in
X'')
X $cat >try.c <<'EOCP'
X#if TRY & 1
Xvoid main() {
X#else
Xmain() {
X#endif
X extern void moo(); /* function returning void */
X void (*goo)(); /* ptr to func returning void */
X#if TRY & 8
X void *hue; /* generic ptr */
X#endif
X#if TRY & 2
X void (*foo[10])();
X#endif
X
X#if TRY & 4
X if(goo == moo) {
X exit(0);
X }
X#endif
X exit(0);
X}
XEOCP
X if $cc -c -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
Xecho "Hmm, your compiler has some difficulty with void. Checking further..." >&4
X if $cc -c -DTRY=1 try.c >/dev/null 2>&1 ; then
X echo "It supports 1..."
X if $cc -c -DTRY=3 try.c >/dev/null 2>&1 ; then
X echo "It also supports 2..."
X if $cc -c -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 -c -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 -c -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 -c -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
Xesac
Xdflt="$voidflags";
Xrp="Your void support flags add up to what?"
X. ./myread
Xvoidflags="$ans"
X$rm -f try.* .out
X
X: determine where private executables go
Xcase "$privlib" in
X'')
X dflt=/usr/lib/$package
X $test -d /usr/local/lib && dflt=/usr/local/lib/$package
X $test -d /local/lib && dflt=/local/lib/$package
X ;;
X*) dflt="$privlib"
X ;;
Xesac
X$cat <<EOM
X
XThere are some auxiliary files for $package that need to be put into a
Xprivate library directory that is accessible by everyone.
X
XEOM
Xfn=d~+
Xrp='Pathname where private library files will reside?'
X. ./getfile
Xprivlib="$ans"
Xprivlibexp="$ansexp"
Xif $afs; then
X $cat <<EOM
X
XSince you are running AFS, I need to distinguish the directory in which
Xprivate files reside from the directory in which they are installed (and from
Xwhich they are presumably copied to the former directory by occult means).
X
XEOM
X case "$installprivlib" in
X '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
X *) dflt="$installprivlib";;
X esac
X fn=de~
X rp='Where will private files be installed?'
X . ./getfile
X installprivlib="$ans"
Xelse
X installprivlib="$privlibexp"
Xfi
X
X: determine lexical analyser generator
Xcase "$lex" in
X'')
X dflt=lex;;
X*)
X dflt="$lex";;
Xesac
Xecho " "
Xif $test -f "$flex"; then
X rp='Which lexical analyser generator (lex or flex) shall I use?'
Xelse
X rp='Which lexical analyser generator shall I use?'
Xfi
X. ./myread
Xlex="$ans"
X: see if we should include -ll
Xecho " "
Xcase "$lex" in
X*flex*)
X xxx=`./loc libfl.a x $libpth`
X case "$xxx" in
X x)
X echo "No flex library found." >&4
X liblex=''
X ;;
X *)
X echo "flex library found in $xxx." >&4
X liblex="$xxx"
X ;;
X esac
X ;;
X*lex)
X xxx=`./loc libl.a x $libpth`
X case "$xxx" in
X x)
X echo "No lex library found." >&4
X liblex=''
X ;;
X *)
X echo "lex library found in $xxx." >&4
X liblex="$xxx"
X ;;
X esac
X ;;
X*)
Xecho "You don't seem to have lex, so I won't look for the lex library." >&4
X liblex=''
X ;;
Xesac
X: determine compiler compiler
Xcase "$yacc" in
X'')
X dflt=yacc;;
X*)
X dflt="$yacc";;
Xesac
Xecho " "
Xif $test -f "$bison"; then
X rp='Which compiler compiler (yacc or bison -y) shall I use?'
Xelse
X rp='Which compiler compiler shall I use?'
Xfi
X. ./myread
Xyacc="$ans"
Xcase "$yacc" in
X*bis*)
X case "$yacc" in
X *-y*) ;;
X *)
X yacc="$yacc -y"
X echo "(Adding -y option to bison to get yacc-compatible behaviour.)"
X ;;
X esac
X ;;
Xesac
X
X: see if we should include -ly
Xecho " "
Xcase "$yacc" in
X*yacc)
X xxx=`./loc liby.a x $libpth`
X case "$xxx" in
X x)
X echo "No yacc library found." >&4
X libyacc=''
X ;;
X *)
X echo "yacc library found in $xxx." >&4
X libyacc="$xxx"
X ;;
X esac
X ;;
X*bison*)
X echo "You are using bison, so I won't look for a yacc library." >&4
X libyacc=''
X ;;
X*)
Xecho "You don't seem to have yacc, so I won't look for the yacc library." >&4
X libyacc=''
X ;;
Xesac
X
X: determine where manual pages go
X$cat <<EOM
X
X$package has manual pages available in source form.
XEOM
Xcase "$_nroff" in
Xnroff)
X echo "However, you don't have nroff, so they're probably useless to you."
X case "$mansrc" in
X '') mansrc="none";;
X esac;;
Xesac
Xecho "If you don't want the manual sources installed, answer 'none'."
Xcase "$mansrc" in
X'')
X lookpath='/usr/local/man/man1 /usr/local/man/man1 /usr/man/manl'
X lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
X lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
X lookpath="$lookpath /usr/man/man.L"
X mansrc=`./loc . $lookpath`
X if $test -d "$mansrc"; then
X dflt="$mansrc"
X else
X dflt="$sysman"
X fi
X ;;
X*) dflt="$mansrc"
X ;;
Xesac
Xecho " "
Xfn=dn~
Xrp='Where do the manual pages (source) go?'
X. ./getfile
Xmansrc="$ans"
Xmansrcexp="$ansexp"
Xif $afs; then
X $cat <<EOM
X
XSince you are running AFS, I need to distinguish the directory in which
Xmanual pages reside from the directory in which they are installed (and from
Xwhich they are presumably copied to the former directory by occult means).
X
XEOM
X case "$installmansrc" in
X '') dflt=`echo $mansrcexp | sed 's#^/afs/#/afs/.#'`;;
X *) dflt="$installmansrc";;
X esac
X fn=de~
X rp='Where will man pages be installed?'
X . ./getfile
X installmansrc="$ans"
Xelse
X installmansrc="$mansrcexp"
Xfi
X
X
Xcase "$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*L1) manext=L1;;
X*) manext=1;;
Xesac
X
X: find out how to generate dependencies
Xecho " "
Xecho "Checking how to generate makefile dependencies on your machine..." >&4
Xtoplev=`cd ..;pwd`
X$cat >dep.c <<'EOCP'
X#include "dep.h"
XEOCP
X$cat >dep.h <<'EOCP'
X
XEOCP
Xtakeflags='flags=""
Xcase "$@" in
X*--*)
X for arg
X do
X shift
X case "$arg" in
X --) break;;
X *) flags="$flags $arg";;
X esac
X done;;
Xesac'
Xcase "$mkdep" in
X'')
X ;;
X*)
X if test -x "$mkdep" &&
X $mkdep dep.c >dep.out 2>/dev/null &&
X $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X then
X echo "$mkdep works."
X else
X mkdep=
X fi
Xesac
X
Xcase "$mkdep" in
X'')
X $spitshell > ../mkdep <<EOM
X$startsh
X$takeflags
Xfor srcfile
Xdo
X $cpp -M -I. $cppflags \$flags \$srcfile 2>/dev/null
Xdone
Xexit 0
XEOM
X mkdep=$toplev/mkdep
X chmod +x $mkdep
X $eunicefix $mkdep
X if $mkdep dep.c >dep.out 2>/dev/null &&
X $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X then
X echo "Looks like we can use $cpp -M."
X else
X mkdep=
X fi
X ;;
Xesac
X
Xcase "$mkdep" in
X'')
X $spitshell > ../mkdep <<EOM
X$startsh
X$takeflags
Xfor srcfile
Xdo
X $cc -MM -I. $cppflags \$flags \$srcfile 2>/dev/null
Xdone
Xexit 0
XEOM
X mkdep=$toplev/mkdep
X chmod +x $mkdep
X $eunicefix $mkdep
X if $mkdep dep.c >dep.out 2>/dev/null &&
X $contains 'dep.o: dep.h' dep.out >/dev/null 2>&1
X then
X echo "Looks like we can use $cc -MM."
X else
X mkdep=
X fi
X ;;
Xesac
X
Xcase "$mkdep" in
X'')
X $spitshell >../mkdep <<EOS
X$startsh
X$takeflags
Xfor srcfile
Xdo
X case "\$srcfile" in
X *.c) c='.c';;
X *.y) c='.y';;
X *.l) c='.l';;
X esac
X filebase=\`basename \$srcfile \$c\`
X <\$srcfile $cpp $cppminus $cppflags -I. \$flags 2>/dev/null | \\
X $sed -e '/^# *[0-9]/!d' \\
X -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
X -e 's|: \./|: |' \\
X -e 's|: *$|: '\$srcfile'|' | \\
X $grep -v '^#' | $sort | $uniq
Xdone
Xexit 0
XEOS
X mkdep=$toplev/mkdep
X chmod +x $mkdep
X $eunicefix $mkdep
X if $mkdep dep.c >dep.out 2>/dev/null &&
X $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X then
X echo "A shell script using $cpp does the trick."
X else
X echo "$cpp doesn't seem to be any use at all."
X $spitshell >../mkdep <<EOS
X$startsh
X$takeflags
Xfiles="\$@"
Xset X \$flags
Xshift
Xinc='.'
Xwhile test \$# -gt 0
Xdo
X case "\$1" in
X -I)
X shift
X inc="\$inc:\$1"
X ;;
X -I*)
X dir=\`echo \$1 | sed -e 's/^-I//'\`
X inc="\$inc:\$dir"
X ;;
X esac
X shift
Xdone
Xset X \$files
Xshift
Xtrap "$rm -f /tmp/mkdep\$\$; exit 1" 1 2 3 15
Xfor srcfile
Xdo
X case "\$srcfile" in
X *.c) c='.c';;
X *.y) c='.y';;
X *.l) c='.l';;
X esac
X filebase=\`basename \$srcfile \$c\`
X echo \$filebase.o: \$srcfile
X $grep '^#[ ]*include' \$srcfile /dev/null | \
X $sed -n -e 's/#[ ]*include[ ]*//' \\
X -e '/<\(.*\)>/ d' \\
X -e 's/:[^"]*"\([^"]*\)".*/: \1/' \\
X -e 's/\.c:/\.o:/p' > /tmp/mkdep\$\$
X IFS=': '
X while read file dep; do
X for dir in \$inc; do
X if $test -f "\$dir/\$dep"; then
X dep="\$dir/\$dep"
X break
X fi
X done
X echo "\$file: \$dep" | $sed -e 's,: \./,: ,'
X done </tmp/mkdep\$\$
X IFS=' '
X $rm -f /tmp/mkdep\$\$
Xdone
Xexit 0
XEOS
X mkdep=$toplev/mkdep
X chmod +x $mkdep
X $eunicefix $mkdep
X if $mkdep dep.c >dep.out 2>/dev/null &&
X $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
X then
X cat << EOM
X
XI can use a script with grep instead, but it will make some incorrect
Xdependencies, since it doesn't understand about conditional compilation.
XMoreover, some dependencies may be missing, because scanning won't be
Xa recursive process.
XIf you have a program which generates makefile dependencies, you may want
Xto use it. If not, you can use the script and edit the Makefile by hand
Xif you need to.
XEOM
X else
X mkdep=
X cat << EOM
X
XI can't seem to generate makefile dependencies at all! Perhaps you have a
Xprogram that does? If you don't, you might look at the mkdep script to
Xsee if you can create one which works.
XEOM
X fi
X fi
Xesac
Xdflt="$mkdep"
Xfn=f~/
Xrp="Name of program to make makefile dependencies?"
X. ./getfile
Xmkdep="$ans"
X$rm -f dep.c dep.h dep.o dep.out
X
X: Cruising for prototypes
Xecho " "
Xecho "Checking out function prototypes..." >&4
X$cat >prototype.c <<'EOCP'
Xmain(int argc, char *argv[]) {
X exit(0);}
XEOCP
Xif $cc -c prototype.c >prototype.out 2>&1 ; then
X echo "Your C compiler appears to support function prototypes."
X val="$define"
Xelse
X echo "Your C compiler doesn't seem to understand function prototypes."
X val="$undef"
Xfi
Xset prototype
Xeval $setvar
X$rm -f prototype*
X
X: see if signal is declared as pointer to function returning int or void
Xecho " "
Xxxx=`./findhdr signal.h`
X$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
Xif $contains 'int.*\*[ ]*signal' $$.tmp >/dev/null 2>&1 ; then
X echo "You have int (*signal())() instead of void." >&4
X val="$undef"
X signal_t="int"
Xelif $contains 'void.*\*[ ]*signal' $$.tmp >/dev/null 2>&1 ; then
X echo "You have void (*signal())() instead of int." >&4
X val="$define"
X signal_t="void"
Xelif $contains 'extern[ ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
X echo "You have int (*signal())() instead of void." >&4
X val="$undef"
X signal_t="int"
Xelse
X case "$d_voidsig" in
X '')
X echo "I can't determine whether signal handler returns void or int..." >&4
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." >&4;;
X esac
Xfi
Xset d_voidsig
Xeval $setvar
X$rm -f $$.tmp
X
X: see if time exists
Xecho " "
Xif set time val -f d_time; eval $csym; $val; then
X echo 'time() found.' >&4
X val="$define"
X case "$timetype" in
X '')
X if $contains 'time_t;' `./findhdr sys/types.h` >/dev/null 2>&1 ; then
X dflt='time_t';
X else
X dflt='long';
X fi
X ;;
X *) dflt="$timetype"
X ;;
X esac
X echo " "
X rp="What type is returned by time() on this sytem?"
X . ./myread
X timetype="$ans"
Xelse
X echo 'time() not found, hope that will do.' >&4
X val="$undef"
X timetype='int';
Xfi
Xset d_time
Xeval $setvar
X
X: define an alternate in-header-list? function
Xinhdr='echo " "; td=$define; tu=$undef; yyy=$@;
Xcont=true; xxf="echo \"<\$1> found.\" >&4";
Xcase $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
X*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
Xesac;
Xcase $# in 4) instead=instead;; *) instead="at last";; esac;
Xwhile $test "$cont"; do
X xxx=`./findhdr $1`
X var=$2; eval "was=\$$2";
X if $test "$xxx" && $test -r "$xxx";
X then eval $xxf;
X eval "case \"\$$var\" in $undef) . whoa; esac"; eval "$var=\$td";
X cont="";
X else eval $xxnf;
X eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu"; fi;
X set $yyy; shift; shift; yyy=$@;
X case $# in 0) cont="";;
X 2) xxf="echo \"but I found <\$1> $instead.\" >&4";
X xxnf="echo \"and I did not find <\$1> either.\" >&4";;
X *) xxf="echo \"but I found <\$1\> instead.\" >&4";
X xxnf="echo \"there is no <\$1>, ...\" >&4";;
X esac;
Xdone;
Xwhile $test "$yyy";
Xdo set $yyy; var=$2; eval "was=\$$2";
X eval "case \"\$$var\" in $define) . whoa; esac"; eval "$var=\$tu";
X set $yyy; shift; shift; yyy=$@;
Xdone'
X
X: see if stdarg is available
Xset stdarg.h i_stdarg
Xeval $inhdr
X
X: see if prototypes support variable argument declarations
Xecho " "
Xcase "$prototype$i_stdarg" in
X$define$define)
X echo "It appears we'll be able to prototype varargs functions." >&4
X val="$define"
X ;;
X*)
X echo "Too bad... We won't be using prototyped varargs functions..." >&4
X val="$undef"
X ;;
Xesac
Xset vaproto
Xeval $setvar
X
X$cat <<EOH
X
XYou may wish to compile with extra compiler warnings enabled.
XNote that doing so enhances your chance of receiving your free set of steak
Xknives, particularly if you find any bugs and report them.
XIf you don't want extra warnings, answer "none".
X
XEOH
Xcase "$warnflags" in
X'') case "$cc" in
X *gcc*)
X dflt="-Wall -Wno-comment"
X if $contains 'fprintf' `./findhdr stdio.h` >/dev/null 2>&1; then
X :
X else
X dflt="$dflt -Wno-implicit"
X fi
X ;;
X *) dflt="none";;
X esac
X ;;
X' ') dflt="none";;
X*) dflt="$warnflags";;
Xesac
X
Xrp="Any $cc flags to enable warnings?"
X. ./myread
Xcase "$ans" in
Xnone) warnflags=' ';;
X*) warnflags="$ans";;
Xesac
X
X: see if this is a sys/file.h system
Xval=''
Xset sys/file.h val
Xeval $inhdr
X
X: do we need to #include <sys/file.h> ?
Xcase "$val" in
X"$define")
X echo " "
X if $h_sysfile; then
X val="$define"
X echo "We'll be including <sys/file.h>." >&4
X else
X val="$undef"
X echo "We won't be including <sys/file.h>." >&4
X fi
X ;;
X*)
X h_sysfile=false
X ;;
Xesac
Xset i_sysfile
Xeval $setvar
X
X: see if fcntl.h is there
Xval=''
Xset fcntl.h val
Xeval $inhdr
X
X: see if we can include fcntl.h
Xcase "$val" in
X"$define")
X echo " "
X if $h_fcntl; then
X val="$define"
X echo "We'll be including <fcntl.h>." >&4
X else
X val="$undef"
X if $h_sysfile; then
X echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
X else
X echo "We won't be including <fcntl.h>." >&4
X fi
X fi
X ;;
X*)
X h_fcntl=false
X val="$undef"
X ;;
Xesac
Xset i_fcntl
Xeval $setvar
X
X: see if stddef is available
Xset stddef.h i_stddef
Xeval $inhdr
X
X: see if stdlib is available
Xset stdlib.h i_stdlib
Xeval $inhdr
X
X: see if we should include time.h, sys/time.h, or both
Xecho " "
Xecho "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
X$echo $n "I'm now running the test program...$c"
X$cat >try.c <<'EOCP'
X#include <sys/types.h>
X#ifdef I_TIME
X#include <time.h>
X#endif
X#ifdef I_SYSTIME
X#ifdef SYSTIMEKERNEL
X#define KERNEL
X#endif
X#include <sys/time.h>
X#endif
X#ifdef I_SYSSELECT
X#include <sys/select.h>
X#endif
Xmain()
X{
X struct tm foo;
X#ifdef S_TIMEVAL
X struct timeval bar;
X#endif
X#ifdef S_TIMEZONE
X struct timezone tzp;
X#endif
X if (foo.tm_sec == foo.tm_sec)
X exit(0);
X#ifdef S_TIMEVAL
X if (bar.tv_sec == bar.tv_sec)
X exit(0);
X#endif
X exit(1);
X}
XEOCP
Xflags=''
Xs_timezone=''
Xsysselect=''
Xfor s_timeval in '-DS_TIMEVAL' ''; do
Xfor i_systimek in '' '-DSYSTIMEKERNEL'; do
Xfor i_time in '' '-DI_TIME'; do
Xfor i_systime in '-DI_SYSTIME' ''; do
X case "$flags" in
X '') $echo $n ".$c"
X if $cc $ccflags \
X $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone \
X try.c -o try >/dev/null 2>&1 ; then
X set X $i_time $i_systime $i_systimek $sysselect $s_timeval
X shift
X flags="$*"
X echo " "
X $echo $n "Succeeded with $flags$c"
X fi
X ;;
X esac
Xdone
Xdone
Xdone
Xdone
Xtimeincl=''
Xecho " "
Xcase "$flags" in
X*SYSTIMEKERNEL*) i_systimek="$define"
X timeincl=`./findhdr sys/time.h`
X echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
X*) i_systimek="$undef";;
Xesac
Xcase "$flags" in
X*I_TIME*) i_time="$define"
X timeincl=`./findhdr time.h`" $timeincl"
X echo "We'll include <time.h>." >&4;;
X*) i_time="$undef";;
Xesac
Xcase "$flags" in
X*I_SYSTIME*) i_systime="$define"
X timeincl=`./findhdr sys/time.h`" $timeincl"
X echo "We'll include <sys/time.h>." >&4;;
X*) i_systime="$undef";;
Xesac
X$rm -f try.c try
X
X: see if sys/types.h has to be included
Xset sys/types.h i_systypes
Xeval $inhdr
X
X: see if this is a unistd.h system
Xset unistd.h i_unistd
Xeval $inhdr
X
X: see if this is a varargs system
Xecho " "
Xif $test `./findhdr varargs.h`; then
X val="$define"
X echo "<varargs.h> found." >&4
Xelse
X val="$undef"
X echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
Xfi
Xset i_varargs
Xeval $setvar
X
X: set up the varargs testing programs
X$cat > varargs.c <<EOP
X#ifdef I_STDARG
X#include <stdarg.h>
X#endif
X#ifdef I_VARARGS
X#include <varargs.h>
X#endif
X
X#ifdef I_STDARG
Xint f(char *p, ...)
X#else
Xint f(va_alist)
Xva_dcl
X#endif
X{
X va_list ap;
X#ifndef I_STDARG
X char *p;
X#endif
X#ifdef I_STDARG
X va_start(ap,p);
X#else
X va_start(ap);
X p = va_arg(ap, char *);
X#endif
X va_end(ap);
X}
XEOP
X$cat > varargs <<EOP
Xif $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
X echo "true"
Xelse
X echo "false"
Xfi
X$rm -f varargs.o
XEOP
Xchmod +x varargs
X
X: now check which varargs header should be included
Xecho " "
Xi_varhdr=''
Xcase "$i_stdarg" in
X"$define")
X if `./varargs I_STDARG`; then
X i_varhdr='stdarg.h'
X i_varargs="$undef"
X elif `./varargs I_VARARGS`; then
X i_varhdr='varargs.h'
X i_stdarg="$undef"
X fi
X ;;
X*)
X if `./varargs I_VARARGS`; then
X i_varhdr='varargs.h'
X fi
X ;;
Xesac
Xcase "$i_varhdr" in
X'')
Xecho "I could not find the definition for va_dcl... You have problems..." >&4
X ;;
X*) echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
Xesac
X$rm -f varargs*
X
X: determine the name of a reasonable mailer
Xcase "$mailer" in
X'')
X if $test -f "$_sendmail"; then
X dflt="$_sendmail"
X elif $test -f "$_smail"; then
X dflt="$_smail"
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";;
Xesac
X$cat <<EOM
X
XI need the full pathname of the program used to deliver mail on your system.
XA typical answer would be /usr/lib/sendmail or /bin/rmail, but you may choose
Xany other program, as long as it can be fed from standard input and will
Xhonour any user-supplied headers.
X
XEOM
Xfn=f
Xrp='Mail transport agent to be used?'
X. ./getfile
Xmailer="$ans"
X
X: set the base revision
Xbaserev=2.0
X
X: get the patchlevel
Xecho " "
Xecho "Getting the current patchlevel..." >&4
Xif $test -r ../patchlevel.h;then
X patchlevel=`awk '/PATCHLEVEL/ {print $3}' < ../patchlevel.h`
Xelse
X patchlevel=0
Xfi
Xecho "(You have $package $baserev PL$patchlevel.)"
X
X: notify author that his package is used
Xif $test -f ../.config/mailauthor &&
X cmp ../patchlevel.h ../.config/mailauthor >/dev/null 2>&1
Xthen
X status="say that you're using $package";
X case "$mailpatches" in
X true) status='have patches mailed to you as they are issued';;
X esac
X case "$notifypatches" in
X true) status='be notified when new patches are issued';;
X esac
X $cat <<EOM
X
XYou have already sent the author of $package (greyham@research.canon.oz.au) mail to
X$status. If you wish, you may modify
Xyour previous request by sending a new mail with different options.
X
XEOM
X rp='Should I send a status update to greyham@research.canon.oz.au?'
X dflt=n
Xelse
X $cat <<EOM
X
XIf you are able to send mail to the Internet, the author of $package would
Xreally appreciate you letting me send off a quick note, just to say that you've
Xtried it. The author is more likely to spend time maintaining $package if it's
Xknown that many people are using it, and you can even ask to get sent new
Xpatches automagically this way if you wish. To protect your privacy, all I'll
Xsay in the mail is the version of $package that you're using.
X
XEOM
X rp='Should I send mail to greyham@research.canon.oz.au?'
X dflt=y
Xfi
X. ./myread
Xcase "$ans" in
X[yY]*)
X echo " "
X echo "Great!. You cooperation is really appreciated."
X $cat <<EOM
X
XSome braindead sites do not set a proper return address in the From: header of
Xtheir outgoing mail, making it impossible to reply to mail they generate.
XIf your site is broken in this way, write to your system administrator and get
Xit fixed!!! In the mean time, you can manually specify the Internet e-mail
Xaddress by which the author can get back to you, should there be a need to do
Xso. If manually specified, it should be something like "user@domain.top".
XIf your mail system generates addresses correctly, specify "none".
X
XEOM
X case "$usermail" in
X '-'|'') dflt=none;;
X *) dflt="$usermail";;
X esac
X rp='Manually specify a return address to use:'
X . ./myread
X case "$ans" in
X none|*@*.*)
X case "$ans" in
X none) usermail='-';;
X *) usermail="$ans";;
X esac
X ;;
X *)
X echo "(Address does not look like an Internet one -- ignoring it.)"
X usermail='-'
X mailpatches=false
X notifypatches=false
X ;;
X esac
X echo " "
X opt=''
X rp='Would you like to have new patches automatically mailed to you?'
X case "$mailpatches" in
X true) dflt=y;;
X *) dflt=n;;
X esac
X . ./myread
X case "$ans" in
X [yY]*) opt=' mailpatches'; mailpatches=true;;
X *)
X mailpatches=false
X echo " "
X rp='Ok, would you like to simply be notified of new patches?'
X case "$notifypatches" in
X false) dflt=n;;
X *) dflt=y;;
X esac
X . ./myread
X echo " "
X case "$ans" in
X [yY]*) opt=' notifypatches'; notifypatches=true;;
X *)
X echo "Fine, I'll simply say that you've tried it then."
X notifypatches=false
X ;;
X esac
X ;;
X esac
X echo "Sending mail to greyham@research.canon.oz.au..." >&4
X atsh='@SH'
X $mailer greyham@research.canon.oz.au <<EOM >/dev/null 2>&1
XSubject: Command
XPrecedence: junk
XTo: greyham@research.canon.oz.au
X
X$atsh package $usermail $package $baserev $patchlevel$opt
XEOM
X $rm -f ../.config/mailauthor
X cp ../patchlevel.h ../.config/mailauthor
X ;;
X*)
X case "$dflt" in
X "y") echo "Oh well, maybe next time.";;
X esac
X ;;
Xesac
X
X: see if we have to deal with yellow pages, now NIS.
Xif $test -d /usr/etc/yp || $test -d /etc/yp; then
X if $test -f /usr/etc/nibindd; then
X echo " "
X echo "I'm fairly confident you're on a NeXT."
X echo " "
X rp='Do you get the passwd file via NetInfo?'
X dflt=y
X case "$passcat" in
X nidump*) ;;
X '') ;;
X *) dflt=n;;
X esac
X . ./myread
X case "$ans" in
X y*) passcat='nidump passwd .'
X ;;
X *) echo "You told me, so don't blame me."
X passcat='cat /etc/passwd'
X ;;
X esac
X echo " "
X rp='Do you get the hosts file via NetInfo?'
X dflt=y
X case "$hostcat" in
X nidump*) ;;
X '') ;;
X *) dflt=n;;
X esac
X . ./myread
X case "$ans" in
X y*) hostcat='nidump hosts .';;
X *) hostcat='cat /etc/hosts';;
X esac
X fi
X case "$passcat" in
X nidump*) ;;
X *)
X case "$passcat" in
X *ypcat*) dflt=y;;
X '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
X dflt=y
X else
X dflt=n
X fi;;
X *) dflt=n;;
X esac
X echo " "
X rp='Are you getting the passwd file via yellow pages?'
X . ./myread
X case "$ans" in
X y*) passcat='ypcat passwd'
X ;;
X *) passcat='cat /etc/passwd'
X ;;
X esac
X ;;
X esac
X case "$hostcat" in
X nidump*) ;;
X *)
X case "$hostcat" in
X *ypcat*) dflt=y;;
X '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
X dflt=y
X else
X dflt=n
X fi;;
X *) dflt=n;;
X esac
X echo " "
X rp='Are you getting the hosts file via yellow pages?'
X . ./myread
X case "$ans" in
X y*) hostcat='ypcat hosts';;
X *) hostcat='cat /etc/hosts';;
X esac
X ;;
X esac
Xfi
X
X: find out how to find out full name
Xcase "$d_berknames" in
X"$define")
X dflt=y;;
X"$undef")
X dflt=n;;
X*)
X if bsd; then
X dflt=y
X elif xenix; then
X dflt=y
X else
X dflt=n
X fi
X ;;
Xesac
X$cat <<'EOM'
X
XDoes your /etc/passwd file keep full names in Berkeley/V7 format (name first
Xthing after ':' in GCOS field)? In that case, a typical entry in the password
Xfile looks like this:
X
X guest:**paswword**:10:100:Mister Guest User:/usr/users:/bin/sh
X ^^^^^^^^^^^^^^^^^
XEOM
Xrp="Berkeley/V7 format for full name in /etc/password?"
X. ./myread
Xcase "$ans" in
Xy*) d_passnames="$define"
X d_berknames="$define"
X d_usgnames="$undef"
X nametype=bsd
X ;;
X*)
X case "$d_usgnames" in
X "$define") dflt=y;;
X "$undef") dflt=n;;
X *)
X if usg; then
X dflt=y
X else
X dflt=n
X fi
X ;;
X esac
X$cat <<'EOM'
X
XDoes your passwd file keep full names in USG format (name sandwiched between a
X'-' and a '(')? In that case, a typical entry in the password file looks like
Xthis:
X
X guest:**paswword**:10:100:000-Mister Guest User(000):/usr/users:/bin/sh
X ^^^^^^^^^^^^^^^^^
XEOM
X rp="USG format for full name in /etc/passwd?"
X . ./myread
X case "$ans" in
X n*) echo "Full name will be taken from ~/.fullname"
X d_passnames="$undef"
X d_berknames="$undef"
X d_usgnames="$undef"
X nametype=other
X ;;
X *)
X d_passnames="$define"
X d_berknames="$undef"
X d_usgnames="$define"
X nametype=usg
X ;;
X esac;;
Xesac
X
X: figure out their full name
Xcase "$NAME" in
X'') case "$nametype" in
X other)
X fn=`./filexp ~/.fullname`
X xxx=usg
X $test -f $fn && xxx=other
X ;;
X *)
X xxx="$nametype"
X ;;
X esac
X
X case "$xxx" in
X bsd)
X cf_name=`$passcat | grep "^$cf_by:" | \
X sed -e 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1/' \
X -e 's/,.*//'`
X ;;
X usg)
X cf_name=`$passcat | grep "^$cf_by:" | \
X sed -e 's/^[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1/' \
X -e 's/[^-]*-\(.*\)(.*)/\1/'`
X ;;
X *)
X cf_name=`$cat $fn`
X ;;
X esac
X ;;
X*)
X cf_name="$NAME"
X ;;
Xesac
Xecho " "
Xecho "Pleased to meet you, $cf_name."
X
X: now get the host name
Xecho " "
Xecho "Figuring out host name..." >&4
Xcase "$myhostname" in
X'') cont=true
X echo 'Maybe "hostname" will work...'
X if tans=`sh -c hostname 2>&1` ; then
X myhostname=$tans
X phostname=hostname
X cont=''
X fi
X ;;
X*) cont='';;
Xesac
Xif $test "$cont"; then
X if xenix; then
X echo 'Oh, dear. Maybe "/etc/systemid" is the key...'
X if tans=`cat /etc/systemid 2>&1` ; then
X myhostname=$tans
X phostname='cat /etc/systemid'
X echo "Whadyaknow. Xenix always was a bit strange..."
X cont=''
X fi
X elif $test -r /etc/systemid; then
X echo "(What is a non-Xenix system doing with /etc/systemid?)"
X fi
Xfi
Xif $test "$cont"; then
X echo 'No, maybe "uuname -l" will work...'
X if tans=`sh -c 'uuname -l' 2>&1` ; then
X myhostname=$tans
X phostname='uuname -l'
X else
X echo 'Strange. Maybe "uname -n" will work...'
X if tans=`sh -c 'uname -n' 2>&1` ; then
X myhostname=$tans
X phostname='uname -n'
X else
X echo 'Oh well, maybe I can mine it out of whoami.h...'
X if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
X myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
X phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
X else
X case "$myhostname" in
X '') echo "Does this machine have an identity crisis or something?"
X phostname='';;
X *)
X echo "Well, you said $myhostname before..."
X phostname='echo $myhostname';;
X esac
X fi
X fi
X fi
Xfi
X: you do not want to know about this
Xset $myhostname
Xmyhostname=$1
X
X: translate upper to lower if necessary
Xcase "$myhostname" in
X*[A-Z]*)
X myhostname=`echo $myhostname | tr '[A-Z]' '[a-z]'`
X echo "(Normalizing case in your host name)"
X ;;
Xesac
X
X: verify guess
Xif $test "$myhostname" ; then
X dflt=y
X rp='Your host name appears to be "'$myhostname'".'" Right?"
X . ./myread
X case "$ans" in
X y*) ;;
X *) myhostname='';;
X esac
Xfi
X
X: bad guess or no guess
Xwhile $test "X$myhostname" = X ; do
X dflt=''
X rp="Please type the (one word) name of your host:"
X . ./myread
X myhostname="$ans"
Xdone
X
Xcase "$myhostname" in
X*.*)
X dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
X myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
X echo "(Trimming domain name from host name--host name is now $myhostname)"
X ;;
X*) case "$mydomain" in
X '')
X $hostcat >hosts
X dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
X hosts | $sort | $uniq | \
X $sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
X case "$dflt" in
X .) echo "(You do not have fully-qualified names in /etc/hosts)"
X dflt='.uucp';;
X esac
X $rm -f hosts
X ;;
X *) dflt="$mydomain";;
X esac;;
Xesac
Xecho " "
Xrp="What is your domain name?"
X. ./myread
Xtans="$ans"
Xcase "$ans" in
X'') ;;
X.*) ;;
X*) tans=".$tans";;
Xesac
Xmydomain="$tans"
X
X: a little sanity check here
Xcase "$phostname" in
X'') ;;
X*)
X case `$phostname` in
X $myhostname$mydomain|$myhostname) ;;
X *)
X case "$phostname" in
X sed*)
X echo "(That doesn't agree with your whoami.h file, by the way.)"
X ;;
X *)
X echo "(That doesn't agree with your $phostname command, by the way.)"
X ;;
X esac
X ;;
X esac
X ;;
Xesac
X
X$cat <<EOM
X
XI need to get your e-mail address in Internet format if possible, i.e.
Xsomething like user@host.domain. Please answer accurately since I have
Xno easy means to double check it. The default value provided below
Xis most probably close to the reality but may not be valid from outside
Xyour organization...
X
XEOM
Xcont=x
Xwhile test "$cont"; do
X case "$cf_email" in
X '') dflt="$cf_by@$myhostname$mydomain";;
X *) dflt="$cf_email";;
X esac
X rp='What is your e-mail address?'
X . ./myread
X cf_email="$ans"
X case "$cf_email" in
X *@*.*) cont='' ;;
X *)
X rp='Address does not look like an Internet one. Use it anyway?'
X case "$fastread" in
X yes) dflt=y ;;
X *) dflt=n ;;
X esac
X . ./myread
X case "$ans" in
X y*) cont='' ;;
X *) echo " " ;;
X esac
X ;;
X esac
Xdone
X
X: offer to join the mailing list
Xlist_request='listserv@research.canon.oz.au'
Xlist_sub="SUBSCRIBE c2man $cf_name"
Xlist_unsub="UNSUBSCRIBE c2man"
Xlist_name="c2man"
X$cat <<EOM
X
XThere is a mailing list for discussion about $package and related issues.
XThis is the preferred place to ask questions about the program and discuss
Xmodifications and additions with the author and other users. If you are able
Xto send mail to the Internet, you are encouraged to subscribe. You need only
Xever subscribe once, and you can unsubscribe automatically at any time in the
Xfuture. If you have already subscribed and you wish to unsubscribe now, you
Xmay do so by answering "unsubscribe". Answer "subscribe" to subscribe to the
Xlist.
X
XEOM
Xrp="Subscribe to or unsubscribe from the $list_name mailing list?"
Xdflt=neither
X. ./myread
Xcase "$ans" in
X[sS]*) $cat <<EOM
X
XYou will be sent a message from the list server to let you know when your
Xsubscription has been successful and telling you how to submit articles and
Xhow to unsubscribe again when necessary. You may also unsubscribe by running
Xthis script again and asking it to do so for you.
X
XEOM
X echo "Sending mail to subscribe you to the $list_name list..." >&4
X $mailer $list_request <<EOM >/dev/null 2>&1
XPrecedence: junk
XTo: $list_request
X
X$list_sub
XEOM
X ;;
X[uU]*) echo "Sending mail to unsubscribe you from the $list_name list..." >&4
X $mailer $list_request <<EOM >/dev/null 2>&1
XPrecedence: junk
XTo: $list_request
X
X$list_unsub
XEOM
X ;;
Xesac
X
X: end of configuration questions
Xecho " "
Xecho "End of configuration questions."
Xecho " "
X
X: back to where it started
Xif test -d ../UU; then
X cd ..
Xfi
X
X: configuration may be patched via a 'config.over' file
Xif $test -f config.over; then
X echo " "
X dflt=y
X rp='I see a config.over file. Do you wish to load it?'
X . UU/myread
X case "$ans" in
X n*) echo "OK, I'll ignore it.";;
X *) . ./config.over
X echo "Configuration override changes have been loaded."
X ;;
X esac
Xfi
X
X: create config.sh file
Xecho " "
Xecho "Creating config.sh..." >&4
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 -der". You may
X# instead choose to run each of the .SH files by yourself, or "Configure -S".
X#
X
X# Configuration time: $cf_time
X# Configured by: $cf_by
X# Target system: $myuname
X
Xd_bsd='$d_bsd'
Xd_eunice='$d_eunice'
Xd_xenix='$d_xenix'
Xeunicefix='$eunicefix'
XMcc='$Mcc'
Xawk='$awk'
Xbash='$bash'
Xbison='$bison'
Xcat='$cat'
Xchgrp='$chgrp'
Xchmod='$chmod'
Xchown='$chown'
Xcompress='$compress'
Xcp='$cp'
Xcpio='$cpio'
Xcpp='$cpp'
Xcsh='$csh'
Xdate='$date'
Xecho='$echo'
Xegrep='$egrep'
Xemacs='$emacs'
Xexpr='$expr'
Xflex='$flex'
Xgcc='$gcc'
Xgrep='$grep'
Xinews='$inews'
Xksh='$ksh'
Xless='$less'
Xline='$line'
Xlint='$lint'
Xln='$ln'
Xlp='$lp'
Xlpr='$lpr'
Xls='$ls'
Xmail='$mail'
Xmailx='$mailx'
Xmake='$make'
Xmkdir='$mkdir'
Xmore='$more'
Xmv='$mv'
Xnroff='$nroff'
Xperl='$perl'
Xpg='$pg'
Xpmake='$pmake'
Xpr='$pr'
Xrm='$rm'
Xrmail='$rmail'
Xsed='$sed'
Xsendmail='$sendmail'
Xsh='$sh'
Xshar='$shar'
Xsleep='$sleep'
Xsmail='$smail'
Xsort='$sort'
Xsubmit='$submit'
Xtail='$tail'
Xtar='$tar'
Xtbl='$tbl'
Xtest='$test'
Xtouch='$touch'
Xtr='$tr'
Xtroff='$troff'
Xuname='$uname'
Xuniq='$uniq'
Xuuname='$uuname'
Xvi='$vi'
Xzcat='$zcat'
Xmailpatches='$mailpatches'
Xnotifypatches='$notifypatches'
Xusermail='$usermail'
Xhint='$hint'
Xmyuname='$myuname'
XAuthor='$Author'
XDate='$Date'
XHeader='$Header'
XId='$Id'
XLocker='$Locker'
XLog='$Log'
XRCSfile='$RCSfile'
XRevision='$Revision'
XSource='$Source'
XState='$State'
Xafs='$afs'
Xbaserev='$baserev'
Xbin='$bin'
Xbinexp='$binexp'
Xinstallbin='$installbin'
Xcc='$cc'
Xccflags='$ccflags'
Xcppflags='$cppflags'
Xldflags='$ldflags'
Xlkflags='$lkflags'
Xoptimize='$optimize'
Xcf_email='$cf_email'
Xcf_by='$cf_by'
Xcf_time='$cf_time'
Xcontains='$contains'
Xcppfilecom='$cppfilecom'
Xcppstdinflags='$cppstdinflags'
Xd_cppcanstdin='$d_cppcanstdin'
Xd_cppignhdrs='$d_cppignhdrs'
Xcpplast='$cpplast'
Xcppminus='$cppminus'
Xcpprun='$cpprun'
Xcppstdin='$cppstdin'
Xd_access='$d_access'
Xd_const='$d_const'
Xd_flexfnam='$d_flexfnam'
Xd_link='$d_link'
Xd_open3='$d_open3'
Xd_portable='$d_portable'
Xd_index='$d_index'
Xd_strchr='$d_strchr'
Xd_strftime='$d_strftime'
Xd_strstr='$d_strstr'
Xd_symlink='$d_symlink'
Xd_time='$d_time'
Xtimetype='$timetype'
Xd_voidsig='$d_voidsig'
Xsignal_t='$signal_t'
Xd_volatile='$d_volatile'
Xh_fcntl='$h_fcntl'
Xh_sysfile='$h_sysfile'
Xi_fcntl='$i_fcntl'
Xi_stdarg='$i_stdarg'
Xi_stddef='$i_stddef'
Xi_stdlib='$i_stdlib'
Xi_string='$i_string'
Xstrings='$strings'
Xi_sysfile='$i_sysfile'
Xi_systypes='$i_systypes'
Xi_systime='$i_systime'
Xi_systimek='$i_systimek'
Xi_time='$i_time'
Xtimeincl='$timeincl'
Xi_unistd='$i_unistd'
Xi_varargs='$i_varargs'
Xi_varhdr='$i_varhdr'
Xlex='$lex'
Xlibc='$libc'
Xliblex='$liblex'
Xlibpth='$libpth'
Xplibpth='$plibpth'
Xxlibpth='$xlibpth'
Xlibs='$libs'
Xlibyacc='$libyacc'
Xmailer='$mailer'
Xinstallmansrc='$installmansrc'
Xmanext='$manext'
Xmansrc='$mansrc'
Xmansrcexp='$mansrcexp'
Xmkdep='$mkdep'
Xmydomain='$mydomain'
Xmyhostname='$myhostname'
Xphostname='$phostname'
Xc='$c'
Xn='$n'
Xd_berknames='$d_berknames'
Xd_passnames='$d_passnames'
Xd_usgnames='$d_usgnames'
Xnametype='$nametype'
Xgroupcat='$groupcat'
Xhostcat='$hostcat'
Xpasscat='$passcat'
Xpackage='$package'
Xspackage='$spackage'
Xpatchlevel='$patchlevel'
Xinstallprivlib='$installprivlib'
Xprivlib='$privlib'
Xprivlibexp='$privlibexp'
Xprototype='$prototype'
Xsharpbang='$sharpbang'
Xshsharp='$shsharp'
Xspitshell='$spitshell'
Xstartsh='$startsh'
Xsysman='$sysman'
Xnm_opt='$nm_opt'
Xrunnm='$runnm'
Xusenm='$usenm'
Xincpath='$incpath'
Xmips='$mips'
Xmips_type='$mips_type'
Xusrinc='$usrinc'
Xvaproto='$vaproto'
Xdefvoidused='$defvoidused'
Xvoidflags='$voidflags'
Xwarnflags='$warnflags'
Xyacc='$yacc'
Xyaccflags='$yaccflags'
XEOT
X
X: add special variables
X$test -f patchlevel.h && \
Xawk '/^#define/ {printf "%s=%s\n",$2,$3}' patchlevel.h >>config.sh
Xecho "CONFIG=true" >>config.sh
X
X: propagate old symbols
Xif $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 *)
X cat <<EOM
XHmm...You had some extra variables I don't know about...I'll try to keep 'em...
XEOM
X echo "# Variables propagated from previous config.sh file." >>config.sh
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
Xfi
X
X: Finish up by extracting the .SH files
Xcase "$alldone" in
Xexit)
X $rm -rf UU
X echo "Done."
X exit 0
X ;;
Xcont)
X ;;
X'')
X echo " "
X dflt=''
X nostick=true
Xecho "If you didn't make any mistakes, then just type a carriage return here."
X rp="If you need to edit config.sh, do it as a shell escape here:"
X . UU/myread
X nostick=''
X case "$ans" in
X '') ;;
X *) : in case they cannot read
X sh 1>&4 -c "$ans";;
X esac
X ;;
Xesac
X
X: if this fails, just run all the .SH files by hand
X. ./config.sh
X
Xecho " "
Xexec 1>&4
X. ./UU/extract
X
!STUFFY!FUNK!
echo "End of kit 3 (of 9)"
echo " "
cat /dev/null >kit3isdone
run=''
config=''
for iskit in 1 2 3 4 5 6 7 8 9; do
if test -f kit${iskit}isdone; then
run="$run $iskit"
else
todo="$todo $iskit"
fi
done
case $todo in
'')
echo "You have run all your kits."
if test -f PACKNOTES; then
sh PACKNOTES
else
echo "You have to rebuild split files by hand (see PACKLIST)."
fi
echo "Please read README and then type Configure."
chmod 755 Configure
rm -f kit*isdone
;;
*) echo "You have run$run."
echo "You still need to run$todo."
;;
esac
: Someone might mail this, so exit before signature...
exit 0
--
Graham Stoney, Hardware/Software Engineer
Canon Information Systems Research Australia
Ph: + 61 2 805 2909 Fax: + 61 2 805 2929
exit 0 # Just in case...