This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #24198] Bad default-domainname extraction in Configure-Script may cause infinit...
[perl5.git] / Configure
index 12b8fb0..e6d6c52 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, it is OK to send
@@ -24,9 +23,9 @@
 # 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 $
+# $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
 #
-# Generated on Fri Mar  3 08:34:32 CET 2006 [metaconfig 3.0 PL70]
+# Generated on Fri Aug  8 16:16:43 CEST 2008 [metaconfig 3.5 PL0]
 # (with additional metaconfig patches by perlbug@perl.org)
 
 cat >c1$$ <<EOF
@@ -65,6 +64,18 @@ EOF
        exit 1
 fi
 
+if test ! -c /dev/null ; then
+       cat >&4 <<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
+*** in /dev.
+*** Cannot continue, aborting.
+***
+EOF
+       exit 1
+fi
+
 : compute my invocation name
 me=$0
 case "$0" in
@@ -76,9 +87,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]'`
@@ -133,9 +144,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
@@ -169,17 +180,19 @@ true)
        esac
        ;;
 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 ./*
@@ -208,7 +221,6 @@ d_bsd=''
 d_eunice=''
 d_xenix=''
 eunicefix=''
-Mcc=''
 ar=''
 awk=''
 bash=''
@@ -304,6 +316,7 @@ firstmakefile=''
 lib_ext=''
 obj_ext=''
 path_sep=''
+rm_try=''
 afs=''
 afsroot=''
 alignbytes=''
@@ -319,7 +332,9 @@ d_atoll=''
 baserev=''
 bin=''
 binexp=''
+initialinstalllocation=''
 installbin=''
+userelocatableinc=''
 byteorder=''
 cc=''
 ccflags=''
@@ -331,7 +346,6 @@ optimize=''
 cf_email=''
 cf_by=''
 cf_time=''
-charsize=''
 contains=''
 cpp_stuff=''
 cpplast=''
@@ -352,9 +366,13 @@ d_attribute_noreturn=''
 d_attribute_pure=''
 d_attribute_unused=''
 d_attribute_warn_unused_result=''
+d_printf_format_null=''
 d_bcmp=''
 d_bcopy=''
+d_builtin_choose_expr=''
+d_builtin_expect=''
 d_bzero=''
+d_c99_variadic_macros=''
 d_casti32=''
 castflags=''
 d_castneg=''
@@ -368,12 +386,14 @@ d_void_closedir=''
 d_cmsghdr_s=''
 d_const=''
 d_copysignl=''
+d_cplusplus=''
 cryptlib=''
 d_crypt=''
 crypt_r_proto=''
 d_crypt_r=''
 d_csh=''
 full_csh=''
+d_ctermid=''
 ctermid_r_proto=''
 d_ctermid_r=''
 ctime_r_proto=''
@@ -382,6 +402,7 @@ d_cuserid=''
 d_dbl_dig=''
 d_dbminitproto=''
 d_difftime=''
+d_dir_dd_fd=''
 d_dirfd=''
 d_dlerror=''
 d_dlopen=''
@@ -542,6 +563,7 @@ d_ldbl_dig=''
 d_libm_lib_version=''
 d_link=''
 d_localtime_r=''
+d_localtime_r_needs_tzset=''
 localtime_r_proto=''
 d_locconv=''
 d_lockf=''
@@ -678,6 +700,7 @@ d_shmctl=''
 d_shmdt=''
 d_shmget=''
 d_sigaction=''
+d_signbit=''
 d_sigprocmask=''
 d_sigsetjmp=''
 usesitecustomize=''
@@ -754,6 +777,7 @@ d_tcsetpgrp=''
 d_telldirproto=''
 d_time=''
 timetype=''
+d_timegm=''
 clocktype=''
 d_times=''
 d_tmpnam_r=''
@@ -773,6 +797,7 @@ d_unsetenv=''
 d_usleep=''
 d_usleepproto=''
 d_ustat=''
+d_pseudofork=''
 d_vfork=''
 usevfork=''
 d_voidsig=''
@@ -815,6 +840,7 @@ html3dir=''
 html3direxp=''
 installhtml3dir=''
 i_arpainet=''
+i_assert=''
 i_crypt=''
 db_hashtype=''
 db_prefixtype=''
@@ -844,9 +870,13 @@ i_limits=''
 i_locale=''
 i_machcthr=''
 i_malloc=''
+i_mallocmalloc=''
 i_math=''
 i_memory=''
 i_mntent=''
+d_ndbm=''
+i_gdbm_ndbm=''
+i_gdbmndbm=''
 i_ndbm=''
 i_netdb=''
 i_neterrno=''
@@ -887,6 +917,7 @@ i_sysmode=''
 i_sysmount=''
 i_sysndir=''
 i_sysparam=''
+i_syspoll=''
 i_sysresrc=''
 i_syssecrt=''
 i_sysselct=''
@@ -917,6 +948,7 @@ i_stdarg=''
 i_varargs=''
 i_varhdr=''
 i_vfork=''
+d_inc_version_list=''
 inc_version_list=''
 inc_version_list_init=''
 installprefix=''
@@ -960,6 +992,10 @@ sPRIgldbl=''
 sSCNfldbl=''
 lseeksize=''
 lseektype=''
+mad=''
+madlyh=''
+madlyobj=''
+madlysrc=''
 make_set_make=''
 d_mymalloc=''
 freetype=''
@@ -1027,6 +1063,7 @@ i8size=''
 i8type=''
 ivsize=''
 ivtype=''
+nv_overflows_integers_at=''
 nv_preserves_uv_bits=''
 nvsize=''
 nvtype=''
@@ -1092,6 +1129,7 @@ sig_name_init=''
 sig_num=''
 sig_num_init=''
 sig_size=''
+d_sitearch=''
 installsitearch=''
 sitearch=''
 sitearchexp=''
@@ -1134,6 +1172,8 @@ stdchar=''
 d_stdio_stream_array=''
 stdio_stream_array=''
 sysman=''
+sGMTIME_max=''
+sGMTIME_min=''
 trnl=''
 uidformat=''
 uidsign=''
@@ -1142,6 +1182,8 @@ uidtype=''
 archname64=''
 use64bitall=''
 use64bitint=''
+dtrace=''
+usedtrace=''
 usefaststdio=''
 ccflags_uselargefiles=''
 ldflags_uselargefiles=''
@@ -1155,7 +1197,6 @@ nm_so_opt=''
 runnm=''
 usenm=''
 useperlio=''
-userelocatableinc=''
 usesocks=''
 d_oldpthreads=''
 use5005threads=''
@@ -1204,6 +1245,7 @@ yacc=''
 yaccflags=''
 CONFIG=''
 
+: Detect odd OSs
 define='define'
 undef='undef'
 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
@@ -1233,27 +1275,12 @@ elif test -d c:/. -o -n "$is_os2" ; then
     _exe=".exe"
 fi
 
+groupstype=''
 i_whoami=''
-ccname=''
-ccversion=''
-perllibs=''
-: set useposix=false in your hint file to disable the POSIX extension.
-useposix=true
-: set useopcode=false in your hint file to disable the Opcode extension.
-useopcode=true
 : Trailing extension.  Override this in a hint file, if needed.
 : Extra object files, if any, needed on this platform.
 archobjs=''
 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=''
-
-groupstype=''
 libnames=''
 : change the next line if compiling for Xenix/286 on Xenix/386
 xlibpth='/usr/lib/386 /lib/386'
@@ -1266,6 +1293,7 @@ glibpth="/lib /usr/lib $xlibpth"
 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
 test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
 test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
+test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
 
 : Private path used by Configure to find libraries.  Its value
 : is prepended to libpth. This variable takes care of special
@@ -1276,20 +1304,36 @@ 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=''
+: set useposix=false in your hint file to disable the POSIX extension.
+useposix=true
+: set useopcode=false in your hint file to disable the Opcode extension.
+useopcode=true
 archname64=''
 ccflags_uselargefiles=''
 ldflags_uselargefiles=''
 libswanted_uselargefiles=''
 : set usemultiplicity on the Configure command line to enable multiplicity.
 : set usesocks on the Configure command line to enable socks.
-: set usethreads on the Configure command line to enable threads.
-usereentrant='undef'
-: full support for void wanted by default
-defvoidused=15
-
 : List of libraries we want.
 : If anyone needs extra -lxxx, put those in a hint file.
 libswanted="sfio socket bind inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun"
@@ -1367,14 +1411,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
@@ -1417,11 +1461,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=$#
@@ -1433,7 +1476,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
@@ -1442,8 +1484,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
@@ -1531,6 +1571,7 @@ while test $# -gt 0; do
                fi
                cd UU
                shift;;
+       --help|\
        -h) shift; error=true;;
        -r) shift; reuseval=true;;
        -s) shift; silent=true; realsilent=true;;
@@ -1574,7 +1615,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
                  ;;
@@ -1588,7 +1629,7 @@ while test $# -gt 0; do
                  *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
                       yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
                  esac
-                 ;;       
+                 ;;
             esac
            case "$xxx" in
            append)
@@ -1613,7 +1654,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;;
@@ -1635,6 +1676,14 @@ Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
   -D : define symbol to have some value:
          -D symbol         symbol gets the value 'define'
          -D symbol=value   symbol gets the value 'value'
+       common used examples (see INSTALL for more info):
+         -Duse64bitint            use 64bit integers
+         -Duse64bitall            use 64bit integers and pointers
+         -Dusethreads             use thread support
+         -Dinc_version_list=none  do not include older perl trees in @INC
+         -DEBUGGING=none          DEBUGGING options
+         -Dcc=gcc                 choose your compiler
+         -Dprefix=/opt/perl5      choose your destination
   -E : stop at the end of questions, after having produced config.sh.
   -K : do not use unless you know what you are doing.
   -O : let -D and -U override definitions from loaded configuration file.
@@ -1642,16 +1691,19 @@ Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
   -U : undefine symbol:
          -U symbol    symbol gets the value 'undef'
          -U symbol=   symbol gets completely empty
+       e.g.:  -Uversiononly
   -A : manipulate symbol after the platform specific hints have been applied:
-        -A symbol=value                append " "value to symbol
-        -A append:symbol=value         append value to symbol
-        -A define:symbol=value         define symbol to have value
-         -A clear:symbol               define symbol to be ''
-        -A define:symbol               define symbol to be 'define'
-        -A eval:symbol=value           define symbol to be eval of value
-        -A prepend:symbol=value        prepend value to symbol
-        -A undef:symbol                define symbol to be 'undef'
-        -A undef:symbol=               define symbol to be ''
+         -A append:symbol=value   append value to symbol
+         -A symbol=value          like append:, but with a separating space
+         -A define:symbol=value   define symbol to have value
+         -A clear:symbol          define symbol to be ''
+         -A define:symbol         define symbol to be 'define'
+         -A eval:symbol=value     define symbol to be eval of value
+         -A prepend:symbol=value  prepend value to symbol
+         -A undef:symbol          define symbol to be 'undef'
+         -A undef:symbol=         define symbol to be ''
+       e.g.:  -A prepend:libswanted='cl pthread '
+              -A ccflags=-DSOME_MACRO
   -V : print version number and exit (with a zero status).
 EOM
        exit 1
@@ -1686,7 +1738,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
@@ -1732,11 +1784,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
@@ -1890,11 +1942,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
@@ -1928,8 +1982,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
@@ -2073,6 +2127,7 @@ 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]*) ;;
@@ -2233,14 +2288,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
@@ -2271,7 +2325,6 @@ tr
 uniq
 "
 trylist="
-Mcc
 ar
 bison
 byacc
@@ -2371,7 +2424,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
@@ -2380,7 +2433,7 @@ make)
        ;;
        esac
        ;;
-esac   
+esac
 case "$gmake" in
 gmake) ;;
 *)     # We can't have osname yet.
@@ -2436,6 +2489,20 @@ FOO
        ;;
 esac
 
+# This question was auctioned at YAPC::Europe-2007 in Vienna
+# I never promised you could answer it. I only auctioned the question.
+cat <<FOO
+The following message is sponsored by
+
+  Dresden.pm<--The stars should be here.
+
+Dear Perl user, system administrator or package
+maintainer, the Perl community sends greetings to
+you. Do you (emblematical) greet back [Y/n]? n
+
+FOO
+
+: Check what type of C compiler we use
 cat <<EOS >trygcc
 $startsh
 EOS
@@ -2457,15 +2524,36 @@ EOM
         case "$cc" in
         *gcc*) trygcc=no ;;
         esac
-        case "`$cc -v -c try.c 2>&1`" in
-        *gcc*) trygcc=no ;;
-        esac
+       # Skip this test because it gives a false match on output like:
+       #    ./trygcc: line 23: cc: command not found
+        # case "`$cc -v -c try.c 2>&1`" in
+        # *gcc*) trygcc=no ;;
+        # esac
         if $test X"$trygcc" = Xyes; then
             if gcc -o try -c try.c; then
                 echo " "
                 echo "You seem to have a working gcc, though." >&4
-                rp="Would you like to use it?"
-                dflt=y
+               # Switching compilers may undo the work of hints files.
+               # The most common problem is -D_REENTRANT for threads.
+               # This heuristic catches that case, but gets false positives
+               # if -Dusethreads was not actually specified.  Better to
+               # bail out here with a useful message than fail 
+               # mysteriously later. Should we perhaps just try to
+               # re-invoke Configure -Dcc=gcc config_args ?
+               if $test -f usethreads.cbu; then
+                       $cat >&4 <<EOM 
+
+*** However, any setting of the C compiler flags (e.g. for thread support)
+*** will be lost.  It may be necessary for you to restart Configure and
+*** add -Dcc=gcc to your Configure command line.
+
+EOM
+                       rp="Would you like to go ahead and try gcc anyway?"
+                       dflt=n
+               else
+                       rp="Would you like to use it?"
+                       dflt=y
+               fi
                 if $test -f myread; then
                     . ./myread
                 else
@@ -2478,15 +2566,6 @@ EOM
                 fi  
                 case "$ans" in
                 [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
-                       if $test -f usethreads.cbu; then
-                           $cat >&4 <<EOM 
-
-*** However, any setting of the C compiler flags (e.g. for thread support)
-*** has been lost.  It may be necessary to pass -Dcc=gcc to Configure
-*** (together with e.g. -Dusethreads).
-
-EOM
-                       fi;;
                 esac
             fi
         fi
@@ -2597,7 +2676,7 @@ case "$lns" in
 esac
 echo " "
 
-
+: Make symlinks util
 case "$mksymlinks" in
 $define|true|[yY]*)
        case "$src" in
@@ -2649,7 +2728,7 @@ $define|true|[yY]*)
        ;;
 esac
 
-
+: Check for Cross-Compilation
 case "$usecrosscompile" in
 $define|true|[yY]*)
        $echo "Cross-compiling..."
@@ -2968,7 +3047,7 @@ myuname=`$uname -a 2>/dev/null`
 $test -z "$myuname" && myuname=`hostname 2>/dev/null`
 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
 # because the A-Z/a-z are not consecutive.
-myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
+myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e "s,['/],,g" | \
        ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
 newmyuname="$myuname"
 dflt=n
@@ -3371,8 +3450,13 @@ EOM
        $cat <<EOM
 
 You may give one or more space-separated answers, or "none" if appropriate.
-A well-behaved OS will have no hints, so answering "none" or just "Policy"
-is a good thing.  DO NOT give a wrong version or a wrong OS.
+If you have a handcrafted Policy.sh file or a Policy.sh file generated by a
+previous run of Configure, you may specify it as well as or instead of
+OS-specific hints.  If hints are provided for your OS, you should use them:
+although Perl can probably be built without hints on many platforms, using
+hints often improve performance and may enable features that Configure can't
+set up on its own. If there are no hints that match your OS, specify "none";
+DO NOT give a wrong version or a wrong OS.
 
 EOM
 
@@ -3502,365 +3586,769 @@ case "$cf_by" in
        esac ;;
 esac
 
-: set up the script used to warn in case of inconsistency
-cat <<EOS >whoa
-$startsh
-EOS
-cat <<'EOSC' >>whoa
-dflt=y
-echo " "
-echo "*** WHOA THERE!!! ***" >&4
-echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
-rp="    Keep the $hint value?"
-. ./myread
-case "$ans" in
-y) td=$was; tu=$was;;
+: decide how portable to be.  Allow command line overrides.
+case "$d_portable" in
+"$undef") ;;
+*)     d_portable="$define" ;;
 esac
-EOSC
-
-: 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";;
-$undef$define) . ./whoa; eval "$var=\$tu";;
-*) eval "$var=$val";;
-esac'
 
-case "$usesocks" in
-$define|true|[yY]*)    dflt='y';;
-*) dflt='n';;
+: set up shell script to do ~ expansion
+cat >filexp <<EOSS
+$startsh
+: expand filename
+case "\$1" in
+ \~/*|\~)
+       echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
+       ;;
+ \~*)
+       if $test -f /bin/csh; then
+               /bin/csh -f -c "glob \$1"
+               failed=\$?
+               echo ""
+               exit \$failed
+       else
+               name=\`$expr x\$1 : '..\([^/]*\)'\`
+               dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
+               if $test ! -d "\$dir"; then
+                       me=\`basename \$0\`
+                       echo "\$me: can't locate home directory for: \$name" >&2
+                       exit 1
+               fi
+               case "\$1" in
+               */*)
+                       echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
+                       ;;
+               *)
+                       echo \$dir
+                       ;;
+               esac
+       fi
+       ;;
+*)
+       echo \$1
+       ;;
 esac
-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.
+EOSS
+chmod +x filexp
+$eunicefix filexp
 
-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" ;;
+: now set up to get a file name
+cat <<EOS >getfile
+$startsh
+EOS
+cat <<'EOSC' >>getfile
+tilde=''
+fullpath=''
+already=''
+skip=''
+none_ok=''
+exp_file=''
+nopath_ok=''
+orig_rp="$rp"
+orig_dflt="$dflt"
+case "$gfpth" in
+'') gfpth='.' ;;
 esac
-set usesocks
-eval $setvar
 
-case "$usesocks" in
-$define|true|[yY]*) useperlio="$define";;
+case "$fn" in
+*\(*)
+       : getfile will accept an answer from the comma-separated list
+       : enclosed in parentheses even if it does not meet other criteria.
+       expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
+       fn=`echo $fn | sed 's/(.*)//'`
+       ;;
 esac
 
-case "$useperlio" in
-$define|true|[yY]*|'') dflt='y';;
-*) dflt='n';;
+case "$fn" in
+*:*)
+       loc_file=`expr $fn : '.*:\(.*\)'`
+       fn=`expr $fn : '\(.*\):.*'`
+       ;;
 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"
-       ;;
+case "$fn" in
+*~*) tilde=true;;
+esac
+case "$fn" in
+*/*) fullpath=true;;
+esac
+case "$fn" in
+*+*) skip=true;;
+esac
+case "$fn" in
+*n*) none_ok=true;;
+esac
+case "$fn" in
+*e*) exp_file=true;;
+esac
+case "$fn" in
+*p*) nopath_ok=true;;
 esac
-set useperlio
-eval $setvar 
 
-case "$usesocks" in
-$define|true|[yY]*)
-       case "$useperlio" in
-       $define|true|[yY]*) ;;
-       *)      cat >&4 <<EOM
+case "$fn" in
+*f*) type='File';;
+*d*) type='Directory';;
+*l*) type='Locate';;
+esac
 
-You are using the SOCKS proxy protocol library which means that you
-should also use the PerlIO layer.  You may be headed for trouble.
+what="$type"
+case "$what" in
+Locate) what='File';;
+esac
 
-EOM
-               ;;
+case "$exp_file" in
+'')
+       case "$d_portable" in
+       "$define") ;;
+       *) exp_file=true;;
        esac
        ;;
 esac
 
-       
-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' ;;
+cd ..
+while test "$type"; do
+       redo=''
+       rp="$orig_rp"
+       dflt="$orig_dflt"
+       case "$tilde" in
+       true) rp="$rp (~name ok)";;
+       esac
+       . UU/myread
+       if test -f UU/getfile.ok && \
+               $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
+       then
+               value="$ans"
+               ansexp="$ans"
+               break
+       fi
+       case "$ans" in
+       none)
+               value=''
+               ansexp=''
+               case "$none_ok" in
+               true) type='';;
                esac
                ;;
-       *)      dflt='n';;
-       esac
-       ;;
-esac
-cat <<EOM
+       *)
+               case "$tilde" in
+               '') value="$ans"
+                       ansexp="$ans";;
+               *)
+                       value=`UU/filexp $ans`
+                       case $? in
+                       0)
+                               if test "$ans" != "$value"; then
+                                       echo "(That expands to $value on this system.)"
+                               fi
+                               ;;
+                       *) value="$ans";;
+                       esac
+                       ansexp="$value"
+                       case "$exp_file" in
+                       '') value="$ans";;
+                       esac
+                       ;;
+               esac
+               case "$fullpath" in
+               true)
+                       case "$ansexp" in
+                       /*) value="$ansexp" ;;
+                       [a-zA-Z]:/*) value="$ansexp" ;;
+                       *)
+                               redo=true
+                               case "$already" in
+                               true)
+                               echo "I shall only accept a full path name, as in /bin/ls." >&4
+                               echo "Use a ! shell escape if you wish to check pathnames." >&4
+                                       ;;
+                               *)
+                               echo "Please give a full path name, starting with slash." >&4
+                                       case "$tilde" in
+                                       true)
+                               echo "Note that using ~name is ok provided it expands well." >&4
+                                               already=true
+                                               ;;
+                                       esac
+                               esac
+                               ;;
+                       esac
+                       ;;
+               esac
+               case "$redo" in
+               '')
+                       case "$type" in
+                       File)
+                               for fp in $gfpth; do
+                                       if test "X$fp" = X.; then
+                                           pf="$ansexp"
+                                       else    
+                                           pf="$fp/$ansexp"
+                                       fi
+                                       if test -f "$pf"; then
+                                               type=''
+                                       elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
+                                       then
+                                               echo "($value is not a plain file, but that's ok.)"
+                                               type=''
+                                       fi
+                                       if test X"$type" = X; then
+                                           value="$pf"
+                                           break
+                                       fi
+                               done
+                               ;;
+                       Directory)
+                               for fp in $gfpth; do
+                                       if test "X$fp" = X.; then
+                                           dir="$ans"
+                                           direxp="$ansexp"
+                                       else    
+                                           dir="$fp/$ansexp"
+                                           direxp="$fp/$ansexp"
+                                       fi
+                                       if test -d "$direxp"; then
+                                               type=''
+                                               value="$dir"
+                                               break
+                                       fi
+                               done
+                               ;;
+                       Locate)
+                               if test -d "$ansexp"; then
+                                       echo "(Looking for $loc_file in directory $value.)"
+                                       value="$value/$loc_file"
+                                       ansexp="$ansexp/$loc_file"
+                               fi
+                               if test -f "$ansexp"; then
+                                       type=''
+                               fi
+                               case "$nopath_ok" in
+                               true)   case "$value" in
+                                       */*) ;;
+                                       *)      echo "Assuming $value will be in people's path."
+                                               type=''
+                                               ;;
+                                       esac
+                                       ;;
+                               esac
+                               ;;
+                       esac
 
-Perl can be built to take advantage of threads on some systems.
-To do so, Configure can be run with -Dusethreads.
+                       case "$skip" in
+                       true) type='';
+                       esac
 
-Note that Perl built with threading support runs slightly slower
-and uses more memory than plain Perl. The current implementation
-is believed to be stable, but it is fairly new, and so should be
-treated with caution.
+                       case "$type" in
+                       '') ;;
+                       *)
+                               if test "$fastread" = yes; then
+                                       dflt=y
+                               else
+                                       dflt=n
+                               fi
+                               rp="$what $value doesn't exist.  Use that name anyway?"
+                               . UU/myread
+                               dflt=''
+                               case "$ans" in
+                               y*) type='';;
+                               *) echo " ";;
+                               esac
+                               ;;
+                       esac
+                       ;;
+               esac
+               ;;
+       esac
+done
+cd UU
+ans="$value"
+rp="$orig_rp"
+dflt="$orig_dflt"
+rm -f getfile.ok
+test "X$gfpthkeep" != Xy && gfpth=""
+EOSC
 
-If this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-rp='Build a threading Perl?'
-. ./myread
-case "$ans" in
-y|Y)    val="$define" ;;
-*)      val="$undef" ;;
+: determine root of directory hierarchy where package will be installed.
+case "$prefix" in
+'')
+       dflt=`./loc . /usr/local /usr/local /local /opt /usr`
+       ;;
+*?/)
+       dflt=`echo "$prefix" | sed 's/.$//'`
+       ;;
+*)
+       dflt="$prefix"
+       ;;
 esac
-set usethreads
-eval $setvar
-
-case "$usethreads" in
-$define)
-       $cat <<EOM
+$cat <<EOM
 
-Since release 5.6, Perl has had two different threading implementations,
-the newer interpreter-based version (ithreads) with one interpreter per
-thread, and the older 5.005 version (5005threads).
-The 5005threads version is effectively unmaintained and will probably be
-removed in Perl 5.10, so there should be no need to build a Perl using it
-unless needed for backwards compatibility with some existing 5.005threads
-code.
+By default, $package will be installed in $dflt/bin, manual pages
+under $dflt/man, etc..., i.e. with $dflt as prefix for all
+installation directories. Typically this is something like /usr/local.
+If you wish to have binaries under /usr/bin but other parts of the
+installation under /usr/local, that's ok: you will be prompted
+separately for each of the installation directories, the prefix being
+only used to set the defaults.
 
 EOM
-       : Default to ithreads unless overridden on command line or with
-       : old config.sh
-       dflt='y'
-       case "$use5005threads" in
-               $define|true|[yY]*) dflt='n';;
-       esac
-       case "$useithreads" in
-               $undef|false|[nN]*) dflt='n';;
-       esac
-       rp='Use the newer interpreter-based ithreads?'
-       . ./myread
+fn=d~
+rp='Installation prefix to use?'
+. ./getfile
+oldprefix=''
+case "$prefix" in
+'') ;;
+*)
        case "$ans" in
-       y|Y)    val="$define" ;;
-       *)      val="$undef" ;;
-       esac
-       set useithreads
-       eval $setvar
-       : Now set use5005threads to the opposite value.
-       case "$useithreads" in
-       $define) val="$undef" ;;
-       *) val="$define" ;;
+       "$prefix") ;;
+       *) oldprefix="$prefix";;
        esac
-       set use5005threads
-       eval $setvar
-       ;;
-*)
-       useithreads="$undef"
-       use5005threads="$undef"
        ;;
 esac
+prefix="$ans"
+prefixexp="$ansexp"
 
-case "$useithreads$use5005threads" in
-"$define$define")
-       $cat >&4 <<EOM
+: allow them to override the AFS root
+case "$afsroot" in
+'')    afsroot=/afs ;;
+*)     afsroot=$afsroot ;;
+esac
 
-You cannot have both the ithreads and the 5.005 threads enabled
-at the same time.  Disabling the 5.005 threads since they are
-much less stable than the ithreads.
-
-EOM
-       use5005threads="$undef"
+: is AFS running?
+echo " "
+case "$afs" in
+$define|true)  afs=true ;;
+$undef|false)  afs=false ;;
+*)     if $test -d $afsroot; then
+               afs=true
+       else
+               afs=false
+       fi
        ;;
 esac
-
-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
+if $afs; then
+       echo "AFS may be running... I'll be extra cautious then..." >&4
+else
+       echo "AFS does not seem to be running..." >&4
 fi
 
-case "$d_oldpthreads" in
-'')    : Configure tests would be welcome here.  For now, assume undef.
-       val="$undef" ;;
-*)     val="$d_oldpthreads" ;;
-esac
-set d_oldpthreads
-eval $setvar
+: determine installation prefix for where package is to be installed.
+if $afs; then 
+$cat <<EOM
 
+Since you are running AFS, I need to distinguish the directory in which
+files will reside from the directory in which they are installed (and from
+which they are presumably copied to the former directory by occult means).
 
-: Look for a hint-file generated 'call-back-unit'.  If the
-: user has specified that a threading perl is to be built,
-: we may need to set or change some other defaults.
-if $test -f usethreads.cbu; then
-    echo "Your platform has some specific hints regarding threaded builds, using them..."
-    . ./usethreads.cbu
+EOM
+       case "$installprefix" in
+       '') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
+       *) dflt="$installprefix";;
+       esac
 else
-    case "$usethreads" in
-       "$define"|true|[yY]*)
-               $cat <<EOM
-(Your platform does not have any specific hints for threaded builds.
- Assuming POSIX threads, then.)
+$cat <<EOM
+
+In some special cases, particularly when building $package for distribution,
+it is convenient to distinguish the directory in which files should be
+installed from the directory ($prefix) in which they will
+eventually reside.  For most users, these two directories are the same.
+
 EOM
-       ;;
-    esac
+       case "$installprefix" in
+       '') dflt=$prefix ;;
+       *) dflt=$installprefix;;
+       esac
+fi
+fn=d~
+rp='What installation prefix should I use for installing files?'
+. ./getfile
+installprefix="$ans"
+installprefixexp="$ansexp"
+
+: Perform the prefixexp/installprefixexp correction if necessary
+cat <<EOS >installprefix
+$startsh
+EOS
+cat <<'EOSC' >>installprefix
+: Change installation prefix, if necessary.
+if $test X"$prefix" != X"$installprefix"; then
+    eval "install${prefixvar}=\`echo \$${prefixvar}exp | sed \"s#^\$prefixexp#\$installprefixexp#\"\`"
+else
+    eval "install${prefixvar}=\"\$${prefixvar}exp\""
 fi
+EOSC
+chmod +x installprefix
+$eunicefix installprefix
+
+: Set variables such as privlib and privlibexp from the output of ./getfile
+: performing the prefixexp/installprefixexp correction if necessary.
+cat <<EOS >setprefixvar
+$startsh
+EOS
+cat <<'EOSC' >>setprefixvar
+eval "${prefixvar}=\"\$ans\""
+eval "${prefixvar}exp=\"\$ansexp\""
+. ./installprefix
+EOSC
+chmod +x setprefixvar
+$eunicefix setprefixvar
+
+: set up the script used to warn in case of inconsistency
+cat <<EOS >whoa
+$startsh
+EOS
+cat <<'EOSC' >>whoa
+dflt=y
+case "$hint" in
+    recommended)
+       case "$hintfile" in
+       '')     echo "The $hint value for \$$var on this machine was \"$was\"!" >&4
+               ;;
+       *)      echo "Hmm.  Based on the hints in hints/$hintfile.sh, " >&4
+               echo "the $hint value for \$$var on this machine was \"$was\"!" >&4
+               ;;
+       esac
+       ;;
+    *) echo " "
+       echo "*** WHOA THERE!!! ***" >&4
+       echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
+       ;;
+esac
+rp="    Keep the $hint value?"
+. ./myread
+case "$ans" in
+y) td=$was; tu=$was;;
+esac
+EOSC
+
+: 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";;
+$undef$define) . ./whoa; eval "$var=\$tu";;
+*) eval "$var=$val";;
+esac'
 
+: Check is we will use socks
+case "$usesocks" in
+$define|true|[yY]*)    dflt='y';;
+*) dflt='n';;
+esac
 cat <<EOM
 
-Perl can be built so that multiple Perl interpreters can coexist
-within the same Perl executable.
+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 "$useithreads" in
-$define)
-       cat <<EOM
-This multiple interpreter support is required for interpreter-based threads.
+case "$usesocks" in
+$define|true|[yY]*) useperlio="$define";;
+esac
+
+: Check if we want perlio
+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"
        ;;
-*)     case "$usemultiplicity" in
-       $define|true|[yY]*)     dflt='y';;
-       *) dflt='n';;
-       esac
-       echo " "
-       echo "If this doesn't make any sense to you, just accept the default '$dflt'."
-       rp='Build Perl for multiplicity?'
-       . ./myread
-       case "$ans" in
-       y|Y)    val="$define" ;;
-       *)      val="$undef" ;;
-       esac
+*)
+       echo "Ok, doing things the stdio way."
+       val="$undef"
        ;;
 esac
-set usemultiplicity
+set useperlio
 eval $setvar
 
+case "$usesocks" in
+$define|true|[yY]*)
+       case "$useperlio" in
+       $define|true|[yY]*) ;;
+       *)      cat >&4 <<EOM
 
-case "$usemorebits" in
-"$define"|true|[yY]*)
-       use64bitint="$define"
-       uselongdouble="$define"
-       usemorebits="$define"
-       ;;
-*)     usemorebits="$undef"
+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
 
-: make some quick guesses about what we are up against
+: get the patchlevel
 echo " "
-$echo $n "Hmm...  $c"
-echo exit 1 >bsd
-echo exit 1 >usg
-echo exit 1 >v7
-echo exit 1 >osf1
-echo exit 1 >eunice
-echo exit 1 >xenix
-echo exit 1 >venix
-echo exit 1 >os2
-d_bsd="$undef"
-$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
-if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
-then
-       echo "Looks kind of like an OSF/1 system, but we'll see..."
-       echo exit 0 >osf1
-elif test `echo abc | $tr a-z A-Z` = Abc ; then
-       xxx=`./loc addbib blurfl $pth`
-       if $test -f $xxx; then
-       echo "Looks kind of like a USG system with BSD features, but we'll see..."
-               echo exit 0 >bsd
-               echo exit 0 >usg
-       else
-               if $contains SIGTSTP foo >/dev/null 2>&1 ; then
-                       echo "Looks kind of like an extended USG system, but we'll see..."
-               else
-                       echo "Looks kind of like a USG system, but we'll see..."
-               fi
-               echo exit 0 >usg
-       fi
-elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
-       echo "Looks kind of like a BSD system, but we'll see..."
-       d_bsd="$define"
-       echo exit 0 >bsd
+echo "Getting the current patchlevel..." >&4
+if $test -r $rsrc/patchlevel.h;then
+       revision=`awk '/define[         ]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
+       patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
+       subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
+       api_revision=`awk '/define[     ]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
+       api_version=`awk '/define[      ]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
+       api_subversion=`awk '/define[   ]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
+       perl_patchlevel=`egrep ',"(MAINT|SMOKE)[0-9][0-9]*"' $rsrc/patchlevel.h|tail -1|sed 's/[^0-9]//g'`
 else
-       echo "Looks kind of like a Version 7 system, but we'll see..."
-       echo exit 0 >v7
+       revision=0
+       patchlevel=0
+       subversion=0
+       api_revision=0
+       api_version=0
+       api_subversion=0
+       perl_patchlevel=0
+       $echo "(You do not have patchlevel.h.  Eek.)"
 fi
-case "$eunicefix" in
-*unixtovms*)
-       $cat <<'EOI'
-There is, however, a strange, musty smell in the air that reminds me of
-something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
-EOI
-       echo exit 0 >eunice
-       d_eunice="$define"
-: it so happens the Eunice I know will not run shell scripts in Unix format
+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" ;;
+esac
+
+$echo "(You have $package $version_patchlevel_string.)"
+
+case "$osname" in
+dos|vms)
+       : XXX Should be a Configure test for double-dots in filenames.
+       version=`echo $revision $patchlevel $subversion | \
+                $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
+       api_versionstring=`echo $api_revision $api_version $api_subversion | \
+                $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
        ;;
 *)
-       echo " "
-       echo "Congratulations.  You aren't running Eunice."
-       d_eunice="$undef"
+       version=`echo $revision $patchlevel $subversion | \
+                $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
+       api_versionstring=`echo $api_revision $api_version $api_subversion | \
+                $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
        ;;
 esac
-: Detect OS2.  The p_ variable is set above in the Head.U unit.
-: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
-: semicolon as a patch separator
-case "$p_" in
-:) ;;
-*)
-       $cat <<'EOI'
-I have the feeling something is not exactly right, however...don't tell me...
-lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
-(Or you may be running DOS with DJGPP.)
-EOI
-       echo exit 0 >os2
-       ;;
+: Special case the 5.005_xx maintenance series, which used 5.005
+: without any subversion label as a subdirectory in $sitelib
+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';;
+       esac
+       ;;
 esac
-if test -f /xenix; then
-       echo "Actually, this looks more like a XENIX system..."
-       echo exit 0 >xenix
-       d_xenix="$define"
+cat <<EOM
+
+Perl can be built to take advantage of threads on some systems.
+To do so, Configure can be run with -Dusethreads.
+
+Note that Perl built with threading support runs slightly slower
+and uses more memory than plain Perl. The current implementation
+is believed to be stable, but it is fairly new, and so should be
+treated with caution.
+
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Build a threading Perl?'
+. ./myread
+case "$ans" in
+y|Y)    val="$define" ;;
+*)      val="$undef" ;;
+esac
+set usethreads
+eval $setvar
+
+if $test $patchlevel -lt 9; then
+    case "$usethreads" in
+    $define)
+       $cat <<EOM
+
+Since release 5.6, Perl has had two different threading implementations,
+the newer interpreter-based version (ithreads) with one interpreter per
+thread, and the older 5.005 version (5005threads).
+The 5005threads version is effectively unmaintained and will probably be
+removed in Perl 5.10, so there should be no need to build a Perl using it
+unless needed for backwards compatibility with some existing 5.005threads
+code.
+
+EOM
+       : Default to ithreads unless overridden on command line or with
+       : old config.sh
+       dflt='y'
+       case "$use5005threads" in
+               $define|true|[yY]*) dflt='n';;
+       esac
+       case "$useithreads" in
+               $undef|false|[nN]*) dflt='n';;
+       esac
+       rp='Use the newer interpreter-based ithreads?'
+       . ./myread
+       case "$ans" in
+       y|Y)    val="$define" ;;
+       *)      val="$undef" ;;
+       esac
+       set useithreads
+       eval $setvar
+       : Now set use5005threads to the opposite value.
+       case "$useithreads" in
+       $define) val="$undef" ;;
+       *) val="$define" ;;
+       esac
+       set use5005threads
+       eval $setvar
+       ;;
+    *)
+       useithreads="$undef"
+       use5005threads="$undef"
+       ;;
+    esac
+
+    case "$useithreads$use5005threads" in
+    "$define$define")
+       $cat >&4 <<EOM
+
+You cannot have both the ithreads and the 5.005 threads enabled
+at the same time.  Disabling the 5.005 threads since they are
+much less stable than the ithreads.
+
+EOM
+       use5005threads="$undef"
+       ;;
+    esac
+
 else
-       echo " "
-       echo "It's not Xenix..."
-       d_xenix="$undef"
+: perl-5.9.x and later
+
+    if test X"$usethreads" = "X$define"; then
+       case "$use5005threads" in
+           $define|true|[yY]*)
+               $cat >&4 <<EOM
+
+5.005 threads has been removed for 5.10.  Perl will be built using ithreads.
+
+EOM
+           ;;
+       esac
+    fi
+
+    use5005threads="$undef"
+    useithreads="$usethreads"
 fi
-chmod +x xenix
-$eunicefix xenix
-if test -f /venix; then
-       echo "Actually, this looks more like a VENIX system..."
-       echo exit 0 >venix
+
+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" ;;
+*)     val="$d_oldpthreads" ;;
+esac
+set d_oldpthreads
+eval $setvar
+
+
+: Look for a hint-file generated 'call-back-unit'.  If the
+: user has specified that a threading perl is to be built,
+: we may need to set or change some other defaults.
+if $test -f usethreads.cbu; then
+    echo "Your platform has some specific hints regarding threaded builds, using them..."
+    . ./usethreads.cbu
 else
-       echo " "
-       if ./xenix; then
-               : null
-       else
-               echo "Nor is it Venix..."
-       fi
+    case "$usethreads" in
+       "$define"|true|[yY]*)
+               $cat <<EOM
+(Your platform does not have any specific hints for threaded builds.
+ Assuming POSIX threads, then.)
+EOM
+       ;;
+    esac
 fi
-chmod +x bsd usg v7 osf1 eunice xenix venix os2
-$eunicefix bsd usg v7 osf1 eunice xenix venix os2
-$rm -f foo
 
+: Check if multiplicity is required
+cat <<EOM
+
+Perl can be built so that multiple Perl interpreters can coexist
+within the same Perl executable.
+EOM
+
+case "$useithreads" in
+$define)
+       cat <<EOM
+This multiple interpreter support is required for interpreter-based threads.
+EOM
+       val="$define"
+       ;;
+*)     case "$usemultiplicity" in
+       $define|true|[yY]*)     dflt='y';;
+       *) dflt='n';;
+       esac
+       echo " "
+       echo "If this doesn't make any sense to you, just accept the default '$dflt'."
+       rp='Build Perl for multiplicity?'
+       . ./myread
+       case "$ans" in
+       y|Y)    val="$define" ;;
+       *)      val="$undef" ;;
+       esac
+       ;;
+esac
+set usemultiplicity
+eval $setvar
+
+: Check if morebits is requested
+case "$usemorebits" in
+"$define"|true|[yY]*)
+       use64bitint="$define"
+       uselongdouble="$define"
+       usemorebits="$define"
+       ;;
+*)     usemorebits="$undef"
+       ;;
+esac
+
+: Determine the C compiler to be used
+echo " "
 case "$cc" in
 '') dflt=cc;;
 *) dflt="$cc";;
@@ -3869,31 +4357,124 @@ rp="Use which C compiler?"
 . ./myread
 cc="$ans"
 
-: See if they have not cc but they do have gcc
+: See whether they have no 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
 
+: make some quick guesses about what we are up against
 echo " "
-echo "Checking for GNU cc in disguise and/or its version number..." >&4
-$cat >try.c <<EOM
-#include <stdio.h>
-int main() {
-#ifdef __GNUC__
-#ifdef __VERSION__
-       printf("%s\n", __VERSION__);
-#else
-       printf("%s\n", "1");
-#endif
-#endif
-       return(0);
-}
-EOM
+$echo $n "Hmm...  $c"
+echo exit 1 >bsd
+echo exit 1 >usg
+echo exit 1 >v7
+echo exit 1 >osf1
+echo exit 1 >eunice
+echo exit 1 >xenix
+echo exit 1 >venix
+echo exit 1 >os2
+d_bsd="$undef"
+$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
+if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
+then
+       echo "Looks kind of like an OSF/1 system, but we'll see..."
+       echo exit 0 >osf1
+elif test `echo abc | $tr a-z A-Z` = Abc ; then
+       xxx=`./loc addbib blurfl $pth`
+       if $test -f $xxx; then
+       echo "Looks kind of like a USG system with BSD features, but we'll see..."
+               echo exit 0 >bsd
+               echo exit 0 >usg
+       else
+               if $contains SIGTSTP foo >/dev/null 2>&1 ; then
+                       echo "Looks kind of like an extended USG system, but we'll see..."
+               else
+                       echo "Looks kind of like a USG system, but we'll see..."
+               fi
+               echo exit 0 >usg
+       fi
+elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
+       echo "Looks kind of like a BSD system, but we'll see..."
+       d_bsd="$define"
+       echo exit 0 >bsd
+else
+       echo "Looks kind of like a Version 7 system, but we'll see..."
+       echo exit 0 >v7
+fi
+case "$eunicefix" in
+*unixtovms*)
+       $cat <<'EOI'
+There is, however, a strange, musty smell in the air that reminds me of
+something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
+EOI
+       echo exit 0 >eunice
+       d_eunice="$define"
+: it so happens the Eunice I know will not run shell scripts in Unix format
+       ;;
+*)
+       echo " "
+       echo "Congratulations.  You aren't running Eunice."
+       d_eunice="$undef"
+       ;;
+esac
+: Detect OS2.  The p_ variable is set above in the Head.U unit.
+: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
+: semicolon as a patch separator
+case "$p_" in
+:) ;;
+*)
+       $cat <<'EOI'
+I have the feeling something is not exactly right, however...don't tell me...
+lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
+(Or you may be running DOS with DJGPP.)
+EOI
+       echo exit 0 >os2
+       ;;
+esac
+if test -f /xenix; then
+       echo "Actually, this looks more like a XENIX system..."
+       echo exit 0 >xenix
+       d_xenix="$define"
+else
+       echo " "
+       echo "It's not Xenix..."
+       d_xenix="$undef"
+fi
+chmod +x xenix
+$eunicefix xenix
+if test -f /venix; then
+       echo "Actually, this looks more like a VENIX system..."
+       echo exit 0 >venix
+else
+       echo " "
+       if ./xenix; then
+               : null
+       else
+               echo "Nor is it Venix..."
+       fi
+fi
+chmod +x bsd usg v7 osf1 eunice xenix venix os2
+$eunicefix bsd usg v7 osf1 eunice xenix venix os2
+$rm -f foo
+
+: 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
+#include <stdio.h>
+int main() {
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#ifdef __VERSION__
+       printf("%s\n", __VERSION__);
+#else
+       printf("%s\n", "1");
+#endif
+#endif
+       return(0);
+}
+EOM
 if $cc -o try $ccflags $ldflags try.c; then
        gccversion=`$run ./try`
        case "$gccversion" in
@@ -3942,313 +4523,31 @@ case "$gccversion" in
     manifestation), I suggest reinstalling the gcc to match
     your operating system release.
 
-EOM
-      ;;
-   *) gccosandvers='' ;; # failed to parse, better be silent
-   esac
-   ;;
-esac
-case "$ccname" in
-'') ccname="$cc" ;;
-esac
-
-# gcc 3.* complain about adding -Idirectories that they already know about,
-# so we will take those off from locincpth.
-case "$gccversion" in
-3*)
-    echo "main(){}">try.c
-    for incdir in $locincpth; do
-       warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
-            grep '^c[cp]p*[01]: warning: changing search order '`
-       if test "X$warn" != X; then
-          locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
-       fi
-    done
-    $rm -f try try.*
-esac
-
-: decide how portable to be.  Allow command line overrides.
-case "$d_portable" in
-"$undef") ;;
-*)     d_portable="$define" ;;
-esac
-
-: set up shell script to do ~ expansion
-cat >filexp <<EOSS
-$startsh
-: expand filename
-case "\$1" in
- ~/*|~)
-       echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
-       ;;
- ~*)
-       if $test -f /bin/csh; then
-               /bin/csh -f -c "glob \$1"
-               failed=\$?
-               echo ""
-               exit \$failed
-       else
-               name=\`$expr x\$1 : '..\([^/]*\)'\`
-               dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
-               if $test ! -d "\$dir"; then
-                       me=\`basename \$0\`
-                       echo "\$me: can't locate home directory for: \$name" >&2
-                       exit 1
-               fi
-               case "\$1" in
-               */*)
-                       echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
-                       ;;
-               *)
-                       echo \$dir
-                       ;;
-               esac
-       fi
-       ;;
-*)
-       echo \$1
-       ;;
-esac
-EOSS
-chmod +x filexp
-$eunicefix filexp
-
-: now set up to get a file name
-cat <<EOS >getfile
-$startsh
-EOS
-cat <<'EOSC' >>getfile
-tilde=''
-fullpath=''
-already=''
-skip=''
-none_ok=''
-exp_file=''
-nopath_ok=''
-orig_rp="$rp"
-orig_dflt="$dflt"
-case "$gfpth" in
-'') gfpth='.' ;;
-esac
-
-case "$fn" in
-*\(*)
-       : getfile will accept an answer from the comma-separated list
-       : enclosed in parentheses even if it does not meet other criteria.
-       expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
-       fn=`echo $fn | sed 's/(.*)//'`
-       ;;
-esac
-
-case "$fn" in
-*:*)
-       loc_file=`expr $fn : '.*:\(.*\)'`
-       fn=`expr $fn : '\(.*\):.*'`
-       ;;
-esac
-
-case "$fn" in
-*~*) tilde=true;;
-esac
-case "$fn" in
-*/*) fullpath=true;;
-esac
-case "$fn" in
-*+*) skip=true;;
-esac
-case "$fn" in
-*n*) none_ok=true;;
-esac
-case "$fn" in
-*e*) exp_file=true;;
-esac
-case "$fn" in
-*p*) nopath_ok=true;;
-esac
-
-case "$fn" in
-*f*) type='File';;
-*d*) type='Directory';;
-*l*) type='Locate';;
-esac
-
-what="$type"
-case "$what" in
-Locate) what='File';;
-esac
-
-case "$exp_file" in
-'')
-       case "$d_portable" in
-       "$define") ;;
-       *) exp_file=true;;
-       esac
-       ;;
-esac
-
-cd ..
-while test "$type"; do
-       redo=''
-       rp="$orig_rp"
-       dflt="$orig_dflt"
-       case "$tilde" in
-       true) rp="$rp (~name ok)";;
-       esac
-       . UU/myread
-       if test -f UU/getfile.ok && \
-               $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
-       then
-               value="$ans"
-               ansexp="$ans"
-               break
-       fi
-       case "$ans" in
-       none)
-               value=''
-               ansexp=''
-               case "$none_ok" in
-               true) type='';;
-               esac
-               ;;
-       *)
-               case "$tilde" in
-               '') value="$ans"
-                       ansexp="$ans";;
-               *)
-                       value=`UU/filexp $ans`
-                       case $? in
-                       0)
-                               if test "$ans" != "$value"; then
-                                       echo "(That expands to $value on this system.)"
-                               fi
-                               ;;
-                       *) value="$ans";;
-                       esac
-                       ansexp="$value"
-                       case "$exp_file" in
-                       '') value="$ans";;
-                       esac
-                       ;;
-               esac
-               case "$fullpath" in
-               true)
-                       case "$ansexp" in
-                       /*) value="$ansexp" ;;
-                       [a-zA-Z]:/*) value="$ansexp" ;;
-                       *)
-                               redo=true
-                               case "$already" in
-                               true)
-                               echo "I shall only accept a full path name, as in /bin/ls." >&4
-                               echo "Use a ! shell escape if you wish to check pathnames." >&4
-                                       ;;
-                               *)
-                               echo "Please give a full path name, starting with slash." >&4
-                                       case "$tilde" in
-                                       true)
-                               echo "Note that using ~name is ok provided it expands well." >&4
-                                               already=true
-                                               ;;
-                                       esac
-                               esac
-                               ;;
-                       esac
-                       ;;
-               esac
-               case "$redo" in
-               '')
-                       case "$type" in
-                       File)
-                               for fp in $gfpth; do
-                                       if test "X$fp" = X.; then
-                                           pf="$ansexp"
-                                       else    
-                                           pf="$fp/$ansexp"
-                                       fi
-                                       if test -f "$pf"; then
-                                               type=''
-                                       elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
-                                       then
-                                               echo "($value is not a plain file, but that's ok.)"
-                                               type=''
-                                       fi
-                                       if test X"$type" = X; then
-                                           value="$pf"
-                                           break
-                                       fi
-                               done
-                               ;;
-                       Directory)
-                               for fp in $gfpth; do
-                                       if test "X$fp" = X.; then
-                                           dir="$ans"
-                                           direxp="$ansexp"
-                                       else    
-                                           dir="$fp/$ansexp"
-                                           direxp="$fp/$ansexp"
-                                       fi
-                                       if test -d "$direxp"; then
-                                               type=''
-                                               value="$dir"
-                                               break
-                                       fi
-                               done
-                               ;;
-                       Locate)
-                               if test -d "$ansexp"; then
-                                       echo "(Looking for $loc_file in directory $value.)"
-                                       value="$value/$loc_file"
-                                       ansexp="$ansexp/$loc_file"
-                               fi
-                               if test -f "$ansexp"; then
-                                       type=''
-                               fi
-                               case "$nopath_ok" in
-                               true)   case "$value" in
-                                       */*) ;;
-                                       *)      echo "Assuming $value will be in people's path."
-                                               type=''
-                                               ;;
-                                       esac
-                                       ;;
-                               esac
-                               ;;
-                       esac
-
-                       case "$skip" in
-                       true) type='';
-                       esac
-
-                       case "$type" in
-                       '') ;;
-                       *)
-                               if test "$fastread" = yes; then
-                                       dflt=y
-                               else
-                                       dflt=n
-                               fi
-                               rp="$what $value doesn't exist.  Use that name anyway?"
-                               . UU/myread
-                               dflt=''
-                               case "$ans" in
-                               y*) type='';;
-                               *) echo " ";;
-                               esac
-                               ;;
-                       esac
-                       ;;
-               esac
-               ;;
-       esac
-done
-cd UU
-ans="$value"
-rp="$orig_rp"
-dflt="$orig_dflt"
-rm -f getfile.ok
-test "X$gfpthkeep" != Xy && gfpth=""
-EOSC
-
+EOM
+      ;;
+   *) gccosandvers='' ;; # failed to parse, better be silent
+   esac
+   ;;
+esac
+case "$ccname" in
+'') ccname="$cc" ;;
+esac
+
+# gcc 3.* complain about adding -Idirectories that they already know about,
+# so we will take those off from locincpth.
+case "$gccversion" in
+3*)
+    echo "main(){}">try.c
+    for incdir in $locincpth; do
+       warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
+            grep '^c[cp]p*[01]: warning: changing search order '`
+       if test "X$warn" != X; then
+          locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
+       fi
+    done
+    $rm -f try try.*
+esac
+
 : What should the include directory be ?
 echo " "
 $echo $n "Hmm...  $c"
@@ -4548,11 +4847,14 @@ lib_ext=$_a
 obj_ext=$_o
 path_sep=$p_
 
+rm_try="$rm -f try try$_exe a.out .out try.[cho] try.$_o core core.try* try.core*"
+
 : Which makefile gets called first.  This is used by make depend.
 case "$firstmakefile" in
 '') firstmakefile='makefile';;
 esac
 
+: Check for uselongdouble support
 case "$ccflags" in
 *-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
 esac
@@ -4629,7 +4931,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
@@ -4671,7 +4973,7 @@ for thislib in $libswanted; do
                   ;;
                esac
                break
-           fi  
+           fi
        done
        if $test ! -f "$xxx"; then
            echo "No -l$thislib."
@@ -4724,19 +5026,75 @@ case "$optimize" in
 'none') optimize=" ";;
 esac
 
+: Check what DEBUGGING is required from the command line
+: -DEBUGGING      or -DDEBUGGING or
+: -DEBUGGING=both                      = -g + -DDEBUGGING
+: -DEBUGGING=-g   or -Doptimize=-g     = -g
+: -DEBUGGING=none or -UDEBUGGING       =
+: -DEBUGGING=old  or -DEBUGGING=default        = ? $optimize
+case "$EBUGGING" in
+'')    ;;
+*)     DEBUGGING=$EBUGGING ;;
+esac
+
+case "$DEBUGGING" in
+-g|both|$define)
+    case "$optimize" in
+       *-g*) ;;
+       *)    optimize="$optimize -g" ;;
+    esac ;;
+none|$undef)
+    case "$optimize" in
+       *-g*)   set `echo "X $optimize " | sed 's/ -g / /'`
+               shift
+               optimize="$*"
+               ;;
+    esac ;;
+esac
+
 dflt=''
+case "$DEBUGGING" in
+both|$define) dflt='-DDEBUGGING'
+esac
+
+: argument order is deliberate, as the flag will start with - which set could
+: think is an option
+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 2>gcctest.out && ./gcctest; then
+    echo "Yes, it does." 2>&1;
+    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
+'
+
 : We will not override a previous value, but we might want to
 : augment a hint file
 case "$hint" in
 default|recommended)
        case "$gccversion" in
-       1*) dflt='-fpcc-struct-return' ;;
+       1*) dflt="$dflt -fpcc-struct-return" ;;
        esac
-       case "$optimize" in
-       *-g*) dflt="$dflt -DDEBUGGING";;
+       case "$optimize:$DEBUGGING" in
+       *-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.
@@ -4747,54 +5105,28 @@ default|recommended)
        case "$gccversion" in
        1*) ;;
        2.[0-8]*) ;;
-       ?*)     echo " "
-               echo "Checking if your compiler accepts -fno-strict-aliasing" 2>&1
-               echo 'int main(void) { return 0; }' > gcctest.c
-               if $cc -O2 -fno-strict-aliasing -o gcctest gcctest.c; then
-                       echo "Yes, it does." 2>&1
-                       case "$ccflags" in
-                       *strict-aliasing*)
-                               echo "Leaving current flags $ccflags alone." 2>&1
-                               ;;
-                       *) dflt="$dflt -fno-strict-aliasing" ;;
-                       esac
-               else
-                       echo "Nope, it doesn't, but that's ok." 2>&1
-               fi
+       ?*)     set strict-aliasing -fno-strict-aliasing
+               eval $checkccflag
                ;;
        esac
        # For gcc, adding -pipe speeds up compilations for some, but apparently
        # some assemblers can't read from stdin.  (It also slows down compilations
        # in other cases, but those are apparently rarer these days.)  AD 5/2004.
        case "$gccversion" in
-       ?*)     echo " "
-               echo "Checking if your compiler accepts -pipe" 2>&1
-               echo 'int main(void) { return 0; }' > gcctest.c
-               if $cc -pipe -o gcctest gcctest.c; then
-                       echo "Yes, it does." 2>&1
-                       case "$ccflags" in
-                       *-pipe*)
-                               echo "Leaving current flags $ccflags alone." 2>&1
-                               ;;
-                       *) dflt="$dflt -pipe" ;;
-                       esac
-               else
-                       echo "Nope, it doesn't, but that's ok." 2>&1
-               fi
+       ?*)     set pipe -pipe
+               eval $checkccflag
+               ;;
+       esac
 
-               echo "Checking if your compiler accepts -Wdeclaration-after-statement" 2>&1
-               echo 'int main(void) { return 0; }' > gcctest.c
-               if $cc -Wdeclaration-after-statement -o gcctest gcctest.c; then
-                       echo "Yes, it does." 2>&1
-                       case "$ccflags" in
-                       *-Wdeclaration-after-statement*)
-                               echo "Leaving current flags $ccflags alone." 2>&1
-                               ;;
-                       *) dflt="$dflt -Wdeclaration-after-statement" ;;
-                       esac
-               else
-                       echo "Nope, it doesn't, but that's ok." 2>&1
-               fi
+       # 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
        ;;
@@ -4935,6 +5267,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
@@ -5001,7 +5342,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 ;;
@@ -5050,12 +5391,17 @@ y)
        ;;
 n) echo "OK, that should do.";;
 esac
-$rm -f try try.* core
+$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='
@@ -5225,7 +5571,7 @@ EOM
        fi
        ;;
 esac
-$rm -f try try.*
+$rm_try
 
 : check for long long
 echo " "
@@ -5239,7 +5585,7 @@ else
        val="$undef"
        echo "You do not have long long."
 fi
-$rm try.*
+$rm_try
 set d_longlong
 eval $setvar
 
@@ -5270,10 +5616,10 @@ EOCP
        fi
        if $test "X$longsize" = "X$longlongsize"; then
                echo "(That isn't any different from an ordinary long.)"
-       fi      
+       fi
        ;;
 esac
-$rm -f try.* try
+$rm_try
 
 : see if inttypes.h is available
 : we want a real compile instead of Inhdr because some systems
@@ -5293,7 +5639,7 @@ else
        echo "<inttypes.h> NOT found." >&4
        val="$undef"
 fi
-$rm -f try.c try
+$rm_try
 set i_inttypes
 eval $setvar
 
@@ -5316,11 +5662,11 @@ else
        val="$undef"
        echo "You do not have int64_t."
 fi
-$rm -f try try.*
+$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
 
@@ -5379,7 +5725,7 @@ case "$quadtype" in
        ;;
 esac
 
-
+: Do we want 64bit support
 case "$uselonglong" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5388,7 +5734,7 @@ case "$uselonglong" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bits" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5397,7 +5743,7 @@ case "$use64bits" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bitints" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5406,7 +5752,7 @@ case "$use64bitints" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bitsint" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5415,7 +5761,7 @@ case "$use64bitsint" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$uselonglongs" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5424,7 +5770,7 @@ case "$uselonglongs" in
 EOM
        use64bitint="$define"
        ;;
-esac                          
+esac
 case "$use64bitsall" in
 "$define"|true|[yY]*)
        cat <<EOM >&4
@@ -5433,7 +5779,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";;
@@ -5484,7 +5830,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
@@ -5597,7 +5943,7 @@ EOCP
        fi
        ;;
 esac
-$rm -f try.c try
+$rm_try
 
 : check for long doubles
 echo " "
@@ -5611,7 +5957,7 @@ else
        val="$undef"
        echo "You do not have long double."
 fi
-$rm try.*
+$rm_try
 set d_longdbl
 eval $setvar
 
@@ -5644,10 +5990,10 @@ EOCP
                echo "That isn't any different from an ordinary double."
                echo "I'll keep your setting anyway, but you may see some"
                echo "harmless compilation warnings."
-       fi      
+       fi
        ;;
 esac
-$rm -f try.* try
+$rm_try
 
 : determine the architecture name
 echo " "
@@ -5769,101 +6115,6 @@ if $test -f archname.cbu; then
        . ./archname.cbu
 fi
 
-: determine root of directory hierarchy where package will be installed.
-case "$prefix" in
-'')
-       dflt=`./loc . /usr/local /usr/local /local /opt /usr`
-       ;;
-*?/)
-       dflt=`echo "$prefix" | sed 's/.$//'`
-       ;;
-*)
-       dflt="$prefix"
-       ;;
-esac
-$cat <<EOM
-
-By default, $package will be installed in $dflt/bin, manual pages
-under $dflt/man, etc..., i.e. with $dflt as prefix for all
-installation directories. Typically this is something like /usr/local.
-If you wish to have binaries under /usr/bin but other parts of the
-installation under /usr/local, that's ok: you will be prompted
-separately for each of the installation directories, the prefix being
-only used to set the defaults.
-
-EOM
-fn=d~
-rp='Installation prefix to use?'
-. ./getfile
-oldprefix=''
-case "$prefix" in
-'') ;;
-*)
-       case "$ans" in
-       "$prefix") ;;
-       *) oldprefix="$prefix";;
-       esac
-       ;;
-esac
-prefix="$ans"
-prefixexp="$ansexp"
-
-case "$afsroot" in
-'')    afsroot=/afs ;;
-*)     afsroot=$afsroot ;;
-esac
-
-: is AFS running?
-echo " "
-case "$afs" in
-$define|true)  afs=true ;;
-$undef|false)  afs=false ;;
-*)     if test -d $afsroot; then
-               afs=true
-       else
-               afs=false
-       fi
-       ;;
-esac
-if $afs; then
-       echo "AFS may be running... I'll be extra cautious then..." >&4
-else
-       echo "AFS does not seem to be running..." >&4
-fi
-
-: determine installation prefix for where package is to be installed.
-if $afs; then 
-$cat <<EOM
-
-Since you are running AFS, I need to distinguish the directory in which
-files will reside from the directory in which they are installed (and from
-which they are presumably copied to the former directory by occult means).
-
-EOM
-       case "$installprefix" in
-       '') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
-       *) dflt="$installprefix";;
-       esac
-else
-$cat <<EOM
-
-In some special cases, particularly when building $package for distribution,
-it is convenient to distinguish the directory in which files should be
-installed from the directory ($prefix) in which they will
-eventually reside.  For most users, these two directories are the same.
-
-EOM
-       case "$installprefix" in
-       '') dflt=$prefix ;;
-       *) dflt=$installprefix;;
-       esac
-fi
-fn=d~
-rp='What installation prefix should I use for installing files?'
-. ./getfile
-installprefix="$ans"
-installprefixexp="$ansexp"
-
 : set the prefixit variable, to compute a suitable default value
 prefixit='case "$3" in
 ""|none)
@@ -5890,81 +6141,75 @@ prefixit='case "$3" in
        esac;;
 esac'
 
-: get the patchlevel
+: determine installation style
+: For now, try to deduce it from prefix unless it is already set.
+: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
+case "$installstyle" in
+'')    case "$prefix" in
+               *perl*) dflt='lib';;
+               *) dflt='lib/perl5' ;;
+       esac
+       ;;
+*)     dflt="$installstyle" ;;
+esac
+: Probably not worth prompting for this since we prompt for all
+: the directories individually, and the prompt would be too long and
+: confusing anyway.
+installstyle=$dflt
+
+: determine where public executables go
 echo " "
-echo "Getting the current patchlevel..." >&4
-if $test -r $rsrc/patchlevel.h;then
-       revision=`awk '/define[         ]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
-       patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
-       subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
-       api_revision=`awk '/define[     ]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
-       api_version=`awk '/define[      ]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
-       api_subversion=`awk '/define[   ]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
-       perl_patchlevel=`egrep 'define PERL_PATCHNUM [0-9][0-9]|,"MAINT[0-9][0-9]*"' $rsrc/patchlevel.h|sed 's/[^0-9]//g'`
-else
-       revision=0
-       patchlevel=0
-       subversion=0
-       api_revision=0
-       api_version=0
-       api_subversion=0
-       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
+set dflt bin bin
+eval $prefixit
+fn=d~
+rp='Pathname where the public executables will reside?'
+. ./getfile
+if $test "X$ansexp" != "X$binexp"; then
+       installbin=''
 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" ;;
+prefixvar=bin
+: XXX Bug? -- ignores Configure -Dinstallprefix setting.
+: XXX If this is fixed, also fix the "start perl" hunk below, which relies on
+:     this via initialinstalllocation
+. ./setprefixvar
+
+case "$userelocatableinc" in
+$define|true|[yY]*)    dflt='y' ;;
+*)                     dflt='n' ;;
 esac
+cat <<EOM
 
-$echo "(You have $package $version_patchlevel_string.)"
+Would you like to build Perl so that the installation is relocatable, so that
+library paths in @INC are determined relative to the path of the perl binary?
+This is not advised for system Perl installs, or if you need to run setid
+scripts or scripts under taint mode.
 
-case "$osname" in
-dos|vms)
-       : XXX Should be a Configure test for double-dots in filenames.
-       version=`echo $revision $patchlevel $subversion | \
-                $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
-       api_versionstring=`echo $api_revision $api_version $api_subversion | \
-                $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
-       ;;
-*)
-       version=`echo $revision $patchlevel $subversion | \
-                $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
-       api_versionstring=`echo $api_revision $api_version $api_subversion | \
-                $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
-       ;;
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Use relocatable @INC?'
+. ./myread
+case "$ans" in
+y|Y)   val="$define" ;;
+*)     val="$undef"  ;;
 esac
-: Special case the 5.005_xx maintenance series, which used 5.005
-: without any subversion label as a subdirectory in $sitelib
-if test "${api_revision}${api_version}${api_subversion}" = "550"; then
-       api_versionstring='5.005'
-fi
+set userelocatableinc
+eval $setvar
 
-: determine installation style
-: For now, try to deduce it from prefix unless it is already set.
-: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
-case "$installstyle" in
-'')    case "$prefix" in
-               *perl*) dflt='lib';;
-               *) dflt='lib/perl5' ;;
-       esac
-       ;;
-*)     dflt="$installstyle" ;;
+initialinstalllocation="$binexp"
+: Default prefix is now "up one level from where the binaries are"
+case "$userelocatableinc" in
+$define|true|[yY]*)
+    bin=".../"
+    binexp=".../"
+    prefix=".../.."
+    prefixexp=".../.."
+    installprefixexp=".../.."
+    ;;
 esac
-: Probably not worth prompting for this since we prompt for all
-: the directories individually, and the prompt would be too long and
-: confusing anyway.
-installstyle=$dflt
 
 : determine where private library files go
 : Usual default is /usr/local/lib/perl5/$version.
-: Also allow things like /opt/perl/lib/$version, since 
+: Also allow things like /opt/perl/lib/$version, since
 : /opt/perl/lib/perl5... would be redundant.
 : The default "style" setting is made in installstyle.U
 case "$installstyle" in
@@ -5978,17 +6223,12 @@ There are some auxiliary files for $package that need to be put into a
 private library directory that is accessible by everyone.
 
 EOM
+fn=$binexp
 fn=d~+
 rp='Pathname where the private library files will reside?'
 . ./getfile
-privlib="$ans"
-privlibexp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installprivlib=`echo $privlibexp | sed "s#^$prefix#$installprefix#"`
-else
-       installprivlib="$privlibexp"
-fi
+prefixvar=privlib
+. ./setprefixvar
 
 : set the prefixup variable, to restore leading tilda escape
 prefixup='case "$prefixexp" in
@@ -6018,22 +6258,17 @@ these files in a separate location.  Otherwise, you can just include
 them with the rest of the public library files.
 
 EOM
+fn=$binexp
 fn=d+~
 rp='Where do you want to put the public architecture-dependent libraries?'
 . ./getfile
-archlib="$ans"
-archlibexp="$ansexp"
+prefixvar=archlib
+. ./setprefixvar
 if $test X"$archlib" = X"$privlib"; then
        d_archlib="$undef"
 else
        d_archlib="$define"
 fi
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installarchlib=`echo $archlibexp | sed "s#^$prefix#$installprefix#"`
-else
-       installarchlib="$archlibexp"
-fi
 
 : see if setuid scripts can be secure
 $cat <<EOM
@@ -6145,6 +6380,201 @@ esac
 set d_dosuid
 eval $setvar
 
+: Find perl5.005 or later.
+echo "Looking for a previously installed perl5.005 or later... "
+case "$perl5" in
+'')    for tdir in `echo "$binexp$path_sep$PATH" | $sed "s/$path_sep/ /g"`; do
+               : Check if this perl is recent and can load a simple module
+               if $test -x $tdir/perl$exe_ext && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
+                       perl5=$tdir/perl
+                       break;
+               elif $test -x $tdir/perl5$exe_ext && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
+                       perl5=$tdir/perl5
+                       break;
+               fi
+       done
+       ;;
+*)     perl5="$perl5"
+       ;;
+esac
+case "$perl5" in
+'')    echo "None found.  That's ok.";;
+*)     echo "Using $perl5." ;;
+esac
+
+: Set the siteprefix variables
+$cat <<EOM
+
+After $package is installed, you may wish to install various
+add-on modules and utilities.  Typically, these add-ons will
+be installed under $prefix with the rest
+of this package.  However, you may wish to install such add-ons
+elsewhere under a different prefix.
+
+If you do not wish to put everything under a single prefix, that's
+ok.  You will be prompted for the individual locations; this siteprefix
+is only used to suggest the defaults.
+
+The default should be fine for most people.
+
+EOM
+fn=d~+
+rp='Installation prefix to use for add-on modules and utilities?'
+: XXX Here might be another good place for an installstyle setting.
+case "$siteprefix" in
+'') dflt=$prefix ;;
+*)  dflt=$siteprefix ;;
+esac
+. ./getfile
+: XXX Prefixit unit does not yet support siteprefix and vendorprefix
+oldsiteprefix=''
+case "$siteprefix" in
+'') ;;
+*)     case "$ans" in
+       "$prefix") ;;
+       *) oldsiteprefix="$prefix";;
+       esac
+       ;;
+esac
+siteprefix="$ans"
+siteprefixexp="$ansexp"
+
+: determine where site specific libraries go.
+: Usual default is /usr/local/lib/perl5/site_perl/$version
+: The default "style" setting is made in installstyle.U
+: XXX No longer works with Prefixit stuff.
+prog=`echo $package | $sed 's/-*[0-9.]*$//'`
+case "$sitelib" in
+'') case "$installstyle" in
+       *lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
+       *)       dflt=$siteprefix/lib/site_$prog/$version ;;
+       esac
+       ;;
+*)     dflt="$sitelib"
+       ;;
+esac
+$cat <<EOM
+
+The installation process will create a directory for
+site-specific extensions and modules.  Most users find it convenient
+to place all site-specific files in this directory rather than in the
+main distribution directory.
+
+EOM
+fn=d~+
+rp='Pathname for the site-specific library files?'
+. ./getfile
+prefixvar=sitelib
+. ./setprefixvar
+sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
+
+: Determine list of previous versions to include in @INC
+$cat > getverlist <<EOPL
+#!$perl5 -w
+use File::Basename;
+\$api_versionstring = "$api_versionstring";
+\$version = "$version";
+\$stem = "$sitelib_stem";
+\$archname = "$archname";
+EOPL
+       $cat >> getverlist <<'EOPL'
+# The list found is store twice for each entry: the original name, and
+# the binary broken down version as pack "sss", so sorting is easy and
+# unambiguous. This will work for all versions that have a maximum of
+# three digit groups, separate by '.'s or '_'s. Names are extended with
+# ".0.0" to ensure at least three elements for the pack.
+#                                      -- H.Merijn Brand (m)'06 23-10-2006
+
+# Can't have leading @ because metaconfig interprets it as a command!
+;@inc_version_list=();
+# XXX Redo to do opendir/readdir?
+if (-d $stem) {
+    chdir($stem);
+    ;@candidates = map {
+       [ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*");
+}
+else {
+    ;@candidates = ();
+}
+
+($pversion, $aversion, $vsn5005) = map {
+    pack "sss", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005";
+foreach $d (@candidates) {
+    if ($d->[1] lt $pversion) {
+       if ($d->[1] ge $aversion) {
+           unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);
+       }
+       elsif ($d->[1] ge $vsn5005) {
+           unshift(@inc_version_list, grep { -d } $d->[0]);
+       }
+    }
+    else {
+       # Skip newer version.  I.e. don't look in
+       # 5.7.0 if we're installing 5.6.1.
+    }
+}
+
+if (@inc_version_list) {
+    print join(' ', @inc_version_list);
+}
+else {
+    # Blank space to preserve value for next Configure run.
+    print " ";
+}
+EOPL
+chmod +x getverlist
+case "$inc_version_list" in
+'')    if test -x "$perl5$exe_ext"; then
+               dflt=`$perl5 getverlist`
+       else
+               dflt='none'
+       fi
+       ;;
+$undef) dflt='none' ;;
+*)  eval dflt=\"$inc_version_list\" ;;
+esac
+case "$dflt" in
+''|' ') dflt=none ;;
+esac
+case "$dflt" in
+5.005) dflt=none ;;
+esac
+$cat <<EOM
+
+In order to ease the process of upgrading, this version of perl
+can be configured to use modules built and installed with earlier
+versions of perl that were installed under $prefix.  Specify here
+the list of earlier versions that this version of perl should check.
+If Configure detected no earlier versions of perl installed under
+$prefix, then the list will be empty.  Answer 'none' to tell perl
+to not search earlier versions.
+
+The default should almost always be sensible, so if you're not sure,
+just accept the default.
+EOM
+
+rp='List of earlier versions to include in @INC?'
+. ./myread
+case "$ans" in
+[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
+*) inc_version_list="$ans" ;;
+esac
+case "$inc_version_list" in
+''|' ')
+       inc_version_list_init='0'
+       d_inc_version_list="$undef"
+       ;;
+*)     inc_version_list_init=`echo $inc_version_list |
+               $sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
+       d_inc_version_list="$define"
+       ;;
+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
@@ -6152,6 +6582,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
@@ -6162,7 +6597,7 @@ else
     echo "<malloc.h> NOT found." >&4
     val="$undef"
 fi
-$rm -f try.c try
+$rm_try
 set i_malloc
 eval $setvar
 
@@ -6260,7 +6695,7 @@ EOM
        voidflags="$ans"
        ;;
 esac
-$rm -f try.* .out
+$rm_try
 
 : check for length of pointer
 echo " "
@@ -6297,7 +6732,7 @@ EOCP
        fi
        ;;
 esac
-$rm -f try.c try
+$rm_try
 case "$use64bitall" in
 "$define"|true|[yY]*)
        case "$ptrsize" in
@@ -6398,107 +6833,36 @@ $cat >malloc.c <<END
 #endif
 #ifdef I_STDLIB
 #include <stdlib.h>
-#endif
-#ifdef TRY_MALLOC
-void *malloc();
-#endif
-#ifdef TRY_FREE
-void free();
-#endif
-END
-case "$malloctype" in
-'')
-       if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
-               malloctype='void *'
-       else
-               malloctype='char *'
-       fi
-       ;;
-esac
-echo "Your system wants malloc to return '$malloctype', it would seem." >&4
-
-case "$freetype" in
-'')
-       if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
-               freetype='void'
-       else
-               freetype='int'
-       fi
-       ;;
-esac
-echo "Your system uses $freetype free(), it would seem." >&4
-$rm -f malloc.[co]
-$cat <<EOM
-
-After $package is installed, you may wish to install various
-add-on modules and utilities.  Typically, these add-ons will
-be installed under $prefix with the rest
-of this package.  However, you may wish to install such add-ons
-elsewhere under a different prefix.
-
-If you do not wish to put everything under a single prefix, that's
-ok.  You will be prompted for the individual locations; this siteprefix
-is only used to suggest the defaults.
-
-The default should be fine for most people.
-
-EOM
-fn=d~+
-rp='Installation prefix to use for add-on modules and utilities?'
-: XXX Here might be another good place for an installstyle setting.
-case "$siteprefix" in
-'') dflt=$prefix ;;
-*)  dflt=$siteprefix ;;
-esac
-. ./getfile
-: XXX Prefixit unit does not yet support siteprefix and vendorprefix
-oldsiteprefix=''
-case "$siteprefix" in
-'') ;;
-*)     case "$ans" in
-       "$prefix") ;;
-       *) oldsiteprefix="$prefix";;
-       esac
+#endif
+#ifdef TRY_MALLOC
+void *malloc();
+#endif
+#ifdef TRY_FREE
+void free();
+#endif
+END
+case "$malloctype" in
+'')
+       if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
+               malloctype='void *'
+       else
+               malloctype='char *'
+       fi
        ;;
 esac
-siteprefix="$ans"
-siteprefixexp="$ansexp"
+echo "Your system wants malloc to return '$malloctype', it would seem." >&4
 
-: determine where site specific libraries go.
-: Usual default is /usr/local/lib/perl5/site_perl/$version
-: The default "style" setting is made in installstyle.U
-: XXX No longer works with Prefixit stuff.
-prog=`echo $package | $sed 's/-*[0-9.]*$//'`
-case "$sitelib" in
-'') case "$installstyle" in
-       *lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
-       *)       dflt=$siteprefix/lib/site_$prog/$version ;;
-       esac
-       ;;
-*)     dflt="$sitelib"
+case "$freetype" in
+'')
+       if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
+               freetype='void'
+       else
+               freetype='int'
+       fi
        ;;
 esac
-$cat <<EOM
-
-The installation process will create a directory for
-site-specific extensions and modules.  Most users find it convenient
-to place all site-specific files in this directory rather than in the
-main distribution directory.
-
-EOM
-fn=d~+
-rp='Pathname for the site-specific library files?'
-. ./getfile
-sitelib="$ans"
-sitelibexp="$ansexp"
-sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsitelib=`echo $sitelibexp | $sed "s#^$prefix#$installprefix#"`
-else
-       installsitelib="$sitelibexp"
-fi
-
+echo "Your system uses $freetype free(), it would seem." >&4
+$rm -f malloc.[co]
 : determine where site specific architecture-dependent libraries go.
 : sitelib  default is /usr/local/lib/perl5/site_perl/$version
 : sitearch default is /usr/local/lib/perl5/site_perl/$version/$archname
@@ -6521,15 +6885,15 @@ EOM
 fn=d~+
 rp='Pathname for the site-specific architecture-dependent library files?'
 . ./getfile
-sitearch="$ans"
-sitearchexp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsitearch=`echo $sitearchexp | sed "s#^$prefix#$installprefix#"`
+prefixvar=sitearch
+. ./setprefixvar
+if $test X"$sitearch" = X"$sitelib"; then
+       d_sitearch="$undef"
 else
-       installsitearch="$sitearchexp"
+       d_sitearch="$define"
 fi
 
+: Set the vendorprefix variables
 $cat <<EOM
 
 The installation process will also create a directory for
@@ -6586,6 +6950,7 @@ case "$ans" in
        ;;
 esac
 
+: Set the vendorlib variables
 case "$vendorprefix" in
 '')    d_vendorlib="$undef"
        vendorlib=''
@@ -6613,13 +6978,10 @@ case "$vendorprefix" in
        ;;
 esac
 vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorlib=`echo $vendorlibexp | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorlib="$vendorlibexp"
-fi
+prefixvar=vendorlib
+. ./installprefix
 
+: Set the vendorarch variables
 case "$vendorprefix" in
 '')    d_vendorarch="$undef"
        vendorarch=''
@@ -6643,12 +7005,8 @@ case "$vendorprefix" in
        vendorarchexp="$ansexp"
        ;;
 esac
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorarch=`echo $vendorarchexp | sed "s#^$prefix#$installprefix#"`
-else
-       installvendorarch="$vendorarchexp"
-fi
+prefixvar=vendorarch
+. ./installprefix
 
 : Final catch-all directories to search
 $cat <<EOM
@@ -6707,6 +7065,7 @@ set prototype
 eval $setvar
 $rm -f prototype*
 
+: Check if ansi2knr is required
 case "$prototype" in
 "$define") ;;
 *)     ansi2knr='ansi2knr'
@@ -6730,26 +7089,89 @@ EOM
        ;;
 esac
 
-: determine where public executables go
-echo " "
-set dflt bin bin
-eval $prefixit
-fn=d~
-rp='Pathname where the public executables will reside?'
-. ./getfile
-if $test "X$ansexp" != "X$binexp"; then
-       installbin=''
-fi
-bin="$ans"
-binexp="$ansexp"
-: Change installation prefix, if necessary.
-: XXX Bug? -- ignores Configure -Dinstallprefix setting.
-if $test X"$prefix" != X"$installprefix"; then
-       installbin=`echo $binexp | sed "s#^$prefix#$installprefix#"`
-else
-       installbin="$binexp"
-fi
+: DTrace support
+dflt_dtrace='/usr/sbin/dtrace'
+cat <<EOM
+
+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
+
+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';;
@@ -6807,7 +7229,7 @@ set html1dir html1dir none
 eval $prefixit
 $cat <<EOM
 
-If you wish to install html files for programs in $spackage, indicate 
+If you wish to install html files for programs in $spackage, indicate
 the appropriate directory here.  To skip installing html files,
 answer "none".
 EOM
@@ -6818,16 +7240,10 @@ esac
 fn=dn+~
 rp="Directory for the main $spackage html pages?"
 . ./getfile
-html1dir="$ans"
-html1direxp="$ansexp"
+prefixvar=html1dir
+. ./setprefixvar
 : Use ' ' for none so value is preserved next time through Configure
 $test X"$html1dir" = "X" && html1dir=' '
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installhtml1dir=`echo $html1direxp | sed "s#^$prefix#$installprefix#"`
-else
-       installhtml1dir="$html1direxp"
-fi
 
 : determine where html pages for libraries and modules go
 set html3dir html3dir none
@@ -6847,134 +7263,10 @@ esac
 fn=dn+~
 rp="Directory for the $spackage module html pages?"
 . ./getfile
-html3dir="$ans"
-html3direxp="$ansexp"
+prefixvar=html3dir
+. ./setprefixvar
 : Use ' ' for none so value is preserved next time through Configure
 $test X"$html3dir" = "X" && html3dir=' '
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installhtml3dir=`echo $html3direxp | sed "s#^$prefix#$installprefix#"`
-else
-       installhtml3dir="$html3direxp"
-fi
-
-: Find perl5.005 or later.
-echo "Looking for a previously installed perl5.005 or later... "
-case "$perl5" in
-'')    for tdir in `echo "$binexp$path_sep$PATH" | $sed "s/$path_sep/ /g"`; do
-               : Check if this perl is recent and can load a simple module
-               if $test -x $tdir/perl$exe_ext && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
-                       perl5=$tdir/perl
-                       break;
-               elif $test -x $tdir/perl5$exe_ext && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
-                       perl5=$tdir/perl5
-                       break;
-               fi
-       done
-       ;;
-*)     perl5="$perl5"
-       ;;
-esac
-case "$perl5" in
-'')    echo "None found.  That's ok.";;
-*)     echo "Using $perl5." ;;
-esac
-
-: Determine list of previous versions to include in @INC
-$cat > getverlist <<EOPL
-#!$perl5 -w
-use File::Basename;
-\$api_versionstring = "$api_versionstring";
-\$version = "$version";
-\$stem = "$sitelib_stem";
-\$archname = "$archname";
-EOPL
-       $cat >> getverlist <<'EOPL'
-# Can't have leading @ because metaconfig interprets it as a command!
-;@inc_version_list=();
-# XXX Redo to do opendir/readdir? 
-if (-d $stem) {
-    chdir($stem);
-    ;@candidates = glob("5.*");
-}
-else {
-    ;@candidates = ();
-}
-
-# XXX ToDo:  These comparisons must be reworked when two-digit
-# subversions come along, so that 5.7.10 compares as greater than
-# 5.7.3!  By that time, hope that 5.6.x is sufficiently
-# widespread that we can use the built-in version vectors rather
-# than reinventing them here.  For 5.6.0, however, we must
-# assume this script will likely be run by 5.005_0x.  --AD 1/2000.
-foreach $d (@candidates) {
-    if ($d lt $version) {
-       if ($d ge $api_versionstring) {
-           unshift(@inc_version_list, grep { -d } "$d/$archname", $d);
-       }
-       elsif ($d ge "5.005") {
-           unshift(@inc_version_list, grep { -d } $d);
-       }
-    }
-    else {
-       # Skip newer version.  I.e. don't look in
-       # 5.7.0 if we're installing 5.6.1.
-    }
-}
-
-if (@inc_version_list) {
-    print join(' ', @inc_version_list);
-}
-else {
-    # Blank space to preserve value for next Configure run.
-    print " ";
-}
-EOPL
-chmod +x getverlist
-case "$inc_version_list" in
-'')    if test -x "$perl5$exe_ext"; then
-               dflt=`$perl5 getverlist`
-       else
-               dflt='none'
-       fi
-       ;;
-$undef) dflt='none' ;;
-*)  eval dflt=\"$inc_version_list\" ;;
-esac
-case "$dflt" in
-''|' ') dflt=none ;;
-esac
-case "$dflt" in
-5.005) dflt=none ;;
-esac
-$cat <<EOM
-
-In order to ease the process of upgrading, this version of perl 
-can be configured to use modules built and installed with earlier 
-versions of perl that were installed under $prefix.  Specify here
-the list of earlier versions that this version of perl should check.
-If Configure detected no earlier versions of perl installed under
-$prefix, then the list will be empty.  Answer 'none' to tell perl
-to not search earlier versions.
-
-The default should almost always be sensible, so if you're not sure,
-just accept the default.
-EOM
-
-rp='List of earlier versions to include in @INC?'
-. ./myread
-case "$ans" in
-[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
-*) inc_version_list="$ans" ;;
-esac
-case "$inc_version_list" in
-''|' ') 
-       inc_version_list_init='0';;
-*)     inc_version_list_init=`echo $inc_version_list |
-               $sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
-       ;;
-esac
-$rm -f getverlist
 
 : determine whether to install perl also as /usr/bin/perl
 
@@ -7021,6 +7313,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'
@@ -7034,7 +7327,7 @@ int main(void)
 {
 #ifdef __GLIBC__
 #   ifdef __GLIBC_MINOR__
-#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
+#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
 #           include <gnu/libc-version.h>
            printf("%s\n",  gnu_get_libc_version());
 #       else
@@ -7059,7 +7352,7 @@ else
        gnulibc_version=''
        echo "You are not using the GNU C Library"
 fi
-$rm -f try try.* glibc.ver
+$rm_try glibc.ver
 set d_gnulibc
 eval $setvar
 
@@ -7154,6 +7447,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
@@ -7383,31 +7677,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 | \
@@ -7432,7 +7726,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
@@ -7444,6 +7739,32 @@ $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'
+#include <stdio.h>
+int main(void)
+{
+#ifdef __cplusplus
+    return 0;
+#else
+    return 1;
+#endif
+}
+EOCP
+set try
+if eval $compile_ok && $run ./try; then
+       val="$define"
+       echo "You are using a C++ compiler."
+else
+       val="$undef"
+       echo "You are not using a C++ compiler."
+fi
+$rm_try cplusplus$$
+set d_cplusplus
+eval $setvar
+
 : is a C symbol defined?
 csym='tlook=$1;
 case "$3" in
@@ -7459,19 +7780,22 @@ 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 "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
+                       echo "extern $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 -f try$_exe try.c core core.* try.core;
+                       $rm_try;
                fi;
        else
-               echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
+               echo "extern $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 -f try$_exe try.c;
+               $rm_try;
        fi;
        ;;
 *)
@@ -7512,10 +7836,24 @@ esac'
 
 : see if dlopen exists
 xxx_runnm="$runnm"
+xxx_ccflags="$ccflags"
 runnm=false
+: with g++ one needs -shared to get is-in-libc to work for dlopen
+case "$gccversion" in
+'')    ;;
+*)     case "$d_cplusplus" in
+       "$define") ccflags="$ccflags -shared" ;;
+       esac
+       ;;
+esac
 set dlopen d_dlopen
 eval $inlibc
 runnm="$xxx_runnm"
+ccflags="$xxx_ccflags"
+
+: see if this is a unistd.h system
+set unistd.h i_unistd
+eval $inhdr
 
 : determine which dynamic loading, if any, to compile in
 echo " "
@@ -7529,7 +7867,7 @@ $undef|n|false)
        dflt='n'
        usedl="$undef"
        ;;
-*) 
+*)
        dflt='n'
        case "$d_dlopen" in
            $define) dflt='y' ;;
@@ -7592,7 +7930,7 @@ EOM
                        ;;
                *)  case "$osname" in
                        darwin) dflt='none' ;;
-                       svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
+                       linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
                        *)      dflt='-fpic' ;;
                    esac ;;
            esac ;;
@@ -7620,10 +7958,14 @@ EOM
 #ifdef I_STDLIB
 #include <stdlib.h>
 #endif
+#$i_unistd I_UNISTD
+#ifdef I_UNISTD
+#include <unistd.h>
+#endif
 int main() {
        char b[4];
        int i = open("a.out",O_RDONLY);
-       if(i == -1) 
+       if(i == -1)
                exit(1); /* fail */
        if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
                exit(0); /* succeed (yes, it's ELF) */
@@ -7640,7 +7982,7 @@ EOM
                        echo "I'll use ld to build dynamic libraries."
                        dflt='ld'
                fi
-               rm -f try.c a.out
+               $rm_try
                ;;
        *)      dflt="$ld"
                ;;
@@ -7666,8 +8008,8 @@ EOM
                              case "$gccversion" in
                              '') dflt="$dflt +vnocompatwarnings" ;;
                              esac
-                             ;;        
-                       linux|irix*|gnu*)       dflt='-shared' ;;
+                             ;;
+                       linux|irix*|gnu*)  dflt="-shared $optimize" ;;
                        next)  dflt='none' ;;
                        solaris) dflt='-G' ;;
                        sunos) dflt='-assert nodefinitions' ;;
@@ -7698,6 +8040,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
@@ -7736,6 +8088,7 @@ EOM
     ;;
 esac
 
+: Do we want a shared libperl?
 also=''
 case "$usedl" in
 $undef)
@@ -7888,7 +8241,7 @@ shrpdir=$archlibexp/CORE
 xxx=''
 tmp_shrpenv=''
 if "$useshrplib"; then
-    case "$osname" in 
+    case "$osname" in
        aix)
                # We'll set it in Makefile.SH...
                ;;
@@ -7917,7 +8270,7 @@ if "$useshrplib"; then
        esac
        case "$xxx" in
        '') ;;
-       *)      
+       *)
                # Only add $xxx if it isn't already in ccdlflags.
                case " $ccdlflags " in
                *" $xxx "*)     ;;
@@ -7925,7 +8278,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
@@ -8009,20 +8362,14 @@ rp="Where do the main $spackage manual pages (source) go?"
 if $test "X$man1direxp" != "X$ansexp"; then
        installman1dir=''
 fi
-man1dir="$ans"
-man1direxp="$ansexp"
+prefixvar=man1dir
+. ./setprefixvar
+
 case "$man1dir" in
 '')    man1dir=' '
        installman1dir='';;
 esac
 
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installman1dir=`echo $man1direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installman1dir="$man1direxp"
-fi
-
 : What suffix to use on installed man pages
 
 case "$man1dir" in
@@ -8071,7 +8418,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*
@@ -8097,7 +8444,7 @@ esac
 case "$d_flexfnam" in
 undef)
        $cat <<'EOM'
-However, your system can't handle the long file names like File::Basename.3. 
+However, your system can't handle the long file names like File::Basename.3.
 EOM
        case "$man3dir" in
        '') man3dir="none";;
@@ -8112,8 +8459,8 @@ case "$man3dir" in
                cat <<EOM >&4
 
 WARNING:  Previous versions of perl installed man3 pages into
-$privlib/man/man3.  This version will suggest a 
-new default of $dflt.  
+$privlib/man/man3.  This version will suggest a
+new default of $dflt.
 EOM
                tdflt=$dflt
                dflt='n'
@@ -8134,20 +8481,14 @@ echo " "
 fn=dn+~
 rp="Where do the $package library man pages (source) go?"
 . ./getfile
-man3dir="$ans"
-man3direxp="$ansexp"
+prefixvar=man3dir
+. ./setprefixvar
+
 case "$man3dir" in
 '')    man3dir=' '
        installman3dir='';;
 esac
 
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installman3dir=`echo $man3direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installman3dir="$man3direxp"
-fi
-
 : What suffix to use on installed man pages
 case "$man3dir" in
 ' ')
@@ -8362,11 +8703,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
@@ -8435,6 +8776,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.
@@ -8470,6 +8812,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
@@ -8513,6 +8856,9 @@ case "$versiononly" in
 esac
 
 : figure out how to guarantee perl startup
+: XXX Note that this currently takes advantage of the bug that binexp ignores
+:     the Configure -Dinstallprefix setting, which in turn means that under
+:     relocatable @INC, initialinstalllocation is what binexp started as.
 case "$startperl" in
 '')
        case "$sharpbang" in
@@ -8522,13 +8868,13 @@ case "$startperl" in
 I can use the #! construct to start perl on your system. This will
 make startup of perl scripts faster, but may cause problems if you
 want to share those scripts and perl is not in a standard place
-($binexp/perl) on all your platforms. The alternative is to force
-a shell by starting the script with a single ':' character.
+($initialinstalllocation/perl) on all your platforms. The alternative
+is to force a shell by starting the script with a single ':' character.
 
 EOH
                case "$versiononly" in
-               "$define")      dflt="$binexp/perl$version";;  
-               *)              dflt="$binexp/perl";;
+               "$define")      dflt="$initialinstalllocation/perl$version";;
+               *)              dflt="$initialinstalllocation/perl";;
                esac
                rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
                . ./myread
@@ -8557,8 +8903,8 @@ echo "I'll use $startperl to start perl scripts."
 case "$perlpath" in
 '')
        case "$versiononly" in
-       "$define")      perlpath="$binexp/perl$version";;
-       *)              perlpath="$binexp/perl";;
+       "$define")      perlpath="$initialinstalllocation/perl$version";;
+       *)              perlpath="$initialinstalllocation/perl";;
        esac
        case "$startperl" in
        *!*) ;;
@@ -8568,10 +8914,10 @@ case "$perlpath" in
 I will use the "eval 'exec'" idiom to start Perl on your system.
 I can use the full path of your Perl binary for this purpose, but
 doing so may cause problems if you want to share those scripts and
-Perl is not always in a standard place ($binexp/perl).
+Perl is not always in a standard place ($initialinstalllocation/perl).
 
 EOH
-               dflt="$binexp/perl"
+               dflt="$initialinstalllocation/perl"
                rp="What path shall I use in \"eval 'exec'\"?"
                . ./myread
                perlpath="$ans"
@@ -8603,12 +8949,12 @@ case "$scriptdir" in
        ;;
 esac
 $cat <<EOM
+
 Some installations have a separate directory just for executable scripts so
 that they can mount it across multiple architectures but keep the scripts in
 one spot.  You might, for example, have a subdirectory of /usr/share for this.
 Or you might just lump your scripts in with all your other executables.
+
 EOM
 fn=d~
 rp='Where do you keep publicly executable scripts?'
@@ -8616,14 +8962,11 @@ rp='Where do you keep publicly executable scripts?'
 if $test "X$ansexp" != "X$scriptdirexp"; then
        installscript=''
 fi
-scriptdir="$ans"
-scriptdirexp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installscript=`echo $scriptdirexp | sed "s#^$prefix#$installprefix#"`
-else
-       installscript="$scriptdirexp"
-fi
+installscriptdir=''
+prefixvar=scriptdir
+. ./setprefixvar
+: A little fix up for an irregularly named variable.
+installscript="$installscriptdir"
 
 : determine where add-on public executables go
 case "$sitebin" in
@@ -8633,14 +8976,8 @@ esac
 fn=d~
 rp='Pathname where the add-on public executables should be installed?'
 . ./getfile
-sitebin="$ans"
-sitebinexp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsitebin=`echo $sitebinexp | sed "s#^$prefix#$installprefix#"`
-else
-       installsitebin="$sitebinexp"
-fi
+prefixvar=sitebin
+. ./setprefixvar
 
 : determine where add-on html pages go
 : There is no standard location, so try to copy the previously-selected
@@ -8655,14 +8992,8 @@ esac
 fn=dn+~
 rp='Pathname where the site-specific html pages should be installed?'
 . ./getfile
-sitehtml1dir="$ans"
-sitehtml1direxp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsitehtml1dir=`echo $sitehtml1direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installsitehtml1dir="$sitehtml1direxp"
-fi
+prefixvar=sitehtml1dir
+. ./setprefixvar
 
 : determine where add-on library html pages go
 : There is no standard location, so try to copy the previously-selected
@@ -8677,19 +9008,13 @@ esac
 fn=dn+~
 rp='Pathname where the site-specific library html pages should be installed?'
 . ./getfile
-sitehtml3dir="$ans"
-sitehtml3direxp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsitehtml3dir=`echo $sitehtml3direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installsitehtml3dir="$sitehtml3direxp"
-fi
+prefixvar=sitehtml3dir
+. ./setprefixvar
 
 : determine where add-on manual pages go
 case "$siteman1dir" in
 '')    dflt=`echo $man1dir | $sed "s#^$prefix#$siteprefix#"` ;;
-*)     dflt=$siteman1dir ;;
+*)     dflt=$siteman1dir ;;
 esac
 case "$dflt" in
 ''|' ') dflt=none ;;
@@ -8697,19 +9022,13 @@ esac
 fn=dn+~
 rp='Pathname where the site-specific manual pages should be installed?'
 . ./getfile
-siteman1dir="$ans"
-siteman1direxp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsiteman1dir=`echo $siteman1direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installsiteman1dir="$siteman1direxp"
-fi
+prefixvar=siteman1dir
+. ./setprefixvar
 
 : determine where add-on library man pages go
 case "$siteman3dir" in
 '')    dflt=`echo $man3dir | $sed "s#^$prefix#$siteprefix#"` ;;
-*)     dflt=$siteman3dir ;;
+*)     dflt=$siteman3dir ;;
 esac
 case "$dflt" in
 ''|' ') dflt=none ;;
@@ -8717,14 +9036,8 @@ esac
 fn=dn+~
 rp='Pathname where the site-specific library manual pages should be installed?'
 . ./getfile
-siteman3dir="$ans"
-siteman3direxp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsiteman3dir=`echo $siteman3direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installsiteman3dir="$siteman3direxp"
-fi
+prefixvar=siteman3dir
+. ./setprefixvar
 
 : determine where add-on public executable scripts go
 case "$sitescript" in
@@ -8735,15 +9048,10 @@ esac
 fn=d~+
 rp='Pathname where add-on public executable scripts should be installed?'
 . ./getfile
-sitescript="$ans"
-sitescriptexp="$ansexp"
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installsitescript=`echo $sitescriptexp | sed "s#^$prefix#$installprefix#"`
-else
-       installsitescript="$sitescriptexp"
-fi
+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`
@@ -8767,7 +9075,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
@@ -8843,7 +9151,7 @@ $cat >try.c <<EOCP
 int main()
 {
     printf("%d\n", (int)sizeof($lseektype));
-    return(0); 
+    return(0);
 }
 EOCP
 set try
@@ -8858,19 +9166,20 @@ else
        . ./myread
        lseeksize="$ans"
 fi
-$rm -f try.c try
+$rm_try
 
 : see what type file positions are declared as in the library
 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>
@@ -8903,6 +9212,7 @@ else
        fpossize="$ans"
 fi
 
+: Check for large file support
 # Backward compatibility (uselfs is deprecated).
 case "$uselfs" in
 "$define"|true|[yY]*)
@@ -8912,7 +9222,7 @@ case "$uselfs" in
 EOM
        uselargefiles="$define"
        ;;
-esac                          
+esac
 
 case "$lseeksize:$fpossize" in
 8:8) cat <<EOM
@@ -8959,7 +9269,7 @@ case "$uselargefiles" in
 int main()
 {
     printf("%d\n", (int)sizeof($lseektype));
-    return(0); 
+    return(0);
 }
 EOCP
                set try
@@ -8978,7 +9288,7 @@ EOCP
                *_t) zzz="$fpostype"    ;;
                *)   zzz="fpos_t"       ;;
                esac
-               $echo $n "Rechecking the size of $zzz...$c" >&4 
+               $echo $n "Rechecking the size of $zzz...$c" >&4
                $cat > try.c <<EOCP
 #include <sys/types.h>
 #include <stdio.h>
@@ -9011,16 +9321,12 @@ EOCP
                        . ./myread
                        fpossize="$ans"
                fi
-               $rm -f try.c try
+               $rm_try
        fi
        ;;
 esac
 
-# probably will refer to
-#   $archlib $privlib $sitearch $sitelib $vendorarch $vendorlib
-need_relocation=0
-userelocatableinc=undef
-
+: Set the vendorbin variables
 case "$vendorprefix" in
 '')    d_vendorbin="$undef"
        vendorbin=''
@@ -9039,13 +9345,10 @@ case "$vendorprefix" in
        vendorbinexp="$ansexp"
        ;;
 esac
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorbin=`echo $vendorbinexp | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorbin="$vendorbinexp"
-fi
+prefixvar=vendorbin
+. ./installprefix
 
+: Set the vendorhtml1dir variables
 case "$vendorprefix" in
 '')    vendorhtml1dir=''
        vendorhtml1direxp=''
@@ -9070,13 +9373,10 @@ case "$vendorprefix" in
 esac
 : Use ' ' for none so value is preserved next time through Configure
 $test X"$vendorhtml1dir" = "X" && vendorhtml1dir=' '
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorhtml1dir=`echo $vendorhtml1direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorhtml1dir="$vendorhtml1direxp"
-fi
+prefixvar=vendorhtml1dir
+. ./installprefix
 
+: Set the vendorhtml3dir variables
 case "$vendorprefix" in
 '')    vendorhtml3dir=''
        vendorhtml3direxp=''
@@ -9101,13 +9401,10 @@ case "$vendorprefix" in
 esac
 : Use ' ' for none so value is preserved next time through Configure
 $test X"$vendorhtml3dir" = "X" && vendorhtml3dir=' '
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorhtml3dir=`echo $vendorhtml3direxp | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorhtml3dir="$vendorhtml3direxp"
-fi
+prefixvar=vendorhtml3dir
+. ./installprefix
 
+: Set the vendorman1dir variables
 case "$vendorprefix" in
 '')    vendorman1dir=''
        vendorman1direxp=''
@@ -9129,13 +9426,10 @@ case "$vendorprefix" in
 esac
 : Use ' ' for none so value is preserved next time through Configure
 $test X"$vendorman1dir" = "X" && vendorman1dir=' '
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorman1dir=`echo "$vendorman1direxp" | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorman1dir="$vendorman1direxp"
-fi
+prefixvar=vendorman1dir
+. ./installprefix
 
+: Set the vendorman3dir variables
 case "$vendorprefix" in
 '')    vendorman3dir=''
        vendorman3direxp=''
@@ -9157,13 +9451,10 @@ case "$vendorprefix" in
 esac
 : Use ' ' for none so value is preserved next time through Configure
 $test X"$vendorman3dir" = "X" && vendorman3dir=' '
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorman3dir=`echo "$vendorman3direxp" | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorman3dir="$vendorman3direxp"
-fi
+prefixvar=vendorman3dir
+. ./installprefix
 
+: Set the vendorscript variables
 case "$vendorprefix" in
 '')    d_vendorscript="$undef"
        vendorscript=''
@@ -9178,7 +9469,7 @@ case "$vendorprefix" in
        esac
        $cat <<EOM
 
-The installation process will create a directory for 
+The installation process will create a directory for
 vendor-supplied scripts.
 
 EOM
@@ -9189,17 +9480,14 @@ EOM
        vendorscriptexp="$ansexp"
        ;;
 esac
-: Change installation prefix, if necessary.
-if $test X"$prefix" != X"$installprefix"; then
-       installvendorscript=`echo $vendorscriptexp | $sed "s#^$prefix#$installprefix#"`
-else
-       installvendorscript="$vendorscriptexp"
-fi
+prefixvar=vendorscript
+. ./installprefix
 
 : 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
@@ -9300,17 +9588,17 @@ else
        sSCNfldbl=$sPRIfldbl    # expect consistency
 fi
 
-$rm -f try try.*
+$rm_try
 
 fi # d_longdbl
 
 case "$sPRIfldbl" in
-'')    d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef"; 
-       d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef"; 
+'')    d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
+       d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
        d_SCNfldbl="$undef";
        ;;
-*)     d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define"; 
-       d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define"; 
+*)     d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
+       d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
        d_SCNfldbl="$define";
        ;;
 esac
@@ -9386,8 +9674,8 @@ char *got;
 }
 
 int main()
-{ 
-       char buf[64]; 
+{
+       char buf[64];
        buf[63] = '\0';
 
        /* This must be 1st test on (which?) platform */
@@ -9395,13 +9683,13 @@ int main()
        Gconvert((DOUBLETYPE)0.1, 8, 0, buf);
        checkit("0.1", buf);
 
-       Gconvert((DOUBLETYPE)0.01, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)0.01, 8, 0, buf);
        checkit("0.01", buf);
 
-       Gconvert((DOUBLETYPE)0.001, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)0.001, 8, 0, buf);
        checkit("0.001", buf);
 
-       Gconvert((DOUBLETYPE)0.0001, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)0.0001, 8, 0, buf);
        checkit("0.0001", buf);
 
        Gconvert((DOUBLETYPE)0.00009, 8, 0, buf);
@@ -9410,42 +9698,42 @@ int main()
        else
            checkit("9e-05", buf);
 
-       Gconvert((DOUBLETYPE)1.0, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.0, 8, 0, buf);
        checkit("1", buf);
 
-       Gconvert((DOUBLETYPE)1.1, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.1, 8, 0, buf);
        checkit("1.1", buf);
 
-       Gconvert((DOUBLETYPE)1.01, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.01, 8, 0, buf);
        checkit("1.01", buf);
 
-       Gconvert((DOUBLETYPE)1.001, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.001, 8, 0, buf);
        checkit("1.001", buf);
 
-       Gconvert((DOUBLETYPE)1.0001, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.0001, 8, 0, buf);
        checkit("1.0001", buf);
 
-       Gconvert((DOUBLETYPE)1.00001, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.00001, 8, 0, buf);
        checkit("1.00001", buf);
 
-       Gconvert((DOUBLETYPE)1.000001, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)1.000001, 8, 0, buf);
        checkit("1.000001", buf);
 
-       Gconvert((DOUBLETYPE)0.0, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)0.0, 8, 0, buf);
        checkit("0", buf);
 
-       Gconvert((DOUBLETYPE)-1.0, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)-1.0, 8, 0, buf);
        checkit("-1", buf);
 
        /* Some Linux gcvt's give 1.e+5 here. */
-       Gconvert((DOUBLETYPE)100000.0, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)100000.0, 8, 0, buf);
        checkit("100000", buf);
-       
+
        /* Some Linux gcvt's give -1.e+5 here. */
-       Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf);
        checkit("-100000", buf);
 
-       Gconvert((DOUBLETYPE)123.456, 8, 0, buf); 
+       Gconvert((DOUBLETYPE)123.456, 8, 0, buf);
        checkit("123.456", buf);
 
        /* Testing of 1e+129 in bigintpm.t must not get extra '.' here. */
@@ -9470,14 +9758,14 @@ for xxx_convert in $gconvert_preference; do
     case $xxx_convert in
     gcvt|gconvert|sprintf) xxx_list="$xxx_list $xxx_convert" ;;
     *) echo "Discarding unrecognized gconvert_preference $xxx_convert" >&4 ;;
-    esac 
+    esac
 done
 : then add any others
 for xxx_convert in gconvert gcvt sprintf; do
     case "$xxx_list" in
     *$xxx_convert*) ;;
     *) xxx_list="$xxx_list $xxx_convert" ;;
-    esac 
+    esac
 done
 
 case "$d_longdbl$uselongdouble" in
@@ -9512,7 +9800,7 @@ esac
 
 for xxx_convert in $xxx_list; do
        echo "Trying $xxx_convert..."
-       $rm -f try try$_o
+       $rm -f try try$_o core
        set try -DTRY_$xxx_convert
        if eval $compile; then
                echo "$xxx_convert() found." >&4
@@ -9545,10 +9833,11 @@ qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;;
       d_Gconvert='sprintf((b),"%.*g",(n),(double)(x))' ;;
    *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
    esac
-   ;;  
+   ;;
 esac
 
 fi
+$rm_try
 
 : see if _fwalk exists
 set fwalk d__fwalk
@@ -9630,7 +9919,7 @@ optimize="$optimize"
 ccflags="$ccflags"
 prototype="$prototype"
 define="$define"
-rm=$rm
+rm_try="$rm_try"
 usethreads=$usethreads
 i_pthread=$i_pthread
 pthread_h_first=$pthread_h_first
@@ -9638,7 +9927,7 @@ EOSH
 
 $cat >> protochk <<'EOSH'
 
-$rm -f try.c
+$rm_try
 foo="$1"
 shift
 while test $# -ge 2; do
@@ -9668,12 +9957,13 @@ echo "$foo" >> try.c
 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
 status=$?
-$rm -f try.[co]
+$rm_try
 exit $status
 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
@@ -9691,7 +9981,7 @@ else
 fi;
 set $varname;
 eval $setvar;
-$rm -f try.c tryout.c'
+$rm_try tryout.c'
 
 : see if sys/types.h has to be included
 set sys/types.h i_systypes
@@ -9701,6 +9991,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
@@ -9717,7 +10008,7 @@ else
 fi;
 set $varname;
 eval $setvar;
-$rm -f try.c try.o'
+$rm_try'
 
 : see if we should include time.h, sys/time.h, or both
 echo " "
@@ -9804,11 +10095,11 @@ EOCP
                echo "We'll include <sys/time.h>." >&4;;
        *) i_systime="$undef";;
        esac
-       $rm -f try.c try
+       $rm_try
 fi
 : see if struct tm knows about tm_zone
 case "$i_systime$i_time" in
-*$define*) 
+*$define*)
         echo " "
         echo "Checking to see if your struct tm has tm_zone field..." >&4
         set d_tm_tm_zone tm tm_zone $i_systime sys/time.h $i_time time.h
@@ -9825,7 +10116,7 @@ case "$d_tm_tm_zone" in
 esac
 : see if struct tm knows about tm_gmtoff
 case "$i_systime$i_time" in
-*$define*) 
+*$define*)
         echo " "
         echo "Checking to see if your struct tm has tm_gmtoff field..." >&4
         set d_tm_tm_gmtoff tm tm_gmtoff $i_systime sys/time.h $i_time time.h
@@ -9930,6 +10221,50 @@ set d_attribute_format
 eval $setvar
 $rm -f attrib*
 
+: Look for GCC-style attribute format with null format allowed
+case "$d_printf_format_null" in
+'') case "$d_attribute_format" in
+    $define)
+       echo " "
+       echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
+$cat >attrib.c <<EOCP
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
+int null_printf (char* pat,...) { return (int)pat; }
+int main () { exit(null_printf(NULL)); }
+EOCP
+       if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
+           : run the executable in case it produces a run-time warning
+           if $run ./attrib >>attrib.out 2>&1; then
+               if $contains 'warning' attrib.out >/dev/null 2>&1; then
+                   echo "Your C compiler doesn't allow __printf__ format to be null."
+                   val="$undef"
+               else
+                   echo "Your C compiler allows __printf__ format to be null."
+                   val="$define"
+               fi
+           else
+           echo "Your C compiler executable failed with __printf__ format null."
+           val="$undef"
+       fi
+    else
+       echo "Your C compiler fails with __printf__ format null."
+       val="$undef"
+    fi
+    ;;
+    *)  val="$undef" ;;
+    esac
+;;
+*)  val="$d_printf_format_null" ;;
+esac
+set d_printf_format_null
+eval $setvar
+$rm -f attrib*
+
 : Look for GCC-style attribute malloc
 case "$d_attribute_malloc" in
 '')
@@ -10106,10 +10441,6 @@ eval $inlibc
 set bcopy d_bcopy
 eval $inlibc
 
-: see if this is a unistd.h system
-set unistd.h i_unistd
-eval $inhdr
-
 : see if getpgrp exists
 set getpgrp d_getpgrp
 eval $inlibc
@@ -10174,7 +10505,7 @@ EOP
 esac
 set d_bsdgetpgrp
 eval $setvar
-$rm -f try try.*
+$rm_try
 
 : see if setpgrp exists
 set setpgrp d_setpgrp
        ;;
 *) val="$undef";;
 esac
-set d_bsdsetpgrp
-eval $setvar
-$rm -f try try.*
-: see if bzero exists
-set bzero d_bzero
-eval $inlibc
+set d_bsdsetpgrp
+eval $setvar
+$rm_try
+
+: Look for GCC-style __builtin_choose_expr
+case "$d_builtin_choose_expr" in
+'')
+    echo " "
+    echo "Checking whether your compiler can handle __builtin_choose_expr ..." >&4
+    $cat >try.c <<'EOCP'
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define SYRINX(x) __builtin_choose_expr( x, (1056*2), (103*50) )
+
+int main(void) {
+    assert( SYRINX(1) == 2112 );
+    assert( SYRINX(1) != 5150 );
+    assert( SYRINX(0) == 5150 );
+    assert( SYRINX(0) != 2112 );
+    puts( "All good!" );
+    exit(0);
+}
+
+EOCP
+    set try
+    if eval $compile && $run ./try; then
+       echo "Your C compiler supports __builtin_choose_expr."
+       val="$define"
+    else
+       echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
+       val="$undef"
+    fi
+;;
+*) val="$d_builtin_choose_expr" ;;
+esac
+
+set d_builtin_choose_expr
+eval $setvar
+$rm_try
+
+: Look for GCC-style __builtin_expect
+case "$d_builtin_expect" in
+'')
+    echo " "
+    echo "Checking whether your compiler can handle __builtin_expect ..." >&4
+    $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 && $run ./try; then
+       echo "Your C compiler supports __builtin_expect."
+       val="$define"
+    else
+       echo "Your C compiler doesn't seem to understand __builtin_expect."
+       val="$undef"
+    fi
+    ;;
+*) val="$d_builtin_expect" ;;
+esac
+
+set d_builtin_expect
+eval $setvar
+$rm_try
+
+: see if bzero exists
+set bzero d_bzero
+eval $inlibc
+
+: see if stdarg is available
+echo " "
+if $test `./findhdr stdarg.h`; then
+       echo "<stdarg.h> found." >&4
+       valstd="$define"
+else
+       echo "<stdarg.h> NOT found." >&4
+       valstd="$undef"
+fi
+
+: see if varags is available
+echo " "
+if $test `./findhdr varargs.h`; then
+       echo "<varargs.h> found." >&4
+else
+       echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
+fi
+
+: set up the varargs testing programs
+$cat > varargs.c <<EOP
+#ifdef I_STDARG
+#include <stdarg.h>
+#endif
+#ifdef I_VARARGS
+#include <varargs.h>
+#endif
+
+#ifdef I_STDARG
+int f(char *p, ...)
+#else
+int f(va_alist)
+va_dcl
+#endif
+{
+       va_list ap;
+#ifndef I_STDARG
+       char *p;
+#endif
+#ifdef I_STDARG
+       va_start(ap,p);
+#else
+       va_start(ap);
+       p = va_arg(ap, char *);
+#endif
+       va_end(ap);
+       return 0;
+}
+EOP
+$cat > varargs <<EOP
+$startsh
+if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
+       echo "true"
+else
+       echo "false"
+fi
+$rm -f varargs$_o
+EOP
+chmod +x varargs
+
+: now check which varargs header should be included
+echo " "
+i_varhdr=''
+case "$valstd" in
+"$define")
+       if `./varargs I_STDARG`; then
+               val='stdarg.h'
+       elif `./varargs I_VARARGS`; then
+               val='varargs.h'
+       fi
+       ;;
+*)
+       if `./varargs I_VARARGS`; then
+               val='varargs.h'
+       fi
+       ;;
+esac
+case "$val" in
+'')
+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
+       stdarg.h)
+               val="$define"; set i_stdarg; eval $setvar
+               val="$undef"; set i_varargs; eval $setvar
+               ;;
+       varargs.h)
+               val="$undef"; set i_stdarg; eval $setvar
+               val="$define"; set i_varargs; eval $setvar
+               ;;
+       esac
+       echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
+esac
+$rm -f varargs*
+
+: see if the Compiler supports C99 variadic macros
+case "$i_stdarg$i_stdlib" in
+    "$define$define")
+    echo "You have <stdarg.h> and <stdlib.h>, so checking for C99 variadic macros." >&4
+    $cat >try.c <<EOCP
+#include <stdio.h>
+#include <stdarg.h>
+
+#define foo(buffer, format, ...) sprintf(buffer, format, __VA_ARGS__)
+
+int main() {
+  char buf[20];
+  foo(buf, "%d %g %.*s", 123, 456.0, (int)3, "789fail");
+  puts(buf);
+  return 0;
+}
+EOCP
+    set try
+    if eval $compile && $run ./try 2>&1 >/dev/null; then
+       case "`$run ./try`" in
+           "123 456 789")
+           echo "You have C99 variadic macros." >&4
+           d_c99_variadic_macros="$define"
+           ;;
+           *)
+           echo "You don't have functional C99 variadic macros." >&4
+           d_c99_variadic_macros="$undef"
+           ;;
+       esac
+    else
+       echo "I couldn't compile and run the test program, so I assume that you don't have functional C99 variadic macros." >&4
+       d_c99_variadic_macros="$undef"
+    fi
+    $rm_try
+    ;;
+    *)
+    echo "You don't have <stdarg.h> and <stdlib.h>, so not checking for C99 variadic macros." >&4
+    d_c99_variadic_macros="$undef"
+    ;;
+esac
 
 : see if signal is declared as pointer to function returning int or void
 echo " "
@@ -10305,7 +10844,7 @@ $cat >try.c <<EOCP
 #endif
 #include <sys/types.h>
 #include <signal.h>
-$signal_t blech(s) int s; { exit(3); }
+$signal_t blech(int s) { exit(3); }
 int main()
 {
        $xxx i32;
@@ -10314,7 +10853,7 @@ int main()
        char str[16];
        signal(SIGFPE, blech);
 
-       /* Don't let compiler optimize the test away.  Store the number 
+       /* Don't let compiler optimize the test away.  Store the number
           in a writable string for gcc to pass to sscanf under HP/UX.
        */
        sprintf(str, "2147483647");
@@ -10350,7 +10889,7 @@ case "$yyy" in
 esac
 set d_casti32
 eval $setvar
-$rm -f try try.*
+$rm_try
 
 : check for ability to cast negative floats to unsigned
 echo " "
@@ -10363,11 +10902,11 @@ $cat >try.c <<EOCP
 #endif
 #include <sys/types.h>
 #include <signal.h>
-$signal_t blech(s) int s; { exit(7); }
-$signal_t blech_in_list(s) int s; { exit(4); }
-unsigned long dummy_long(p) unsigned long p; { return p; }
-unsigned int dummy_int(p) unsigned int p; { return p; }
-unsigned short dummy_short(p) unsigned short p; { return p; }
+$signal_t blech(int s) { exit(7); }
+$signal_t blech_in_list(int s) { exit(4); }
+unsigned long dummy_long(unsigned long p) { return p; }
+unsigned int dummy_int(unsigned int p) { return p; }
+unsigned short dummy_short(unsigned short p) { return p; }
 int main()
 {
        double f;
@@ -10376,12 +10915,12 @@ int main()
        unsigned short ashort;
        int result = 0;
        char str[16];
-       
+
        /* Frustrate gcc-2.7.2's optimizer which failed this test with
           a direct f = -123. assignment.  gcc-2.8.0 reportedly
           optimized the whole file away
        */
-       /* Store the number in a writable string for gcc to pass to 
+       /* Store the number in a writable string for gcc to pass to
           sscanf under HP/UX.
        */
        sprintf(str, "-123");
@@ -10450,7 +10989,7 @@ case "$castflags" in
 esac
 set d_castneg
 eval $setvar
-$rm -f try.*
+$rm_try
 
 : see if vprintf exists
 echo " "
@@ -10458,38 +10997,75 @@ if set vprintf val -f d_vprintf; eval $csym; $val; then
        echo 'vprintf() found.' >&4
        val="$define"
        $cat >try.c <<EOF
-#include <varargs.h>
+#$i_stdarg I_STDARG  /* Only one of these can be defined by i_varhrd */
+#$i_varargs I_VARARGS
+
 #$i_stdlib I_STDLIB
+#$i_unistd I_UNISTD
+
+#ifdef I_STDARG
+#  include <stdarg.h>
+#else /* I_VARARGS */
+#  include <varargs.h>
+#endif
+
+#ifdef I_UNISTD
+#  include <unistd.h>
+#endif
+
 #ifdef I_STDLIB
-#include <stdlib.h>
+#  include <stdlib.h>
 #endif
 
-int main() { xxx("foo"); }
+#include <stdio.h> /* vsprintf prototype */
+
+#ifdef I_STDARG
+void xxx(int n, ...)
+{
+    va_list args;
+    char buf[10];
+    va_start(args, n);
+    exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
+}
+int main() { xxx(1, "foo"); }
+
+#else /* I_VARARGS */
 
 xxx(va_alist)
 va_dcl
 {
-       va_list args;
-       char buf[10];
-
-       va_start(args);
-       exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
+    va_list args;
+    char buf[10];
+    va_start(args);
+    exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
 }
+int main() { xxx("foo"); }
+
+#endif
+
 EOF
        set try
-       if eval $compile && $run ./try; then
-               echo "Your vsprintf() returns (int)." >&4
-               val2="$undef"
+       if eval $compile_ok; then
+               if $run ./try; then
+                       echo "Your vsprintf() returns (int)." >&4
+                       val2="$undef"
+               else
+                       echo "Your vsprintf() returns (char*)." >&4
+                       val2="$define"
+               fi
        else
-               echo "Your vsprintf() returns (char*)." >&4
-               val2="$define"
+               echo 'I am unable to compile the vsprintf() test program.' >&4
+               # We shouldn't get here.  If we do, assume the standard signature,
+               # not the old BSD one.
+               echo 'Guessing that vsprintf() returns (int).' >&4
+               val2="$undef"
        fi
 else
        echo 'vprintf() NOT found.' >&4
-               val="$undef"
-               val2="$undef"
+       val="$undef"
+       val2="$undef"
 fi
-$rm -f try try.*
+$rm_try
 set d_vprintf
 eval $setvar
 val=$val2
@@ -10516,6 +11092,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
@@ -10532,11 +11109,11 @@ else
 fi;
 set $varname;
 eval $setvar;
-$rm -f try.c try.o'
+$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
@@ -10573,7 +11150,7 @@ else
                                                        sockethdr="-I/usr/netinclude"
                                                        ;;
                                                esac
-                                               echo "Found Berkeley sockets interface in lib$net." >&4 
+                                               echo "Found Berkeley sockets interface in lib$net." >&4
                                                if $contains setsockopt libc.list >/dev/null 2>&1; then
                                                        d_oldsock="$undef"
                                                else
@@ -10614,14 +11191,14 @@ EOF
                val="$define"
        fi
        set d_${enum}; eval $setvar
-       $rm -f try.c try
+       $rm_try
 done
 
 : see if this is a sys/uio.h system
 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
@@ -10640,7 +11217,7 @@ typedef struct spug { int drokk; } spug;
 int main()
 {
        const char *foo;
-       const spug y;
+       const spug y = { 0 };
 }
 EOCP
 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
@@ -10757,6 +11334,10 @@ case "$full_csh" in
 '') full_csh=$csh ;;
 esac
 
+: see if ctermid exists
+set ctermid d_ctermid
+eval $inlibc
+
 : see if ctermid_r exists
 set ctermid_r d_ctermid_r
 eval $inlibc
@@ -10966,7 +11547,7 @@ case "$guess1" in
 'struct dirent') guess2='struct direct' ;;
 *) guess2='struct dirent' ;;
 esac
-               
+
 if $contains "$guess1" try.c >/dev/null 2>&1; then
        direntrytype="$guess1"
        echo "Your directory entries are $direntrytype." >&4
@@ -10980,8 +11561,7 @@ else
        . ./myread
        direntrytype="$ans"
 fi
-$rm -f try.c
-
+$rm_try
 
 : see if the directory entry stores field length
 echo " "
@@ -10995,7 +11575,43 @@ else
 fi
 set d_dirnamlen
 eval $setvar
-$rm -f try.c
+$rm_try
+
+: Look for DIR.dd_fd
+case "$i_dirent" in
+"$define")
+    echo "Checking to see if DIR has a dd_fd member variable" >&4
+    $cat >try.c <<EOCP
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#include <dirent.h>
+
+int main() {
+    DIR dir;
+    dir.dd_fd = 1;
+    return 0;
+}
+EOCP
+    val=$undef
+    set try
+    if eval $compile; then
+        echo "Yes, it does."
+        val="$define"
+    else
+        echo "No, it does not."
+        val="$undef"
+    fi
+    ;;
+*)
+    echo "You don't have a <dirent.h>, so not checking for dd_fd." >&4
+    val="$undef"
+    ;;
+esac
+set d_dir_dd_fd
+eval $setvar
+$rm_try
 
 : see if this is an sysdir system
 set sys/dir.h i_sysdir
@@ -11070,6 +11686,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
@@ -11154,9 +11771,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
@@ -11174,7 +11791,7 @@ EOM
        fi
        ;;
 esac
-               
+
 $rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.*
 
 set d_dlsymun
@@ -11697,7 +12314,25 @@ else
 fi
 set d_open3
 eval $setvar
-$rm -f try try.*
+$rm_try
+
+: 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 " "
@@ -11711,7 +12346,7 @@ else
        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
+               ./warn "No string header found -- You'll surely have problems."
        fi
 fi
 set i_string
@@ -11774,6 +12409,14 @@ esac
 set i_fcntl
 eval $setvar
 
+: see if fork exists
+set fork d_fork
+eval $inlibc
+
+: see if pipe exists
+set pipe d_pipe
+eval $inlibc
+
 : check for non-blocking I/O stuff
 case "$h_sysfile" in
 true) echo "#include <sys/file.h>" > head.c;;
@@ -11828,18 +12471,20 @@ EOCP
        ;;
 *) echo "Using $hint value $o_nonblock.";;
 esac
-$rm -f try try.* .out core
+$rm_try
 
 echo " "
 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
 case "$eagain" in
 '')
+       case "$d_fork:$d_pipe" in
+       define:define)
        $cat head.c > try.c
        $cat >>try.c <<EOCP
 #include <errno.h>
 #include <sys/types.h>
 #include <signal.h>
-#include <stdio.h> 
+#include <stdio.h>
 #$i_stdlib I_STDLIB
 #ifdef I_STDLIB
 #include <stdlib.h>
@@ -11862,7 +12507,7 @@ extern int errno;
 #else
 #include <strings.h>
 #endif
-$signal_t blech(x) int x; { exit(3); }
+$signal_t blech(int x) { exit(3); }
 EOCP
        $cat >> try.c <<'EOCP'
 int main()
@@ -11966,6 +12611,12 @@ EOCP
                echo "I can't compile the test program--assuming errno EAGAIN will do."
                eagain=EAGAIN
        fi
+       ;;
+       *)      echo "Can't figure out how to test this--assuming errno EAGAIN will do."
+               eagain=EAGAIN
+               val="$define"
+               ;;
+       esac
        set d_eofnblk
        eval $setvar
        ;;
@@ -11982,7 +12633,7 @@ EOCP
        esac
        ;;
 esac
-$rm -f try try.* .out core head.c mtry
+$rm_try head.c mtry
 
 : see if _ptr and _cnt from stdio act std
 echo " "
@@ -12081,7 +12732,7 @@ if eval $compile && $to try.c; then
 else
        echo "Your stdio doesn't appear very std."
 fi
-$rm -f try.c try
+$rm_try
 
 # glibc 2.2.90 and above apparently change stdio streams so Perl's
 # direct buffer manipulation no longer works.  The Configure tests
@@ -12181,7 +12832,7 @@ int main() {
        if (cnt == FILE_cnt(fp)) {
                puts("Pass_unchanged");
                exit (0);
-       }       
+       }
        if (FILE_cnt(fp) == (cnt - 42)) {
                puts("Pass_changed");
                exit (0);
@@ -12208,7 +12859,7 @@ EOP
        else
                echo "It seems we can't set ptr in your stdio.  Nevermind." >&4
        fi
-       $rm -f try.c try
+       $rm_try
        ;;
 esac
 
@@ -12246,7 +12897,7 @@ EOP
        else
                echo "However, it seems to be lacking the _base field."
        fi
-       $rm -f try.c try
+       $rm_try
        ;;
 esac
 set d_stdiobase
@@ -12285,8 +12936,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
@@ -12295,7 +12946,7 @@ $cat >try.c <<EOCP
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
-$signal_t blech(x) int x; { exit(3); }
+$signal_t blech(int x) { exit(3); }
 int main() {
 #if defined(F_SETLK) && defined(F_SETLKW)
      struct flock flock;
@@ -12349,8 +13000,7 @@ EOM
 esac
 set d_fcntl_can_lock
 eval $setvar
-$rm -f try*
-
+$rm_try
 
 : check for fd_set items
 $cat <<EOM
@@ -12428,7 +13078,7 @@ EOM
                d_fd_macros="$undef"
        fi
 fi
-$rm -f try try.*
+$rm_try
 
 : see if fgetpos exists
 set fgetpos d_fgetpos
@@ -12451,10 +13101,6 @@ echo " "
 set d_flockproto flock $i_sysfile sys/file.h
 eval $hasproto
 
-: see if fork exists
-set fork d_fork
-eval $inlibc
-
 : see if fp_class exists
 set fp_class d_fp_class
 eval $inlibc
@@ -12479,7 +13125,6 @@ eval $inlibc
 set fpclassl d_fpclassl
 eval $inlibc
 
-
 : check for fpos64_t
 echo " "
 echo "Checking to see if you have fpos64_t..." >&4
@@ -12498,7 +13143,7 @@ else
        8) echo "(Your fpos_t is 64 bits, so you could use that.)" ;;
        esac
 fi
-$rm -f try.* try
+$rm_try
 set d_fpos64_t
 eval $setvar
 
@@ -12514,7 +13159,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
@@ -12535,12 +13180,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
@@ -12561,10 +13204,10 @@ 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 for a working futimes()" >&4
+echo "Checking if you have a working futimes()" >&4
 $cat >try.c <<EOCP
 #include <stdio.h>
 #include <sys/time.h>
@@ -12585,16 +13228,16 @@ if eval $compile; then
     `$run ./try`
     rc=$?
     case "$rc" in
-       0)  echo "Yes, it does" >&4
+       0)  echo "Yes, you have" >&4
            d_futimes="$define"
            ;;
-       *)  echo "No, it has futimes, but it isn't working ($rc) (probably harmless)\n" >&4
+       *)  echo "No, you have futimes, but it isn't working ($rc) (probably harmless)" >&4
            ;;
     esac
 else
-    echo "No, it does not (probably harmless)\n" >&4
+    echo "No, it does not (probably harmless)" >&4
 fi
-$rm -f try.* try core core.try.*
+$rm_try
 
 : see if getcwd exists
 set getcwd d_getcwd
@@ -12604,7 +13247,6 @@ eval $inlibc
 set getespwnam d_getespwnam
 eval $inlibc
 
-
 : see if getfsstat exists
 set getfsstat d_getfsstat
 eval $inlibc
@@ -12839,7 +13481,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
@@ -13350,6 +13992,7 @@ eval $hasproto
 set getpagesize d_getpagsz
 eval $inlibc
 
+: Optional checks for getprotobyname and getprotobynumber
 
 : see if getprotobyname exists
 set getprotobyname d_getpbyname
@@ -13710,6 +14353,7 @@ case "$d_getpwuid_r" in
        ;;
 esac
 
+: Optional checks for getsbyname and getsbyport
 
 : see if getservbyname exists
 set getservbyname d_getsbyname
@@ -14199,10 +14843,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
@@ -14220,9 +14864,9 @@ EOCP
            echo "Yes, it does ($foo)" >&4
            d_libm_lib_version="$define"
        else
-           echo "No, it does not (probably harmless)\n" >&4
+           echo "No, it does not (probably harmless)" >&4
            fi
-       $rm -f try.* try core core.try.*
+       $rm_try
        ;;
 
     esac
@@ -14276,6 +14920,59 @@ case "$d_localtime_r" in
        ;;
 esac
 
+: see if localtime_r calls tzset
+case "$localtime_r_proto" in
+REENTRANT_PROTO*)
+       $cat >try.c <<EOCP
+/*  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>
+int main()
+{
+    time_t t = time(0L);
+    char w_tz[]="TZ" "=GMT+5",
+        e_tz[]="TZ" "=GMT-5",
+       *tz_e = (char*)malloc(16),
+       *tz_w = (char*)malloc(16);
+    struct tm tm_e, tm_w;
+    memset(&tm_e,'\0',sizeof(struct tm));
+    memset(&tm_w,'\0',sizeof(struct tm));
+    strcpy(tz_e,e_tz);
+    strcpy(tz_w,w_tz);
+
+    putenv(tz_e);
+    localtime_r(&t, &tm_e);
+
+    putenv(tz_w);
+    localtime_r(&t, &tm_w);
+
+    if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
+       return 1;
+    return 0;
+}
+EOCP
+       set try
+       if eval $compile; then
+           if $run ./try; then
+               d_localtime_r_needs_tzset=undef;
+           else
+               d_localtime_r_needs_tzset=define;
+           fi;
+       else
+           d_localtime_r_needs_tzset=undef;
+       fi;
+     ;;
+  *)
+     d_localtime_r_needs_tzset=undef;
+     ;;
+esac
+$rm_try
+
 : see if localeconv exists
 set localeconv d_locconv
 eval $inlibc
@@ -14413,12 +15110,12 @@ $define$define)
 Checking to see whether your modfl() is okay for large values...
 EOM
 $cat >try.c <<EOCP
-#include <math.h> 
+#include <math.h>
 #include <stdio.h>
 EOCP
 if $test "X$d_modflproto" != "X$define"; then
        $cat >>try.c <<EOCP
-/* Sigh. many current glibcs provide the function, but do not prototype it.  */ 
+/* Sigh. many current glibcs provide the function, but do not prototype it. */
 long double modfl (long double, long double *);
 EOCP
 fi
@@ -14426,7 +15123,7 @@ $cat >>try.c <<EOCP
 int main() {
     long double nv = 4294967303.15;
     long double v, w;
-    v = modfl(nv, &w);         
+    v = modfl(nv, &w);
 #ifdef __GLIBC__
     printf("glibc");
 #endif
@@ -14457,7 +15154,7 @@ EOCP
                        d_modfl="$undef"
                        ;;
                esac
-               $rm -f try.* try core core.try.*
+               $rm_try
        else
                echo "I cannot figure out whether your modfl() is okay, assuming it isn't."
                d_modfl="$undef"
@@ -14559,7 +15256,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
@@ -14590,40 +15287,6 @@ eval $inhdr
 set nl_langinfo d_nl_langinfo
 eval $inlibc
 
-: check for length of character
-echo " "
-case "$charsize" in
-'')
-       echo "Checking to see how big your characters are (hey, you never know)..." >&4
-       $cat >try.c <<EOCP
-#include <stdio.h>
-#$i_stdlib I_STDLIB
-#ifdef I_STDLIB
-#include <stdlib.h>
-#endif
-int main()
-{
-    printf("%d\n", (int)sizeof(char));
-    exit(0);
-}
-EOCP
-       set try
-       if eval $compile_ok; then
-               dflt=`$run ./try`
-       else
-               dflt='1'
-               echo "(I can't seem to compile the test program.  Guessing...)"
-       fi
-       ;;
-*)
-       dflt="$charsize"
-       ;;
-esac
-rp="What is the size of a character (in bytes)?"
-. ./myread
-charsize="$ans"
-$rm -f try.c try
-
 : check for volatile keyword
 echo " "
 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
@@ -14653,9 +15316,9 @@ else
 fi
 set d_volatile
 eval $setvar
-$rm -f try.*
-
+$rm_try
 
+: Check basic sizes
 echo " "
 $echo "Choosing the C types to be used for Perl's internal types..." >&4
 
@@ -14712,38 +15375,10 @@ int main() {
 }
 EOCP
 
-case "$i8type" in
-'')    case "$charsize" in
-       1)      i8type=char
-               u8type="unsigned char"
-               i8size=$charsize
-               u8size=$charsize
-               ;;
-       esac
-       ;;
-esac
-case "$i8type" in
-'')    set try -DINT8
-       if eval $compile; then
-               case "`$run ./try`" in
-               int8_t) i8type=int8_t
-                       u8type=uint8_t
-                       i8size=1
-                       u8size=1
-                       ;;
-               esac
-       fi
-       ;;
-esac
-case "$i8type" in
-'')    if $test $charsize -ge 1; then
-               i8type=char
-               u8type="unsigned char"
-               i8size=$charsize
-               u8size=$charsize
-       fi
-       ;;
-esac
+i8type="signed char"
+u8type="unsigned char"
+i8size=1
+u8size=1
 
 case "$i16type" in
 '')    case "$shortsize" in
@@ -14848,7 +15483,7 @@ $cat <<EOP >try.c
 #include <signal.h>
 #ifdef SIGFPE
 $volatile int bletched = 0;
-$signal_t blech(s) int s; { bletched = 1; }
+$signal_t blech(int s) { bletched = 1; }
 #endif
 int main() {
     $uvtype u = 0;
@@ -14870,10 +15505,9 @@ int main() {
       if (($uvtype)d != (u - 1))
         break;
 #ifdef SIGFPE
-      if (bletched) {
+      if (bletched)
        break;
 #endif
-      }        
     }
     printf("%d\n", ((i == n) ? -n : i));
     exit(0);
@@ -14885,19 +15519,101 @@ d_nv_preserves_uv="$undef"
 if eval $compile; then
        nv_preserves_uv_bits="`$run ./try`"
 fi
-case "$nv_preserves_uv_bits" in
-\-[1-9]*)      
-       nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
-       $echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs."  2>&1
-       d_nv_preserves_uv="$define"
-       ;;
-[1-9]*)        $echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs."  2>&1
-       d_nv_preserves_uv="$undef" ;;
-*)     $echo "Can't figure out how many bits your NVs preserve." 2>&1
-       nv_preserves_uv_bits="$undef" ;;
-esac
-
-$rm -f try.* try
+case "$nv_preserves_uv_bits" in
+\-[1-9]*)
+       nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
+       $echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs."  2>&1
+       d_nv_preserves_uv="$define"
+       ;;
+[1-9]*)        $echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs."  2>&1
+       d_nv_preserves_uv="$undef" ;;
+*)     $echo "Can't figure out how many bits your NVs preserve." 2>&1
+       nv_preserves_uv_bits="0" ;;
+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.
@@ -14920,7 +15636,7 @@ $cat <<EOP >try.c
 #include <signal.h>
 #ifdef SIGFPE
 $volatile int bletched = 0;
-$signal_t blech(s) int s; { bletched = 1; }
+$signal_t blech(int s) { bletched = 1; }
 #endif
 
 int checkit($nvtype d, char *where) {
@@ -14976,7 +15692,7 @@ int main(int argc, char **argv) {
        printf("(gives %g)\n", d);
        return 1;
     }
-    
+
 #ifdef SIGFPE
     if (bletched) {
        printf("No - something bleched\n");
@@ -15018,9 +15734,7 @@ EOM
            ;;
     esac
 fi
-
-$rm -f try.* try
-
+$rm_try
 
 : check for off64_t
 echo " "
@@ -15041,14 +15755,14 @@ else
        8) echo "(Your off_t is 64 bits, so you could use that.)" ;;
        esac
 fi
-$rm -f try.* try
+$rm_try
 set d_off64_t
 eval $setvar
 
 : how to create joinable pthreads
 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
        echo " "
-       echo "Checking what constant to use for creating joinable pthreads..." >&4 
+       echo "Checking what constant to use for creating joinable pthreads..." >&4
        $cat >try.c <<'EOCP'
 #include <pthread.h>
 int main() {
@@ -15074,7 +15788,7 @@ EOCP
                        val=PTHREAD_CREATE_UNDETACHED
                        set old_pthread_create_joinable
                        eval $setvar
-               else            
+               else
                        set try -DJOINABLE=__UNDETACHED
                        if eval $compile; then
                                echo "You seem to use __UNDETACHED." >&4
@@ -15095,7 +15809,7 @@ EOCP
                        fi
                fi
        fi
-       $rm -f try try.*
+       $rm_try
 else
     d_old_pthread_create_joinable="$undef"
     old_pthread_create_joinable=""
 set pause d_pause
 eval $inlibc
 
-: see if pipe exists
-set pipe d_pipe
-eval $inlibc
-
 : see if poll exists
 set poll d_poll
 eval $inlibc
@@ -15117,6 +15827,7 @@ eval $inlibc
 set readlink d_readlink
 eval $inlibc
 
+: Check if exe is symlink to abs path of executing program
 echo " "
 procselfexe=''
 val="$undef"
@@ -15144,6 +15855,54 @@ $rm -f reflect
 set d_procselfexe
 eval $setvar
 
+: backward compatibility for d_hvfork
+if test X$d_hvfork != X; then
+       d_vfork="$d_hvfork"
+       d_hvfork=''
+fi
+: see if there is a vfork
+val=''
+set vfork val
+eval $inlibc
+
+d_pseudofork=$undef
+
+: Ok, but do we want to use it. vfork is reportedly unreliable in
+: perl on Solaris 2.x, and probably elsewhere.
+case "$val" in
+$define)
+       echo " "
+       case "$usevfork" in
+       false) dflt='n';;
+       *) dflt='y';;
+       esac
+       cat <<'EOM'
+
+Perl can only use a vfork() that doesn't suffer from strict
+restrictions on calling functions or modifying global data in
+the child.  For example, glibc-2.1 contains such a vfork()
+that is unsuitable.  If your system provides a proper fork()
+call, chances are that you do NOT want perl to use vfork().
+
+EOM
+       rp="Do you still want to use vfork()?"
+       . ./myread
+       case "$ans" in
+       y|Y) ;;
+       *)
+               echo "Ok, we won't use vfork()."
+               val="$undef"
+               ;;
+       esac
+       ;;
+esac
+set d_vfork
+eval $setvar
+case "$d_vfork" in
+$define) usevfork='true';;
+*) usevfork='false';;
+esac
+
 : see whether the pthread_atfork exists
 $cat >try.c <<EOP
 #include <pthread.h>
@@ -15176,7 +15935,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>
@@ -15241,12 +15999,10 @@ $define)
 esac
 set d_pthread_yield
 eval $setvar
-
 case "$sched_yield" in
 '') sched_yield=undef ;;
 esac
-
-$rm -f try try.*
+$rm_try
 
 : see if random_r exists
 set random_r d_random_r
@@ -15496,7 +16252,7 @@ exit(0);
 EOCP
                set try
                if eval $compile_ok; then
-                       if ./try 2>/dev/null; then
+                       if $run ./try 2>/dev/null; then
                                echo "Yes, it can."
                                val="$define"
                        else
@@ -15507,7 +16263,7 @@ EOCP
                fi
                ;;
        esac
-       $rm -f try.* try core
+       $rm_try
        ;;
 esac
 set d_safebcpy
@@ -15572,7 +16328,7 @@ exit(0);
 EOCP
                set try
                if eval $compile_ok; then
-                       if ./try 2>/dev/null; then
+                       if $run ./try 2>/dev/null; then
                                echo "Yes, it can."
                                val="$define"
                        else
@@ -15583,7 +16339,7 @@ EOCP
                fi
                ;;
        esac
-       $rm -f try.* try core
+       $rm_try
        ;;
 esac
 set d_safemcpy
@@ -15639,7 +16395,7 @@ EOCP
        fi
        ;;
 esac
-$rm -f try.* try core
+$rm_try
 set d_sanemcmp
 eval $setvar
 
@@ -15714,7 +16470,7 @@ else
     echo "You do not have union semun in <sys/sem.h>." >&4
     val="$undef"
 fi
-$rm -f try try.c
+$rm_try
 set d_union_semun
 eval $setvar
 
@@ -15722,7 +16478,7 @@ eval $setvar
 case "$d_sem" in
 $define)
     echo " "
-    $cat > try.h <<END
+    $cat > tryh.h <<END
 #ifndef S_IRUSR
 #   ifdef S_IREAD
 #      define S_IRUSR S_IREAD
@@ -15757,7 +16513,7 @@ END
 #include <sys/stat.h>
 #include <stdio.h>
 #include <errno.h>
-#include "try.h"
+#include "tryh.h"
 #ifndef errno
 extern int errno;
 #endif
@@ -15803,7 +16559,7 @@ END
           semun) val="$define" ;;
           esac
       fi
-      $rm -f try try.c
+      $rm_try
       set d_semctl_semun
       eval $setvar
       ;;
@@ -15827,7 +16583,7 @@ END
 #include <sys/ipc.h>
 #include <sys/sem.h>
 #include <sys/stat.h>
-#include "try.h"
+#include "tryh.h"
 #include <stdio.h>
 #include <errno.h>
 #ifndef errno
@@ -15865,7 +16621,7 @@ END
           semid_ds) val="$define" ;;
           esac
       fi
-      $rm -f try try.c
+      $rm_try
       set d_semctl_semid_ds
       eval $setvar
       ;;
@@ -15877,7 +16633,6 @@ END
     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
         ;;
     esac
-    $rm -f try.h
     ;;
 *)  val="$undef"
 
@@ -15891,6 +16646,7 @@ END
     eval $setvar
     ;;
 esac
+$rm_try tryh.h
 
 : see if sendmsg exists
 set sendmsg d_sendmsg
@@ -16303,7 +17059,6 @@ eval $inlibc
 set sfio.h i_sfio
 eval $inhdr
 
-
 : see if sfio library is available
 case "$i_sfio" in
 $define)
@@ -16453,8 +17208,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
@@ -16486,7 +17241,52 @@ else
        val="$undef"
 fi
 set d_sigaction; eval $setvar
-$rm -f try try$_o try.c
+$rm_try
+
+: see if this is a sunmath.h system
+set sunmath.h i_sunmath
+eval $inhdr
+
+: see if signbit exists
+$echo $n "Checking to see if you have signbit() available to work on $nvtype... $c" >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#$i_sunmath I_SUNMATH
+#ifdef I_MATH
+#  include <math.h>
+#endif
+#ifdef I_SUNMATH  /* Solaris special math library */
+#  include <sunmath.h>
+#endif
+#define NV $nvtype
+int main(int argc, char **argv)
+{
+    NV x = 0.0;
+    NV y = -0.0;
+    if ((signbit(x) == 0) && (signbit(y) != 0))
+       return 0;
+    else
+       return 1;
+}
+EOCP
+val="$undef"
+set try
+if eval $compile; then
+    if $run ./try; then
+        $echo "Yes." >&4
+       val="$define"
+    else
+        $echo "Signbit seems to be available, but doesn't work as I expected."
+        $echo "I won't use it." >&4
+       val="$undef"
+    fi
+else
+    $echo "Nope." >&4
+    dflt="$undef"
+fi
+set d_signbit
+eval $setvar
+$rm_try
 
 : see if sigprocmask exists
 set sigprocmask d_sigprocmask
@@ -16539,7 +17339,7 @@ EOM
 esac
 set d_sigsetjmp
 eval $setvar
-$rm -f try.c try
+$rm_try
 
 : see if snprintf exists
 set snprintf d_snprintf
@@ -16602,7 +17402,7 @@ EOM
        d_snprintf="$undef"
        d_vsnprintf="$undef"
     fi
-    $rm -f try.* try core core.try.*
+    $rm_try
     ;;
 esac
 
@@ -16662,7 +17462,6 @@ int main(int argc, char **argv) {
 EOP
 set try
 
-d_sprintf_returns_strlen="$undef"
 if eval $compile; then
     xxx="`$run ./try`"
     case "$?" in
@@ -16677,9 +17476,11 @@ 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 -f try.* try
+$rm_try
 
 : see if srand48_r exists
 set srand48_r d_srand48_r
@@ -16777,24 +17578,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
@@ -16805,10 +17603,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
@@ -16824,6 +17621,7 @@ case "$d_statfs_f_flags" in
 *)              echo "No, it doesn't." ;;
 esac
 
+: Check stream access
 $cat >&4 <<EOM
 Checking how to access stdio streams by file descriptor number...
 EOM
@@ -16844,7 +17642,7 @@ EOCP
                        esac
                fi
        done
-       $rm -f try.* try$exe_ext
+       $rm_try
 esac
 case "$stdio_stream_array" in
 '')    $cat >&4 <<EOM
@@ -16885,7 +17683,7 @@ else
 fi
 set d_strctcpy
 eval $setvar
-$rm -f try.*
+$rm_try
 
 : see if strerror and/or sys_errlist[] exist
 echo " "
@@ -17017,7 +17815,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;
@@ -17074,7 +17872,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;
@@ -17135,6 +17933,9 @@ EOM
                   d_strtoul="$undef"
                   ;;
                esac
+       else
+               echo "(I can't seem to compile the test program--assuming it doesn't)"
+               d_strtoul="$undef"
        fi
        ;;
 esac
@@ -17154,7 +17955,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;
@@ -17189,6 +17990,9 @@ EOM
                   d_strtoull="$undef"
                   ;;
                esac
+       else
+               echo "(I can't seem to compile the test program--assuming it doesn't)"
+               d_strtoull="$undef"
        fi
        ;;
 esac
@@ -17205,7 +18009,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;
@@ -17241,6 +18045,9 @@ EOM
                   d_strtouq="$undef"
                   ;;
                esac
+       else
+               echo "(I can't seem to compile the test program--assuming it doesn't)"
+               d_strtouq="$undef"
        fi
        ;;
 esac
@@ -17301,6 +18108,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
@@ -17429,6 +18240,7 @@ fi
 set d_tzname
 eval $setvar
 
+: Check if is a multiplatform env
 case "$osname" in
 next|rhapsody|darwin) multiarch="$define" ;;
 esac
@@ -17487,7 +18299,7 @@ int main()
 EOCP
                xxx_prompt=y
                set try
-               if eval $compile && ./try > /dev/null; then
+               if eval $compile && $run ./try > /dev/null; then
                        dflt=`$run ./try`
                        case "$dflt" in
                        [1-4][1-4][1-4][1-4]|12345678|87654321)
@@ -17515,11 +18327,11 @@ EOM
                esac
                ;;
        esac
-       $rm -f try.c try
+       $rm_try
        ;;
 esac
 
-
+: Checking 32bit aligndness
 $cat <<EOM
 
 Checking to see whether you can access character data unalignedly...
@@ -17536,7 +18348,7 @@ case "$d_u32align" in
 #define U8 $u8type
 #include <signal.h>
 #ifdef SIGBUS
-$signal_t bletch(s) int s; { exit(4); }
+$signal_t bletch(int s) { exit(4); }
 #endif
 int main() {
 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
@@ -17619,7 +18431,7 @@ else
        *)      d_u32align="$define" ;;
        esac
 fi
-$rm -f core core.try.* try.core
+$rm_try
 ;;
 esac
 
@@ -17652,52 +18464,6 @@ eval $hasproto
 set ustat d_ustat
 eval $inlibc
 
-: backward compatibility for d_hvfork
-if test X$d_hvfork != X; then
-       d_vfork="$d_hvfork"
-       d_hvfork=''
-fi
-: see if there is a vfork
-val=''
-set vfork val
-eval $inlibc
-
-: Ok, but do we want to use it. vfork is reportedly unreliable in 
-: perl on Solaris 2.x, and probably elsewhere.
-case "$val" in
-$define)
-       echo " "
-       case "$usevfork" in
-       false) dflt='n';;
-       *) dflt='y';;
-       esac
-       cat <<'EOM'
-Perl can only use a vfork() that doesn't suffer from strict
-restrictions on calling functions or modifying global data in
-the child.  For example, glibc-2.1 contains such a vfork()
-that is unsuitable.  If your system provides a proper fork()
-call, chances are that you do NOT want perl to use vfork().
-
-EOM
-       rp="Do you still want to use vfork()?"
-       . ./myread
-       case "$ans" in
-       y|Y) ;;
-       *)
-               echo "Ok, we won't use vfork()."
-               val="$undef"
-               ;;
-       esac
-       ;;
-esac
-set d_vfork
-eval $setvar
-case "$d_vfork" in
-$define) usevfork='true';;
-*) usevfork='false';;
-esac
-
 : see if closedir exists
 set closedir d_closedir
 eval $inlibc
@@ -17732,7 +18498,7 @@ case "$d_closedir" in
 #endif
 #endif
 #endif
-#endif 
+#endif
 int main() { return closedir(opendir(".")); }
 EOM
        set try
@@ -17755,7 +18521,8 @@ EOM
 esac
 set d_void_closedir
 eval $setvar
-$rm -f try try.*
+$rm_try
+
 : see if there is a wait4
 set wait4 d_wait4
 eval $inlibc
@@ -17834,7 +18601,7 @@ EOCP
        rp="Doubles must be aligned on a how-many-byte boundary?"
        . ./myread
        alignbytes="$ans"
-       $rm -f try.c try
+       $rm_try
        ;;
 esac
 
@@ -17913,7 +18680,7 @@ int main(int argc, char *argv[])
     /* check that db.h & libdb are compatible */
     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
        printf("db.h and libdb are incompatible.\n") ;
-        exit(3);       
+        exit(3);
     }
 
     printf("db.h and libdb are compatible.\n") ;
@@ -17925,7 +18692,7 @@ int main(int argc, char *argv[])
     if (Version < 2003004) {
     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
        printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
-        exit(2);       
+        exit(2);
     }
 
     exit(0);
@@ -17964,13 +18731,13 @@ EOCP
                        ;;
                esac
        fi
-       $rm -f try.*
+       $rm_try
        ;;
 esac
 
 case "$i_db" in
 define)
-       : Check the return type needed for hash 
+       : Check the return type needed for hash
        echo " "
        echo "Checking return type needed for hash for Berkeley DB ..." >&4
        $cat >try.c <<EOCP
@@ -18007,7 +18774,7 @@ EOCP
                echo "Help:  I can't seem to compile the db test program." >&4
                echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
        fi
-       $rm -f try.*
+       $rm_try
        echo "Your version of Berkeley DB uses $db_hashtype for hash."
        ;;
 *)     db_hashtype=u_int32_t
@@ -18015,7 +18782,7 @@ EOCP
 esac
 case "$i_db" in
 define)
-       : Check the return type needed for prefix 
+       : Check the return type needed for prefix
        echo " "
        echo "Checking return type needed for prefix for Berkeley DB ..." >&4
        cat >try.c <<EOCP
@@ -18052,14 +18819,13 @@ EOCP
                echo "Help:  I can't seem to compile the db test program." >&4
                echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
        fi
-       $rm -f try.*
+       $rm_try
        echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
        ;;
 *)     db_prefixtype='size_t'
        ;;
 esac
 
-
 : How can we generate normalized random numbers ?
 echo " "
 echo "Looking for a random number function..." >&4
@@ -18165,7 +18931,7 @@ EOCP
                        rp="How many bits does your $randfunc() function produce?"
                        . ./myread
                        randbits="$ans"
-                       $rm -f try.c try
+                       $rm_try
                        drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
                        seedfunc="s$randfunc"
                        randseedtype=unsigned
@@ -18190,6 +18956,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'
@@ -18213,10 +18980,11 @@ else
        echo "I'm unable to compile the test program." >&4
        echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
 fi
-$rm -f try try.*
+$rm_try
 set ebcdic
 eval $setvar
 
+: Check how to flush
 echo " "
 $cat >&4 <<EOM
 Checking how to flush all pending stdio output...
@@ -18276,7 +19044,7 @@ int main() {
 #    endif
 #   endif
 #  endif
-# endif 
+# endif
 # ifdef HAS_STDIO_STREAM_ARRAY
     if (open_max > 0) {
       long i;
@@ -18285,7 +19053,7 @@ int main() {
                STDIO_STREAM_ARRAY[i]._file < open_max &&
                STDIO_STREAM_ARRAY[i]._flag)
                fflush(&STDIO_STREAM_ARRAY[i]);
-    }  
+    }
   }
 # endif
 #endif
@@ -18454,7 +19222,7 @@ EOM
                                        fflushall="`$cat try.out`"
                                fi
                        fi
-                       $rm -f core try.core core.try.*
+                       $rm_try
                        case "$fflushall" in
                        x)      $cat >&4 <<EOM
 Whew. Flushing explicitly all the stdio streams works.
@@ -18504,7 +19272,7 @@ We won't be flushing handles at all before fork/exec/popen.
 EOM
        ;;
 esac
-$rm -f try.* try$exe_ext
+$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.
@@ -18539,12 +19307,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>
@@ -18574,12 +19343,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>
@@ -18611,6 +19381,7 @@ else
 fi
 
 
+: Check 64bit sizes
 echo " "
 
 if $test X"$quadtype" != X; then
 if $test X"$sPRId64" = X; then
        echo "Cannot figure out how to print 64-bit integers." >&4
 fi
-
-$rm -f try try.*
+$rm_try
 
 fi
 
 case "$sPRId64" in
-'')    d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef"; 
-       d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef"; 
+'')    d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef";
+       d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef";
        ;;
-*)     d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define"; 
-       d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define"; 
+*)     d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define";
+       d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define";
        ;;
 esac
 
-
+: Check format strings for internal types
 echo " "
 $echo "Checking the format strings to be used for Perl's internal types..." >&4
 
@@ -18826,6 +19596,7 @@ case "$ivdformat" in
     ;;
 esac
 
+: Check format string for GID
 
 echo " "
 $echo "Checking the format string to be used for gids..." >&4
@@ -18873,7 +19644,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
 *)  groupstype="$gidtype";;
 esac
 
-echo " "
-echo "Checking if your $make program sets \$(MAKE)..." >&4
-case "$make_set_make" in
-'')
-       $sed 's/^X //' > testmake.mak << 'EOF'
-Xall:
-X      @echo 'maketemp="$(MAKE)"'
-EOF
-       case "`$make -f testmake.mak 2>/dev/null`" in
-       *maketemp=*) make_set_make='#' ;;
-       *)      make_set_make="MAKE=$make" ;;
-       esac
-       $rm -f testmake.mak
-       ;;
-esac
-case "$make_set_make" in
-'#') echo "Yup, it does.";;
-*) echo "Nope, it doesn't.";;
-esac
-
-: see what type is used for mode_t
-rp="What is the type used for file modes for system calls (e.g. fchmod())?"
-set mode_t modetype int stdio.h sys/types.h
-eval $typedef_ask
-
-: see if stdarg is available
-echo " "
-if $test `./findhdr stdarg.h`; then
-       echo "<stdarg.h> found." >&4
-       valstd="$define"
-else
-       echo "<stdarg.h> NOT found." >&4
-       valstd="$undef"
-fi
+: MAD = Misc Attribute Definition
 
-: see if varags is available
-echo " "
-if $test `./findhdr varargs.h`; then
-       echo "<varargs.h> found." >&4
+if $test $patchlevel -lt 9; then
+: MAD is not available in 5.8.x or earlier.
+    ans=n;
 else
-       echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
-fi
+    case "$mad" in
+    $define|true|[yY]*)        dflt='y' ;;
+    *)                 dflt='n' ;;
+    esac
+    cat <<EOM
 
-: set up the varargs testing programs
-$cat > varargs.c <<EOP
-#ifdef I_STDARG
-#include <stdarg.h>
-#endif
-#ifdef I_VARARGS
-#include <varargs.h>
-#endif
+Would you like to build with Misc Attribute Decoration? This is development
+work leading to a Perl 5 to Perl 6 convertor, which imposes a space and speed
+overhead on the interpreter.
 
-#ifdef I_STDARG
-int f(char *p, ...)
-#else
-int f(va_alist)
-va_dcl
-#endif
-{
-       va_list ap;
-#ifndef I_STDARG
-       char *p;
-#endif
-#ifdef I_STDARG
-       va_start(ap,p);
-#else
-       va_start(ap);
-       p = va_arg(ap, char *);
-#endif
-       va_end(ap);
-}
-EOP
-$cat > varargs <<EOP
-$startsh
-if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
-       echo "true"
-else
-       echo "false"
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+    rp='Build Perl with MAD?'
+    . ./myread
 fi
-$rm -f varargs$_o
-EOP
-chmod +x varargs
+case "$ans" in
+y|Y)   val="$define"
+       madlyh='madly.h madly.act madly.tab'
+       madlysrc='madly.c'
+       madlyobj="madly$_o" ;;
+*)     val="$undef"
+       madlyh=''
+       madlysrc=''
+       madlyobj='' ;;
+esac
+set mad
+eval $setvar
 
-: now check which varargs header should be included
+: check whether make sets MAKE
 echo " "
-i_varhdr=''
-case "$valstd" in
-"$define")
-       if `./varargs I_STDARG`; then
-               val='stdarg.h'
-       elif `./varargs I_VARARGS`; then
-               val='varargs.h'
-       fi
-       ;;
-*)
-       if `./varargs I_VARARGS`; then
-               val='varargs.h'
-       fi
-       ;;
-esac
-case "$val" in
+echo "Checking if your $make program sets \$(MAKE)..." >&4
+case "$make_set_make" in
 '')
-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
-       stdarg.h)
-               val="$define"; set i_stdarg; eval $setvar
-               val="$undef"; set i_varargs; eval $setvar
-               ;;
-       varargs.h)
-               val="$undef"; set i_stdarg; eval $setvar
-               val="$define"; set i_varargs; eval $setvar
-               ;;
+       $sed 's/^X //' > testmake.mak << 'EOF'
+Xall:
+X      @echo 'maketemp="$(MAKE)"'
+EOF
+       case "`$make -f testmake.mak 2>/dev/null`" in
+       *maketemp=*) make_set_make='#' ;;
+       *)      make_set_make="MAKE=$make" ;;
        esac
-       echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
+       $rm -f testmake.mak
+       ;;
 esac
-$rm -f varargs*
+case "$make_set_make" in
+'#') echo "Yup, it does.";;
+*) echo "Nope, it doesn't.";;
+esac
+
+: see what type is used for mode_t
+rp="What is the type used for file modes for system calls (e.g. fchmod())?"
+set mode_t modetype int stdio.h sys/types.h
+eval $typedef_ask
 
 : see if we need va_copy
 echo " "
@@ -19035,28 +19742,28 @@ ivfprintf(FILE *f, const char *fmt, va_list *valp)
 {
   return vfprintf(f, fmt, *valp);
 }
-int    
+
+int
 myvfprintf(FILE *f, const  char *fmt, va_list val)
 {
   return ivfprintf(f, fmt, &val);
 }
-      
+
 int
-myprintf(char *fmt, ...) 
+myprintf(char *fmt, ...)
 {
   va_list val;
   va_start(val, fmt);
-  return myvfprintf(stdout, fmt, val); 
-}         
+  return myvfprintf(stdout, fmt, val);
+}
 
 int
 main(int ac, char **av)
 {
   signal(SIGSEGV, exit);
 
-  myprintf("%s%cs all right, then\n", "that", '\'');                            
-  exit(0);      
+  myprintf("%s%cs all right, then\n", "that", '\'');
+  exit(0);
 }
 EOCP
        set try
@@ -19075,7 +19782,7 @@ EOCP
                need_va_copy="$define"
                ;;
        esac
-       $rm -f try.* core core.* *.core *.core.*
+       $rm_try
        ;;
 *)     echo "You don't have <stdarg.h>, not checking for va_copy()." >&4
        ;;
@@ -19235,9 +19942,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
@@ -19306,7 +20010,91 @@ 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 accepts
+echo "Checking max offsets that gmtime () accepts"
+
+case $i_values in
+    define) yyy="#include <values.h>" ;;
+    *)      yyy="" ;;
+    esac
+
+$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)
+{
+    tmp = gmtime (&t);
+    if (tmp == NULL || tmp->tm_year < -1900)
+       tmp = NULL;
+    else
+       pt = t;
+    } /* gm_check */
+
+int check_max ()
+{
+  tmp = NULL;
+  pt  = 0;
+#ifdef MAXLONG
+  gm_check (MAXLONG);
+#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) continue;
+      gm_check (x);
+      }
+    }
+  printf ("sGMTIME_max=%ld\n", pt);
+  return (0);
+  }
+
+int check_min ()
+{
+  tmp = NULL;
+  pt  = 0;
+#ifdef MINLONG
+  gm_check (MINLONG);
+#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);
+      }
+    }
+  printf ("sGMTIME_min=%ld\n", pt);
+  return (0);
+  }
+
+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
+    yyy=`$run ./try`
+    eval $yyy
+else
+    echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
+    fi
+$rm_try
+
+: check for type of arguments to select.
 case "$selecttype" in
 '') case "$d_select" in
        $define)
@@ -19315,7 +20103,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
@@ -19401,7 +20189,7 @@ $selecttype b;
 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
 #define NBITS  (NBYTES * 8)
 int main() {
-    char *s = malloc(NBYTES);
+    char *s = (char *)malloc(NBYTES);
     struct timeval t;
     int i;
     FILE* fp;
@@ -19454,7 +20242,7 @@ EOM
                        val=$ans
                        selectminbits="$val"
                fi
-               $rm -f try.* try
+               $rm_try
                ;;
        *)      : no select, so pick a harmless default
                selectminbits=$safebits
@@ -19464,28 +20252,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
@@ -19596,14 +20376,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
     }
@@ -19613,7 +20393,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++) {
@@ -19633,7 +20413,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
@@ -19733,14 +20514,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>
@@ -19792,7 +20574,7 @@ else
        size_t) echo "(You do have size_t, that might work. Some people are happy with just an int.)" ;;
        esac
 fi
-$rm -f try try.*
+$rm_try
 set d_socklen_t
 eval $setvar
 
@@ -19864,7 +20646,7 @@ int main()
                printf("$dflt\n");
        else if (sizeof(Size_t) == sizeof(int))
                printf("int\n");
-       else 
+       else
                printf("long\n");
        exit(0);
 }
@@ -19888,12 +20670,11 @@ EOM
        . ./myread
        ssizetype="$ans"
 fi
-$rm -f try try.*
+$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"
@@ -19901,7 +20682,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 " "
@@ -19927,12 +20708,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>
@@ -19961,6 +20743,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"    ;;
@@ -19998,7 +20781,7 @@ else
 fi
 
 
-
+: Check format string for UID
 echo " "
 $echo "Checking the format string to be used for uids..." >&4
 
@@ -20037,7 +20820,7 @@ case "$uidsign" in
        ;;
 esac
 
-
+: Check if site customization support was requested
 case "$usesitecustomize" in
     $define|true|[Yy]*)
        usesitecustomize="$define"
@@ -20078,6 +20861,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
@@ -20086,6 +20873,55 @@ eval $inhdr
 set fp_class.h i_fp_class
 eval $inhdr
 
+: see if gdbm.h is available
+set gdbm.h t_gdbm
+eval $inhdr
+case "$t_gdbm" in
+$define)
+       : see if gdbm_open exists
+       set gdbm_open d_gdbm_open
+       eval $inlibc
+       case "$d_gdbm_open" in
+       $undef)
+               t_gdbm="$undef"
+               echo "We won't be including <gdbm.h>"
+               ;;
+       esac
+       ;;
+esac
+val="$t_gdbm"
+set i_gdbm
+eval $setvar
+
+: 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
+
+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
+
 : see if this is a ieeefp.h system
 case "$i_ieeefp" in
 '' ) set ieeefp.h i_ieeefp
@@ -20105,46 +20941,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
@@ -20168,7 +20968,7 @@ EOM
                echo "We won't be including <net/errno.h>." >&4
                val="$undef"
        fi
-       $rm -f try.* try
+       $rm_try
        ;;
 esac
 set i_neterrno
@@ -20186,6 +20986,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
@@ -20211,7 +21012,7 @@ IA64 iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
 INLINE_INTRINSICS INTRINSICS INT64 interdata is68k ksr1
 LANGUAGE_C LARGE_FILE_API LARGEFILE64_SOURCE
 LARGEFILE_SOURCE LFS64_LARGEFILE LFS_LARGEFILE
-Linux LITTLE_ENDIAN LONG64 LONG_DOUBLE LONG_LONG
+LIBCATAMOUNT Linux LITTLE_ENDIAN LONG64 LONG_DOUBLE LONG_LONG
 LONGDOUBLE LONGLONG LP64 luna luna88k Lynx
 M68000 m68k m88100 m88k M88KBCS_TARGET M_COFF
 M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM M_SYS3
@@ -20230,7 +21031,7 @@ pa_risc PA_RISC1_1 PA_RISC2_0 PARAGON parisc
 pc532 pdp11 PGC PIC plexus PORTAR posix
 POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
 POSIX_C_SOURCE POSIX_SOURCE POWER
-PROTOTYPES PWB pyr QNX R3000 REENTRANT RES Rhapsody RISC6000
+PROTOTYPES PWB pyr QNX QK_USER R3000 REENTRANT RES Rhapsody RISC6000
 riscix riscos RT S390 SA110 scs SCO sequent sgi SGI_SOURCE SH3 sinix
 SIZE_INT SIZE_LONG SIZE_PTR SOCKET_SOURCE SOCKETS_SOURCE
 sony sony_news sonyrisc sparc sparclite spectrum
@@ -20350,7 +21151,7 @@ do
        -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A//' | $sed 's/\(.*\)(\(.*\))/\1=\2/';;
        esac
 done
-$rm -f try.c
+$rm_try
 EOS
 postprocess_cc_v=''
 chmod +x ccsym
@@ -20426,14 +21227,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
@@ -20444,7 +21245,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
@@ -20454,7 +21255,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
@@ -20466,10 +21267,6 @@ val=$val3; set i_termios; eval $setvar
 set stddef.h i_stddef
 eval $inhdr
 
-: see if this is a sunmath.h system
-set sunmath.h i_sunmath
-eval $inhdr
-
 : see if sys/access.h is available
 set sys/access.h i_sysaccess
 eval $inhdr
 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
@@ -20541,7 +21340,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
@@ -20558,10 +21356,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")
@@ -20573,26 +21367,7 @@ case "$d_vfork" in
        ;;
 esac
 
-: see if gdbm.h is available
-set gdbm.h t_gdbm
-eval $inhdr
-case "$t_gdbm" in
-$define)
-       : see if gdbm_open exists
-       set gdbm_open d_gdbm_open
-       eval $inlibc
-       case "$d_gdbm_open" in
-       $undef)
-               t_gdbm="$undef"
-               echo "We won't be including <gdbm.h>"
-               ;;
-       esac
-       ;;
-esac
-val="$t_gdbm"
-set i_gdbm
-eval $setvar
-
+: Check extensions
 echo " "
 echo "Looking for extensions..." >&4
 : If we are using the old config.sh, known_extensions may contain
@@ -20608,40 +21383,42 @@ nonxs_extensions=''
 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
 find_extensions='
     for xxx in *; do
-       case "$xxx" in
-           DynaLoader|dynaload) ;;
-           *)
-           if $test -f $xxx/$xxx.xs; then
-               known_extensions="$known_extensions $1$xxx";
-           elif $test -f $xxx/Makefile.PL; then
-               nonxs_extensions="$nonxs_extensions $1$xxx";
-           else
-               if $test -d $xxx -a $# -lt 10; then
-                   set $1$xxx/ $*;
-                   cd "$xxx";
-                   eval $find_extensions;
-                   cd ..;
-                   shift;
-               fi;
-           fi
-           ;;
-       esac;
+       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";
+           else
+               if $test -d $xxx -a $# -lt 10; then
+                   set $1$xxx/ $*;
+                   cd "$xxx";
+                   eval $find_extensions;
+                   cd ..;
+                   shift;
+               fi;
+           fi
+           ;;
+       esac;
     done'
 tdir=`pwd`
 cd "$rsrc/ext"
 set X
 shift
 eval $find_extensions
-# Special case:  Add in threads/shared since it is not picked up by the
-# recursive find above (and adding in general recursive finding breaks
-# SDBM_File/sdbm).  A.D.  10/25/2001.
-known_extensions="$known_extensions threads/shared"
-set X $nonxs_extensions
-shift
-nonxs_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"
 set X $known_extensions
 shift
 known_extensions="$*"
+set X $nonxs_extensions
+shift
+nonxs_extensions="$*"
 cd "$tdir"
 
 : Now see which are supported on this system.
@@ -20654,15 +21431,21 @@ for xxx in $known_extensions ; do
                esac
                ;;
        GDBM_File|gdbm_fil)
-               case "$i_gdbm" in 
+               case "$i_gdbm" in
                $define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        I18N/Langinfo|i18n_lan)
-               case "$i_langinfo$d_nl_langinfo" in 
+               case "$i_langinfo$d_nl_langinfo" in
                $define$define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
+       IPC/SysV|ipc/sysv)
+               : XXX Do we need a useipcsysv variable here
+               case "${d_msg}${d_sem}${d_shm}" in
+               *"${define}"*) avail_ext="$avail_ext $xxx" ;;
+               esac
+               ;;
        NDBM_File|ndbm_fil)
                case "$i_ndbm" in
                $define)
@@ -20677,32 +21460,36 @@ for xxx in $known_extensions ; do
                    ;;
                esac
                ;;
-       ODBM_File|odbm_fil) 
+       ODBM_File|odbm_fil)
                case "${i_dbm}${i_rpcsvcdbm}" in
                *"${define}"*)
-                   case "$osname-$use64bitint" in
-                   hpux-define)
-                       case "$libs" in
-                       *-ldbm*) avail_ext="$avail_ext $xxx" ;;
+                   case "$d_cplusplus" in
+                   define) ;; # delete as a function name will not work
+                   *)  case "$osname-$use64bitint" in
+                       hpux-define)
+                           case "$libs" in
+                           *-ldbm*) avail_ext="$avail_ext $xxx" ;;
+                           esac
+                           ;;
+                       *) avail_ext="$avail_ext $xxx" ;;
                        esac
                        ;;
-                   *) avail_ext="$avail_ext $xxx" ;;
                    esac
                    ;;
                esac
                ;;
-       POSIX|posix)
-               case "$useposix" in
+       Opcode|opcode)
+               case "$useopcode" in
                true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
-       Opcode|opcode)
-               case "$useopcode" in
+       POSIX|posix)
+               case "$useposix" in
                true|define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        Socket|socket)
-               case "$d_socket" in 
+               case "$d_socket" in
                true|$define|y)
                    case "$osname" in
                    beos) ;; # not unless BONE
@@ -20713,31 +21500,18 @@ for xxx in $known_extensions ; do
                ;;
        Sys/Syslog|sys/syslog)
                : XXX syslog requires socket
-               case "$d_socket" in 
+               case "$d_socket" in
                true|$define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        Thread|thread)
                 case "$usethreads" in
                 true|$define|y)
-                        case "$useithreads" in
-                        $undef|false|[nN]*) avail_ext="$avail_ext $xxx" ;;
+                        case "$use5005threads" in
+                        $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
                         esac
                esac
                ;;
-       XS/APItest|xs/apitest)
-               # This is just for testing.  Skip it unless we have dynamic loading.
-
-               case "$usedl" in
-               $define) avail_ext="$avail_ext $xxx" ;;
-               esac
-               ;;
-       XS/Typemap|xs/typemap)
-               # This is just for testing.  Skip it unless we have dynamic loading.
-               case "$usedl" in
-               $define) avail_ext="$avail_ext $xxx" ;;
-               esac
-               ;;
        threads|threads/shared)
                # threads and threads::shared are special cases.
                # To stop people from asking "Perl 5.8.0 was supposed
@@ -20752,10 +21526,22 @@ for xxx in $known_extensions ; do
                # --jhi
                avail_ext="$avail_ext $xxx"
                ;;
-       IPC/SysV|ipc/sysv)
-               : XXX Do we need a useipcsysv variable here
-               case "${d_msg}${d_sem}${d_shm}" in 
-               *"${define}"*) avail_ext="$avail_ext $xxx" ;;
+       Win32*)
+               case "$osname" in
+               cygwin) avail_ext="$avail_ext $xxx" ;;
+               esac
+               ;;
+       XS/APItest|xs/apitest)
+               # This is just for testing.  Skip it unless we have dynamic loading.
+
+               case "$usedl" in
+               $define) avail_ext="$avail_ext $xxx" ;;
+               esac
+               ;;
+       XS/Typemap|xs/typemap)
+               # This is just for testing.  Skip it unless we have dynamic loading.
+               case "$usedl" in
+               $define) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        *)      avail_ext="$avail_ext $xxx"
@@ -20844,11 +21630,11 @@ EOM
                previous)
                        if test X"$dynamic_ext" != X"$avail_ext"; then
                                $cat <<EOM
-NOTICE:  Your previous config.sh list may be incorrect. 
-The extensions now available to you are 
+NOTICE:  Your previous config.sh list may be incorrect.
+The extensions now available to you are
        ${avail_ext}
 but the default list from your previous config.sh is
-       ${dynamic_ext} 
+       ${dynamic_ext}
 
 EOM
                        fi
@@ -20880,7 +21666,7 @@ EOM
                shift
                dflt="$*"
                ;;
-       *)  dflt="$static_ext" 
+       *)  dflt="$static_ext"
                ;;
        esac
 
@@ -20896,8 +21682,8 @@ EOM
        ;;
 *)
        $cat <<EOM
-A number of extensions are supplied with $package.  Answer "none" 
-to include no extensions. 
+A number of extensions are supplied with $package.  Answer "none"
+to include no extensions.
 Note that DynaLoader is always built and need not be mentioned here.
 
 EOM
@@ -20909,11 +21695,11 @@ EOM
                previous)
                        if test X"$static_ext" != X"$avail_ext"; then
                                $cat <<EOM
-NOTICE:  Your previous config.sh list may be incorrect. 
-The extensions now available to you are 
+NOTICE:  Your previous config.sh list may be incorrect.
+The extensions now available to you are
        ${avail_ext}
 but the default list from your previous config.sh is
-       ${static_ext} 
+       ${static_ext}
 
 EOM
                        fi
@@ -20933,7 +21719,7 @@ EOM
        esac
        ;;
 esac
-#        
+#
 # Encode is a special case.  If we are building Encode as a static
 # extension, we need to explicitly list its subextensions as well.
 # For other nested extensions, this is handled automatically by
@@ -20978,7 +21764,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="$*"
            ;;
@@ -21011,9 +21797,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
 
@@ -21061,13 +21847,16 @@ $startsh
 # Configured by     : $cf_by
 # Target system     : $myuname
 
+EOT
+$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'
@@ -21113,7 +21902,6 @@ ccversion='$ccversion'
 cf_by='$cf_by'
 cf_email='$cf_email'
 cf_time='$cf_time'
-charsize='$charsize'
 chgrp='$chgrp'
 chmod='$chmod'
 chown='$chown'
@@ -21172,7 +21960,10 @@ d_bcopy='$d_bcopy'
 d_bsd='$d_bsd'
 d_bsdgetpgrp='$d_bsdgetpgrp'
 d_bsdsetpgrp='$d_bsdsetpgrp'
+d_builtin_choose_expr='$d_builtin_choose_expr'
+d_builtin_expect='$d_builtin_expect'
 d_bzero='$d_bzero'
+d_c99_variadic_macros='$d_c99_variadic_macros'
 d_casti32='$d_casti32'
 d_castneg='$d_castneg'
 d_charvspr='$d_charvspr'
@@ -21185,15 +21976,18 @@ d_closedir='$d_closedir'
 d_cmsghdr_s='$d_cmsghdr_s'
 d_const='$d_const'
 d_copysignl='$d_copysignl'
+d_cplusplus='$d_cplusplus'
 d_crypt='$d_crypt'
 d_crypt_r='$d_crypt_r'
 d_csh='$d_csh'
+d_ctermid='$d_ctermid'
 d_ctermid_r='$d_ctermid_r'
 d_ctime_r='$d_ctime_r'
 d_cuserid='$d_cuserid'
 d_dbl_dig='$d_dbl_dig'
 d_dbminitproto='$d_dbminitproto'
 d_difftime='$d_difftime'
+d_dir_dd_fd='$d_dir_dd_fd'
 d_dirfd='$d_dirfd'
 d_dirnamlen='$d_dirnamlen'
 d_dlerror='$d_dlerror'
@@ -21312,6 +22106,7 @@ d_grpasswd='$d_grpasswd'
 d_hasmntopt='$d_hasmntopt'
 d_htonl='$d_htonl'
 d_ilogbl='$d_ilogbl'
+d_inc_version_list='$d_inc_version_list'
 d_index='$d_index'
 d_inetaton='$d_inetaton'
 d_int64_t='$d_int64_t'
@@ -21326,6 +22121,7 @@ d_ldbl_dig='$d_ldbl_dig'
 d_libm_lib_version='$d_libm_lib_version'
 d_link='$d_link'
 d_localtime_r='$d_localtime_r'
+d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
 d_locconv='$d_locconv'
 d_lockf='$d_lockf'
 d_longdbl='$d_longdbl'
@@ -21368,6 +22164,7 @@ d_msgsnd='$d_msgsnd'
 d_msync='$d_msync'
 d_munmap='$d_munmap'
 d_mymalloc='$d_mymalloc'
+d_ndbm='$d_ndbm'
 d_nice='$d_nice'
 d_nl_langinfo='$d_nl_langinfo'
 d_nv_preserves_uv='$d_nv_preserves_uv'
@@ -21384,7 +22181,9 @@ d_phostname='$d_phostname'
 d_pipe='$d_pipe'
 d_poll='$d_poll'
 d_portable='$d_portable'
+d_printf_format_null='$d_printf_format_null'
 d_procselfexe='$d_procselfexe'
+d_pseudofork='$d_pseudofork'
 d_pthread_atfork='$d_pthread_atfork'
 d_pthread_attr_setscope='$d_pthread_attr_setscope'
 d_pthread_yield='$d_pthread_yield'
@@ -21464,8 +22263,10 @@ d_shmctl='$d_shmctl'
 d_shmdt='$d_shmdt'
 d_shmget='$d_shmget'
 d_sigaction='$d_sigaction'
+d_signbit='$d_signbit'
 d_sigprocmask='$d_sigprocmask'
 d_sigsetjmp='$d_sigsetjmp'
+d_sitearch='$d_sitearch'
 d_snprintf='$d_snprintf'
 d_sockatmark='$d_sockatmark'
 d_sockatmarkproto='$d_sockatmarkproto'
@@ -21521,6 +22322,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'
@@ -21568,6 +22370,7 @@ dlsrc='$dlsrc'
 doublesize='$doublesize'
 drand01='$drand01'
 drand48_r_proto='$drand48_r_proto'
+dtrace='$dtrace'
 dynamic_ext='$dynamic_ext'
 eagain='$eagain'
 ebcdic='$ebcdic'
@@ -21649,6 +22452,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'
@@ -21661,6 +22465,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'
@@ -21670,6 +22476,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'
@@ -21704,6 +22511,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'
@@ -21735,6 +22543,7 @@ inc_version_list='$inc_version_list'
 inc_version_list_init='$inc_version_list_init'
 incpath='$incpath'
 inews='$inews'
+initialinstalllocation='$initialinstalllocation'
 installarchlib='$installarchlib'
 installbin='$installbin'
 installhtml1dir='$installhtml1dir'
@@ -21803,6 +22612,10 @@ lpr='$lpr'
 ls='$ls'
 lseeksize='$lseeksize'
 lseektype='$lseektype'
+mad='$mad'
+madlyh='$madlyh'
+madlyobj='$madlyobj'
+madlysrc='$madlysrc'
 mail='$mail'
 mailx='$mailx'
 make='$make'
@@ -21842,6 +22655,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'
@@ -21892,9 +22706,12 @@ readdir64_r_proto='$readdir64_r_proto'
 readdir_r_proto='$readdir_r_proto'
 revision='$revision'
 rm='$rm'
+rm_try='$rm_try'
 rmail='$rmail'
 run='$run'
 runnm='$runnm'
+sGMTIME_max='$sGMTIME_max'
+sGMTIME_min='$sGMTIME_min'
 sPRIEUldbl='$sPRIEUldbl'
 sPRIFUldbl='$sPRIFUldbl'
 sPRIGUldbl='$sPRIGUldbl'
@@ -22021,6 +22838,7 @@ use64bitall='$use64bitall'
 use64bitint='$use64bitint'
 usecrosscompile='$usecrosscompile'
 usedl='$usedl'
+usedtrace='$usedtrace'
 usefaststdio='$usefaststdio'
 useithreads='$useithreads'
 uselargefiles='$uselargefiles'
@@ -22093,8 +22911,9 @@ 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
+       $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
@@ -22103,7 +22922,7 @@ if $test -f UU/config.sh; then
                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
+               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}"'"'