This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove old Class-ISA remnants
[perl5.git] / Configure
index 71f997f..a8e4a48 100755 (executable)
--- a/Configure
+++ b/Configure
 # 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
+#     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
+# pumpkin to backport the patch to the metaunits if it is accepted.
+# For more information on patching Configure, see pod/perlhack.pod
+#
+# The metaunits are also available from the public git repository:
+#     http://perl5.git.perl.org/metaconfig.git/ or
+#     $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
 #
-# Though this script was generated by metaconfig, it is OK to send
-# patches against it. It's up to the Configure pumpkin to backport
-# the patch to the metaunits if it is accepted.
 # See Porting/pumpkin.pod for more information on metaconfig.
 #
 
-# $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
-#
-# Generated on Mon Jan 19 16:46:57 CET 2009 [metaconfig 3.5 PL0]
+# Generated on Wed Apr  9 12:24:24 CEST 2014 [metaconfig 3.5 PL0]
 # (with additional metaconfig patches by perlbug@perl.org)
 
 cat >c1$$ <<EOF
@@ -53,7 +56,7 @@ true || exec sh $0 $argv:q
 rm -f c1$$ c2$$
 
 if test -f /dev/cputype -a -f /dev/drivers -a -f /dev/osversion; then
-       cat >&4 <<EOF
+       cat <<EOF
 ***
 *** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
 *** Configure that well.  (Plan 9 is close to UNIX but not close enough.)
@@ -65,7 +68,7 @@ EOF
 fi
 
 if test ! -c /dev/null ; then
-       cat >&4 <<EOF
+       cat <<EOF
 ***
 *** I'm sorry, but /dev/null appears to be a file rather than a device.
 *** Please consult your operating sytem's notes for making a device
@@ -88,7 +91,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 '\\\\' / `
@@ -96,7 +99,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
@@ -203,8 +206,16 @@ ccsymbols=''
 cppccsymbols=''
 cppsymbols=''
 from=''
+hostgenerate=''
+hostosname=''
+hostperl=''
 run=''
 targetarch=''
+targetdir=''
+targetenv=''
+targethost=''
+targetmkdir=''
+targetport=''
 to=''
 usecrosscompile=''
 extern_C=''
@@ -309,6 +320,7 @@ RCSfile=''
 Revision=''
 Source=''
 State=''
+sysroot=''
 _a=''
 _exe=''
 _o=''
@@ -329,6 +341,7 @@ d_archlib=''
 installarchlib=''
 archname=''
 myarchname=''
+useversionedarchname=''
 d_atolf=''
 d_atoll=''
 baserev=''
@@ -348,6 +361,8 @@ optimize=''
 cf_email=''
 cf_by=''
 cf_time=''
+charbits=''
+charsize=''
 contains=''
 cpp_stuff=''
 cpplast=''
@@ -467,6 +482,7 @@ d_ftime=''
 d_gettimeod=''
 d_futimes=''
 d_Gconvert=''
+d_getaddrinfo=''
 d_getcwd=''
 d_getespwnam=''
 d_getfsstat=''
@@ -498,6 +514,7 @@ d_getlogin_r=''
 getlogin_r_proto=''
 d_getmnt=''
 d_getmntent=''
+d_getnameinfo=''
 d_getnbyaddr=''
 d_getnbyname=''
 d_getnent=''
@@ -554,8 +571,11 @@ d_hasmntopt=''
 d_htonl=''
 d_ilogbl=''
 d_inetaton=''
+d_inetntop=''
+d_inetpton=''
 d_int64_t=''
 d_isascii=''
+d_isblank=''
 d_isfinite=''
 d_isinf=''
 d_isnan=''
@@ -617,6 +637,8 @@ d_pause=''
 d_pipe=''
 d_poll=''
 d_portable=''
+d_prctl=''
+d_prctl_set_name=''
 d_procselfexe=''
 procselfexe=''
 d_old_pthread_create_joinable=''
@@ -693,8 +715,6 @@ d_setservent_r=''
 setservent_r_proto=''
 d_setsid=''
 d_setvbuf=''
-d_sfio=''
-usesfio=''
 d_shm=''
 d_shmat=''
 d_shmatprototype=''
@@ -711,6 +731,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=''
@@ -718,6 +742,9 @@ d_msg_peek=''
 d_msg_proxy=''
 d_oldsock=''
 d_scm_rights=''
+d_sin6_scope_id=''
+d_sockaddr_in6=''
+d_sockaddr_sa_len=''
 d_socket=''
 d_sockpair=''
 sockethdr=''
@@ -735,6 +762,8 @@ d_sresuproto=''
 d_statblks=''
 d_statfs_f_flags=''
 d_statfs_s=''
+d_static_inline=''
+perl_static_inline=''
 d_fstatvfs=''
 d_statvfs=''
 d_stdio_cnt_lval=''
@@ -820,13 +849,16 @@ d_wcstombs=''
 d_wctomb=''
 d_writev=''
 dlext=''
+bin_ELF=''
 cccdlflags=''
 ccdlflags=''
 dlsrc=''
 ld=''
+ld_can_script=''
 lddlflags=''
 usedl=''
 doublesize=''
+bootstrap_charset=''
 ebcdic=''
 fflushNULL=''
 fflushall=''
@@ -862,7 +894,6 @@ i_rpcsvcdbm=''
 d_dirnamlen=''
 direntrytype=''
 i_dirent=''
-i_dld=''
 i_dlfcn=''
 i_fcntl=''
 i_float=''
@@ -907,9 +938,9 @@ d_pwgecos=''
 d_pwpasswd=''
 d_pwquota=''
 i_pwd=''
-i_sfio=''
 i_shadow=''
 i_socks=''
+i_stdbool=''
 i_stddef=''
 i_stdlib=''
 i_string=''
@@ -977,6 +1008,7 @@ libperl=''
 shrpenv=''
 useshrplib=''
 glibpth=''
+incpth=''
 libpth=''
 loclibpth=''
 plibpth=''
@@ -1135,6 +1167,7 @@ scriptdirexp=''
 selectminbits=''
 selecttype=''
 sh=''
+targetsh=''
 sig_count=''
 sig_name=''
 sig_name_init=''
@@ -1171,6 +1204,7 @@ sitescript=''
 sitescriptexp=''
 sizesize=''
 sizetype=''
+d_libname_unique=''
 so=''
 socksizetype=''
 sharpbang=''
@@ -1178,6 +1212,8 @@ shsharp=''
 spitshell=''
 src=''
 ssizetype=''
+st_ino_sign=''
+st_ino_size=''
 startperl=''
 startsh=''
 stdchar=''
@@ -1199,6 +1235,7 @@ use64bitint=''
 dtrace=''
 usedtrace=''
 usefaststdio=''
+usekernprocpathname=''
 ccflags_uselargefiles=''
 ldflags_uselargefiles=''
 libswanted_uselargefiles=''
@@ -1210,6 +1247,7 @@ nm_opt=''
 nm_so_opt=''
 runnm=''
 usenm=''
+usensgetexecutablepath=''
 useperlio=''
 usesocks=''
 d_oldpthreads=''
@@ -1220,6 +1258,7 @@ usethreads=''
 incpath=''
 mips_type=''
 usrinc=''
+vaproto=''
 d_vendorarch=''
 installvendorarch=''
 vendorarch=''
@@ -1253,8 +1292,6 @@ installvendorscript=''
 vendorscript=''
 vendorscriptexp=''
 versiononly=''
-defvoidused=''
-voidflags=''
 yacc=''
 yaccflags=''
 CONFIG=''
@@ -1284,6 +1321,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"
@@ -1295,6 +1335,18 @@ i_whoami=''
 : Extra object files, if any, needed on this platform.
 archobjs=''
 archname=''
+: Possible local include directories to search.
+: Set locincpth to "" in a hint file to defeat local include searches.
+locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
+locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
+:
+: no include file wanted by default
+inclwanted=''
+
+: Enable -DEBUGGING and -DDEBUGGING from the command line
+EBUGGING=''
+DEBUGGING=''
+
 libnames=''
 : change the next line if compiling for Xenix/286 on Xenix/386
 xlibpth='/usr/lib/386 /lib/386'
@@ -1320,21 +1372,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
-
-: Possible local include directories to search.
-: Set locincpth to "" in a hint file to defeat local include searches.
-locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
-locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
-:
-: no include file wanted by default
-inclwanted=''
-
-: Enable -DEBUGGING and -DDEBUGGING from the command line
-EBUGGING=''
-DEBUGGING=old
-
 ccname=''
 ccversion=''
 perllibs=''
@@ -1350,7 +1387,7 @@ 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="socket bind inet nsl nm ndbm gdbm dbm db malloc dl ld sun"
 libswanted="$libswanted 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.
@@ -1394,16 +1431,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
@@ -2236,7 +2277,7 @@ in the default answer, as if the default line was a set of arguments given to a
 script shell.  This means you may also use $* to repeat the whole default line,
 so you do not have to re-type everything to add something to the default.
 
-Everytime there is a substitution, you will have to confirm.  If there is an
+Every time there is a substitution, you will have to confirm.  If there is an
 error (e.g. an unmatched backtick), the default answer will remain unchanged
 and you will be prompted again.
 
@@ -2275,6 +2316,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
@@ -2356,13 +2439,14 @@ make
 more
 nm
 nroff
+perl
 pg
 test
 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
@@ -2432,6 +2516,15 @@ egrep)
        _egrep=$grep
        ;;
 esac
+case "$less" in
+'')    ;;
+*)     if $less -R </dev/null >/dev/null; then
+              echo "Substituting less -R for less."
+              less="$less -R"
+              _less=$less
+       fi
+       ;;
+esac
 case "$ln" in
 ln)
        echo "Substituting cp for ln."
@@ -2672,7 +2765,7 @@ case "$lns" in
                                ;;
                        *)      issymlink='' ;;
                        esac
-               fi              
+               fi
        fi
        if $test "X$issymlink" = X; then
                if $test -L sym 2>/dev/null; then
@@ -2745,71 +2838,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
@@ -2832,18 +2955,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 ;;
@@ -2853,6 +2981,7 @@ $define|true|[yY]*)
        ssh|rsh)
            cat >$run <<EOF
 #!/bin/sh
+env=''
 case "\$1" in
 -cwd)
   shift
@@ -2860,18 +2989,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
            ;;
@@ -2880,7 +3016,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
            ;;
@@ -2897,11 +3033,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
@@ -2937,7 +3073,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
@@ -2983,7 +3119,7 @@ EOF
 *)     run=''
        to=:
        from=:
-       usecrosscompile='undef'
+       usecrosscompile="$undef"
        targetarch=''
        ;;
 esac
@@ -3061,9 +3197,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
@@ -3210,6 +3350,9 @@ EOM
                        *) osvers=$tmp;;
                        esac
                        ;;
+               bitrig) osname=bitrig
+                       osvers="$3"
+                       ;;
                bsd386) osname=bsd386
                        osvers=`$uname -r`
                        ;;
@@ -3253,6 +3396,7 @@ EOM
                        case "$3" in
                        *)      osvers="$3" ;;
                        esac
+                       $test -f /system/lib/libandroid.so && osname=linux-android
                        ;;
                MiNT)   osname=mint
                        ;;
@@ -3402,8 +3546,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
 
@@ -3948,7 +4126,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
@@ -4044,77 +4222,6 @@ $undef$define) . ./whoa; eval "$var=\$tu";;
 *) eval "$var=$val";;
 esac'
 
-: Check is we will use socks
-case "$usesocks" in
-$define|true|[yY]*)    dflt='y';;
-*) dflt='n';;
-esac
-cat <<EOM
-
-Perl can be built to use the SOCKS proxy protocol library.  To do so,
-Configure must be run with -Dusesocks.  If you use SOCKS you also need
-to use the PerlIO abstraction layer, this will be implicitly selected.
-
-If this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-rp='Build Perl for SOCKS?'
-. ./myread
-case "$ans" in
-y|Y)   val="$define" ;;
-*)      val="$undef" ;;
-esac
-set usesocks
-eval $setvar
-
-case "$usesocks" in
-$define|true|[yY]*) useperlio="$define";;
-esac
-
-: Check if we want perlio
-case "$useperlio" in
-$define|true|[yY]*|'') dflt='y';;
-*) dflt='n';;
-esac
-cat <<EOM
-
-Previous version of $package used the standard IO mechanisms as
-defined in <stdio.h>.  Versions 5.003_02 and later of $package allow
-alternate IO mechanisms via the PerlIO abstraction layer, but the
-stdio mechanism is still available if needed.  The abstraction layer
-can use AT&T's sfio (if you already have sfio installed) or regular stdio.
-Using PerlIO with sfio may cause problems with some extension modules.
-
-If this doesn't make any sense to you, just accept the default '$dflt'.
-EOM
-rp='Use the PerlIO abstraction layer?'
-. ./myread
-case "$ans" in
-y|Y)
-       val="$define"
-       ;;
-*)
-       echo "Ok, doing things the stdio way."
-       val="$undef"
-       ;;
-esac
-set useperlio
-eval $setvar
-
-case "$usesocks" in
-$define|true|[yY]*)
-       case "$useperlio" in
-       $define|true|[yY]*) ;;
-       *)      cat >&4 <<EOM
-
-You are using the SOCKS proxy protocol library which means that you
-should also use the PerlIO layer.  You may be headed for trouble.
-
-EOM
-               ;;
-       esac
-       ;;
-esac
-
 : get the patchlevel
 echo " "
 echo "Getting the current patchlevel..." >&4
@@ -4136,11 +4243,6 @@ else
        perl_patchlevel=0
        $echo "(You do not have patchlevel.h.  Eek.)"
 fi
-if $test -r $rsrc/.patch ; then
-       if $test "X$perl_patchlevel" = "X" || $test "`cat $rsrc/.patch`" -gt "$perl_patchlevel" ; then
-               perl_patchlevel=`cat $rsrc/.patch`
-       fi
-fi
 : Define a handy string here to avoid duplication in myconfig.SH and configpm.
 version_patchlevel_string="version $patchlevel subversion $subversion"
 case "$perl_patchlevel" in
@@ -4179,25 +4281,18 @@ $define|true|[yY]*)     dflt='y';;
 *)     # Catch case where user specified ithreads or 5005threads but
        # forgot -Dusethreads (A.D. 4/2002)
        case "$useithreads$use5005threads" in
-       *$define*)
-               case "$useperlio" in
-               "$define")      dflt='y' ;;
-               *)              dflt='n' ;;
-               esac
-               ;;
-       *)      dflt='n';;
+       *$define*)      dflt='y';;
+       *)              dflt='n';;
        esac
        ;;
 esac
 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
@@ -4213,22 +4308,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';;
@@ -4287,16 +4374,6 @@ EOM
     useithreads="$usethreads"
 fi
 
-if test X"$usethreads" = "X$define" -a "X$useperlio" = "Xundef"; then
-       cat >&4 <<EOF
-***
-*** To build with ithreads you must also use the PerlIO layer.
-*** Cannot continue, aborting.
-***
-EOF
-       exit 1
-fi
-
 case "$d_oldpthreads" in
 '')    : Configure tests would be welcome here.  For now, assume undef.
        val="$undef" ;;
@@ -4394,8 +4471,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
@@ -4566,10 +4643,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
@@ -4579,7 +4673,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'
@@ -4627,7 +4721,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."
@@ -4670,37 +4764,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; \
@@ -4760,11 +4854,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='';;
@@ -4773,7 +4946,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
@@ -4791,6 +4963,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';;
 *)
@@ -4828,6 +5008,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
@@ -4872,6 +5071,28 @@ case "$firstmakefile" in
 '') firstmakefile='makefile';;
 esac
 
+: Check is we will use socks
+case "$usesocks" in
+$define|true|[yY]*)    dflt='y';;
+*) dflt='n';;
+esac
+cat <<EOM
+
+Perl can be built to use the SOCKS proxy protocol library.  To do so,
+Configure must be run with -Dusesocks.  If you use SOCKS you also need
+to use the PerlIO abstraction layer, this will be implicitly selected.
+
+If this doesn't make any sense to you, just accept the default '$dflt'.
+EOM
+rp='Build Perl for SOCKS?'
+. ./myread
+case "$ans" in
+y|Y)   val="$define" ;;
+*)      val="$undef" ;;
+esac
+set usesocks
+eval $setvar
+
 : Check for uselongdouble support
 case "$ccflags" in
 *-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
@@ -5080,8 +5301,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:";
@@ -5287,10 +5509,10 @@ case "$ldflags" in
 esac
 # See note above about -fstack-protector
 case "$ccflags" in
-*-fstack-protector*) 
+*-fstack-protector*)
        case "$dflt" in
        *-fstack-protector*) ;; # Don't add it again
-       *) dflt="$dflt -fstack-protector" ;; 
+       *) dflt="$dflt -fstack-protector" ;;
        esac
        ;;
 esac
@@ -5364,20 +5586,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
@@ -5464,17 +5673,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"
@@ -5890,8 +6094,61 @@ if $test -f use64bitint.cbu; then
 fi
 case "$use64bitint" in
 "$define"|true|[yY]*)
-       case "$longsize" in
-       4) case "$archname64" in
+       : 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
           ;;
@@ -6047,6 +6304,32 @@ esac
 rp='What is your architecture name'
 . ./myread
 archname="$ans"
+
+: 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
@@ -6113,21 +6396,6 @@ $define)
        esac
        ;;
 esac
-case "$useperlio" in
-$define)
-       echo "Perlio selected." >&4
-       ;;
-*)
-       echo "Perlio not selected, using stdio." >&4
-       case "$archname" in
-        *-stdio*) echo "...and architecture name already has -stdio." >&4
-                ;;
-        *)      archname="$archname-stdio"
-                echo "...setting architecture name to $archname." >&4
-                ;;
-        esac
-       ;;
-esac
 if $test -f archname.cbu; then
        echo "Your platform has some specific hints for architecture name, using them..."
        . ./archname.cbu
@@ -6525,6 +6793,7 @@ if (-d $stem) {
     chdir($stem);
     ;@candidates = map {
        [ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*");
+    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
 }
 else {
     ;@candidates = ();
@@ -6634,112 +6903,11 @@ $rm_try
 set i_malloc
 eval $setvar
 
-: check for void type
-echo " "
-echo "Checking to see how well your C compiler groks the void type..." >&4
-case "$voidflags" in
-'')
-       $cat >try.c <<EOCP
-#$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() { 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
-       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
-       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
 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
-       else
-               echo '#define VOID_PTR void *' > try.c
-       fi
        $cat >>try.c <<EOCP
 #include <stdio.h>
 #$i_stdlib I_STDLIB
@@ -6748,7 +6916,7 @@ case "$ptrsize" in
 #endif
 int main()
 {
-    printf("%d\n", (int)sizeof(VOID_PTR));
+    printf("%d\n", (int)sizeof(void *));
     exit(0);
 }
 EOCP
@@ -6824,6 +6992,7 @@ case "$usemymalloc" 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?"
@@ -6959,7 +7128,7 @@ case "$ans" in
 [yY]*) fn=d~+
        rp='Installation prefix to use for vendor-supplied add-ons?'
        case "$vendorprefix" in
-       '') dflt='' ;;
+       '') dflt="$prefix" ;;
        *)  dflt=$vendorprefix ;;
        esac
        . ./getfile
@@ -7051,9 +7220,9 @@ $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 
+These directories will be searched after
+       $sitearch
+       $sitelib
 EOM
 test X"$vendorlib" != "X" && echo '    ' $vendorlib
 test X"$vendorarch" != "X" && echo '   ' $vendorarch
@@ -7071,7 +7240,7 @@ EOM
 rp='Colon-separated list of additional directories for perl to search?'
 . ./myread
 case "$ans" in
-' '|''|none)   otherlibdirs=' ' ;;     
+' '|''|none)   otherlibdirs=' ' ;;
 *)     otherlibdirs="$ans" ;;
 esac
 case "$otherlibdirs" in
@@ -7129,6 +7298,8 @@ 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.
@@ -7406,11 +7577,11 @@ case "$usenm" in
                ;;
        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
+                       echo "'nm' won't be sufficient on this system." >&4
                        dflt=n
                fi
                ;;
@@ -7548,8 +7719,8 @@ unknown)
                         $sort | $sed -e 's/^.* //'`
                eval set \$$#
        done
-       $test -r $1 || set /usr/ccs/lib/libc.$so
-       $test -r $1 || set /lib/libsys_s$_a
+       $test -r $1 || set $sysroot/usr/ccs/lib/libc.$so
+       $test -r $1 || set $sysroot/lib/libsys_s$_a
        ;;
 *)
        set blurfl
@@ -7645,7 +7816,7 @@ $echo $n ".$c"
 $grep fprintf libc.tmp > libc.ptf
 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
 xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
-xxx='[ADTSIW]'
+xxx='[ADTSIWi]'
 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
        eval $xscan;\
        $contains '^fprintf$' libc.list >/dev/null 2>&1; then
@@ -7773,10 +7944,6 @@ esac
 esac
 $rm -f libnames libpath
 
-: see if dld is available
-set dld.h i_dld
-eval $inhdr
-
 : Check if we are using C++
 echo " "
 echo "Checking for C++..." >&4
@@ -7826,13 +7993,13 @@ yes)
                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;
+                       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()) return(0); else return(1); }"> try.c;
+               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;
@@ -7898,22 +8065,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'
        ;;
@@ -7921,24 +8085,22 @@ esac
 rp="Do you wish to use dynamic loading?"
 . ./myread
 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"
@@ -7956,8 +8118,8 @@ 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' ;;
@@ -7966,31 +8128,55 @@ EOM
                        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
@@ -8002,36 +8188,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 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"
+                   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
@@ -8040,62 +8230,83 @@ 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" ;;
+                   next)  dflt='none' ;;
+                   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*)
+               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
 
@@ -8104,28 +8315,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' ;;
+                   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"
        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
+void foo() {}
+void bar() {}
+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
+       ;;
 esac
 
 : Do we want a shared libperl?
@@ -8137,7 +8377,7 @@ $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.'
                        ;;
@@ -8185,6 +8425,13 @@ esac
 
 case "$useshrplib" in
 true)
+       case "$userelocatableinc" in
+       true|define)
+               echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
+               echo "See INSTALL for an explanation why that won't work." >&4
+               exit 4
+               ;;
+       esac
        case "$libperl" in
        '')
                # Figure out a good name for libperl.so.  Since it gets stored in
@@ -8204,7 +8451,7 @@ true)
                        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
@@ -8292,7 +8539,7 @@ if "$useshrplib"; then
        solaris)
                xxx="-R $shrpdir"
                ;;
-       freebsd|netbsd|openbsd|interix|dragonfly)
+       freebsd|mirbsd|netbsd|openbsd|interix|dragonfly|bitrig)
                xxx="-Wl,-R$shrpdir"
                ;;
        bsdos|linux|irix*|dec_osf|gnu*)
@@ -8301,9 +8548,6 @@ if "$useshrplib"; then
        next)
                # next doesn't like the default...
                ;;
-       beos)
-               # beos doesn't like the default, either.
-               ;;
        haiku)
                # Haiku doesn't like the default, either.
                ;;
@@ -8355,7 +8599,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"
@@ -8838,9 +9082,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
@@ -9376,6 +9630,9 @@ EOCP
        ;;
 esac
 
+: Check if we want perlio
+useperlio="$define"
+
 : Set the vendorbin variables
 case "$vendorprefix" in
 '')    d_vendorbin="$undef"
@@ -9863,7 +10120,7 @@ done
 
 case "$d_longdbl$uselongdouble" in
 "$define$define")
-    : again, add prefered functions to our list first
+    : again, add preferred functions to our list first
     xxx_ld_list=""
     for xxx_convert in $gconvert_ld_preference; do
         case $xxx_convert in
@@ -10024,7 +10281,7 @@ eval $inlibc
 set pthread.h i_pthread
 eval $inhdr
 
-: define a fucntion to check prototypes
+: define a function to check prototypes
 $cat > protochk <<EOSH
 $startsh
 cc="$cc"
@@ -10795,7 +11052,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
@@ -10847,6 +11104,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
@@ -10863,6 +11121,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
@@ -10995,7 +11262,7 @@ int main()
        signal(SIGFPE, blech);
 
        /* Don't let compiler optimize the test away.  Store the number
-          in a writable string for gcc to pass to sscanf under HP/UX.
+          in a writable string for gcc to pass to sscanf under HP-UX.
        */
        sprintf(str, "2147483647");
        sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
@@ -11062,7 +11329,7 @@ int main()
           optimized the whole file away
        */
        /* Store the number in a writable string for gcc to pass to
-          sscanf under HP/UX.
+          sscanf under HP-UX.
        */
        sprintf(str, "-123");
        sscanf(str, "%lf", &f);  /* f = -123.; */
@@ -11258,57 +11525,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
@@ -11317,38 +11584,163 @@ eval $inlibc
 
 
 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
+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() {
-    int i = $ENUM;
+struct sockaddr sa;
+return (sa.sa_len);
 }
 EOF
-       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 sys/uio.h i_sysuio
-eval $inhdr
+val="$undef"
+set try; if eval $compile; then
+    val="$define"
+fi
+set d_sockaddr_sa_len; eval $setvar
+$rm_try
 
-: Check for cmsghdr support
 echo " "
-echo "Checking to see if your system supports struct cmsghdr..." >&4
-set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
-eval $hasstruct
-case "$d_cmsghdr_s" in
-"$define")      echo "Yes, it does."   ;;
-*)              echo "No, it doesn't." ;;
-esac
-
+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_in6 sin6;
+return (sin6.sin6_scope_id);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+    val="$define"
+fi
+set d_sin6_scope_id; eval $setvar
+$rm_try
+
+echo " "
+echo "Checking the availability struct ip_mreq ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int main() {
+struct ip_mreq mreq;
+return (mreq.imr_multiaddr.s_addr);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+       val="$define"
+fi
+set d_ip_mreq; eval $setvar
+$rm_try
+
+echo " "
+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 ip_mreq_source mreq;
+return (mreq.imr_multiaddr.s_addr);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+       val="$define"
+fi
+set d_ip_mreq_source; eval $setvar
+$rm_try
+
+echo " "
+echo "Checking the availability struct ipv6_mreq ..." >&4
+$cat >try.c <<EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int main() {
+struct ipv6_mreq mreq;
+return (mreq.ipv6mr_interface);
+}
+EOF
+val="$undef"
+set try; if eval $compile; then
+    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
+#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
+done
+
+: see if this is a sys/uio.h system
+set sys/uio.h i_sysuio
+eval $inhdr
+
+: Check for cmsghdr support
+echo " "
+echo "Checking to see if your system supports struct cmsghdr..." >&4
+set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
+eval $hasstruct
+case "$d_cmsghdr_s" in
+"$define")      echo "Yes, it does."   ;;
+*)              echo "No, it doesn't." ;;
+esac
+
 
 : check for const keyword
 echo " "
@@ -11794,7 +12186,7 @@ $cat >dirfd.c <<EOM
 #endif
 #endif
 #endif
-#endif 
+#endif
 int main() {
        DIR *dirp = opendir(".");
        if (dirfd(dirp) >= 0)
@@ -12297,7 +12689,7 @@ $define)
        $rm -f $$.h
        ;;
 *)
-       val="$undef"; 
+       val="$undef";
        set d_pwquota; eval $setvar
        set d_pwage; eval $setvar
        set d_pwchange; eval $setvar
@@ -12670,7 +13062,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!";;
@@ -13394,6 +13786,10 @@ eval $ndbm_hdr_protochk
 set gdbm_ndbm gdbm-ndbm.h
 eval $ndbm_hdr_protochk
 
+: see if getaddrinfo exists
+set getaddrinfo d_getaddrinfo
+eval $inlibc
+
 : see if getcwd exists
 set getcwd d_getcwd
 eval $inlibc
@@ -13943,6 +14339,10 @@ eval $inlibc
 set getmntent d_getmntent
 eval $inlibc
 
+: see if getnameinfo exists
+set getnameinfo d_getnameinfo
+eval $inlibc
+
 : see if getnetbyaddr exists
 set getnetbyaddr d_getnbyaddr
 eval $inlibc
@@ -14886,6 +15286,14 @@ set d_index; eval $setvar
 set inet_aton d_inetaton
 eval $inlibc
 
+: see if inet_ntop exists
+set inet_ntop d_inetntop
+eval $inlibc
+
+: see if inet_pton exists
+set inet_pton d_inetpton
+eval $inlibc
+
 : Look for isascii
 echo " "
 $cat >isascii.c <<EOCP
@@ -14915,6 +15323,30 @@ set d_isascii
 eval $setvar
 $rm -f isascii*
 
+: Look for isblank
+echo " "
+$cat >isblank.c <<'EOCP'
+#include <stdio.h>
+#include <ctype.h>
+int main() {
+       int c = ' ';
+       if (isblank(c))
+               return 0 ;
+       else
+               return 1 ;
+}
+EOCP
+if $cc $ccflags $ldflags -o isblank isblank.c $libs >/dev/null 2>&1 ; then
+       echo "isblank() found." >&4
+       val="$define"
+else
+       echo "isblank() NOT found." >&4
+       val="$undef"
+fi
+set d_isblank
+eval $setvar
+$rm -f isblank*
+
 : see if isfinite exists
 set isfinite d_isfinite
 eval $inlibc
@@ -15540,7 +15972,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
@@ -15999,6 +16431,31 @@ eval $inlibc
 set poll d_poll
 eval $inlibc
 
+: see if prctl exists
+set prctl d_prctl
+eval $inlibc
+
+: see if prctl supports PR_SET_NAME
+d_prctl_set_name=$undef
+case $d_prctl in
+    $define)
+       $cat >try.c <<EOM
+#include <sys/prctl.h>
+
+int main (int argc, char *argv[])
+{
+    return (prctl (PR_SET_NAME, "Test"));
+    } /* main */
+EOM
+       set try
+       if eval $compile_ok && $run ./try; then
+           echo "Your prctl (PR_SET_NAME, ...) works"
+           d_prctl_set_name=$define
+           fi
+       $rm_try
+       ;;
+    esac
+
 : see if readlink exists
 set readlink d_readlink
 eval $inlibc
@@ -16008,23 +16465,24 @@ echo " "
 procselfexe=''
 val="$undef"
 case "$d_readlink" in
-"$define")
-       if $issymlink /proc/self/exe ; then
-               $ls -l /proc/self/exe > reflect
-               if $contains /`basename $ls` reflect >/dev/null 2>&1; then
-                       echo "You have Linux-like /proc/self/exe."
-                       procselfexe='"/proc/self/exe"'
-                       val="$define"
-               fi
-       fi
-       if $issymlink /proc/curproc/file ; then
-               $ls -l /proc/curproc/file > reflect
+    "$define")
+       : 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
+           shift; shift
+           if $issymlink $try; then
+               $ls -l $try > reflect
                if $contains /`basename $ls` reflect >/dev/null 2>&1; then
-                       echo "You have BSD-like /proc/curproc/file."
-                       procselfexe='"/proc/curproc/file"'
-                       val="$define"
+                   echo "You have $type-like $try."
+                   procselfexe='"'$try'"'
+                   val="$define"
+                   : This will break out of the loop
+                   set X; shift
                fi
-       fi
+           fi
+       done
        ;;
 esac
 $rm -f reflect
@@ -17231,78 +17689,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."
-       case "$useperlio" in
-       "$undef")
-           echo "For sfio also the PerlIO abstraction layer is needed."
-           echo "Earlier you said you wouldn't want that."
-           ;;
-       esac
-       rp="You seem to have sfio available, do you want to try using it?"
-       . ./myread
-       case "$ans" in
-       y|Y)    echo "Ok, turning on both sfio and PerlIO, then."
-               useperlio="$define"
-               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
@@ -17409,7 +17795,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
@@ -17797,6 +18183,112 @@ case "$d_statfs_f_flags" in
 *)              echo "No, it doesn't." ;;
 esac
 
+: see what flavor, if any, of static inline is supported
+echo " "
+echo "Checking to see if your system supports static inline..."
+$cat > try.c <<'EOCP'
+#include <stdlib.h>
+extern int f_via_a(int x);
+extern int f_via_b(int x);
+int main(int argc, char **argv)
+{
+    int y;
+
+    y = f_via_a(0);
+#ifdef USE_B
+    y = f_via_b(0);
+#endif
+    if (y == 42) {
+        return EXIT_SUCCESS;
+    }
+    else {
+        return EXIT_FAILURE;
+    }
+}
+EOCP
+$cat > a.c <<'EOCP'
+static INLINE int f(int x) {
+    int y;
+    y = x + 42;
+    return y;
+}
+
+int f_via_a(int x)
+{
+    return f(x);
+}
+EOCP
+$cat > b.c <<'EOCP'
+extern int f(int x);
+
+int f_via_b(int x)
+{
+    return f(x);
+}
+EOCP
+
+# Respect a hint (or previous) value for perl_static_inline, if there is one.
+case "$perl_static_inline" in
+'')    # Check the various possibilities, and break out on success.
+       # For gcc, prefer __inline__, which will still permit
+       # cflags.SH to add in -ansi.
+       case "$gccversion" in
+               '') xxx="inline __inline__ __inline _inline";;
+               *)  xxx="__inline__ inline __inline _inline";;
+       esac
+       for inline in $xxx; do
+               set try -DINLINE=$inline a.c
+               if eval $compile && $run ./try; then
+                       # Now make sure there is no external linkage of static
+                       # functions
+                       set try -DINLINE=$inline -DUSE_B a.c b.c
+                       if eval $compile && $run ./try; then
+                               $echo "Your compiler supports static $inline, " >&4
+                               $echo "but it also creates an external definition," >&4
+                               $echo "so I won't use it." >&4
+                               val=$undef
+                       else
+                               $echo "Your compiler supports static $inline." >&4
+                               val=$define
+                               perl_static_inline="static $inline";
+                               break;
+                       fi
+               else
+                       $echo "Your compiler does NOT support static $inline." >&4
+                       val="$undef"
+               fi
+       done
+       ;;
+*inline*) # Some variant of inline exists.
+       echo "Keeping your $hint value of $perl_static_inline."
+       val=$define
+       ;;
+static)  # No inline capabilities
+       echo "Keeping your $hint value of $perl_static_inline."
+       val=$undef
+       ;;
+*)  # Unrecognized previous value -- blindly trust the supplied
+       # value and hope it makes sense.  Use old value for
+       # d_static_inline, if there is one.
+       echo "Keeping your $hint value of $perl_static_inline."
+       case "$d_static_inline" in
+               '') val=$define ;;
+               *)  val=$d_static_inline ;;
+       esac
+       ;;
+esac
+# Fallback to plain 'static' if nothing worked.
+case "$perl_static_inline" in
+'')
+       perl_static_inline="static"
+       val=$undef
+       ;;
+esac
+set d_static_inline
+eval $setvar
+$rm -f a.[co] b.[co]
+$rm_try
+
 : Check stream access
 $cat >&4 <<EOM
 Checking how to access stdio streams by file descriptor number...
@@ -17868,11 +18360,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`; \
@@ -17880,7 +18372,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
@@ -18418,7 +18910,7 @@ eval $setvar
 
 : Check if is a multiplatform env
 case "$osname" in
-next|rhapsody|darwin) multiarch="$define" ;;
+next|darwin) multiarch="$define" ;;
 esac
 case "$multiarch" in
 ''|[nN]*) multiarch="$undef" ;;
@@ -18426,10 +18918,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
@@ -18507,7 +18999,7 @@ EOM
        ;;
 esac
 
-: Checking 32bit aligndness
+: Checking 32bit alignedness
 $cat <<EOM
 
 Checking to see whether you can access character data unalignedly...
@@ -18528,8 +19020,8 @@ $signal_t bletch(int s) { exit(4); }
 #endif
 int main() {
 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
-    U8 buf[8];
-    U32 *up;
+    volatile U8 buf[8];
+    volatile U32 *up;
     int i;
 
     if (sizeof(U32) != 4) {
@@ -18728,34 +19220,22 @@ 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()
 {
@@ -18763,38 +19243,129 @@ 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
 
-: how do we concatenate cpp tokens here?
+: Determine if this is an EBCDIC system
 echo " "
-echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
-$cat >cpp_stuff.c <<'EOCP'
-#define RCAT(a,b)a/**/b
-#define ACAT(a,b)a ## b
-RCAT(Rei,ser)
-ACAT(Cir,cus)
-EOCP
-$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
+echo "Determining whether or not we are on an EBCDIC system..." >&4
+$cat >try.c <<'EOM'
+int main()
+{
+  if ('M'==0xd4) return 0;
+  return 1;
+}
+EOM
+
+case "$BOOTSTRAP_CHARSET" in
+    Y|y|define) bootstrap_charset=$define      ;;
+    *)         bootstrap_charset=$undef        ;;
+esac
+
+val=$undef
+set try
+if eval $compile_ok; then
+       if $run ./try; then
+               echo "You seem to speak EBCDIC." >&4
+               val="$define"
+       else
+               echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF-8." >&4
+       fi
+else
+       echo "I'm unable to compile the test program." >&4
+       echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
+fi
+$rm_try
+set ebcdic
+eval $setvar
+
+: length of character in bytes. Is always 1, otherwise it is not C
+: This used to be a test using sizeof
+charsize=1
+
+: Check for the number of bits in a character
+case "$charbits" in
+'')    echo "Checking how long a character is (in bits)..." >&4
+       $cat >try.c <<EOCP
+#include <stdio.h>
+int main ()
+{
+    int n;
+    unsigned char c;
+    for (c = 1, n = 0; c; c <<= 1, n++) ;
+    printf ("%d\n", n);
+    return (0);
+    }
+EOCP
+       set try
+       if eval $compile_ok; then
+               dflt=`$run ./try`
+       else
+               dflt='8'
+               echo "(I can't seem to compile the test program.  Guessing...)"
+       fi
+       ;;
+*)
+       dflt="$charbits"
+       ;;
+esac
+rp="What is the length of a character (in bits)?"
+. ./myread
+charbits="$ans"
+$rm_try
+case "$charbits" in
+8)     ;;
+*)     cat >&4 << EOM
+Your system has an unsigned character size of $charbits bits, which
+is rather unusual (normally it is 8 bits).  Perl likely will not work
+correctly on your system, with subtle bugs in various places.
+EOM
+       rp='Do you really want to continue?'
+       dflt='n'
+       . ./myread
+       case "$ans" in
+               [yY])   echo >&4 "Okay, continuing."    ;;
+               *)      exit 1                          ;;
+       esac
+esac
+
+: how do we concatenate cpp tokens here?
+echo " "
+echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
+$cat >cpp_stuff.c <<'EOCP'
+#define RCAT(a,b)a/**/b
+#define ACAT(a,b)a ## b
+RCAT(Rei,ser)
+ACAT(Cir,cus)
+EOCP
+$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
        echo "Oh!  Smells like ANSI's been here." >&4
        echo "We can catify or stringify, separately or together!"
@@ -19004,26 +19575,7 @@ esac
 
 : 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=*)
@@ -19034,131 +19586,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
-
-: Determine if this is an EBCDIC system
-echo " "
-echo "Determining whether or not we are on an EBCDIC system..." >&4
-$cat >try.c <<'EOM'
-int main()
-{
-  if ('M'==0xd4) return 0;
-  return 1;
-}
-EOM
-
-val=$undef
-set try
-if eval $compile_ok; then
-       if $run ./try; then
-               echo "You seem to speak EBCDIC." >&4
-               val="$define"
-       else
-               echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF-8." >&4
-       fi
-else
-       echo "I'm unable to compile the test program." >&4
-       echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
-fi
-$rm_try
-set ebcdic
-eval $setvar
+randfunc=Perl_drand48
+drand01="Perl_drand48()"
+seedfunc="Perl_drand48_init"
+randbits=48
+randseedtype=U32
 
 : Check how to flush
 echo " "
@@ -19242,7 +19674,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
@@ -19253,7 +19685,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
@@ -19263,11 +19695,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
@@ -19298,37 +19730,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).
@@ -19379,7 +19818,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.
@@ -19961,6 +20406,7 @@ EOCP
        $rm_try
        ;;
 *)     echo "You don't have <stdarg.h>, not checking for va_copy()." >&4
+       need_va_copy="$undef"
        ;;
 esac
 
@@ -20118,9 +20564,9 @@ case "$pager" in
        esac
        ;;
 *)     dflt="$pager"
-       fn="f/($pager)"
        ;;
 esac
+fn="f/($dflt)"
 echo " "
 rp='What pager is used on your system?'
 . ./getfile
@@ -20516,7 +20962,7 @@ esac
 : Trace out the files included by signal.h, then look for SIGxxx names.
 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 |
@@ -20934,6 +21380,74 @@ EOM
 fi
 $rm_try
 
+: Check the size of st_ino
+$echo " "
+$echo "Checking the size of st_ino..." >&4
+$cat > try.c <<EOCP
+#include <sys/stat.h>
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int main() {
+    struct stat st;
+    printf("%d\n", (int)sizeof(st.st_ino));
+    exit(0);
+}
+EOCP
+set try
+if eval $compile_ok; then
+       val=`$run ./try`
+       case "$val" in
+       '')     st_ino_size=4
+               $echo "(I can't execute the test program--guessing $st_ino_size.)" >&4
+               ;;
+       *)      st_ino_size=$val
+               $echo "Your st_ino is $st_ino_size bytes long."
+               ;;
+       esac
+else
+       st_ino_size=4
+       $echo "(I can't compile the test program--guessing $st_ino_size.)" >&4
+fi
+$rm_try
+
+: Check if st_ino is signed
+$echo " "
+$echo "Checking the sign of st_ino..." >&4
+$cat > try.c <<EOCP
+#include <sys/stat.h>
+#include <stdio.h>
+int main() {
+       struct stat foo;
+        foo.st_ino = -1;
+       if (foo.st_ino < 0)
+               printf("-1\n");
+       else
+               printf("1\n");
+}
+EOCP
+set try
+if eval $compile; then
+       val=`$run ./try`
+       case "$val" in
+       '')     st_ino_sign=1
+               $echo "(I can't execute the test program--guessing unsigned.)" >&4
+               ;;
+       *)      st_ino_sign=$val
+               case "$st_ino_sign" in
+                1) $echo "Your st_ino is unsigned." ;;
+               -1) $echo "Your st_ino is signed."   ;;
+               esac
+               ;;
+       esac
+else
+       st_ino_sign=1
+       $echo "(I can't compile the test program--guessing unsigned.)" >&4
+fi
+$rm_try
+
 : see what type of char stdio uses.
 echo " "
 echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
@@ -21082,6 +21596,221 @@ case "$uidsign" in
        ;;
 esac
 
+: Determine if we can use sysctl with KERN_PROC_PATHNAME to find executing program
+echo " "
+echo "Determining whether we can use sysctl with KERN_PROC_PATHNAME to find executing program..." >&4
+$cat >try.c <<'EOM'
+/* Intentionally a long probe as I'd like to sanity check that the exact
+   approach is going to work, as thinking it will work, but only having it
+   part working at runtime is worse than not having it.  */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/param.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(int argc, char **argv) {
+    char *buffer;
+    char *argv_leaf = strrchr(argv[0], '/');
+    char *buffer_leaf;
+    size_t size = 0;
+    int mib[4];
+
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_PROC;
+    mib[2] = KERN_PROC_PATHNAME;
+    mib[3] = -1;
+
+    if (!argv_leaf) {
+       fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
+       return 1;
+    }
+
+    if (sysctl(mib, 4, NULL, &size, NULL, 0)) {
+       perror("sysctl");
+       return 2;
+    }
+
+    if (size < strlen(argv_leaf) + 1) {
+       fprintf(stderr, "size %lu is too short for a path\n",
+               (unsigned long) size);
+       return 3;
+    }
+
+    if (size > MAXPATHLEN * MAXPATHLEN) {
+       fprintf(stderr, "size %lu is too long for a path\n",
+               (unsigned long) size);
+       return 4;
+    }
+
+    buffer = malloc(size);
+    if (!buffer) {
+       perror("malloc");
+       return 5;
+    }
+
+    if (sysctl(mib, 4, buffer, &size, NULL, 0)) {
+       perror("sysctl");
+       return 6;
+    }
+
+    if (strlen(buffer) + 1 != size) {
+       fprintf(stderr, "size != strlen(buffer) + 1 (%lu != %lu)\n",
+               (unsigned long)size, (unsigned long)strlen(buffer) + 1);
+        return 7;
+    }
+
+
+    if (*buffer != '/') {
+       fprintf(stderr, "Not an absolute path: '%s'\n", buffer);
+       return 8;
+    }
+
+    if (strstr(buffer, "/./")) {
+       fprintf(stderr, "Contains /./: '%s'\n", buffer);
+       return 9;
+    }
+
+    if (strstr(buffer, "/../")) {
+       fprintf(stderr, "Contains /../: '%s'\n", buffer);
+       return 10;
+    }
+
+    buffer_leaf = strrchr(buffer, '/');
+    if (strcmp(buffer_leaf, argv_leaf) != 0) {
+       fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], buffer);
+       return 11;
+    }
+
+    free(buffer);
+
+    return 0;
+}
+EOM
+
+val=$undef
+set try
+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"
+       else
+               echo "Nope, sysctl with KERN_PROC_PATHNAME doesn't work here." >&4
+               val="$undef"
+       fi
+else
+       echo "I'm unable to compile the test program." >&4
+       echo "I'll assume no sysctl with KERN_PROC_PATHNAME here." >&4
+       val="$undef"
+fi
+$rm_try
+set usekernprocpathname
+eval $setvar
+
+: Determine if we can use _NSGetExecutablePath to find executing program
+echo " "
+echo "Determining whether we can use _NSGetExecutablePath to find executing program..." >&4
+$cat >try.c <<'EOM'
+/* Intentionally a long probe as I'd like to sanity check that the exact
+   approach is going to work, as thinking it will work, but only having it
+   part working at runtime is worse than not having it.  */
+#include <mach-o/dyld.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <string.h>
+
+int
+main(int argc, char **argv) {
+    char buf[1];
+    uint32_t size = sizeof(buf);
+    int result;
+    char *buffer;
+    char *tidied;
+    char *argv_leaf = strrchr(argv[0], '/');
+    char *tidied_leaf;
+
+    if (!argv_leaf) {
+       fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
+       return 1;
+    }
+
+    _NSGetExecutablePath(buf, &size);
+    if (size > MAXPATHLEN * MAXPATHLEN) {
+       fprintf(stderr, "_NSGetExecutablePath size %u is too long for a path\n",
+               (unsigned int) size);
+       return 2;
+    }
+
+    buffer = malloc(size);
+    if (!buffer) {
+       perror("malloc");
+       return 3;
+    }
+
+    result = _NSGetExecutablePath(buffer, &size);
+    if (result != 0) {
+       fprintf(stderr, "_NSGetExecutablePath returned %i for a size of %u\n",
+               result, (unsigned int) size);
+       return 4;
+    }
+
+    tidied = realpath(buffer, NULL);
+    if (!tidied) {
+       perror("realpath");
+       return 5;
+    }
+
+    free(buffer);
+
+    if (*tidied != '/') {
+       fprintf(stderr, "Not an absolute path: '%s'\n", tidied);
+       return 6;
+    }
+
+    if (strstr(tidied, "/./")) {
+       fprintf(stderr, "Contains /./: '%s'\n", tidied);
+       return 7;
+    }
+
+    if (strstr(tidied, "/../")) {
+       fprintf(stderr, "Contains /../: '%s'\n", tidied);
+       return 8;
+    }
+
+    tidied_leaf = strrchr(tidied, '/');
+    if (strcmp(tidied_leaf, argv_leaf) != 0) {
+       fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], tidied);
+       return 9;
+    }
+
+    free(tidied);
+
+    return 0;
+}
+EOM
+
+val=$undef
+set try
+if eval $compile; then
+       if $run ./try; then
+               echo "You can use _NSGetExecutablePath to find the executing program." >&4
+               val="$define"
+       else
+               echo "Nope, _NSGetExecutablePath doesn't work here." >&4
+       fi
+else
+       echo "I'm unable to compile the test program." >&4
+       echo "I'll assume no _NSGetExecutablePath here." >&4
+fi
+$rm_try
+set usensgetexecutablepath
+eval $setvar
+
 : Check if site customization support was requested
 case "$usesitecustomize" in
     $define|true|[Yy]*)
@@ -21092,6 +21821,21 @@ case "$usesitecustomize" in
        ;;
     esac
 
+: see if prototypes support variable argument declarations
+echo " "
+case "$prototype$i_stdarg" in
+$define$define)
+       echo "It appears we'll be able to prototype varargs functions." >&4
+       val="$define"
+       ;;
+*)
+       echo "Too bad... We won't be using prototyped varargs functions..." >&4
+       val="$undef"
+       ;;
+esac
+set vaproto
+eval $setvar
+
 : determine compiler compiler
 case "$yacc" in
 '')
@@ -21117,7 +21861,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
        ;;
@@ -21351,15 +22095,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*::*.*)
+  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
     tHdrH=_tmpHdr
     rm -f $tHdrH'.h' $tHdrH
     touch $tHdrH'.h'
-    if cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
-       sed 's/#define[\ \  ]*//;s/[\ \     ].*$//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
+    # 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 -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
@@ -21446,56 +22191,85 @@ 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
 val=$val2; set i_sgtty; eval $setvar
 val=$val3; set i_termios; eval $setvar
 
+: see if stdbool is available
+: we want a real compile instead of Inhdr because some Solaris systems
+: have stdbool.h, but it can only be used if the compiler indicates it
+: is sufficiently c99-compliant.
+echo " "
+$cat >try.c <<EOCP
+#include <stdio.h>
+#include <stdbool.h>
+int func(bool x)
+{
+    return x ? 1 : 0;
+}
+int main(int argc, char **argv)
+{
+    return func(0);
+}
+EOCP
+set try
+if eval $compile; then
+       echo "<stdbool.h> found." >&4
+       val="$define"
+else
+       echo "<stdbool.h> NOT found." >&4
+       val="$undef"
+fi
+$rm_try
+set i_stdbool
+eval $setvar
+
 : see if stddef is available
 set stddef.h i_stddef
 eval $inhdr
@@ -21603,10 +22377,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
@@ -21614,49 +22388,74 @@ nonxs_extensions=''
 
 : Function to recursively find available extensions, ignoring DynaLoader
 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
+: In 5.10.1 and later, extensions are stored in directories
+: like File-Glob instead of the older File/Glob/.
 find_extensions='
     for xxx in *; do
        case "$xxx" in
            DynaLoader|dynaload) ;;
            *)
-           if $test -f $xxx/$xxx.xs -o -f $xxx/$xxx.c; then
-               known_extensions="$known_extensions $1$xxx";
-           elif $test -f $xxx/Makefile.PL; then
-               nonxs_extensions="$nonxs_extensions $1$xxx";
-           else
-               if $test -d $xxx -a $# -lt 10; then
-                   set $1$xxx/ $*;
-                   cd "$xxx";
-                   eval $find_extensions;
-                   cd ..;
-                   shift;
-               fi;
-           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" > $$.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 (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 > $$.tmp;
+           if   $contains "\.xs$" $$.tmp > /dev/null 2>&1; then
+               xs_extensions="$xs_extensions $this_ext";
+           elif $contains "\.c$"  $$.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 $$.tmp;
            ;;
        esac;
     done'
 tdir=`pwd`
+cd "$rsrc/cpan"
+set X
+shift
+eval $find_extensions
+cd "$rsrc/dist"
+set X
+shift
+eval $find_extensions
 cd "$rsrc/ext"
 set X
 shift
 eval $find_extensions
-# Special case:  Add in modules that nest beyond the first level.
-# Currently threads/shared and Hash/Util/FieldHash, since they are
-# not picked up by the recursive find above (and adding in general
-# recursive finding breaks SDBM_File/sdbm).
-# A.D. 20011025 (SDBM), ajgough 20071008 (FieldHash)
-known_extensions="$known_extensions threads/shared Hash/Util/FieldHash"
-set X $known_extensions
+set X $xs_extensions
 shift
-known_extensions="$*"
+xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
 set X $nonxs_extensions
 shift
-nonxs_extensions="$*"
+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
        DB_File|db_file)
                case "$i_db" in
@@ -21680,7 +22479,7 @@ for xxx in $known_extensions ; do
                esac
                ;;
        NDBM_File|ndbm_fil)
-               case "$i_ndbm" in
+               case "$d_ndbm" in
                $define)
                    case "$osname-$use64bitint" in
                    hpux-define)
@@ -21723,12 +22522,7 @@ 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)
@@ -21759,6 +22553,8 @@ for xxx in $known_extensions ; do
                # --jhi
                avail_ext="$avail_ext $xxx"
                ;;
+       VMS*)
+               ;;
        Win32*)
                case "$osname" in
                cygwin) avail_ext="$avail_ext $xxx" ;;
@@ -21789,7 +22585,7 @@ avail_ext="$*"
 case "$onlyextensions" in
 '') ;;
 *)  keepextensions=''
-    echo "You have requested that only certains extensions be included..." >&4
+    echo "You have requested that only certain extensions be included..." >&4
     for i in $onlyextensions; do
         case " $avail_ext " in
         *" $i "*)
@@ -21824,6 +22620,8 @@ esac
 nonxs_ext=''
 for xxx in $nonxs_extensions ; do
        case "$xxx" in
+       VMS*)
+               ;;
        *)      nonxs_ext="$nonxs_ext $xxx"
                ;;
        esac
@@ -21959,9 +22757,10 @@ esac
 # the appropriate Makefile.PL.
 case " $static_ext " in
        *" Encode "*) # Add the subextensions of Encode
-       cd "$rsrc/ext"
+       cd "$rsrc/cpan"
        for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
                static_ext="$static_ext Encode/$xxx"
+               known_extensions="$known_extensions Encode/$xxx"
        done
        cd "$tdir"
        ;;
@@ -21997,7 +22796,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="$*"
            ;;
@@ -22081,7 +22880,9 @@ $startsh
 # Target system     : $myuname
 
 EOT
+: Add in command line options if available
 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
+
 $spitshell <<EOT >>config.sh
 
 Author='$Author'
@@ -22117,8 +22918,10 @@ awk='$awk'
 baserev='$baserev'
 bash='$bash'
 bin='$bin'
+bin_ELF='$bin_ELF'
 binexp='$binexp'
 bison='$bison'
+bootstrap_charset='$bootstrap_charset'
 byacc='$byacc'
 byteorder='$byteorder'
 c='$c'
@@ -22135,6 +22938,8 @@ ccversion='$ccversion'
 cf_by='$cf_by'
 cf_email='$cf_email'
 cf_time='$cf_time'
+charbits='$charbits'
+charsize='$charsize'
 chgrp='$chgrp'
 chmod='$chmod'
 chown='$chown'
@@ -22283,6 +23088,7 @@ d_ftime='$d_ftime'
 d_futimes='$d_futimes'
 d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
 d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
+d_getaddrinfo='$d_getaddrinfo'
 d_getcwd='$d_getcwd'
 d_getespwnam='$d_getespwnam'
 d_getfsstat='$d_getfsstat'
@@ -22304,6 +23110,7 @@ d_getlogin='$d_getlogin'
 d_getlogin_r='$d_getlogin_r'
 d_getmnt='$d_getmnt'
 d_getmntent='$d_getmntent'
+d_getnameinfo='$d_getnameinfo'
 d_getnbyaddr='$d_getnbyaddr'
 d_getnbyname='$d_getnbyname'
 d_getnent='$d_getnent'
@@ -22349,8 +23156,15 @@ d_ilogbl='$d_ilogbl'
 d_inc_version_list='$d_inc_version_list'
 d_index='$d_index'
 d_inetaton='$d_inetaton'
+d_inetntop='$d_inetntop'
+d_inetpton='$d_inetpton'
 d_int64_t='$d_int64_t'
+d_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_isinf='$d_isinf'
 d_isnan='$d_isnan'
@@ -22359,6 +23173,7 @@ d_killpg='$d_killpg'
 d_lchown='$d_lchown'
 d_ldbl_dig='$d_ldbl_dig'
 d_libm_lib_version='$d_libm_lib_version'
+d_libname_unique='$d_libname_unique'
 d_link='$d_link'
 d_localtime64='$d_localtime64'
 d_localtime_r='$d_localtime_r'
@@ -22424,6 +23239,8 @@ d_phostname='$d_phostname'
 d_pipe='$d_pipe'
 d_poll='$d_poll'
 d_portable='$d_portable'
+d_prctl='$d_prctl'
+d_prctl_set_name='$d_prctl_set_name'
 d_printf_format_null='$d_printf_format_null'
 d_procselfexe='$d_procselfexe'
 d_pseudofork='$d_pseudofork'
@@ -22498,7 +23315,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'
@@ -22509,8 +23325,11 @@ d_sigaction='$d_sigaction'
 d_signbit='$d_signbit'
 d_sigprocmask='$d_sigprocmask'
 d_sigsetjmp='$d_sigsetjmp'
+d_sin6_scope_id='$d_sin6_scope_id'
 d_sitearch='$d_sitearch'
 d_snprintf='$d_snprintf'
+d_sockaddr_in6='$d_sockaddr_in6'
+d_sockaddr_sa_len='$d_sockaddr_sa_len'
 d_sockatmark='$d_sockatmark'
 d_sockatmarkproto='$d_sockatmarkproto'
 d_socket='$d_socket'
@@ -22526,6 +23345,7 @@ d_sresuproto='$d_sresuproto'
 d_statblks='$d_statblks'
 d_statfs_f_flags='$d_statfs_f_flags'
 d_statfs_s='$d_statfs_s'
+d_static_inline='$d_static_inline'
 d_statvfs='$d_statvfs'
 d_stdio_cnt_lval='$d_stdio_cnt_lval'
 d_stdio_ptr_lval='$d_stdio_ptr_lval'
@@ -22606,7 +23426,6 @@ 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'
@@ -22683,6 +23502,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'
@@ -22702,7 +23524,6 @@ 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_fcntl='$i_fcntl'
 i_float='$i_float'
@@ -22734,11 +23555,11 @@ i_prot='$i_prot'
 i_pthread='$i_pthread'
 i_pwd='$i_pwd'
 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_stdlib='$i_stdlib'
 i_string='$i_string'
@@ -22786,6 +23607,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'
@@ -22824,6 +23646,7 @@ ivtype='$ivtype'
 known_extensions='$known_extensions'
 ksh='$ksh'
 ld='$ld'
+ld_can_script='$ld_can_script'
 lddlflags='$lddlflags'
 ldflags='$ldflags'
 ldflags_uselargefiles='$ldflags_uselargefiles'
@@ -22922,6 +23745,7 @@ path_sep='$path_sep'
 perl5='$perl5'
 perl='$perl'
 perl_patchlevel='$perl_patchlevel'
+perl_static_inline='$perl_static_inline'
 perladmin='$perladmin'
 perllibs='$perllibs'
 perlpath='$perlpath'
@@ -23034,6 +23858,8 @@ srand48_r_proto='$srand48_r_proto'
 srandom_r_proto='$srandom_r_proto'
 src='$src'
 ssizetype='$ssizetype'
+st_ino_sign='$st_ino_sign'
+st_ino_size='$st_ino_size'
 startperl='$startperl'
 startsh='$startsh'
 static_ext='$static_ext'
@@ -23049,9 +23875,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'
@@ -23088,6 +23921,7 @@ usedl='$usedl'
 usedtrace='$usedtrace'
 usefaststdio='$usefaststdio'
 useithreads='$useithreads'
+usekernprocpathname='$usekernprocpathname'
 uselargefiles='$uselargefiles'
 uselongdouble='$uselongdouble'
 usemallocwrap='$usemallocwrap'
@@ -23095,17 +23929,18 @@ usemorebits='$usemorebits'
 usemultiplicity='$usemultiplicity'
 usemymalloc='$usemymalloc'
 usenm='$usenm'
+usensgetexecutablepath='$usensgetexecutablepath'
 useopcode='$useopcode'
 useperlio='$useperlio'
 useposix='$useposix'
 usereentrant='$usereentrant'
 userelocatableinc='$userelocatableinc'
-usesfio='$usesfio'
 useshrplib='$useshrplib'
 usesitecustomize='$usesitecustomize'
 usesocks='$usesocks'
 usethreads='$usethreads'
 usevendorprefix='$usevendorprefix'
+useversionedarchname='$useversionedarchname'
 usevfork='$usevfork'
 usrinc='$usrinc'
 uuname='$uuname'
@@ -23115,6 +23950,7 @@ uvsize='$uvsize'
 uvtype='$uvtype'
 uvuformat='$uvuformat'
 uvxformat='$uvxformat'
+vaproto='$vaproto'
 vendorarch='$vendorarch'
 vendorarchexp='$vendorarchexp'
 vendorbin='$vendorbin'
@@ -23138,7 +23974,6 @@ version='$version'
 version_patchlevel_string='$version_patchlevel_string'
 versiononly='$versiononly'
 vi='$vi'
-voidflags='$voidflags'
 xlibpth='$xlibpth'
 yacc='$yacc'
 yaccflags='$yaccflags'
@@ -23146,9 +23981,6 @@ zcat='$zcat'
 zip='$zip'
 EOT
 
-: Add in command line options if available
-$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
-
 : add special variables
 $test -f $src/patchlevel.h && \
 awk '/^#define[        ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
@@ -23161,16 +23993,16 @@ if $test -f UU/config.sh; then
        $sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' \
                config.sh config.sh UU/oldconfig.sh |\
                $sort | $uniq -u >UU/oldsyms
-       set X `cat UU/oldsyms`
+       set X `$cat UU/oldsyms`
        shift
        case $# in
        0) ;;
        *)
-               cat <<EOM
+               $cat <<EOM
 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
 EOM
                echo ": Variables propagated from previous config.sh file." >>config.sh
-               for sym in `cat UU/oldsyms`; do
+               for sym in `$cat UU/oldsyms`; do
                        echo "    Propagating $hint variable "'$'"$sym..."
                        eval 'tmp="$'"${sym}"'"'
                        echo "$tmp" | \