This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert "Fix Configure's csym test for gcc's link time optimisation"
[perl5.git] / Configure
index cd04dae..74450a9 100755 (executable)
--- a/Configure
+++ b/Configure
 # Yes, you may rip this off to use in other distribution packages. This
 # script belongs to the public domain and cannot be copyrighted.
 #
-# (Note: this Configure script was generated automatically. Rather than
+# Note: this Configure script was generated automatically. Rather than
 # working with this copy of Configure, you may wish to get metaconfig.
-# The dist-3.0 package (which contains metaconfig) was posted in
-# comp.sources.misc and is available on CPAN under authors/id/RAM so
-# you may fetch it yourself from your nearest archive site.)
+# The dist package (which contains metaconfig) is available via SVN:
+#     svn co https://svn.sourceforge.net/svnroot/dist/trunk/dist
 #
+# Though this script was generated by metaconfig from metaunits, it is
+# OK to send patches against Configure itself. It's up to the Configure
+# pumpkin to backport the patch to the metaunits if it is accepted.
+# For more information on patching Configure, see pod/perlhack.pod
+#
+# The metaunits are also available from the public git repository:
+#     http://perl5.git.perl.org/metaconfig.git/ or
+#     $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
 #
-# Though this script was generated by metaconfig, it is OK to send
-# patches against it. It's up to the Configure pumpkin to backport
-# the patch to the metaunits if it is accepted.
 # See Porting/pumpkin.pod for more information on metaconfig.
 #
 
-# $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
-#
-# Generated on Mon Oct  8 10:22:27 CEST 2007 [metaconfig 3.0 PL70]
+# Generated on Sun Jul 31 12:11:29 CEST 2011 [metaconfig 3.5 PL0]
 # (with additional metaconfig patches by perlbug@perl.org)
 
 cat >c1$$ <<EOF
@@ -54,7 +56,7 @@ true || exec sh $0 $argv:q
 rm -f c1$$ c2$$
 
 if test -f /dev/cputype -a -f /dev/drivers -a -f /dev/osversion; then
-       cat >&4 <<EOF
+       cat <<EOF
 ***
 *** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
 *** Configure that well.  (Plan 9 is close to UNIX but not close enough.)
@@ -66,7 +68,7 @@ EOF
 fi
 
 if test ! -c /dev/null ; then
-       cat >&4 <<EOF
+       cat <<EOF
 ***
 *** I'm sorry, but /dev/null appears to be a file rather than a device.
 *** Please consult your operating sytem's notes for making a device
@@ -88,9 +90,9 @@ esac
 
 : Proper separator for the PATH environment variable
 p_=:
-: On OS/2 this directory should exist if this is not floppy only system :-]
+: On OS/2 this directory should exist if this is not floppy only system ":-]"
 if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' ) 2>&1 >/dev/null ; then
-    if test -n "$OS2_SHELL"; then
+       if test -n "$OS2_SHELL"; then
                p_=\;
                PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
                OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
@@ -145,9 +147,9 @@ if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
 fi
 if test -f /osf_boot -a -f /usr/sbin/setld; then
        if test X`/usr/bin/uname -s` = XOSF1; then
-               avoidksh="to avoid Digital UNIX' ksh"
-               newsh=/bin/sh
-               unset BIN_SH # if this is 'xpg4' sh will start up ksh
+               avoidksh="to avoid Digital UNIX' ksh"
+               newsh=/bin/sh
+               unset BIN_SH
        fi
 fi
 case "$inksh/$needksh" in
@@ -183,16 +185,17 @@ true)
 esac
 test -x "${newsh}" || unset newsh
 
-: if needed set CDPATH to a harmless value that is not chatty
+: if needed, set CDPATH to a harmless value that is not chatty
 : avoid bash 2.02 problems with empty CDPATH.
 case "$CDPATH" in
 '')    ;;
 *)     case "$SHELL" in
-       *bash*) CDPATH='.' ;;
-       *)              CDPATH='' ;;
+       *bash*) CDPATH='.' ;;
+       *) CDPATH='' ;;
        esac
        ;;
 esac
+
 : Configure runs within the UU subdirectory
 test -d UU || mkdir UU
 cd UU && rm -f ./*
@@ -207,7 +210,9 @@ run=''
 targetarch=''
 to=''
 usecrosscompile=''
+extern_C=''
 mistrustnm=''
+usedevel=''
 perllibs=''
 dynamic_ext=''
 extensions=''
@@ -221,7 +226,6 @@ d_bsd=''
 d_eunice=''
 d_xenix=''
 eunicefix=''
-Mcc=''
 ar=''
 awk=''
 bash=''
@@ -347,6 +351,8 @@ optimize=''
 cf_email=''
 cf_by=''
 cf_time=''
+charbits=''
+charsize=''
 contains=''
 cpp_stuff=''
 cpplast=''
@@ -360,6 +366,7 @@ d_aintl=''
 d_alarm=''
 asctime_r_proto=''
 d_asctime_r=''
+d_attribute_deprecated=''
 d_attribute_format=''
 d_attribute_malloc=''
 d_attribute_nonnull=''
@@ -465,6 +472,7 @@ d_ftime=''
 d_gettimeod=''
 d_futimes=''
 d_Gconvert=''
+d_getaddrinfo=''
 d_getcwd=''
 d_getespwnam=''
 d_getfsstat=''
@@ -496,6 +504,7 @@ d_getlogin_r=''
 getlogin_r_proto=''
 d_getmnt=''
 d_getmntent=''
+d_getnameinfo=''
 d_getnbyaddr=''
 d_getnbyname=''
 d_getnent=''
@@ -552,6 +561,8 @@ d_hasmntopt=''
 d_htonl=''
 d_ilogbl=''
 d_inetaton=''
+d_inetntop=''
+d_inetpton=''
 d_int64_t=''
 d_isascii=''
 d_isfinite=''
@@ -615,6 +626,8 @@ d_pause=''
 d_pipe=''
 d_poll=''
 d_portable=''
+d_prctl=''
+d_prctl_set_name=''
 d_procselfexe=''
 procselfexe=''
 d_old_pthread_create_joinable=''
@@ -716,6 +729,8 @@ d_msg_peek=''
 d_msg_proxy=''
 d_oldsock=''
 d_scm_rights=''
+d_sin6_scope_id=''
+d_sockaddr_sa_len=''
 d_socket=''
 d_sockpair=''
 sockethdr=''
@@ -733,6 +748,8 @@ d_sresuproto=''
 d_statblks=''
 d_statfs_f_flags=''
 d_statfs_s=''
+d_static_inline=''
+perl_static_inline=''
 d_fstatvfs=''
 d_statvfs=''
 d_stdio_cnt_lval=''
@@ -778,6 +795,13 @@ d_tcsetpgrp=''
 d_telldirproto=''
 d_time=''
 timetype=''
+d_asctime64=''
+d_ctime64=''
+d_difftime64=''
+d_gmtime64=''
+d_localtime64=''
+d_mktime64=''
+d_timegm=''
 clocktype=''
 d_times=''
 d_tmpnam_r=''
@@ -811,6 +835,7 @@ d_wcstombs=''
 d_wctomb=''
 d_writev=''
 dlext=''
+bin_ELF=''
 cccdlflags=''
 ccdlflags=''
 dlsrc=''
@@ -840,6 +865,7 @@ html3dir=''
 html3direxp=''
 installhtml3dir=''
 i_arpainet=''
+i_assert=''
 i_crypt=''
 db_hashtype=''
 db_prefixtype=''
@@ -869,9 +895,16 @@ i_limits=''
 i_locale=''
 i_machcthr=''
 i_malloc=''
+i_mallocmalloc=''
 i_math=''
 i_memory=''
 i_mntent=''
+d_gdbm_ndbm_h_uses_prototypes=''
+d_gdbmndbm_h_uses_prototypes=''
+d_ndbm=''
+d_ndbm_h_uses_prototypes=''
+i_gdbm_ndbm=''
+i_gdbmndbm=''
 i_ndbm=''
 i_netdb=''
 i_neterrno=''
@@ -912,6 +945,7 @@ i_sysmode=''
 i_sysmount=''
 i_sysndir=''
 i_sysparam=''
+i_syspoll=''
 i_sysresrc=''
 i_syssecrt=''
 i_sysselct=''
@@ -1057,6 +1091,7 @@ i8size=''
 i8type=''
 ivsize=''
 ivtype=''
+nv_overflows_integers_at=''
 nv_preserves_uv_bits=''
 nvsize=''
 nvtype=''
@@ -1159,12 +1194,18 @@ shsharp=''
 spitshell=''
 src=''
 ssizetype=''
+st_ino_sign=''
+st_ino_size=''
 startperl=''
 startsh=''
 stdchar=''
 d_stdio_stream_array=''
 stdio_stream_array=''
 sysman=''
+sGMTIME_max=''
+sGMTIME_min=''
+sLOCALTIME_max=''
+sLOCALTIME_min=''
 trnl=''
 uidformat=''
 uidsign=''
@@ -1173,6 +1214,8 @@ uidtype=''
 archname64=''
 use64bitall=''
 use64bitint=''
+dtrace=''
+usedtrace=''
 usefaststdio=''
 ccflags_uselargefiles=''
 ldflags_uselargefiles=''
@@ -1195,6 +1238,7 @@ usethreads=''
 incpath=''
 mips_type=''
 usrinc=''
+vaproto=''
 d_vendorarch=''
 installvendorarch=''
 vendorarch=''
@@ -1234,6 +1278,7 @@ yacc=''
 yaccflags=''
 CONFIG=''
 
+: Detect odd OSs
 define='define'
 undef='undef'
 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
@@ -1263,12 +1308,26 @@ elif test -d c:/. -o -n "$is_os2" ; then
     _exe=".exe"
 fi
 
+groupstype=''
 i_whoami=''
+archname=''
+: Possible local include directories to search.
+: Set locincpth to "" in a hint file to defeat local include searches.
+locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
+locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
+:
+: no include file wanted by default
+inclwanted=''
+
+: Enable -DEBUGGING and -DDEBUGGING from the command line
+EBUGGING=''
+DEBUGGING=''
+
+: set usethreads on the Configure command line to enable threads.
+usereentrant='undef'
 : Trailing extension.  Override this in a hint file, if needed.
 : Extra object files, if any, needed on this platform.
 archobjs=''
-archname=''
-groupstype=''
 libnames=''
 : change the next line if compiling for Xenix/286 on Xenix/386
 xlibpth='/usr/lib/386 /lib/386'
@@ -1292,26 +1351,9 @@ plibpth=''
 libswanted=''
 : some systems want to use only the non-versioned libso:s
 ignore_versioned_solibs=''
-siteman1dir=''
-siteman3dir=''
-sitescript=''
-: set usethreads on the Configure command line to enable threads.
-usereentrant='undef'
 : full support for void wanted by default
 defvoidused=15
 
-: Possible local include directories to search.
-: Set locincpth to "" in a hint file to defeat local include searches.
-locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
-locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
-:
-: no include file wanted by default
-inclwanted=''
-
-: Enable -DEBUGGING and -DDEBUGGING from the command line
-EBUGGING=''
-DEBUGGING=old
-
 ccname=''
 ccversion=''
 perllibs=''
@@ -1402,14 +1444,14 @@ if `$sh -c '#' >/dev/null 2>&1`; then
        echo "#!$xcat" >sharp
        $eunicefix sharp
        chmod +x sharp
-       ./sharp > today
+       ./sharp > today 2>/dev/null
        if test -s today; then
                sharpbang='#!'
        else
                echo "#! $xcat" > sharp
                $eunicefix sharp
                chmod +x sharp
-               ./sharp > today
+               ./sharp > today 2>/dev/null
                if test -s today; then
                        sharpbang='#! '
                else
@@ -1452,11 +1494,10 @@ else
 fi
 rm -f sharp
 
-
 : Save command line options in file UU/cmdline.opt for later use in
 : generating config.sh.
 cat > cmdline.opt <<EOSH
-# Configure command line arguments.
+: Configure command line arguments.
 config_arg0='$0'
 config_args='$*'
 config_argc=$#
@@ -1468,7 +1509,6 @@ for arg in "$@"; do
        cat >>cmdline.opt <<EOSH
 config_arg$argn='$arg'
 EOSH
-       # Extreme backslashitis: replace each ' by '"'"'
        cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
 $arg
 EOC
@@ -1477,8 +1517,6 @@ EOC
        argn=`expr $argn + 1`
        args_sep=' '
 done
-# args_exp is good for restarting self: eval "set X $args_exp"; shift; $0 "$@"
-# used by ./hints/os2.sh
 rm -f cmdl.opt
 
 : produce awk script to parse command line options
@@ -1610,7 +1648,7 @@ while test $# -gt 0; do
                  case "$zzz" in
                  *:*) zzz='' ;;
                  *)   xxx=append
-                      zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'` 
+                      zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
                       yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
                  esac
                  ;;
@@ -1624,7 +1662,7 @@ while test $# -gt 0; do
                  *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
                       yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
                  esac
-                 ;;       
+                 ;;
             esac
            case "$xxx" in
            append)
@@ -1649,7 +1687,7 @@ while test $# -gt 0; do
            esac
            shift
            ;;
-       -V) echo "$me generated by metaconfig 3.0 PL70." >&2
+       -V) echo "$me generated by metaconfig 3.5 PL0." >&2
            exit 0;;
        --) break;;
        -*) echo "$me: unknown option $1" >&2; shift; error=true;;
@@ -1733,7 +1771,7 @@ touch optdef.sh
 touch posthint.sh
 
 : set package name
-package=perl5
+package='perl5'
 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
@@ -1779,11 +1817,11 @@ case "$src" in
 '')    src=/
        rsrc=/
        ;;
-/*) rsrc="$src";;
-*) rsrc="../$src";;
+/*)    rsrc="$src";;
+*)     rsrc="../$src";;
 esac
 if test -f $rsrc/Configure && \
-       $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
+       $contains "^package='$package'\$" $rsrc/Configure >/dev/null 2>&1
 then
    : found it, so we are ok.
 else
@@ -1937,11 +1975,13 @@ rm -f .echotmp
 echo " "
 if test -f "$rsrc/MANIFEST"; then
        echo "First let's make sure your kit is complete.  Checking..." >&4
-       awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | (split -l 50 2>/dev/null || split -50)
+       awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
+               (split -l 50 2>/dev/null || split -50)
        rm -f missing
        tmppwd=`pwd`
        for filelist in x??; do
-               (cd "$rsrc"; ls `cat "$tmppwd/$filelist"` >/dev/null 2>>"$tmppwd/missing")
+               (cd "$rsrc"; ls `cat "$tmppwd/$filelist"` \
+                       >/dev/null 2>>"$tmppwd/missing")
        done
        if test -s missing; then
                cat missing >&4
@@ -1975,8 +2015,8 @@ else
 fi
 rm -f missing x??
 
-echo " "
 : Find the appropriate value for a newline for tr
+echo " "
 if test -n "$DJGPP"; then
        trnl='\012'
 fi
@@ -2120,9 +2160,11 @@ persist across sessions for $package.
 You may safely delete it if you wish.
 EOF
 
+: See if we are using a devel version and want that
 xversion=`awk '/define[        ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
 case "$usedevel" in
-$define|true|[yY]*) ;;
+$define|true|[yY]*)
+    usedevel="$define" ;;
 *) case "$xversion" in
    *[13579])
        cat >&4 <<EOH
@@ -2155,6 +2197,7 @@ EOH
        esac
        ;;
     esac
+    usedevel="$undef"
     ;;
 esac
 case "$usedevel" in
@@ -2212,7 +2255,7 @@ in the default answer, as if the default line was a set of arguments given to a
 script shell.  This means you may also use $* to repeat the whole default line,
 so you do not have to re-type everything to add something to the default.
 
-Everytime there is a substitution, you will have to confirm.  If there is an
+Every time there is a substitution, you will have to confirm.  If there is an
 error (e.g. an unmatched backtick), the default answer will remain unchanged
 and you will be prompted again.
 
@@ -2280,14 +2323,13 @@ for dir in \$*; do
                exit 0
        elif test "X$_exe" != X -a -f \$thisthing$_exe; then
                echo \$thisthing
-               exit 0
+               exit 0
        elif test -f \$dir/\$thing.exe; then
                if test -n "$DJGPP"; then
                        echo \$dir/\$thing.exe
                elif test "$eunicefix" != ":"; then
                        : on Eunice apparently
                        echo \$dir/\$thing
-                       exit 0
                fi
                exit 0
        fi
@@ -2318,7 +2360,6 @@ tr
 uniq
 "
 trylist="
-Mcc
 ar
 bison
 byacc
@@ -2334,6 +2375,7 @@ make
 more
 nm
 nroff
+perl
 pg
 test
 uname
@@ -2410,6 +2452,15 @@ egrep)
        _egrep=$grep
        ;;
 esac
+case "$less" in
+'')    ;;
+*)     if $less -R </dev/null >/dev/null; then
+              echo "Substituting less -R for less."
+              less="$less -R"
+              _less=$less
+       fi
+       ;;
+esac
 case "$ln" in
 ln)
        echo "Substituting cp for ln."
@@ -2418,7 +2469,7 @@ ln)
        ;;
 esac
 case "$make" in
-make)  
+make)
        case "$gmake" in
        gmake)
        echo "I can't find make or gmake, and my life depends on it." >&4
@@ -2427,7 +2478,7 @@ make)
        ;;
        esac
        ;;
-esac   
+esac
 case "$gmake" in
 gmake) ;;
 *)     # We can't have osname yet.
@@ -2496,6 +2547,7 @@ you. Do you (emblematical) greet back [Y/n]? n
 
 FOO
 
+: Check what type of C compiler we use
 cat <<EOS >trygcc
 $startsh
 EOS
@@ -2669,7 +2721,7 @@ case "$lns" in
 esac
 echo " "
 
-
+: Make symlinks util
 case "$mksymlinks" in
 $define|true|[yY]*)
        case "$src" in
@@ -2721,7 +2773,7 @@ $define|true|[yY]*)
        ;;
 esac
 
-
+: Check for Cross-Compilation
 case "$usecrosscompile" in
 $define|true|[yY]*)
        $echo "Cross-compiling..."
@@ -3590,10 +3642,10 @@ 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"
                failed=\$?
@@ -3900,6 +3952,7 @@ esac
 prefix="$ans"
 prefixexp="$ansexp"
 
+: allow them to override the AFS root
 case "$afsroot" in
 '')    afsroot=/afs ;;
 *)     afsroot=$afsroot ;;
@@ -3910,7 +3963,7 @@ echo " "
 case "$afs" in
 $define|true)  afs=true ;;
 $undef|false)  afs=false ;;
-*)     if test -d $afsroot; then
+*)     if $test -d $afsroot; then
                afs=true
        else
                afs=false
@@ -4012,7 +4065,7 @@ y) td=$was; tu=$was;;
 esac
 EOSC
 
-: function used to set $1 to $val
+: function used to set '$1' to '$val'
 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
 case "$val$was" in
 $define$undef) . ./whoa; eval "$var=\$td";;
@@ -4020,76 +4073,6 @@ $undef$define) . ./whoa; eval "$var=\$tu";;
 *) eval "$var=$val";;
 esac'
 
-case "$usesocks" in
-$define|true|[yY]*)    dflt='y';;
-*) dflt='n';;
-esac
-cat <<EOM
-
-Perl can be built to use the SOCKS proxy protocol library.  To do so,
-Configure must be run with -Dusesocks.  If you use SOCKS you also need
-to use the PerlIO abstraction layer, this will be implicitly selected.
-
-If this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-rp='Build Perl for SOCKS?'
-. ./myread
-case "$ans" in
-y|Y)   val="$define" ;;     
-*)      val="$undef" ;;
-esac
-set usesocks
-eval $setvar
-
-case "$usesocks" in
-$define|true|[yY]*) useperlio="$define";;
-esac
-
-case "$useperlio" in
-$define|true|[yY]*|'') dflt='y';;
-*) dflt='n';;
-esac
-cat <<EOM
-
-Previous version of $package used the standard IO mechanisms as
-defined in <stdio.h>.  Versions 5.003_02 and later of $package allow
-alternate IO mechanisms via the PerlIO abstraction layer, but the
-stdio mechanism is still available if needed.  The abstraction layer
-can use AT&T's sfio (if you already have sfio installed) or regular stdio.
-Using PerlIO with sfio may cause problems with some extension modules.
-
-If this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-rp='Use the PerlIO abstraction layer?'
-. ./myread
-case "$ans" in
-y|Y) 
-       val="$define"
-       ;;
-*)      
-       echo "Ok, doing things the stdio way."
-       val="$undef"
-       ;;
-esac
-set useperlio
-eval $setvar 
-
-case "$usesocks" in
-$define|true|[yY]*)
-       case "$useperlio" in
-       $define|true|[yY]*) ;;
-       *)      cat >&4 <<EOM
-
-You are using the SOCKS proxy protocol library which means that you
-should also use the PerlIO layer.  You may be headed for trouble.
-
-EOM
-               ;;
-       esac
-       ;;
-esac
-
-       
 : get the patchlevel
 echo " "
 echo "Getting the current patchlevel..." >&4
@@ -4111,16 +4094,13 @@ else
        perl_patchlevel=0
        $echo "(You do not have patchlevel.h.  Eek.)"
 fi
-if $test -r $rsrc/.patch ; then
-       if $test "X$perl_patchlevel" = "X" || $test "`cat $rsrc/.patch`" -gt "$perl_patchlevel" ; then
-               perl_patchlevel=`cat $rsrc/.patch`
-       fi
-fi
 : Define a handy string here to avoid duplication in myconfig.SH and configpm.
 version_patchlevel_string="version $patchlevel subversion $subversion"
 case "$perl_patchlevel" in
 0|'') ;;
-*) version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel" ;;
+*)  perl_patchlevel=`echo $perl_patchlevel | sed 's/.* //'`
+    version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel"
+    ;;
 esac
 
 $echo "(You have $package $version_patchlevel_string.)"
@@ -4146,18 +4126,14 @@ if test "${api_revision}${api_version}${api_subversion}" = "550"; then
        api_versionstring='5.005'
 fi
 
+: Do we want threads support and if so, what type
 case "$usethreads" in
 $define|true|[yY]*)     dflt='y';;
 *)     # Catch case where user specified ithreads or 5005threads but
        # forgot -Dusethreads (A.D. 4/2002)
        case "$useithreads$use5005threads" in
-       *$define*)      
-               case "$useperlio" in
-               "$define")      dflt='y' ;;
-               *)              dflt='n' ;;
-               esac
-               ;;
-       *)      dflt='n';;
+       *$define*)      dflt='y';;
+       *)              dflt='n';;
        esac
        ;;
 esac
@@ -4259,16 +4235,6 @@ EOM
     useithreads="$usethreads"
 fi
 
-if test X"$usethreads" = "X$define" -a "X$useperlio" = "Xundef"; then
-       cat >&4 <<EOF
-***
-*** To build with ithreads you must also use the PerlIO layer.
-*** Cannot continue, aborting.
-***
-EOF
-       exit 1
-fi
-
 case "$d_oldpthreads" in
 '')    : Configure tests would be welcome here.  For now, assume undef.
        val="$undef" ;;
@@ -4295,6 +4261,7 @@ EOM
     esac
 fi
 
+: Check if multiplicity is required
 cat <<EOM
 
 Perl can be built so that multiple Perl interpreters can coexist
@@ -4325,7 +4292,7 @@ esac
 set usemultiplicity
 eval $setvar
 
-
+: Check if morebits is requested
 case "$usemorebits" in
 "$define"|true|[yY]*)
        use64bitint="$define"
@@ -4336,6 +4303,23 @@ case "$usemorebits" in
        ;;
 esac
 
+: Determine the C compiler to be used
+echo " "
+case "$cc" in
+'') dflt=cc;;
+*) dflt="$cc";;
+esac
+rp="Use which C compiler?"
+. ./myread
+cc="$ans"
+
+: See whether they have no cc but they do have gcc
+. ./trygcc
+if $test -f cc.cbu; then
+    . ./cc.cbu
+fi
+. ./checkcc
+
 : make some quick guesses about what we are up against
 echo " "
 $echo $n "Hmm...  $c"
@@ -4431,24 +4415,7 @@ chmod +x bsd usg v7 osf1 eunice xenix venix os2
 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
 $rm -f foo
 
-case "$cc" in
-'') dflt=cc;;
-*) dflt="$cc";;
-esac
-rp="Use which C compiler?"
-. ./myread
-cc="$ans"
-
-: See if they have not cc but they do have gcc
-. ./trygcc
-: Look for a hint-file generated 'call-back-unit'.  Now that the
-: user has specified the compiler, we may need to set or change some
-: other defaults.
-if $test -f cc.cbu; then
-    . ./cc.cbu
-fi
-. ./checkcc
-
+: Check if we are using GNU gcc and what its version is
 echo " "
 echo "Checking for GNU cc in disguise and/or its version number..." >&4
 $cat >try.c <<EOM
@@ -4843,6 +4810,29 @@ case "$firstmakefile" in
 '') firstmakefile='makefile';;
 esac
 
+: Check is we will use socks
+case "$usesocks" in
+$define|true|[yY]*)    dflt='y';;
+*) dflt='n';;
+esac
+cat <<EOM
+
+Perl can be built to use the SOCKS proxy protocol library.  To do so,
+Configure must be run with -Dusesocks.  If you use SOCKS you also need
+to use the PerlIO abstraction layer, this will be implicitly selected.
+
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Build Perl for SOCKS?'
+. ./myread
+case "$ans" in
+y|Y)   val="$define" ;;
+*)      val="$undef" ;;
+esac
+set usesocks
+eval $setvar
+
+: Check for uselongdouble support
 case "$ccflags" in
 *-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
 esac
@@ -4919,7 +4909,7 @@ for thislib in $libswanted; do
                xxx=$thisdir/lib$thislib.$so
                $test -f "$xxx" && eval $libscheck
                $test -f "$xxx" && libstyle=shared
-           fi  
+           fi
            if test ! -f "$xxx"; then
                xxx=$thisdir/lib$thislib$_a
                $test -f "$xxx" && eval $libscheck
@@ -4961,7 +4951,7 @@ for thislib in $libswanted; do
                   ;;
                esac
                break
-           fi  
+           fi
        done
        if $test ! -f "$xxx"; then
            echo "No -l$thislib."
@@ -5047,18 +5037,25 @@ esac
 
 : argument order is deliberate, as the flag will start with - which set could
 : think is an option
-checkccflag='check=$1; flag=$2;
+checkccflag='check=$1; flag=$2; callback=$3;
 echo " ";
 echo "Checking if your compiler accepts $flag" 2>&1;
 echo "int main(void) { return 0; }" > gcctest.c;
-if $cc -O2 $flag -o gcctest gcctest.c; then
+if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && ./gcctest; then
     echo "Yes, it does." 2>&1;
-    case "$ccflags" in
-    *$check*)
-       echo "Leaving current flags $ccflags alone." 2>&1
-       ;;
-    *) dflt="$dflt $flag" ;;
-    esac
+    if $test -s gcctest.out ; then
+        echo "But your platform does not like it:";
+        cat gcctest.out;
+    else
+       case "$ccflags" in
+       *$check*)
+           echo "Leaving current flags $ccflags alone." 2>&1
+           ;;
+       *) dflt="$dflt $flag";
+           eval $callback
+           ;;
+       esac
+    fi
 else
     echo "Nope, it does not, but that is ok." 2>&1;
 fi
@@ -5075,7 +5072,7 @@ default|recommended)
        *-g*:old) dflt="$dflt -DDEBUGGING";;
        esac
        case "$gccversion" in
-       2*) if test -d /etc/conf/kconfig.d &&
+       2*) if $test -d /etc/conf/kconfig.d &&
                        $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
                then
                        # Interactive Systems (ISC) POSIX mode.
@@ -5086,7 +5083,7 @@ default|recommended)
        case "$gccversion" in
        1*) ;;
        2.[0-8]*) ;;
-       ?*)     set strict-aliasing -fno-strict-aliasing
+       ?*)     set strict-aliasing -fno-strict-aliasing
                eval $checkccflag
                ;;
        esac
@@ -5098,6 +5095,18 @@ default|recommended)
                eval $checkccflag
                ;;
        esac
+
+       # on x86_64 (at least) we require an extra library (libssp) in the
+       # link command line. This library is not named, so I infer that it is
+       # an implementation detail that may change. Hence the safest approach
+       # is to add the flag to the flags passed to the compiler at link time,
+       # as that way the compiler can do the right implementation dependant
+       # thing. (NWC)
+       case "$gccversion" in
+       ?*)     set stack-protector -fstack-protector
+               eval $checkccflag
+               ;;
+       esac
        ;;
 esac
 
@@ -5236,6 +5245,15 @@ case "$ldflags" in
        ;;
 *) dflt="$ldflags";;
 esac
+# See note above about -fstack-protector
+case "$ccflags" in
+*-fstack-protector*) 
+       case "$dflt" in
+       *-fstack-protector*) ;; # Don't add it again
+       *) dflt="$dflt -fstack-protector" ;; 
+       esac
+       ;;
+esac
 
 : Try to guess additional flags to pick up local libraries.
 for thislibdir in $libpth; do
@@ -5302,7 +5320,7 @@ and I got the following output:
 EOM
 dflt=y
 if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; then
-       if $sh -c "$run ./try" >>try.msg 2>&1; then
+       if $sh -c "$run ./try " >>try.msg 2>&1; then
                xxx=`$run ./try`
                case "$xxx" in
                "Ok") dflt=n ;;
@@ -5351,12 +5369,17 @@ y)
        ;;
 n) echo "OK, that should do.";;
 esac
-$rm_try
+$rm_try gcctest gcctest.out
 
 : define a shorthand compile call
 compile='
 mc_file=$1;
 shift;
+case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
+echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to perlbug@perl.org" >&4;
+exit 1;
+fi;
+esac;
 $cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
 : define a shorthand compile call for compilations that should be ok.
 compile_ok='
@@ -5621,7 +5644,7 @@ $rm_try
 set d_int64_t
 eval $setvar
 
-
+: Check if 64bit ints have a quad type
 echo " "
 echo "Checking which 64-bit integer type we could use..." >&4
 
@@ -5680,7 +5703,7 @@ case "$quadtype" in
        ;;
 esac
 
-
+: Do we want 64bit support
 case "$uselonglong" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5689,7 +5712,7 @@ case "$uselonglong" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bits" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5698,7 +5721,7 @@ case "$use64bits" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bitints" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5707,7 +5730,7 @@ case "$use64bitints" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bitsint" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5716,7 +5739,7 @@ case "$use64bitsint" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$uselonglongs" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5725,7 +5748,7 @@ case "$uselonglongs" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bitsall" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5734,7 +5757,7 @@ case "$use64bitsall" in
 EOM
        use64bitall="$define"
        ;;
-esac                          
+esac
 
 case "$ccflags" in
 *-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
@@ -5785,7 +5808,7 @@ case "$use64bitall" in
    *) dflt='n' ;;
    esac
    ;;
-esac   
+esac
 cat <<EOM
 
 You may also choose to try maximal 64-bitness.  It means using as much
@@ -6050,21 +6073,6 @@ $define)
        esac
        ;;
 esac
-case "$useperlio" in
-$define)
-       echo "Perlio selected." >&4
-       ;;
-*)
-       echo "Perlio not selected, using stdio." >&4
-       case "$archname" in
-        *-stdio*) echo "...and architecture name already has -stdio." >&4
-                ;;
-        *)      archname="$archname-stdio"
-                echo "...setting architecture name to $archname." >&4
-                ;;
-        esac
-       ;;
-esac
 if $test -f archname.cbu; then
        echo "Your platform has some specific hints for architecture name, using them..."
        . ./archname.cbu
@@ -6303,6 +6311,7 @@ eval $setvar
 $rm -f reflect flect
 
 : now see if they want to do setuid emulation
+if $test $patchlevel -lt 11; then
 echo " "
 val="$undef"
 case "$d_suidsafe" in
@@ -6334,6 +6343,20 @@ EOM
 esac
 set d_dosuid
 eval $setvar
+else
+    case "$d_dosuid" in
+       "$define")
+       cat >&4 <<EOH
+
+SUID emulation has been removed for 5.12
+Please re-run Configure without -Dd_dosuid
+
+EOH
+       exit 1;
+       ;;
+    esac
+    d_dosuid=undef
+fi
 
 : Find perl5.005 or later.
 echo "Looking for a previously installed perl5.005 or later... "
@@ -6357,6 +6380,7 @@ case "$perl5" in
 *)     echo "Using $perl5." ;;
 esac
 
+: Set the siteprefix variables
 $cat <<EOM
 
 After $package is installed, you may wish to install various
@@ -6446,6 +6470,7 @@ if (-d $stem) {
     chdir($stem);
     ;@candidates = map {
        [ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*");
+    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
 }
 else {
     ;@candidates = ();
@@ -6525,6 +6550,10 @@ case "$inc_version_list" in
 esac
 $rm -f getverlist
 
+: see if malloc/malloc.h has to be included
+set malloc/malloc.h i_mallocmalloc
+eval $inhdr
+
 : see if this is a malloc.h system
 : we want a real compile instead of Inhdr because some systems have a
 : malloc.h that just gives a compile error saying to use stdlib.h instead
@@ -6532,6 +6561,11 @@ echo " "
 $cat >try.c <<EOCP
 #include <stdlib.h>
 #include <malloc.h>
+#$i_mallocmalloc I_MALLOCMALLOC
+#ifdef I_MALLOCMALLOC
+# include <malloc/malloc.h>
+#endif
+
 int main () { return 0; }
 EOCP
 set try
@@ -6838,6 +6872,7 @@ else
        d_sitearch="$define"
 fi
 
+: Set the vendorprefix variables
 $cat <<EOM
 
 The installation process will also create a directory for
@@ -6894,6 +6929,7 @@ case "$ans" in
        ;;
 esac
 
+: Set the vendorlib variables
 case "$vendorprefix" in
 '')    d_vendorlib="$undef"
        vendorlib=''
@@ -6924,6 +6960,7 @@ vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
 prefixvar=vendorlib
 . ./installprefix
 
+: Set the vendorarch variables
 case "$vendorprefix" in
 '')    d_vendorarch="$undef"
        vendorarch=''
@@ -6949,6 +6986,11 @@ case "$vendorprefix" in
 esac
 prefixvar=vendorarch
 . ./installprefix
+if $test X"$vendorarch" = X"$vendorlib"; then
+       d_vendorarch="$undef"
+else
+       d_vendorarch="$define"
+fi
 
 : Final catch-all directories to search
 $cat <<EOM
@@ -7007,6 +7049,7 @@ set prototype
 eval $setvar
 $rm -f prototype*
 
+: Check if ansi2knr is required
 case "$prototype" in
 "$define") ;;
 *)     ansi2knr='ansi2knr'
@@ -7030,45 +7073,130 @@ EOM
        ;;
 esac
 
-echo " "
-case "$extras" in
-'') dflt='n';;
-*) dflt='y';;
-esac
-cat <<EOM
-Perl can be built with extra modules or bundles of modules which
-will be fetched from the CPAN and installed alongside Perl.
+: DTrace support
+dflt_dtrace='/usr/sbin/dtrace'
+$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/dtrace'
 
-Notice that you will need access to the CPAN; either via the Internet,
-or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
-be asked later to configure the CPAN.pm module which will in turn do
-the installation of the rest of the extra modules or bundles.)
+cat <<EOM
 
-Notice also that if the modules require any external software such as
-libraries and headers (the libz library and the zlib.h header for the
-Compress::Zlib module, for example) you MUST have any such software
-already installed, this configuration process will NOT install such
-things for you.
+Perl can be built to support DTrace on platforms that support it.
+DTrace is a diagnosis and performance analysis tool from Sun.
 
 If this doesn't make any sense to you, just accept the default '$dflt'.
 EOM
-rp='Install any extra modules (y or n)?'
-. ./myread
-case "$ans" in
-y|Y)
-       cat <<EOM
 
-Please list any extra modules or bundles to be installed from CPAN,
-with spaces between the names.  The names can be in any format the
-'install' command of CPAN.pm will understand.  (Answer 'none',
-without the quotes, to install no extra modules or bundles.)
-EOM
-       rp='Extras?'
-       dflt="$extras"
-       . ./myread
-       extras="$ans"
-esac
-case "$extras" in
+while $test 1 ; do
+       case "$usedtrace" in
+       $define|true|[yY]*)
+               dflt='y'
+               ;;
+       ?*)
+               dflt='y'
+               dflt_dtrace=$usedtrace
+               ;;
+       *)
+               dflt='n'
+               ;;
+       esac
+
+       rp='Support DTrace if available?'
+       . ./myread
+       case "$ans" in
+       y|Y)    val="$define" ;;
+       *)      val="$undef" ;;
+       esac
+       set usedtrace
+       eval $setvar
+
+       test "X$usedtrace" != "X$define" && break
+
+       echo " "
+       rp='Where is the dtrace executable?'
+       dflt=$dflt_dtrace
+       . ./getfile
+       val="$ans"
+       set dtrace
+       eval $setvar
+
+       if $test -f $dtrace
+       then
+               if $dtrace -h -s ../perldtrace.d \
+                       -o perldtrace.tmp >/dev/null 2>&1 \
+                       && rm -f perldtrace.tmp
+               then
+                       echo " "
+                       echo "Good: your $dtrace knows about the -h flag."
+               else
+                       cat >&2 <<EOM
+
+*** $me:  Fatal Error:  $dtrace doesn't support -h flag
+***
+*** Your installed dtrace doesn't support the -h switch to compile a D
+*** program into a C header. Can't continue.
+
+EOM
+                       exit 1
+               fi
+               break;
+       fi
+
+       case "$fastread" in
+       yes)
+               cat >&2 <<EOM
+
+*** $me:  Fatal Error:  $dtrace not found.
+*** Can't continue.
+
+EOM
+               exit 1
+               ;;
+       *)
+               echo "*** $dtrace was not found."
+               echo " "
+               ;;
+       esac
+done
+
+: See if we want extra modules installed
+echo " "
+case "$extras" in
+'') dflt='n';;
+*) dflt='y';;
+esac
+cat <<EOM
+Perl can be built with extra modules or bundles of modules which
+will be fetched from the CPAN and installed alongside Perl.
+
+Notice that you will need access to the CPAN; either via the Internet,
+or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
+be asked later to configure the CPAN.pm module which will in turn do
+the installation of the rest of the extra modules or bundles.)
+
+Notice also that if the modules require any external software such as
+libraries and headers (the libz library and the zlib.h header for the
+Compress::Zlib module, for example) you MUST have any such software
+already installed, this configuration process will NOT install such
+things for you.
+
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Install any extra modules (y or n)?'
+. ./myread
+case "$ans" in
+y|Y)
+       cat <<EOM
+
+Please list any extra modules or bundles to be installed from CPAN,
+with spaces between the names.  The names can be in any format the
+'install' command of CPAN.pm will understand.  (Answer 'none',
+without the quotes, to install no extra modules or bundles.)
+EOM
+       rp='Extras?'
+       dflt="$extras"
+       . ./myread
+       extras="$ans"
+esac
+case "$extras" in
 ''|'none')
        val=''
        $rm -f ../extras.lst
@@ -7171,6 +7299,7 @@ fi
 set installusrbinperl
 eval $setvar
 
+: Check if we are using the GNU C library
 echo " "
 echo "Checking for GNU C Library..." >&4
 cat >try.c <<'EOCP'
@@ -7304,6 +7433,7 @@ case "$nm_so_opt" in
        ;;
 esac
 
+: Figure out where the libc is located
 case "$runnm" in
 true)
 : get list of predefined functions in a handy place
@@ -7463,7 +7593,7 @@ $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'
-xxx='[ADTSIW]'
+xxx='[ADTSIWi]'
 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
        eval $xscan;\
        $contains '^fprintf$' libc.list >/dev/null 2>&1; then
@@ -7533,31 +7663,31 @@ else
                echo " "
                echo "$nm didn't seem to work right. Trying $ar instead..." >&4
                com=''
-               if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
+               if $ar t $libc > libc.tmp && \
+                       $contains '^fprintf$' libc.tmp >/dev/null 2>&1
+               then
                        for thisname in $libnames $libc; do
                                $ar t $thisname >>libc.tmp
                        done
                        $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
                        echo "Ok." >&4
                elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
-                       # Repeat libc to extract forwarders to DLL entries too
                        for thisname in $libnames $libc; do
                                $ar tv $thisname >>libc.tmp
-                               # Revision 50 of EMX has bug in $ar.
-                               # it will not extract forwarders to DLL entries
-                               # Use emximp which will extract exactly them.
                                emximp -o tmp.imp $thisname \
                                    2>/dev/null && \
                                    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
                                    < tmp.imp >>libc.tmp
-                               $rm tmp.imp
+                               $rm -f tmp.imp
                        done
                        $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
                        echo "Ok." >&4
                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
+                       if  bld t $libc | \
+                               $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list &&
+                               $test -s libc.list
                        then
                                for thisname in $libnames; do
                                        bld t $libnames | \
@@ -7582,7 +7712,8 @@ define)
 *)  if $test -f /lib/syscalls.exp; then
        echo " "
        echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
-       $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*[        ]*$/\1/p' /lib/syscalls.exp >>libc.list
+       $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*[        ]*$/\1/p' \
+               /lib/syscalls.exp >>libc.list
     fi
     ;;
 esac
@@ -7594,7 +7725,7 @@ $rm -f libnames libpath
 set dld.h i_dld
 eval $inhdr
 
-
+: Check if we are using C++
 echo " "
 echo "Checking for C++..." >&4
 $cat >try.c <<'EOCP'
@@ -7627,6 +7758,10 @@ case "$3" in
 -a) tf=libc.tmp; tdc="[]";;
 *) tlook="^$1\$"; tf=libc.list; tdc="()";;
 esac;
+case "$d_cplusplus" in
+    $define)   extern_C="extern \"C\"" ;;
+    *)         extern_C="extern"       ;;
+esac;
 tx=yes;
 case "$reuseval-$4" in
 true-) ;;
@@ -7635,20 +7770,17 @@ esac;
 case "$tx" in
 yes)
        tval=false;
-       case "$d_cplusplus" in
-               $define) extern_C=\"C\";;
-       esac;
        if $test "$runnm" = true; then
                if $contains $tlook $tf >/dev/null 2>&1; then
                        tval=true;
                elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
-                       echo "extern $extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
+                       echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
                        $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
                        $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
                        $rm_try;
                fi;
        else
-               echo "extern $extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
+               echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
                $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
                $rm_try;
        fi;
@@ -7737,6 +7869,7 @@ esac
 rp="Do you wish to use dynamic loading?"
 . ./myread
 usedl="$ans"
+bin_ELF="$undef"
 case "$ans" in
 y*) usedl="$define"
        case "$dlsrc" in
@@ -7833,6 +7966,7 @@ EOM
 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
 EOM
                        dflt="$cc"
+                       bin_ELF="$define"
                else
                        echo "I'll use ld to build dynamic libraries."
                        dflt='ld'
@@ -7859,6 +7993,7 @@ EOM
     case "$lddlflags" in
     '') case "$osname" in
                        beos) dflt='-nostart' ;;
+                       haiku) dflt='-shared' ;;
                        hpux) dflt='-b';
                              case "$gccversion" in
                              '') dflt="$dflt +vnocompatwarnings" ;;
@@ -7895,6 +8030,16 @@ EOM
        ''|' ') dflt='none' ;;
        esac
 
+       case "$ldflags" in
+       *-fstack-protector*)
+           case "$dflt" in
+                       *-fstack-protector*) ;; # Don't add it again
+                       *) dflt="$dflt -fstack-protector" ;; 
+               esac
+               ;;
+       esac
+
+
     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
     . ./myread
     case "$ans" in
@@ -7933,6 +8078,7 @@ EOM
     ;;
 esac
 
+: Do we want a shared libperl?
 also=''
 case "$usedl" in
 $undef)
@@ -7941,7 +8087,7 @@ $undef)
        ;;
 *)     case "$useshrplib" in
        '')     case "$osname" in
-               svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|cygwin*)
+               svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|haiku|cygwin*)
                        dflt=y
                        also='Building a shared libperl is required for dynamic loading to work on your system.'
                        ;;
@@ -7989,15 +8135,22 @@ esac
 
 case "$useshrplib" in
 true)
+       case "$userelocatableinc" in
+       true|define)
+               echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
+               echo "See INSTALL for an explanation why that won't work." >&4
+               exit 4
+               ;;
+       esac
        case "$libperl" in
        '')
                # Figure out a good name for libperl.so.  Since it gets stored in
                # a version-specific architecture-dependent library, the version
                # number isn't really that important, except for making cc/ld happy.
                #
-               # A name such as libperl.so.3.1
+               # A name such as libperl.so.10.1
                majmin="libperl.$so.$patchlevel.$subversion"
-               # A name such as libperl.so.301
+               # A name such as libperl.so.100
                majonly=`echo $patchlevel $subversion |
                        $awk '{printf "%d%02d", $1, $2}'`
                majonly=libperl.$so.$majonly
@@ -8011,8 +8164,12 @@ true)
                linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
                        dflt=libperl.$so
                        ;;
-               cygwin*) # ld links against an importlib
-                       dflt=libperl$lib_ext
+               cygwin*) # ld links now against the dll directly
+                       majmin="cygperl5_${patchlevel}_${subversion}.${so}"
+                       majonly=`echo $patchlevel $subversion |
+                               $awk '{printf "%03d%03d", $1, $2}'`
+                       majonly=cygperl5.$majonly.$so
+                       dflt=$majmin
                        ;;
                *)      # Try to guess based on whether libc has major.minor.
                        case "$libc" in
@@ -8085,14 +8242,14 @@ shrpdir=$archlibexp/CORE
 xxx=''
 tmp_shrpenv=''
 if "$useshrplib"; then
-    case "$osname" in 
+    case "$osname" in
        aix)
                # We'll set it in Makefile.SH...
                ;;
        solaris)
                xxx="-R $shrpdir"
                ;;
-       freebsd|netbsd|openbsd|interix|dragonfly)
+       freebsd|mirbsd|netbsd|openbsd|interix|dragonfly)
                xxx="-Wl,-R$shrpdir"
                ;;
        bsdos|linux|irix*|dec_osf|gnu*)
@@ -8104,17 +8261,23 @@ if "$useshrplib"; then
        beos)
                # beos doesn't like the default, either.
                ;;
+       haiku)
+               # Haiku doesn't like the default, either.
+               ;;
        hpux*)
                # hpux doesn't like the default, either.
                tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
                ;;
+       cygwin)
+               # cygwin needs only ldlibpth
+               ;;
        *)
                tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
                ;;
        esac
        case "$xxx" in
        '') ;;
-       *)      
+       *)
                # Only add $xxx if it isn't already in ccdlflags.
                case " $ccdlflags " in
                *" $xxx "*)     ;;
@@ -8122,7 +8285,7 @@ if "$useshrplib"; then
                        cat <<EOM >&4
 
 Adding $xxx to the flags
-passed to $ld so that the perl executable will find the 
+passed to $ld so that the perl executable will find the
 installed shared $libperl.
 
 EOM
@@ -8262,7 +8425,7 @@ You can't have filenames longer than 14 chars.
 You can't even think about them!
 EOM
        val="$undef"
-fi 
+fi
 set d_flexfnam
 eval $setvar
 $rm -rf 123456789abcde*
@@ -8547,11 +8710,11 @@ case "$myhostname" in
                                echo "(Attempting domain name extraction from $tans)"
                                dflt=.`$sed -n -e 's/   / /g' \
                                  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
-                                 | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
+                                 -e 1q 2>/dev/null`
                                case "$dflt" in
                                .) dflt=.`$sed -n -e 's/        / /g' \
                                     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
-                                    | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
+                                    -e 1q 2>/dev/null`
                                        ;;
                                esac
                        fi
@@ -8620,6 +8783,7 @@ case "$phostname" in
        ;;
 esac
 
+: determine the e-mail address of the user who is running us
 $cat <<EOM
 
 I need to get your e-mail address in Internet format if possible, i.e.
@@ -8655,6 +8819,7 @@ while test "$cont"; do
        esac
 done
 
+: Ask e-mail of administrator
 $cat <<EOM
 
 If you or somebody else will be maintaining perl at your site, please
@@ -8893,6 +9058,7 @@ rp='Pathname where add-on public executable scripts should be installed?'
 prefixvar=sitescript
 . ./setprefixvar
 
+: Check if faststdio is requested and available
 case "$usefaststdio" in
 $define|true|[yY]*|'')
        xversion=`awk '/define[         ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
@@ -8916,7 +9082,7 @@ EOM
 rp='Use the "fast stdio" if available?'
 . ./myread
 case "$ans" in
-y|Y)   val="$define" ;;     
+y|Y)   val="$define" ;;
 *)      val="$undef" ;;
 esac
 set usefaststdio
@@ -9014,12 +9180,13 @@ rp="What is the type for file position used by fsetpos()?"
 set fpos_t fpostype long stdio.h sys/types.h
 eval $typedef_ask
 
+: Check size for Fpos_t
 echo " "
 case "$fpostype" in
 *_t) zzz="$fpostype"   ;;
 *)   zzz="fpos_t"      ;;
 esac
-echo "Checking the size of $zzz..." >&4 
+echo "Checking the size of $zzz..." >&4
 cat > try.c <<EOCP
 #include <sys/types.h>
 #include <stdio.h>
@@ -9052,6 +9219,7 @@ else
        fpossize="$ans"
 fi
 
+: Check for large file support
 # Backward compatibility (uselfs is deprecated).
 case "$uselfs" in
 "$define"|true|[yY]*)
@@ -9165,6 +9333,10 @@ EOCP
        ;;
 esac
 
+: Check if we want perlio
+useperlio="$define"
+
+: Set the vendorbin variables
 case "$vendorprefix" in
 '')    d_vendorbin="$undef"
        vendorbin=''
@@ -9186,6 +9358,7 @@ esac
 prefixvar=vendorbin
 . ./installprefix
 
+: Set the vendorhtml1dir variables
 case "$vendorprefix" in
 '')    vendorhtml1dir=''
        vendorhtml1direxp=''
@@ -9213,6 +9386,7 @@ $test X"$vendorhtml1dir" = "X" && vendorhtml1dir=' '
 prefixvar=vendorhtml1dir
 . ./installprefix
 
+: Set the vendorhtml3dir variables
 case "$vendorprefix" in
 '')    vendorhtml3dir=''
        vendorhtml3direxp=''
@@ -9240,6 +9414,7 @@ $test X"$vendorhtml3dir" = "X" && vendorhtml3dir=' '
 prefixvar=vendorhtml3dir
 . ./installprefix
 
+: Set the vendorman1dir variables
 case "$vendorprefix" in
 '')    vendorman1dir=''
        vendorman1direxp=''
@@ -9264,6 +9439,7 @@ $test X"$vendorman1dir" = "X" && vendorman1dir=' '
 prefixvar=vendorman1dir
 . ./installprefix
 
+: Set the vendorman3dir variables
 case "$vendorprefix" in
 '')    vendorman3dir=''
        vendorman3direxp=''
@@ -9288,6 +9464,7 @@ $test X"$vendorman3dir" = "X" && vendorman3dir=' '
 prefixvar=vendorman3dir
 . ./installprefix
 
+: Set the vendorscript variables
 case "$vendorprefix" in
 '')    d_vendorscript="$undef"
        vendorscript=''
@@ -9316,10 +9493,51 @@ esac
 prefixvar=vendorscript
 . ./installprefix
 
+: script used to emit important warnings
+cat >warn <<EOS
+$startsh
+if test \$# -gt 0; then
+       echo "\$@" >msg
+else
+       cat >msg
+fi
+echo "*** WARNING:" >&4
+sed -e 's/^/*** /' <msg >&4
+echo "*** " >&4
+cat msg >>config.msg
+echo " " >>config.msg
+rm -f msg
+EOS
+chmod +x warn
+$eunicefix warn
+
+: see which of string.h or strings.h is needed
+echo " "
+strings=`./findhdr string.h`
+if $test "$strings" && $test -r "$strings"; then
+       echo "Using <string.h> instead of <strings.h>." >&4
+       val="$define"
+else
+       val="$undef"
+       strings=`./findhdr strings.h`
+       if $test "$strings" && $test -r "$strings"; then
+               echo "Using <strings.h> instead of <string.h>." >&4
+       else
+               ./warn "No string header found -- You'll surely have problems."
+       fi
+fi
+set i_string
+eval $setvar
+case "$i_string" in
+"$undef") strings=`./findhdr strings.h`;;
+*)       strings=`./findhdr string.h`;;
+esac
+
 : see if qgcvt exists
 set qgcvt d_qgcvt
 eval $inlibc
 
+: Check print/scan long double stuff
 echo " "
 
 if $test X"$d_longdbl" = X"$define"; then
@@ -9488,15 +9706,18 @@ char *myname = "sprintf";
 
 #include <stdio.h>
 
-#define I_STDLIB $i_stdlib
+#$i_stdlib I_STDLIB
 #ifdef I_STDLIB
 #include <stdlib.h>
 #endif
+#$i_string I_STRING
+#ifdef I_STRING
+#  include <string.h>
+#else
+#  include <strings.h>
+#endif
 
-int
-checkit(expect, got)
-char *expect;
-char *got;
+int checkit(char *expect, char *got)
 {
     if (strcmp(expect, got)) {
                printf("%s oddity:  Expected %s, got %s\n",
@@ -9602,7 +9823,7 @@ done
 
 case "$d_longdbl$uselongdouble" in
 "$define$define")
-    : again, add prefered functions to our list first
+    : again, add preferred functions to our list first
     xxx_ld_list=""
     for xxx_convert in $gconvert_ld_preference; do
         case $xxx_convert in
@@ -9739,11 +9960,31 @@ eval $inlibc
 set alarm d_alarm
 eval $inlibc
 
+: see if 64bit time functions exists
+
+set ctime64 d_ctime64
+eval $inlibc
+
+set localtime64 d_localtime64
+eval $inlibc
+
+set gmtime64 d_gmtime64
+eval $inlibc
+
+set mktime64 d_mktime64
+eval $inlibc
+
+set difftime64 d_difftime64
+eval $inlibc
+
+set asctime64 d_asctime64
+eval $inlibc
+
 : see if POSIX threads are available
 set pthread.h i_pthread
 eval $inhdr
 
-: define a fucntion to check prototypes
+: define a function to check prototypes
 $cat > protochk <<EOSH
 $startsh
 cc="$cc"
@@ -9795,6 +10036,7 @@ EOSH
 chmod +x protochk
 $eunicefix protochk
 
+: Define hasproto macro for Configure internal use
 hasproto='varname=$1; func=$2; shift; shift;
 while $test $# -ge 2; do
        case "$1" in
@@ -9822,6 +10064,7 @@ eval $inhdr
 set sys/select.h i_sysselct
 eval $inhdr
 
+: Define hasfield macro for Configure internal use
 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
 while $test $# -ge 2; do
        case "$1" in
@@ -9978,19 +10221,19 @@ case "$d_asctime_r" in
        define)
        case "$asctime_r_proto" in
        ''|0) try='char* asctime_r(const struct tm*, char*);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=B_SB ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SB ;;
        esac
        case "$asctime_r_proto" in
        ''|0) try='char* asctime_r(const struct tm*, char*, int);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=B_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SBI ;;
        esac
        case "$asctime_r_proto" in
        ''|0) try='int asctime_r(const struct tm*, char*);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=I_SB ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SB ;;
        esac
        case "$asctime_r_proto" in
        ''|0) try='int asctime_r(const struct tm*, char*, int);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SBI ;;
        esac
        case "$asctime_r_proto" in
        ''|0)   d_asctime_r=undef
@@ -10235,6 +10478,34 @@ set d_attribute_unused
 eval $setvar
 $rm -f attrib*
 
+: Look for GCC-style attribute deprecated
+case "$d_attribute_deprecated" in
+'')
+echo " "
+echo "Checking whether your compiler can handle __attribute__((deprecated)) ..." >&4
+$cat >attrib.c <<'EOCP'
+#include <stdio.h>
+int I_am_deprecated(void) __attribute__((deprecated));
+EOCP
+if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
+       if $contains 'warning' attrib.out >/dev/null 2>&1; then
+               echo "Your C compiler doesn't support __attribute__((deprecated))."
+               val="$undef"
+       else
+               echo "Your C compiler supports __attribute__((deprecated))."
+               val="$define"
+       fi
+else
+       echo "Your C compiler doesn't seem to understand __attribute__ at all."
+       val="$undef"
+fi
+;;
+*) val="$d_attribute_deprecated" ;;
+esac
+set d_attribute_deprecated
+eval $setvar
+$rm -f attrib*
+
 : Look for GCC-style attribute warn_unused_result
 case "$d_attribute_warn_unused_result" in
 '')
@@ -10426,7 +10697,7 @@ int main(void) {
 
 EOCP
     set try
-    if eval $compile; then
+    if eval $compile && $run ./try; then
        echo "Your C compiler supports __builtin_choose_expr."
        val="$define"
     else
@@ -10446,18 +10717,20 @@ case "$d_builtin_expect" in
 '')
     echo " "
     echo "Checking whether your compiler can handle __builtin_expect ..." >&4
-    $cat >builtin.c <<'EOCP'
+    $cat >try.c <<'EOCP'
 int main(void) {
     int n = 50;
     if ( __builtin_expect(n, 0) ) n = 1;
+    /* Remember shell exit code truth is 0, C truth is non-zero */
+    return !(n == 1);
 }
 EOCP
     set try
-    if eval $compile; then
-       echo "Your C compiler supports __builtin_choose_expr."
+    if eval $compile && $run ./try; then
+       echo "Your C compiler supports __builtin_expect."
        val="$define"
     else
-       echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
+       echo "Your C compiler doesn't seem to understand __builtin_expect."
        val="$undef"
     fi
     ;;
@@ -10554,7 +10827,7 @@ echo "I could not find the definition for va_dcl... You have problems..." >&4
        val="$undef"; set i_stdarg; eval $setvar
        val="$undef"; set i_varargs; eval $setvar
        ;;
-*) 
+*)
        set i_varhdr
        eval $setvar
        case "$i_varhdr" in
@@ -10682,7 +10955,7 @@ int main()
        signal(SIGFPE, blech);
 
        /* Don't let compiler optimize the test away.  Store the number
-          in a writable string for gcc to pass to sscanf under HP/UX.
+          in a writable string for gcc to pass to sscanf under HP-UX.
        */
        sprintf(str, "2147483647");
        sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
@@ -10749,7 +11022,7 @@ int main()
           optimized the whole file away
        */
        /* Store the number in a writable string for gcc to pass to
-          sscanf under HP/UX.
+          sscanf under HP-UX.
        */
        sprintf(str, "-123");
        sscanf(str, "%lf", &f);  /* f = -123.; */
@@ -10920,6 +11193,7 @@ eval $inlibc
 set clearenv d_clearenv
 eval $inlibc
 
+: Define hasstruct macro for Configure internal use
 hasstruct='varname=$1; struct=$2; shift; shift;
 while $test $# -ge 2; do
        case "$1" in
@@ -10938,9 +11212,9 @@ set $varname;
 eval $setvar;
 $rm_try'
 
+: see whether socket exists
 socketlib=''
 sockethdr=''
-: see whether socket exists
 echo " "
 $echo $n "Hmm... $c" >&4
 if set socket val -f d_socket; eval $csym; $val; then
@@ -11003,6 +11277,41 @@ eval $inlibc
 
 
 echo " "
+echo "Checking the availability sa_len in the sock struct ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+int main() {
+struct sockaddr sa;
+return (sa.sa_len);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+       val="$define"
+fi
+set d_sockaddr_sa_len; eval $setvar
+$rm_try
+
+echo " "
+echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int main() {
+struct sockaddr_in6 sin6;
+return (sin6.sin6_scope_id);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+       val="$define"
+fi
+set d_sin6_scope_id; eval $setvar
+$rm_try
+
+echo " "
 echo "Checking the availability of certain socket constants..." >&4
 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
        enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
@@ -11025,7 +11334,7 @@ done
 set sys/uio.h i_sysuio
 eval $inhdr
 
-
+: Check for cmsghdr support
 echo " "
 echo "Checking to see if your system supports struct cmsghdr..." >&4
 set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
@@ -11120,11 +11429,11 @@ case "$d_crypt_r" in
        define)
        case "$crypt_r_proto" in
        ''|0) try='char* crypt_r(const char*, const char*, struct crypt_data*);'
-       ./protochk "extern $try" $hdrs && crypt_r_proto=B_CCS ;;
+       ./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCS ;;
        esac
        case "$crypt_r_proto" in
        ''|0) try='char* crypt_r(const char*, const char*, CRYPTD*);'
-       ./protochk "extern $try" $hdrs && crypt_r_proto=B_CCD ;;
+       ./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCD ;;
        esac
        case "$crypt_r_proto" in
        ''|0)   d_crypt_r=undef
@@ -11181,7 +11490,7 @@ case "$d_ctermid_r" in
        define)
        case "$ctermid_r_proto" in
        ''|0) try='char* ctermid_r(char*);'
-       ./protochk "extern $try" $hdrs && ctermid_r_proto=B_B ;;
+       ./protochk "$extern_C $try" $hdrs && ctermid_r_proto=B_B ;;
        esac
        case "$ctermid_r_proto" in
        ''|0)   d_ctermid_r=undef
@@ -11222,19 +11531,19 @@ case "$d_ctime_r" in
        define)
        case "$ctime_r_proto" in
        ''|0) try='char* ctime_r(const time_t*, char*);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=B_SB ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SB ;;
        esac
        case "$ctime_r_proto" in
        ''|0) try='char* ctime_r(const time_t*, char*, int);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=B_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SBI ;;
        esac
        case "$ctime_r_proto" in
        ''|0) try='int ctime_r(const time_t*, char*);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=I_SB ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SB ;;
        esac
        case "$ctime_r_proto" in
        ''|0) try='int ctime_r(const time_t*, char*, int);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SBI ;;
        esac
        case "$ctime_r_proto" in
        ''|0)   d_ctime_r=undef
@@ -11513,6 +11822,7 @@ runnm="$xxx_runnm"
 set dlfcn.h i_dlfcn
 eval $inhdr
 
+: Check what extension to use for shared libs
 case "$usedl" in
 $define|y|true)
        $cat << EOM
@@ -11597,9 +11907,9 @@ int main()
 }
 EOM
        : Call the object file tmp-dyna.o in case dlext=o.
-       if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
-               mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
-               $ld -o dyna.$dlext $ldflags $lddlflags tmp-dyna${_o} > /dev/null 2>&1 && 
+       if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 &&
+               mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 &&
+               $ld -o dyna.$dlext $ldflags $lddlflags tmp-dyna${_o} > /dev/null 2>&1 &&
                $cc -o fred $ccflags $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1 && $to dyna.$dlext; then
                xxx=`$run ./fred`
                case $xxx in
@@ -11617,7 +11927,7 @@ EOM
        fi
        ;;
 esac
-               
+
 $rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.*
 
 set d_dlsymun
@@ -11639,7 +11949,7 @@ case "$d_drand48_r" in
        define)
        case "$drand48_r_proto" in
        ''|0) try='int drand48_r(struct drand48_data*, double*);'
-       ./protochk "extern $try" $hdrs && drand48_r_proto=I_ST ;;
+       ./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;;
        esac
        case "$drand48_r_proto" in
        ''|0)   d_drand48_r=undef
@@ -11722,11 +12032,11 @@ case "$d_endgrent_r" in
        define)
        case "$endgrent_r_proto" in
        ''|0) try='int endgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endgrent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && endgrent_r_proto=I_H ;;
        esac
        case "$endgrent_r_proto" in
        ''|0) try='void endgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endgrent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && endgrent_r_proto=V_H ;;
        esac
        case "$endgrent_r_proto" in
        ''|0)   d_endgrent_r=undef
@@ -11775,11 +12085,11 @@ case "$d_endhostent_r" in
        define)
        case "$endhostent_r_proto" in
        ''|0) try='int endhostent_r(struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && endhostent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endhostent_r_proto=I_D ;;
        esac
        case "$endhostent_r_proto" in
        ''|0) try='void endhostent_r(struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && endhostent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endhostent_r_proto=V_D ;;
        esac
        case "$endhostent_r_proto" in
        ''|0)   d_endhostent_r=undef
@@ -11824,11 +12134,11 @@ case "$d_endnetent_r" in
        define)
        case "$endnetent_r_proto" in
        ''|0) try='int endnetent_r(struct netent_data*);'
-       ./protochk "extern $try" $hdrs && endnetent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endnetent_r_proto=I_D ;;
        esac
        case "$endnetent_r_proto" in
        ''|0) try='void endnetent_r(struct netent_data*);'
-       ./protochk "extern $try" $hdrs && endnetent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endnetent_r_proto=V_D ;;
        esac
        case "$endnetent_r_proto" in
        ''|0)   d_endnetent_r=undef
@@ -11873,11 +12183,11 @@ case "$d_endprotoent_r" in
        define)
        case "$endprotoent_r_proto" in
        ''|0) try='int endprotoent_r(struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && endprotoent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=I_D ;;
        esac
        case "$endprotoent_r_proto" in
        ''|0) try='void endprotoent_r(struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && endprotoent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=V_D ;;
        esac
        case "$endprotoent_r_proto" in
        ''|0)   d_endprotoent_r=undef
@@ -12010,11 +12320,11 @@ case "$d_endpwent_r" in
        define)
        case "$endpwent_r_proto" in
        ''|0) try='int endpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endpwent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && endpwent_r_proto=I_H ;;
        esac
        case "$endpwent_r_proto" in
        ''|0) try='void endpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endpwent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && endpwent_r_proto=V_H ;;
        esac
        case "$endpwent_r_proto" in
        ''|0)   d_endpwent_r=undef
@@ -12059,11 +12369,11 @@ case "$d_endservent_r" in
        define)
        case "$endservent_r_proto" in
        ''|0) try='int endservent_r(struct servent_data*);'
-       ./protochk "extern $try" $hdrs && endservent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endservent_r_proto=I_D ;;
        esac
        case "$endservent_r_proto" in
        ''|0) try='void endservent_r(struct servent_data*);'
-       ./protochk "extern $try" $hdrs && endservent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endservent_r_proto=V_D ;;
        esac
        case "$endservent_r_proto" in
        ''|0)   d_endservent_r=undef
@@ -12142,28 +12452,6 @@ set d_open3
 eval $setvar
 $rm_try
 
-: see which of string.h or strings.h is needed
-echo " "
-strings=`./findhdr string.h`
-if $test "$strings" && $test -r "$strings"; then
-       echo "Using <string.h> instead of <strings.h>." >&4
-       val="$define"
-else
-       val="$undef"
-       strings=`./findhdr strings.h`
-       if $test "$strings" && $test -r "$strings"; then
-               echo "Using <strings.h> instead of <string.h>." >&4
-       else
-               echo "No string header found -- You'll surely have problems." >&4
-       fi
-fi
-set i_string
-eval $setvar
-case "$i_string" in
-"$undef") strings=`./findhdr strings.h`;;
-*)       strings=`./findhdr string.h`;;
-esac
-
 : see if this is a sys/file.h system
 val=''
 set sys/file.h val
@@ -12744,8 +13032,8 @@ eval $inlibc
 set fcntl d_fcntl
 eval $inlibc
 
-echo " "
 : See if fcntl-based locking works.
+echo " "
 $cat >try.c <<EOCP
 #$i_stdlib I_STDLIB
 #ifdef I_STDLIB
@@ -12933,7 +13221,6 @@ eval $inlibc
 set fpclassl d_fpclassl
 eval $inlibc
 
-
 : check for fpos64_t
 echo " "
 echo "Checking to see if you have fpos64_t..." >&4
@@ -12968,7 +13255,7 @@ eval $inhdr
 set sys/mount.h i_sysmount
 eval $inhdr
 
-
+: Check for fs_data_s
 echo " "
 echo "Checking to see if your system supports struct fs_data..." >&4
 set d_fs_data_s fs_data $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h
@@ -12989,12 +13276,10 @@ esac
 set fsetpos d_fsetpos
 eval $inlibc
 
-
 : see if fstatfs exists
 set fstatfs d_fstatfs
 eval $inlibc
 
-
 : see if statvfs exists
 set statvfs d_statvfs
 eval $inlibc
@@ -13015,8 +13300,8 @@ case "$longsize" in
 8) echo "(Your long is 64 bits, so you could use ftell.)" ;;
 esac
 
-d_futimes="$undef"
 : check for a working futimes
+d_futimes="$undef"
 echo " "
 echo "Checking if you have a working futimes()" >&4
 $cat >try.c <<EOCP
@@ -13050,6 +13335,64 @@ else
 fi
 $rm_try
 
+: see if ndbm.h is available
+set ndbm.h i_ndbm
+eval $inhdr
+: Compatibility location for RedHat 7.1
+set gdbm/ndbm.h i_gdbmndbm
+eval $inhdr
+: Compatibility location for Debian 4.0
+set gdbm-ndbm.h i_gdbm_ndbm
+eval $inhdr
+
+val="$undef"
+if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then
+       : see if dbm_open exists
+       set dbm_open d_dbm_open
+       eval $inlibc
+       case "$d_dbm_open" in
+       $undef)
+               i_ndbm="$undef"
+               i_gdbmndbm="$undef"
+               i_gdbm_ndbm="$undef"
+               echo "We won't be including <ndbm.h>"
+               val="$undef"
+               ;;
+       *) val="$define"
+          ;;
+       esac
+fi
+set d_ndbm
+eval $setvar
+
+ndbm_hdr_protochk='name=$1; hdr=$2;
+eval "ihdr=\$""i_$name";
+val="$undef";
+if $test "$ihdr" = "$define"; then
+       $echo "Checking if your <$hdr> uses prototypes..." >&4;
+       case "$d_cplusplus" in
+       $define) ./protochk "$extern_C void dbm_close(DBM *);" literal "extern \"C\" {" $ihdr $hdr literal "}" && val="$define" ;;
+       *) ./protochk "$extern_C void dbm_close(int, int);" $ihdr $hdr || val="$define" ;;
+       esac;
+       case "$val" in
+       $define) $echo "Your <$hdr> seems to have prototypes";;
+       *) $echo "Your <$hdr> does not seem to have prototypes";;
+       esac;
+fi;
+set "d_${name}_h_uses_prototypes";
+eval $setvar'
+
+set ndbm ndbm.h
+eval $ndbm_hdr_protochk
+set gdbmndbm gdbm/ndbm.h
+eval $ndbm_hdr_protochk
+set gdbm_ndbm gdbm-ndbm.h
+eval $ndbm_hdr_protochk
+
+: see if getaddrinfo exists
+set getaddrinfo d_getaddrinfo
+eval $inlibc
+
 : see if getcwd exists
 set getcwd d_getcwd
 eval $inlibc
@@ -13058,7 +13401,6 @@ eval $inlibc
 set getespwnam d_getespwnam
 eval $inlibc
 
-
 : see if getfsstat exists
 set getfsstat d_getfsstat
 eval $inlibc
@@ -13083,27 +13425,27 @@ case "$d_getgrent_r" in
        define)
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, size_t, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBWR ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, int, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIR ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='struct group* getgrent_r(struct group*, char*, size_t);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=S_SBW ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBW ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='struct group* getgrent_r(struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBI ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBI ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, int, FILE**);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBIH ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIH ;;
        esac
        case "$getgrent_r_proto" in
        ''|0)   d_getgrent_r=undef
@@ -13144,19 +13486,19 @@ case "$d_getgrgid_r" in
        define)
        case "$getgrgid_r_proto" in
        ''|0) try='int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0) try='int getgrgid_r(gid_t, struct group*, char*, int, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0) try='int getgrgid_r(gid_t, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0) try='struct group* getgrgid_r(gid_t, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0)   d_getgrgid_r=undef
@@ -13197,23 +13539,23 @@ case "$d_getgrnam_r" in
        define)
        case "$getgrnam_r_proto" in
        ''|0) try='int getgrnam_r(const char*, struct group*, char*, size_t, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='int getgrnam_r(const char*, struct group*, char*, int, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='struct group* getgrnam_r(const char*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=S_CBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CBI ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='int getgrnam_r(const char*, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='struct group* getgrnam_r(const char*, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0)   d_getgrnam_r=undef
@@ -13293,7 +13635,7 @@ case "$d_uname$d_gethname" in
 *define*)
        dflt=n
        cat <<EOM
+
 Every now and then someone has a $call() that lies about the hostname
 but can't be fixed for political or economic reasons.  If you wish, I can
 pretend $call() isn't there and maybe compute hostname at run-time
@@ -13351,47 +13693,47 @@ case "$d_gethostbyaddr_r" in
        define)
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const void*, size_t, int, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, int, int, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const void*, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, int, int, struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, int, int);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0)   d_gethostbyaddr_r=undef
@@ -13432,15 +13774,15 @@ case "$d_gethostbyname_r" in
        define)
        case "$gethostbyname_r_proto" in
        ''|0) try='int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
        esac
        case "$gethostbyname_r_proto" in
        ''|0) try='struct hostent* gethostbyname_r(const char*, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
        esac
        case "$gethostbyname_r_proto" in
        ''|0) try='int gethostbyname_r(const char*, struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
        esac
        case "$gethostbyname_r_proto" in
        ''|0)   d_gethostbyname_r=undef
@@ -13481,27 +13823,27 @@ case "$d_gethostent_r" in
        define)
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBIE ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=S_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBIE ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBI ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, char*, int);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBI ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SD ;;
        esac
        case "$gethostent_r_proto" in
        ''|0)   d_gethostent_r=undef
@@ -13555,19 +13897,19 @@ case "$d_getlogin_r" in
        define)
        case "$getlogin_r_proto" in
        ''|0) try='int getlogin_r(char*, size_t);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=I_BW ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BW ;;
        esac
        case "$getlogin_r_proto" in
        ''|0) try='int getlogin_r(char*, int);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=I_BI ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BI ;;
        esac
        case "$getlogin_r_proto" in
        ''|0) try='char* getlogin_r(char*, size_t);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=B_BW ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BW ;;
        esac
        case "$getlogin_r_proto" in
        ''|0) try='char* getlogin_r(char*, int);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=B_BI ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BI ;;
        esac
        case "$getlogin_r_proto" in
        ''|0)   d_getlogin_r=undef
@@ -13600,6 +13942,10 @@ eval $inlibc
 set getmntent d_getmntent
 eval $inlibc
 
+: see if getnameinfo exists
+set getnameinfo d_getnameinfo
+eval $inlibc
+
 : see if getnetbyaddr exists
 set getnetbyaddr d_getnbyaddr
 eval $inlibc
@@ -13628,35 +13974,35 @@ case "$d_getnetbyaddr_r" in
        define)
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(unsigned long, int, struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(long, int, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='struct netent* getnetbyaddr_r(in_addr_t, int, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='struct netent* getnetbyaddr_r(long, int, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(in_addr_t, int, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(long, int, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(int, int, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(uint32_t, int, struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0)   d_getnetbyaddr_r=undef
@@ -13697,19 +14043,19 @@ case "$d_getnetbyname_r" in
        define)
        case "$getnetbyname_r_proto" in
        ''|0) try='int getnetbyname_r(const char*, struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0) try='int getnetbyname_r(const char*, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0) try='struct netent* getnetbyname_r(const char*, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0) try='int getnetbyname_r(const char*, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0)   d_getnetbyname_r=undef
@@ -13750,27 +14096,27 @@ case "$d_getnetent_r" in
        define)
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBIE ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='struct netent* getnetent_r(struct netent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=S_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBIE ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='struct netent* getnetent_r(struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBI ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBI ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SD ;;
        esac
        case "$getnetent_r_proto" in
        ''|0)   d_getnetent_r=undef
@@ -13804,6 +14150,7 @@ eval $hasproto
 set getpagesize d_getpagsz
 eval $inlibc
 
+: Optional checks for getprotobyname and getprotobynumber
 
 : see if getprotobyname exists
 set getprotobyname d_getpbyname
@@ -13849,15 +14196,15 @@ case "$d_getprotobyname_r" in
        define)
        case "$getprotobyname_r_proto" in
        ''|0) try='int getprotobyname_r(const char*, struct protoent*, char*, size_t, struct protoent**);'
-       ./protochk "extern $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
        esac
        case "$getprotobyname_r_proto" in
        ''|0) try='struct protoent* getprotobyname_r(const char*, struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
        esac
        case "$getprotobyname_r_proto" in
        ''|0) try='int getprotobyname_r(const char*, struct protoent*, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
        esac
        case "$getprotobyname_r_proto" in
        ''|0)   d_getprotobyname_r=undef
@@ -13898,15 +14245,15 @@ case "$d_getprotobynumber_r" in
        define)
        case "$getprotobynumber_r_proto" in
        ''|0) try='int getprotobynumber_r(int, struct protoent*, char*, size_t, struct protoent**);'
-       ./protochk "extern $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
        esac
        case "$getprotobynumber_r_proto" in
        ''|0) try='struct protoent* getprotobynumber_r(int, struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
        esac
        case "$getprotobynumber_r_proto" in
        ''|0) try='int getprotobynumber_r(int, struct protoent*, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
        esac
        case "$getprotobynumber_r_proto" in
        ''|0)   d_getprotobynumber_r=undef
@@ -13947,19 +14294,19 @@ case "$d_getprotoent_r" in
        define)
        case "$getprotoent_r_proto" in
        ''|0) try='int getprotoent_r(struct protoent*, char*, size_t, struct protoent**);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0) try='int getprotoent_r(struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBI ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0) try='struct protoent* getprotoent_r(struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=S_SBI ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0) try='int getprotoent_r(struct protoent*, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SD ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0)   d_getprotoent_r=undef
@@ -14013,27 +14360,27 @@ case "$d_getpwent_r" in
        define)
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, size_t, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBWR ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, int, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIR ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='struct passwd* getpwent_r(struct passwd*, char*, size_t);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=S_SBW ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBW ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='struct passwd* getpwent_r(struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBI ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBI ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, int, FILE**);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBIH ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIH ;;
        esac
        case "$getpwent_r_proto" in
        ''|0)   d_getpwent_r=undef
@@ -14074,19 +14421,19 @@ case "$d_getpwnam_r" in
        define)
        case "$getpwnam_r_proto" in
        ''|0) try='int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0) try='struct passwd* getpwnam_r(const char*, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0)   d_getpwnam_r=undef
@@ -14127,19 +14474,19 @@ case "$d_getpwuid_r" in
        define)
        case "$getpwuid_r_proto" in
        ''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0) try='struct passwd* getpwuid_r(uid_t, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0)   d_getpwuid_r=undef
@@ -14164,6 +14511,7 @@ case "$d_getpwuid_r" in
        ;;
 esac
 
+: Optional checks for getsbyname and getsbyport
 
 : see if getservbyname exists
 set getservbyname d_getsbyname
@@ -14193,15 +14541,15 @@ case "$d_getservbyname_r" in
        define)
        case "$getservbyname_r_proto" in
        ''|0) try='int getservbyname_r(const char*, const char*, struct servent*, char*, size_t, struct servent**);'
-       ./protochk "extern $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
        esac
        case "$getservbyname_r_proto" in
        ''|0) try='struct servent* getservbyname_r(const char*, const char*, struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
        esac
        case "$getservbyname_r_proto" in
        ''|0) try='int getservbyname_r(const char*, const char*, struct servent*, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
        esac
        case "$getservbyname_r_proto" in
        ''|0)   d_getservbyname_r=undef
@@ -14242,15 +14590,15 @@ case "$d_getservbyport_r" in
        define)
        case "$getservbyport_r_proto" in
        ''|0) try='int getservbyport_r(int, const char*, struct servent*, char*, size_t, struct servent**);'
-       ./protochk "extern $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
        esac
        case "$getservbyport_r_proto" in
        ''|0) try='struct servent* getservbyport_r(int, const char*, struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
        esac
        case "$getservbyport_r_proto" in
        ''|0) try='int getservbyport_r(int, const char*, struct servent*, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
        esac
        case "$getservbyport_r_proto" in
        ''|0)   d_getservbyport_r=undef
@@ -14291,19 +14639,19 @@ case "$d_getservent_r" in
        define)
        case "$getservent_r_proto" in
        ''|0) try='int getservent_r(struct servent*, char*, size_t, struct servent**);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBWR ;;
        esac
        case "$getservent_r_proto" in
        ''|0) try='int getservent_r(struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBI ;;
        esac
        case "$getservent_r_proto" in
        ''|0) try='struct servent* getservent_r(struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=S_SBI ;;
        esac
        case "$getservent_r_proto" in
        ''|0) try='int getservent_r(struct servent*, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SD ;;
        esac
        case "$getservent_r_proto" in
        ''|0)   d_getservent_r=undef
@@ -14357,11 +14705,11 @@ case "$d_getspnam_r" in
        define)
        case "$getspnam_r_proto" in
        ''|0) try='int getspnam_r(const char*, struct spwd*, char*, size_t, struct spwd**);'
-       ./protochk "extern $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
        esac
        case "$getspnam_r_proto" in
        ''|0) try='struct spwd* getspnam_r(const char*, struct spwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getspnam_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getspnam_r_proto=S_CSBI ;;
        esac
        case "$getspnam_r_proto" in
        ''|0)   d_getspnam_r=undef
@@ -14421,11 +14769,11 @@ case "$d_gmtime_r" in
        define)
        case "$gmtime_r_proto" in
        ''|0) try='struct tm* gmtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && gmtime_r_proto=S_TS ;;
+       ./protochk "$extern_C $try" $hdrs && gmtime_r_proto=S_TS ;;
        esac
        case "$gmtime_r_proto" in
        ''|0) try='int gmtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && gmtime_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && gmtime_r_proto=I_TS ;;
        esac
        case "$gmtime_r_proto" in
        ''|0)   d_gmtime_r=undef
@@ -14541,6 +14889,14 @@ set d_index; eval $setvar
 set inet_aton d_inetaton
 eval $inlibc
 
+: see if inet_ntop exists
+set inet_ntop d_inetntop
+eval $inlibc
+
+: see if inet_pton exists
+set inet_pton d_inetpton
+eval $inlibc
+
 : Look for isascii
 echo " "
 $cat >isascii.c <<EOCP
@@ -14653,10 +15009,10 @@ eval $setvar
 set math.h i_math
 eval $inhdr
 
+: check to see if math.h defines _LIB_VERSION
 d_libm_lib_version="$undef"
 case $i_math in
     $define)
-       : check to see if math.h defines _LIB_VERSION
        echo " "
        echo "Checking to see if your libm supports _LIB_VERSION..." >&4
        $cat >try.c <<EOCP
@@ -14701,11 +15057,11 @@ case "$d_localtime_r" in
        define)
        case "$localtime_r_proto" in
        ''|0) try='struct tm* localtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && localtime_r_proto=S_TS ;;
+       ./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;;
        esac
        case "$localtime_r_proto" in
        ''|0) try='int localtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && localtime_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;;
        esac
        case "$localtime_r_proto" in
        ''|0)   d_localtime_r=undef
@@ -14737,11 +15093,32 @@ REENTRANT_PROTO*)
 /*  Does our libc's localtime_r call tzset ?
  *  return 0 if so, 1 otherwise.
  */
-#include <sys/types.h>
-#include <unistd.h>
-#include <time.h>
-#include <string.h>
-#include <malloc.h>
+#$i_systypes   I_SYS_TYPES
+#$i_unistd     I_UNISTD
+#$i_time       I_TIME
+#$i_stdlib     I_STDLIB
+#$i_string     I_STRING
+#$i_malloc     I_MALLOC
+#ifdef I_SYS_TYPES
+#  include <sys/types.h>
+#endif
+#ifdef I_UNISTD
+#  include <unistd.h>
+#endif
+#ifdef I_TIME
+#  include <time.h>
+#endif
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#ifdef I_STRING
+#  include <string.h>
+#else
+#  include <strings.h>
+#endif
+#ifdef I_MALLOC
+#  include <malloc.h>
+#endif
 int main()
 {
     time_t t = time(0L);
@@ -15066,7 +15443,7 @@ fi
 set d_msg
 eval $setvar
 
-
+: Check for msghdr_s
 echo " "
 echo "Checking to see if your system supports struct msghdr..." >&4
 set d_msghdr_s msghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
@@ -15128,7 +15505,7 @@ set d_volatile
 eval $setvar
 $rm_try
 
-
+: Check basic sizes
 echo " "
 $echo "Choosing the C types to be used for Perl's internal types..." >&4
 
@@ -15185,7 +15562,7 @@ int main() {
 }
 EOCP
 
-i8type=char
+i8type="signed char"
 u8type="unsigned char"
 i8size=1
 u8size=1
@@ -15342,6 +15719,89 @@ case "$nv_preserves_uv_bits" in
 esac
 $rm_try
 
+$echo "Checking to find the largest integer value your NVs can hold..." >&4
+: volatile so that the compiler has to store it out to memory.
+if test X"$d_volatile" = X"$define"; then
+       volatile=volatile
+fi
+$cat <<EOP >try.c
+#include <stdio.h>
+
+typedef $nvtype NV;
+
+int
+main() {
+  NV value = 2;
+  int count = 1;
+
+  while(count < 256) {
+    $volatile NV up = value + 1.0;
+    $volatile NV negated = -value;
+    $volatile NV down = negated - 1.0;
+    $volatile NV got_up = up - value;
+    int up_good = got_up == 1.0;
+    int got_down = down - negated;
+    int down_good = got_down == -1.0;
+
+    if (down_good != up_good) {
+      fprintf(stderr,
+             "Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n",
+             up_good, (double) got_up, down_good, (double) got_down,
+             count, (double) value);
+      return 1;
+    }
+    if (!up_good) {
+      while (1) {
+       if (count > 8) {
+         count -= 8;
+         fputs("256.0", stdout);
+       } else {
+         count--;
+         fputs("2.0", stdout);
+       }
+       if (!count) {
+         puts("");
+         return 0;
+       }
+       fputs("*", stdout);
+      }
+    }
+    value *= 2;
+    ++count;
+  }
+  fprintf(stderr, "Cannot overflow integer range, even at 2**%d (%.20f)\n",
+         count, (double) value);
+  return 1;
+}
+EOP
+set try
+
+nv_overflows_integers_at='0'
+if eval $compile; then
+    xxx="`$run ./try`"
+    case "$?" in
+       0)
+           case "$xxx" in
+               2*)  cat >&4 <<EOM
+The largest integer your NVs can preserve is equal to $xxx
+EOM
+                   nv_overflows_integers_at="$xxx"
+                   ;;
+               *)  cat >&4 <<EOM
+Cannot determine the largest integer value your NVs can hold, unexpected output
+'$xxx'
+EOM
+                   ;;
+           esac
+           ;;
+       *)  cat >&4 <<EOM
+Cannot determine the largest integer value your NVs can hold
+EOM
+           ;;
+    esac
+fi
+$rm_try
+
 $echo "Checking whether NV 0.0 is all bits zero in memory..." >&4
 : volatile so that the compiler has to store it out to memory.
 if test X"$d_volatile" = X"$define"; then
@@ -15550,10 +16010,36 @@ eval $inlibc
 set poll d_poll
 eval $inlibc
 
+: see if prctl exists
+set prctl d_prctl
+eval $inlibc
+
+: see if prctl supports PR_SET_NAME
+d_prctl_set_name=$undef
+case $d_prctl in
+    $define)
+       $cat >try.c <<EOM
+#include <sys/prctl.h>
+
+int main (int argc, char *argv[])
+{
+    return (prctl (PR_SET_NAME, "Test"));
+    } /* main */
+EOM
+       set try
+       if eval $compile_ok && $run ./try; then
+           echo "Your prctl (PR_SET_NAME, ...) works"
+           d_prctl_set_name=$define
+           fi
+       $rm_try
+       ;;
+    esac
+
 : see if readlink exists
 set readlink d_readlink
 eval $inlibc
 
+: Check if exe is symlink to abs path of executing program
 echo " "
 procselfexe=''
 val="$undef"
@@ -15661,7 +16147,6 @@ eval $setvar
 set pthread_attr_setscope d_pthread_attr_setscope
 eval $inlibc
 
-
 : see whether the various POSIXish _yields exist
 $cat >try.c <<EOP
 #include <pthread.h>
@@ -15747,15 +16232,15 @@ case "$d_random_r" in
        define)
        case "$random_r_proto" in
        ''|0) try='int random_r(int*, struct random_data*);'
-       ./protochk "extern $try" $hdrs && random_r_proto=I_iS ;;
+       ./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;;
        esac
        case "$random_r_proto" in
        ''|0) try='int random_r(long*, struct random_data*);'
-       ./protochk "extern $try" $hdrs && random_r_proto=I_lS ;;
+       ./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;;
        esac
        case "$random_r_proto" in
        ''|0) try='int random_r(struct random_data*, int32_t*);'
-       ./protochk "extern $try" $hdrs && random_r_proto=I_St ;;
+       ./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;;
        esac
        case "$random_r_proto" in
        ''|0)   d_random_r=undef
@@ -15806,11 +16291,11 @@ case "$d_readdir64_r" in
        define)
        case "$readdir64_r_proto" in
        ''|0) try='int readdir64_r(DIR*, struct dirent64*, struct dirent64**);'
-       ./protochk "extern $try" $hdrs && readdir64_r_proto=I_TSR ;;
+       ./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TSR ;;
        esac
        case "$readdir64_r_proto" in
        ''|0) try='int readdir64_r(DIR*, struct dirent64*);'
-       ./protochk "extern $try" $hdrs && readdir64_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TS ;;
        esac
        case "$readdir64_r_proto" in
        ''|0)   d_readdir64_r=undef
@@ -15851,11 +16336,11 @@ case "$d_readdir_r" in
        define)
        case "$readdir_r_proto" in
        ''|0) try='int readdir_r(DIR*, struct dirent*, struct dirent**);'
-       ./protochk "extern $try" $hdrs && readdir_r_proto=I_TSR ;;
+       ./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TSR ;;
        esac
        case "$readdir_r_proto" in
        ''|0) try='int readdir_r(DIR*, struct dirent*);'
-       ./protochk "extern $try" $hdrs && readdir_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TS ;;
        esac
        case "$readdir_r_proto" in
        ''|0)   d_readdir_r=undef
@@ -16407,11 +16892,11 @@ case "$d_setgrent_r" in
        define)
        case "$setgrent_r_proto" in
        ''|0) try='int setgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setgrent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && setgrent_r_proto=I_H ;;
        esac
        case "$setgrent_r_proto" in
        ''|0) try='void setgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setgrent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && setgrent_r_proto=V_H ;;
        esac
        case "$setgrent_r_proto" in
        ''|0)   d_setgrent_r=undef
@@ -16456,11 +16941,11 @@ case "$d_sethostent_r" in
        define)
        case "$sethostent_r_proto" in
        ''|0) try='int sethostent_r(int, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && sethostent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && sethostent_r_proto=I_ID ;;
        esac
        case "$sethostent_r_proto" in
        ''|0) try='void sethostent_r(int, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && sethostent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && sethostent_r_proto=V_ID ;;
        esac
        case "$sethostent_r_proto" in
        ''|0)   d_sethostent_r=undef
@@ -16517,7 +17002,7 @@ case "$d_setlocale_r" in
        define)
        case "$setlocale_r_proto" in
        ''|0) try='int setlocale_r(int, const char*, char*, int);'
-       ./protochk "extern $try" $hdrs && setlocale_r_proto=I_ICBI ;;
+       ./protochk "$extern_C $try" $hdrs && setlocale_r_proto=I_ICBI ;;
        esac
        case "$setlocale_r_proto" in
        ''|0)   d_setlocale_r=undef
@@ -16562,11 +17047,11 @@ case "$d_setnetent_r" in
        define)
        case "$setnetent_r_proto" in
        ''|0) try='int setnetent_r(int, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && setnetent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setnetent_r_proto=I_ID ;;
        esac
        case "$setnetent_r_proto" in
        ''|0) try='void setnetent_r(int, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && setnetent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setnetent_r_proto=V_ID ;;
        esac
        case "$setnetent_r_proto" in
        ''|0)   d_setnetent_r=undef
@@ -16627,11 +17112,11 @@ case "$d_setprotoent_r" in
        define)
        case "$setprotoent_r_proto" in
        ''|0) try='int setprotoent_r(int, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && setprotoent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=I_ID ;;
        esac
        case "$setprotoent_r_proto" in
        ''|0) try='void setprotoent_r(int, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && setprotoent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=V_ID ;;
        esac
        case "$setprotoent_r_proto" in
        ''|0)   d_setprotoent_r=undef
@@ -16676,11 +17161,11 @@ case "$d_setpwent_r" in
        define)
        case "$setpwent_r_proto" in
        ''|0) try='int setpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setpwent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && setpwent_r_proto=I_H ;;
        esac
        case "$setpwent_r_proto" in
        ''|0) try='void setpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setpwent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && setpwent_r_proto=V_H ;;
        esac
        case "$setpwent_r_proto" in
        ''|0)   d_setpwent_r=undef
@@ -16745,11 +17230,11 @@ case "$d_setservent_r" in
        define)
        case "$setservent_r_proto" in
        ''|0) try='int setservent_r(int, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && setservent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setservent_r_proto=I_ID ;;
        esac
        case "$setservent_r_proto" in
        ''|0) try='void setservent_r(int, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && setservent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setservent_r_proto=V_ID ;;
        esac
        case "$setservent_r_proto" in
        ''|0)   d_setservent_r=undef
@@ -16786,7 +17271,6 @@ eval $inlibc
 set sfio.h i_sfio
 eval $inhdr
 
-
 : see if sfio library is available
 case "$i_sfio" in
 $define)
@@ -16806,17 +17290,10 @@ $define)
        *) dflt='n';;
        esac
        echo "$package can use the sfio library, but it is experimental."
-       case "$useperlio" in
-       "$undef")
-           echo "For sfio also the PerlIO abstraction layer is needed."
-           echo "Earlier you said you wouldn't want that."
-           ;;
-       esac
        rp="You seem to have sfio available, do you want to try using it?"
        . ./myread
        case "$ans" in
-       y|Y)    echo "Ok, turning on both sfio and PerlIO, then."
-               useperlio="$define"
+       y|Y)    echo "Ok, turning on sfio then."
                val="$define"
                ;;
        *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
@@ -16936,8 +17413,8 @@ fi
 set d_shm
 eval $setvar
 
-echo " "
 : see if we have sigaction
+echo " "
 if set sigaction val -f d_sigaction; eval $csym; $val; then
        echo 'sigaction() found.' >&4
        $cat > try.c <<EOP
@@ -17190,7 +17667,6 @@ int main(int argc, char **argv) {
 EOP
 set try
 
-d_sprintf_returns_strlen="$undef"
 if eval $compile; then
     xxx="`$run ./try`"
     case "$?" in
@@ -17205,6 +17681,9 @@ EOM
        d_sprintf_returns_strlen="$undef"
         ;;
     esac
+else
+    echo "(I can't seem to compile the test program--assuming it doesn't)" >&4
+    d_sprintf_returns_strlen="$undef"
 fi
 $rm_try
 
@@ -17224,7 +17703,7 @@ case "$d_srand48_r" in
        define)
        case "$srand48_r_proto" in
        ''|0) try='int srand48_r(long, struct drand48_data*);'
-       ./protochk "extern $try" $hdrs && srand48_r_proto=I_LS ;;
+       ./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;;
        esac
        case "$srand48_r_proto" in
        ''|0)   d_srand48_r=undef
@@ -17265,7 +17744,7 @@ case "$d_srandom_r" in
        define)
        case "$srandom_r_proto" in
        ''|0) try='int srandom_r(unsigned int, struct random_data*);'
-       ./protochk "extern $try" $hdrs && srandom_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;;
        esac
        case "$srandom_r_proto" in
        ''|0)   d_srandom_r=undef
@@ -17304,24 +17783,21 @@ eval $hasproto
 set sys/stat.h i_sysstat
 eval $inhdr
 
-
 : see if stat knows about block sizes
 echo " "
 echo "Checking to see if your struct stat has st_blocks field..." >&4
 set d_statblks stat st_blocks $i_sysstat sys/stat.h
 eval $hasfield
 
-
 : see if this is a sys/vfs.h system
 set sys/vfs.h i_sysvfs
 eval $inhdr
 
-
 : see if this is a sys/statfs.h system
 set sys/statfs.h i_sysstatfs
 eval $inhdr
 
-
+: Check for statfs_s
 echo " "
 echo "Checking to see if your system supports struct statfs..." >&4
 set d_statfs_s statfs $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h $i_sysvfs sys/vfs.h $i_sysstatfs sys/statfs.h
@@ -17332,10 +17808,9 @@ case "$d_statfs_s" in
 esac
 
 
-
 : see if struct statfs knows about f_flags
 case "$d_statfs_s" in
-define)        
+define)
        echo " "
        echo "Checking to see if your struct statfs has f_flags field..." >&4
        set d_statfs_f_flags statfs f_flags $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h $i_sysvfs sys/vfs.h $i_sysstatfs sys/statfs.h
@@ -17351,6 +17826,113 @@ case "$d_statfs_f_flags" in
 *)              echo "No, it doesn't." ;;
 esac
 
+: see what flavor, if any, of static inline is supported
+echo " "
+echo "Checking to see if your system supports static inline..."
+$cat > try.c <<'EOCP'
+#include <stdlib.h>
+extern int f_via_a(int x);
+extern int f_via_b(int x);
+int main(int argc, char **argv)
+{
+    int y;
+
+    y = f_via_a(0);
+#ifdef USE_B
+    y = f_via_b(0);
+#endif
+    if (y == 42) {
+        return EXIT_SUCCESS;
+    }
+    else {
+        return EXIT_FAILURE;
+    }
+}
+EOCP
+$cat > a.c <<'EOCP'
+static INLINE int f(int x) {
+    int y;
+    y = x + 42;
+    return y;
+}
+
+int f_via_a(int x)
+{
+    return f(x);
+}
+EOCP
+$cat > b.c <<'EOCP'
+extern int f(int x);
+
+int f_via_b(int x)
+{
+    return f(x);
+}
+EOCP
+
+# Respect a hint (or previous) value for perl_static_inline, if there is one.
+case "$perl_static_inline" in
+'')    # Check the various possibilities, and break out on success.
+       # For gcc, prefer __inline__, which will still permit 
+       # cflags.SH to add in -ansi.
+       case "$gccversion" in
+               '') xxx="inline __inline__ __inline _inline";;
+               *)  xxx="__inline__ inline __inline _inline";;
+       esac
+       for inline in $xxx; do
+               set try -DINLINE=$inline a.c
+               if eval $compile && $run ./try; then
+                       # Now make sure there is no external linkage of static
+                       # functions
+                       set try -DINLINE=$inline -DUSE_B a.c b.c
+                       if eval $compile && $run ./try; then
+                               $echo "Your compiler supports static $inline, " >&4
+                               $echo "but it also creates an external definition," >&4
+                               $echo "so I won't use it." >&4
+                               val=$undef
+                       else
+                               $echo "Your compiler supports static $inline." >&4
+                               val=$define
+                               perl_static_inline="static $inline";
+                               break;
+                       fi
+               else
+                       $echo "Your compiler does NOT support static $inline." >&4
+                       val="$undef"
+               fi
+       done
+       ;;
+*inline*) # Some variant of inline exists.
+       echo "Keeping your $hint value of $perl_static_inline."
+       val=$define
+       ;;
+static)  # No inline capabilities
+       echo "Keeping your $hint value of $perl_static_inline."
+       val=$undef
+       ;;
+*)  # Unrecognized previous value -- blindly trust the supplied
+       # value and hope it makes sense.  Use old value for
+       # d_static_inline, if there is one.
+       echo "Keeping your $hint value of $perl_static_inline."
+       case "$d_static_inline" in
+               '') val=$define ;;
+               *)  val=$d_static_inline ;;
+       esac
+       ;;
+esac
+# Fallback to plain 'static' if nothing worked.
+case "$perl_static_inline" in
+'')
+       perl_static_inline="static"
+       val=$undef
+       ;;
+esac
+set d_static_inline
+eval $setvar
+$rm -f a.[co] b.[co]
+$rm_try
+
+: Check stream access
 $cat >&4 <<EOM
 Checking how to access stdio streams by file descriptor number...
 EOM
@@ -17469,15 +18051,15 @@ case "$d_strerror_r" in
        define)
        case "$strerror_r_proto" in
        ''|0) try='int strerror_r(int, char*, size_t);'
-       ./protochk "extern $try" $hdrs && strerror_r_proto=I_IBW ;;
+       ./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBW ;;
        esac
        case "$strerror_r_proto" in
        ''|0) try='int strerror_r(int, char*, int);'
-       ./protochk "extern $try" $hdrs && strerror_r_proto=I_IBI ;;
+       ./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBI ;;
        esac
        case "$strerror_r_proto" in
        ''|0) try='char* strerror_r(int, char*, size_t);'
-       ./protochk "extern $try" $hdrs && strerror_r_proto=B_IBW ;;
+       ./protochk "$extern_C $try" $hdrs && strerror_r_proto=B_IBW ;;
        esac
        case "$strerror_r_proto" in
        ''|0)   d_strerror_r=undef
@@ -17544,7 +18126,7 @@ EOM
 #define strtoll _strtoll
 #endif
 #include <stdio.h>
-extern long long int strtoll(char *s, char **, int); 
+extern long long int strtoll(char *s, char **, int);
 static int bad = 0;
 int check(char *s, long long ell, int een) {
        long long gll;
@@ -17601,7 +18183,7 @@ EOM
        $cat >try.c <<'EOCP'
 #include <errno.h>
 #include <stdio.h>
-extern unsigned long int strtoul(char *s, char **, int); 
+extern unsigned long int strtoul(char *s, char **, int);
 static int bad = 0;
 void check(char *s, unsigned long eul, int een) {
        unsigned long gul;
@@ -17684,7 +18266,7 @@ EOM
 #define strtoull __strtoull
 #endif
 #include <stdio.h>
-extern unsigned long long int strtoull(char *s, char **, int); 
+extern unsigned long long int strtoull(char *s, char **, int);
 static int bad = 0;
 int check(char *s, long long eull, int een) {
        long long gull;
@@ -17738,7 +18320,7 @@ EOM
        $cat >try.c <<'EOCP'
 #include <errno.h>
 #include <stdio.h>
-extern unsigned long long int strtouq(char *s, char **, int); 
+extern unsigned long long int strtouq(char *s, char **, int);
 static int bad = 0;
 void check(char *s, unsigned long long eull, int een) {
        unsigned long long gull;
@@ -17837,6 +18419,10 @@ if test "X$d_time" = X -o X"$timetype" = X; then
     eval $setvar
 fi
 
+: see if timegm exists
+set timegm d_timegm
+eval $inlibc
+
 : see if this is a sys/times.h system
 set sys/times.h i_systimes
 eval $inhdr
@@ -17875,7 +18461,7 @@ case "$d_tmpnam_r" in
        define)
        case "$tmpnam_r_proto" in
        ''|0) try='char* tmpnam_r(char*);'
-       ./protochk "extern $try" $hdrs && tmpnam_r_proto=B_B ;;
+       ./protochk "$extern_C $try" $hdrs && tmpnam_r_proto=B_B ;;
        esac
        case "$tmpnam_r_proto" in
        ''|0)   d_tmpnam_r=undef
@@ -17920,15 +18506,15 @@ case "$d_ttyname_r" in
        define)
        case "$ttyname_r_proto" in
        ''|0) try='int ttyname_r(int, char*, size_t);'
-       ./protochk "extern $try" $hdrs && ttyname_r_proto=I_IBW ;;
+       ./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBW ;;
        esac
        case "$ttyname_r_proto" in
        ''|0) try='int ttyname_r(int, char*, int);'
-       ./protochk "extern $try" $hdrs && ttyname_r_proto=I_IBI ;;
+       ./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBI ;;
        esac
        case "$ttyname_r_proto" in
        ''|0) try='char* ttyname_r(int, char*, int);'
-       ./protochk "extern $try" $hdrs && ttyname_r_proto=B_IBI ;;
+       ./protochk "$extern_C $try" $hdrs && ttyname_r_proto=B_IBI ;;
        esac
        case "$ttyname_r_proto" in
        ''|0)   d_ttyname_r=undef
@@ -17965,6 +18551,7 @@ fi
 set d_tzname
 eval $setvar
 
+: Check if is a multiplatform env
 case "$osname" in
 next|rhapsody|darwin) multiarch="$define" ;;
 esac
@@ -18055,6 +18642,7 @@ EOM
        ;;
 esac
 
+: Checking 32bit alignedness
 $cat <<EOM
 
 Checking to see whether you can access character data unalignedly...
@@ -18075,8 +18663,8 @@ $signal_t bletch(int s) { exit(4); }
 #endif
 int main() {
 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
-    U8 buf[8];
-    U32 *up;
+    volatile U8 buf[8];
+    volatile U32 *up;
     int i;
 
     if (sizeof(U32) != 4) {
@@ -18332,6 +18920,56 @@ esac
 : set the base revision
 baserev=5.0
 
+: length of character in bytes. Is always 1, otherwise it isnt C
+: This used to be a test using sizeof
+charsize=1
+
+: Check for the number of bits in a character
+case "$charbits" in
+'')    echo "Checking how long a character is (in bits)..." >&4
+       $cat >try.c <<EOCP
+#include <stdio.h>
+int main ()
+{
+    int n;
+    unsigned char c;
+    for (c = 1, n = 0; c; c <<= 1, n++) ;
+    printf ("%d\n", n);
+    return (0);
+    }
+EOCP
+       set try
+       if eval $compile_ok; then
+               dflt=`$run ./try`
+       else
+               dflt='8'
+               echo "(I can't seem to compile the test program.  Guessing...)"
+       fi
+       ;;
+*)
+       dflt="$charbits"
+       ;;
+esac
+rp="What is the length of a character (in bits)?"
+. ./myread
+charbits="$ans"
+$rm_try
+case "$charbits" in
+8)     ;;
+*)     cat >&4 << EOM
+Your system has an unsigned character size of $charbits bits, which
+is rather unusual (normally it is 8 bits).  Perl likely will not work
+correctly on your system, with subtle bugs in various places.
+EOM
+       rp='Do you really want to continue?'
+       dflt='n'
+       . ./myread
+       case "$ans" in
+               [yY])   echo >&4 "Okay, continuing."    ;;
+               *)      exit 1                          ;;
+       esac
+esac
+
 : how do we concatenate cpp tokens here?
 echo " "
 echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
@@ -18679,6 +19317,7 @@ EOCP
        esac
 done
 
+: Determine if this is an EBCDIC system
 echo " "
 echo "Determining whether or not we are on an EBCDIC system..." >&4
 $cat >try.c <<'EOM'
@@ -18706,6 +19345,7 @@ $rm_try
 set ebcdic
 eval $setvar
 
+: Check how to flush
 echo " "
 $cat >&4 <<EOM
 Checking how to flush all pending stdio output...
@@ -18825,7 +19465,7 @@ EOM
                        fi
                fi
        fi
-       $rm_try
+       $rm -f core try.core core.try.*
        case "$fflushNULL" in
        x)      $cat >&4 <<EOM
 Your fflush(NULL) works okay for output streams.
@@ -18993,7 +19633,7 @@ We won't be flushing handles at all before fork/exec/popen.
 EOM
        ;;
 esac
-$rm_try
+$rm_try tryp
 
 : Store the full pathname to the ar program for use in the C program
 : Respect a hint or command line value for full_ar.
@@ -19028,12 +19668,13 @@ gid_t) echo "gid_t found." ;;
        ;;
 esac
 
+: Check the size of GID
 echo " "
 case "$gidtype" in
 *_t) zzz="$gidtype"    ;;
 *)   zzz="gid"         ;;
 esac
-echo "Checking the size of $zzz..." >&4 
+echo "Checking the size of $zzz..." >&4
 cat > try.c <<EOCP
 #include <sys/types.h>
 #include <stdio.h>
@@ -19063,12 +19704,13 @@ else
 fi
 
 
+: Check if GID is signed
 echo " "
 case "$gidtype" in
 *_t) zzz="$gidtype"    ;;
 *)   zzz="gid"         ;;
 esac
-echo "Checking the sign of $zzz..." >&4 
+echo "Checking the sign of $zzz..." >&4
 cat > try.c <<EOCP
 #include <sys/types.h>
 #include <stdio.h>
@@ -19100,6 +19742,7 @@ else
 fi
 
 
+: Check 64bit sizes
 echo " "
 
 if $test X"$quadtype" != X; then
@@ -19255,7 +19898,7 @@ case "$sPRId64" in
        ;;
 esac
 
-
+: Check format strings for internal types
 echo " "
 $echo "Checking the format strings to be used for Perl's internal types..." >&4
 
@@ -19314,6 +19957,7 @@ case "$ivdformat" in
     ;;
 esac
 
+: Check format string for GID
 
 echo " "
 $echo "Checking the format string to be used for gids..." >&4
@@ -19361,7 +20005,6 @@ eval $inlibc
 set setgroups d_setgrps
 eval $inlibc
 
-
 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
 echo " "
 case "$d_getgrps$d_setgrps" in
@@ -19382,6 +20025,7 @@ EOM
 *)  groupstype="$gidtype";;
 esac
 
+: MAD = Misc Attribute Definition
 
 if $test $patchlevel -lt 9; then
 : MAD is not available in 5.8.x or earlier.
@@ -19415,6 +20059,7 @@ esac
 set mad
 eval $setvar
 
+: check whether make sets MAKE
 echo " "
 echo "Checking if your $make program sets \$(MAKE)..." >&4
 case "$make_set_make" in
@@ -19527,7 +20172,7 @@ EOM
                for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
                        for yyy in size_t long int; do
                                case "$netdb_host_type" in
-                               '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
+                               '')     try="$extern_C struct hostent *gethostbyaddr($xxx, $yyy, int);"
                                        if ./protochk "$try" $hdrs; then
                                                echo "Your system accepts $xxx for the first arg."
                                                echo "...and $yyy for the second arg."
@@ -19576,7 +20221,7 @@ EOM
                        $i_unistd unistd.h"
                for xxx in "const char *" "char *"; do
                        case "$netdb_name_type" in
-                       '')     try="extern struct hostent *gethostbyname($xxx);"
+                       '')     try="$extern_C struct hostent *gethostbyname($xxx);"
                                if ./protochk "$try" $hdrs; then
                                        echo "Your system accepts $xxx."
                                        netdb_name_type="$xxx"
@@ -19614,7 +20259,7 @@ EOM
                        $i_unistd unistd.h"
                for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
                        case "$netdb_net_type" in
-                       '')     try="extern struct netent *getnetbyaddr($xxx, int);"
+                       '')     try="$extern_C struct netent *getnetbyaddr($xxx, int);"
                                if ./protochk "$try" $hdrs; then
                                        echo "Your system accepts $xxx."
                                        netdb_net_type="$xxx"
@@ -19658,9 +20303,6 @@ case "$pager" in
        esac
        ;;
 *)     dflt="$pager"
-       : Instruct ./getfile to trust the hinted or previous pager value,
-       : even if it does not begin with a slash.  For example, on os2,
-       : pager might be cmd /c more.  See comments in UU/getfile.
        fn="f/($pager)"
        ;;
 esac
@@ -19729,7 +20371,177 @@ else
 fi
 $rm -f foo* bar*
 
-: check for type of arguments to select. 
+: see if this is a values.h system
+set values.h i_values
+eval $inhdr
+
+: Check the max offset that gmtime and localtime accept
+echo "Checking max offsets that gmtime () accepts"
+
+case $i_values in
+    define) yyy="#include <values.h>" ;;
+    *)      yyy="" ;;
+    esac
+
+case "$sGMTIME_min/$sGMTIME_max" in
+    0/0|/)
+       $cat >try.c <<EOCP
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+$yyy
+
+int i;
+struct tm *tmp;
+time_t pt;
+
+void gm_check (time_t t, int min_year, int max_year)
+{
+    tmp = gmtime (&t);
+    if ( tmp == NULL ||
+       /* Check tm_year overflow */
+        tmp->tm_year < min_year || tmp->tm_year > max_year)
+       tmp = NULL;
+    else
+       pt = t;
+    } /* gm_check */
+
+int check_max ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MAXLONG
+    gm_check (MAXLONG, 69, 0x7fffffff);
+#endif
+    if (tmp == NULL || tmp->tm_year < 0) {
+       for (i = 63; i >= 0; i--) {
+           time_t x = pt | ((time_t)1 << i);
+           if (x < 0 || x < pt) continue;
+           gm_check (x, 69, 0x7fffffff);
+           }
+       }
+    printf ("sGMTIME_max=%ld\n", pt);
+    return (0);
+    } /* check_max */
+
+int check_min ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MINLONG
+    gm_check (MINLONG, -1900, 70);
+#endif
+    if (tmp == NULL) {
+       for (i = 36; i >= 0; i--) {
+           time_t x = pt - ((time_t)1 << i);
+           if (x > 0) continue;
+           gm_check (x, -1900, 70);
+           }
+       }
+    printf ("sGMTIME_min=%ld\n", pt);
+    return (0);
+    } /* check_min */
+
+int main (int argc, char *argv[])
+{
+    fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t));
+    check_max ();
+    check_min ();
+    return (0);
+    } /* main */
+EOCP
+       set try
+       if eval $compile; then
+           eval `$run ./try`
+       else
+           echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
+           fi
+       $rm_try
+       ;;
+    esac
+
+echo "Checking max offsets that localtime () accepts"
+
+case "$sLOCALTIME_min/$sLOCALTIME_max" in
+    0/0|/)
+       $cat >try.c <<EOCP
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+$yyy
+
+int i;
+struct tm *tmp;
+time_t pt;
+
+void local_check (time_t t, int min_year, int max_year)
+{
+    if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
+       tmp = NULL;
+    else
+       tmp = localtime (&t);
+    if ( tmp == NULL ||
+       /* Check tm_year overflow */
+        tmp->tm_year < min_year || tmp->tm_year > max_year)
+       tmp = NULL;
+    else
+       pt = t;
+    } /* local_check */
+
+int check_max ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MAXLONG
+    local_check (MAXLONG, 69, 0x7fffffff);
+#endif
+    if (tmp == NULL || tmp->tm_year < 0) {
+       for (i = 63; i >= 0; i--) {
+           time_t x = pt | ((time_t)1 << i);
+           if (x < 0 || x < pt) continue;
+           local_check (x, 69, 0x7fffffff);
+           }
+       }
+    printf ("sLOCALTIME_max=%ld\n", pt);
+    return (0);
+   } /* check_max */
+
+int check_min ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MINLONG
+    local_check (MINLONG, -1900, 70);
+#endif
+    if (tmp == NULL) {
+       for (i = 36; i >= 0; i--) {
+           time_t x = pt - ((time_t)1 << i);
+           if (x > 0) continue;
+           local_check (x, -1900, 70);
+           }
+       }
+    printf ("sLOCALTIME_min=%ld\n", pt);
+    return (0);
+    } /* check_min */
+
+int main (int argc, char *argv[])
+{
+    check_max ();
+    check_min ();
+    return (0);
+    } /* main */
+EOCP
+       set try
+       if eval $compile; then
+           eval `$run ./try`
+       else
+           echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
+           fi
+       $rm_try
+       ;;
+    esac
+
+: check for type of arguments to select.
 case "$selecttype" in
 '') case "$d_select" in
        $define)
@@ -19738,7 +20550,7 @@ case "$selecttype" in
 Checking to see what type of arguments are accepted by select().
 EOM
                hdrs="$define sys/types.h
-                       $i_systime sys/time.h 
+                       $i_systime sys/time.h
                        $i_sysselct sys/select.h
                        $d_socket sys/socket.h"
                : The first arg can be int, unsigned, or size_t
@@ -19750,7 +20562,7 @@ EOM
                        for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
                                for tmo in 'struct timeval *' 'const struct timeval *'; do
                                        case "$val" in
-                                       '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
+                                       '')     try="$extern_C select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
                                                if ./protochk "$try" $hdrs; then
                                                        echo "Your system accepts $xxx."
                                                        val="$xxx"
@@ -19887,28 +20699,20 @@ EOM
 esac
 
 : Trace out the files included by signal.h, then look for SIGxxx names.
-: Remove SIGARRAYSIZE used by HPUX.
-: Remove SIGSTKSIZE used by Linux.
-: Remove SIGSTKSZ used by Posix.
-: Remove SIGTYP void lines used by OS2.
-: Some cpps, like os390, dont give the file name anywhere
 if [ "X$fieldn" = X ]; then
        : Just make some guesses.  We check them later.
        xxx='/usr/include/signal.h /usr/include/sys/signal.h'
 else
        xxx=`echo '#include <signal.h>' |
        $cppstdin $cppminus $cppflags 2>/dev/null |
-       $grep '^[       ]*#.*include' | 
-       $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sed 's!\\\\\\\\!/!g' | $sort | $uniq`
+       $grep '^[       ]*#.*include' |
+       $awk "{print \\$$fieldn}" | $sed 's!"!!g' |\
+               $sed 's!\\\\\\\\!/!g' | $sort | $uniq`
 fi
-: Check this list of files to be sure we have parsed the cpp output ok.
-: This will also avoid potentially non-existent files, such 
-: as ../foo/bar.h
 xxxfiles=''
 for xx in $xxx /dev/null ; do
        $test -f "$xx" && xxxfiles="$xxxfiles $xx"
 done
-: If we have found no files, at least try signal.h
 case "$xxxfiles" in
 '')    xxxfiles=`./findhdr signal.h` ;;
 esac
@@ -20019,14 +20823,14 @@ $1 ~ /^NSIG$/ { nsig = $2 }
     if (sig_name[$2]) {
        dup_name[ndups] = $1
        dup_num[ndups] = $2
-       ndups++ 
+       ndups++
     }
     else {
        sig_name[$2] = $1
        sig_num[$2] = $2
     }
 }
-END { 
+END {
     if (nsig == 0) {
        nsig = maxsig + 1
     }
@@ -20036,7 +20840,7 @@ END {
            printf("%s %d\n", sig_name[n], sig_num[n])
        }
        else {
-           printf("NUM%d %d\n", n, n) 
+           printf("NUM%d %d\n", n, n)
        }
     }
     for (n = 0; n < ndups; n++) {
@@ -20056,7 +20860,8 @@ $cat >>signal_cmd <<'EOS'
 
 set signal
 if eval $compile_ok; then
-       $run ./signal$_exe | ($sort -n -k 2 2>/dev/null || $sort -n +1) | $uniq | $awk -f signal.awk >signal.lst
+       $run ./signal$_exe | ($sort -n -k 2 2>/dev/null || $sort -n +1) |\
+               $uniq | $awk -f signal.awk >signal.lst
 else
        echo "(I can't seem be able to compile the whole test program)" >&4
        echo "(I'll try it in little pieces.)" >&4
@@ -20156,14 +20961,15 @@ echo $sig_name | $awk \
        printf "\n"
 }'
 sig_size=`echo $sig_name | awk '{print NF}'`
-$rm -f signal signal.c signal.awk signal.lst signal_cmd 
+$rm -f signal signal.c signal.awk signal.lst signal_cmd
 
+: Check size of size
 echo " "
 case "$sizetype" in
 *_t) zzz="$sizetype"   ;;
 *)   zzz="filesize"    ;;
 esac
-echo "Checking the size of $zzz..." >&4 
+echo "Checking the size of $zzz..." >&4
 cat > try.c <<EOCP
 #include <sys/types.h>
 #include <stdio.h>
@@ -20237,7 +21043,7 @@ EOM
        yyy="$yyy $sizetype int long unsigned"
        for xxx in $yyy; do
                case "$socksizetype" in
-               '')     try="extern int accept(int, struct sockaddr *, $xxx *);"
+               '')     try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
                        case "$usesocks" in
                        "$define")
                                if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
@@ -20313,10 +21119,77 @@ EOM
 fi
 $rm_try
 
+: Check the size of st_ino
+$echo " "
+$echo "Checking the size of st_ino..." >&4
+$cat > try.c <<EOCP
+#include <sys/stat.h>
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int main() {
+    struct stat st;
+    printf("%d\n", (int)sizeof(st.st_ino));
+    exit(0);
+}
+EOCP
+set try
+if eval $compile_ok; then
+       val=`$run ./try`
+       case "$val" in
+       '')     st_ino_size=4
+               $echo "(I can't execute the test program--guessing $st_ino_size.)" >&4
+               ;;
+       *)      st_ino_size=$val
+               $echo "Your st_ino is $st_ino_size bytes long."
+               ;;
+       esac
+else
+       st_ino_size=4
+       $echo "(I can't compile the test program--guessing $st_ino_size.)" >&4
+fi
+$rm_try
+
+: Check if st_ino is signed
+$echo " "
+$echo "Checking the sign of st_ino..." >&4
+$cat > try.c <<EOCP
+#include <sys/stat.h>
+#include <stdio.h>
+int main() {
+       struct stat foo;
+        foo.st_ino = -1;
+       if (foo.st_ino < 0)
+               printf("-1\n");
+       else
+               printf("1\n");
+}
+EOCP
+set try
+if eval $compile; then
+       val=`$run ./try`
+       case "$val" in
+       '')     st_ino_sign=1
+               $echo "(I can't execute the test program--guessing unsigned.)" >&4
+               ;;
+       *)      st_ino_sign=$val
+               case "$st_ino_sign" in
+                1) $echo "Your st_ino is unsigned." ;;
+               -1) $echo "Your st_ino is signed."   ;;
+               esac
+               ;;
+       esac
+else
+       st_ino_sign=1
+       $echo "(I can't compile the test program--guessing unsigned.)" >&4
+fi
+$rm_try
+
 : see what type of char stdio uses.
 echo " "
-echo '#include <stdio.h>' > stdio.c
-$cppstdin $cppminus < stdio.c > stdioh
+echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
 if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
        echo "Your stdio uses unsigned chars." >&4
        stdchar="unsigned char"
@@ -20324,7 +21197,7 @@ else
        echo "Your stdio uses signed chars." >&4
        stdchar="char"
 fi
-$rm -f stdio.* stdioh
+$rm -f stdioh
 
 : see what type uids are declared as in the kernel
 echo " "
@@ -20350,12 +21223,13 @@ uid_t)        echo "uid_t found." ;;
        ;;
 esac
 
+: Check size of UID
 echo " "
 case "$uidtype" in
 *_t) zzz="$uidtype"    ;;
 *)   zzz="uid"         ;;
 esac
-echo "Checking the size of $zzz..." >&4 
+echo "Checking the size of $zzz..." >&4
 cat > try.c <<EOCP
 #include <sys/types.h>
 #include <stdio.h>
@@ -20384,6 +21258,7 @@ else
        echo "(I can't compile the test program--guessing $uidsize.)" >&4
 fi
 
+: Check if UID is signed
 echo " "
 case "$uidtype" in
 *_t) zzz="$uidtype"    ;;
@@ -20421,7 +21296,7 @@ else
 fi
 
 
-
+: Check format string for UID
 echo " "
 $echo "Checking the format string to be used for uids..." >&4
 
@@ -20460,7 +21335,7 @@ case "$uidsign" in
        ;;
 esac
 
-
+: Check if site customization support was requested
 case "$usesitecustomize" in
     $define|true|[Yy]*)
        usesitecustomize="$define"
@@ -20470,6 +21345,21 @@ case "$usesitecustomize" in
        ;;
     esac
 
+: see if prototypes support variable argument declarations
+echo " "
+case "$prototype$i_stdarg" in
+$define$define)
+       echo "It appears we'll be able to prototype varargs functions." >&4
+       val="$define"
+       ;;
+*)
+       echo "Too bad... We won't be using prototyped varargs functions..." >&4
+       val="$undef"
+       ;;
+esac
+set vaproto
+eval $setvar
+
 : determine compiler compiler
 case "$yacc" in
 '')
@@ -20501,6 +21391,10 @@ case "$yacc" in
        ;;
 esac
 
+: see if this is a assert.h system
+set assert.h i_assert
+eval $inhdr
+
 : see if this is a fp.h system
 set fp.h i_fp
 eval $inhdr
@@ -20548,46 +21442,10 @@ else
        i_machcthr="$undef"
 fi
 
-
-
 : see if this is a mntent.h system
 set mntent.h i_mntent
 eval $inhdr
 
-: see if ndbm.h is available
-set ndbm.h t_ndbm
-eval $inhdr
-
-case "$t_ndbm" in
-$undef)
-    # Some Linux distributions such as RedHat 7.1 put the
-    # ndbm.h header in /usr/include/gdbm/ndbm.h.
-    if $test -f /usr/include/gdbm/ndbm.h; then
-       echo '<gdbm/ndbm.h> found.'
-        ccflags="$ccflags -I/usr/include/gdbm"
-        cppflags="$cppflags -I/usr/include/gdbm"
-        t_ndbm=$define
-    fi
-    ;;
-esac
-
-case "$t_ndbm" in
-$define)
-       : see if dbm_open exists
-       set dbm_open d_dbm_open
-       eval $inlibc
-       case "$d_dbm_open" in
-       $undef)
-               t_ndbm="$undef"
-               echo "We won't be including <ndbm.h>"
-               ;;
-       esac
-       ;;
-esac
-val="$t_ndbm"
-set i_ndbm
-eval $setvar
-
 : see if net/errno.h is available
 val=''
 set net/errno.h val
@@ -20629,6 +21487,7 @@ eval $inhdr
 set prot.h i_prot
 eval $inhdr
 
+: Preprocessor symbols
 echo " "
 $echo "Guessing which symbols your C compiler and preprocessor define..." >&4
 $cat <<'EOSH' > Cppsym.know
@@ -20763,11 +21622,11 @@ $eunicefix Cppsym.try
 ./Cppsym < Cppsym.know > Cppsym.true
 : Add in any linux cpp "predefined macros":
 case "$osname::$gccversion" in
-  *linux*::*.*)
+  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
     tHdrH=_tmpHdr
     rm -f $tHdrH'.h' $tHdrH
     touch $tHdrH'.h'
-    if cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
+    if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
        sed 's/#define[\ \  ]*//;s/[\ \     ].*$//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
        if [ -s $tHdrH'_cppsym.real' ]; then
          cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
@@ -20869,14 +21728,14 @@ case "$val3" in
                                echo "<sgtty.h> found." >&4
                        else
                                echo "System is pyramid with BSD universe."
-                               echo "<sgtty.h> not found--you could have problems." >&4
+                               ./warn "<sgtty.h> not found--you could have problems."
                        fi;;
                *) if $test `./findhdr termio.h`; then
                                val="$define"
                                echo "<termio.h> found." >&4
                        else
                                echo "System is pyramid with USG universe."
-                               echo "<termio.h> not found--you could have problems." >&4
+                               ./warn "<termio.h> not found--you could have problems."
                        fi;;
                esac
        elif ./usg; then
@@ -20887,7 +21746,7 @@ case "$val3" in
                        echo "<sgtty.h> found." >&4
                        val2="$define"
                else
-echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
+                       ./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
                fi
        else
                if $test `./findhdr sgtty.h`; then
@@ -20897,7 +21756,7 @@ echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
                        echo "<termio.h> found." >&4
                        val="$define"
                else
-echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
+                       ./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
                fi
        fi;;
 esac
 set i_syssockio
 eval $setvar
 
-
 : see if this is a syslog.h system
 set syslog.h i_syslog
 eval $inhdr
 
-
 : see if this is a sys/mode.h system
 set sys/mode.h i_sysmode
 eval $inhdr
 
+: see if there is a sys/poll.h file
+set sys/poll.h i_syspoll
+eval $inhdr
+
 : see if sys/resource.h has to be included
 set sys/resource.h i_sysresrc
 eval $inhdr
@@ -20980,7 +21841,6 @@ eval $inhdr
 set sys/un.h i_sysun
 eval $inhdr
 
-
 : see if this is a sys/utsname.h system
 set sys/utsname.h i_sysutsname
 eval $inhdr
@@ -20997,10 +21857,6 @@ eval $inhdr
 set utime.h i_utime
 eval $inhdr
 
-: see if this is a values.h system
-set values.h i_values
-eval $inhdr
-
 : see if this is a vfork system
 case "$d_vfork" in
 "$define")
@@ -21012,6 +21868,7 @@ case "$d_vfork" in
        ;;
 esac
 
+: Check extensions
 echo " "
 echo "Looking for extensions..." >&4
 : If we are using the old config.sh, known_extensions may contain
@@ -21025,44 +21882,72 @@ nonxs_extensions=''
 
 : Function to recursively find available extensions, ignoring DynaLoader
 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
+: In 5.10.1 and later, extensions are stored in directories
+: like File-Glob instead of the older File/Glob/.
 find_extensions='
     for xxx in *; do
        case "$xxx" in
            DynaLoader|dynaload) ;;
            *)
-           if $test -f $xxx/$xxx.xs -o -f $xxx/$xxx.c; then
-               known_extensions="$known_extensions $1$xxx";
-           elif $test -f $xxx/Makefile.PL; then
-               nonxs_extensions="$nonxs_extensions $1$xxx";
+           this_ext=`echo $xxx | $sed -e s/-/\\\//g`;
+           leaf=`echo $xxx | $sed -e s/.*-//`;
+           if $test -d File; then
+               if $test -f $xxx/$leaf.xs -o -f $xxx/$leaf.c; then
+                   known_extensions="$known_extensions $1$this_ext";
+               elif $test -f $xxx/Makefile.PL; then
+                   nonxs_extensions="$nonxs_extensions $1$this_ext";
+               else
+                   if $test -d $xxx -a $# -lt 10; then
+                       set $1$xxx/ $*;
+                       cd "$xxx";
+                       eval $find_extensions;
+                       cd ..;
+                       shift;
+                   fi;
+               fi;
            else
-               if $test -d $xxx -a $# -lt 10; then
-                   set $1$xxx/ $*;
-                   cd "$xxx";
-                   eval $find_extensions;
-                   cd ..;
-                   shift;
+               $ls -1 $xxx > $$.tmp;
+               if   $contains "\.xs$" $$.tmp > /dev/null 2>&1; then
+                   known_extensions="$known_extensions $this_ext";
+               elif $contains "\.c$"  $$.tmp > /dev/null 2>&1; then
+                   known_extensions="$known_extensions $this_ext";
+               elif $test -d $xxx; then
+                   nonxs_extensions="$nonxs_extensions $this_ext";
                fi;
+               $rm -f $$.tmp;
            fi
            ;;
        esac;
     done'
 tdir=`pwd`
+cd "$rsrc/cpan"
+set X
+shift
+eval $find_extensions
+cd "$rsrc/dist"
+set X
+shift
+eval $find_extensions
 cd "$rsrc/ext"
 set X
 shift
 eval $find_extensions
-# Special case:  Add in modules that nest beyond the first level.
-# Currently threads/shared and Hash/Util/FieldHash, since they are
-# not picked up by the recursive find above (and adding in general
-# recursive finding breaks SDBM_File/sdbm).
-# A.D. 20011025 (SDBM), ajgough 20071008 (FieldHash)
-known_extensions="$known_extensions threads/shared Hash/Util/FieldHash"
+if $test -d File-Glob; then
+    : All ext/ flattened
+else
+    # Special case:  Add in modules that nest beyond the first level.
+    # Currently threads/shared and Hash/Util/FieldHash, since they are
+    # not picked up by the recursive find above (and adding in general
+    # recursive finding breaks SDBM_File/sdbm).
+    # A.D. 20011025 (SDBM), ajgough 20071008 (FieldHash)
+    known_extensions="$known_extensions threads/shared Hash/Util/FieldHash"
+fi
 set X $known_extensions
 shift
-known_extensions="$*"
+known_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 set X $nonxs_extensions
 shift
-nonxs_extensions="$*"
+nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 cd "$tdir"
 
 : Now see which are supported on this system.
@@ -21091,7 +21976,7 @@ for xxx in $known_extensions ; do
                esac
                ;;
        NDBM_File|ndbm_fil)
-               case "$i_ndbm" in
+               case "$d_ndbm" in
                $define)
                    case "$osname-$use64bitint" in
                    hpux-define)
@@ -21170,6 +22055,8 @@ for xxx in $known_extensions ; do
                # --jhi
                avail_ext="$avail_ext $xxx"
                ;;
+       VMS*)
+               ;;
        Win32*)
                case "$osname" in
                cygwin) avail_ext="$avail_ext $xxx" ;;
@@ -21200,7 +22087,7 @@ avail_ext="$*"
 case "$onlyextensions" in
 '') ;;
 *)  keepextensions=''
-    echo "You have requested that only certains extensions be included..." >&4
+    echo "You have requested that only certain extensions be included..." >&4
     for i in $onlyextensions; do
         case " $avail_ext " in
         *" $i "*)
@@ -21370,7 +22257,7 @@ esac
 # the appropriate Makefile.PL.
 case " $static_ext " in
        *" Encode "*) # Add the subextensions of Encode
-       cd "$rsrc/ext"
+       cd "$rsrc/cpan"
        for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
                static_ext="$static_ext Encode/$xxx"
        done
@@ -21408,7 +22295,7 @@ sunos*X4*)
     ;;
 *) case "$usedl" in
     $define|true|[yY]*)
-           set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'` 
+           set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'` 
            shift
            perllibs="$*"
            ;;
@@ -21441,9 +22328,9 @@ if test -d ../UU; then
        cd ..
 fi
 
-: configuration may be patched via a 'config.arch' file
+: configuration may be unconditionally patched via a 'config.arch' file
 if $test -f config.arch; then
-       echo "I see a config.arch file, loading it."
+       echo "I see a config.arch file, loading it." >&4
        . ./config.arch
 fi
 
@@ -21491,13 +22378,18 @@ $startsh
 # Configured by     : $cf_by
 # Target system     : $myuname
 
+EOT
+: Add in command line options if available
+$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
+
+$spitshell <<EOT >>config.sh
+
 Author='$Author'
 Date='$Date'
 Header='$Header'
 Id='$Id'
 Locker='$Locker'
 Log='$Log'
-Mcc='$Mcc'
 RCSfile='$RCSfile'
 Revision='$Revision'
 Source='$Source'
@@ -21525,6 +22417,7 @@ awk='$awk'
 baserev='$baserev'
 bash='$bash'
 bin='$bin'
+bin_ELF='$bin_ELF'
 binexp='$binexp'
 bison='$bison'
 byacc='$byacc'
@@ -21543,6 +22436,8 @@ ccversion='$ccversion'
 cf_by='$cf_by'
 cf_email='$cf_email'
 cf_time='$cf_time'
+charbits='$charbits'
+charsize='$charsize'
 chgrp='$chgrp'
 chmod='$chmod'
 chown='$chown'
@@ -21586,9 +22481,11 @@ d_accessx='$d_accessx'
 d_aintl='$d_aintl'
 d_alarm='$d_alarm'
 d_archlib='$d_archlib'
+d_asctime64='$d_asctime64'
 d_asctime_r='$d_asctime_r'
 d_atolf='$d_atolf'
 d_atoll='$d_atoll'
+d_attribute_deprecated='$d_attribute_deprecated'
 d_attribute_format='$d_attribute_format'
 d_attribute_malloc='$d_attribute_malloc'
 d_attribute_nonnull='$d_attribute_nonnull'
@@ -21623,10 +22520,12 @@ d_crypt_r='$d_crypt_r'
 d_csh='$d_csh'
 d_ctermid='$d_ctermid'
 d_ctermid_r='$d_ctermid_r'
+d_ctime64='$d_ctime64'
 d_ctime_r='$d_ctime_r'
 d_cuserid='$d_cuserid'
 d_dbl_dig='$d_dbl_dig'
 d_dbminitproto='$d_dbminitproto'
+d_difftime64='$d_difftime64'
 d_difftime='$d_difftime'
 d_dir_dd_fd='$d_dir_dd_fd'
 d_dirfd='$d_dirfd'
@@ -21685,6 +22584,9 @@ d_fsync='$d_fsync'
 d_ftello='$d_ftello'
 d_ftime='$d_ftime'
 d_futimes='$d_futimes'
+d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
+d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
+d_getaddrinfo='$d_getaddrinfo'
 d_getcwd='$d_getcwd'
 d_getespwnam='$d_getespwnam'
 d_getfsstat='$d_getfsstat'
@@ -21706,6 +22608,7 @@ d_getlogin='$d_getlogin'
 d_getlogin_r='$d_getlogin_r'
 d_getmnt='$d_getmnt'
 d_getmntent='$d_getmntent'
+d_getnameinfo='$d_getnameinfo'
 d_getnbyaddr='$d_getnbyaddr'
 d_getnbyname='$d_getnbyname'
 d_getnent='$d_getnent'
@@ -21741,6 +22644,7 @@ d_getservprotos='$d_getservprotos'
 d_getspnam='$d_getspnam'
 d_getspnam_r='$d_getspnam_r'
 d_gettimeod='$d_gettimeod'
+d_gmtime64='$d_gmtime64'
 d_gmtime_r='$d_gmtime_r'
 d_gnulibc='$d_gnulibc'
 d_grpasswd='$d_grpasswd'
@@ -21750,6 +22654,8 @@ d_ilogbl='$d_ilogbl'
 d_inc_version_list='$d_inc_version_list'
 d_index='$d_index'
 d_inetaton='$d_inetaton'
+d_inetntop='$d_inetntop'
+d_inetpton='$d_inetpton'
 d_int64_t='$d_int64_t'
 d_isascii='$d_isascii'
 d_isfinite='$d_isfinite'
@@ -21761,6 +22667,7 @@ d_lchown='$d_lchown'
 d_ldbl_dig='$d_ldbl_dig'
 d_libm_lib_version='$d_libm_lib_version'
 d_link='$d_link'
+d_localtime64='$d_localtime64'
 d_localtime_r='$d_localtime_r'
 d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
 d_locconv='$d_locconv'
@@ -21785,6 +22692,7 @@ d_mkdtemp='$d_mkdtemp'
 d_mkfifo='$d_mkfifo'
 d_mkstemp='$d_mkstemp'
 d_mkstemps='$d_mkstemps'
+d_mktime64='$d_mktime64'
 d_mktime='$d_mktime'
 d_mmap='$d_mmap'
 d_modfl='$d_modfl'
@@ -21805,6 +22713,8 @@ d_msgsnd='$d_msgsnd'
 d_msync='$d_msync'
 d_munmap='$d_munmap'
 d_mymalloc='$d_mymalloc'
+d_ndbm='$d_ndbm'
+d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
 d_nice='$d_nice'
 d_nl_langinfo='$d_nl_langinfo'
 d_nv_preserves_uv='$d_nv_preserves_uv'
@@ -21821,6 +22731,8 @@ d_phostname='$d_phostname'
 d_pipe='$d_pipe'
 d_poll='$d_poll'
 d_portable='$d_portable'
+d_prctl='$d_prctl'
+d_prctl_set_name='$d_prctl_set_name'
 d_printf_format_null='$d_printf_format_null'
 d_procselfexe='$d_procselfexe'
 d_pseudofork='$d_pseudofork'
@@ -21906,8 +22818,10 @@ d_sigaction='$d_sigaction'
 d_signbit='$d_signbit'
 d_sigprocmask='$d_sigprocmask'
 d_sigsetjmp='$d_sigsetjmp'
+d_sin6_scope_id='$d_sin6_scope_id'
 d_sitearch='$d_sitearch'
 d_snprintf='$d_snprintf'
+d_sockaddr_sa_len='$d_sockaddr_sa_len'
 d_sockatmark='$d_sockatmark'
 d_sockatmarkproto='$d_sockatmarkproto'
 d_socket='$d_socket'
@@ -21923,6 +22837,7 @@ d_sresuproto='$d_sresuproto'
 d_statblks='$d_statblks'
 d_statfs_f_flags='$d_statfs_f_flags'
 d_statfs_s='$d_statfs_s'
+d_static_inline='$d_static_inline'
 d_statvfs='$d_statvfs'
 d_stdio_cnt_lval='$d_stdio_cnt_lval'
 d_stdio_ptr_lval='$d_stdio_ptr_lval'
@@ -21962,6 +22877,7 @@ d_tcsetpgrp='$d_tcsetpgrp'
 d_telldir='$d_telldir'
 d_telldirproto='$d_telldirproto'
 d_time='$d_time'
+d_timegm='$d_timegm'
 d_times='$d_times'
 d_tm_tm_gmtoff='$d_tm_tm_gmtoff'
 d_tm_tm_zone='$d_tm_tm_zone'
@@ -22009,6 +22925,7 @@ dlsrc='$dlsrc'
 doublesize='$doublesize'
 drand01='$drand01'
 drand48_r_proto='$drand48_r_proto'
+dtrace='$dtrace'
 dynamic_ext='$dynamic_ext'
 eagain='$eagain'
 ebcdic='$ebcdic'
@@ -22025,6 +22942,7 @@ eunicefix='$eunicefix'
 exe_ext='$exe_ext'
 expr='$expr'
 extensions='$extensions'
+extern_C='$extern_C'
 extras='$extras'
 fflushNULL='$fflushNULL'
 fflushall='$fflushall'
@@ -22090,6 +23008,7 @@ i64type='$i64type'
 i8size='$i8size'
 i8type='$i8type'
 i_arpainet='$i_arpainet'
+i_assert='$i_assert'
 i_bsdioctl='$i_bsdioctl'
 i_crypt='$i_crypt'
 i_db='$i_db'
@@ -22102,6 +23021,8 @@ i_float='$i_float'
 i_fp='$i_fp'
 i_fp_class='$i_fp_class'
 i_gdbm='$i_gdbm'
+i_gdbm_ndbm='$i_gdbm_ndbm'
+i_gdbmndbm='$i_gdbmndbm'
 i_grp='$i_grp'
 i_ieeefp='$i_ieeefp'
 i_inttypes='$i_inttypes'
@@ -22111,6 +23032,7 @@ i_limits='$i_limits'
 i_locale='$i_locale'
 i_machcthr='$i_machcthr'
 i_malloc='$i_malloc'
+i_mallocmalloc='$i_mallocmalloc'
 i_math='$i_math'
 i_memory='$i_memory'
 i_mntent='$i_mntent'
@@ -22145,6 +23067,7 @@ i_sysmode='$i_sysmode'
 i_sysmount='$i_sysmount'
 i_sysndir='$i_sysndir'
 i_sysparam='$i_sysparam'
+i_syspoll='$i_syspoll'
 i_sysresrc='$i_sysresrc'
 i_syssecrt='$i_syssecrt'
 i_sysselct='$i_sysselct'
@@ -22288,6 +23211,7 @@ nroff='$nroff'
 nvEUformat='$nvEUformat'
 nvFUformat='$nvFUformat'
 nvGUformat='$nvGUformat'
+nv_overflows_integers_at='$nv_overflows_integers_at'
 nv_preserves_uv_bits='$nv_preserves_uv_bits'
 nveformat='$nveformat'
 nvfformat='$nvfformat'
@@ -22310,6 +23234,7 @@ path_sep='$path_sep'
 perl5='$perl5'
 perl='$perl'
 perl_patchlevel='$perl_patchlevel'
+perl_static_inline='$perl_static_inline'
 perladmin='$perladmin'
 perllibs='$perllibs'
 perlpath='$perlpath'
@@ -22342,6 +23267,10 @@ rm_try='$rm_try'
 rmail='$rmail'
 run='$run'
 runnm='$runnm'
+sGMTIME_max='$sGMTIME_max'
+sGMTIME_min='$sGMTIME_min'
+sLOCALTIME_max='$sLOCALTIME_max'
+sLOCALTIME_min='$sLOCALTIME_min'
 sPRIEUldbl='$sPRIEUldbl'
 sPRIFUldbl='$sPRIFUldbl'
 sPRIGUldbl='$sPRIGUldbl'
@@ -22418,6 +23347,8 @@ srand48_r_proto='$srand48_r_proto'
 srandom_r_proto='$srandom_r_proto'
 src='$src'
 ssizetype='$ssizetype'
+st_ino_sign='$st_ino_sign'
+st_ino_size='$st_ino_size'
 startperl='$startperl'
 startsh='$startsh'
 static_ext='$static_ext'
@@ -22467,7 +23398,9 @@ use5005threads='$use5005threads'
 use64bitall='$use64bitall'
 use64bitint='$use64bitint'
 usecrosscompile='$usecrosscompile'
+usedevel='$usedevel'
 usedl='$usedl'
+usedtrace='$usedtrace'
 usefaststdio='$usefaststdio'
 useithreads='$useithreads'
 uselargefiles='$uselargefiles'
@@ -22497,6 +23430,7 @@ uvsize='$uvsize'
 uvtype='$uvtype'
 uvuformat='$uvuformat'
 uvxformat='$uvxformat'
+vaproto='$vaproto'
 vendorarch='$vendorarch'
 vendorarchexp='$vendorarchexp'
 vendorbin='$vendorbin'
@@ -22528,30 +23462,28 @@ zcat='$zcat'
 zip='$zip'
 EOT
 
-: Add in command line options if available
-$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
-
 : add special variables
 $test -f $src/patchlevel.h && \
 awk '/^#define[        ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
-echo "PERL_PATCHLEVEL=$perl_patchlevel" >>config.sh
+echo "PERL_PATCHLEVEL='$perl_patchlevel'" >>config.sh
 echo "PERL_CONFIG_SH=true" >>config.sh
 
 : propagate old symbols
 if $test -f UU/config.sh; then
        <UU/config.sh $sort | $uniq >UU/oldconfig.sh
-       sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
-       $sort | $uniq -u >UU/oldsyms
-       set X `cat UU/oldsyms`
+       $sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' \
+               config.sh config.sh UU/oldconfig.sh |\
+               $sort | $uniq -u >UU/oldsyms
+       set X `$cat UU/oldsyms`
        shift
        case $# in
        0) ;;
        *)
-               cat <<EOM
+               $cat <<EOM
 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
 EOM
-               echo "# Variables propagated from previous config.sh file." >>config.sh
-               for sym in `cat UU/oldsyms`; do
+               echo ": Variables propagated from previous config.sh file." >>config.sh
+               for sym in `$cat UU/oldsyms`; do
                        echo "    Propagating $hint variable "'$'"$sym..."
                        eval 'tmp="$'"${sym}"'"'
                        echo "$tmp" | \