This is my patch patch.1i for perl5.001.
[p5sagit/p5-mst-13.2.git] / Configure
index 86f28eb..e2910d5 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -18,9 +18,9 @@
 # archive site. Check with Archie if you don't know where that can be.)
 #
 
-# $Id: Head.U,v 3.0.1.6 1994/10/29 15:54:19 ram Exp $
+# $Id: Head.U,v 3.0.1.7 1995/03/21 08:46:15 ram Exp $
 #
-# Generated on Tue Feb 28 10:00:27 EST 1995 [metaconfig 3.0 PL51]
+# Generated on Wed May 31 09:14:05 EDT 1995 [metaconfig 3.0 PL55]
 
 cat >/tmp/c1$$ <<EOF
 ARGGGHHHH!!!!!
@@ -58,11 +58,13 @@ esac
 
 : Proper PATH setting
 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
-paths=$paths:'/usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin'
-paths=$paths:'/sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
-paths=$paths:'/bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin'
-paths=$paths:'/etc /usr/lib /usr/ucblib /lib /usr/ccs/lib'
-paths=$paths:'/sbin /usr/sbin /usr/libexec'
+paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
+paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
+paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
+paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
+paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
+paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
+paths="$paths /sbin /usr/sbin /usr/libexec"
 
 for p in $paths
 do
@@ -229,7 +231,6 @@ d_alarm=''
 d_attribut=''
 d_bcmp=''
 d_bcopy=''
-d_byacc=''
 d_bzero=''
 d_casti32=''
 castflags=''
@@ -252,7 +253,6 @@ d_dlopen=''
 d_dlsymun=''
 d_dosuid=''
 d_suidsafe=''
-d_drem=''
 d_dup2=''
 d_fchmod=''
 d_fchown=''
@@ -263,7 +263,6 @@ d_fds_bits=''
 d_fgetpos=''
 d_flexfnam=''
 d_flock=''
-d_fmod=''
 d_fork=''
 d_fsetpos=''
 d_Gconvert=''
@@ -282,7 +281,6 @@ d_htonl=''
 d_isascii=''
 d_killpg=''
 d_link=''
-d_linuxstd=''
 d_locconv=''
 d_lockf=''
 d_lstat=''
@@ -351,7 +349,12 @@ d_sockpair=''
 sockethdr=''
 socketlib=''
 d_statblks=''
+d_stdiobase=''
 d_stdstdio=''
+stdio_base=''
+stdio_bufsiz=''
+stdio_cnt=''
+stdio_ptr=''
 d_index=''
 d_strchr=''
 d_strcoll=''
@@ -390,6 +393,7 @@ cccdlflags=''
 ccdlflags=''
 d_shrplib=''
 dlsrc=''
+ld=''
 lddlflags=''
 shrpdir=''
 usedl=''
@@ -471,10 +475,14 @@ mallocobj=''
 mallocsrc=''
 malloctype=''
 usemymalloc=''
-installmansrc=''
-manext=''
-mansrc=''
-mansrcexp=''
+installman1dir=''
+man1dir=''
+man1direxp=''
+man1ext=''
+installman3dir=''
+man3dir=''
+man3direxp=''
+man3ext=''
 huge=''
 large=''
 medium=''
@@ -507,6 +515,10 @@ scriptdir=''
 scriptdirexp=''
 selecttype=''
 sig_name=''
+d_sitelib=''
+installsitelib=''
+sitelib=''
+sitelibexp=''
 sizetype=''
 so=''
 sharpbang=''
@@ -607,7 +619,6 @@ al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
 al="$al xenix z8000"
 
-gccversion=''
 groupstype=''
 i_whoami=''
 : change the next line if compiling for Xenix/286 on Xenix/386
@@ -696,7 +707,7 @@ EOS
 : produce awk script to parse command line options
 cat >options.awk <<'EOF'
 BEGIN {
-       optstr = "dD:eEf:hOrsSU:V";     # getopt-style specification
+       optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
 
        len = length(optstr);
        for (i = 1; i <= len; i++) {
@@ -754,6 +765,7 @@ error=''
 silent=''
 extractsh=''
 override=''
+knowitall=''
 rm -f optdef.sh
 
 : option parsing
@@ -776,6 +788,7 @@ while test $# -gt 0; do
        -r) shift; reuseval=true;;
        -s) shift; silent=true;;
        -E) shift; alldone=exit;;
+       -K) shift; knowitall=true;;
        -O) shift; override=true;;
        -S) shift; extractsh=true;;
        -D)
@@ -803,7 +816,7 @@ while test $# -gt 0; do
                esac
                shift
                ;;
-       -V) echo "$me generated by metaconfig 3.0 PL51." >&2
+       -V) echo "$me generated by metaconfig 3.0 PL55." >&2
                exit 0;;
        --) break;;
        -*) echo "$me: unknown option $1" >&2; shift; error=true;;
@@ -814,7 +827,7 @@ done
 case "$error" in
 true)
        cat >&2 <<EOM
-Usage: $me [-dehrEOSV] [-f config.sh] [-D symbol] [-D symbol=value]
+Usage: $me [-dehrEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
                  [-U symbol] [-U symbol=]
   -d : use defaults for all answers.
   -e : go on without questioning past the production of config.sh.
@@ -826,6 +839,7 @@ Usage: $me [-dehrEOSV] [-f config.sh] [-D symbol] [-D symbol=value]
          -D symbol         symbol gets the value 'define'
          -D symbol=value   symbol gets the value 'value'
   -E : stop at the end of questions, after having produced config.sh.
+  -K : do not use unless you know what you are doing.
   -O : let -D and -U override definitions from loaded configuration file.
   -S : perform variable substitutions on all .SH files (can mix with -f)
   -U : undefine symbol:
@@ -1425,16 +1439,19 @@ myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
        ./tr '[A-Z]' '[a-z]' | tr '\012' ' '`
 newmyuname="$myuname"
 dflt=n
-if test "$fastread" = yes; then
-       dflt=y
-elif test -f ../config.sh; then
-       if $contains myuname= ../config.sh >/dev/null 2>&1; then
-               eval "`grep myuname= ../config.sh`"
-       fi
-       if test "X$myuname" = "X$newmyuname"; then
-               dflt=y
+case "$knowitall" in
+'')
+       if test -f ../config.sh; then
+               if $contains myuname= ../config.sh >/dev/null 2>&1; then
+                       eval "`grep myuname= ../config.sh`"
+               fi
+               if test "X$myuname" = "X$newmyuname"; then
+                       dflt=y
+               fi
        fi
-fi
+       ;;
+*) dflt=y;;
+esac
 
 : Get old answers from old config file if Configure was run on the
 : same system, otherwise use the hints.
@@ -1479,6 +1496,9 @@ EOM
        $test -d /usr/apollo/bin && osname=apollo
        $test -f /etc/saf/_sactab && osname=svr4
        $test -d /usr/include/minix && osname=minix
+       $test -d /MachTen && osname=machten && \
+               osvers=`/usr/etc/version | $awk '{print $2}' | \
+               $sed -e 's/[A-Za-z]$//'`
        if $test -f $uname; then
                set X $myuname
                shift
@@ -2105,7 +2125,15 @@ if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
        *)  echo "You are using GNU cc $gccversion." ;;
        esac
 else
-       echo "I can't compile the test program -- Assuming it isn't GNU cc."
+       echo " "
+       echo "*** WHOA THERE!!! ***" >&4
+       echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
+       case "$knowitall" in
+       '')
+       echo "    You'd better start hunting for one and let me know about it." >&4
+               exit 1
+               ;;
+       esac
 fi
 $rm -f gccvers*
 case "$gccversion" in
@@ -2744,6 +2772,60 @@ none) ldflags='';;
 esac
 rmlist="$rmlist pdp11"
 
+: coherency check
+echo " "
+echo "Checking your choice of C compiler and flags for coherency..." >&4
+set X $cc $optimize $ccflags try.c -o try $ldflags
+shift
+$cat >try.msg <<EOM
+I've tried to compile and run a simple program with:
+
+       $*
+       ./try
+
+and I got the following output:
+
+EOM
+$cat > try.c <<'EOF'
+#include <stdio.h>
+main() { exit(0); }
+EOF
+dflt=y
+if sh -c "$cc $optimize $ccflags try.c -o try $ldflags" >>try.msg 2>&1; then
+       if sh -c './try' >>try.msg 2>&1; then
+               dflt=n
+       else
+               echo "The program compiled OK, but exited with status $?." >>try.msg
+               rp="You have a problem.  Shall I abort Configure"
+               dflt=y
+       fi
+else
+       echo "I can't compile the test program." >>try.msg
+       rp="You have a BIG problem.  Shall I abort Configure"
+       dflt=y
+fi
+case "$dflt" in
+y)
+       $cat try.msg
+       case "$knowitall" in
+       '')
+               echo "(The supplied flags might be incorrect with this C compiler.)"
+               ;;
+       *) dflt=n;;
+       esac
+       echo " "
+       . ./myread
+       case "$ans" in
+       n*|N*) ;;
+       *)      echo "Ok.  Stopping Configure." >&4
+               exit 1
+               ;;
+       esac
+       ;;
+n) echo "OK, that should do.";;
+esac
+$rm -f try try.* core
+
 : Set private lib path
 case "$plibpth" in
 '') if ./mips; then
@@ -2991,10 +3073,18 @@ unknown)
        set /usr/ccs/lib/libc.$so
        $test -r $1 || set /usr/lib/libc.$so
        $test -r $1 || set /usr/shlib/libc.$so
-       $test -r $1 || set /usr/lib/libc.$so.[0-9]*
+       $test -r $1 || \
+               set `echo blurfl; echo /usr/lib/libc.$so.[0-9]* | \
+               tr ' ' '\012' | egrep -v '\.[A-Za-z]*$' | $sed -e '
+                       h
+                       s/[0-9][0-9]*/0000&/g
+                       s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
+                       G
+                       s/\n/ /' | \
+                sort | $sed -e 's/^.* //'`
+       eval set \$$#
        $test -r $1 || set /lib/libc.$so
        $test -r $1 || set /lib/libsys_s.a
-       eval set \$$#
        ;;
 *)
        set blurfl
@@ -3084,7 +3174,8 @@ $echo $n ".$c"
 $grep fprintf libc.tmp > libc.ptf
 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
-if com="$sed -n -e 's/^.* [ADTSI]  *_[_.]*//p' -e 's/^.* [ADTSI] //p'";\
+xxx='[ADTSIW]'
+if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx //p'";\
        eval $xscan;\
        $contains '^fprintf$' libc.list >/dev/null 2>&1; then
                eval $xrun
@@ -3127,11 +3218,12 @@ elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
                eval $xrun
 else
        nm -p $* 2>/dev/null >libc.tmp
-       com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'";\
-       eval "<libc.tmp $com >libc.list"
-       if $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+       $grep fprintf libc.tmp > libc.ptf
+       if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
+               eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
+       then
                nm_opt='-p'
-               echo "done" >&4
+               eval $xrun
        else
                echo " "
                echo "nm didn't seem to work right. Trying ar instead..." >&4
@@ -3145,7 +3237,8 @@ else
                else
                        echo "ar didn't seem to work right." >&4
                        echo "Maybe this is a Cray...trying bld instead..." >&4
-                       if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
+                       if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list
+                       then
                                for thisname in $libnames; do
                                        bld t $libnames | \
                                        $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
@@ -3190,7 +3283,7 @@ yes)
                else tval=false;
                fi;;
        *)
-               echo "main() { extern int $1$tdc; printf(\"%d\", $1$tc); }" > t.c;
+               echo "main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
                if $cc $ccflags -o t t.c $ldflags $libs >/dev/null 2>&1;
                then tval=true;
                else tval=false;
@@ -3246,8 +3339,15 @@ yes)
 esac'
 
 : see if gconvert exists
+: On some SVR4 systems, gconvert is present but can not be used 
+: because it requires some other unavailable functions.
+: Therefore, do not use the nm extraction, but use a real compile
+: and link test instead.
+xxx_runnm="$runnm"
+runnm=false
 set gconvert d_gconvert
 eval $inlibc
+runnm="$xxx_runnm"
 
 case "$d_gconvert" in
 $define)
@@ -3698,14 +3798,6 @@ set d_bsdpgrp
 eval $setvar
 $rm -f set set.c
 
-: Check if we really have byacc
-case "$byacc" in
-''|'byacc') val="$undef" ;;
-*) val="$define" ;;
-esac
-set d_byacc
-eval $setvar
-
 : see if bzero exists
 set bzero d_bzero
 eval $inlibc
@@ -3829,10 +3921,14 @@ echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
 $cat >try.c <<EOCP
 #include <sys/types.h>
 #include <signal.h>
-$signal_t blech() { exit(3); }
+$signal_t blech() { exit(7); }
+$signal_t blech_in_list() { exit(4); }
+unsigned long dummy_long(p) unsigned long p; { return p; }
+unsigned int dummy_int(p) unsigned int p; { return p; }
+unsigned short dummy_short(p) unsigned short p; { return p; }
 main()
 {
-       double f = -123;
+       double f = -123.;
        unsigned long along;
        unsigned int aint;
        unsigned short ashort;
@@ -3864,6 +3960,19 @@ main()
        along = (unsigned long)f;
        if (along != 0x80000001)
                result |= 2;
+       if (result)
+               exit(result);
+       signal(SIGFPE, blech_in_list);
+       f = 123.;
+       along = dummy_long((unsigned long)f);
+       aint = dummy_int((unsigned int)f);
+       ashort = dummy_short((unsigned short)f);
+       if (along != (unsigned long)123)
+               result |= 4;
+       if (aint != (unsigned int)123)
+               result |= 4;
+       if (ashort != (unsigned short)123)
+               result |= 4;
        exit(result);
 
 }
@@ -3873,7 +3982,7 @@ if $cc -o try $ccflags try.c >/dev/null 2>&1; then
        castflags=$?
 else
        echo "(I can't seem to compile the test program--assuming it can't)"
-       castflags=3
+       castflags=7
 fi
 case "$castflags" in
 0)     val="$define"
@@ -4016,10 +4125,10 @@ while $test "$cont"; do
        var=$2; eval "was=\$$2";
        if $test "$xxx" && $test -r "$xxx";
        then eval $xxf;
-               eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
+       eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
                cont="";
        else eval $xxnf;
-               eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
+       eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
        set $yyy; shift; shift; yyy=$@;
        case $# in 0) cont="";;
        2) xxf="echo \"but I found <\$1> $instead.\" >&4";
@@ -4142,16 +4251,28 @@ eval $setvar
 $rm -f try.c
 
 : see if dlerror exists
+: On NetBSD and FreeBSD, dlerror might be available, but it is in 
+: /usr/lib/crt0.o, not in any of the libraries.  Therefore, do not
+: use the nm extraction, but use a real compile and link test instead.
+xxx_runnm="$runnm"
+runnm=false
 set dlerror d_dlerror
 eval $inlibc
+runnm="$xxx_runnm"
 
 : see if dld is available
 set dld.h i_dld
 eval $inhdr
 
 : see if dlopen exists
+: On NetBSD and FreeBSD, dlopen is available, but it is in 
+: /usr/lib/crt0.o, not in any of the libraries.  Therefore, do not
+: use the nm extraction, but use a real compile and link test instead.
+xxx_runnm="$runnm"
+runnm=false
 set dlopen d_dlopen
 eval $inlibc
+runnm="$xxx_runnm"
 
 : determine which dynamic loading, if any, to compile in
 echo " "
@@ -4206,6 +4327,7 @@ y*) usedl="$define"
        usedl="$define"
        : emulate basename
        dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
+
     $cat << EOM
 
 Some systems may require passing special flags to $cc -c to
@@ -4214,29 +4336,69 @@ To use no flags, say "none".
 
 EOM
     case "$cccdlflags" in
-    ''|' ') case "$cc" in
-               *gcc*)  dflt='-fpic' ;;
-               *)  case "$osname" in
+    '')        case "$gccversion" in
+               '') case "$osname" in
                        hpux)   dflt='+z' ;;
                        next)   dflt='none' ;;
-                       solaris) dflt='-K pic' ;;
+                       solaris|svr4*|esix*) dflt='-Kpic' ;;
                        sunos)  dflt='-pic' ;;
-                       svr4*|esix*) dflt='-Kpic' ;;
                        *)      dflt='none' ;;
                    esac ;;
+               *)      dflt='-fpic' ;;
            esac ;;
-    *) dflt="$cccdlflags" ;;
+    *) dflt="$cccdlflags" ;;
     esac
     rp="Any special flags to pass to $cc -c to compile shared library modules?"
     . ./myread
     case "$ans" in
-    none) cccdlflags='' ;;
+    none) cccdlflags=' ' ;;
     *) cccdlflags="$ans" ;;
     esac
 
-    cat << 'EOM'
+    cat << EOM
 
-Some systems may require passing special flags to ld to create a
+Some systems use ld to create libraries that can be dynamically loaded,
+while other systems (such as those using ELF) use $cc.
+
+EOM
+       case "$ld" in
+       '')     $cat >try.c <<'EOM'
+/* Test for whether ELF binaries are produced */
+#include <fcntl.h>
+#include <stdlib.h>
+main() {
+       char b[4];
+       int i = open("a.out",O_RDONLY);
+       if(i == -1) 
+               exit(1); /* fail */
+       if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
+               exit(0); /* succeed (yes, it's ELF) */
+       else
+               exit(1); /* fail */
+}
+EOM
+               if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
+                       cat <<EOM
+You appear to have ELF support.  I'll use $cc to build dynamic libraries.
+EOM
+                       dflt="$cc"
+               else
+                       echo "I'll use ld to build dynamic libraries."
+                       dflt='ld'
+               fi
+               rm -f try.c a.out
+               ;;
+       *)      dflt="$ld"
+               ;;
+       esac
+
+    rp="What command should be used to create dynamic libraries?"
+    . ./myread
+       ld="$ans"
+
+    cat << EOM
+
+Some systems may require passing special flags to $ld to create a
 library that can be dynamically loaded.  If your ld flags include
 -L/other/path options to locate libraries outside your loader's normal
 search path, you may need to specify those -L options here as well.  To
@@ -4244,8 +4406,9 @@ use no flags, say "none".
 
 EOM
     case "$lddlflags" in
-    ''|' ') case "$osname" in
+    '') case "$osname" in
                        hpux)  dflt='-b' ;;
+                       linux)  dflt='-shared' ;;
                        next)  dflt='none' ;;
                        solaris) dflt='-G' ;;
                        sunos) dflt='-assert nodefinitions' ;;
@@ -4255,10 +4418,10 @@ EOM
                        ;;
     *) dflt="$lddlflags" ;;
     esac
-    rp="Any special flags to pass to ld to create a dynamically loaded library?"
+    rp="Any special flags to pass to $ld to create a dynamically loaded library?"
     . ./myread
     case "$ans" in
-    none) lddlflags='' ;;
+    none) lddlflags=' ' ;;
     *) lddlflags="$ans" ;;
     esac
 
@@ -4270,8 +4433,9 @@ say "none".
 
 EOM
     case "$ccdlflags" in
-    ''|' ') case "$osname" in
-               hpux)   dflt='none' ;;
+    '') case "$osname" in
+               hpux)   dflt='-Wl,-E' ;;
+               linux)  dflt='-rdynamic' ;;
                next)   dflt='none' ;;
                sunos)  dflt='none' ;;
                *)      dflt='none' ;;
@@ -4281,11 +4445,12 @@ EOM
     rp="Any special flags to pass to $cc to use dynamic loading?"
     . ./myread
     case "$ans" in
-    none) ccdlflags='' ;;
+    none) ccdlflags=' ' ;;
     *) ccdlflags="$ans" ;;
     esac
     ;;
 *)  usedl="$undef"
+       ld='ld'
     dlsrc='dl_none.xs'
     lddlflags=''
     ccdlflags=''
@@ -4417,7 +4582,7 @@ main()
 }
 EOM
        if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
-               ld $lddlflags -o dyna.$dlext dyna.o > /dev/null 2>&1 && 
+               $ld $lddlflags -o dyna.$dlext dyna.o > /dev/null 2>&1 && 
                $cc $ccflags $ldflags $cccdlflags $ccdlflags fred.c -o fred $libs > /dev/null 2>&1; then
                xxx=`./fred`
                case $xxx in
@@ -4549,10 +4714,6 @@ esac
 set d_dosuid
 eval $setvar
 
-: see if drem exists
-set drem d_drem
-eval $inlibc
-
 : see if dup2 exists
 set dup2 d_dup2
 eval $inlibc
@@ -4620,10 +4781,6 @@ $rm -rf /tmp/cf$$ 123456789abcde*
 set flock d_flock
 eval $inlibc
 
-: see if fmod exists
-set fmod d_fmod
-eval $inlibc
-
 : see if fork exists
 set fork d_fork
 eval $inlibc
@@ -4789,47 +4946,6 @@ eval $inlibc
 set link d_link
 eval $inlibc
 
-: see if stdio is really std
-echo " "
-xxx=`./findhdr stdio.h`
-if $contains 'char.*_ptr;' "$xxx" >/dev/null 2>&1 ; then
-       if $contains '_cnt;' "$xxx" >/dev/null 2>&1 ; then
-               echo "Your stdio is pretty std." >&4
-               val="$define"
-       else
-               echo "Your stdio isn't very std." >&4
-               val="$undef"
-       fi
-else
-       echo "Your stdio isn't very std." >&4
-       val="$undef"
-fi
-set d_stdstdio
-eval $setvar
-
-: see if stdio is like that in linux
-case "$d_stdstdio" in
-"$undef")
-       echo " "
-       xxx=`./findhdr stdio.h`
-       $cppstdin $cppflags $cppminus < "$xxx" > stdio.E
-       if $contains 'char.*_IO_read_base' stdio.E >/dev/null 2>&1 && \
-               $contains '_IO_read_ptr' stdio.E >/dev/null 2>&1 && \
-               $contains '_IO_read_end' stdio.E >/dev/null 2>&1 ; then
-                       echo "Your stdio looks like linux." >&4
-                       val="$define"
-       else
-               echo "You don't have linux stdio, either." >&4
-               val="$undef"
-       fi
-       $rm -f stdio.E
-       ;;
-*)     val="$undef" ;;
-esac
-
-set d_linuxstd
-eval $setvar
-
 : see if localeconv exists
 set localeconv d_locconv
 eval $inlibc
@@ -5201,10 +5317,10 @@ memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
 for (align = 7; align >= 0; align--) {
        for (len = 36; len; len--) {
                b = buf+align;
-               memcpy(abc, b, len);
+               memcpy(b, abc, len);
                for (off = 1; off <= len; off++) {
-                       memcpy(b, b+off, len);
                        memcpy(b+off, b, len);
+                       memcpy(b, b+off, len);
                        if (memcmp(b, abc, len))
                                exit(1);
                }
@@ -5375,6 +5491,49 @@ fi
 set d_shm
 eval $setvar
 
+: determine whether the user wants to include a site-specific library
+: in addition to privlib.
+$cat <<EOM
+
+Some sites may wish to specify a local directory for $package
+to search by default in addition to $privlib.
+If you don't want to use such an additional directory, answer 'none'.
+
+EOM
+dflt=none
+fn=d~+n
+rp='Local directory for additional library files?'
+. ./getfile
+if $test "X$sitelibexp" != "X$ansexp"; then
+       installsitelib=''
+fi
+sitelib="$ans"
+sitelibexp="$ansexp"
+if $afs; then
+       $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+private files reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+       case "$installsitelib" in
+       '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
+       *) dflt="$installsitelib";;
+       esac
+       fn=de~
+       rp='Where will additional local files be installed?'
+       . ./getfile
+       installsitelib="$ans"
+else
+       installsitelib="$sitelibexp"
+fi
+
+case "$sitelibexp" in
+''|' ') d_sitelib=undef ;;
+*) d_sitelib=define ;;
+esac
+
 socketlib=''
 sockethdr=''
 : see whether socket exists
@@ -5446,6 +5605,103 @@ fi
 set d_statblks
 eval $setvar
 
+: see if _ptr and _cnt from stdio act std
+echo " "
+if $contains '_IO_fpos_t' `./findhdr stdio.h` >/dev/null 2>&1 ; then
+       echo "(Looks like you have stdio.h from Linux.)"
+       case "$stdio_ptr" in
+       '') stdio_ptr='((fp)->_IO_read_ptr)';;
+       esac
+       case "$stdio_cnt" in
+       '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)';;
+       esac
+       case "$stdio_base" in
+       '') stdio_base='((fp)->_IO_read_base)';;
+       esac
+       case "$stdio_bufsiz" in
+       '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base))';;
+       esac
+else
+       case "$stdio_ptr" in
+       '') stdio_ptr='((fp)->_ptr)';;
+       esac
+       case "$stdio_cnt" in
+       '') stdio_cnt='((fp)->_cnt)';;
+       esac
+       case "$stdio_base" in
+       '') stdio_base='((fp)->_base)';;
+       esac
+       case "$stdio_bufsiz" in
+       '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
+       esac
+fi
+: test whether _ptr and _cnt really work
+echo "Checking how std your stdio is..." >&4
+$cat >try.c <<EOP
+#include <stdio.h>
+#define FILE_ptr(fp)   $stdio_ptr
+#define FILE_cnt(fp)   $stdio_cnt
+main() { 
+       FILE *fp = fopen("try.c", "r");
+       char c = getc(fp);
+       if (
+               18 <= FILE_cnt(fp) &&
+               strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
+       )
+               exit(0);
+       exit(1);
+}
+EOP
+val="$undef"
+if $cc $ccflags $ldflags -o try try.c $libs >/dev/null 2>&1; then
+       if ./try; then
+               echo "Your stdio acts pretty std."
+               val="$define"
+       else
+               echo "Your stdio isn't very std."
+       fi
+else
+       echo "Your stdio doesn't appear very std."
+fi
+$rm -f try.c try
+set d_stdstdio
+eval $setvar
+
+: see if _base is also standard
+val="$undef"
+case "$d_stdstdio" in
+$define)
+       $cat >try.c <<EOP
+#include <stdio.h>
+#define FILE_base(fp)  $stdio_base
+#define FILE_bufsiz(fp)        $stdio_bufsiz
+main() { 
+       FILE *fp = fopen("try.c", "r");
+       char c = getc(fp);
+       if (
+               19 <= FILE_bufsiz(fp) &&
+               strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
+       )
+               exit(0);
+       exit(1);
+}
+EOP
+       if $cc $ccflags $ldflags -o try try.c $libs > /dev/null 2>&1; then
+               if ./try; then
+                       echo "Even its _base field acts std."
+                       val="$define"
+               else
+                       echo "But its _base field isn't std."
+               fi
+       else
+               echo "However, it seems to be lacking the _base field."
+       fi
+       $rm -f try.c try
+       ;;
+esac
+set d_stdiobase
+eval $setvar
+
 : see if strcoll exists
 set strcoll d_strcoll
 eval $inlibc
@@ -5623,7 +5879,10 @@ if $test -d /usr/etc/yp || $test -d /etc/yp; then
                . ./myread
                case "$ans" in
                y*) hostcat='nidump hosts .';;
-               *) ;;
+               *)      case "$hostcat" in
+                       nidump*) hostcat='';;
+                       esac
+                       ;;
                esac
        fi
        case "$hostcat" in
@@ -6093,20 +6352,20 @@ eval $inhdr
 case "$i_db" in
 define)
        : Check the return type needed for hash 
+       echo " "
        echo "Checking return type needed for hash for Berkeley DB ..." >&4
-       cat >try.c <<'EOCP'
+       $cat >try.c <<'EOCP'
 #include <sys/types.h>
 #include <db.h>
-u_int32_t 
-hash_cb (ptr, size)
-const void * ptr ;
-size_t size ;
+u_int32_t hash_cb (ptr, size)
+void *ptr;
+size_t size;
 {
 }
-HASHINFO info ;
+HASHINFO info;
 main()
 {
-    info.hash = hash_cb ;
+       info.hash = hash_cb;
 }
 EOCP
        if $cc $ccflags -c try.c >try.out 2>&1 ; then
@@ -6119,7 +6378,7 @@ EOCP
                echo "I can't seem to compile the test program." >&4
                db_hashtype=int
        fi
-       $rm -f try.[co]
+       $rm -f try.*
        echo "Your version of Berkeley DB uses $db_hashtype for hash."
        ;;
 *)     db_hashtype=int
@@ -6129,20 +6388,20 @@ esac
 case "$i_db" in
 define)
        : Check the return type needed for prefix 
+       echo " "
        echo "Checking return type needed for prefix for Berkeley DB ..." >&4
        cat >try.c <<'EOCP'
 #include <sys/types.h>
 #include <db.h>
-size_t 
-prefix_cb (key1, key2)
-const DBT * key1 ;
-const DBT * key2 ;
+size_t prefix_cb (key1, key2)
+DBT *key1;
+DBT *key2;
 {
 }
-BTREEINFO info ;
+BTREEINFO info;
 main()
 {
-    info.prefix = prefix_cb ;
+       info.prefix = prefix_cb;
 }
 EOCP
        if $cc $ccflags -c try.c  >try.out 2>&1 ; then
@@ -6155,7 +6414,7 @@ EOCP
                echo "I can't seem to compile the test program." >&4
                db_prefixtype='int'
        fi
-       $rm -f try.[co]
+       $rm -f try.*
        echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
        ;;
 *)     db_prefixtype='int'
@@ -6314,10 +6573,26 @@ eval $setvar
 echo " "
 echo "Looking for extensions..." >&4
 cd ../ext
+: If we are using the old config.sh, known_extensions may contain
+: old or inaccurate or duplicate values.
 known_extensions=''
+: We do not use find because it might not be available.
+: We do not just use MANIFEST because the user may have dropped
+: some additional extensions into the source tree and expect them
+: to be built.
 for xxx in * ; do
        if $test -f $xxx/$xxx.xs; then
                known_extensions="$known_extensions $xxx"
+       else
+               if $test -d $xxx; then
+                       cd $xxx
+                       for yyy in * ; do
+                               if $test -f $yyy/$yyy.xs; then
+                                       known_extensions="$known_extensions $xxx/$yyy"
+                               fi
+                       done
+                       cd ..
+               fi
        fi
 done
 set X $known_extensions
@@ -6372,7 +6647,7 @@ them at all.  Answer "none" to include no extensions.
 
 EOM
        case "$dynamic_ext" in
-       ''|' ') dflt="$avail_ext" ;;
+       '') dflt="$avail_ext" ;;
        *)      dflt="$dynamic_ext" ;;
        esac
        case "$dflt" in
@@ -6381,12 +6656,12 @@ EOM
        rp="What extensions do you wish to load dynamically?"
        . ./myread
        case "$ans" in
-       none) dynamic_ext='' ;;
+       none) dynamic_ext=' ' ;;
        *) dynamic_ext="$ans" ;;
        esac
 
        case "$static_ext" in
-       ''|' ')
+       '')
                : Exclude those already listed in dynamic linking
                dflt=''
                for xxx in $avail_ext; do
@@ -6409,7 +6684,7 @@ EOM
        rp="What extensions do you wish to load statically?"
        . ./myread
        case "$ans" in
-       none) static_ext='' ;;
+       none) static_ext=' ' ;;
        *) static_ext="$ans" ;;
        esac
        ;;
@@ -6420,7 +6695,7 @@ to include no extensions.
 
 EOM
        case "$static_ext" in
-       ''|' ') dflt="$avail_ext" ;;
+       '') dflt="$avail_ext" ;;
        *)      dflt="$static_ext" ;;
        esac
 
@@ -6430,7 +6705,7 @@ EOM
        rp="What extensions do you wish to include?"
        . ./myread
        case "$ans" in
-       none) static_ext='' ;;
+       none) static_ext=' ' ;;
        *) static_ext="$ans" ;;
        esac
        ;;
@@ -6505,7 +6780,7 @@ rp="What type is lseek's offset on this system declared as?"
 lseektype="$ans"
 
 : determine where manual pages go
-set mansrc mansrc none
+set man1dir man1dir none
 eval $prefixit
 $cat <<EOM
 
@@ -6514,12 +6789,12 @@ EOM
 case "$nroff" in
 nroff)
        echo "However, you don't have nroff, so they're probably useless to you."
-       case "$mansrc" in
-       '') mansrc="none";;
+       case "$man1dir" in
+       '') man1dir="none";;
        esac;;
 esac
 echo "If you don't want the manual sources installed, answer 'none'."
-case "$mansrc" in
+case "$man1dir" in
 '')
        lookpath="$prefixexp/man/man1 $prefixexp/man/u_man/man1"
        lookpath="$lookpath $prefixexp/man/l_man/man1"
@@ -6527,9 +6802,9 @@ case "$mansrc" in
        lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
        lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
        lookpath="$lookpath /usr/man/man.L"
-       mansrc=`./loc . $prefixexp/man/man1 $lookpath`
-       if $test -d "$mansrc"; then
-               dflt="$mansrc"
+       man1dir=`./loc . $prefixexp/man/man1 $lookpath`
+       if $test -d "$man1dir"; then
+               dflt="$man1dir"
        else
                dflt="$sysman"
        fi
@@ -6537,21 +6812,104 @@ case "$mansrc" in
        eval $prefixup
        ;;
 ' ') dflt=none;;
-*)  dflt="$mansrc"
+*)  dflt="$man1dir"
        ;;
 esac
 echo " "
 fn=dn~
-rp='Where do the manual pages (source) go?'
+rp="Where do the main $spackage manual pages (source) go?"
+. ./getfile
+if test "X$man1direxp" != "X$ansexp"; then
+       installman1dir=''
+fi
+man1dir="$ans"
+man1direxp="$ansexp"
+case "$man1dir" in
+'') man1dir=' '
+       installman1dir='';;
+esac
+if $afs; then
+       $cat <<EOM
+
+Since you are running AFS, I need to distinguish the directory in which
+manual pages reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
+
+EOM
+       case "$installman1dir" in
+       '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
+       *) dflt="$installman1dir";;
+       esac
+       fn=de~
+       rp='Where will man pages be installed?'
+       . ./getfile
+       installman1dir="$ans"
+else
+       installman1dir="$man1direxp"
+fi
+
+case "$man1dir" in
+' ') man1ext='0';;
+*l) man1ext=l;;
+*n) man1ext=n;;
+*o) man1ext=l;;
+*p) man1ext=n;;
+*C) man1ext=C;;
+*L) man1ext=L;;
+*L1) man1ext=L1;;
+*) man1ext=1;;
+esac
+
+: determine where library module manual pages go
+set man3dir man3dir none
+eval $prefixit
+$cat <<EOM
+
+$spackage has manual pages for many of the library modules.
+EOM
+
+case "$nroff" in
+nroff)
+       $cat <<'EOM'
+However, you don't have nroff, so they're probably useless to you.
+You can use the supplied perldoc script instead.
+EOM
+       case "$man3dir" in
+       '') man3dir="none";;
+       esac;;
+esac
+
+case "$d_flexfnam" in
+undef)
+       $cat <<'EOM'
+However, your system can't handle the long file names like File::Basename.3. 
+You can use the supplied perldoc script instead.
+EOM
+       case "$man3dir" in
+       '') man3dir="none";;
+       esac;;
+esac
+
+echo "If you don't want the manual sources installed, answer 'none'."
+case "$man3dir" in
+'')    dflt="$privlib/man/man3" ;;
+' ') dflt=none;;
+*)     dflt="$man3dir" ;;
+esac
+echo " "
+
+fn=dn~
+rp="Where do the $spackage library man pages (source) go?"
 . ./getfile
-if test "X$mansrcexp" != "X$ansexp"; then
-       installmansrc=''
+if test "X$man3direxp" != "X$ansexp"; then
+       installman3dir=''
 fi
-mansrc="$ans"
-mansrcexp="$ansexp"
-case "$mansrc" in
-'') mansrc=' '
-       installmansrc='';;
+
+man3dir="$ans"
+man3direxp="$ansexp"
+case "$man3dir" in
+'') man3dir=' '
+       installman3dir='';;
 esac
 if $afs; then
        $cat <<EOM
@@ -6561,28 +6919,28 @@ manual pages reside from the directory in which they are installed (and from
 which they are presumably copied to the former directory by occult means).
 
 EOM
-       case "$installmansrc" in
-       '') dflt=`echo $mansrcexp | sed 's#^/afs/#/afs/.#'`;;
-       *) dflt="$installmansrc";;
+       case "$installman3dir" in
+       '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
+       *) dflt="$installman3dir";;
        esac
        fn=de~
        rp='Where will man pages be installed?'
        . ./getfile
-       installmansrc="$ans"
+       installman3dir="$ans"
 else
-       installmansrc="$mansrcexp"
+       installman3dir="$man3direxp"
 fi
 
-case "$mansrc" in
-' ') manext='0';;
-*l) manext=l;;
-*n) manext=n;;
-*o) manext=l;;
-*p) manext=n;;
-*C) manext=C;;
-*L) manext=L;;
-*L1) manext=L1;;
-*) manext=1;;
+case "$man3dir" in
+' ') man3ext='0';;
+*l) man3ext=l;;
+*n) man3ext=n;;
+*o) man3ext=l;;
+*p) man3ext=n;;
+*C) man3ext=C;;
+*L) man3ext=L;;
+*L3) man3ext=L3;;
+*) man3ext=3;;
 esac
 
 : see what type is used for mode_t
@@ -6994,7 +7352,8 @@ echo " "
 case "$sig_name" in
 '')
        echo "Generating a list of signal names..." >&4
-       xxx=`./findhdr signal.h`" "`./findhdr sys/signal.h`" "`./findhdr linux/signal.h`
+       xxx=`./findhdr signal.h`" "`./findhdr sys/signal.h`
+       xxx="$xxx "`./findhdr linux/signal.h`
        set X `cat $xxx 2>&1 | $awk '
 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
        sig[$3] = substr($2,4,20)
@@ -7326,7 +7685,8 @@ EOS
 chmod +x ccsym
 $eunicefix ccsym
 ./ccsym | $sort | $uniq >ccsym.raw
-$awk '/\=/ { print $0; next } { print $0"=1" }' ccsym.raw >ccsym.list
+$awk '/\=/ { print $0; next }
+       { print $0"=1" }' ccsym.raw >ccsym.list
 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
 $comm -13 ccsym.true ccsym.list >ccsym.own
 $comm -12 ccsym.true ccsym.list >ccsym.com
@@ -7571,6 +7931,19 @@ case "$d_vfork" in
        ;;
 esac
 
+: Remove build directory name from cppstdin so it can be used from
+: either the present location or the final installed location.
+echo " "
+: Get out of the UU directory to get correct path name.
+cd ..
+case "$cppstdin" in
+`pwd`/cppstdin)
+       echo "Stripping down cppstdin path name"
+       cppstdin=cppstdin
+       ;;
+esac
+cd UU
+
 : end of configuration questions
 echo " "
 echo "End of configuration questions."
@@ -7683,7 +8056,6 @@ d_bcmp='$d_bcmp'
 d_bcopy='$d_bcopy'
 d_bsd='$d_bsd'
 d_bsdpgrp='$d_bsdpgrp'
-d_byacc='$d_byacc'
 d_bzero='$d_bzero'
 d_casti32='$d_casti32'
 d_castneg='$d_castneg'
@@ -7703,7 +8075,6 @@ d_dlerror='$d_dlerror'
 d_dlopen='$d_dlopen'
 d_dlsymun='$d_dlsymun'
 d_dosuid='$d_dosuid'
-d_drem='$d_drem'
 d_dup2='$d_dup2'
 d_eunice='$d_eunice'
 d_fchmod='$d_fchmod'
@@ -7715,7 +8086,6 @@ d_fds_bits='$d_fds_bits'
 d_fgetpos='$d_fgetpos'
 d_flexfnam='$d_flexfnam'
 d_flock='$d_flock'
-d_fmod='$d_fmod'
 d_fork='$d_fork'
 d_fpathconf='$d_fpathconf'
 d_fsetpos='$d_fsetpos'
@@ -7732,7 +8102,6 @@ d_index='$d_index'
 d_isascii='$d_isascii'
 d_killpg='$d_killpg'
 d_link='$d_link'
-d_linuxstd='$d_linuxstd'
 d_locconv='$d_locconv'
 d_lockf='$d_lockf'
 d_lstat='$d_lstat'
@@ -7801,9 +8170,11 @@ d_shmctl='$d_shmctl'
 d_shmdt='$d_shmdt'
 d_shmget='$d_shmget'
 d_shrplib='$d_shrplib'
+d_sitelib='$d_sitelib'
 d_socket='$d_socket'
 d_sockpair='$d_sockpair'
 d_statblks='$d_statblks'
+d_stdiobase='$d_stdiobase'
 d_stdstdio='$d_stdstdio'
 d_strchr='$d_strchr'
 d_strcoll='$d_strcoll'
@@ -7919,13 +8290,16 @@ incpath='$incpath'
 inews='$inews'
 installarchlib='$installarchlib'
 installbin='$installbin'
-installmansrc='$installmansrc'
+installman1dir='$installman1dir'
+installman3dir='$installman3dir'
 installprivlib='$installprivlib'
 installscript='$installscript'
+installsitelib='$installsitelib'
 intsize='$intsize'
 known_extensions='$known_extensions'
 ksh='$ksh'
 large='$large'
+ld='$ld'
 lddlflags='$lddlflags'
 ldflags='$ldflags'
 less='$less'
@@ -7948,9 +8322,12 @@ make='$make'
 mallocobj='$mallocobj'
 mallocsrc='$mallocsrc'
 malloctype='$malloctype'
-manext='$manext'
-mansrc='$mansrc'
-mansrcexp='$mansrcexp'
+man1dir='$man1dir'
+man1direxp='$man1direxp'
+man1ext='$man1ext'
+man3dir='$man3dir'
+man3direxp='$man3direxp'
+man3ext='$man3ext'
 medium='$medium'
 mips='$mips'
 mips_type='$mips_type'
@@ -8002,6 +8379,8 @@ shrpdir='$shrpdir'
 shsharp='$shsharp'
 sig_name='$sig_name'
 signal_t='$signal_t'
+sitelib='$sitelib'
+sitelibexp='$sitelibexp'
 sizetype='$sizetype'
 sleep='$sleep'
 smail='$smail'
@@ -8017,6 +8396,10 @@ ssizetype='$ssizetype'
 startsh='$startsh'
 static_ext='$static_ext'
 stdchar='$stdchar'
+stdio_base='$stdio_base'
+stdio_bufsiz='$stdio_bufsiz'
+stdio_cnt='$stdio_cnt'
+stdio_ptr='$stdio_ptr'
 strings='$strings'
 submit='$submit'
 sysman='$sysman'