This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Porting/bench.pl: add --compact option
[perl5.git] / Configure
index fa8fbb0..cfbdaa1 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
-# working with this copy of Configure, you may wish to get metaconfig.
-# The dist package (which contains metaconfig) is available via SVN:
-#     svn co https://svn.sourceforge.net/svnroot/dist/trunk/dist
+# Note: this Configure script was generated automatically by the tool
+# called "metaconfig". Rather than working with this copy of Configure,
+# you may wish to get metaconfig. Perl uses a modified version of this
+# tool, available in the "dist" folder in the checkout of the git repo
+#    $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
+# The original dist package (including metaconfig) is available via SVN:
+#    $ svn co https://svn.code.sf.net/p/dist/code/trunk/dist
 #
 # Though this script was generated by metaconfig from metaunits, it is
 # OK to send patches against Configure itself. It's up to the Configure
@@ -26,9 +29,8 @@
 #     $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
 #
 # See Porting/pumpkin.pod for more information on metaconfig.
-#
 
-# Generated on Sat Mar 31 16:09:53 CEST 2012 [metaconfig 3.5 PL0]
+# Generated using [metaconfig 3.5 PL0]
 # (with additional metaconfig patches by perlbug@perl.org)
 
 cat >c1$$ <<EOF
@@ -67,7 +69,10 @@ EOF
        exit 1
 fi
 
-if test ! -c /dev/null ; then
+if test -f /sys/utilities/MultiView ; then
+       # AmigaOS, test -c for /dev/null is not useful
+       :
+elif test ! -c /dev/null ; then
        cat <<EOF
 ***
 *** I'm sorry, but /dev/null appears to be a file rather than a device.
@@ -91,7 +96,7 @@ esac
 : Proper separator for the PATH environment variable
 p_=:
 : 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 -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' 2>&1 ) 2>&1 >/dev/null ; then
        if test -n "$OS2_SHELL"; then
                p_=\;
                PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
@@ -99,7 +104,7 @@ if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' ) 2>&1 >/dev/null ; then
                is_os2=yes
        elif test -n "$DJGPP"; then
                case "X${MACHTYPE:-nonesuchmach}" in
-               *cygwin) ;;
+               *cygwin|*msys) ;;
                *) p_=\; ;;
                esac
        fi
@@ -206,8 +211,16 @@ ccsymbols=''
 cppccsymbols=''
 cppsymbols=''
 from=''
+hostgenerate=''
+hostosname=''
+hostperl=''
 run=''
 targetarch=''
+targetdir=''
+targetenv=''
+targethost=''
+targetmkdir=''
+targetport=''
 to=''
 usecrosscompile=''
 extern_C=''
@@ -312,6 +325,7 @@ RCSfile=''
 Revision=''
 Source=''
 State=''
+sysroot=''
 _a=''
 _exe=''
 _o=''
@@ -332,6 +346,7 @@ d_archlib=''
 installarchlib=''
 archname=''
 myarchname=''
+useversionedarchname=''
 d_atolf=''
 d_atoll=''
 baserev=''
@@ -362,10 +377,13 @@ cppstdin=''
 d__fwalk=''
 d_access=''
 d_accessx=''
+d_acosh=''
 d_aintl=''
 d_alarm=''
 asctime_r_proto=''
 d_asctime_r=''
+d_asinh=''
+d_atanh=''
 d_attribute_deprecated=''
 d_attribute_format=''
 d_attribute_malloc=''
@@ -375,6 +393,7 @@ d_attribute_pure=''
 d_attribute_unused=''
 d_attribute_warn_unused_result=''
 d_printf_format_null=''
+d_backtrace=''
 d_bcmp=''
 d_bcopy=''
 d_builtin_choose_expr=''
@@ -384,6 +403,7 @@ d_c99_variadic_macros=''
 d_casti32=''
 castflags=''
 d_castneg=''
+d_cbrt=''
 d_chown=''
 d_chroot=''
 d_chsize=''
@@ -393,6 +413,7 @@ d_closedir=''
 d_void_closedir=''
 d_cmsghdr_s=''
 d_const=''
+d_copysign=''
 d_copysignl=''
 d_cplusplus=''
 cryptlib=''
@@ -412,6 +433,7 @@ d_dbminitproto=''
 d_difftime=''
 d_dir_dd_fd=''
 d_dirfd=''
+d_dladdr=''
 d_dlerror=''
 d_dlopen=''
 d_dlsymun=''
@@ -440,6 +462,10 @@ endpwent_r_proto=''
 d_endsent=''
 d_endservent_r=''
 endservent_r_proto=''
+d_erf=''
+d_erfc=''
+d_exp2=''
+d_expm1=''
 d_faststdio=''
 d_fchdir=''
 d_fchmod=''
@@ -449,17 +475,25 @@ d_fcntl_can_lock=''
 d_fd_macros=''
 d_fd_set=''
 d_fds_bits=''
+d_fdim=''
+d_fegetround=''
 d_fgetpos=''
 d_finite=''
 d_finitel=''
 d_flexfnam=''
 d_flock=''
 d_flockproto=''
+d_fma=''
+d_fmax=''
+d_fmin=''
 d_fork=''
 d_fp_class=''
+d_fp_classl=''
 d_fpclass=''
+d_fp_classify=''
 d_fpclassify=''
 d_fpclassl=''
+d_fpgetround=''
 d_fpos64_t=''
 d_frexpl=''
 d_fs_data_s=''
@@ -559,6 +593,8 @@ d_gnulibc=''
 gnulibc_version=''
 d_hasmntopt=''
 d_htonl=''
+d_hypot=''
+d_ilogb=''
 d_ilogbl=''
 d_inetaton=''
 d_inetntop=''
@@ -567,23 +603,45 @@ d_int64_t=''
 d_isascii=''
 d_isblank=''
 d_isfinite=''
+d_isfinitel=''
 d_isinf=''
+d_isinfl=''
+d_isless=''
 d_isnan=''
 d_isnanl=''
+d_isnormal=''
+d_j0=''
+d_j0l=''
 d_killpg=''
+d_lc_monetary_2008=''
 d_lchown=''
 d_ldbl_dig=''
+d_lgamma=''
+d_lgamma_r=''
 d_libm_lib_version=''
 d_link=''
+d_llrint=''
+d_llrintl=''
+d_llround=''
+d_llroundl=''
 d_localtime_r=''
 d_localtime_r_needs_tzset=''
 localtime_r_proto=''
 d_locconv=''
 d_lockf=''
+d_log1p=''
+d_log2=''
+d_logb=''
+d_ldexpl=''
 d_longdbl=''
+longdblkind=''
 longdblsize=''
 d_longlong=''
 longlongsize=''
+d_lrint=''
+d_lrintl=''
+d_lround=''
+d_lroundl=''
 d_lseekproto=''
 d_lstat=''
 d_madvise=''
@@ -617,6 +675,10 @@ d_msgrcv=''
 d_msgsnd=''
 d_msync=''
 d_munmap=''
+d_nan=''
+d_nearbyint=''
+d_nextafter=''
+d_nexttoward=''
 d_nice=''
 d_nl_langinfo=''
 d_off64_t=''
@@ -638,6 +700,7 @@ d_pthread_attr_setscope=''
 d_pthread_yield=''
 d_sched_yield=''
 sched_yield=''
+d_ptrdiff_t=''
 d_qgcvt=''
 d_random_r=''
 random_r_proto=''
@@ -652,12 +715,20 @@ readdir_r_proto=''
 d_readlink=''
 d_readv=''
 d_recvmsg=''
+d_re_comp=''
+d_regcmp=''
+d_regcomp=''
+d_remainder=''
+d_remquo=''
 d_rename=''
+d_rint=''
 d_rmdir=''
+d_round=''
 d_safebcpy=''
 d_safemcpy=''
 d_sanemcmp=''
 d_sbrkproto=''
+d_scalbn=''
 d_scalbnl=''
 d_select=''
 d_sem=''
@@ -705,8 +776,6 @@ d_setservent_r=''
 setservent_r_proto=''
 d_setsid=''
 d_setvbuf=''
-d_sfio=''
-usesfio=''
 d_shm=''
 d_shmat=''
 d_shmatprototype=''
@@ -723,7 +792,10 @@ d_snprintf=''
 d_vsnprintf=''
 d_sockatmark=''
 d_sockatmarkproto=''
+d_ip_mreq=''
+d_ip_mreq_source=''
 d_ipv6_mreq=''
+d_ipv6_mreq_source=''
 d_msg_ctrunc=''
 d_msg_dontroute=''
 d_msg_oob=''
@@ -748,6 +820,7 @@ d_srandom_r=''
 srandom_r_proto=''
 d_sresgproto=''
 d_sresuproto=''
+d_stat=''
 d_statblks=''
 d_statfs_f_flags=''
 d_statfs_s=''
@@ -796,6 +869,7 @@ d_system=''
 d_tcgetpgrp=''
 d_tcsetpgrp=''
 d_telldirproto=''
+d_tgamma=''
 d_time=''
 timetype=''
 d_asctime64=''
@@ -809,7 +883,9 @@ clocktype=''
 d_times=''
 d_tmpnam_r=''
 tmpnam_r_proto=''
+d_trunc=''
 d_truncate=''
+d_truncl=''
 d_ttyname_r=''
 ttyname_r_proto=''
 d_tzname=''
@@ -834,7 +910,9 @@ d_charvspr=''
 d_vprintf=''
 d_wait4=''
 d_waitpid=''
+d_wcscmp=''
 d_wcstombs=''
+d_wcsxfrm=''
 d_wctomb=''
 d_writev=''
 dlext=''
@@ -870,6 +948,7 @@ html3direxp=''
 installhtml3dir=''
 i_arpainet=''
 i_assert=''
+i_bfd=''
 i_crypt=''
 db_hashtype=''
 db_prefixtype=''
@@ -882,9 +961,10 @@ i_rpcsvcdbm=''
 d_dirnamlen=''
 direntrytype=''
 i_dirent=''
-i_dld=''
 i_dlfcn=''
+i_execinfo=''
 i_fcntl=''
+i_fenv=''
 i_float=''
 i_fp=''
 i_fp_class=''
@@ -927,11 +1007,12 @@ d_pwgecos=''
 d_pwpasswd=''
 d_pwquota=''
 i_pwd=''
-i_sfio=''
+i_quadmath=''
 i_shadow=''
 i_socks=''
 i_stdbool=''
 i_stddef=''
+i_stdint=''
 i_stdlib=''
 i_string=''
 strings=''
@@ -984,6 +1065,10 @@ i_vfork=''
 d_inc_version_list=''
 inc_version_list=''
 inc_version_list_init=''
+doubleinfbytes=''
+doublenanbytes=''
+longdblinfbytes=''
+longdblnanbytes=''
 installprefix=''
 installprefixexp=''
 installstyle=''
@@ -998,6 +1083,7 @@ libperl=''
 shrpenv=''
 useshrplib=''
 glibpth=''
+incpth=''
 libpth=''
 loclibpth=''
 plibpth=''
@@ -1016,6 +1102,7 @@ d_PRIeldbl=''
 d_PRIfldbl=''
 d_PRIgldbl=''
 d_SCNfldbl=''
+doublekind=''
 sPRIEUldbl=''
 sPRIFUldbl=''
 sPRIGUldbl=''
@@ -1025,10 +1112,6 @@ sPRIgldbl=''
 sSCNfldbl=''
 lseeksize=''
 lseektype=''
-mad=''
-madlyh=''
-madlyobj=''
-madlysrc=''
 make_set_make=''
 d_mymalloc=''
 freetype=''
@@ -1045,6 +1128,9 @@ installman3dir=''
 man3dir=''
 man3direxp=''
 man3ext=''
+doublemantbits=''
+longdblmantbits=''
+nvmantbits=''
 modetype=''
 multiarch=''
 mydomain=''
@@ -1156,6 +1242,7 @@ scriptdirexp=''
 selectminbits=''
 selecttype=''
 sh=''
+targetsh=''
 sig_count=''
 sig_name=''
 sig_name_init=''
@@ -1192,6 +1279,7 @@ sitescript=''
 sitescriptexp=''
 sizesize=''
 sizetype=''
+d_libname_unique=''
 so=''
 socksizetype=''
 sharpbang=''
@@ -1219,6 +1307,7 @@ uidtype=''
 archname64=''
 use64bitall=''
 use64bitint=''
+usecbacktrace=''
 dtrace=''
 usedtrace=''
 usefaststdio=''
@@ -1236,6 +1325,7 @@ runnm=''
 usenm=''
 usensgetexecutablepath=''
 useperlio=''
+usequadmath=''
 usesocks=''
 d_oldpthreads=''
 use5005threads=''
@@ -1279,8 +1369,6 @@ installvendorscript=''
 vendorscript=''
 vendorscriptexp=''
 versiononly=''
-defvoidused=''
-voidflags=''
 yacc=''
 yaccflags=''
 CONFIG=''
@@ -1310,6 +1398,9 @@ elif test -f "/system/gnu_library/bin/ar.pm"; then
 elif test -n "$DJGPP"; then
 : DOS DJGPP
     _exe=".exe"
+elif test -f /kern/cookiejar; then
+: MiNT
+    _exe=""
 elif test -d c:/. -o -n "$is_os2" ; then
 : OS/2 or cygwin
     _exe=".exe"
@@ -1358,9 +1449,6 @@ libswanted=''
 ignore_versioned_solibs=''
 : set usethreads on the Configure command line to enable threads.
 usereentrant='undef'
-: full support for void wanted by default
-defvoidused=15
-
 ccname=''
 ccversion=''
 perllibs=''
@@ -1376,8 +1464,8 @@ libswanted_uselargefiles=''
 : set usesocks on the Configure command line to enable socks.
 : 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"
-libswanted="$libswanted m crypt sec util c cposix posix ucb bsd BSD"
+libswanted="cl pthread socket bind inet nsl ndbm gdbm dbm db malloc dl ld"
+libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
 : We probably want to search /usr/shlib before most other libraries.
 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
@@ -1420,16 +1508,20 @@ esac
 
 case "$sh" in
 '')    cat >&2 <<EOM
-$me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
+$me:  Fatal Error:  I can't find a Bourne Shell anywhere.
 
 Usually it's in /bin/sh.  How did you even get this far?
-Please contact me (Perl Maintainers) at perlbug@perl.org and 
+Please contact me (Perl Maintainers) at perlbug@perl.org and
 we'll try to straighten this all out.
 EOM
        exit 1
        ;;
 esac
 
+: When cross-compiling we need to separate the sh-to-run-Configure-with from the sh-to-use-in-Perl
+: default both to the same thing, cross-compilers can then set targetsh differently if they like
+targetsh=$sh
+
 : see if sh knows # comments
 if `$sh -c '#' >/dev/null 2>&1`; then
        shsharp=true
@@ -1587,7 +1679,6 @@ alldone=''
 error=''
 silent=''
 extractsh=''
-override=''
 knowitall=''
 rm -f optdef.sh posthint.sh
 cat >optdef.sh <<EOS
@@ -1617,7 +1708,7 @@ while test $# -gt 0; do
        -s) shift; silent=true; realsilent=true;;
        -E) shift; alldone=exit;;
        -K) shift; knowitall=true;;
-       -O) shift; override=true;;
+       -O) shift;;
        -S) shift; silent=true; extractsh=true;;
        -D)
                shift
@@ -1726,7 +1817,7 @@ Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
          -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.
+  -O : ignored for backward compatibility
   -S : perform variable substitutions on all .SH files (can mix with -f)
   -U : undefine symbol:
          -U symbol    symbol gets the value 'undef'
@@ -1773,6 +1864,11 @@ esac
 
 : run the defines and the undefines, if any, but leave the file out there...
 touch optdef.sh
+grep '\\' optdef.sh >/dev/null 2>&1
+if test $? = 0; then
+    echo "Configure does not support \\ in -D arguments"
+    exit 1
+fi
 . ./optdef.sh
 : create the posthint manipulation script and leave the file out there...
 touch posthint.sh
@@ -1781,8 +1877,8 @@ touch posthint.sh
 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
-ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
+case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
+ABYZ-abyz) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
 esac
 
@@ -1943,7 +2039,7 @@ true)
        echo "Fetching answers from $config_sh..."
        cd ..
        . $config_sh
-       test "$override" && . ./optdef.sh
+       . UU/optdef.sh
        echo " "
        . UU/extract
        rm -rf UU
@@ -2301,6 +2397,48 @@ EOH
        esac
 fi
 
+: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
+: This is primarily meant for cross-compile environments, and may fail to be useful in other cases
+if test "X$sysroot" = X; then
+    sysroot=""
+else
+    case "$cc" in
+       *gcc*|*g++*)
+           echo "Using $sysroot to find your headers and libraries, adding to ccflags"
+           # _sysroot is used in places where we need --sysroot=foo
+           # but using the rest of the flags could cause issues.
+           _sysroot="--sysroot=$sysroot";
+           case "$ccflags" in
+               *sysroot*) ;;
+               'undef'|*)
+               ccflags="$ccflags $_sysroot"
+           esac
+           case "$ldflags" in
+               *sysroot*) ;;
+               'undef'|*)
+               ldflags="$ldflags $_sysroot"
+           esac
+           case "$cppflags" in
+               *sysroot*) ;;
+               'undef'|*)
+               cppflags="$cppflags $_sysroot"
+           esac
+           # lddlflags updated below in lddlflags section;
+           # same with cccdlflags
+           ;;
+    esac
+
+    # Adjust some defaults to also use $sysroot
+    for var in xlibpth loclibpth locincpth glibpth; do
+       eval xxx=\$$var
+       eval $var=''
+       for path in $xxx; do
+           eval $var=\"\$$var $sysroot$path\"
+       done
+    done
+
+fi
+
 : find out where common programs are
 echo " "
 echo "Locating common programs..." >&4
@@ -2389,7 +2527,7 @@ uname
 zip
 "
 pth=`echo $PATH | sed -e "s/$p_/ /g"`
-pth="$pth /lib /usr/lib"
+pth="$pth $sysroot/lib $sysroot/usr/lib"
 for file in $loclist; do
        eval xxx=\$$file
        case "$xxx" in
@@ -2461,7 +2599,7 @@ egrep)
 esac
 case "$less" in
 '')    ;;
-*)     if $less -R </dev/null >/dev/null; then
+*)     if $less -R </dev/null >/dev/null 2>&1; then
               echo "Substituting less -R for less."
               less="$less -R"
               _less=$less
@@ -2589,11 +2727,11 @@ EOM
                # 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 
+               # 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 
+                       $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
@@ -2615,7 +2753,7 @@ EOM
                         echo "Cannot find myread, sorry.  Aborting." >&2
                         exit 1
                     fi
-                fi  
+                fi
                 case "$ans" in
                 [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
                 esac
@@ -2631,9 +2769,9 @@ cat <<EOS >checkcc
 $startsh
 EOS
 cat <<'EOSC' >>checkcc
-case "$cc" in        
+case "$cc" in
 '') ;;
-*)  $rm -f try try.*              
+*)  $rm -f try try.*
     $cat >try.c <<EOM
 int main(int argc, char *argv[]) {
   return 0;
@@ -2645,7 +2783,7 @@ EOM
         if $test X"$despair" = Xyes; then
            echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
         fi
-        $cat >&4 <<EOM         
+        $cat >&4 <<EOM
 You need to find a working C compiler.
 Either (purchase and) install the C compiler supplied by your OS vendor,
 or for a free C compiler try http://gcc.gnu.org/
@@ -2708,7 +2846,7 @@ case "$lns" in
                                ;;
                        *)      issymlink='' ;;
                        esac
-               fi              
+               fi
        fi
        if $test "X$issymlink" = X; then
                if $test -L sym 2>/dev/null; then
@@ -2738,38 +2876,41 @@ $define|true|[yY]*)
        *)      case "$lns:$issymlink" in
                *"ln"*" -s:"*"test -"?)
                        echo "Creating the symbolic links..." >&4
-                       echo "(First creating the subdirectories...)" >&4
                        cd ..
-                       awk '{print $1}' $src/MANIFEST | grep / | sed 's:/[^/]*$::' | sort -u | while true; do
-                               read directory
-                               test -z "$directory" && break
-                               mkdir -p $directory
-                       done
+                       awk '{print $1}' $src/MANIFEST | sed -e 's:/\([^/]*\)$: \1:' |
+                       awk 'NF == 1 {
+                               dir=".";
+                               file=$1 "";
+                            }
+                            NF == 2 {
+                               dir=$1 "";
+                               file=$2 "";
+                            }
+                            {
+                                print "# dir = ", dir, "file = ", file
+                                mf[dir] = mf[dir]" "source"/"dir"/"file;
+                            } END {
+                                for (d in mf) {
+                                    if (d != ".") { print("mkdir -p "d) }
+                                    print("ln -sf "mf[d]" "d);
+                                }
+                            }' source="$src" > UU/mksymlinks.$$
+                       sh UU/mksymlinks.$$
+                       rm UU/mksymlinks.$$
                        # Sanity check 1.
                        if test ! -d t/base; then
                                echo "Failed to create the subdirectories.  Aborting." >&4
                                exit 1
                        fi
-                       echo "(Then creating the symlinks...)" >&4
-                       awk '{print $1}' $src/MANIFEST | while true; do
-                               read filename
-                               test -z "$filename" && break
-                               if test -f $filename; then
-                                       if $issymlink $filename; then
-                                               rm -f $filename
-                                       fi
-                               fi
-                               if test -f $filename; then
-                                       echo "$filename already exists, not symlinking."
-                               else
-                                       ln -s $src/$filename $filename
-                               fi
-                       done
                        # Sanity check 2.
                        if test ! -f t/base/lex.t; then
                                echo "Failed to create the symlinks (t/base/lex.t missing).  Aborting." >&4
                                exit 1
                        fi
+                       if test ! -f win32/win32.c; then
+                               echo "Failed to create the symlinks (win32/win32.c missing).  Aborting." >&4
+                               exit 1
+                       fi
                        cd UU
                        ;;
                *)      echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
@@ -2781,71 +2922,101 @@ $define|true|[yY]*)
 esac
 
 : Check for Cross-Compilation
+if $test "X$targethost" = "X"; then
+    targethost=""
+fi
+if $test "X$targetenv" = "X"; then
+    targetenv=""
+fi
 case "$usecrosscompile" in
 $define|true|[yY]*)
        $echo "Cross-compiling..."
-        croak=''
-       case "$cc" in
-       *-*-gcc) # A cross-compiling gcc, probably.
-           targetarch=`$echo $cc|$sed 's/-gcc$//'`
-           ar=$targetarch-ar
+       croak=''
+       case "$cc" in
+       *-gcc*|*-g++*) # A cross-compiling gcc, probably.
+           # arm-linux-androideabi-gcc  -> arm-linux-androideabi
+           # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
+           targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
+           ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
            # leave out ld, choosing it is more complex
-           nm=$targetarch-nm
-           ranlib=$targetarch-ranlib
-           $echo 'extern int foo;' > try.c
-           set X `$cc -v -E try.c 2>&1 | $awk '/^#include </,/^End of search /'|$grep '/include'`
-           shift
-            if $test $# -gt 0; then
-               incpth="$incpth $*"
-               incpth="`$echo $incpth|$sed 's/^ //'`"
-                echo "Guessing incpth '$incpth'." >&4
-                for i in $*; do
-                   j="`$echo $i|$sed 's,/include$,/lib,'`"
-                   if $test -d $j; then
-                       libpth="$libpth $j"
-                   fi
-                done   
-               libpth="`$echo $libpth|$sed 's/^ //'`"
-                echo "Guessing libpth '$libpth'." >&4
-           fi
-           $rm -f try.c
-           ;;
+           nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
+           ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
+           # We are in a weird spot. Just before us, some values
+           # were 'saved', to be restored after the hints are
+           # run.  This means that the changes we made to ar,
+           # nm and ranlib will get reverted.
+           # To avoid that, we hijack the saving mechanism and
+           # have it save our new values.
+           for file in ar nm ranlib; do
+               eval xxx=\$$file
+               eval $file=$xxx$_exe
+               eval _$file=$xxx
+           done
+       ;;
        esac
        case "$targetarch" in
        '') echo "Targetarch not defined." >&4; croak=y ;;
-        *)  echo "Using targetarch $targetarch." >&4 ;;
-       esac
-       case "$incpth" in
-       '') echo "Incpth not defined." >&4; croak=y ;;
-        *)  echo "Using incpth '$incpth'." >&4 ;;
-       esac
-       case "$libpth" in
-       '') echo "Libpth not defined." >&4; croak=y ;;
-        *)  echo "Using libpth '$libpth'." >&4 ;;
-       esac
-       case "$usrinc" in
-       '') for i in $incpth; do
-               if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
-                   usrinc=$i
-                   echo "Guessing usrinc $usrinc." >&4
-                   break
-               fi
-           done
-           case "$usrinc" in
-           '') echo "Usrinc not defined." >&4; croak=y ;;
-           esac
-            ;;
-        *)  echo "Using usrinc $usrinc." >&4 ;;
+       *)  echo "Using targetarch $targetarch." >&4 ;;
        esac
        case "$targethost" in
        '') echo "Targethost not defined." >&4; croak=y ;;
-        *)  echo "Using targethost $targethost." >&4
+       *)  echo "Using targethost $targethost." >&4
        esac
        locincpth=' '
        loclibpth=' '
        case "$croak" in
        y) echo "Cannot continue, aborting." >&4; exit 1 ;;
        esac
+    : compile a host miniperl and generate_uudmap, unless we got passed them
+    if $test "X$hostperl" = X; then
+      echo "Building host miniperl and generate_uudmap binaries" >&4
+      before_host=`pwd`
+      cd ..
+      cd $src
+      src=`pwd`
+      rm -rf $src/host
+      mkdir $src/host
+      cd $src/host
+      $src/Configure -des -Dusedevel -Dmksymlinks
+      $make miniperl
+      case "$hostgenerate" in
+      '') $make generate_uudmap
+          hostgenerate=$src/host/generate_uudmap
+          ;;
+       "$undef") hostgenerate=''
+          ;;
+      esac
+      hostperl=$src/host/miniperl
+      cd $before_host
+    fi
+    hostosname=`$hostperl -le 'print $^O'`
+    ;;
+*)
+    usecrosscompile="$undef"
+    ;;
+esac
+
+: Define -Dtargethost=somecomputer to run compiled tests on another machine
+case "$targethost" in
+    '') echo "Checking for cross-compile" >&4
+    case "$usecrosscompile$multiarch" in
+       *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
+         if [ -f Makefile ]; then
+           echo " "
+           echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
+         else
+           echo "Configure done."
+         fi
+       exit 0
+       ;;
+     *) echo "No targethost for running compiler tests against defined, running locally" >&4
+        run=''
+        to=:
+        from=:
+        ;;
+    esac
+    ;;
+    *) echo "Using targethost $targethost." >&4
        case "$src" in
        /*) run=$src/Cross/run
            targetmkdir=$src/Cross/mkdir
@@ -2868,18 +3039,23 @@ $define|true|[yY]*)
        case "$targetfrom" in
        '') targetfrom=scp ;;
        esac
-       run=$run-$targetrun
-       to=$to-$targetto
-       from=$from-$targetfrom
+       run=$run-$targetrun
+       to=$to-$targetto
+       from=$from-$targetfrom
        case "$targetdir" in
        '')  targetdir=/tmp
-             echo "Guessing targetdir $targetdir." >&4
-             ;;
+            echo "Guessing targetdir $targetdir." >&4
+            ;;
        esac
        case "$targetuser" in
        '')  targetuser=root
-             echo "Guessing targetuser $targetuser." >&4
-             ;;
+            echo "Guessing targetuser $targetuser." >&4
+            ;;
+       esac
+       case "$targetport" in
+       '')  targetport=22
+            echo "Guessing targetport $targetport." >&4
+            ;;
        esac
        case "$targetfrom" in
        scp)    q=-q ;;
@@ -2889,6 +3065,7 @@ $define|true|[yY]*)
        ssh|rsh)
            cat >$run <<EOF
 #!/bin/sh
+env=''
 case "\$1" in
 -cwd)
   shift
@@ -2896,18 +3073,25 @@ case "\$1" in
   shift
   ;;
 esac
+case "\$1" in
+-env)
+  shift
+  env=\$1
+  shift
+  ;;
+esac
 case "\$cwd" in
 '') cwd=$targetdir ;;
 esac
 exe=\$1
 shift
-if $test ! -f \$exe.xok; then
-  $to \$exe
-  $touch \$exe.xok
-fi
-$targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@"
+$to \$exe
+$targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
 EOF
            ;;
+       adb)
+           $touch $run
+           ;;
        *)  echo "Unknown targetrun '$targetrun'" >&4
            exit 1
            ;;
@@ -2916,7 +3100,7 @@ EOF
        */Cross/mkdir)
            cat >$targetmkdir <<EOF
 #!/bin/sh
-$targetrun -l $targetuser $targethost "mkdir -p \$@"
+$targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
 EOF
            $chmod a+rx $targetmkdir
            ;;
@@ -2933,11 +3117,11 @@ do
   case "\$f" in
   /*)
     $targetmkdir \`dirname \$f\`
-    $targetto $q \$f $targetuser@$targethost:\$f            || exit 1
+    $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f           2>/dev/null  || exit 1
     ;;
   *)
     $targetmkdir $targetdir/\`dirname \$f\`
-    $targetto $q \$f $targetuser@$targethost:$targetdir/\$f || exit 1
+    $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
     ;;
   esac
 done
@@ -2973,7 +3157,7 @@ EOF
 for f in \$@
 do
   $rm -f \$f
-  $targetfrom $q $targetuser@$targethost:$targetdir/\$f . || exit 1
+  $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
 done
 exit 0
 EOF
@@ -3019,15 +3203,15 @@ EOF
 *)     run=''
        to=:
        from=:
-       usecrosscompile='undef'
+       usecrosscompile="$undef"
        targetarch=''
        ;;
 esac
 
 : see whether [:lower:] and [:upper:] are supported character classes
 echo " "
-case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
-ABYZ)
+case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | $tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
+ABYZ-abyz)
        echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
        up='[:upper:]'
        low='[:lower:]'
@@ -3097,9 +3281,13 @@ case "$config_sh" in
 '')
 myuname=`$uname -a 2>/dev/null`
 $test -z "$myuname" && myuname=`hostname 2>/dev/null`
+# Downcase everything to avoid ambiguity.
+# Remove slashes and single quotes so we can use parts of this in
+# directory and file names.
+# Remove newlines so myuname is sane to use elsewhere.
 # 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,['/],,g" | \
        ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
 newmyuname="$myuname"
 dflt=n
@@ -3169,12 +3357,11 @@ EOM
        $test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
        $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
        $test -f /bin/mips && /bin/mips && osname=mips
-       $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
-               $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
        $test -d /usr/apollo/bin && osname=apollo
        $test -f /etc/saf/_sactab && osname=svr4
-       $test -d /usr/include/minix && osname=minix
+       $test -d /usr/include/minix && osname=minix && osvers=`$uname -r`
        $test -f /system/gnu_library/bin/ar.pm && osname=vos
+       $test -f /sys/utilities/MultiView && osname=amigaos
        if $test -d /MachTen -o -d /MachTen_Folder; then
                osname=machten
                if $test -x /sbin/version; then
@@ -3207,7 +3394,6 @@ EOM
                        *) osname=mips ;;
                        esac;;
                [23]100) osname=mips ;;
-               next*) osname=next ;;
                i386*)
                        tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
                        if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
@@ -3246,6 +3432,9 @@ EOM
                        *) osvers=$tmp;;
                        esac
                        ;;
+               bitrig) osname=bitrig
+                       osvers="$3"
+                       ;;
                bsd386) osname=bsd386
                        osvers=`$uname -r`
                        ;;
@@ -3289,6 +3478,7 @@ EOM
                        case "$3" in
                        *)      osvers="$3" ;;
                        esac
+                       $test -f /system/lib/libandroid.so && osname=linux-android
                        ;;
                MiNT)   osname=mint
                        ;;
@@ -3301,7 +3491,6 @@ EOM
                        *) osname=newsos ;;
                        esac
                        ;;
-               next*) osname=next ;;
                nonstop-ux) osname=nonstopux ;;
                openbsd) osname=openbsd
                        osvers="$3"
@@ -3438,8 +3627,42 @@ EOM
         case "$targetarch" in
         '') ;;
         *)  hostarch=$osname
-            osname=`echo $targetarch|sed 's,^[^-]*-,,'`
-            osvers=''
+            case "$targetarch" in
+                nto*|*-nto-*)
+                    # Will load qnx.sh, which should change osname to nto
+                    osname=qnx
+                    osvers=''
+                    ;;
+                *linux-android*)
+                    # Catch arm-linux-androideabi, mipsel-linux-android,
+                    # and i686-linux-android
+                    osname=linux-android
+                    osvers=''
+                    ;;
+                *linux*)
+                    # Something like arm-linux-gnueabihf is really just
+                    # plain linux.
+                    osname=linux
+                    osvers=''
+                    ;;
+                *solaris*|*sunos*)
+                    osname=solaris
+                    # XXX perhaps we should just assume
+                    # osvers to be 2, or maybe take the value
+                    # from targetarch. Using $run before the
+                    # hints are run is somewhat icky.
+                    set X `$run $uname -a 2>/dev/null`
+                    shift
+                    case "$3" in
+                        5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
+                        *)  osvers="$3" ;;
+                    esac
+                    ;;
+                *)
+                   osname=`echo $targetarch|sed 's,^[^-]*-,,'`
+                   osvers=''
+                ;;
+            esac
             ;;
         esac
 
@@ -3569,7 +3792,7 @@ cd UU
        hint=previous
        ;;
 esac
-test "$override" && . ./optdef.sh
+. ./optdef.sh
 
 : Restore computed paths
 for file in $loclist $trylist; do
@@ -3984,7 +4207,7 @@ else
 fi
 
 : determine installation prefix for where package is to be installed.
-if $afs; then 
+if $afs; then
 $cat <<EOM
 
 Since you are running AFS, I need to distinguish the directory in which
@@ -4116,15 +4339,15 @@ 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 }'`
+                $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
        api_versionstring=`echo $api_revision $api_version $api_subversion | \
-                $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
+                $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
        ;;
 *)
        version=`echo $revision $patchlevel $subversion | \
-                $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
+                $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
        api_versionstring=`echo $api_revision $api_version $api_subversion | \
-                $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
+                $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
        ;;
 esac
 : Special case the 5.005_xx maintenance series, which used 5.005
@@ -4146,13 +4369,11 @@ $define|true|[yY]*)     dflt='y';;
 esac
 cat <<EOM
 
-Perl can be built to take advantage of threads on some systems.
+Perl can be built to offer a form of threading support 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.
+and uses slightly more memory than plain Perl.
 
 If this doesn't make any sense to you, just accept the default '$dflt'.
 EOM
@@ -4168,22 +4389,14 @@ 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';;
+               $define|true|[yY]*)
+                       echo "5.005 threads are no longer supported"
+                       exit 1
+               ;;
        esac
        case "$useithreads" in
                $undef|false|[nN]*) dflt='n';;
@@ -4339,8 +4552,8 @@ 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
+$cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null
+if test -f /osf_boot || $contains 'OSF/1' $sysroot/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
@@ -4511,10 +4724,27 @@ case "$gccversion" in
     $rm -f try try.*
 esac
 
+# gcc 4.9 by default does some optimizations that break perl.
+# see ticket 121505.
+#
+# The -fwrapv disables those optimizations (and probably others,) so
+# for gcc 4.9 (and later, since the optimizations probably won't go
+# away), add -fwrapv unless the user requests -fno-wrapv, which
+# disables -fwrapv, or if the user requests -fsanitize=undefined,
+# which turns the overflows -fwrapv ignores into runtime errors.
+case "$gccversion" in
+4.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*)
+    case "$ccflags" in
+    *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
+    *) ccflags="$ccflags -fwrapv" ;;
+    esac
+esac
+
 : What should the include directory be ?
+: Use sysroot if set, so findhdr looks in the right place.
 echo " "
 $echo $n "Hmm...  $c"
-dflt='/usr/include'
+dflt="$sysroot/usr/include"
 incpath=''
 mips_type=''
 if $test -f /bin/mips && /bin/mips; then
@@ -4524,7 +4754,7 @@ if $test -f /bin/mips && /bin/mips; then
 /bsd43
 #endif
 EOCP
-       if cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
+       if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
                dflt='/bsd43/usr/include'
                incpath='/bsd43'
                mips_type='BSD 4.3'
@@ -4572,7 +4802,7 @@ if test ! -f cppstdin; then
                # locations but we'll cheat by using the -M flag.
                echo 'cat >.$$.c; rm -f .$$.u; '"$cc"' ${1+"$@"} -M -c .$$.c 2>/dev/null; test -s .$$.u && awk '"'"'$2 ~ /\.h$/ { print "# 0 \""$2"\"" }'"'"' .$$.u; rm -f .$$.o .$$.u; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' > cppstdin
        else
-               echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
+               echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
        fi
 else
        echo "Keeping your $hint cppstdin wrapper."
@@ -4615,37 +4845,37 @@ elif echo 'Maybe "'"$cc"' -E" will work...'; \
        $cc -E <testcpp.c >testcpp.out 2>&1; \
        $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
        echo "Yup, it does."
-       x_cpp="$cc -E"
+       x_cpp="$cc $cppflags -E"
        x_minus='';
 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
        $cc -E - <testcpp.c >testcpp.out 2>&1; \
        $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
        echo "Yup, it does."
-       x_cpp="$cc -E"
+       x_cpp="$cc $cppflags -E"
        x_minus='-';
 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
        $cc -P <testcpp.c >testcpp.out 2>&1; \
        $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
        echo "Yipee, that works!"
-       x_cpp="$cc -P"
+       x_cpp="$cc $cppflags -P"
        x_minus='';
 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
        $cc -P - <testcpp.c >testcpp.out 2>&1; \
        $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
        echo "At long last!"
-       x_cpp="$cc -P"
+       x_cpp="$cc $cppflags -P"
        x_minus='-';
 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
        $cpp <testcpp.c >testcpp.out 2>&1; \
        $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
        echo "It works!"
-       x_cpp="$cpp"
+       x_cpp="$cpp $cppflags"
        x_minus='';
 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
        $cpp - <testcpp.c >testcpp.out 2>&1; \
        $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
        echo "Hooray, it works!  I was beginning to wonder."
-       x_cpp="$cpp"
+       x_cpp="$cpp $cppflags"
        x_minus='-';
 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
        $wrapper <testcpp.c >testcpp.out 2>&1; \
@@ -4705,11 +4935,90 @@ case "$cppstdin" in
 esac
 $rm -f testcpp.c testcpp.out
 
+: Adjust cppfilter for path component separator
+case "$osname" in
+vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
+os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
+*)   cppfilter='' ;;
+esac
+
+: Use gcc to determine libpth and incpth
+# If using gcc or clang, we can get better values for libpth, incpth
+# and usrinc directly from the compiler.
+# Note that ccname for clang is also gcc.
+case "$ccname" in
+    gcc)
+       $echo 'extern int foo;' > try.c
+       set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
+       shift
+       if $test $# -gt 0; then
+           incpth="$incpth $*"
+           incpth="`$echo $incpth|$sed 's/^ //'`"
+           for i in $*; do
+               j="`$echo $i|$sed 's,/include$,/lib,'`"
+               if $test -d $j; then
+                   libpth="$libpth $j"
+               fi
+           done
+           libpth="`$echo $libpth|$sed 's/^ //'`"
+           for xxx in $libpth $loclibpth $plibpth $glibpth; do
+               if $test -d $xxx; then
+                   case " $libpth " in
+                   *" $xxx "*) ;;
+                   *) libpth="$libpth $xxx";;
+                   esac
+               fi
+           done
+       fi
+       $rm -f try.c
+       case "$usrinc" in
+       '') for i in $incpth; do
+               if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
+                   usrinc="$i"
+                   break
+               fi
+           done
+           ;;
+       esac
+
+       case "$usecrosscompile" in
+       $define|true|[yY]*)
+           case "$incpth" in
+               '') echo "Incpth not defined." >&4; croak=y ;;
+               *)  echo "Using incpth '$incpth'." >&4 ;;
+           esac
+           case "$libpth" in
+               '') echo "Libpth not defined." >&4; croak=y ;;
+               *)  echo "Using libpth '$libpth'." >&4 ;;
+           esac
+           case "$usrinc" in
+               '') echo "Usrinc not defined." >&4; croak=y ;;
+               *)  echo "Using usrinc $usrinc." >&4 ;;
+           esac
+           case "$croak" in
+               y)
+               if test "X$sysroot" = X; then
+                   echo "Cannot continue, aborting." >&4; exit 1
+               else
+                   echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
+               fi
+               ;;
+           esac
+           ;;
+       esac
+    ;;
+esac
+
+: Default value for incpth is just usrinc
+case "$incpth" in
+'') incpth="$usrinc";;
+esac
+
 : Set private lib path
 case "$plibpth" in
 '') if ./mips; then
-               plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
-       fi;;
+       plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
+    fi;;
 esac
 case "$libpth" in
 ' ') dlist='';;
@@ -4718,7 +5027,6 @@ case "$libpth" in
 esac
 
 : Now check and see which directories actually exist, avoiding duplicates
-libpth=''
 for xxx in $dlist
 do
     if $test -d $xxx; then
@@ -4736,6 +5044,14 @@ know not to be holding relevant libraries, and add any that are needed.
 Say "none" for none.
 
 EOM
+
+if test "X$sysroot" != X; then
+    $cat <<EOM
+You have set sysroot to $sysroot, please supply the directories excluding sysroot
+
+EOM
+fi
+
 case "$libpth" in
 '') dflt='none';;
 *)
@@ -4773,6 +5089,25 @@ rp='What is the file extension used for shared libraries?'
 . ./myread
 so="$ans"
 
+: Does target system insist that shared library basenames are unique
+$cat << EOM
+
+Some dynamic loaders assume that the *basename* of shared library filenames
+are globally unique.  We'll default this to undef as we assume your system
+is not this weird. Set to defined if you're on one of them.
+
+EOM
+
+dflt='n'
+rp='Make shared library basenames unique?'
+. ./myread
+case "$ans" in
+y|Y) val="$define" ;;
+*)   val="$undef"  ;;
+esac
+set d_libname_unique
+eval $setvar
+
 : Define several unixisms.
 : Hints files or command line option can be used to override them.
 : The convoluted testing is in case hints files set either the old
@@ -4884,6 +5219,12 @@ EOM
     esac
 fi
 
+: Check if quadmath is requested
+case "$usequadmath" in
+"$define"|true|[yY]*) usequadmath="$define" ;;
+*)                    usequadmath="$undef"  ;;
+esac
+
 : Looking for optional libraries
 echo " "
 echo "Checking for optional libraries..." >&4
@@ -4897,6 +5238,12 @@ esac
 case "$usesocks" in
 "$define") libswanted="$libswanted socks5 socks5_sh" ;;
 esac
+case "$usecbacktrace" in
+"$define") libswanted="$libswanted bfd" ;;
+esac
+case "$usequadmath" in
+"$define") libswanted="$libswanted quadmath" ;;
+esac
 libsfound=''
 libsfiles=''
 libsdirs=''
@@ -4911,6 +5258,9 @@ for thislib in $libswanted; do
                xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|sed -n '$p'`
                $test -f "$xxx" && eval $libscheck
                $test -f "$xxx" && libstyle=shared
+               xxx=`ls $thisdir/lib$thislib.[0-9].$so 2>/dev/null|sed -n '$p'`
+               $test -f "$xxx" && eval $libscheck
+               $test -f "$xxx" && libstyle=shared
            fi
            if test ! -f "$xxx"; then
                xxx=$thisdir/lib$thislib.$so
@@ -5047,8 +5397,9 @@ esac
 checkccflag='check=$1; flag=$2; callback=$3;
 echo " ";
 echo "Checking if your compiler accepts $flag" 2>&1;
+[ "X$sysroot" != "X" ] && echo "For sysroot = $sysroot";
 echo "int main(void) { return 0; }" > gcctest.c;
-if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && ./gcctest; then
+if $cc $_sysroot -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
     echo "Yes, it does." 2>&1;
     if $test -s gcctest.out ; then
         echo "But your platform does not like it:";
@@ -5109,9 +5460,20 @@ default|recommended)
        # 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
+       case "$osname" in
+       amigaos) ;; # -fstack-protector builds but doesn't work
+       *)      case "$gccversion" in
+               ?*)     set stack-protector-strong -fstack-protector-strong
+                       eval $checkccflag
+                       case "$dflt" in
+                       *-fstack-protector-strong*) ;; # It got added.
+                       *) # Try the plain/older -fstack-protector.
+                          set stack-protector -fstack-protector
+                          eval $checkccflag
+                          ;;
+                       esac
+                       ;;
+               esac
                ;;
        esac
        ;;
@@ -5187,7 +5549,12 @@ esac
 : the following weeds options from ccflags that are of no interest to cpp
 case "$cppflags" in
 '') cppflags="$ccflags" ;;
-*)  cppflags="$cppflags $ccflags" ;;
+*)  set X $ccflags; shift
+    case " $cppflags " in
+    *" $1 "*) ;;  # Try to avoid doubling the cppflags.
+    *) cppflags="$cppflags $ccflags" ;;
+    esac
+    ;;
 esac
 case "$gccversion" in
 1*) cppflags="$cppflags -D__GNUC__"
@@ -5254,10 +5621,16 @@ case "$ldflags" in
 esac
 # See note above about -fstack-protector
 case "$ccflags" in
-*-fstack-protector*) 
+*-fstack-protector-strong*)
+       case "$dflt" in
+       *-fstack-protector-strong*) ;; # Don't add it again
+       *) dflt="$dflt -fstack-protector-strong" ;;
+       esac
+       ;;
+*-fstack-protector*)
        case "$dflt" in
        *-fstack-protector*) ;; # Don't add it again
-       *) dflt="$dflt -fstack-protector" ;; 
+       *) dflt="$dflt -fstack-protector" ;;
        esac
        ;;
 esac
@@ -5331,20 +5704,7 @@ if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; t
                xxx=`$run ./try`
                case "$xxx" in
                "Ok") dflt=n ;;
-               *)      echo 'The program compiled OK, but produced no output.' >> try.msg
-                       case " $libs " in
-                       *" -lsfio "*)
-                               cat >> try.msg <<'EOQS'
-If $libs contains -lsfio, and sfio is mis-configured, then it
-sometimes (apparently) runs and exits with a 0 status, but with no
-output!  It may have to do with sfio's use of _exit vs. exit.
-
-EOQS
-                               rp="You have a big problem.  Shall I abort Configure"
-                               dflt=y
-                               ;;
-                       esac
-                       ;;
+               *)    echo 'The program compiled OK, but produced no output.' >> try.msg ;;
                esac
        else
                echo "The program compiled OK, but exited with status $?." >>try.msg
@@ -5398,6 +5758,11 @@ $cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs;'
 echo " "
 echo "Computing filename position in cpp output for #include directives..." >&4
 case "$osname" in
+amigaos) fieldn=3 ;;  # Workaround for a bug in abc (pdksh).
+esac
+case "$fieldn" in
+'')
+case "$osname" in
 vos) testaccess=-e ;;
 *)   testaccess=-r ;;
 esac
@@ -5422,6 +5787,8 @@ EOF
 chmod +x fieldn
 fieldn=`./fieldn`
 $rm -f foo.c fieldn
+;;
+esac
 case $fieldn in
 '') pos='???';;
 1) pos=first;;
@@ -5431,17 +5798,12 @@ case $fieldn in
 esac
 echo "Your cpp writes the filename in the $pos field of the line."
 
-case "$osname" in
-vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
-os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
-*)   cppfilter='' ;;
-esac
 : locate header file
 $cat >findhdr <<EOF
 $startsh
 wanted=\$1
 name=''
-for usrincdir in $usrinc
+for usrincdir in $incpth
 do
        if test -f \$usrincdir/\$wanted; then
                echo "\$usrincdir/\$wanted"
@@ -5857,6 +6219,59 @@ if $test -f use64bitint.cbu; then
 fi
 case "$use64bitint" in
 "$define"|true|[yY]*)
+       : This test was common to all the OpenBSD forks, and seems harmless for
+       : other platforms:
+       echo " "
+       echo "Checking if your C library has broken 64-bit functions..." >&4
+       cat >try.c <<EOCP
+#include <stdio.h>
+typedef $uquadtype myULL;
+int main (void)
+{
+    struct {
+       double d;
+       myULL  u;
+    } *p, test[] = {
+       {4294967303.15, 4294967303ULL},
+       {4294967294.2,  4294967294ULL},
+       {4294967295.7,  4294967295ULL},
+       {0.0, 0ULL}
+    };
+    for (p = test; p->u; p++) {
+       myULL x = (myULL)p->d;
+       if (x != p->u) {
+           printf("buggy\n");
+           return 0;
+       }
+    }
+    printf("ok\n");
+    return 0;
+}
+EOCP
+       set try
+       if eval $compile_ok; then
+           libcquad=`$run ./try`
+           echo "Your C library's 64-bit functions are $libcquad."
+       else
+           echo "(I can't seem to compile the test program.)"
+           echo "Assuming that your C library's 64-bit functions are ok."
+           libcquad="ok"
+       fi
+       $rm_try
+
+       case "$libcquad" in
+           buggy*)
+               cat >&4 <<EOM
+
+*** You have a C library with broken 64-bit functions.
+*** 64-bit support does not work reliably in this configuration.
+*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
+*** Cannot continue, aborting.
+
+EOM
+               exit 1
+               ;;
+       esac
        case "$longsize" in
        4) case "$archname64" in
           '') archname64=64int ;;
        ;;
 esac
 
-: check for length of double
+: Check if we are using the GNU C library
 echo " "
-case "$doublesize" in
-'')
-       echo "Checking to see how big your double precision numbers are..." >&4
-       $cat >try.c <<EOCP
+echo "Checking for GNU C Library..." >&4
+cat >try.c <<'EOCP'
+/* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
+   alone are insufficient to distinguish different versions, such as
+   2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
+   libc version 2.1.0.      A. Dougherty,  June 3, 2002.
+*/
 #include <stdio.h>
-#$i_stdlib I_STDLIB
-#ifdef I_STDLIB
-#include <stdlib.h>
-#endif
-int main()
+int main(void)
 {
-    printf("%d\n", (int)sizeof(double));
-    exit(0);
+#ifdef __GLIBC__
+#   ifdef __GLIBC_MINOR__
+#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
+#           include <gnu/libc-version.h>
+           printf("%s\n",  gnu_get_libc_version());
+#       else
+           printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
+#       endif
+#   else
+       printf("%d\n",  __GLIBC__);
+#   endif
+    return 0;
+#else
+    return 1;
+#endif
 }
 EOCP
-       set try
-       if eval $compile_ok; then
-               doublesize=`$run ./try`
-               echo "Your double is $doublesize bytes long."
-       else
-               dflt='8'
-               echo "(I can't seem to compile the test program.  Guessing...)"
-               rp="What is the size of a double precision number (in bytes)?"
-               . ./myread
-               doublesize="$ans"
-       fi
-       ;;
-esac
-$rm_try
-
-: check for long doubles
-echo " "
-echo "Checking to see if you have long double..." >&4
-echo 'int main() { long double x = 7.0; }' > try.c
 set try
-if eval $compile; then
+if eval $compile_ok && $run ./try > glibc.ver; then
        val="$define"
-       echo "You have long double."
+       gnulibc_version=`$cat glibc.ver`
+       echo "You are using the GNU C Library version $gnulibc_version"
 else
        val="$undef"
-       echo "You do not have long double."
+       gnulibc_version=''
+       echo "You are not using the GNU C Library"
 fi
-$rm_try
-set d_longdbl
+$rm_try glibc.ver
+set d_gnulibc
 eval $setvar
 
-: check for length of long double
-case "${d_longdbl}${longdblsize}" in
-$define)
-       echo " "
-       echo "Checking to see how big your long doubles are..." >&4
-       $cat >try.c <<'EOCP'
-#include <stdio.h>
-int main()
-{
-       printf("%d\n", sizeof(long double));
-}
-EOCP
-       set try
-       set try
-       if eval $compile; then
-               longdblsize=`$run ./try`
-               echo "Your long doubles are $longdblsize bytes long."
-       else
-               dflt='8'
+: see if nm is to be used to determine whether a symbol is defined or not
+case "$usenm" in
+'')
+       dflt=''
+       case "$d_gnulibc" in
+       "$define")
                echo " "
-               echo "(I can't seem to compile the test program.  Guessing...)" >&4
-               rp="What is the size of a long double (in bytes)?"
-               . ./myread
-               longdblsize="$ans"
-       fi
-       if $test "X$doublesize" = "X$longdblsize"; then
-               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
-       ;;
-esac
-$rm_try
-
-: determine the architecture name
-echo " "
-if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
-       tarch=`arch`"-$osname"
-elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
-       if uname -m > tmparch 2>&1 ; then
-               tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
-                       -e 's/$/'"-$osname/" tmparch`
-       else
-               tarch="$osname"
-       fi
-       $rm -f tmparch
-else
-       tarch="$osname"
-fi
-case "$myarchname" in
-''|"$tarch") ;;
-*)
-       echo "(Your architecture name used to be $myarchname.)"
-       archname=''
-       ;;
-esac
-case "$targetarch" in
-'') ;;
-*)  archname=`echo $targetarch|sed 's,^[^-]*-,,'` ;;
-esac
-myarchname="$tarch"
-case "$archname" in
-'') dflt="$tarch";;
-*) dflt="$archname";;
-esac
-rp='What is your architecture name'
-. ./myread
-archname="$ans"
-case "$usethreads" in
-$define)
-       echo "Threads selected." >&4
-       case "$archname" in
-        *-thread*) echo "...and architecture name already has -thread." >&4
-                ;;
-        *)      archname="$archname-thread"
-                echo "...setting architecture name to $archname." >&4
-                ;;
-        esac
-       ;;
-esac
-case "$usemultiplicity" in
-$define)
-       echo "Multiplicity selected." >&4
-       case "$archname" in
-        *-multi*) echo "...and architecture name already has -multi." >&4
-                ;;
-        *)      archname="$archname-multi"
-                echo "...setting architecture name to $archname." >&4
-                ;;
-        esac
-       ;;
-esac
-case "$use64bitint$use64bitall" in
-*"$define"*)
-       case "$archname64" in
-       '')
-               echo "This architecture is naturally 64-bit, not changing architecture name." >&4
-               ;;
-       *)
-               case "$use64bitint" in
-               "$define") echo "64 bit integers selected." >&4 ;;
-               esac
-               case "$use64bitall" in
-               "$define") echo "Maximal 64 bitness selected." >&4 ;;
-               esac
-               case "$archname" in
-               *-$archname64*) echo "...and architecture name already has $archname64." >&4
-                       ;;
-               *)      archname="$archname-$archname64"
-                       echo "...setting architecture name to $archname." >&4
-                       ;;
-               esac
+               echo "nm probably won't work on the GNU C Library." >&4
+               dflt=n
                ;;
        esac
-esac
-case "$uselongdouble" in
-$define)
-       echo "Long doubles selected." >&4
-       case "$longdblsize" in
-       $doublesize)
-               echo "...but long doubles are equal to doubles, not changing architecture name." >&4
+       case "$dflt" in
+       '')
+               if $test "$osname" = aix -a "X$PASE" != "Xdefine" -a ! -f /lib/syscalls.exp; then
+                       echo " "
+                       echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
+                       echo "'nm' won't be sufficient on this system." >&4
+                       dflt=n
+               fi
                ;;
-       *)
-               case "$archname" in
-               *-ld*) echo "...and architecture name already has -ld." >&4
-                       ;;
-               *)      archname="$archname-ld"
-                       echo "...setting architecture name to $archname." >&4
-                       ;;
-               esac
+       esac
+       case "$dflt" in
+       '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
+               if $test $dflt -gt 20; then
+                       dflt=y
+               else
+                       dflt=n
+               fi
                ;;
        esac
        ;;
-esac
-if $test -f archname.cbu; then
-       echo "Your platform has some specific hints for architecture name, using them..."
-       . ./archname.cbu
-fi
-
-: set the prefixit variable, to compute a suitable default value
-prefixit='case "$3" in
-""|none)
-       case "$oldprefix" in
-       "") eval "$1=\"\$$2\"";;
-       *)
-               case "$3" in
-               "") eval "$1=";;
-               none)
-                       eval "tp=\"\$$2\"";
-                       case "$tp" in
-                       ""|" ") eval "$1=\"\$$2\"";;
-                       *) eval "$1=";;
-                       esac;;
-               esac;;
-       esac;;
 *)
-       eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
-       case "$tp" in
-       --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
-       /*-$oldprefix/*|\~*-$oldprefix/*)
-               eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
-       *) eval "$1=\"\$$2\"";;
-       esac;;
-esac'
-
-: 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' ;;
+       case "$usenm" in
+       true|$define) dflt=y;;
+       *) dflt=n;;
        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 " "
-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
-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
+$cat <<EOM
 
-case "$userelocatableinc" in
-$define|true|[yY]*)    dflt='y' ;;
-*)                     dflt='n' ;;
-esac
-cat <<EOM
+I can use $nm to extract the symbols from your C libraries. This
+is a time consuming task which may generate huge output on the disk (up
+to 3 megabytes) but that should make the symbols extraction faster. The
+alternative is to skip the 'nm' extraction part and to compile a small
+test program instead to determine whether each symbol is present. If
+you have a fast C compiler and/or if your 'nm' output cannot be parsed,
+this may be the best solution.
 
-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.
+You probably shouldn't let me use 'nm' if you are using the GNU C Library.
 
-If this doesn't make any sense to you, just accept the default '$dflt'.
 EOM
-rp='Use relocatable @INC?'
+rp="Shall I use $nm to extract C symbols from the libraries?"
 . ./myread
 case "$ans" in
-y|Y)   val="$define" ;;
-*)     val="$undef"  ;;
-esac
-set userelocatableinc
-eval $setvar
-
-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=".../.."
-    ;;
+[Nn]*) usenm=false;;
+*) usenm=true;;
 esac
 
-: determine where private library files go
-: Usual default is /usr/local/lib/perl5/$version.
-: 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
-*lib/perl5*) set dflt privlib lib/$package/$version ;;
-*)      set dflt privlib lib/$version ;;
+runnm=$usenm
+case "$reuseval" in
+true) runnm=false;;
 esac
-eval $prefixit
-$cat <<EOM
 
-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
-prefixvar=privlib
-. ./setprefixvar
-
-: set the prefixup variable, to restore leading tilda escape
-prefixup='case "$prefixexp" in
-"$prefix") ;;
-*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
-esac'
+: nm options which may be necessary
+case "$nm_opt" in
+'') if $test -f /mach_boot; then
+               nm_opt=''       # Mach
+       elif $test -d /usr/ccs/lib; then
+               nm_opt='-p'     # Solaris (and SunOS?)
+       elif $test -f /dgux; then
+               nm_opt='-p'     # DG-UX
+       elif $test -f /lib64/rld; then
+               nm_opt='-p'     # 64-bit Irix
+       else
+               nm_opt=''
+       fi;;
+esac
 
-: determine where public architecture dependent libraries go
-set archlib archlib
-eval $prefixit
-: privlib default is /usr/local/lib/$package/$version
-: archlib default is /usr/local/lib/$package/$version/$archname
-: privlib may have an optional trailing /share.
-tdflt=`echo $privlib | $sed 's,/share$,,'`
-tdflt=$tdflt/$archname
-case "$archlib" in
-'')    dflt=$tdflt
+: nm options which may be necessary for shared libraries but illegal
+: for archive libraries.  Thank you, Linux.
+case "$nm_so_opt" in
+'')    case "$myuname" in
+       *linux*|gnu*)
+               if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
+                       nm_so_opt='--dynamic'
+               fi
+               ;;
+       esac
        ;;
-*)     dflt="$archlib"
-    ;;
 esac
-$cat <<EOM
-
-$spackage contains architecture-dependent library files.  If you are
-sharing libraries in a heterogeneous environment, you might store
-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
-prefixvar=archlib
-. ./setprefixvar
-if $test X"$archlib" = X"$privlib"; then
-       d_archlib="$undef"
+: Figure out where the libc is located
+case "$runnm" in
+true)
+: get list of predefined functions in a handy place
+echo " "
+case "$libc" in
+'') libc=unknown
+       case "$libs" in
+       *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
+       esac
+       ;;
+esac
+case "$libs" in
+'') ;;
+*)  for thislib in $libs; do
+       case "$thislib" in
+       -lc|-lc_s)
+               : Handle C library specially below.
+               ;;
+       -l*)
+               thislib=`echo $thislib | $sed -e 's/^-l//'`
+               if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
+                       :
+               elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
+                       :
+               elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
+                       :
+               elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
+                       :
+               elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
+                       :
+               elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
+                       :
+               elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
+                       :
+               else
+                       try=''
+               fi
+               libnames="$libnames $try"
+               ;;
+       *) libnames="$libnames $thislib" ;;
+       esac
+       done
+       ;;
+esac
+xxx=normal
+case "$libc" in
+unknown)
+       set /lib/libc.$so
+       for xxx in $libpth; do
+               $test -r $1 || set $xxx/libc.$so
+               : The messy sed command sorts on library version numbers.
+               $test -r $1 || \
+                       set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
+                       tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
+                               h
+                               s/[0-9][0-9]*/0000&/g
+                               s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
+                               G
+                               s/\n/ /' | \
+                        $sort | $sed -e 's/^.* //'`
+               eval set \$$#
+       done
+       $test -r $1 || set $sysroot/usr/ccs/lib/libc.$so
+       $test -r $1 || set $sysroot/lib/libsys_s$_a
+       ;;
+*)
+       set blurfl
+       ;;
+esac
+if $test -r "$1"; then
+       echo "Your (shared) C library seems to be in $1."
+       libc="$1"
+elif $test -r /lib/libc && $test -r /lib/clib; then
+       echo "Your C library seems to be in both /lib/clib and /lib/libc."
+       xxx=apollo
+       libc='/lib/clib /lib/libc'
+       if $test -r /lib/syslib; then
+               echo "(Your math library is in /lib/syslib.)"
+               libc="$libc /lib/syslib"
+       fi
+elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
+       echo "Your C library seems to be in $libc, as you said before."
+elif $test -r $incpath/usr/lib/libc$_a; then
+       libc=$incpath/usr/lib/libc$_a;
+       echo "Your C library seems to be in $libc.  That's fine."
+elif $test -r /lib/libc$_a; then
+       libc=/lib/libc$_a;
+       echo "Your C library seems to be in $libc.  You're normal."
 else
-       d_archlib="$define"
+       if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
+               :
+       elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
+               libnames="$libnames "`./loc clib blurfl/dyick $libpth`
+       elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
+               :
+       elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
+               :
+       elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
+               :
+       else
+               tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
+       fi
+       if $test -r "$tans"; then
+               echo "Your C library seems to be in $tans, of all places."
+               libc=$tans
+       else
+               libc='blurfl'
+       fi
 fi
+if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
+       dflt="$libc"
+       cat <<EOM
 
-: see if setuid scripts can be secure
-$cat <<EOM
-
-Some kernels have a bug that prevents setuid #! scripts from being
-secure.  Some sites have disabled setuid #! scripts because of this.
+If the guess above is wrong (which it might be if you're using a strange
+compiler, or your machine supports multiple models), you can override it here.
 
-First let's decide if your kernel supports secure setuid #! scripts.
-(If setuid #! scripts would be secure but have been disabled anyway,
-don't say that they are secure if asked.)
+EOM
+else
+       dflt=''
+       echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
+       cat >&4 <<EOM
+I can't seem to find your C library.  I've looked in the following places:
 
 EOM
+       $sed 's/^/      /' libpath
+       cat <<EOM
 
-val="$undef"
-if $test -d /dev/fd; then
-       echo "#!$ls" >reflect
-       chmod +x,u+s reflect
-       ./reflect >flect 2>&1
-       if $contains "/dev/fd" flect >/dev/null; then
-               echo "Congratulations, your kernel has secure setuid scripts!" >&4
-               val="$define"
-       else
-               $cat <<EOM
-If you are not sure if they are secure, I can check but I'll need a
-username and password different from the one you are using right now.
-If you don't have such a username or don't want me to test, simply
-enter 'none'.
+None of these seems to contain your C library. I need to get its name...
 
 EOM
-               rp='Other username to test security of setuid scripts with?'
-               dflt='none'
-               . ./myread
-               case "$ans" in
-               n|none)
-                       case "$d_suidsafe" in
-                       '')     echo "I'll assume setuid scripts are *not* secure." >&4
-                               dflt=n;;
-                       "$undef")
-                               echo "Well, the $hint value is *not* secure." >&4
-                               dflt=n;;
-                       *)      echo "Well, the $hint value *is* secure." >&4
-                               dflt=y;;
-                       esac
-                       ;;
-               *)
-                       $rm -f reflect flect
-                       echo "#!$ls" >reflect
-                       chmod +x,u+s reflect
-                       echo >flect
-                       chmod a+w flect
-                       echo '"su" will (probably) prompt you for '"$ans's password."
-                       su $ans -c './reflect >flect'
-                       if $contains "/dev/fd" flect >/dev/null; then
-                               echo "Okay, it looks like setuid scripts are secure." >&4
-                               dflt=y
-                       else
-                               echo "I don't think setuid scripts are secure." >&4
-                               dflt=n
-                       fi
-                       ;;
-               esac
-               rp='Does your kernel have *secure* setuid scripts?'
-               . ./myread
-               case "$ans" in
-               [yY]*)  val="$define";;
-               *)      val="$undef";;
-               esac
-       fi
-else
-       echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
-       echo "(That's for file descriptors, not floppy disks.)"
-       val="$undef"
 fi
-set d_suidsafe
-eval $setvar
-
-$rm -f reflect flect
-
-: now see if they want to do setuid emulation
-if $test $patchlevel -lt 11; then
-echo " "
-val="$undef"
-case "$d_suidsafe" in
-"$define")
-       val="$undef"
-       echo "No need to emulate SUID scripts since they are secure here." >&4
-       ;;
-*)
-       $cat <<EOM
-Some systems have disabled setuid scripts, especially systems where
-setuid scripts cannot be secure.  On systems where setuid scripts have
-been disabled, the setuid/setgid bits on scripts are currently
-useless.  It is possible for $package to detect those bits and emulate
-setuid/setgid in a secure fashion.  This emulation will only work if
-setuid scripts have been disabled in your kernel.
-
-EOM
-       case "$d_dosuid" in
-       "$define") dflt=y ;;
-       *) dflt=n ;;
-       esac
-       rp="Do you want to do setuid/setgid emulation?"
-       . ./myread
-       case "$ans" in
-       [yY]*)  val="$define";;
-       *)      val="$undef";;
-       esac
-       ;;
-esac
-set d_dosuid
-eval $setvar
-else
-    case "$d_dosuid" in
-       "$define")
-       cat >&4 <<EOH
-
-SUID emulation has been removed for 5.12
-Please re-run Configure without -Dd_dosuid
-
-EOH
-       exit 1;
-       ;;
-    esac
-    d_dosuid=undef
-fi
-
-: Find perl5.005 or later.
-echo "Looking for a previously installed perl5.005 or later... "
-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?'
+fn=f
+rp='Where is your C library?'
 . ./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
+libc="$ans"
 
-# 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.*");
-    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
-}
-else {
-    ;@candidates = ();
-}
+echo " "
+echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
+set X `cat libnames`
+shift
+xxx=files
+case $# in 1) xxx=file; esac
+echo "Extracting names from the following $xxx for later perusal:" >&4
+echo " "
+$sed 's/^/     /' libnames >&4
+echo " "
+$echo $n "This may take a while...$c" >&4
 
-($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.
-    }
-}
+for file in $*; do
+       case $file in
+       *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
+       *) $nm $nm_opt $file 2>/dev/null;;
+       esac
+done >libc.tmp
 
-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`
+$echo $n ".$c"
+$grep fprintf libc.tmp > libc.ptf
+xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
+xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
+xxx='[ADTSIWi]'
+if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
+                               -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
+       eval $xscan;\
+       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
+               eval $xrun
+else
+       $nm -p $* 2>/dev/null >libc.tmp
+       $grep fprintf libc.tmp > libc.ptf
+       if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
+               eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
+       then
+               nm_opt='-p'
+               eval $xrun
        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" ;;
+               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
+                       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
+                       for thisname in $libnames $libc; do
+                               $ar tv $thisname >>libc.tmp
+                               emximp -o tmp.imp $thisname \
+                                   2>/dev/null && \
+                                   $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
+                                   < tmp.imp >>libc.tmp
+                               $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 &&
+                               $test -s libc.list
+                       then
+                               for thisname in $libnames; do
+                                       bld t $libnames | \
+                                       $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
+                                       $ar t $thisname >>libc.tmp
+                               done
+                               echo "Ok." >&4
+                       else
+                               echo "That didn't work either.  Giving up." >&4
+                               exit 1
+                       fi
+               fi
+       fi
+fi
+nm_extract="$com"
+case "$PASE" in
+define)
+    echo " "
+    echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
+    dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
+    ;;
+*)  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
+    fi
+    ;;
 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
+$rm -f libnames libpath
 
-: 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
+: Check if we are using C++
 echo " "
-$cat >try.c <<EOCP
-#include <stdlib.h>
-#include <malloc.h>
-#$i_mallocmalloc I_MALLOCMALLOC
-#ifdef I_MALLOCMALLOC
-# include <malloc/malloc.h>
+echo "Checking for C++..." >&4
+$cat >try.c <<'EOCP'
+#include <stdio.h>
+int main(void)
+{
+#ifdef __cplusplus
+    return 0;
+#else
+    return 1;
 #endif
-
-int main () { return 0; }
+}
 EOCP
 set try
-if eval $compile; then
-    echo "<malloc.h> found." >&4
-    val="$define"
+if eval $compile_ok && $run ./try; then
+       val="$define"
+       echo "You are using a C++ compiler."
 else
-    echo "<malloc.h> NOT found." >&4
-    val="$undef"
+       val="$undef"
+       echo "You are not using a C++ compiler."
 fi
-$rm_try
-set i_malloc
+$rm_try cplusplus$$
+set d_cplusplus
 eval $setvar
 
-: check for void type
+: is a C symbol defined?
+csym='tlook=$1;
+case "$3" in
+-v) tf=libc.tmp; tdc="";;
+-a) tf=libc.tmp; tdc="[]";;
+*) tlook="^$1\$"; tf=libc.list; tdc="()";;
+esac;
+case "$d_cplusplus" in
+    $define)   extern_C="extern \"C\"" ;;
+    *)         extern_C="extern"       ;;
+esac;
+tx=yes;
+case "$reuseval-$4" in
+true-) ;;
+true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
+esac;
+case "$tx" in
+yes)
+       tval=false;
+       if $test "$runnm" = true; then
+               if $contains $tlook $tf >/dev/null 2>&1; then
+                       tval=true;
+               elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
+                       echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) return(0); else return(1); }"> try.c;
+                       $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
+                       $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
+                       $rm_try;
+               fi;
+       else
+               echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) return(0); else return(1); }"> try.c;
+               $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
+               $rm_try;
+       fi;
+       ;;
+*)
+       case "$tval" in
+       $define) tval=true;;
+       *) tval=false;;
+       esac;
+       ;;
+esac;
+eval "$2=$tval"'
+
+: define an is-in-libc? function
+inlibc='echo " "; td=$define; tu=$undef;
+sym=$1; var=$2; eval "was=\$$2";
+tx=yes;
+case "$reuseval$was" in
+true) ;;
+true*) tx=no;;
+esac;
+case "$tx" in
+yes)
+       set $sym tres -f;
+       eval $csym;
+       case "$tres" in
+       true)
+               echo "$sym() found." >&4;
+               case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
+       *)
+               echo "$sym() NOT found." >&4;
+               case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
+       esac;;
+*)
+       case "$was" in
+       $define) echo "$sym() found." >&4;;
+       *) echo "$sym() NOT found." >&4;;
+       esac;;
+esac'
+
+: check for length of double
 echo " "
-echo "Checking to see how well your C compiler groks the void type..." >&4
-case "$voidflags" in
+case "$doublesize" in
 '')
+       echo "Checking to see how big your double precision numbers are..." >&4
        $cat >try.c <<EOCP
+#include <stdio.h>
 #$i_stdlib I_STDLIB
 #ifdef I_STDLIB
 #include <stdlib.h>
 #endif
-#if TRY & 1
-void sub() {
-#else
-sub() {
-#endif
-       extern void moo();      /* function returning void */
-       void (*goo)();          /* ptr to func returning void */
-#if TRY & 8
-       void *hue;              /* generic ptr */
-#endif
-#if TRY & 2
-       void (*foo[10])();
-#endif
-
-#if TRY & 4
-       if(goo == moo) {
-               exit(0);
-       }
-#endif
-       exit(0);
+int main()
+{
+    printf("%d\n", (int)sizeof(double));
+    exit(0);
 }
-int main() { sub(); }
 EOCP
-       if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
-               voidflags=$defvoidused
-       echo "Good.  It appears to support void to the level $package wants.">&4
-               if $contains warning .out >/dev/null 2>&1; then
-                       echo "However, you might get some warnings that look like this:"
-                       $cat .out
-               fi
+       set try
+       if eval $compile_ok; then
+               doublesize=`$run ./try`
+               echo "Your double is $doublesize bytes long."
        else
-echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
-               if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
-                       echo "It supports 1..."
-                       if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
-                               echo "It also supports 2..."
-                               if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
-                                       voidflags=7
-                                       echo "And it supports 4 but not 8 definitely."
-                               else
-                                       echo "It doesn't support 4..."
-                                       if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
-                                               voidflags=11
-                                               echo "But it supports 8."
-                                       else
-                                               voidflags=3
-                                               echo "Neither does it support 8."
-                                       fi
-                               fi
-                       else
-                               echo "It does not support 2..."
-                               if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
-                                       voidflags=13
-                                       echo "But it supports 4 and 8."
-                               else
-                                       if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
-                                               voidflags=5
-                                               echo "And it supports 4 but has not heard about 8."
-                                       else
-                                               echo "However it supports 8 but not 4."
-                                       fi
-                               fi
-                       fi
-               else
-                       echo "There is no support at all for void."
-                       voidflags=0
-               fi
+               dflt='8'
+               echo "(I can't seem to compile the test program.  Guessing...)"
+               rp="What is the size of a double precision number (in bytes)?"
+               . ./myread
+               doublesize="$ans"
        fi
-esac
-case "$voidflags" in
-"$defvoidused") ;;
-*)     $cat >&4 <<'EOM'
-  Support flag bits are:
-    1: basic void declarations.
-    2: arrays of pointers to functions returning void.
-    4: operations between pointers to and addresses of void functions.
-    8: generic void pointers.
-EOM
-       dflt="$voidflags";
-       rp="Your void support flags add up to what?"
-       . ./myread
-       voidflags="$ans"
        ;;
 esac
 $rm_try
 
-: check for length of pointer
+: see if this is a float.h system
+set float.h i_float
+eval $inhdr
+
+: check for long doubles
 echo " "
-case "$ptrsize" in
-'')
-       echo "Checking to see how big your pointers are..." >&4
-       if test "$voidflags" -gt 7; then
-               echo '#define VOID_PTR char *' > try.c
+echo "Checking to see if you have long double..." >&4
+echo 'int main() { long double x = 7.0; }' > try.c
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have long double."
+else
+       val="$undef"
+       echo "You do not have long double."
+fi
+$rm_try
+set d_longdbl
+eval $setvar
+
+: see if ldexpl exists
+set ldexpl d_ldexpl
+eval $inlibc
+
+: check for length of long double
+case "${d_longdbl}${longdblsize}" in
+$define)
+       echo " "
+       echo "Checking to see how big your long doubles are..." >&4
+       $cat >try.c <<'EOCP'
+#include <stdio.h>
+int main()
+{
+       printf("%d\n", sizeof(long double));
+}
+EOCP
+       set try
+       set try
+       if eval $compile; then
+               longdblsize=`$run ./try`
+               echo "Your long doubles are $longdblsize bytes long."
        else
-               echo '#define VOID_PTR void *' > try.c
+               dflt='8'
+               echo " "
+               echo "(I can't seem to compile the test program.  Guessing...)" >&4
+               rp="What is the size of a long double (in bytes)?"
+               . ./myread
+               longdblsize="$ans"
        fi
-       $cat >>try.c <<EOCP
-#include <stdio.h>
+       if $test "X$doublesize" = "X$longdblsize"; then
+               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
+       ;;
+esac
+$rm_try
+
+$echo "Checking the kind of long doubles you have..." >&4
+case "$d_longdbl" in
+define)
+$cat <<EOP >try.c
+#$i_float I_FLOAT
 #$i_stdlib I_STDLIB
+#define LONGDBLSIZE $longdblsize
+#define DOUBLESIZE $doublesize
+#ifdef I_FLOAT
+#include <float.h>
+#endif
 #ifdef I_STDLIB
 #include <stdlib.h>
 #endif
-int main()
-{
-    printf("%d\n", (int)sizeof(VOID_PTR));
+#include <stdio.h>
+static const long double d = -0.1L;
+int main() {
+  unsigned const char* b = (unsigned const char*)(&d);
+#if DOUBLESIZE == LONGDBLSIZE
+  printf("0\n"); /* if it floats like double */
+  exit(0);
+#endif
+#if (LDBL_MANT_DIG == 113 || FLT128_MANT_DIG == 113) && LONGDBLSIZE == 16
+  if (b[0] == 0x9A && b[1] == 0x99 && b[15] == 0xBF) {
+    /* IEEE 754 128-bit little-endian */
+    printf("1\n");
+    exit(0);
+  }
+  if (b[0] == 0xBF && b[14] == 0x99 && b[15] == 0x9A) {
+    /* IEEE 128-bit big-endian, e.g. solaris sparc */
+    printf("2\n");
+    exit(0);
+  }
+#endif
+/* For alignment 32-bit platforms have the 80 bits in 12 bytes,
+ * while 64-bits platforms have it in 16 bytes.  The trailing bytes
+ * cannot be trusted. */
+#if LDBL_MANT_DIG == 64 && (LONGDBLSIZE == 16 || LONGDBLSIZE == 12)
+  if (b[0] == 0xCD && b[9] == 0xBF) {
+    /* x86 80-bit little-endian, sizeof 12 (ILP32, Solaris x86)
+     * or 16 (LP64, Linux and OS X), 4 or 6 bytes of padding.
+     * Also known as "extended precision". */
+    printf("3\n");
+    exit(0);
+  }
+  if (b[0] == 0xBF && b[9] == 0xCD) {
+    /* Is there ever big-endian 80-bit, really?
+     *
+     * The Motorola 68881 had another "extended precision" format:
+     * sign:1 exp:15 zero:16 integer:1 mantissa:63
+     * for total of 96 bits of bytes.  The zero bits were unused.
+     * See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL" for more details.
+     * If it ever becomes relevant, this format should be allocated
+     * a new doublekind code since it's quite different from the Intel x87.
+     */
+    printf("4\n");
+    exit(0);
+  }
+#endif
+#if (LDBL_MANT_DIG == 106 || LDBL_MANT_DIG == 107) && LONGDBLSIZE == 16
+  /* software "double double", the 106 is 53+53.
+   * but irix thinks it is 107. */
+  if (b[0] == 0x9A && b[7] == 0x3C && b[8] == 0x9A && b[15] == 0xBF) {
+    /* double double 128-bit fully little-endian,
+     * little-endian doubles in little-endian order,
+     * 9a 99 99 99 99 99 59 3c 9a 99 99 99 99 99 b9 bf */
+    printf("5\n");
+    exit(0);
+  }
+  if (b[0] == 0xBF && b[7] == 0x9A && b[8] == 0x3C && b[15] == 0x9A) {
+    /* double double 128-bit fully big-endian,
+     * big-endian doubles in big-endian order,
+     * e.g. PPC/Power and MIPS:
+     * bf b9 99 99 99 99 99 9a 3c 59 99 99 99 99 99 9a */
+    printf("6\n");
+    exit(0);
+  }
+  if (b[0] == 0x9A && b[7] == 0xBF && b[8] == 0x9A && b[15] == 0x3C) {
+    /* double double 128-bit mixed endian.
+     * little-endian doubles in big-endian order,
+     * e.g. ppc64el,
+     * 9a 99 99 99 99 99 b9 bf 9a 99 99 99 99 99 59 3c */
+    printf("7\n");
+    exit(0);
+  }
+  if (b[0] == 0x3C && b[7] == 0x9A && b[8] == 0xBF && b[15] == 0x9A) {
+    /* double double 128-bit mixed endian,
+     * big-endian doubles in little-endian order,
+     * 3c 59 99 99 99 99 99 9a bf b9 99 99 99 99 99 9a */
+    printf("8\n");
     exit(0);
+  }
+#endif
+  printf("-1\n"); /* unknown */
+  exit(0);
 }
-EOCP
-       set try
-       if eval $compile_ok; then
-               ptrsize=`$run ./try`
-               echo "Your pointers are $ptrsize bytes long."
+EOP
+set try
+if eval $compile; then
+    longdblkind=`$run ./try`
+else
+    longdblkind=-1
+fi
+;;
+*) longdblkind=0 ;;
+esac
+case "$longdblkind" in
+0) echo "Your long doubles are doubles." >&4 ;;
+1) echo "You have IEEE 754 128-bit little endian long doubles." >&4 ;;
+2) echo "You have IEEE 754 128-bit big endian long doubles." >&4 ;;
+3) echo "You have x86 80-bit little endian long doubles." >& 4 ;;
+4) echo "You have x86 80-bit big endian long doubles." >& 4 ;;
+5) echo "You have 128-bit fully little-endian double-double long doubles (64-bit LEs in LE)." >& 4 ;;
+6) echo "You have 128-bit fully big-endian double-double long doubles (64-bit BEs in BE)." >& 4 ;;
+7) echo "You have 128-bit mixed double-double long doubles (64-bit LEs in BE)." >& 4 ;;
+8) echo "You have 128-bit mixed double-double long doubles (64-bit BEs in LE)." >& 4 ;;
+*) echo "Cannot figure out your long double." >&4 ;;
+esac
+$rm_try
+
+: determine the architecture name
+echo " "
+if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
+       tarch=`arch`"-$osname"
+elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
+       if uname -m > tmparch 2>&1 ; then
+               tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
+                       -e 's/$/'"-$osname/" tmparch`
        else
-               dflt='4'
-               echo "(I can't seem to compile the test program.  Guessing...)" >&4
-               rp="What is the size of a pointer (in bytes)?"
-               . ./myread
-               ptrsize="$ans"
+               tarch="$osname"
        fi
+       $rm -f tmparch
+else
+       tarch="$osname"
+fi
+case "$myarchname" in
+''|"$tarch") ;;
+*)
+       echo "(Your architecture name used to be $myarchname.)"
+       archname=''
        ;;
 esac
-$rm_try
-case "$use64bitall" in
-"$define"|true|[yY]*)
-       case "$ptrsize" in
-       4)      cat <<EOM >&4
+case "$targetarch" in
+'') ;;
+*)  archname=`echo $targetarch|sed 's,^[^-]*-,,'` ;;
+esac
+myarchname="$tarch"
+case "$archname" in
+'') dflt="$tarch";;
+*) dflt="$archname";;
+esac
+rp='What is your architecture name'
+. ./myread
+archname="$ans"
 
-*** You have chosen a maximally 64-bit build,
-*** but your pointers are only 4 bytes wide.
-*** Please rerun Configure without -Duse64bitall.
-EOM
-               case "$d_quad" in
-               define)
-                       cat <<EOM >&4
-*** Since you have quads, you could possibly try with -Duse64bitint.
-EOM
+: optionally add API version to the architecture for versioned archlibs
+case "$useversionedarchname" in
+$define|true|[yY]*) dflt='y';;
+*)                  dflt='n';;
+esac
+rp='Add the Perl API version to your archname?'
+. ./myread
+case "$ans" in
+y|Y)   useversionedarchname="$define" ;;
+*)      useversionedarchname="$undef" ;;
+esac
+case "$useversionedarchname" in
+$define)
+       case "$archname" in
+       *-$api_versionstring)
+               echo "...and architecture name already has -$api_versionstring" >&4
+               ;;
+       *)
+               archname="$archname-$api_versionstring"
+               echo "...setting architecture name to $archname." >&4
+               ;;
+       esac
+       ;;
+esac
+
+case "$usethreads" in
+$define)
+       echo "Threads selected." >&4
+       case "$archname" in
+       *-thread*) echo "...and architecture name already has -thread." >&4
+               ;;
+       *)      archname="$archname-thread"
+               echo "...setting architecture name to $archname." >&4
+               ;;
+       esac
+       ;;
+esac
+case "$usemultiplicity" in
+$define)
+       echo "Multiplicity selected." >&4
+       case "$archname" in
+       *-multi*) echo "...and architecture name already has -multi." >&4
+               ;;
+       *)      archname="$archname-multi"
+               echo "...setting architecture name to $archname." >&4
+               ;;
+       esac
+       ;;
+esac
+case "$use64bitint$use64bitall" in
+*"$define"*)
+       case "$archname64" in
+       '')
+               echo "This architecture is naturally 64-bit, not changing architecture name." >&4
+               ;;
+       *)
+               case "$use64bitint" in
+               "$define") echo "64 bit integers selected." >&4 ;;
+               esac
+               case "$use64bitall" in
+               "$define") echo "Maximal 64 bitness selected." >&4 ;;
+               esac
+               case "$archname" in
+               *-$archname64*) echo "...and architecture name already has $archname64." >&4
+                       ;;
+               *)      archname="$archname-$archname64"
+                       echo "...setting architecture name to $archname." >&4
+                       ;;
+               esac
+               ;;
+       esac
+esac
+case "$uselongdouble" in
+$define)
+       echo "Long doubles selected." >&4
+       case "$longdblsize" in
+       $doublesize)
+               echo "...but long doubles are equal to doubles, not changing architecture name." >&4
+               ;;
+       *)
+               case "$archname" in
+               *-ld*) echo "...and architecture name already has -ld." >&4
+                       ;;
+               *)      archname="$archname-ld"
+                       echo "...setting architecture name to $archname." >&4
                        ;;
                esac
-               cat <<EOM >&4
-*** Cannot continue, aborting.
-
-EOM
-
-               exit 1
                ;;
        esac
        ;;
 esac
-
-
-: determine whether to use malloc wrapping
-echo " "
-case "$usemallocwrap" in
-[yY]*|true|$define)    dflt='y' ;;
-[nN]*|false|$undef)    dflt='n' ;;
-*)     case "$usedevel" in
-       [yY]*|true|$define)     dflt='y' ;;
-       *) dflt='n' ;;
+case "$usequadmath" in
+$define)
+       echo "quadmath selected." >&4
+       case "$archname" in
+       *-ld*) echo "...and architecture name already has -quadmath." >&4
+               ;;
+       *)      archname="$archname-quadmath"
+               echo "...setting architecture name to $archname." >&4
+               ;;
        esac
        ;;
 esac
-rp="Do you wish to wrap malloc calls to protect against potential overflows?"
-. ./myread
-usemallocwrap="$ans"
-case "$ans" in
-y*|true)
-       usemallocwrap="$define" ;;
+if $test -f archname.cbu; then
+       echo "Your platform has some specific hints for architecture name, using them..."
+       . ./archname.cbu
+fi
+
+: set the prefixit variable, to compute a suitable default value
+prefixit='case "$3" in
+""|none)
+       case "$oldprefix" in
+       "") eval "$1=\"\$$2\"";;
+       *)
+               case "$3" in
+               "") eval "$1=";;
+               none)
+                       eval "tp=\"\$$2\"";
+                       case "$tp" in
+                       ""|" ") eval "$1=\"\$$2\"";;
+                       *) eval "$1=";;
+                       esac;;
+               esac;;
+       esac;;
 *)
-       usemallocwrap="$undef" ;;
-esac
+       eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
+       case "$tp" in
+       --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
+       /*-$oldprefix/*|\~*-$oldprefix/*)
+               eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
+       *) eval "$1=\"\$$2\"";;
+       esac;;
+esac'
 
-: determine which malloc to compile in
-echo " "
-case "$usemymalloc" in
-[yY]*|true|$define)    dflt='y' ;;
-[nN]*|false|$undef)    dflt='n' ;;
-*)     case "$ptrsize" in
-       4) dflt='y' ;;
-       *) dflt='n' ;;
+: 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
-       if test "$useithreads" = "$define"; then dflt='n'; fi
        ;;
+*)     dflt="$installstyle" ;;
 esac
-rp="Do you wish to attempt to use the malloc that comes with $package?"
+: 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 " "
+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
+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
+
+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.
+
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Use relocatable @INC?'
 . ./myread
-usemymalloc="$ans"
 case "$ans" in
-y*|true)
-       usemymalloc='y'
-       mallocsrc='malloc.c'
-       mallocobj="malloc$_o"
-       d_mymalloc="$define"
-       case "$libs" in
-       *-lmalloc*)
-               : Remove malloc from list of libraries to use
-               echo "Removing unneeded -lmalloc from library list" >&4
-               set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
-               shift
-               libs="$*"
-               echo "libs = $libs" >&4
-               ;;
-       esac
-       ;;
-*)
-       usemymalloc='n'
-       mallocsrc=''
-       mallocobj=''
-       d_mymalloc="$undef"
-       ;;
+y|Y)   val="$define" ;;
+*)     val="$undef"  ;;
 esac
+set userelocatableinc
+eval $setvar
 
-: compute the return types of malloc and free
-echo " "
-$cat >malloc.c <<END
-#$i_malloc I_MALLOC
-#$i_stdlib I_STDLIB
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef I_MALLOC
-#include <malloc.h>
-#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
-       ;;
+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
-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]
-: 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
-: sitelib may have an optional trailing /share.
-case "$sitearch" in
-'')    dflt=`echo $sitelib | $sed 's,/share$,,'`
-       dflt="$dflt/$archname"
-       ;;
-*)     dflt="$sitearch"
-       ;;
+: determine where private library files go
+: Usual default is /usr/local/lib/perl5/$version.
+: 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
+*lib/perl5*) set dflt privlib lib/$package/$version ;;
+*)      set dflt privlib lib/$version ;;
 esac
-set sitearch sitearch none
 eval $prefixit
 $cat <<EOM
 
-The installation process will also create a directory for
-architecture-dependent site-specific extensions and modules.
+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 for the site-specific architecture-dependent library files?'
+rp='Pathname where the private library files will reside?'
 . ./getfile
-prefixvar=sitearch
+prefixvar=privlib
 . ./setprefixvar
-if $test X"$sitearch" = X"$sitelib"; then
-       d_sitearch="$undef"
-else
-       d_sitearch="$define"
-fi
-
-: Set the vendorprefix variables
-$cat <<EOM
-
-The installation process will also create a directory for
-vendor-supplied add-ons.  Vendors who supply perl with their system
-may find it convenient to place all vendor-supplied files in this
-directory rather than in the main distribution directory.  This will
-ease upgrades between binary-compatible maintenance versions of perl.
-
-Of course you may also use these directories in whatever way you see
-fit.  For example, you might use them to access modules shared over a
-company-wide network.
 
-The default answer should be fine for most people.
-This causes further questions about vendor add-ons to be skipped
-and no vendor-specific directories will be configured for perl.
+: set the prefixup variable, to restore leading tilda escape
+prefixup='case "$prefixexp" in
+"$prefix") ;;
+*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
+esac'
 
-EOM
-rp='Do you want to configure vendor-specific add-on directories?'
-case "$usevendorprefix" in
-define|true|[yY]*) dflt=y ;;
-*)     : User may have set vendorprefix directly on Configure command line.
-       case "$vendorprefix" in
-       ''|' ') dflt=n ;;
-       *)      dflt=y ;;
-       esac
-       ;;
-esac
-. ./myread
-case "$ans" in
-[yY]*) fn=d~+
-       rp='Installation prefix to use for vendor-supplied add-ons?'
-       case "$vendorprefix" in
-       '') dflt='' ;;
-       *)  dflt=$vendorprefix ;;
-       esac
-       . ./getfile
-       : XXX Prefixit unit does not yet support siteprefix and vendorprefix
-       oldvendorprefix=''
-       case "$vendorprefix" in
-       '') ;;
-       *)      case "$ans" in
-               "$prefix") ;;
-               *) oldvendorprefix="$prefix";;
-               esac
-               ;;
-       esac
-       usevendorprefix="$define"
-       vendorprefix="$ans"
-       vendorprefixexp="$ansexp"
-       ;;
-*)     usevendorprefix="$undef"
-       vendorprefix=''
-       vendorprefixexp=''
+: determine where public architecture dependent libraries go
+set archlib archlib
+eval $prefixit
+: privlib default is /usr/local/lib/$package/$version
+: archlib default is /usr/local/lib/$package/$version/$archname
+: privlib may have an optional trailing /share.
+tdflt=`echo $privlib | $sed 's,/share$,,'`
+tdflt=$tdflt/$archname
+case "$archlib" in
+'')    dflt=$tdflt
        ;;
+*)     dflt="$archlib"
+    ;;
 esac
+$cat <<EOM
 
-: Set the vendorlib variables
-case "$vendorprefix" in
-'')    d_vendorlib="$undef"
-       vendorlib=''
-       vendorlibexp=''
-       ;;
-*)     d_vendorlib="$define"
-       : determine where vendor-supplied modules go.
-       : Usual default is /usr/local/lib/perl5/vendor_perl/$version
-       case "$vendorlib" in
-       '')
-               prog=`echo $package | $sed 's/-*[0-9.]*$//'`
-               case "$installstyle" in
-               *lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
-               *)           dflt=$vendorprefix/lib/vendor_$prog/$version ;;
-               esac
-               ;;
-       *)      dflt="$vendorlib"
-               ;;
-       esac
-       fn=d~+
-       rp='Pathname for the vendor-supplied library files?'
-       . ./getfile
-       vendorlib="$ans"
-       vendorlibexp="$ansexp"
-       ;;
-esac
-vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
-prefixvar=vendorlib
-. ./installprefix
+$spackage contains architecture-dependent library files.  If you are
+sharing libraries in a heterogeneous environment, you might store
+these files in a separate location.  Otherwise, you can just include
+them with the rest of the public library files.
 
-: Set the vendorarch variables
-case "$vendorprefix" in
-'')    d_vendorarch="$undef"
-       vendorarch=''
-       vendorarchexp=''
-       ;;
-*)     d_vendorarch="$define"
-       : determine where vendor-supplied architecture-dependent libraries go.
-       : vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
-       : vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
-       : vendorlib may have an optional trailing /share.
-       case "$vendorarch" in
-       '')     dflt=`echo $vendorlib | $sed 's,/share$,,'`
-               dflt="$dflt/$archname"
-               ;;
-       *)      dflt="$vendorarch" ;;
-       esac
-       fn=d~+
-       rp='Pathname for vendor-supplied architecture-dependent files?'
-       . ./getfile
-       vendorarch="$ans"
-       vendorarchexp="$ansexp"
-       ;;
-esac
-prefixvar=vendorarch
-. ./installprefix
-if $test X"$vendorarch" = X"$vendorlib"; then
-       d_vendorarch="$undef"
+EOM
+fn=$binexp
+fn=d+~
+rp='Where do you want to put the public architecture-dependent libraries?'
+. ./getfile
+prefixvar=archlib
+. ./setprefixvar
+if $test X"$archlib" = X"$privlib"; then
+       d_archlib="$undef"
 else
-       d_vendorarch="$define"
+       d_archlib="$define"
 fi
 
-: Final catch-all directories to search
+: see if setuid scripts can be secure
 $cat <<EOM
 
-Lastly, you can have perl look in other directories for extensions and
-modules in addition to those already specified.
-These directories will be searched after 
-       $sitearch 
-       $sitelib 
-EOM
-test X"$vendorlib" != "X" && echo '    ' $vendorlib
-test X"$vendorarch" != "X" && echo '   ' $vendorarch
-echo ' '
-case "$otherlibdirs" in
-''|' ') dflt='none' ;;
-*)     dflt="$otherlibdirs" ;;
-esac
-$cat <<EOM
-Enter a colon-separated set of extra paths to include in perl's @INC
-search path, or enter 'none' for no extra paths.
+Some kernels have a bug that prevents setuid #! scripts from being
+secure.  Some sites have disabled setuid #! scripts because of this.
+
+First let's decide if your kernel supports secure setuid #! scripts.
+(If setuid #! scripts would be secure but have been disabled anyway,
+don't say that they are secure if asked.)
 
 EOM
 
-rp='Colon-separated list of additional directories for perl to search?'
-. ./myread
-case "$ans" in
-' '|''|none)   otherlibdirs=' ' ;;     
-*)     otherlibdirs="$ans" ;;
-esac
-case "$otherlibdirs" in
-' ') val=$undef ;;
-*)     val=$define ;;
-esac
-set d_perl_otherlibdirs
-eval $setvar
+val="$undef"
+if $test -d /dev/fd; then
+       echo "#!$ls" >reflect
+       chmod +x,u+s reflect
+       ./reflect >flect 2>&1
+       if $contains "/dev/fd" flect >/dev/null; then
+               echo "Congratulations, your kernel has secure setuid scripts!" >&4
+               val="$define"
+       else
+               $cat <<EOM
+If you are not sure if they are secure, I can check but I'll need a
+username and password different from the one you are using right now.
+If you don't have such a username or don't want me to test, simply
+enter 'none'.
 
-: Cruising for prototypes
-echo " "
-echo "Checking out function prototypes..." >&4
-$cat >prototype.c <<EOCP
-#$i_stdlib I_STDLIB
-#ifdef I_STDLIB
-#include <stdlib.h>
-#endif
-int main(int argc, char *argv[]) {
-       exit(0);}
-EOCP
-if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
-       echo "Your C compiler appears to support function prototypes."
-       val="$define"
+EOM
+               rp='Other username to test security of setuid scripts with?'
+               dflt='none'
+               . ./myread
+               case "$ans" in
+               n|none)
+                       case "$d_suidsafe" in
+                       '')     echo "I'll assume setuid scripts are *not* secure." >&4
+                               dflt=n;;
+                       "$undef")
+                               echo "Well, the $hint value is *not* secure." >&4
+                               dflt=n;;
+                       *)      echo "Well, the $hint value *is* secure." >&4
+                               dflt=y;;
+                       esac
+                       ;;
+               *)
+                       $rm -f reflect flect
+                       echo "#!$ls" >reflect
+                       chmod +x,u+s reflect
+                       echo >flect
+                       chmod a+w flect
+                       echo '"su" will (probably) prompt you for '"$ans's password."
+                       su $ans -c './reflect >flect'
+                       if $contains "/dev/fd" flect >/dev/null; then
+                               echo "Okay, it looks like setuid scripts are secure." >&4
+                               dflt=y
+                       else
+                               echo "I don't think setuid scripts are secure." >&4
+                               dflt=n
+                       fi
+                       ;;
+               esac
+               rp='Does your kernel have *secure* setuid scripts?'
+               . ./myread
+               case "$ans" in
+               [yY]*)  val="$define";;
+               *)      val="$undef";;
+               esac
+       fi
 else
-       echo "Your C compiler doesn't seem to understand function prototypes."
+       echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
+       echo "(That's for file descriptors, not floppy disks.)"
        val="$undef"
 fi
-set prototype
+set d_suidsafe
 eval $setvar
-$rm -f prototype*
-
-: Check if ansi2knr is required
-case "$prototype" in
-"$define") ;;
-*)     ansi2knr='ansi2knr'
-       echo " "
-       cat <<EOM >&4
-
-$me:  FATAL ERROR:
-This version of $package can only be compiled by a compiler that 
-understands function prototypes.  Unfortunately, your C compiler 
-       $cc $ccflags
-doesn't seem to understand them.  Sorry about that.
-
-If GNU cc is available for your system, perhaps you could try that instead.  
 
-Eventually, we hope to support building Perl with pre-ANSI compilers.
-If you would like to help in that effort, please contact <perlbug@perl.org>.
+$rm -f reflect flect
 
-Aborting Configure now.
-EOM
-       exit 2
+: now see if they want to do setuid emulation
+if $test $patchlevel -lt 11; then
+echo " "
+val="$undef"
+case "$d_suidsafe" in
+"$define")
+       val="$undef"
+       echo "No need to emulate SUID scripts since they are secure here." >&4
        ;;
-esac
-
-: DTrace support
-dflt_dtrace='/usr/sbin/dtrace'
-$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/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.
+*)
+       $cat <<EOM
+Some systems have disabled setuid scripts, especially systems where
+setuid scripts cannot be secure.  On systems where setuid scripts have
+been disabled, the setuid/setgid bits on scripts are currently
+useless.  It is possible for $package to detect those bits and emulate
+setuid/setgid in a secure fashion.  This emulation will only work if
+setuid scripts have been disabled in your kernel.
 
-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'
-               ;;
+       case "$d_dosuid" in
+       "$define") dflt=y ;;
+       *) dflt=n ;;
        esac
-
-       rp='Support DTrace if available?'
+       rp="Do you want to do setuid/setgid emulation?"
        . ./myread
        case "$ans" in
-       y|Y)    val="$define" ;;
-       *)      val="$undef" ;;
+       [yY]*)  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
+       ;;
+esac
+set d_dosuid
+eval $setvar
+else
+    case "$d_dosuid" in
+       "$define")
+       cat >&4 <<EOH
 
-*** $me:  Fatal Error:  $dtrace not found.
-*** Can't continue.
+SUID emulation has been removed for 5.12
+Please re-run Configure without -Dd_dosuid
 
-EOM
-               exit 1
-               ;;
-       *)
-               echo "*** $dtrace was not found."
-               echo " "
-               ;;
-       esac
-done
+EOH
+       exit 1;
+       ;;
+    esac
+    d_dosuid=undef
+fi
 
-: See if we want extra modules installed
-echo " "
-case "$extras" in
-'') dflt='n';;
-*) dflt='y';;
+: 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
-cat <<EOM
-Perl can be built with extra modules or bundles of modules which
-will be fetched from the CPAN and installed alongside Perl.
 
-Notice that you will need access to the CPAN; either via the Internet,
-or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
-be asked later to configure the CPAN.pm module which will in turn do
-the installation of the rest of the extra modules or bundles.)
+: Set the siteprefix variables
+$cat <<EOM
 
-Notice also that if the modules require any external software such as
-libraries and headers (the libz library and the zlib.h header for the
-Compress::Zlib module, for example) you MUST have any such software
-already installed, this configuration process will NOT install such
-things for you.
+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 this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-rp='Install any extra modules (y or n)?'
-. ./myread
-case "$ans" in
-y|Y)
-       cat <<EOM
+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.
 
-Please list any extra modules or bundles to be installed from CPAN,
-with spaces between the names.  The names can be in any format the
-'install' command of CPAN.pm will understand.  (Answer 'none',
-without the quotes, to install no extra modules or bundles.)
 EOM
-       rp='Extras?'
-       dflt="$extras"
-       . ./myread
-       extras="$ans"
+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
-case "$extras" in
-''|'none')
-       val=''
-       $rm -f ../extras.lst
-       ;;
-*)     echo "(Saving the list of extras for later...)"
-       echo "$extras" > ../extras.lst
-       val="'$extras'"
+. ./getfile
+: XXX Prefixit unit does not yet support siteprefix and vendorprefix
+oldsiteprefix=''
+case "$siteprefix" in
+'') ;;
+*)     case "$ans" in
+       "$prefix") ;;
+       *) oldsiteprefix="$prefix";;
+       esac
        ;;
 esac
-set extras
-eval $setvar
-echo " "
+siteprefix="$ans"
+siteprefixexp="$ansexp"
 
-: determine where html pages for programs go
-set html1dir html1dir none
-eval $prefixit
+: 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
 
-If you wish to install html files for programs in $spackage, indicate
-the appropriate directory here.  To skip installing html files,
-answer "none".
+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
-case "$html1dir" in
-''|none|$undef|' ') dflt=none ;;
-*) dflt=$html1dir ;;
-esac
-fn=dn+~
-rp="Directory for the main $spackage html pages?"
+fn=d~+
+rp='Pathname for the site-specific library files?'
 . ./getfile
-prefixvar=html1dir
+prefixvar=sitelib
 . ./setprefixvar
-: Use ' ' for none so value is preserved next time through Configure
-$test X"$html1dir" = "X" && html1dir=' '
+sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
 
-: determine where html pages for libraries and modules go
-set html3dir html3dir none
-eval $prefixit
-$cat <<EOM
+: 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
 
-If you wish to install html files for modules associated with $spackage,
-indicate the appropriate directory here.  To skip installing html files,
-answer "none".
-EOM
-: There is no obvious default.  If they have specified html1dir, then
-: try to key off that, possibly changing .../html1 into .../html3.
-case "$html3dir" in
-'') html3dir=`echo "$html1dir" | $sed 's/1$/3$/'` ;;
-*) dflt=$html3dir ;;
-esac
-fn=dn+~
-rp="Directory for the $spackage module html pages?"
-. ./getfile
-prefixvar=html3dir
-. ./setprefixvar
-: Use ' ' for none so value is preserved next time through Configure
-$test X"$html3dir" = "X" && html3dir=' '
+# 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.*");
+    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
+}
+else {
+    ;@candidates = ();
+}
 
-: determine whether to install perl also as /usr/bin/perl
+($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.
+    }
+}
 
-echo " "
-if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
-       $cat <<EOM
-Many scripts expect perl to be installed as /usr/bin/perl.
+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
 
-If you want to, I can install the perl you are about to compile
-as /usr/bin/perl (in addition to $bin/perl).
+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
-       if test -f /usr/bin/perl; then
-           $cat <<EOM
 
-However, please note that because you already have a /usr/bin/perl,
-overwriting that with a new Perl would very probably cause problems.
-Therefore I'm assuming you don't want to do that (unless you insist).
+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
 
-EOM
-           case "$installusrbinperl" in
-           "$define"|[yY]*)    dflt='y';;
-           *)                  dflt='n';;
-           esac
-       else
-           $cat <<EOM
+: see if malloc/malloc.h has to be included
+set malloc/malloc.h i_mallocmalloc
+eval $inhdr
 
-Since you don't have a /usr/bin/perl I'm assuming creating one is okay.
+: 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
+echo " "
+$cat >try.c <<EOCP
+#include <stdlib.h>
+#include <malloc.h>
+#$i_mallocmalloc I_MALLOCMALLOC
+#ifdef I_MALLOCMALLOC
+# include <malloc/malloc.h>
+#endif
 
-EOM
-           case "$installusrbinperl" in
-           "$undef"|[nN]*)     dflt='n';;
-           *)                  dflt='y';;
-           esac
-       fi
-       rp="Do you want to install perl as /usr/bin/perl?"
-       . ./myread
-       case "$ans" in
-       [yY]*)  val="$define";;
-       *)      val="$undef" ;;
-       esac
+int main () { return 0; }
+EOCP
+set try
+if eval $compile; then
+    echo "<malloc.h> found." >&4
+    val="$define"
 else
-       val="$undef"
+    echo "<malloc.h> NOT found." >&4
+    val="$undef"
 fi
-set installusrbinperl
+$rm_try
+set i_malloc
 eval $setvar
 
-: Check if we are using the GNU C library
+: check for length of pointer
 echo " "
-echo "Checking for GNU C Library..." >&4
-cat >try.c <<'EOCP'
-/* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
-   alone are insufficient to distinguish different versions, such as
-   2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
-   libc version 2.1.0.      A. Dougherty,  June 3, 2002.
-*/
+case "$ptrsize" in
+'')
+       echo "Checking to see how big your pointers are..." >&4
+       $cat >try.c <<EOCP
 #include <stdio.h>
-int main(void)
-{
-#ifdef __GLIBC__
-#   ifdef __GLIBC_MINOR__
-#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
-#           include <gnu/libc-version.h>
-           printf("%s\n",  gnu_get_libc_version());
-#       else
-           printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
-#       endif
-#   else
-       printf("%d\n",  __GLIBC__);
-#   endif
-    return 0;
-#else
-    return 1;
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
 #endif
+int main()
+{
+    printf("%d\n", (int)sizeof(void *));
+    exit(0);
 }
 EOCP
-set try
-if eval $compile_ok && $run ./try > glibc.ver; then
-       val="$define"
-       gnulibc_version=`$cat glibc.ver`
-       echo "You are using the GNU C Library version $gnulibc_version"
-else
-       val="$undef"
-       gnulibc_version=''
-       echo "You are not using the GNU C Library"
-fi
-$rm_try glibc.ver
-set d_gnulibc
-eval $setvar
+       set try
+       if eval $compile_ok; then
+               ptrsize=`$run ./try`
+               echo "Your pointers are $ptrsize bytes long."
+       else
+               dflt='4'
+               echo "(I can't seem to compile the test program.  Guessing...)" >&4
+               rp="What is the size of a pointer (in bytes)?"
+               . ./myread
+               ptrsize="$ans"
+       fi
+       ;;
+esac
+$rm_try
+case "$use64bitall" in
+"$define"|true|[yY]*)
+       case "$ptrsize" in
+       4)      cat <<EOM >&4
 
-: see if nm is to be used to determine whether a symbol is defined or not
-case "$usenm" in
-'')
-       dflt=''
-       case "$d_gnulibc" in
-       "$define")
-               echo " "
-               echo "nm probably won't work on the GNU C Library." >&4
-               dflt=n
+*** You have chosen a maximally 64-bit build,
+*** but your pointers are only 4 bytes wide.
+*** Please rerun Configure without -Duse64bitall.
+EOM
+               case "$d_quad" in
+               define)
+                       cat <<EOM >&4
+*** Since you have quads, you could possibly try with -Duse64bitint.
+EOM
+                       ;;
+               esac
+               cat <<EOM >&4
+*** Cannot continue, aborting.
+
+EOM
+
+               exit 1
                ;;
        esac
-       case "$dflt" in
-       '') 
-               if $test "$osname" = aix -a "X$PASE" != "Xdefine" -a ! -f /lib/syscalls.exp; then
-                       echo " "
-                       echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
-                       echo "'nm' won't be sufficient on this sytem." >&4
-                       dflt=n
-               fi
-               ;;
+       ;;
+esac
+
+
+: determine whether to use malloc wrapping
+echo " "
+case "$usemallocwrap" in
+[yY]*|true|$define)    dflt='y' ;;
+[nN]*|false|$undef)    dflt='n' ;;
+*)     case "$usedevel" in
+       [yY]*|true|$define)     dflt='y' ;;
+       *) dflt='n' ;;
        esac
-       case "$dflt" in
-       '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
-               if $test $dflt -gt 20; then
-                       dflt=y
-               else
-                       dflt=n
-               fi
+       ;;
+esac
+rp="Do you wish to wrap malloc calls to protect against potential overflows?"
+. ./myread
+usemallocwrap="$ans"
+case "$ans" in
+y*|true)
+       usemallocwrap="$define" ;;
+*)
+       usemallocwrap="$undef" ;;
+esac
+
+: determine which malloc to compile in
+echo " "
+case "$usemymalloc" in
+[yY]*|true|$define)    dflt='y' ;;
+[nN]*|false|$undef)    dflt='n' ;;
+*)     case "$ptrsize" in
+       4) dflt='y' ;;
+       *) dflt='n' ;;
+       esac
+       if test "$useithreads" = "$define"; then dflt='n'; fi
+       ;;
+esac
+rp="Do you wish to attempt to use the malloc that comes with $package?"
+. ./myread
+usemymalloc="$ans"
+case "$ans" in
+y*|true)
+       usemymalloc='y'
+       mallocsrc='malloc.c'
+       mallocobj="malloc$_o"
+       d_mymalloc="$define"
+       case "$libs" in
+       *-lmalloc*)
+               : Remove malloc from list of libraries to use
+               echo "Removing unneeded -lmalloc from library list" >&4
+               set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
+               shift
+               libs="$*"
+               echo "libs = $libs" >&4
                ;;
        esac
        ;;
 *)
-       case "$usenm" in
-       true|$define) dflt=y;;
-       *) dflt=n;;
-       esac
+       usemymalloc='n'
+       mallocsrc=''
+       mallocobj=''
+       d_mymalloc="$undef"
+       ;;
+esac
+
+: compute the return types of malloc and free
+echo " "
+$cat >malloc.c <<END
+#$i_malloc I_MALLOC
+#$i_stdlib I_STDLIB
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef I_MALLOC
+#include <malloc.h>
+#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]
+: 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
+: sitelib may have an optional trailing /share.
+case "$sitearch" in
+'')    dflt=`echo $sitelib | $sed 's,/share$,,'`
+       dflt="$dflt/$archname"
+       ;;
+*)     dflt="$sitearch"
        ;;
 esac
+set sitearch sitearch none
+eval $prefixit
 $cat <<EOM
 
-I can use $nm to extract the symbols from your C libraries. This
-is a time consuming task which may generate huge output on the disk (up
-to 3 megabytes) but that should make the symbols extraction faster. The
-alternative is to skip the 'nm' extraction part and to compile a small
-test program instead to determine whether each symbol is present. If
-you have a fast C compiler and/or if your 'nm' output cannot be parsed,
-this may be the best solution.
-
-You probably shouldn't let me use 'nm' if you are using the GNU C Library.
+The installation process will also create a directory for
+architecture-dependent site-specific extensions and modules.
 
 EOM
-rp="Shall I use $nm to extract C symbols from the libraries?"
-. ./myread
-case "$ans" in
-[Nn]*) usenm=false;;
-*) usenm=true;;
-esac
+fn=d~+
+rp='Pathname for the site-specific architecture-dependent library files?'
+. ./getfile
+prefixvar=sitearch
+. ./setprefixvar
+if $test X"$sitearch" = X"$sitelib"; then
+       d_sitearch="$undef"
+else
+       d_sitearch="$define"
+fi
 
-runnm=$usenm
-case "$reuseval" in
-true) runnm=false;;
-esac
+: Set the vendorprefix variables
+$cat <<EOM
 
-: nm options which may be necessary
-case "$nm_opt" in
-'') if $test -f /mach_boot; then
-               nm_opt=''       # Mach
-       elif $test -d /usr/ccs/lib; then
-               nm_opt='-p'     # Solaris (and SunOS?)
-       elif $test -f /dgux; then
-               nm_opt='-p'     # DG-UX
-       elif $test -f /lib64/rld; then
-               nm_opt='-p'     # 64-bit Irix
-       else
-               nm_opt=''
-       fi;;
-esac
+The installation process will also create a directory for
+vendor-supplied add-ons.  Vendors who supply perl with their system
+may find it convenient to place all vendor-supplied files in this
+directory rather than in the main distribution directory.  This will
+ease upgrades between binary-compatible maintenance versions of perl.
 
-: nm options which may be necessary for shared libraries but illegal
-: for archive libraries.  Thank you, Linux.
-case "$nm_so_opt" in
-'')    case "$myuname" in
-       *linux*|gnu*)
-               if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
-                       nm_so_opt='--dynamic'
-               fi
-               ;;
+Of course you may also use these directories in whatever way you see
+fit.  For example, you might use them to access modules shared over a
+company-wide network.
+
+The default answer should be fine for most people.
+This causes further questions about vendor add-ons to be skipped
+and no vendor-specific directories will be configured for perl.
+
+EOM
+rp='Do you want to configure vendor-specific add-on directories?'
+case "$usevendorprefix" in
+define|true|[yY]*) dflt=y ;;
+*)     : User may have set vendorprefix directly on Configure command line.
+       case "$vendorprefix" in
+       ''|' ') dflt=n ;;
+       *)      dflt=y ;;
        esac
        ;;
 esac
-
-: Figure out where the libc is located
-case "$runnm" in
-true)
-: get list of predefined functions in a handy place
-echo " "
-case "$libc" in
-'') libc=unknown
-       case "$libs" in
-       *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
+. ./myread
+case "$ans" in
+[yY]*) fn=d~+
+       rp='Installation prefix to use for vendor-supplied add-ons?'
+       case "$vendorprefix" in
+       '') dflt="$prefix" ;;
+       *)  dflt=$vendorprefix ;;
+       esac
+       . ./getfile
+       : XXX Prefixit unit does not yet support siteprefix and vendorprefix
+       oldvendorprefix=''
+       case "$vendorprefix" in
+       '') ;;
+       *)      case "$ans" in
+               "$prefix") ;;
+               *) oldvendorprefix="$prefix";;
+               esac
+               ;;
        esac
+       usevendorprefix="$define"
+       vendorprefix="$ans"
+       vendorprefixexp="$ansexp"
+       ;;
+*)     usevendorprefix="$undef"
+       vendorprefix=''
+       vendorprefixexp=''
        ;;
 esac
-case "$libs" in
-'') ;;
-*)  for thislib in $libs; do
-       case "$thislib" in
-       -lc|-lc_s)
-               : Handle C library specially below.
+
+: Set the vendorlib variables
+case "$vendorprefix" in
+'')    d_vendorlib="$undef"
+       vendorlib=''
+       vendorlibexp=''
+       ;;
+*)     d_vendorlib="$define"
+       : determine where vendor-supplied modules go.
+       : Usual default is /usr/local/lib/perl5/vendor_perl/$version
+       case "$vendorlib" in
+       '')
+               prog=`echo $package | $sed 's/-*[0-9.]*$//'`
+               case "$installstyle" in
+               *lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
+               *)           dflt=$vendorprefix/lib/vendor_$prog/$version ;;
+               esac
                ;;
-       -l*)
-               thislib=`echo $thislib | $sed -e 's/^-l//'`
-               if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
-                       :
-               elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
-                       :
-               elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
-                       :
-               elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
-                       :
-               elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
-                       :
-               elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
-                       :
-               elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
-                       :
-               else
-                       try=''
-               fi
-               libnames="$libnames $try"
+       *)      dflt="$vendorlib"
                ;;
-       *) libnames="$libnames $thislib" ;;
        esac
-       done
+       fn=d~+
+       rp='Pathname for the vendor-supplied library files?'
+       . ./getfile
+       vendorlib="$ans"
+       vendorlibexp="$ansexp"
        ;;
 esac
-xxx=normal
-case "$libc" in
-unknown)
-       set /lib/libc.$so
-       for xxx in $libpth; do
-               $test -r $1 || set $xxx/libc.$so
-               : The messy sed command sorts on library version numbers.
-               $test -r $1 || \
-                       set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
-                       tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
-                               h
-                               s/[0-9][0-9]*/0000&/g
-                               s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
-                               G
-                               s/\n/ /' | \
-                        $sort | $sed -e 's/^.* //'`
-               eval set \$$#
-       done
-       $test -r $1 || set /usr/ccs/lib/libc.$so
-       $test -r $1 || set /lib/libsys_s$_a
+vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
+prefixvar=vendorlib
+. ./installprefix
+
+: Set the vendorarch variables
+case "$vendorprefix" in
+'')    d_vendorarch="$undef"
+       vendorarch=''
+       vendorarchexp=''
        ;;
-*)
-       set blurfl
+*)     d_vendorarch="$define"
+       : determine where vendor-supplied architecture-dependent libraries go.
+       : vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
+       : vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
+       : vendorlib may have an optional trailing /share.
+       case "$vendorarch" in
+       '')     dflt=`echo $vendorlib | $sed 's,/share$,,'`
+               dflt="$dflt/$archname"
+               ;;
+       *)      dflt="$vendorarch" ;;
+       esac
+       fn=d~+
+       rp='Pathname for vendor-supplied architecture-dependent files?'
+       . ./getfile
+       vendorarch="$ans"
+       vendorarchexp="$ansexp"
        ;;
 esac
-if $test -r "$1"; then
-       echo "Your (shared) C library seems to be in $1."
-       libc="$1"
-elif $test -r /lib/libc && $test -r /lib/clib; then
-       echo "Your C library seems to be in both /lib/clib and /lib/libc."
-       xxx=apollo
-       libc='/lib/clib /lib/libc'
-       if $test -r /lib/syslib; then
-               echo "(Your math library is in /lib/syslib.)"
-               libc="$libc /lib/syslib"
-       fi
-elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
-       echo "Your C library seems to be in $libc, as you said before."
-elif $test -r $incpath/usr/lib/libc$_a; then
-       libc=$incpath/usr/lib/libc$_a;
-       echo "Your C library seems to be in $libc.  That's fine."
-elif $test -r /lib/libc$_a; then
-       libc=/lib/libc$_a;
-       echo "Your C library seems to be in $libc.  You're normal."
+prefixvar=vendorarch
+. ./installprefix
+if $test X"$vendorarch" = X"$vendorlib"; then
+       d_vendorarch="$undef"
 else
-       if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
-               :
-       elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
-               libnames="$libnames "`./loc clib blurfl/dyick $libpth`
-       elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
-               :
-       elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
-               :
-       elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
-               :
-       else
-               tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
-       fi
-       if $test -r "$tans"; then
-               echo "Your C library seems to be in $tans, of all places."
-               libc=$tans
-       else
-               libc='blurfl'
-       fi
+       d_vendorarch="$define"
 fi
-if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
-       dflt="$libc"
-       cat <<EOM
 
-If the guess above is wrong (which it might be if you're using a strange
-compiler, or your machine supports multiple models), you can override it here.
+: Final catch-all directories to search
+$cat <<EOM
+
+Lastly, you can have perl look in other directories for extensions and
+modules in addition to those already specified.
+These directories will be searched after
+       $sitearch
+       $sitelib
+EOM
+test X"$vendorlib" != "X" && echo '    ' $vendorlib
+test X"$vendorarch" != "X" && echo '   ' $vendorarch
+echo ' '
+case "$otherlibdirs" in
+''|' ') dflt='none' ;;
+*)     dflt="$otherlibdirs" ;;
+esac
+$cat <<EOM
+Enter a colon-separated set of extra paths to include in perl's @INC
+search path, or enter 'none' for no extra paths.
 
 EOM
+
+rp='Colon-separated list of additional directories for perl to search?'
+. ./myread
+case "$ans" in
+' '|''|none)   otherlibdirs=' ' ;;
+*)     otherlibdirs="$ans" ;;
+esac
+case "$otherlibdirs" in
+' ') val=$undef ;;
+*)     val=$define ;;
+esac
+set d_perl_otherlibdirs
+eval $setvar
+
+: Cruising for prototypes
+echo " "
+echo "Checking out function prototypes..." >&4
+$cat >prototype.c <<EOCP
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int main(int argc, char *argv[]) {
+       exit(0);}
+EOCP
+if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
+       echo "Your C compiler appears to support function prototypes."
+       val="$define"
 else
-       dflt=''
-       echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
-       cat >&4 <<EOM
-I can't seem to find your C library.  I've looked in the following places:
+       echo "Your C compiler doesn't seem to understand function prototypes."
+       val="$undef"
+fi
+set prototype
+eval $setvar
+$rm -f prototype*
+
+: Check if ansi2knr is required
+case "$prototype" in
+"$define") ;;
+*)     ansi2knr='ansi2knr'
+       echo " "
+       cat <<EOM >&4
+
+$me:  FATAL ERROR:
+This version of $package can only be compiled by a compiler that
+understands function prototypes.  Unfortunately, your C compiler
+       $cc $ccflags
+doesn't seem to understand them.  Sorry about that.
+
+If GNU cc is available for your system, perhaps you could try that instead.
+
+Eventually, we hope to support building Perl with pre-ANSI compilers.
+If you would like to help in that effort, please contact <perlbug@perl.org>.
 
+Aborting Configure now.
 EOM
-       $sed 's/^/      /' libpath
-       cat <<EOM
+       exit 2
+       ;;
+esac
 
-None of these seems to contain your C library. I need to get its name...
+: DTrace support
+dflt_dtrace='/usr/sbin/dtrace'
+$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/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.
 EOM
-fi
-fn=f
-rp='Where is your C library?'
-. ./getfile
-libc="$ans"
 
-echo " "
-echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
-set X `cat libnames`
-shift
-xxx=files
-case $# in 1) xxx=file; esac
-echo "Extracting names from the following $xxx for later perusal:" >&4
-echo " "
-$sed 's/^/     /' libnames >&4
-echo " "
-$echo $n "This may take a while...$c" >&4
+while $test 1 ; do
+       case "$usedtrace" in
+       $define|true|[yY]*)
+               dflt='y'
+               ;;
+       ?*)
+               dflt='y'
+               dflt_dtrace=$usedtrace
+               ;;
+       *)
+               dflt='n'
+               ;;
+       esac
 
-for file in $*; do
-       case $file in
-       *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
-       *) $nm $nm_opt $file 2>/dev/null;;
+       rp='Support DTrace if available?'
+       . ./myread
+       case "$ans" in
+       y|Y)    val="$define" ;;
+       *)      val="$undef" ;;
        esac
-done >libc.tmp
+       set usedtrace
+       eval $setvar
 
-$echo $n ".$c"
-$grep fprintf libc.tmp > libc.ptf
-xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
-xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
-xxx='[ADTSIWi]'
-if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
-                               -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
-       eval $xscan;\
-       $contains '^fprintf$' libc.list >/dev/null 2>&1; then
-               eval $xrun
-else
-       $nm -p $* 2>/dev/null >libc.tmp
-       $grep fprintf libc.tmp > libc.ptf
-       if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
-               eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
+       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
-               nm_opt='-p'
-               eval $xrun
-       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
+               if $dtrace -h -s ../perldtrace.d \
+                       -o perldtrace.tmp >/dev/null 2>&1 \
+                       && rm -f perldtrace.tmp
                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
-                       for thisname in $libnames $libc; do
-                               $ar tv $thisname >>libc.tmp
-                               emximp -o tmp.imp $thisname \
-                                   2>/dev/null && \
-                                   $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
-                                   < tmp.imp >>libc.tmp
-                               $rm -f tmp.imp
-                       done
-                       $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
-                       echo "Ok." >&4
+                       echo " "
+                       echo "Good: your $dtrace knows about the -h flag."
                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 &&
-                               $test -s libc.list
-                       then
-                               for thisname in $libnames; do
-                                       bld t $libnames | \
-                                       $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
-                                       $ar t $thisname >>libc.tmp
-                               done
-                               echo "Ok." >&4
-                       else
-                               echo "That didn't work either.  Giving up." >&4
-                               exit 1
-                       fi
+                       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
-fi
-nm_extract="$com"
-case "$PASE" in
-define)
-    echo " "
-    echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
-    dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
-    ;;
-*)  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
-    fi
-    ;;
+
+       case "$fastread" in
+       yes)
+               cat >&2 <<EOM
+
+*** $me:  Fatal Error:  $dtrace not found.
+*** Can't continue.
+
+EOM
+               exit 1
+               ;;
+       *)
+               echo "*** $dtrace was not found."
+               echo " "
+               ;;
+       esac
+done
+
+: See if we want extra modules installed
+echo " "
+case "$extras" in
+'') dflt='n';;
+*) dflt='y';;
 esac
-;;
+cat <<EOM
+Perl can be built with extra modules or bundles of modules which
+will be fetched from the CPAN and installed alongside Perl.
+
+Notice that you will need access to the CPAN; either via the Internet,
+or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
+be asked later to configure the CPAN.pm module which will in turn do
+the installation of the rest of the extra modules or bundles.)
+
+Notice also that if the modules require any external software such as
+libraries and headers (the libz library and the zlib.h header for the
+Compress::Zlib module, for example) you MUST have any such software
+already installed, this configuration process will NOT install such
+things for you.
+
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Install any extra modules (y or n)?'
+. ./myread
+case "$ans" in
+y|Y)
+       cat <<EOM
+
+Please list any extra modules or bundles to be installed from CPAN,
+with spaces between the names.  The names can be in any format the
+'install' command of CPAN.pm will understand.  (Answer 'none',
+without the quotes, to install no extra modules or bundles.)
+EOM
+       rp='Extras?'
+       dflt="$extras"
+       . ./myread
+       extras="$ans"
 esac
-$rm -f libnames libpath
+case "$extras" in
+''|'none')
+       val=''
+       $rm -f ../extras.lst
+       ;;
+*)     echo "(Saving the list of extras for later...)"
+       echo "$extras" > ../extras.lst
+       val="'$extras'"
+       ;;
+esac
+set extras
+eval $setvar
+echo " "
 
-: see if dld is available
-set dld.h i_dld
-eval $inhdr
+: determine where html pages for programs go
+set html1dir html1dir none
+eval $prefixit
+$cat <<EOM
+
+If you wish to install html files for programs in $spackage, indicate
+the appropriate directory here.  To skip installing html files,
+answer "none".
+EOM
+case "$html1dir" in
+''|none|$undef|' ') dflt=none ;;
+*) dflt=$html1dir ;;
+esac
+fn=dn+~
+rp="Directory for the main $spackage html pages?"
+. ./getfile
+prefixvar=html1dir
+. ./setprefixvar
+: Use ' ' for none so value is preserved next time through Configure
+$test X"$html1dir" = "X" && html1dir=' '
+
+: determine where html pages for libraries and modules go
+set html3dir html3dir none
+eval $prefixit
+$cat <<EOM
+
+If you wish to install html files for modules associated with $spackage,
+indicate the appropriate directory here.  To skip installing html files,
+answer "none".
+EOM
+: There is no obvious default.  If they have specified html1dir, then
+: try to key off that, possibly changing .../html1 into .../html3.
+case "$html3dir" in
+'') html3dir=`echo "$html1dir" | $sed 's/1$/3$/'` ;;
+*) dflt=$html3dir ;;
+esac
+fn=dn+~
+rp="Directory for the $spackage module html pages?"
+. ./getfile
+prefixvar=html3dir
+. ./setprefixvar
+: Use ' ' for none so value is preserved next time through Configure
+$test X"$html3dir" = "X" && html3dir=' '
+
+: determine whether to install perl also as /usr/bin/perl
 
-: 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
+if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
+       $cat <<EOM
+Many scripts expect perl to be installed as /usr/bin/perl.
 
-: is a C symbol defined?
-csym='tlook=$1;
-case "$3" in
--v) tf=libc.tmp; tdc="";;
--a) tf=libc.tmp; tdc="[]";;
-*) tlook="^$1\$"; tf=libc.list; tdc="()";;
-esac;
-case "$d_cplusplus" in
-    $define)   extern_C="extern \"C\"" ;;
-    *)         extern_C="extern"       ;;
-esac;
-tx=yes;
-case "$reuseval-$4" in
-true-) ;;
-true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
-esac;
-case "$tx" in
-yes)
-       tval=false;
-       if $test "$runnm" = true; then
-               if $contains $tlook $tf >/dev/null 2>&1; then
-                       tval=true;
-               elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
-                       echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
-                       $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
-                       $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
-                       $rm_try;
-               fi;
+If you want to, I can install the perl you are about to compile
+as /usr/bin/perl (in addition to $bin/perl).
+EOM
+       if test -f /usr/bin/perl; then
+           $cat <<EOM
+
+However, please note that because you already have a /usr/bin/perl,
+overwriting that with a new Perl would very probably cause problems.
+Therefore I'm assuming you don't want to do that (unless you insist).
+
+EOM
+           case "$installusrbinperl" in
+           "$define"|[yY]*)    dflt='y';;
+           *)                  dflt='n';;
+           esac
        else
-               echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
-               $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
-               $rm_try;
-       fi;
-       ;;
-*)
-       case "$tval" in
-       $define) tval=true;;
-       *) tval=false;;
-       esac;
-       ;;
-esac;
-eval "$2=$tval"'
+           $cat <<EOM
 
-: define an is-in-libc? function
-inlibc='echo " "; td=$define; tu=$undef;
-sym=$1; var=$2; eval "was=\$$2";
-tx=yes;
-case "$reuseval$was" in
-true) ;;
-true*) tx=no;;
-esac;
-case "$tx" in
-yes)
-       set $sym tres -f;
-       eval $csym;
-       case "$tres" in
-       true)
-               echo "$sym() found." >&4;
-               case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
-       *)
-               echo "$sym() NOT found." >&4;
-               case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
-       esac;;
-*)
-       case "$was" in
-       $define) echo "$sym() found." >&4;;
-       *) echo "$sym() NOT found." >&4;;
-       esac;;
-esac'
+Since you don't have a /usr/bin/perl I'm assuming creating one is okay.
+
+EOM
+           case "$installusrbinperl" in
+           "$undef"|[nN]*)     dflt='n';;
+           *)                  dflt='y';;
+           esac
+       fi
+       rp="Do you want to install perl as /usr/bin/perl?"
+       . ./myread
+       case "$ans" in
+       [yY]*)  val="$define";;
+       *)      val="$undef" ;;
+       esac
+else
+       val="$undef"
+fi
+set installusrbinperl
+eval $setvar
 
 : see if dlopen exists
 xxx_runnm="$runnm"
@@ -7836,6 +8312,7 @@ runnm=false
 : with g++ one needs -shared to get is-in-libc to work for dlopen
 case "$gccversion" in
 '')    ;;
+*Clang*)       ;;
 *)     case "$d_cplusplus" in
        "$define") ccflags="$ccflags -shared" ;;
        esac
@@ -7854,22 +8331,19 @@ eval $inhdr
 echo " "
 dldir="ext/DynaLoader"
 case "$usedl" in
-$define|y|true)
+    $define|y|true)
        dflt='y'
        usedl="$define"
        ;;
-$undef|n|false)
+    $undef|n|false)
        dflt='n'
        usedl="$undef"
        ;;
-*)
+    *)
        dflt='n'
        case "$d_dlopen" in
            $define) dflt='y' ;;
        esac
-       case "$i_dld" in
-           $define) dflt='y' ;;
-       esac
        : Does a dl_xxx.xs file exist for this operating system
        $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
        ;;
@@ -7879,23 +8353,20 @@ rp="Do you wish to use dynamic loading?"
 usedl="$ans"
 bin_ELF="$undef"
 case "$ans" in
-y*) usedl="$define"
+    y*) usedl="$define"
        case "$dlsrc" in
-       '')
-               if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
-                       dflt="$dldir/dl_${osname}.xs"
+           '') if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
+                   dflt="$dldir/dl_${osname}.xs"
                elif $test "$d_dlopen" = "$define" ; then
-                       dflt="$dldir/dl_dlopen.xs"
-               elif $test "$i_dld" = "$define" ; then
-                       dflt="$dldir/dl_dld.xs"
+                   dflt="$dldir/dl_dlopen.xs"
                else
-                       dflt=''
+                   dflt=''
                fi
                ;;
-       *)      dflt="$dldir/$dlsrc"
+           *)  dflt="$dldir/$dlsrc"
                ;;
        esac
-    echo "The following dynamic loading files are available:"
+       echo "The following dynamic loading files are available:"
        : Can not go over to $dldir because getfile has path hard-coded in.
        tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir"
        rp="Source file to use for dynamic loading"
@@ -7913,41 +8384,64 @@ compile modules that will be used to create a shared library.
 To use no flags, say "none".
 
 EOM
-    case "$cccdlflags" in
-    '')        case "$gccversion" in
+       case "$cccdlflags" in
+           '') case "$gccversion" in
                '') case "$osname" in
                        hpux)   dflt='+z' ;;
-                       next)   dflt='none' ;;
                        irix*)  dflt='-KPIC' ;;
                        svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
                        sunos)  dflt='-pic' ;;
                        *)      dflt='none' ;;
                    esac
-                       ;;
+                   ;;
                *)  case "$osname" in
-                       darwin) dflt='none' ;;
-                       linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
+                       darwin) dflt='none' ;;
+                       *linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
                        *)      dflt='-fpic' ;;
                    esac ;;
-           esac ;;
-       ' ') dflt='none' ;;
-    *) dflt="$cccdlflags" ;;
-    esac
-    rp="Any special flags to pass to $cc -c to compile shared library modules?"
-    . ./myread
-    case "$ans" in
-    none) cccdlflags=' ' ;;
-    *) cccdlflags="$ans" ;;
-    esac
+               esac ;;
+           ' ') dflt='none' ;;
+           *)   dflt="$cccdlflags" ;;
+       esac
+
+       case "$dflt" in
+           none) dflt='' ;;
+       esac
+
+       # If -Dsysroot was specified, now's the time to add it
+       # to cccdlflags
+       if test "X$sysroot" != X; then
+           case "$gccversion" in
+               '') ;;
+               *)  case "$dflt" in
+                       *sysroot*) ;;
+                       'undef'|*)
+                           dflt="$dflt --sysroot=$sysroot" ;;
+                   esac
+                   ;;
+           esac
+       fi
+
+       case "$dflt" in
+           '') dflt='none';;
+       esac
+
+       rp="Any special flags to pass to $cc -c to compile shared library modules?"
+       . ./myread
+       case "$ans" in
+           none) cccdlflags=' ' ;;
+           *)    cccdlflags="$ans" ;;
+       esac
 
-    cat << EOM
+       cat << EOM
 
 Some systems use ld to create libraries that can be dynamically loaded,
 while other systems (such as those using ELF) use $cc.
 
 EOM
-       case "$ld" in
-       '')     $cat >try.c <<EOM
+
+: Determine if this is ELF
+       $cat >try.c <<EOM
 /* Test for whether ELF binaries are produced */
 #include <fcntl.h>
 #$i_stdlib I_STDLIB
@@ -7959,37 +8453,40 @@ EOM
 #include <unistd.h>
 #endif
 int main() {
-       char b[4];
-       int i = open("a.out",O_RDONLY);
-       if(i == -1)
-               exit(1); /* fail */
-       if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
-               exit(0); /* succeed (yes, it's ELF) */
-       else
-               exit(1); /* fail */
+    char b[4];
+    int i = open("a.out",O_RDONLY);
+    if(i == -1)
+       exit(1); /* fail */
+    if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
+       exit(0); /* succeed (yes, it is ELF) */
+    exit(1); /* fail */
 }
 EOM
-               if $cc $ccflags $ldflags try.c >/dev/null 2>&1 && $run ./a.out; then
-                       cat <<EOM
+       if $cc $ccflags $ldflags -o a.out try.c >/dev/null 2>&1 && $run ./a.out; then
+           bin_ELF="$define"
+       fi
+       $rm_try
+
+       case "$ld" in
+           '') if $test $bin_ELF = "$define"; then
+                   cat <<EOM
 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
 EOM
-                       dflt="$cc"
-                       bin_ELF="$define"
+                   dflt="$cc"
                else
-                       echo "I'll use ld to build dynamic libraries."
-                       dflt='ld'
+                   echo "I'll use ld to build dynamic libraries."
+                   dflt='ld'
                fi
-               $rm_try
                ;;
-       *)      dflt="$ld"
+           *)  dflt="$ld"
                ;;
        esac
 
-    rp="What command should be used to create dynamic libraries?"
-    . ./myread
+       rp="What command should be used to create dynamic libraries?"
+       . ./myread
        ld="$ans"
 
-    cat << EOM
+       cat << EOM
 
 Some systems may require passing special flags to $ld to create a
 library that can be dynamically loaded.  If your ld flags include
@@ -7998,62 +8495,88 @@ search path, you may need to specify those -L options here as well.  To
 use no flags, say "none".
 
 EOM
-    case "$lddlflags" in
-    '') case "$osname" in
-                       beos) dflt='-nostart' ;;
-                       haiku) dflt='-shared' ;;
-                       hpux) dflt='-b';
-                             case "$gccversion" in
+       case "$lddlflags" in
+           '') case "$osname" in
+                   haiku) dflt='-shared' ;;
+                   hpux) dflt='-b';
+                         case "$gccversion" in
                              '') dflt="$dflt +vnocompatwarnings" ;;
-                             esac
-                             ;;
-                       linux|irix*|gnu*)  dflt="-shared $optimize" ;;
-                       next)  dflt='none' ;;
-                       solaris) dflt='-G' ;;
-                       sunos) dflt='-assert nodefinitions' ;;
-                       svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
-               *)     dflt='none' ;;
-                       esac
-                       ;;
-    *) dflt="$lddlflags" ;;
-    esac
+                         esac
+                         ;;
+                   *linux*|irix*|gnu*)  dflt="-shared $optimize" ;;
+                   solaris) # See [perl #66604].
+                           # On Solaris 11, gcc -m64 on amd64
+                           # appears not to understand -G.  gcc versions at
+                           # least as old as 3.4.3 support -shared, so just
+                           # use that with Solaris 11 and later, but keep
+                           # the old behavior for older Solaris versions.
+                           case "$gccversion" in
+                               '') dflt='-G' ;;
+                               *)  case "$osvers" in
+                                       2.?|2.10) dflt='-G' ;;
+                                       *) dflt='-shared' ;;
+                                   esac
+                                   ;;
+                           esac
+                           ;;
+                   sunos) dflt='-assert nodefinitions' ;;
+                   svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
+                   *)     dflt='none' ;;
+               esac
+               ;;
+           *) dflt="$lddlflags" ;;
+       esac
+
+       : Only do this for gcc, since, for example, qcc has no concept
+       : of --sysroot.
+       if $test "X$sysroot" != X; then
+           case "$gccversion" in
+               '') ;;
+               *)  dflt="$dflt --sysroot $sysroot" ;;
+           esac
+       fi
 
        : Try to guess additional flags to pick up local libraries.
        : Be careful not to append to a plain 'none'
        case "$dflt" in
-       none) dflt='' ;;
+           none) dflt='' ;;
        esac
        for thisflag in $ldflags; do
-               case "$thisflag" in
+           case "$thisflag" in
                -L*|-R*|-Wl,-R*)
-                       case " $dflt " in
+                   case " $dflt " in
                        *" $thisflag "*) ;;
                        *) dflt="$dflt $thisflag" ;;
-                       esac
-                       ;;
-               esac
+                   esac
+                   ;;
+           esac
        done
 
        case "$dflt" in
-       ''|' ') dflt='none' ;;
+           ''|' ') dflt='none' ;;
        esac
 
        case "$ldflags" in
-       *-fstack-protector*)
-           case "$dflt" in
-                       *-fstack-protector*) ;; # Don't add it again
-                       *) dflt="$dflt -fstack-protector" ;; 
+           *-fstack-protector-strong*)
+               case "$dflt" in
+                   *-fstack-protector-strong*) ;; # Don't add it again
+                   *) dflt="$dflt -fstack-protector-strong" ;;
+               esac
+               ;;
+           *-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
-    none) lddlflags=' ' ;;
-    *) lddlflags="$ans" ;;
-    esac
+       rp="Any special flags to pass to $ld to create a dynamically loaded library?"
+       . ./myread
+       case "$ans" in
+           none) lddlflags=' ' ;;
+           *) lddlflags="$ans" ;;
+       esac
 
        cat <<EOM
 
@@ -8062,56 +8585,57 @@ the resulting executable will use dynamic linking.  To use no flags,
 say "none".
 
 EOM
-    case "$ccdlflags" in
-    '') case "$osname" in
-           linux|hpux|gnu*)    dflt='-Wl,-E' ;;
-           next|sunos) dflt='none' ;;
-           *)          dflt='none' ;;
-           esac ;;
-    ' ')  dflt='none' ;;
-    *)  dflt="$ccdlflags" ;;
-    esac
-    rp="Any special flags to pass to $cc to use dynamic linking?"
-    . ./myread
-    case "$ans" in
-    none) ccdlflags=' ' ;;
-    *) ccdlflags="$ans" ;;
-    esac
-    ;;
-*)  usedl="$undef"
+       case "$ccdlflags" in
+           '') case "$osname" in
+                   *linux*|hpux|gnu*) dflt='-Wl,-E' ;;
+                   sunos)             dflt='none'   ;;
+                   *)                 dflt='none'   ;;
+               esac ;;
+           ' ') dflt='none' ;;
+           *)   dflt="$ccdlflags" ;;
+       esac
+       rp="Any special flags to pass to $cc to use dynamic linking?"
+       . ./myread
+       case "$ans" in
+           none) ccdlflags=' ' ;;
+           *)    ccdlflags="$ans" ;;
+       esac
+       ;;
+
+    *)  usedl="$undef"
        ld='ld'
-    dlsrc='dl_none.xs'
-    lddlflags=''
-    ccdlflags=''
-    ;;
+       dlsrc='dl_none.xs'
+       lddlflags=''
+       ccdlflags=''
+       ;;
 esac
 
 ld_can_script="$undef"
 case "$bin_ELF$usedl" in
-$define$define)
-    # Abuse try.h and a.out names for neat cleanup
-    $cat >try.c <<EOM
+    $define$define)
+       # Abuse try.h and a.out names for neat cleanup
+       $cat >try.c <<EOM
 void foo() {}
 void bar() {}
 EOM
-    $cat >try.h <<EOM
+       $cat >try.h <<EOM
 LIBTEST_42 {
  global:
   foo;
  local: *;
  };
 EOM
-    if $cc $cccdlflags $ccdlflags $ccflags \
-           $ldflags $lddlflags -o a.out try.c \
-           -Wl,--version-script=try.h >/dev/null 2>&1 \
-       &&  $test -s a.out ; then
-       echo "ld supports scripting" >&4
-       ld_can_script="$define"
-    else
-       echo "ld does not support scripting" >&4
-    fi
-    $rm_try
-    ;;
+       if $cc $cccdlflags $ccdlflags $ccflags \
+              $ldflags $lddlflags -o a.out try.c \
+              -Wl,--version-script=try.h >/dev/null 2>&1 \
+          &&  $test -s a.out ; then
+           echo "ld supports scripting" >&4
+           ld_can_script="$define"
+       else
+           echo "ld does not support scripting" >&4
+       fi
+       $rm_try
+       ;;
 esac
 
 : Do we want a shared libperl?
@@ -8123,19 +8647,10 @@ $undef)
        ;;
 *)     case "$useshrplib" in
        '')     case "$osname" in
-               svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|haiku|cygwin*)
+               svr4*|nonstopux|dgux|dynixptx|esix|powerux|haiku|cygwin*)
                        dflt=y
                        also='Building a shared libperl is required for dynamic loading to work on your system.'
                        ;;
-               next*)
-                       case "$osvers" in
-                       4*)     dflt=y
-                               also='Building a shared libperl is needed for MAB support.'
-                               ;;
-                       *)      dflt=n
-                               ;;
-                       esac
-                       ;;
                *)      dflt=n
                        ;;
                esac
@@ -8193,11 +8708,7 @@ true)
                # I'd prefer to keep the os-specific stuff here to a minimum, and
                # rely on figuring it out from the naming of libc.
                case "${osname}${osvers}" in
-               next4*)
-                       dflt=libperl.5.$so
-                       # XXX How handle the --version stuff for MAB?
-                       ;;
-               linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
+               *linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
                        dflt=libperl.$so
                        ;;
                cygwin*) # ld links now against the dll directly
@@ -8285,21 +8796,12 @@ if "$useshrplib"; then
        solaris)
                xxx="-R $shrpdir"
                ;;
-       freebsd|mirbsd|netbsd|openbsd|interix|dragonfly)
+       freebsd|mirbsd|netbsd|openbsd|interix|dragonfly|bitrig)
                xxx="-Wl,-R$shrpdir"
                ;;
-       bsdos|linux|irix*|dec_osf|gnu*)
+       bsdos|linux|irix*|dec_osf|gnu*|haiku)
                xxx="-Wl,-rpath,$shrpdir"
                ;;
-       next)
-               # next doesn't like the default...
-               ;;
-       beos)
-               # beos doesn't like the default, either.
-               ;;
-       haiku)
-               # Haiku doesn't like the default, either.
-               ;;
        hpux*)
                # hpux doesn't like the default, either.
                tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
@@ -8348,7 +8850,7 @@ esac
 : determine where manual pages are on this system
 echo " "
 case "$sysman" in
-'') 
+'')
        syspath='/usr/share/man/man1 /usr/man/man1'
        syspath="$syspath /usr/man/mann /usr/man/manl /usr/man/local/man1"
        syspath="$syspath /usr/man/u_man/man1"
@@ -8563,26 +9065,6 @@ esac
 
 : see if we have to deal with yellow pages, now NIS.
 if $test -d /usr/etc/yp || $test -d /etc/yp || $test -d /usr/lib/yp; then
-       if $test -f /usr/etc/nibindd; then
-               echo " "
-               echo "I'm fairly confident you're on a NeXT."
-               echo " "
-               rp='Do you get the hosts file via NetInfo?'
-               dflt=y
-               case "$hostcat" in
-               nidump*) ;;
-               '') ;;
-               *) dflt=n;;
-               esac
-               . ./myread
-               case "$ans" in
-               y*) hostcat='nidump hosts .';;
-               *)      case "$hostcat" in
-                       nidump*) hostcat='';;
-                       esac
-                       ;;
-               esac
-       fi
        case "$hostcat" in
        nidump*) ;;
        *)
@@ -8831,9 +9313,19 @@ your organization...
 EOM
 cont=x
 while test "$cont"; do
+       case "$MAILDOMAIN" in
+       '')
+               if $test -s /etc/mailname; then
+                       maildomain=`$cat /etc/mailname`
+               else
+                       maildomain="$myhostname$mydomain"
+               fi
+               ;;
+       *)  maildomain="$MAILDOMAIN";;
+       esac
        case "$cf_email" in
-       '') dflt="$cf_by@$myhostname$mydomain";;
-       *) dflt="$cf_email";;
+       '') dflt="$cf_by@$maildomain";;
+       *)  dflt="$cf_email";;
        esac
        rp='What is your e-mail address?'
        . ./myread
@@ -9094,6 +9586,29 @@ rp='Pathname where add-on public executable scripts should be installed?'
 prefixvar=sitescript
 . ./setprefixvar
 
+: see if backtrace exists
+set backtrace d_backtrace
+eval $inlibc
+
+: add flags if using c backtrace
+case "$usecbacktrace" in
+  "") usecbacktrace=$undef ;;
+  [yY]*|true|$define)
+    case "$d_backtrace" in
+      [yY]*|true|$define)
+        case " $ccflags " in
+         *" -DUSE_C_BACKTRACE "*) ;; # Already there.
+         *) ccflags="$ccflags -DUSE_C_BACKTRACE -g" ;;
+         esac
+        ;;
+      *)
+        echo "This system does not support backtrace" >&4
+        usecbacktrace=$undef
+        ;;
+      esac
+    ;;
+  esac
+
 : Check if faststdio is requested and available
 case "$usefaststdio" in
 $define|true|[yY]*|'')
@@ -9573,6 +10088,93 @@ esac
 set qgcvt d_qgcvt
 eval $inlibc
 
+: Check what kind of doubles your system has
+$echo "Checking the kind of doubles you have..." >&4
+$cat >try.c <<EOP
+#$i_stdlib I_STDLIB
+#define DOUBLESIZE $doublesize
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+static const double d = -0.1;
+int main() {
+  unsigned const char* b = (unsigned const char*)(&d);
+#if DOUBLESIZE == 4
+  if (b[0] == 0xCD && b[3] == 0xBD) {
+    /* IEEE 754 32-bit little-endian */
+    printf("1\n");
+    exit(0);
+  }
+  if (b[0] == 0xBD && b[3] == 0xCD) {
+    /* IEEE 754 32-bit big-endian */
+    printf("2\n");
+    exit(0);
+  }
+#endif
+#if DOUBLESIZE == 8
+  if (b[0] == 0x9A && b[7] == 0xBF) {
+    /* IEEE 754 64-bit little-endian */
+    printf("3\n");
+    exit(0);
+  }
+  if (b[0] == 0xBF && b[7] == 0x9A) {
+    /* IEEE 754 64-bit big-endian */
+    printf("4\n");
+    exit(0);
+  }
+  if (b[0] == 0x99 && b[3] == 0xBF && b[4] == 0x9A && b[7] == 0x99) {
+   /* ARM mixed endian: two little-endian 32-bit floats, in big endian order:
+    * 4 5 6 7 0 1 2 3 (MSB = 7, LSB = 0)
+    * 99 99 b9 bf 9a 99 99 99 */
+    printf("7\n");
+    exit(0);
+  }
+  if (b[0] == 0x99 && b[3] == 0x9A && b[4] == 0xBF && b[7] == 0x99) {
+   /* The opposite of case 7, mixed endian: two big-endian 32-bit floats,
+    * in little endian order: 3 2 1 0 7 6 5 4 (MSB = 7, LSB = 0)
+    * 99 99 99 9a bf b9 99 99 */
+    printf("8\n");
+    exit(0);
+  }
+#endif
+#if DOUBLESIZE == 16
+  if (b[0] == 0x9A && b[15] == 0xBF) {
+    /* IEEE 754 128-bit little-endian */
+    printf("5\n");
+    exit(0);
+  }
+  if (b[0] == 0xBF && b[15] == 0x9A) {
+    /* IEEE 754 128-bit big-endian */
+    printf("6\n");
+    exit(0);
+  }
+#endif
+  /* Then there are old mainframe/miniframe formats like VAX, IBM, and CRAY.
+   * Whether those environments can still build Perl is debatable. */
+  printf("-1\n"); /* unknown */
+  exit(0);
+}
+EOP
+set try
+if eval $compile; then
+    doublekind=`$run ./try`
+else
+    doublekind=-1
+fi
+case "$doublekind" in
+1) echo "You have IEEE 754 32-bit little endian doubles." >&4 ;;
+2) echo "You have IEEE 754 32-bit big endian doubles." >&4 ;;
+3) echo "You have IEEE 754 64-bit little endian doubles." >&4 ;;
+4) echo "You have IEEE 754 64-bit big endian doubles." >&4 ;;
+5) echo "You have IEEE 754 128-bit little endian doubles." >&4 ;;
+6) echo "You have IEEE 754 128-bit big endian doubles." >&4 ;;
+7) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit LEs in BE)." >&4 ;;
+8) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit BEs in LE)." >&4 ;;
+*) echo "Cannot figure out your double.  You VAX, or something?" >&4 ;;
+esac
+$rm_try
+
 : Check print/scan long double stuff
 echo " "
 
@@ -9595,7 +10197,7 @@ EOCP
                case "$yyy" in
                123.456)
                        sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
-                       sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
+                       sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
                        echo "We will use %f."
                        ;;
                esac
@@ -9617,7 +10219,7 @@ EOCP
                case "$yyy" in
                123.456)
                        sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
-                       sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
+                       sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
                        echo "We will use %Lf."
                        ;;
                esac
@@ -9639,7 +10241,7 @@ EOCP
                case "$yyy" in
                123.456)
                        sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
-                       sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
+                       sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
                        echo "We will use %llf."
                        ;;
                esac
@@ -9661,7 +10263,7 @@ EOCP
                case "$yyy" in
                123.456)
                        sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
-                       sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
+                       sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
                        echo "We will use %lf."
                        ;;
                esac
@@ -9689,6 +10291,38 @@ case "$sPRIfldbl" in
        ;;
 esac
 
+: Before committing on uselongdouble, see whether that looks sane.
+if $test "$uselongdouble" = "$define"; then
+    message=""
+    echo " "
+    echo "Checking if your long double math functions work right..." >&4
+    $cat > try.c <<EOF
+#include <math.h>
+#include <stdio.h>
+int main() {
+  printf("%"$sPRIgldbl"\n", sqrtl(logl(expl(cosl(sinl(0.0L))))+powl(2.0L, 3.0L)));
+}
+EOF
+    case "$osname:$gccversion" in
+    aix:)      saveccflags="$ccflags"
+               ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
+    esac
+    set try
+    if eval $compile_ok; then
+      yyy=`$run ./try`
+    fi
+    case "$yyy" in
+    3) echo "Your long double math functions are working correctly." >&4 ;;
+    *) echo "Your long double math functions are broken, not using long doubles." >&4
+       uselongdouble=$undef
+       ;;
+    esac
+    $rm_try
+    case "$osname:$gccversion" in
+    aix:)      ccflags="$saveccflags" ;; # restore
+    esac
+fi
+
 : Check how to convert floats to strings.
 
 if test "X$d_Gconvert" = X; then
@@ -9988,6 +10622,10 @@ $rm -f access*
 set accessx d_accessx
 eval $inlibc
 
+: see if acosh exists
+set acosh d_acosh
+eval $inlibc
+
 : see if aintl exists
 set aintl d_aintl
 eval $inlibc
@@ -10294,6 +10932,14 @@ case "$d_asctime_r" in
        ;;
 esac
 
+: see if asinh exists
+set asinh d_asinh
+eval $inlibc
+
+: see if atanh exists
+set atanh d_atanh
+eval $inlibc
+
 : see if atolf exists
 set atolf d_atolf
 eval $inlibc
@@ -10791,7 +11437,7 @@ else
        valstd="$undef"
 fi
 
-: see if varags is available
+: see if varargs is available
 echo " "
 if $test `./findhdr varargs.h`; then
        echo "<varargs.h> found." >&4
@@ -10843,6 +11489,7 @@ chmod +x varargs
 : now check which varargs header should be included
 echo " "
 i_varhdr=''
+val=''
 case "$valstd" in
 "$define")
        if `./varargs I_STDARG`; then
@@ -10859,6 +11506,15 @@ case "$valstd" in
 esac
 case "$val" in
 '')
+       echo " "
+       echo "*** WHOA THERE!!! ***" >&4
+       echo "    Your C compiler \"$cc\" doesn't seem to support stdarg or varargs!" >&4
+       case "$knowitall" in
+       '')
+       echo "    I'm giving up; maybe you can try again with a different compiler?" >&4
+               exit 1
+               ;;
+       esac
 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
@@ -11010,7 +11666,7 @@ int main()
 EOCP
 set try
 if eval $compile_ok; then
-       $run ./try
+       $run ./try 2>/dev/null
        yyy=$?
 else
        echo "(I can't seem to compile the test program--assuming it can't)"
@@ -11110,7 +11766,7 @@ int main()
 EOCP
 set try
 if eval $compile_ok; then
-       $run ./try
+       $run ./try 2>/dev/null
        castflags=$?
 else
        echo "(I can't seem to compile the test program--assuming it can't)"
@@ -11128,6 +11784,10 @@ set d_castneg
 eval $setvar
 $rm_try
 
+: see if cbrt exists
+set cbrt d_cbrt
+eval $inlibc
+
 : see if vprintf exists
 echo " "
 if set vprintf val -f d_vprintf; eval $csym; $val; then
@@ -11254,57 +11914,57 @@ sockethdr=''
 echo " "
 $echo $n "Hmm... $c" >&4
 if set socket val -f d_socket; eval $csym; $val; then
+    echo "Looks like you have Berkeley networking support." >&4
+    d_socket="$define"
+    if set setsockopt val -f; eval $csym; $val; then
+       d_oldsock="$undef"
+    else
+       echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
+       d_oldsock="$define"
+    fi
+else
+    if $contains socklib libc.list >/dev/null 2>&1; then
        echo "Looks like you have Berkeley networking support." >&4
        d_socket="$define"
-       if set setsockopt val -f; eval $csym; $val; then
-               d_oldsock="$undef"
-       else
-               echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
-               d_oldsock="$define"
-       fi
-else
-       if $contains socklib libc.list >/dev/null 2>&1; then
-               echo "Looks like you have Berkeley networking support." >&4
-               d_socket="$define"
-               : we will have to assume that it supports the 4.2 BSD interface
-               d_oldsock="$undef"
+       : we will have to assume that it supports the 4.2 BSD interface
+       d_oldsock="$undef"
+    else
+       echo "You don't have Berkeley networking in libc$_a..." >&4
+       if test "X$d_socket" = "X$define"; then
+           echo "...but you seem to believe that you have sockets." >&4
        else
-               echo "You don't have Berkeley networking in libc$_a..." >&4
-               if test "X$d_socket" = "X$define"; then
-                  echo "...but you seem to believe that you have sockets." >&4
-               else
-                       for net in net socket
-                       do
-                               if test -f /usr/lib/lib$net$_a; then
-                                       ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
-                                       $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
-                                       if $contains socket libc.list >/dev/null 2>&1; then
-                                               d_socket="$define"
-                                               socketlib="-l$net"
-                                               case "$net" in
-                                               net)
-                                                       echo "...but the Wollongong group seems to have hacked it in." >&4
-                                                       sockethdr="-I/usr/netinclude"
-                                                       ;;
-                                               esac
-                                               echo "Found Berkeley sockets interface in lib$net." >&4
-                                               if $contains setsockopt libc.list >/dev/null 2>&1; then
-                                                       d_oldsock="$undef"
-                                               else
-                                                       echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
-                                                       d_oldsock="$define"
-                                               fi
-                                               break
-                                       fi
-                               fi
-                       done
-                       if test "X$d_socket" != "X$define"; then
-                          echo "or anywhere else I see." >&4
-                          d_socket="$undef"
-                          d_oldsock="$undef"
+           for net in net socket
+           do
+               if test -f $sysroot/usr/lib/lib$net$_a; then
+                   ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) ||  \
+                   $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list
+                   if $contains socket libc.list >/dev/null 2>&1; then
+                       d_socket="$define"
+                       socketlib="-l$net"
+                       case "$net" in
+                       net)
+                           echo "...but the Wollongong group seems to have hacked it in." >&4
+                           sockethdr="-I$sysroot/usr/netinclude"
+                           ;;
+                       esac
+                       echo "Found Berkeley sockets interface in lib$net." >&4
+                       if $contains setsockopt libc.list >/dev/null 2>&1; then
+                           d_oldsock="$undef"
+                       else
+                           echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
+                           d_oldsock="$define"
                        fi
+                       break
+                   fi
                fi
+           done
+           if test "X$d_socket" != "X$define"; then
+              echo "or anywhere else I see." >&4
+              d_socket="$undef"
+              d_oldsock="$undef"
+           fi
        fi
+    fi
 fi
 
 : see if socketpair exists
@@ -11313,56 +11973,92 @@ eval $inlibc
 
 
 echo " "
-echo "Checking the availability sa_len in the sock struct ..." >&4
+echo "Checking the availability sa_len in the sock struct ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+int main() {
+struct sockaddr sa;
+return (sa.sa_len);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+    val="$define"
+fi
+set d_sockaddr_sa_len; eval $setvar
+$rm_try
+
+echo " "
+echo "Checking the availability struct sockaddr_in6 ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int main() {
+struct sockaddr_in6 sin6;
+return (sin6.sin6_family);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+    val="$define"
+fi
+set d_sockaddr_in6; eval $setvar
+$rm_try
+
+echo " "
+echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
 $cat >try.c <<EOF
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
 int main() {
-struct sockaddr sa;
-return (sa.sa_len);
+struct sockaddr_in6 sin6;
+return (sin6.sin6_scope_id);
 }
 EOF
 val="$undef"
 set try; if eval $compile; then
-       val="$define"
+    val="$define"
 fi
-set d_sockaddr_sa_len; eval $setvar
+set d_sin6_scope_id; eval $setvar
 $rm_try
 
 echo " "
-echo "Checking the availability struct sockaddr_in6 ..." >&4
+echo "Checking the availability struct ip_mreq ..." >&4
 $cat >try.c <<EOF
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 int main() {
-struct sockaddr_in6 sin6;
-return (sin6.sin6_family);
+struct ip_mreq mreq;
+return (mreq.imr_multiaddr.s_addr);
 }
 EOF
 val="$undef"
 set try; if eval $compile; then
-       val="$define"
+       val="$define"
 fi
-set d_sockaddr_in6; eval $setvar
+set d_ip_mreq; eval $setvar
 $rm_try
 
 echo " "
-echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
+echo "Checking the availability struct ip_mreq_source ..." >&4
 $cat >try.c <<EOF
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 int main() {
-struct sockaddr_in6 sin6;
-return (sin6.sin6_scope_id);
+struct ip_mreq_source mreq;
+return (mreq.imr_multiaddr.s_addr);
 }
 EOF
 val="$undef"
 set try; if eval $compile; then
-       val="$define"
+       val="$define"
 fi
-set d_sin6_scope_id; eval $setvar
+set d_ip_mreq_source; eval $setvar
 $rm_try
 
 echo " "
@@ -11378,28 +12074,46 @@ return (mreq.ipv6mr_interface);
 EOF
 val="$undef"
 set try; if eval $compile; then
-       val="$define"
+    val="$define"
 fi
 set d_ipv6_mreq; eval $setvar
 $rm_try
 
 echo " "
+echo "Checking the availability struct ipv6_mreq_source ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int main() {
+struct ipv6_mreq_source mreq;
+return (mreq.imr_multiaddr.s_addr);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+       val="$define"
+fi
+set d_ipv6_mreq_source; eval $setvar
+$rm_try
+
+echo " "
 echo "Checking the availability of certain socket constants..." >&4
 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
-       enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
-       $cat >try.c <<EOF
+    enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
+    $cat >try.c <<EOF
 #include <sys/types.h>
 #include <sys/socket.h>
 int main() {
     int i = $ENUM;
 }
 EOF
-       val="$undef"
-       set try; if eval $compile; then
-               val="$define"
-       fi
-       set d_${enum}; eval $setvar
-       $rm_try
+    val="$undef"
+    set try; if eval $compile; then
+       val="$define"
+    fi
+    set d_${enum}; eval $setvar
+    $rm_try
 done
 
 : see if this is a sys/uio.h system
 set d_const
 eval $setvar
 
+: see if copysign exists
+set copysign d_copysign
+eval $inlibc
+
 : see if copysignl exists
 set copysignl d_copysignl
 eval $inlibc
@@ -11648,10 +12366,6 @@ eval $inlibc
 set limits.h i_limits
 eval $inhdr
 
-: see if this is a float.h system
-set float.h i_float
-eval $inhdr
-
 : See if number of significant digits in a double precision number is known
 echo " "
 $cat >dbl_dig.c <<EOM
@@ -11846,9 +12560,6 @@ $cat >dirfd.c <<EOM
 #endif
 #if defined(I_DIRENT)
 #include <dirent.h>
-#if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
-#include <sys/dir.h>
-#endif
 #else
 #ifdef I_SYS_NDIR
 #include <sys/ndir.h>
@@ -11861,7 +12572,7 @@ $cat >dirfd.c <<EOM
 #endif
 #endif
 #endif
-#endif 
+#endif
 int main() {
        DIR *dirp = opendir(".");
        if (dirfd(dirp) >= 0)
@@ -11883,6 +12594,10 @@ set d_dirfd
 eval $setvar
 $rm -f dirfd*
 
+: see if dladdr exists
+set dladdr d_dladdr
+eval $inlibc
+
 : see if dlerror exists
 xxx_runnm="$runnm"
 runnm=false
@@ -12364,7 +13079,7 @@ $define)
        $rm -f $$.h
        ;;
 *)
-       val="$undef"; 
+       val="$undef";
        set d_pwquota; eval $setvar
        set d_pwage; eval $setvar
        set d_pwchange; eval $setvar
@@ -12645,8 +13360,8 @@ 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)
+       case "$d_fork:$d_pipe:$d_alarm" in
+       define:define:define)
        $cat head.c > try.c
        $cat >>try.c <<EOCP
 #include <errno.h>
@@ -12684,11 +13399,15 @@ int main()
        int pu[2];
        char buf[1];
        char string[100];
-
-       pipe(pd);       /* Down: child -> parent */
-       pipe(pu);       /* Up: parent -> child */
+       int ret;
+
+       ret = pipe(pd); /* Down: child -> parent */
+       if (ret != 0)
+               exit(3);
+       ret = pipe(pu); /* Up: parent -> child */
+       if (ret != 0)
+               exit(3);
        if (0 != fork()) {
-               int ret;
                close(pd[1]);   /* Parent reads from pd[0] */
                close(pu[0]);   /* Parent writes (blocking) to pu[1] */
 #ifdef F_SETFL
@@ -12702,7 +13421,9 @@ int main()
                if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
                        exit(2);
                sprintf(string, "%d\n", ret);
-               write(2, string, strlen(string));
+               ret = write(2, string, strlen(string));
+               if (ret != strlen(string))
+                       exit(3);
                alarm(0);
 #ifdef EAGAIN
                if (errno == EAGAIN) {
@@ -12715,19 +13436,25 @@ int main()
                        printf("EWOULDBLOCK\n");
 #endif
        ok:
-               write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
+               ret = write(pu[1], buf, 1);     /* Unblocks child, tell it to close our pipe */
+               if (ret != 1)
+                       exit(3);
                sleep(2);                               /* Give it time to close our pipe */
                alarm(5);
                ret = read(pd[0], buf, 1);      /* Should read EOF */
                alarm(0);
                sprintf(string, "%d\n", ret);
-               write(4, string, strlen(string));
+               ret = write(4, string, strlen(string));
+               if (ret != strlen(string))
+                       exit(3);
                exit(0);
        }
 
        close(pd[0]);                   /* We write to pd[1] */
        close(pu[1]);                   /* We read from pu[0] */
-       read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
+       ret = read(pu[0], buf, 1);      /* Wait for parent to signal us we may continue */
+       if (ret != 1)
+               exit(3);
        close(pd[1]);                   /* Pipe pd is now fully closed! */
        exit(0);                                /* Bye bye, thank you for playing! */
 }
@@ -12737,7 +13464,7 @@ EOCP
                echo "$startsh" >mtry
                echo "$run ./try >try.out 2>try.ret 4>try.err || exit 4" >>mtry
                chmod +x mtry
-               ./mtry >/dev/null 2>&1
+               $run ./mtry >/dev/null 2>&1
                case $? in
                0) eagain=`$cat try.out`;;
                1) echo "Could not perform non-blocking setting!";;
@@ -12803,6 +13530,22 @@ EOCP
 esac
 $rm_try head.c mtry
 
+: see if erf exists
+set erf d_erf
+eval $inlibc
+
+: see if erfc exists
+set erfc d_erfc
+eval $inlibc
+
+: see if exp2 exists
+set exp2 d_exp2
+eval $inlibc
+
+: see if expm1 exists
+set expm1 d_expm1
+eval $inlibc
+
 : see if _ptr and _cnt from stdio act std
 echo " "
 
@@ -13248,6 +13991,14 @@ EOM
 fi
 $rm_try
 
+: see if fdim exists
+set fdim d_fdim
+eval $inlibc
+
+: see if fegetround exists
+set fegetround d_fegetround
+eval $inlibc
+
 : see if fgetpos exists
 set fgetpos d_fgetpos
 eval $inlibc
@@ -13269,10 +14020,55 @@ echo " "
 set d_flockproto flock $i_sysfile sys/file.h
 eval $hasproto
 
+: see if fma exists
+set fma d_fma
+eval $inlibc
+
+: see if fmax exists
+set fmax d_fmax
+eval $inlibc
+
+: see if fmin exists
+set fmin d_fmin
+eval $inlibc
+
 : see if fp_class exists
 set fp_class d_fp_class
 eval $inlibc
 
+: see if this is a math.h system
+set math.h i_math
+eval $inhdr
+
+: check for fpclassify
+echo "Checking to see if you have fpclassify..." >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+int main() { return fpclassify(1.0) == FP_NORMAL ? 0 : 1; }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have fpclassify."
+else
+       val="$undef"
+       echo "You do not have fpclassify."
+fi
+$rm_try
+set d_fpclassify
+eval $setvar
+
+: see if fp_classify exists
+set fp_classify d_fp_classify
+eval $inlibc
+
+: see if fp_classl exists
+set fp_classl d_fp_classl
+eval $inlibc
+
 : see if pathconf exists
 set pathconf d_pathconf
 eval $inlibc
@@ -13285,14 +14081,14 @@ eval $inlibc
 set fpclass d_fpclass
 eval $inlibc
 
-: see if fpclassify exists
-set fpclassify d_fpclassify
-eval $inlibc
-
 : see if fpclassl exists
 set fpclassl d_fpclassl
 eval $inlibc
 
+: see if fpgetround exists
+set fpgetround d_fpgetround
+eval $inlibc
+
 : check for fpos64_t
 echo " "
 echo "Checking to see if you have fpos64_t..." >&4
@@ -14920,6 +15716,14 @@ esac
 set d_htonl
 eval $setvar
 
+: see if hypot exists
+set hypot d_hypot
+eval $inlibc
+
+: see if ilogb exists
+set ilogb d_ilogb
+eval $inlibc
+
 : see if ilogbl exists
 set ilogbl d_ilogbl
 eval $inlibc
@@ -15006,9 +15810,9 @@ $cat >isblank.c <<'EOCP'
 int main() {
        int c = ' ';
        if (isblank(c))
-               exit(0);
+               return 0 ;
        else
-               exit(1);
+               return 1 ;
 }
 EOCP
 if $cc $ccflags $ldflags -o isblank isblank.c $libs >/dev/null 2>&1 ; then
@@ -15022,26 +15826,160 @@ set d_isblank
 eval $setvar
 $rm -f isblank*
 
-: see if isfinite exists
-set isfinite d_isfinite
-eval $inlibc
+: check for isfinite
+echo "Checking to see if you have isfinite..." >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+int main() { return isfinite(0.0); }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have isfinite."
+else
+       val="$undef"
+       echo "You do not have isfinite."
+fi
+$rm_try
+set d_isfinite
+eval $setvar
 
-: see if isinf exists
-set isinf d_isinf
+: see if isfinitel exists
+set isfinitel d_isfinitel
 eval $inlibc
 
-: see if isnan exists
-set isnan d_isnan
+: check for isinf
+echo "Checking to see if you have isinf..." >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+int main() { return isinf(0.0); }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have isinf."
+else
+       val="$undef"
+       echo "You do not have isinf."
+fi
+$rm_try
+set d_isinf
+eval $setvar
+
+: see if isinfl exists
+set isinfl d_isinfl
 eval $inlibc
 
+: check for isless
+echo "Checking to see if you have isless..." >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+int main() { return isless(0.0); }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have isless."
+else
+       val="$undef"
+       echo "You do not have isless."
+fi
+$rm_try
+set d_isless
+eval $setvar
+
+: check for isnan
+echo "Checking to see if you have isnan..." >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+int main() { return isnan(0.0); }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have isnan."
+else
+       val="$undef"
+       echo "You do not have isnan."
+fi
+$rm_try
+set d_isnan
+eval $setvar
+
 : see if isnanl exists
 set isnanl d_isnanl
 eval $inlibc
 
+: check for isnormal
+echo "Checking to see if you have isnormal..." >&4
+$cat >try.c <<EOCP
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+int main() { return isnormal(0.0); }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have isnormal."
+else
+       val="$undef"
+       echo "You do not have isnormal."
+fi
+$rm_try
+set d_isnormal
+eval $setvar
+
+: see if j0 exists
+set j0 d_j0
+eval $inlibc
+
+: see if j0l exists
+set j0l d_j0l
+eval $inlibc
+
 : see if killpg exists
 set killpg d_killpg
 eval $inlibc
 
+: see if localeconv exists
+set localeconv d_locconv
+eval $inlibc
+
+: see if libc has the POSIX.1-2008 currency locale rules
+case "$d_locconv:$d_lc_monetary_2008" in
+$define:)
+       $cat >try.c <<EOCP
+#include <locale.h>
+int main() {
+       struct lconv *lc = localeconv();
+       char int_p_cs_precedes = lc->int_p_cs_precedes;
+       return 0;
+}
+EOCP
+       set try
+       if eval $compile; then
+               d_lc_monetary_2008="$define"
+       else
+               d_lc_monetary_2008="$undef"
+       fi;
+       $rm_try
+       ;;
+esac
+
 : see if lchown exists
 echo " "
 $cat > try.c <<'EOCP'
@@ -15101,9 +16039,13 @@ $rm -f ldbl_dig.?
 set d_ldbl_dig
 eval $setvar
 
-: see if this is a math.h system
-set math.h i_math
-eval $inhdr
+: see if lgamma exists
+set lgamma d_lgamma
+eval $inlibc
+
+: see if lgamma_r exists
+set lgamma_r d_lgamma_r
+eval $inlibc
 
 : check to see if math.h defines _LIB_VERSION
 d_libm_lib_version="$undef"
@@ -15137,6 +16079,22 @@ EOCP
 set link d_link
 eval $inlibc
 
+: see if llrint exists
+set llrint d_llrint
+eval $inlibc
+
+: see if llrintl exists
+set llrintl d_llrintl
+eval $inlibc
+
+: see if llround exists
+set llround d_llround
+eval $inlibc
+
+: see if llroundl exists
+set llroundl d_llroundl
+eval $inlibc
+
 : see if localtime_r exists
 set localtime_r d_localtime_r
 eval $inlibc
@@ -15256,14 +16214,38 @@ EOCP
 esac
 $rm_try
 
-: see if localeconv exists
-set localeconv d_locconv
-eval $inlibc
-
 : see if lockf exists
 set lockf d_lockf
 eval $inlibc
 
+: see if log1p exists
+set log1p d_log1p
+eval $inlibc
+
+: see if log2 exists
+set log2 d_log2
+eval $inlibc
+
+: see if logb exists
+set logb d_logb
+eval $inlibc
+
+: see if lrint exists
+set lrint d_lrint
+eval $inlibc
+
+: see if lrintl exists
+set lrintl d_lrintl
+eval $inlibc
+
+: see if lround exists
+set lround d_lround
+eval $inlibc
+
+: see if lroundl exists
+set lroundl d_lroundl
+eval $inlibc
+
 : see if prototype for lseek is available
 echo " "
 set d_lseekproto lseek $i_systypes sys/types.h $i_unistd unistd.h
@@ -15376,6 +16358,10 @@ eval $inlibc
 set scalbnl d_scalbnl
 eval $inlibc
 
+: see if truncl exists
+set truncl d_truncl
+eval $inlibc
+
 : see if modfl exists
 set modfl d_modfl
 eval $inlibc
@@ -15454,10 +16440,14 @@ if $test "$uselongdouble" = "$define"; then
        message="$message sqrtl"
     fi
     if $test "$d_modfl" != "$define"; then
-       if $test "$d_aintl:$d_copysignl" = "$define:$define"; then
-           echo "You have both aintl and copysignl, so I can emulate modfl."
+       if $test "$d_truncl:$d_copysignl" = "$define:$define"; then
+           echo "You have both truncl and copysignl, so I can emulate modfl."
        else
-           message="$message modfl"
+           if $test "$d_aintl:$d_copysignl" = "$define:$define"; then
+               echo "You have both aintl and copysignl, so I can emulate modfl."
+           else
+               message="$message modfl"
+           fi
        fi
     fi
     if $test "$d_frexpl" != "$define"; then
@@ -15467,6 +16457,9 @@ if $test "$uselongdouble" = "$define"; then
            message="$message frexpl"
        fi
     fi
+    if $test "$d_ldexpl" != "$define"; then
+       message="$message ldexpl"
+    fi
 
     if $test "$message" != ""; then
        $cat <<EOM >&4
@@ -15550,12 +16543,28 @@ case "$d_msghdr_s" in
 esac
 
 
-: see if msync exists
-set msync d_msync
+: see if msync exists
+set msync d_msync
+eval $inlibc
+
+: see if munmap exists
+set munmap d_munmap
+eval $inlibc
+
+: see if nan exists
+set nan d_nan
+eval $inlibc
+
+: see if nearbyint exists
+set nearbyint d_nearbyint
+eval $inlibc
+
+: see if nextafter exists
+set nextafter d_nextafter
 eval $inlibc
 
-: see if munmap exists
-set munmap d_munmap
+: see if nexttoward exists
+set nexttoward d_nexttoward
 eval $inlibc
 
 : see if nice exists
@@ -15570,6 +16579,10 @@ eval $inhdr
 set nl_langinfo d_nl_langinfo
 eval $inlibc
 
+: see if this is a quadmath.h system
+set quadmath.h i_quadmath
+eval $inhdr
+
 : check for volatile keyword
 echo " "
 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
@@ -15629,6 +16642,48 @@ define:define)
        ;;
 esac
 
+case "$usequadmath:$i_quadmath" in
+define:define)
+  nvtype="__float128"
+  nvsize=16
+  case "$libs" in
+  *quadmath*) ;;
+  *) $cat <<EOM >&4
+
+*** You requested the use of the quadmath library, but you
+*** do not seem to have the quadmath library installed.
+*** Cannot continue, aborting.
+EOM
+    exit 1
+    ;;
+  esac
+  ;;
+define:*) $cat <<EOM >&4
+
+*** You requested the use of the quadmath library, but you
+*** do not seem to have the required header, <quadmath.h>.
+EOM
+  case "$gccversion" in
+  [23].*|4.[0-5]*)
+   $cat <<EOM >&4
+*** Your gcc looks a bit old:
+*** $gccversion
+EOM
+    ;;
+  '')
+   $cat <<EOM >&4
+*** You are not running a gcc.
+EOM
+    ;;
+  esac
+  $cat <<EOM >&4
+*** For the quadmath library you need at least gcc 4.6.
+*** Cannot continue, aborting.
+EOM
+  exit 1
+  ;;
+esac
+
 $echo "(IV will be "$ivtype", $ivsize bytes)"
 $echo "(UV will be "$uvtype", $uvsize bytes)"
 $echo "(NV will be "$nvtype", $nvsize bytes)"
@@ -15647,7 +16702,7 @@ int main() {
 #endif
 #ifdef INT16
    int16_t i =  INT16_MAX;
-  uint16_t i = UINT16_MAX;
+  uint16_t u = UINT16_MAX;
   printf("int16_t\n");
 #endif
 #ifdef INT32
@@ -16115,6 +17170,9 @@ d_prctl_set_name=$undef
 case $d_prctl in
     $define)
        $cat >try.c <<EOM
+#ifdef __ANDROID__
+#include <unistd.h>
+#endif
 #include <sys/prctl.h>
 
 int main (int argc, char *argv[])
@@ -16135,14 +17193,21 @@ EOM
 set readlink d_readlink
 eval $inlibc
 
-: Check if exe is symlink to abs path of executing program
+: Check if there is a /proc symlink to the abs path of
+: the executing program.  We will honor hints of d_procselfexe=$undef
+: or procselfexe being non-empty, otherwise will try to determine both
+: if we have readlink.
+: AmigaOS will attempt to mount proc: aka /proc, if /proc/... is
+: referenced, and AmigaOS does not have a proc filesystem anyway.
 echo " "
-procselfexe=''
 val="$undef"
-case "$d_readlink" in
-    "$define")
-       : NetBSD first as /proc/self is a symlink to /proc/curproc, and it feels
-       : more tidy to avoid an extra level of symlink
+if $test "X$d_procselfexe" = Xundef; then
+       procselfexe=''
+elif $test "X$procselfexe" != X -a "X$procselfexe" != 'X '; then
+       val="$define"
+elif $test "X$d_readlink" = Xdefine; then
+        : NetBSD first as /proc/self is a symlink to /proc/curproc,
+        : and it feels more tidy to avoid an extra level of symlink
        set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
        while test $# -gt 0; do
            type=$1; try=$2
@@ -16158,8 +17223,7 @@ case "$d_readlink" in
                fi
            fi
        done
-       ;;
-esac
+fi
 $rm -f reflect
 set d_procselfexe
 eval $setvar
@@ -16313,6 +17377,25 @@ case "$sched_yield" in
 esac
 $rm_try
 
+: check for ptrdiff_t
+echo " "
+echo "Checking to see if you have ptrdiff_t..." >&4
+$cat >try.c <<EOCP
+#include <stddef.h>
+int main() { ptrdiff_t x = 7; }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have ptrdiff_t."
+else
+       val="$undef"
+       echo "You do not have ptrdiff_t."
+fi
+$rm_try
+set d_ptrdiff_t
+eval $setvar
+
 : see if random_r exists
 set random_r d_random_r
 eval $inlibc
@@ -16470,14 +17553,56 @@ eval $inlibc
 set recvmsg d_recvmsg
 eval $inlibc
 
+: see if regcomp, regcmp, or re_comp exist, for regular pattern matching
+echo " "
+if set regcomp val -f d_regcomp; eval $csym; $val; then
+       echo 'regcomp() found.' >&4
+       d_regcomp="$define"
+       d_regcmp="$undef"
+       d_re_comp="$undef"
+elif set regcmp val -f d_regcmp; eval $csym; $val; then
+       echo 'regcmp() found.' >&4
+       d_regcmp="$define"
+       d_regcomp="$undef"
+       d_re_comp="$undef"
+elif set re_comp val -f d_re_comp; eval $csym; $val; then
+       echo 're_comp() found, assuming re_exec() also exists.' >&4
+       d_re_comp="$define"
+       d_regcomp="$undef"
+       d_regcmp="$undef"
+else
+       $cat >&4 <<EOM
+No regcomp(), regcmp() nor re_comp() found !! No regular pattern matching.
+EOM
+       d_regcmp="$undef"
+       d_re_comp="$undef"
+       d_regcomp="$undef"
+fi
+
+: see if remainder exists
+set remainder d_remainder
+eval $inlibc
+
+: see if remquo exists
+set remquo d_remquo
+eval $inlibc
+
 : see if rename exists
 set rename d_rename
 eval $inlibc
 
+: see if rint exists
+set rint d_rint
+eval $inlibc
+
 : see if rmdir exists
 set rmdir d_rmdir
 eval $inlibc
 
+: see if round exists
+set round d_round
+eval $inlibc
+
 : see if memory.h is available.
 val=''
 set memory.h val
@@ -16713,6 +17838,10 @@ echo " "
 set d_sbrkproto sbrk $i_unistd unistd.h
 eval $hasproto
 
+: see if scalbn exists
+set scalbn d_scalbn
+eval $inlibc
+
 : see if select exists
 set select d_select
 eval $inlibc
@@ -17364,71 +18493,6 @@ eval $inlibc
 set setvbuf d_setvbuf
 eval $inlibc
 
-: see if sfio.h is available
-set sfio.h i_sfio
-eval $inhdr
-
-: see if sfio library is available
-case "$i_sfio" in
-$define)
-       val=''
-       set sfreserve val
-       eval $inlibc
-       ;;
-*)
-       val="$undef"
-       ;;
-esac
-: Ok, but do we want to use it.
-case "$val" in
-$define)
-       case "$usesfio" in
-       true|$define|[yY]*) dflt='y';;
-       *) dflt='n';;
-       esac
-       echo "$package can use the sfio library, but it is experimental."
-       rp="You seem to have sfio available, do you want to try using it?"
-       . ./myread
-       case "$ans" in
-       y|Y)    echo "Ok, turning on sfio then."
-               val="$define"
-               ;;
-       *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
-               val="$undef"
-               ;;
-       esac
-       ;;
-*)     case "$usesfio" in
-       true|$define|[yY]*)
-               echo "Sorry, cannot find sfio on this machine." >&4
-               echo "Ignoring your setting of usesfio=$usesfio." >&4
-               val="$undef"
-               ;;
-       esac
-       ;;
-esac
-set d_sfio
-eval $setvar
-case "$d_sfio" in
-$define) usesfio='true';;
-*) usesfio='false';;
-esac
-case "$d_sfio" in
-$define) ;;
-*)     : Remove sfio from list of libraries to use
-       case "$libs" in
-       *-lsfio*)
-               echo "Removing unneeded -lsfio from library list" >&4
-               set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
-               shift
-               libs="$*"
-               echo "libs = $libs" >&4
-               ;;
-       esac
-;;
-esac
-
-
 : see if shmctl exists
 set shmctl d_shmctl
 eval $inlibc
@@ -17488,13 +18552,13 @@ freebsd)
         h_shm=false
        val="$undef"
        set shmctl d_shmctl
-       evat $setvar
+       eval $setvar
        set shmget d_shmget
-       evat $setvar
+       eval $setvar
        set shmat d_shmat
-       evat $setvar
+       eval $setvar
        set shmdt d_shmdt
-       evat $setvar
+       eval $setvar
        ;;
     esac
     ;;
@@ -17535,7 +18599,7 @@ EOP
        if eval $compile_ok; then
                val="$define"
        else
-               echo "But you don't seem to have a useable struct sigaction." >&4
+               echo "But you don't seem to have a usable struct sigaction." >&4
                val="$undef"
        fi
 else
@@ -17876,6 +18940,10 @@ echo " "
 set d_sresuproto setresuid $i_unistd unistd.h
 eval $hasproto
 
+: see if stat exists
+set stat d_stat
+eval $inlibc
+
 : see if sys/stat.h is available
 set sys/stat.h i_sysstat
 eval $inhdr
@@ -17970,7 +19038,7 @@ EOCP
 # Respect a hint (or previous) value for perl_static_inline, if there is one.
 case "$perl_static_inline" in
 '')    # Check the various possibilities, and break out on success.
-       # For gcc, prefer __inline__, which will still permit 
+       # For gcc, prefer __inline__, which will still permit
        # cflags.SH to add in -ansi.
        case "$gccversion" in
                '') xxx="inline __inline__ __inline _inline";;
@@ -18100,11 +19168,11 @@ if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
                echo 'strerror() found.' >&4
                d_strerror="$define"
                d_strerrm='strerror(e)'
-               if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
-                       echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
+               if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
+                       echo "(You also have sys_errlist[], so we could roll our own strerror.)"
                        d_syserrlst="$define"
                else
-                       echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
+                       echo "(Since you don't have sys_errlist[], strerror() is welcome.)"
                        d_syserrlst="$undef"
                fi
     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
@@ -18112,7 +19180,7 @@ if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
                echo 'strerror() found in string header.' >&4
                d_strerror="$define"
                d_strerrm='strerror(e)'
-               if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
+               if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
                        echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
                                d_syserrlst="$define"
                else
@@ -18498,6 +19566,10 @@ echo " "
 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
 eval $hasproto
 
+: see if tgamma exists
+set tgamma d_tgamma
+eval $inlibc
+
 : see if time exists
 echo " "
 if test "X$d_time" = X -o X"$timetype" = X; then
@@ -18583,6 +19655,10 @@ case "$d_tmpnam_r" in
        ;;
 esac
 
+: see if trunc exists
+set trunc d_trunc
+eval $inlibc
+
 : see if truncate exists
 set truncate d_truncate
 eval $inlibc
@@ -18650,7 +19726,7 @@ eval $setvar
 
 : Check if is a multiplatform env
 case "$osname" in
-next|rhapsody|darwin) multiarch="$define" ;;
+darwin) multiarch="$define" ;;
 esac
 case "$multiarch" in
 ''|[nN]*) multiarch="$undef" ;;
@@ -18658,10 +19734,10 @@ esac
 
 : check for ordering of bytes in a UV
 echo " "
-case "$usecrosscompile$multiarch" in
+case "$multiarch" in
 *$define*)
        $cat <<EOM
-You seem to be either cross-compiling or doing a multiarchitecture build,
+You seem to be doing a multiarchitecture build,
 skipping the byteorder check.
 
 EOM
@@ -18891,9 +19967,6 @@ case "$d_closedir" in
 #endif
 #if defined(I_DIRENT)
 #include <dirent.h>
-#if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
-#include <sys/dir.h>
-#endif
 #else
 #ifdef I_SYS_NDIR
 #include <sys/ndir.h>
@@ -18939,10 +20012,67 @@ eval $inlibc
 set waitpid d_waitpid
 eval $inlibc
 
+: look for wcscmp
+echo " "
+$cat >try.c <<'EOCP'
+#include <stdio.h>
+#include <wchar.h>
+int main ()
+{
+    wchar_t *s = L" ";
+    return (wcscmp (s, s) ? 1 : 0);
+    }
+EOCP
+set try
+val="$undef"
+if eval $compile; then
+    `$run ./try`
+    case "$?" in
+       0)  echo "A working wcscmp() found." >&4
+           val="$define" ;;
+       *)  echo "wcscmp() found, but it doesn't work" >&4
+           ;;
+       esac
+else
+    echo "wcscmp() NOT found." >&4
+    fi
+set d_wcscmp
+eval $setvar
+$rm_try
+
 : see if wcstombs exists
 set wcstombs d_wcstombs
 eval $inlibc
 
+: look for wcsxfrm
+echo " "
+$cat >try.c <<'EOCP'
+#include <errno.h>
+#include <wchar.h>
+int main ()
+{
+    wchar_t dst[4], *src = L" ";
+    errno = 0;
+    return (wcsxfrm (dst, src, 1) ? errno ? errno : 0 : 1);
+    }
+EOCP
+set try
+val="$undef"
+if eval $compile; then
+    `$run ./try`
+    case "$?" in
+       0)  echo "A working wcsxfrm() found." >&4
+           val="$define" ;;
+       *)  echo "wcsxfrm() found, but it doesn't work" >&4
+           ;;
+       esac
+else
+    echo "wcsxfrm() NOT found." >&4
+    fi
+set d_wcsxfrm
+eval $setvar
+$rm_try
+
 : see if wctomb exists
 set wctomb d_wctomb
 eval $inlibc
@@ -18951,43 +20081,24 @@ eval $inlibc
 set writev d_writev
 eval $inlibc
 
-: preserve RCS keywords in files with variable substitution, grrr
-Date='$Date'
-Id='$Id'
-Log='$Log'
-RCSfile='$RCSfile'
-Revision='$Revision'
-
 : check for alignment requirements
 echo " "
-case "$usecrosscompile$multiarch" in
-*$define*)
-       $cat <<EOM
-You seem to be either cross-compiling or doing a multiarchitecture build,
-skipping the memory alignment check.
-
-EOM
-       case "$alignbytes" in
-       '') alignbytes=8 ;;
-       esac
-       ;;
-*)
-       case "$alignbytes" in
-       '') echo "Checking alignment constraints..." >&4
-               if $test "X$uselongdouble" = Xdefine -a "X$d_longdbl" = Xdefine; then
-                       $cat >try.c <<'EOCP'
+case "$alignbytes" in
+    '') echo "Checking alignment constraints..." >&4
+       if $test "X$uselongdouble" = Xdefine -a "X$d_longdbl" = Xdefine; then
+           $cat >try.c <<'EOCP'
 typedef long double NV;
 EOCP
-               else
-                       $cat >try.c <<'EOCP'
+       else
+           $cat >try.c <<'EOCP'
 typedef double NV;
 EOCP
-               fi
-               $cat >>try.c <<'EOCP'
+       fi
+       $cat >>try.c <<'EOCP'
 #include <stdio.h>
 struct foobar {
-       char foo;
-       NV bar;
+    char foo;
+    NV bar;
 } try_algn;
 int main()
 {
@@ -18995,29 +20106,37 @@ int main()
     return(0);
 }
 EOCP
-               set try
-               if eval $compile_ok; then
-                       dflt=`$run ./try`
-               else
-                       dflt='8'
-                       echo "(I can't seem to compile the test program...)"
+       set try
+       if eval $compile_ok; then
+           dflt=`$run ./try`
+       else
+           dflt='8'
+           echo "(I can't seem to compile the test program...)"
+       fi
+       case "$multiarch" in
+           *$define*)
+               : The usual safe value is 8, but Darwin with -Duselongdouble
+               : needs 16.  Hence, we will take 8 as a minimum, but allow
+               : Configure to pick a larger value if needed.
+               if $test "$dflt" -lt 8; then
+                   dflt='8'
+                   echo "Setting alignment to 8 for multiarch support.">&4
                fi
                ;;
-       *) dflt="$alignbytes"
-               ;;
        esac
-       rp="Doubles must be aligned on a how-many-byte boundary?"
-       . ./myread
-       alignbytes="$ans"
-       $rm_try
+       ;;
+    *) dflt="$alignbytes"
        ;;
 esac
-
+rp="Doubles must be aligned on a how-many-byte boundary?"
+. ./myread
+alignbytes="$ans"
+$rm_try
 
 : set the base revision
 baserev=5.0
 
-: length of character in bytes. Is always 1, otherwise it isnt C
+: length of character in bytes. Is always 1, otherwise it is not C
 : This used to be a test using sizeof
 charsize=1
 
@@ -19207,9 +20326,7 @@ define)
 #include <db.h>
 
 #ifndef DB_VERSION_MAJOR
-u_int32_t hash_cb (ptr, size)
-const void *ptr;
-size_t size;
+u_int32_t hash_cb (const void* ptr, size_t size)
 {
 }
 HASHINFO info;
@@ -19251,61 +20368,303 @@ define)
 #include <sys/types.h>
 #include <db.h>
 
-#ifndef DB_VERSION_MAJOR
-size_t prefix_cb (key1, key2)
-const DBT *key1;
-const DBT *key2;
-{
-}
-BTREEINFO info;
-int main()
-{
-       info.prefix = prefix_cb;
+#ifndef DB_VERSION_MAJOR
+size_t prefix_cb (const DBT *key1, const DBT *key2)
+{
+}
+BTREEINFO info;
+int main()
+{
+       info.prefix = prefix_cb;
+}
+#endif
+EOCP
+       if $cc $ccflags -c try.c  >try.out 2>&1 ; then
+               if $contains warning try.out >>/dev/null 2>&1 ; then
+                       db_prefixtype='int'
+               else
+                       db_prefixtype='size_t'
+               fi
+       else
+               db_prefixtype='size_t'
+               : XXX Maybe we should just give up here.
+               $cat try.out >&4
+               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_try
+       echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
+       ;;
+*)     db_prefixtype='size_t'
+       ;;
+esac
+
+: Check what kind of inf/nan your system has
+$echo "Checking the kind of infinities and nans you have..." >&4
+$cat >try.c <<EOP
+#define DOUBLESIZE $doublesize
+#$d_longdbl HAS_LONG_DOUBLE
+#ifdef HAS_LONG_DOUBLE
+#define LONGDBLSIZE $longdblsize
+#define LONGDBLKIND $longdblkind
+#endif
+#$i_math I_MATH
+#ifdef I_MATH
+#include <math.h>
+#endif
+#include <stdio.h>
+/* Note that whether the sign bit is on or off
+ * for NaN depends on the CPU/FPU, and possibly
+ * can be affected by the build toolchain.
+ *
+ * For example for older MIPS and HP-PA 2.0 the quiet NaN is:
+ * 0x7f, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ * 0x7f, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ * (respectively) as opposed to the more usual
+ * 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ */
+static void bytes(unsigned char *p, unsigned int n) {
+  int i;
+  for (i = 0; i < n; i++) {
+    printf("0x%02x%s", p[i], i < n - 1 ? ", " : "\n");
+  }
+}
+int main(int argc, char *argv[]) {
+   /* We cannot use 1.0/0.0 and 0.0/0.0 (with L suffixes for long double)
+    * because some compilers are 'smart' and not only warn but refuse to
+    * compile such 'illegal' values. */
+   double dinf = exp(1e9);
+   double dnan = sqrt(-1.0);
+#ifdef HAS_LONG_DOUBLE
+   long double ldinf = (long double)exp(1e9);
+   long double ldnan = (long double)sqrt(-1.0);
+#endif
+  if (argc == 2) {
+    switch (argv[1][0]) {
+    case '1': bytes(&dinf, sizeof(dinf)); break;
+    case '2': bytes(&dnan, sizeof(dnan)); break;
+#ifdef HAS_LONG_DOUBLE
+# if LONG_DOUBLEKIND == 3 || LONG_DOUBLEKIND == 4
+/* the 80-bit long doubles might have garbage in their excess bytes */
+    memset((char *)&ldinf + 10, '\0', LONG_DOUBLESIZE - 10);
+# endif
+    case '3': bytes(&ldinf, sizeof(ldinf)); break;
+    case '4': bytes(&ldnan, sizeof(ldnan)); break;
+#endif
+    }
+  }
+  return 0;
+}
+EOP
+set try
+if eval $compile; then
+    doubleinfbytes=`$run ./try 1`
+    doublenanbytes=`$run ./try 2`
+    case "$d_longdbl" in
+    $define)
+      longdblinfbytes=`$run ./try 3`
+      longdblnanbytes=`$run ./try 4`
+      ;;
+    esac
+else
+    # Defaults in case the above test program failed.
+    case "$doublekind" in
+    1) # IEEE 754 32-bit LE
+       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f'
+       doublenanbytes='0x00, 0x00, 0xf8, 0x7f'
+       ;;
+    2) # IEEE 754 32-bit BE
+       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00'
+       doublenanbytes='0x7f, 0xf8, 0x00, 0x00'
+       ;;
+    3) # IEEE 754 64-bit LE
+       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
+       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
+       ;;
+    4) # IEEE 754 64-bit BE
+       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    5) # IEEE 754 128-bit LE
+       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
+       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
+       ;;
+    6) # IEEE 754 128-bit BE
+       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    7) # IEEE 754 64-bit mixed: 32-bit LEs in BE
+       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00'
+       doublenanbytes='0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    8) # IEEE 754 64-bit mixed: 32-bit BEs in LE
+       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00'
+       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00'
+       ;;
+    *) # No idea.
+       doubleinfbytes=$undef
+       doublenanbytes=$undef
+       ;;
+    esac
+    case "$longdblkind" in
+    1) # IEEE 754 128-bit LE
+       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f'
+       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f'
+       ;;
+    2) # IEEE 754 128-bit BE
+       longdblinfbytes='0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       longdblnanbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    3) # IEEE 754 80-bit LE, 12 or 16 bytes (x86)
+       case "$longdblsize" in
+       12) # x86 32-bit (96 bits, or 4 x 32, or 12 x 8)
+           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00'
+           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00'
+           ;;
+       16) # x86_64
+           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+           ;;
+       *)  # No idea.
+           longdblinfbytes=$undef
+           longdblnanbytes=$undef
+       ;;
+       esac
+       ;;
+    4) # IEEE 754 80-bit BE, 12 or 16 bytes
+       case "$longdblsize" in
+       12) # 32-bit system
+           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+           ;;
+       16) # 64-bit system
+           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+           ;;
+       *)  # No idea.
+           longdblinfbytes=$undef
+           longdblnanbytes=$undef
+       ;;
+       esac
+       ;;
+    5) # 128-bit LE-LE "double double"
+       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
+       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
+       ;;
+    6) # 128-bit BE-BE "double double"
+       longdblinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       longdblnanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    7) # 128-bit LE-BE "double double"
+       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    8) # 128-bit BE-LE "double double"
+       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
+       ;;
+    *) # No idea.
+       longdblinfbytes=$undef
+       longdblnanbytes=$undef
+       ;;
+    esac
+fi
+$rm_try
+
+: Check the length of the double mantissa
+$echo "Checking how many mantissa bits your doubles have..." >&4
+$cat >try.c <<EOP
+#$i_float I_FLOAT
+#$i_sunmath I_SUNMATH
+#ifdef I_FLOAT
+# include <float.h>
+#endif
+#ifdef I_SUNMATH
+# include <sunmath.h>
+#endif
+#ifdef DBL_MANT_DIG
+# define BITS (DBL_MANT_DIG - 1) /* the implicit bit does not count */
+#endif
+#include <stdio.h>
+int main(int argc, char *argv[]) {
+#ifdef BITS
+  printf("%d\n", BITS);
+#endif
+  return 0;
 }
+EOP
+set try
+if eval $compile; then
+    doublemantbits=`$run ./try`
+else
+    doublemantbits="$undef"
+fi
+$rm_try
+
+: Check the length of the longdouble mantissa
+$echo "Checking how many mantissa bits your long doubles have..." >&4
+$cat >try.c <<EOP
+#$i_float I_FLOAT
+#$i_sunmath I_SUNMATH
+#ifdef I_FLOAT
+# include <float.h>
 #endif
-EOCP
-       if $cc $ccflags -c try.c  >try.out 2>&1 ; then
-               if $contains warning try.out >>/dev/null 2>&1 ; then
-                       db_prefixtype='int'
-               else
-                       db_prefixtype='size_t'
-               fi
-       else
-               db_prefixtype='size_t'
-               : XXX Maybe we should just give up here.
-               $cat try.out >&4
-               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_try
-       echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
-       ;;
-*)     db_prefixtype='size_t'
-       ;;
-esac
+#ifdef I_SUNMATH
+# include <sunmath.h>
+#endif
+#$d_longdbl HAS_LONG_DOUBLE
+#if defined(HAS_LONG_DOUBLE) && defined(LDBL_MANT_DIG)
+# if ($longdblkind == 3) || ($longdblkind == 4) /* 80-bit extended precision */
+/* This format has no implicit bit.  Beware, however, that for
+ * this format the bare LDBL_MANT_DIG is misleading for inf/nan:
+ * the top three bits are used for inf (100) / qnan (11x) / snan (101),
+ * and the top bit must have been one since 387, zero is plain invalid.
+ * For normal fp values, the LDBL_MANT_DIG is fine, though. */
+#  define BITS LDBL_MANT_DIG
+# elif ($longdblkind == 5 || $longdblkind == 6 || $longdblkind == 7 || $longdblkind == 8) /* double double */
+/* LDBL_MANT_DIG of 106 (twice 53) would be logical, but for some
+ * reason e.g. Irix thinks 107.  But in any case, we want only
+ * the number of real bits, the implicit bits are of no interest.  */
+#  define BITS 2 * (DBL_MANT_DIG - 1)
+# else
+#  define BITS (LDBL_MANT_DIG - 1) /* the implicit bit does not count */
+# endif
+#endif
+#include <stdio.h>
+int main(int argc, char *argv[]) {
+#ifdef BITS
+  printf("%d\n", BITS);
+#endif
+  return 0;
+}
+EOP
+set try
+if eval $compile; then
+    longdblmantbits=`$run ./try`
+else
+    longdblmantbits="$undef"
+fi
+$rm_try
+
+: Check the length of the NV mantissa
+$echo "Checking how many mantissa bits your NVs have..." >&4
+if test "X$usequadmath" = "X$define"; then
+  nvmantbits=112 # 128-1-15
+else
+  if test "X$nvsize" = "X$doublesize"; then
+    nvmantbits="$doublemantbits"
+  else
+     if test "X$nvsize" = "X$longdblsize"; then
+       nvmantbits="$longdblmantbits"
+     else
+       nvmantbits="$undef"
+     fi
+  fi
+fi
 
 : How can we generate normalized random numbers ?
 echo " "
-echo "Looking for a random number function..." >&4
-case "$randfunc" in
-'')
-       if set drand48 val -f; eval $csym; $val; then
-               dflt="drand48"
-               echo "Good, found drand48()." >&4
-       elif set random val -f; eval $csym; $val; then
-               dflt="random"
-               echo "OK, found random()." >&4
-       else
-               dflt="rand"
-               echo "Yick, looks like I have to use rand()." >&4
-       fi
-       echo " "
-       ;;
-*)
-       dflt="$randfunc"
-       ;;
-esac
-cont=true
+echo "Using our internal random number implementation..." >&4
 
 case "$ccflags" in
 *-Dmy_rand=*|*-Dmy_srand=*)
@@ -19316,103 +20675,11 @@ case "$ccflags" in
        ;;
 esac
 
-while $test "$cont"; do
-       rp="Use which function to generate random numbers?"
-       . ./myread
-       if $test "$ans" = "$dflt"; then
-               : null
-       else
-               randbits=''
-       fi
-       randfunc="$ans"
-       if set $ans val -f; eval $csym; $val; then
-               cont=''
-       else
-               dflt=y
-               rp="I cannot find function $ans. Use that name anyway?"
-               . ./myread
-               dflt=rand
-               case "$ans" in
-                       [yY]*) cont='';;
-               esac
-       fi
-       case "$cont" in
-       '')
-               case "$randfunc" in
-               drand48)
-                       drand01="drand48()"
-                       seedfunc="srand48"
-                       randbits=48
-                       randseedtype=long
-                       ;;
-               rand|random)
-                       case "$randbits" in
-                       '')
-echo "Checking to see how many bits your $randfunc() function produces..." >&4
-                               $cat >try.c <<EOCP
-#$i_unistd I_UNISTD
-#$i_stdlib I_STDLIB
-#include <stdio.h>
-#ifdef I_UNISTD
-#  include <unistd.h>
-#endif
-#ifdef I_STDLIB
-#  include <stdlib.h>
-#endif
-int main()
-{
-       register int i;
-       register unsigned long tmp;
-       register unsigned long max = 0L;
-
-       for (i = 1000; i; i--) {
-               tmp = (unsigned long) $randfunc();
-               if (tmp > max) max = tmp;
-       }
-       for (i = 0; max; i++)
-               max /= 2;
-       printf("%d\n",i);
-}
-EOCP
-                               set try
-                               if eval $compile_ok; then
-                                       dflt=`try`
-                               else
-                                       dflt='?'
-                                       echo "(I can't seem to compile the test program...)"
-                               fi
-                               ;;
-                       *)
-                               dflt="$randbits"
-                               ;;
-                       esac
-                       rp="How many bits does your $randfunc() function produce?"
-                       . ./myread
-                       randbits="$ans"
-                       $rm_try
-                       drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
-                       seedfunc="s$randfunc"
-                       randseedtype=unsigned
-                       ;;
-               *)
-                       dflt="31"
-                       rp="How many bits does your $randfunc() function produce?"
-                       . ./myread
-                       randbits="$ans"
-                       seedfunc="s$randfunc"
-                       drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
-                       if set $seedfunc val -f; eval $csym; $val; then
-                               echo "(Using $seedfunc() to seed random generator)"
-                       else
-                               echo "(Warning: no $seedfunc() to seed random generator)"
-                               seedfunc=rand
-                       fi
-                       randseedtype=unsigned
-                       ;;
-               esac
-               ;;
-       esac
-done
+randfunc=Perl_drand48
+drand01="Perl_drand48()"
+seedfunc="Perl_drand48_init"
+randbits=48
+randseedtype=U32
 
 : Determine if this is an EBCDIC system
 echo " "
@@ -19524,7 +20791,7 @@ if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
     output=''
     set try -DTRY_FPUTC
     if eval $compile; then
-           $run ./try 2>/dev/null
+           $run ./try 2>/dev/null
            code="$?"
            $from try.out
            if $test ! -s try.out -a "X$code" = X42; then
@@ -19535,7 +20802,7 @@ if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
     '')
            set try -DTRY_FPRINTF
            if eval $compile; then
-                   $run ./try 2>/dev/null
+                   $run ./try 2>/dev/null
                    code="$?"
                    $from try.out
                    if $test ! -s try.out -a "X$code" = X42; then
@@ -19545,11 +20812,11 @@ if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
        ;;
     esac
 fi
-: check for fflush NULL behaviour
+: check for fflush NULL behavior
 case "$fflushNULL" in
 '')    set try -DTRY_FFLUSH_NULL $output
        if eval $compile; then
-               $run ./try 2>/dev/null
+               $run ./try 2>/dev/null
                code="$?"
                $from try.out
                if $test -s try.out -a "X$code" = X42; then
@@ -19580,37 +20847,44 @@ main(int argc, char **argv)
     int i;
     char *bp = buf;
     while (1) {
-        while ((i = getc(stdin)) != -1
-               && (*bp++ = i) != '\n'
-               && bp < &buf[1024])
-       /* DO NOTHING */ ;
-        *bp = '\0';
-        fprintf(stdout, "%s", buf);
-        fflush(NULL);
-        if (i == -1)
+       while ((i = getc(stdin)) != -1
+              && (*bp++ = i) != '\n'
+              && bp < &buf[1024])
+       /* DO NOTHING */ ;
+       *bp = '\0';
+       fprintf(stdout, "%s", buf);
+       fflush(NULL);
+       if (i == -1)
            return 0;
-        bp = buf;
+       bp = buf;
     }
 }
 EOCP
-                fflushNULL="$define"
-                set tryp
-                if eval $compile; then
-                    $rm -f tryp.out
-                    $cat tryp.c | $run ./tryp 2>/dev/null > tryp.out
-                    if cmp tryp.c tryp.out >/dev/null 2>&1; then
-                       $cat >&4 <<EOM
+               fflushNULL="$define"
+               set tryp
+               if eval $compile; then
+                   $rm -f tryp.out
+                   # Copy the .c file to the remote host ($to is an ssh-alike if targethost is set)
+                   if $test "X$targethost" != X; then
+                       $to tryp.c
+                       $to tryp
+                       $run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
+                   else
+                       $cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
+                   fi
+                   if cmp tryp.c tryp.out >/dev/null 2>&1; then
+                      $cat >&4 <<EOM
 fflush(NULL) seems to behave okay with input streams.
 EOM
                        fflushNULL="$define"
-                    else
+                   else
                        $cat >&4 <<EOM
 Ouch, fflush(NULL) clobbers input pipes!  We will not use it.
 EOM
-                        fflushNULL="$undef"
-                    fi
-                fi
-               $rm -f core tryp.c tryp.core core.tryp.*
+                       fflushNULL="$undef"
+                   fi
+               fi
+               $rm -f core tryp.c tryp.core core.tryp.*
                ;;
        '')     $cat >&4 <<EOM
 Your fflush(NULL) isn't working (contrary to ANSI C).
@@ -19661,7 +20935,13 @@ EOCP
        set tryp
        if eval $compile; then
            $rm -f tryp.out
-           $cat tryp.c | $run ./tryp 2>/dev/null > tryp.out
+           if $test "X$targethost" != X; then
+               $to tryp.c
+               $to tryp
+               $run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
+           else
+               $cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
+           fi
            if cmp tryp.c tryp.out >/dev/null 2>&1; then
               $cat >&4 <<EOM
 Good, at least fflush(stdin) seems to behave okay when stdin is a pipe.
@@ -20032,20 +21312,29 @@ else
        fi
 fi
 
-if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
+if $test X"$usequadmath" = X"$define"; then
+    nveformat='"Qe"'
+    nvfformat='"Qf"'
+    nvgformat='"Qg"'
+    nvEUformat='"QE"'
+    nvFUformat='"QF"'
+    nvGUformat='"QG"'
+else
+    if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
        nveformat="$sPRIeldbl"
        nvfformat="$sPRIfldbl"
        nvgformat="$sPRIgldbl"
        nvEUformat="$sPRIEUldbl"
        nvFUformat="$sPRIFUldbl"
        nvGUformat="$sPRIGUldbl"
-else
+    else
        nveformat='"e"'
        nvfformat='"f"'
        nvgformat='"g"'
        nvEUformat='"E"'
        nvFUformat='"F"'
        nvGUformat='"G"'
+    fi
 fi
 
 case "$ivdformat" in
@@ -20122,40 +21411,6 @@ EOM
 *)  groupstype="$gidtype";;
 esac
 
-: MAD = Misc Attribute Definition
-
-if $test $patchlevel -lt 9; then
-: MAD is not available in 5.8.x or earlier.
-    ans=n;
-else
-    case "$mad" in
-    $define|true|[yY]*)        dflt='y' ;;
-    *)                 dflt='n' ;;
-    esac
-    cat <<EOM
-
-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.
-
-If this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-    rp='Build Perl with MAD?'
-    . ./myread
-fi
-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
-
 : check whether make sets MAKE
 echo " "
 echo "Checking if your $make program sets \$(MAKE)..." >&4
@@ -20243,6 +21498,7 @@ EOCP
        $rm_try
        ;;
 *)     echo "You don't have <stdarg.h>, not checking for va_copy()." >&4
+       need_va_copy="$undef"
        ;;
 esac
 
@@ -20251,7 +21507,7 @@ rp="What is the type used for the length parameter for string functions?"
 set size_t sizetype 'unsigned int' stdio.h sys/types.h
 eval $typedef_ask
 
-: check for type of arguments to gethostbyaddr. 
+: check for type of arguments to gethostbyaddr.
 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
        case "$d_gethbyaddr" in
        $define)
@@ -20260,8 +21516,8 @@ if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
 Checking to see what type of arguments are accepted by gethostbyaddr().
 EOM
                hdrs="$define sys/types.h
-                       $d_socket sys/socket.h 
-                       $i_niin netinet/in.h 
+                       $d_socket sys/socket.h
+                       $i_niin netinet/in.h
                        $i_netdb netdb.h
                        $i_unistd unistd.h"
                : The first arg can 'char *' or 'void *'
@@ -20298,12 +21554,12 @@ EOM
                netdb_hlen_type="$sizetype"
                ;;
        esac
-       # Remove the "const" if needed. -- but then we'll have a 
+       # Remove the "const" if needed. -- but then we'll have a
        # prototype clash!
        # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
 fi
 
-: check for type of argument to gethostbyname. 
+: check for type of argument to gethostbyname.
 if test "X$netdb_name_type" = X ; then
        case "$d_gethbyname" in
        $define)
@@ -20312,8 +21568,8 @@ if test "X$netdb_name_type" = X ; then
 Checking to see what type of argument is accepted by gethostbyname().
 EOM
                hdrs="$define sys/types.h
-                       $d_socket sys/socket.h 
-                       $i_niin netinet/in.h 
+                       $d_socket sys/socket.h
+                       $i_niin netinet/in.h
                        $i_netdb netdb.h
                        $i_unistd unistd.h"
                for xxx in "const char *" "char *"; do
@@ -20341,7 +21597,7 @@ EOM
        esac
 fi
 
-: check for type of 1st argument to getnetbyaddr. 
+: check for type of 1st argument to getnetbyaddr.
 if test "X$netdb_net_type" = X ; then
        case "$d_getnbyaddr" in
        $define)
@@ -20350,8 +21606,8 @@ if test "X$netdb_net_type" = X ; then
 Checking to see what type of 1st argument is accepted by getnetbyaddr().
 EOM
                hdrs="$define sys/types.h
-                       $d_socket sys/socket.h 
-                       $i_niin netinet/in.h 
+                       $d_socket sys/socket.h
+                       $i_niin netinet/in.h
                        $i_netdb netdb.h
                        $i_unistd unistd.h"
                for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
@@ -20400,9 +21656,9 @@ case "$pager" in
        esac
        ;;
 *)     dflt="$pager"
-       fn="f/($pager)"
        ;;
 esac
+fn="f/($dflt)"
 echo " "
 rp='What pager is used on your system?'
 . ./getfile
@@ -20541,7 +21797,7 @@ int check_min ()
 
 int main (int argc, char *argv[])
 {
-    fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t));
+    /* fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t)); */
     check_max ();
     check_min ();
     return (0);
@@ -20549,7 +21805,7 @@ int main (int argc, char *argv[])
 EOCP
        set try
        if eval $compile; then
-           eval `$run ./try`
+           eval `$run ./try 2>/dev/null`
        else
            echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
            fi
@@ -20630,7 +21886,7 @@ int main (int argc, char *argv[])
 EOCP
        set try
        if eval $compile; then
-           eval `$run ./try`
+           eval `$run ./try 2>/dev/null`
        else
            echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
            fi
@@ -20762,7 +22018,7 @@ int main() {
 EOCP
                set try
                if eval $compile_ok; then
-                       selectminbits=`$run ./try`
+                       selectminbits=`$run ./try 2>/dev/null`
                        case "$selectminbits" in
                        '')     cat >&4 <<EOM
 Cannot figure out on how many bits at a time your select() operates.
@@ -20796,9 +22052,11 @@ EOM
 esac
 
 : Trace out the files included by signal.h, then look for SIGxxx names.
+case "$sig_num_init" in
+'')
 if [ "X$fieldn" = X ]; then
        : Just make some guesses.  We check them later.
-       xxx='/usr/include/signal.h /usr/include/sys/signal.h'
+       xxx="$sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h"
 else
        xxx=`echo '#include <signal.h>' |
        $cppstdin $cppminus $cppflags 2>/dev/null |
@@ -21059,6 +22317,8 @@ echo $sig_name | $awk \
 }'
 sig_size=`echo $sig_name | awk '{print NF}'`
 $rm -f signal signal.c signal.awk signal.lst signal_cmd
+;;
+esac
 
 : Check size of size
 echo " "
@@ -21530,7 +22790,7 @@ EOM
 
 val=$undef
 set try
-if eval $compile_ok; then
+if eval $compile; then
        if $run ./try; then
                echo "You can use sysctl with KERN_PROC_PATHNAME to find the executing program." >&4
                val="$define"
@@ -21632,7 +22892,7 @@ EOM
 
 val=$undef
 set try
-if eval $compile_ok; then
+if eval $compile; then
        if $run ./try; then
                echo "You can use _NSGetExecutablePath to find the executing program." >&4
                val="$define"
@@ -21697,7 +22957,7 @@ case "$yacc" in
        *-y*) ;;
        *)
                yacc="$yacc -y"
-               echo "(Adding -y option to bison to get yacc-compatible behaviour.)"
+               echo "(Adding -y option to bison to get yacc-compatible behavior.)"
                ;;
        esac
        ;;
@@ -21707,6 +22967,18 @@ esac
 set assert.h i_assert
 eval $inhdr
 
+: see if this is a bfd.h system
+set bfd.h i_bfd
+eval $inhdr
+
+: see if this is an execinfo.h system
+set execinfo.h i_execinfo
+eval $inhdr
+
+: see if this is a fenv.h system
+set fenv.h i_fenv
+eval $inhdr
+
 : see if this is a fp.h system
 set fp.h i_fp
 eval $inhdr
@@ -21803,73 +23075,72 @@ eval $inhdr
 echo " "
 $echo "Guessing which symbols your C compiler and preprocessor define..." >&4
 $cat <<'EOSH' > Cppsym.know
-a29k ABI64 aegis AES_SOURCE AIX AIX32 AIX370
-AIX41 AIX42 AIX43 AIX_SOURCE aixpc ALL_SOURCE
-alliant alpha am29000 AM29000 AMD64 amd64 amiga AMIGAOS AMIX
-ansi ANSI_C_SOURCE apollo ardent ARM32 atarist att386 att3b
-BeOS BIG_ENDIAN BIT_MSF bsd BSD bsd43 bsd4_2 bsd4_3 BSD4_3 bsd4_4
-BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES BSDCOMPAT bsdi
-bull c cadmus clipper CMU COFF COMPILER_VERSION
-concurrent convex cpu cray CRAY CRAYMPP ctix CX_UX
-CYGWIN DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO
-Dynix DynixPTX ELF encore EPI EXTENSIONS FAVOR_BSD
-FILE_OFFSET_BITS FreeBSD GCC_NEW_VARARGS gcos gcx gimpel
-GLIBC GLIBC_MINOR
-GNU_SOURCE GNUC GNUC_MINOR GNU_LIBRARY GO32 gould GOULD_PN
-H3050R H3050RX hbullx20 hcx host_mips
-hp200 hp300 hp700 HP700 hp800 hp9000
-hp9000s200 hp9000s300 hp9000s400 hp9000s500
-hp9000s700 hp9000s800 hp9k8 hp_osf hppa hpux HPUX_SOURCE
-i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960
-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
-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
-M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX MACH machine MachTen
-MATH_HAS_NO_SIDE_EFFECTS
-mc300 mc500 mc68000 mc68010 mc68020 mc68030 mc68040
-mc68060 mc68k mc68k32 mc700 mc88000 mc88100 merlin
-mert MiNT mips MIPS_FPSET MIPS_ISA MIPS_SIM MIPS_SZINT
-MIPS_SZLONG MIPS_SZPTR MIPSEB MIPSEL MODERN_C motorola
-mpeix MSDOS MTXINU MULTIMAX mvs MVS n16 ncl_el ncl_mr
-NetBSD news1500 news1700 news1800 news1900 news3700
-news700 news800 news900 NeXT NLS nonstopux ns16000 ns32000
-ns32016 ns32332 ns32k nsc32000
+a29k aarch64 ABI64 aegis AES_SOURCE AIX AIX32 AIX370 AIX41 AIX42
+AIX43 aixpc AIX_SOURCE alliant ALL_SOURCE alpha AM29000 am29000
+AMD64 amd64 amiga AMIGAOS AMIX ansi ANSI_C_SOURCE apollo arch_ppc
+arch_pwr ardent ARM ARM32 atarist att386 att3b
+BeOS BIG_ENDIAN BIT_MSF BSD bsd bsd43 bsd4_2 BSD4_3 bsd4_3 bsd4_4
+BSDCOMPAT bsdi BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES bull
+byteorder byte_order
+c cadmus clang clipper CMU COFF COMPILER_VERSION concurrent
+convex cpu CRAY cray CRAYMPP ctix CX_UX CYGWIN
+DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO Dynix DynixPTX
+ELF encore EPI EXTENSIONS
+FAVOR_BSD FILE_OFFSET_BITS FORTIFY_SOURCE FreeBSD
+GCC_NEW_VARARGS gcos gcx gimpel GLIBC GLIBC_MINOR GNUC GNUC_MINOR
+GNU_LIBRARY GNU_SOURCE GO32 gould GOULD_PN
+H3050R H3050RX hbullx20 hcx host_mips hp200 hp300 HP700 hp700
+hp800 hp9000 hp9000s200 hp9000s300 hp9000s400 hp9000s500
+hp9000s700 hp9000s800 hp9k8 hppa hpux HPUX_SOURCE hp_osf
+i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960 IA32 IA64
+iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
+INLINE_INTRINSICS INT64 INTEL interdata INTRINSICS is68k itanium
+ksr1
+LANGUAGE_C LARGEFILE64_SOURCE LARGEFILE_SOURCE LARGE_FILE_API
+LFS64_LARGEFILE LFS_LARGEFILE LIBCATAMOUNT Linux LITTLE_ENDIAN
+LONG64 LONGDOUBLE LONGLONG LONG_DOUBLE LONG_LONG LP64 luna
+luna88k Lynx
+M68000 m68k m88100 m88k M88KBCS_TARGET MACH machine MachTen
+MATH_HAS_NO_SIDE_EFFECTS mc300 mc500 mc68000 mc68010 mc68020
+mc68030 mc68040 mc68060 mc68k mc68k32 mc700 mc88000 mc88100
+merlin mert MiNT mips MIPSEB MIPSEL MIPS_FPSET MIPS_ISA MIPS_SIM
+MIPS_SZINT MIPS_SZLONG MIPS_SZPTR MODERN_C motorola mpeix MSDOS
+MTXINU MULTIMAX MVS mvs M_AMD64 M_ARM M_ARMT M_COFF M_I186 M_I286
+M_I386 M_I8086 M_I86 M_I86SM M_IA64 M_IX86 M_PPC M_SYS3 M_SYS5
+M_SYSIII M_SYSV M_UNIX M_X86 M_XENIX
+n16 ncl_el ncl_mr NetBSD news1500 news1700 news1800 news1900
+news3700 news700 news800 news900 NeXT NLS nonstopux ns16000
+ns32000 ns32016 ns32332 ns32k nsc32000
 OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
-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 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
-stardent stdc STDC_EXT stratos sun sun3 sun386
-Sun386i svr3 svr4 SVR4_2 SVR4_SOURCE svr5
-SX system SYSTYPE_BSD SYSTYPE_BSD43 SYSTYPE_BSD44
-SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3 SYSV4 SYSV5
-sysV68 sysV88 Tek4132 Tek4300 titan
-TM3200 TM5400 TM5600
-tower tower32 tower32_200 tower32_600 tower32_700
+PARAGON parisc pa_risc PA_RISC1_1 PA_RISC2_0 pc532 pdp11 PGC PIC
+plexus PORTAR posix POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
+POSIX_C_SOURCE POSIX_SOURCE POWER powerpc ppc PROTOTYPES PWB pyr
+QK_USER QNX
+R3000 REENTRANT RES Rhapsody RISC6000 riscix riscos RT
+S390 S390x SA110 SCO scs sequent sgi SGI_SOURCE SH SH3 sinix
+SIZE_INT SIZE_LONG SIZE_PTR SOCKETS_SOURCE SOCKET_SOURCE sony
+sonyrisc sony_news sparc sparclite sparcv8 sparcv9 spectrum
+stardent stdc STDC_EXT stratos sun sun3 sun386 Sun386i svr3 svr4
+SVR4_2 SVR4_SOURCE svr5 SX system SYSTYPE_BSD SYSTYPE_BSD43
+SYSTYPE_BSD44 SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3
+SYSV4 SYSV5 sysV68 sysV88
+Tek4132 Tek4300 thumb thw_370 thw_intel thw_rs6000 titan TM3200
+TM5400 TM5600 tower tower32 tower32_200 tower32_600 tower32_700
 tower32_800 tower32_850 tss
-u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5
-ultrix UMAXV UnicomPBB UnicomPBD UNICOS UNICOSMK
-unix UNIX95 UNIX99 unixpc unos
-USE_BSD USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE USE_LARGEFILE64
-USE_MISC USE_POSIX USE_POSIX199309 USE_POSIX199506 USE_POSIX2
-USE_REENTRANT USE_SVID USE_UNIX98 USE_XOPEN USE_XOPEN_EXTENDED
-USGr4 USGr4_2
-Utek UTek UTS UWIN uxpm uxps vax venix VMESA vms x86_64 xenix Xenix286
-XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2 XPG2_EXTENDED
-XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
-z8000
+u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5 ultrix UMAXV UnicomPBB
+UnicomPBD UNICOS UNICOSMK unix UNIX95 UNIX99 unixpc unos USE_BSD
+USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE
+USE_LARGEFILE64 USE_MISC USE_POSIX USE_POSIX199309
+USE_POSIX199506 USE_POSIX2 USE_REENTRANT USE_SVID USE_UNIX98
+USE_XOPEN USE_XOPEN_EXTENDED USGr4 USGr4_2 UTek Utek UTS UWIN
+uxpm uxps
+vax venix VMESA vms
+x86_64 xenix Xenix286 XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2
+XPG2_EXTENDED XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
+z8000 zarch
 EOSH
 # Maybe put other stuff here too.
-cat <<EOSH >>Cppsym.know
+./tr '-' '_' <<EOSH >>Cppsym.know
 $osname
 EOSH
 ./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
@@ -21882,8 +23153,8 @@ $startsh
 if $test \$# -gt 0; then
     echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
     if $test -s Cppsym.got; then
-        $rm -f Cppsym.got
-        exit 0
+       $rm -f Cppsym.got
+       exit 0
     fi
     $rm -f Cppsym.got
     exit 1
@@ -21931,15 +23202,16 @@ $cc -o try -Dcpp_stuff=$cpp_stuff $optimize \$ccflags $ldflags try.c $libs && $r
 EOSH
 chmod +x Cppsym.try
 $eunicefix Cppsym.try
-./Cppsym < Cppsym.know > Cppsym.true
-: Add in any linux cpp "predefined macros":
+./Cppsym < Cppsym.know | $sort | $uniq > Cppsym.true
+: Add in any Linux cpp "predefined macros":
 case "$osname::$gccversion" in
   *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
     tHdrH=_tmpHdr
     rm -f $tHdrH'.h' $tHdrH
     touch $tHdrH'.h'
+    # Filter out macro arguments, such as Linux's __INT8_C(c)
     if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
-       sed 's/#define[\ \  ]*//;s/[\ \     ].*$//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
+       sed -e 's/#define[\ \  ]*//;s/[\ \     ].*$//' -e 's/(.*//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
        if [ -s $tHdrH'_cppsym.real' ]; then
          cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
        fi
@@ -21971,9 +23243,9 @@ chmod +x ccsym
 $eunicefix ccsym
 ./ccsym > ccsym1.raw
 if $test -s ccsym1.raw; then
-       $sort ccsym1.raw | $uniq >ccsym.raw
+    $sort ccsym1.raw | $uniq >ccsym.raw
 else
-       mv ccsym1.raw ccsym.raw
+    mv ccsym1.raw ccsym.raw
 fi
 
 $awk '/\=/ { print $0; next }
@@ -21987,9 +23259,9 @@ if $test -z ccsym.raw; then
        echo " "
        echo "However, your C preprocessor defines the following symbols:"
        $cat Cppsym.true
-       ccsymbols=''
+       ccsymbols=''
        cppsymbols=`$cat Cppsym.true`
-        cppsymbols=`echo $cppsymbols`
+       cppsymbols=`echo $cppsymbols`
        cppccsymbols="$cppsymbols"
 else
        if $test -s ccsym.com; then
@@ -22015,61 +23287,81 @@ else
                echo "Your C compiler ${also}defines the following cpp symbols:"
                $sed -e 's/\(..*\)=1/\1/' ccsym.own
                $sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
-               ccsymbols=`$cat ccsym.own`
-               ccsymbols=`echo $ccsymbols`
+               ccsymbols=`$cat ccsym.own`
+               ccsymbols=`echo $ccsymbols`
                $test "$silent" || sleep 1
        fi
 fi
 
+: add -D_FORTIFY_SOURCE if feasible and not already there
+case "$gccversion" in
+[45].*)        case "$optimize$ccflags" in
+       *-O*)   case "$ccflags$cppsymbols" in
+               *_FORTIFY_SOURCE=*) # Don't add it again.
+                       echo "You seem to have -D_FORTIFY_SOURCE already, not adding it." >&4
+                       ;;
+               *)      echo "Adding -D_FORTIFY_SOURCE=2 to ccflags..." >&4
+                       ccflags="$ccflags -D_FORTIFY_SOURCE=2"
+                       ;;
+               esac
+               ;;
+       *)      echo "You have gcc 4.* or later but not optimizing, not adding -D_FORTIFY_SOURCE." >&4
+               ;;
+       esac
+       ;;
+*)     echo "You seem not to have gcc 4.* or later, not adding -D_FORTIFY_SOURCE." >&4
+       ;;
+esac
+
 : see if this is a termio system
 val="$undef"
 val2="$undef"
 val3="$undef"
 if $test `./findhdr termios.h`; then
-       set tcsetattr i_termios
-       eval $inlibc
-       val3="$i_termios"
+    set tcsetattr i_termios
+    eval $inlibc
+    val3="$i_termios"
 fi
 echo " "
 case "$val3" in
-"$define") echo "You have POSIX termios.h... good!" >&4;;
-*) if ./Cppsym pyr; then
-               case "`/bin/universe`" in
+    "$define") echo "You have POSIX termios.h... good!" >&4;;
+    *)  if ./Cppsym pyr; then
+           case "`$run /bin/universe`" in
                ucb) if $test `./findhdr sgtty.h`; then
-                               val2="$define"
-                               echo "<sgtty.h> found." >&4
-                       else
-                               echo "System is pyramid with BSD universe."
-                               ./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."
-                               ./warn "<termio.h> not found--you could have problems."
-                       fi;;
-               esac
-       elif ./usg; then
-               if $test `./findhdr termio.h`; then
-                       echo "<termio.h> found." >&4
-                       val="$define"
-               elif $test `./findhdr sgtty.h`; then
-                       echo "<sgtty.h> found." >&4
                        val2="$define"
-               else
-                       ./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
-               fi
-       else
-               if $test `./findhdr sgtty.h`; then
                        echo "<sgtty.h> found." >&4
-                       val2="$define"
-               elif $test `./findhdr termio.h`; then
-                       echo "<termio.h> found." >&4
+                   else
+                       echo "System is pyramid with BSD universe."
+                       ./warn "<sgtty.h> not found--you could have problems."
+                   fi;;
+               *)  if $test `./findhdr termio.h`; then
                        val="$define"
-               else
-                       ./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
-               fi
+                       echo "<termio.h> found." >&4
+                   else
+                       echo "System is pyramid with USG universe."
+                       ./warn "<termio.h> not found--you could have problems."
+                   fi;;
+           esac
+       elif ./usg; then
+           if $test `./findhdr termio.h`; then
+               echo "<termio.h> found." >&4
+               val="$define"
+           elif $test `./findhdr sgtty.h`; then
+               echo "<sgtty.h> found." >&4
+               val2="$define"
+           else
+               ./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
+           fi
+       else
+           if $test `./findhdr sgtty.h`; then
+               echo "<sgtty.h> found." >&4
+               val2="$define"
+           elif $test `./findhdr termio.h`; then
+               echo "<termio.h> found." >&4
+               val="$define"
+           else
+               ./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
+           fi
        fi;;
 esac
 set i_termio; eval $setvar
@@ -22109,6 +23401,10 @@ eval $setvar
 set stddef.h i_stddef
 eval $inhdr
 
+: see if stdint is available
+set stdint.h i_stdint
+eval $inhdr
+
 : see if sys/access.h is available
 set sys/access.h i_sysaccess
 eval $inhdr
@@ -22212,10 +23508,10 @@ esac
 : Check extensions
 echo " "
 echo "Looking for extensions..." >&4
-: If we are using the old config.sh, known_extensions may contain
-: old or inaccurate or duplicate values.
-known_extensions=''
+: If we are using the old config.sh, nonxs_extensions and xs_extensions may
+: contain old or inaccurate or duplicate values.
 nonxs_extensions=''
+xs_extensions=''
 : We do not use find because it might not be available.
 : We do not just use MANIFEST because the user may have dropped
 : some additional extensions into the source tree and expect them
@@ -22230,52 +23526,39 @@ find_extensions='
        case "$xxx" in
            DynaLoader|dynaload) ;;
            *)
-           this_ext=`echo $xxx | $sed -e s/-/\\\//g`;
-           leaf=`echo $xxx | $sed -e s/.*-//`;
-           if $test -d File; then
-               if $test -f $xxx/$leaf.xs -o -f $xxx/$leaf.c; then
-                   known_extensions="$known_extensions $1$this_ext";
-               elif $test -f $xxx/Makefile.PL; then
-                   nonxs_extensions="$nonxs_extensions $1$this_ext";
-               else
-                   if $test -d $xxx -a $# -lt 10; then
-                       set $1$xxx/ $*;
-                       cd "$xxx";
-                       eval $find_extensions;
-                       cd ..;
-                       shift;
-                   fi;
-               fi;
-           else
-               echo " $known_extensions $nonxs_extensions" > $$.tmp;
-               if $contains " $this_ext " $$.tmp; then
-                   echo >&4;
-                   echo "Duplicate directories detected for extension $xxx" >&4;
-                   echo "Configure cannot correctly recover from this - shall I abort?" >&4;
-                   case "$knowitall" in
-                   "") dflt=y;;
-                   *) dflt=n;;
-                   esac;
-                   . ../UU/myread;
-                   case "$ans" in
-                   n*|N*) ;;
-                   *) echo >&4;
-                      echo "Ok.  Stopping Configure." >&4;
-                      echo "Please remove the duplicate directory (eg using git clean) and then re-run Configure" >&4;
-                       exit 1;;
-                   esac;
-                   echo "Ok.  You will need to correct config.sh before running make." >&4;
-               fi;
-               $ls -1 $xxx > $$.tmp;
-               if   $contains "\.xs$" $$.tmp > /dev/null 2>&1; then
-                   known_extensions="$known_extensions $this_ext";
-               elif $contains "\.c$"  $$.tmp > /dev/null 2>&1; then
-                   known_extensions="$known_extensions $this_ext";
-               elif $test -d $xxx; then
-                   nonxs_extensions="$nonxs_extensions $this_ext";
-               fi;
-               $rm -f $$.tmp;
-           fi
+           this_ext=`echo "$xxx" | $sed -e s/-/\\\//g`;
+           case "$this_ext" in
+               Scalar/List/Utils) this_ext="List/Util" ;;
+               PathTools)         this_ext="Cwd"       ;;
+           esac;
+           echo " $xs_extensions $nonxs_extensions" > "$tdir/$$.tmp";
+           if $contains " $this_ext " "$tdir/$$.tmp"; then
+               echo >&4;
+               echo "Duplicate directories detected for extension $xxx" >&4;
+               echo "Configure cannot correctly recover from this - shall I abort?" >&4;
+               case "$knowitall" in
+               "") dflt=y;;
+               *) dflt=n;;
+               esac;
+               . ../UU/myread;
+               case "$ans" in
+               n*|N*) ;;
+               *) echo >&4;
+                   echo "Ok.  Stopping Configure." >&4;
+                   echo "Please remove the duplicate directory (e.g. using git clean) and then re-run Configure" >&4;
+                   exit 1;;
+               esac;
+               echo "Ok.  You will need to correct config.sh before running make." >&4;
+           fi;
+           $ls -1 "$xxx" > "$tdir/$$.tmp";
+           if   $contains "\.xs$" "$tdir/$$.tmp" > /dev/null 2>&1; then
+               xs_extensions="$xs_extensions $this_ext";
+           elif $contains "\.c$"  "$tdir/$$.tmp" > /dev/null 2>&1; then
+               xs_extensions="$xs_extensions $this_ext";
+           elif $test -d "$xxx"; then
+               nonxs_extensions="$nonxs_extensions $this_ext";
+           fi;
+           $rm -f "$tdir/$$.tmp";
            ;;
        esac;
     done'
@@ -22292,28 +23575,24 @@ cd "$rsrc/ext"
 set X
 shift
 eval $find_extensions
-if $test -d File-Glob; then
-    : All ext/ flattened
-else
-    # Special case:  Add in modules that nest beyond the first level.
-    # Currently threads/shared and Hash/Util/FieldHash, since they are
-    # not picked up by the recursive find above (and adding in general
-    # recursive finding breaks SDBM_File/sdbm).
-    # A.D. 20011025 (SDBM), ajgough 20071008 (FieldHash)
-    known_extensions="$known_extensions threads/shared Hash/Util/FieldHash"
-fi
-set X $known_extensions
+set X $xs_extensions
 shift
-known_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
+xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 set X $nonxs_extensions
 shift
 nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 cd "$tdir"
+known_extensions=`echo $nonxs_extensions $xs_extensions  | tr ' ' $trnl | $sort | tr $trnl ' '`
 
 : Now see which are supported on this system.
 avail_ext=''
-for xxx in $known_extensions ; do
+for xxx in $xs_extensions ; do
        case "$xxx" in
+       Amiga*)
+               case "$osname" in
+               amigaos) avail_ext="$avail_ext $xxx" ;;
+               esac
+               ;;
        DB_File|db_file)
                case "$i_db" in
                $define) avail_ext="$avail_ext $xxx" ;;
@@ -22379,18 +23658,18 @@ for xxx in $known_extensions ; do
                ;;
        Socket|socket)
                case "$d_socket" in
-               true|$define|y)
-                   case "$osname" in
-                   beos) ;; # not unless BONE
-                   *) avail_ext="$avail_ext $xxx" ;;
-                   esac
-                   ;;
+               true|$define|y) avail_ext="$avail_ext $xxx" ;;
                esac
                ;;
        Sys/Syslog|sys/syslog)
-               : XXX syslog requires socket
-               case "$d_socket" in
-               true|$define|y) avail_ext="$avail_ext $xxx" ;;
+               case $osname in
+                       amigaos) ;; # not really very useful on AmigaOS
+                       *)
+                       : XXX syslog requires socket
+                       case "$d_socket" in
+                       true|$define|y) avail_ext="$avail_ext $xxx" ;;
+                       esac
+                       ;;
                esac
                ;;
        Thread|thread)
@@ -22482,6 +23761,8 @@ esac
 nonxs_ext=''
 for xxx in $nonxs_extensions ; do
        case "$xxx" in
+       VMS*)
+               ;;
        *)      nonxs_ext="$nonxs_ext $xxx"
                ;;
        esac
@@ -22620,6 +23901,7 @@ case " $static_ext " in
        cd "$rsrc/cpan"
        for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
                static_ext="$static_ext Encode/$xxx"
+               known_extensions="$known_extensions Encode/$xxx"
        done
        cd "$tdir"
        ;;
@@ -22655,7 +23937,7 @@ sunos*X4*)
     ;;
 *) case "$usedl" in
     $define|true|[yY]*)
-           set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -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="$*"
            ;;
@@ -22838,11 +24120,14 @@ d_SCNfldbl='$d_SCNfldbl'
 d__fwalk='$d__fwalk'
 d_access='$d_access'
 d_accessx='$d_accessx'
+d_acosh='$d_acosh'
 d_aintl='$d_aintl'
 d_alarm='$d_alarm'
 d_archlib='$d_archlib'
 d_asctime64='$d_asctime64'
 d_asctime_r='$d_asctime_r'
+d_asinh='$d_asinh'
+d_atanh='$d_atanh'
 d_atolf='$d_atolf'
 d_atoll='$d_atoll'
 d_attribute_deprecated='$d_attribute_deprecated'
@@ -22853,6 +24138,7 @@ d_attribute_noreturn='$d_attribute_noreturn'
 d_attribute_pure='$d_attribute_pure'
 d_attribute_unused='$d_attribute_unused'
 d_attribute_warn_unused_result='$d_attribute_warn_unused_result'
+d_backtrace='$d_backtrace'
 d_bcmp='$d_bcmp'
 d_bcopy='$d_bcopy'
 d_bsd='$d_bsd'
@@ -22864,6 +24150,7 @@ d_bzero='$d_bzero'
 d_c99_variadic_macros='$d_c99_variadic_macros'
 d_casti32='$d_casti32'
 d_castneg='$d_castneg'
+d_cbrt='$d_cbrt'
 d_charvspr='$d_charvspr'
 d_chown='$d_chown'
 d_chroot='$d_chroot'
@@ -22873,6 +24160,7 @@ d_clearenv='$d_clearenv'
 d_closedir='$d_closedir'
 d_cmsghdr_s='$d_cmsghdr_s'
 d_const='$d_const'
+d_copysign='$d_copysign'
 d_copysignl='$d_copysignl'
 d_cplusplus='$d_cplusplus'
 d_crypt='$d_crypt'
@@ -22890,6 +24178,7 @@ d_difftime='$d_difftime'
 d_dir_dd_fd='$d_dir_dd_fd'
 d_dirfd='$d_dirfd'
 d_dirnamlen='$d_dirnamlen'
+d_dladdr='$d_dladdr'
 d_dlerror='$d_dlerror'
 d_dlopen='$d_dlopen'
 d_dlsymun='$d_dlsymun'
@@ -22911,7 +24200,11 @@ d_endpwent_r='$d_endpwent_r'
 d_endsent='$d_endsent'
 d_endservent_r='$d_endservent_r'
 d_eofnblk='$d_eofnblk'
+d_erf='$d_erf'
+d_erfc='$d_erfc'
 d_eunice='$d_eunice'
+d_exp2='$d_exp2'
+d_expm1='$d_expm1'
 d_faststdio='$d_faststdio'
 d_fchdir='$d_fchdir'
 d_fchmod='$d_fchmod'
@@ -22920,19 +24213,27 @@ d_fcntl='$d_fcntl'
 d_fcntl_can_lock='$d_fcntl_can_lock'
 d_fd_macros='$d_fd_macros'
 d_fd_set='$d_fd_set'
+d_fdim='$d_fdim'
 d_fds_bits='$d_fds_bits'
+d_fegetround='$d_fegetround'
 d_fgetpos='$d_fgetpos'
 d_finite='$d_finite'
 d_finitel='$d_finitel'
 d_flexfnam='$d_flexfnam'
 d_flock='$d_flock'
 d_flockproto='$d_flockproto'
+d_fma='$d_fma'
+d_fmax='$d_fmax'
+d_fmin='$d_fmin'
 d_fork='$d_fork'
 d_fp_class='$d_fp_class'
+d_fp_classify='$d_fp_classify'
+d_fp_classl='$d_fp_classl'
 d_fpathconf='$d_fpathconf'
 d_fpclass='$d_fpclass'
 d_fpclassify='$d_fpclassify'
 d_fpclassl='$d_fpclassl'
+d_fpgetround='$d_fpgetround'
 d_fpos64_t='$d_fpos64_t'
 d_frexpl='$d_frexpl'
 d_fs_data_s='$d_fs_data_s'
@@ -23010,6 +24311,8 @@ d_gnulibc='$d_gnulibc'
 d_grpasswd='$d_grpasswd'
 d_hasmntopt='$d_hasmntopt'
 d_htonl='$d_htonl'
+d_hypot='$d_hypot'
+d_ilogb='$d_ilogb'
 d_ilogbl='$d_ilogbl'
 d_inc_version_list='$d_inc_version_list'
 d_index='$d_index'
@@ -23017,25 +24320,50 @@ d_inetaton='$d_inetaton'
 d_inetntop='$d_inetntop'
 d_inetpton='$d_inetpton'
 d_int64_t='$d_int64_t'
+d_ip_mreq='$d_ip_mreq'
+d_ip_mreq_source='$d_ip_mreq_source'
 d_ipv6_mreq='$d_ipv6_mreq'
+d_ipv6_mreq_source='$d_ipv6_mreq_source'
 d_isascii='$d_isascii'
 d_isblank='$d_isblank'
 d_isfinite='$d_isfinite'
+d_isfinitel='$d_isfinitel'
 d_isinf='$d_isinf'
+d_isinfl='$d_isinfl'
+d_isless='$d_isless'
 d_isnan='$d_isnan'
 d_isnanl='$d_isnanl'
+d_isnormal='$d_isnormal'
+d_j0='$d_j0'
+d_j0l='$d_j0l'
 d_killpg='$d_killpg'
+d_lc_monetary_2008='$d_lc_monetary_2008'
 d_lchown='$d_lchown'
 d_ldbl_dig='$d_ldbl_dig'
+d_ldexpl='$d_ldexpl'
+d_lgamma='$d_lgamma'
+d_lgamma_r='$d_lgamma_r'
 d_libm_lib_version='$d_libm_lib_version'
+d_libname_unique='$d_libname_unique'
 d_link='$d_link'
+d_llrint='$d_llrint'
+d_llrintl='$d_llrintl'
+d_llround='$d_llround'
+d_llroundl='$d_llroundl'
 d_localtime64='$d_localtime64'
 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_log1p='$d_log1p'
+d_log2='$d_log2'
+d_logb='$d_logb'
 d_longdbl='$d_longdbl'
 d_longlong='$d_longlong'
+d_lrint='$d_lrint'
+d_lrintl='$d_lrintl'
+d_lround='$d_lround'
+d_lroundl='$d_lroundl'
 d_lseekproto='$d_lseekproto'
 d_lstat='$d_lstat'
 d_madvise='$d_madvise'
@@ -23075,8 +24403,12 @@ d_msgsnd='$d_msgsnd'
 d_msync='$d_msync'
 d_munmap='$d_munmap'
 d_mymalloc='$d_mymalloc'
+d_nan='$d_nan'
 d_ndbm='$d_ndbm'
 d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
+d_nearbyint='$d_nearbyint'
+d_nextafter='$d_nextafter'
+d_nexttoward='$d_nexttoward'
 d_nice='$d_nice'
 d_nl_langinfo='$d_nl_langinfo'
 d_nv_preserves_uv='$d_nv_preserves_uv'
@@ -23101,6 +24433,7 @@ d_pseudofork='$d_pseudofork'
 d_pthread_atfork='$d_pthread_atfork'
 d_pthread_attr_setscope='$d_pthread_attr_setscope'
 d_pthread_yield='$d_pthread_yield'
+d_ptrdiff_t='$d_ptrdiff_t'
 d_pwage='$d_pwage'
 d_pwchange='$d_pwchange'
 d_pwclass='$d_pwclass'
@@ -23112,19 +24445,27 @@ d_pwquota='$d_pwquota'
 d_qgcvt='$d_qgcvt'
 d_quad='$d_quad'
 d_random_r='$d_random_r'
+d_re_comp='$d_re_comp'
 d_readdir64_r='$d_readdir64_r'
 d_readdir='$d_readdir'
 d_readdir_r='$d_readdir_r'
 d_readlink='$d_readlink'
 d_readv='$d_readv'
 d_recvmsg='$d_recvmsg'
+d_regcmp='$d_regcmp'
+d_regcomp='$d_regcomp'
+d_remainder='$d_remainder'
+d_remquo='$d_remquo'
 d_rename='$d_rename'
 d_rewinddir='$d_rewinddir'
+d_rint='$d_rint'
 d_rmdir='$d_rmdir'
+d_round='$d_round'
 d_safebcpy='$d_safebcpy'
 d_safemcpy='$d_safemcpy'
 d_sanemcmp='$d_sanemcmp'
 d_sbrkproto='$d_sbrkproto'
+d_scalbn='$d_scalbn'
 d_scalbnl='$d_scalbnl'
 d_sched_yield='$d_sched_yield'
 d_scm_rights='$d_scm_rights'
@@ -23169,7 +24510,6 @@ d_setsent='$d_setsent'
 d_setservent_r='$d_setservent_r'
 d_setsid='$d_setsid'
 d_setvbuf='$d_setvbuf'
-d_sfio='$d_sfio'
 d_shm='$d_shm'
 d_shmat='$d_shmat'
 d_shmatprototype='$d_shmatprototype'
@@ -23197,6 +24537,7 @@ d_srand48_r='$d_srand48_r'
 d_srandom_r='$d_srandom_r'
 d_sresgproto='$d_sresgproto'
 d_sresuproto='$d_sresuproto'
+d_stat='$d_stat'
 d_statblks='$d_statblks'
 d_statfs_f_flags='$d_statfs_f_flags'
 d_statfs_s='$d_statfs_s'
@@ -23239,13 +24580,16 @@ d_tcgetpgrp='$d_tcgetpgrp'
 d_tcsetpgrp='$d_tcsetpgrp'
 d_telldir='$d_telldir'
 d_telldirproto='$d_telldirproto'
+d_tgamma='$d_tgamma'
 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'
 d_tmpnam_r='$d_tmpnam_r'
+d_trunc='$d_trunc'
 d_truncate='$d_truncate'
+d_truncl='$d_truncl'
 d_ttyname_r='$d_ttyname_r'
 d_tzname='$d_tzname'
 d_u32align='$d_u32align'
@@ -23271,7 +24615,9 @@ d_vprintf='$d_vprintf'
 d_vsnprintf='$d_vsnprintf'
 d_wait4='$d_wait4'
 d_waitpid='$d_waitpid'
+d_wcscmp='$d_wcscmp'
 d_wcstombs='$d_wcstombs'
+d_wcsxfrm='$d_wcsxfrm'
 d_wctomb='$d_wctomb'
 d_writev='$d_writev'
 d_xenix='$d_xenix'
@@ -23281,10 +24627,13 @@ db_prefixtype='$db_prefixtype'
 db_version_major='$db_version_major'
 db_version_minor='$db_version_minor'
 db_version_patch='$db_version_patch'
-defvoidused='$defvoidused'
 direntrytype='$direntrytype'
 dlext='$dlext'
 dlsrc='$dlsrc'
+doubleinfbytes='$doubleinfbytes'
+doublekind='$doublekind'
+doublemantbits='$doublemantbits'
+doublenanbytes='$doublenanbytes'
 doublesize='$doublesize'
 drand01='$drand01'
 drand48_r_proto='$drand48_r_proto'
@@ -23358,6 +24707,9 @@ h_fcntl='$h_fcntl'
 h_sysfile='$h_sysfile'
 hint='$hint'
 hostcat='$hostcat'
+hostgenerate='$hostgenerate'
+hostosname='$hostosname'
+hostperl='$hostperl'
 html1dir='$html1dir'
 html1direxp='$html1direxp'
 html3dir='$html3dir'
@@ -23372,14 +24724,16 @@ i8size='$i8size'
 i8type='$i8type'
 i_arpainet='$i_arpainet'
 i_assert='$i_assert'
+i_bfd='$i_bfd'
 i_bsdioctl='$i_bsdioctl'
 i_crypt='$i_crypt'
 i_db='$i_db'
 i_dbm='$i_dbm'
 i_dirent='$i_dirent'
-i_dld='$i_dld'
 i_dlfcn='$i_dlfcn'
+i_execinfo='$i_execinfo'
 i_fcntl='$i_fcntl'
+i_fenv='$i_fenv'
 i_float='$i_float'
 i_fp='$i_fp'
 i_fp_class='$i_fp_class'
@@ -23408,14 +24762,15 @@ i_poll='$i_poll'
 i_prot='$i_prot'
 i_pthread='$i_pthread'
 i_pwd='$i_pwd'
+i_quadmath='$i_quadmath'
 i_rpcsvcdbm='$i_rpcsvcdbm'
-i_sfio='$i_sfio'
 i_sgtty='$i_sgtty'
 i_shadow='$i_shadow'
 i_socks='$i_socks'
 i_stdarg='$i_stdarg'
 i_stdbool='$i_stdbool'
 i_stddef='$i_stddef'
+i_stdint='$i_stdint'
 i_stdlib='$i_stdlib'
 i_string='$i_string'
 i_sunmath='$i_sunmath'
@@ -23462,6 +24817,7 @@ ignore_versioned_solibs='$ignore_versioned_solibs'
 inc_version_list='$inc_version_list'
 inc_version_list_init='$inc_version_list_init'
 incpath='$incpath'
+incpth='$incpth'
 inews='$inews'
 initialinstalllocation='$initialinstalllocation'
 installarchlib='$installarchlib'
@@ -23525,6 +24881,10 @@ lns='$lns'
 localtime_r_proto='$localtime_r_proto'
 locincpth='$locincpth'
 loclibpth='$loclibpth'
+longdblinfbytes='$longdblinfbytes'
+longdblkind='$longdblkind'
+longdblmantbits='$longdblmantbits'
+longdblnanbytes='$longdblnanbytes'
 longdblsize='$longdblsize'
 longlongsize='$longlongsize'
 longsize='$longsize'
@@ -23533,10 +24893,6 @@ lpr='$lpr'
 ls='$ls'
 lseeksize='$lseeksize'
 lseektype='$lseektype'
-mad='$mad'
-madlyh='$madlyh'
-madlyobj='$madlyobj'
-madlysrc='$madlysrc'
 mail='$mail'
 mailx='$mailx'
 make='$make'
@@ -23581,6 +24937,7 @@ nv_preserves_uv_bits='$nv_preserves_uv_bits'
 nveformat='$nveformat'
 nvfformat='$nvfformat'
 nvgformat='$nvgformat'
+nvmantbits='$nvmantbits'
 nvsize='$nvsize'
 nvtype='$nvtype'
 o_nonblock='$o_nonblock'
@@ -23729,9 +25086,16 @@ strings='$strings'
 submit='$submit'
 subversion='$subversion'
 sysman='$sysman'
+sysroot='$sysroot'
 tail='$tail'
 tar='$tar'
 targetarch='$targetarch'
+targetdir='$targetdir'
+targetenv='$targetenv'
+targethost='$targethost'
+targetmkdir='$targetmkdir'
+targetport='$targetport'
+targetsh='$targetsh'
 tbl='$tbl'
 tee='$tee'
 test='$test'
@@ -23762,6 +25126,7 @@ uquadtype='$uquadtype'
 use5005threads='$use5005threads'
 use64bitall='$use64bitall'
 use64bitint='$use64bitint'
+usecbacktrace='$usecbacktrace'
 usecrosscompile='$usecrosscompile'
 usedevel='$usedevel'
 usedl='$usedl'
@@ -23780,14 +25145,15 @@ usensgetexecutablepath='$usensgetexecutablepath'
 useopcode='$useopcode'
 useperlio='$useperlio'
 useposix='$useposix'
+usequadmath='$usequadmath'
 usereentrant='$usereentrant'
 userelocatableinc='$userelocatableinc'
-usesfio='$usesfio'
 useshrplib='$useshrplib'
 usesitecustomize='$usesitecustomize'
 usesocks='$usesocks'
 usethreads='$usethreads'
 usevendorprefix='$usevendorprefix'
+useversionedarchname='$useversionedarchname'
 usevfork='$usevfork'
 usrinc='$usrinc'
 uuname='$uuname'
@@ -23821,7 +25187,6 @@ version='$version'
 version_patchlevel_string='$version_patchlevel_string'
 versiononly='$versiononly'
 vi='$vi'
-voidflags='$voidflags'
 xlibpth='$xlibpth'
 yacc='$yacc'
 yaccflags='$yaccflags'
@@ -23860,6 +25225,9 @@ EOM
        esac
 fi
 
+: preserve RCS keywords in files with variable substitution, grrr
+Id='$Id'
+
 : Finish up by extracting the .SH files
 case "$alldone" in
 exit)