This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix prototype detection for C++
[perl5.git] / Configure
index 5bc904a..857a78e 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -25,7 +25,7 @@
 
 # $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
 #
-# Generated on Fri Mar 21 11:25:23 CET 2008 [metaconfig 3.5 PL0]
+# Generated on Mon Oct 27 19:29:26 CET 2008 [metaconfig 3.5 PL0]
 # (with additional metaconfig patches by perlbug@perl.org)
 
 cat >c1$$ <<EOF
@@ -207,6 +207,7 @@ run=''
 targetarch=''
 to=''
 usecrosscompile=''
+extern_C=''
 mistrustnm=''
 perllibs=''
 dynamic_ext=''
@@ -777,6 +778,13 @@ d_tcsetpgrp=''
 d_telldirproto=''
 d_time=''
 timetype=''
+d_asctime64=''
+d_ctime64=''
+d_difftime64=''
+d_gmtime64=''
+d_localtime64=''
+d_mktime64=''
+d_timegm=''
 clocktype=''
 d_times=''
 d_tmpnam_r=''
@@ -873,6 +881,9 @@ i_mallocmalloc=''
 i_math=''
 i_memory=''
 i_mntent=''
+d_ndbm=''
+i_gdbm_ndbm=''
+i_gdbmndbm=''
 i_ndbm=''
 i_netdb=''
 i_neterrno=''
@@ -1168,6 +1179,10 @@ stdchar=''
 d_stdio_stream_array=''
 stdio_stream_array=''
 sysman=''
+sGMTIME_max=''
+sGMTIME_min=''
+sLOCALTIME_max=''
+sLOCALTIME_min=''
 trnl=''
 uidformat=''
 uidsign=''
@@ -1269,12 +1284,12 @@ elif test -d c:/. -o -n "$is_os2" ; then
     _exe=".exe"
 fi
 
+groupstype=''
 i_whoami=''
 : Trailing extension.  Override this in a hint file, if needed.
 : Extra object files, if any, needed on this platform.
 archobjs=''
 archname=''
-groupstype=''
 libnames=''
 : change the next line if compiling for Xenix/286 on Xenix/386
 xlibpth='/usr/lib/386 /lib/386'
@@ -1405,14 +1420,14 @@ if `$sh -c '#' >/dev/null 2>&1`; then
        echo "#!$xcat" >sharp
        $eunicefix sharp
        chmod +x sharp
-       ./sharp > today
+       ./sharp > today 2>/dev/null
        if test -s today; then
                sharpbang='#!'
        else
                echo "#! $xcat" > sharp
                $eunicefix sharp
                chmod +x sharp
-               ./sharp > today
+               ./sharp > today 2>/dev/null
                if test -s today; then
                        sharpbang='#! '
                else
@@ -1936,7 +1951,7 @@ rm -f .echotmp
 echo " "
 if test -f "$rsrc/MANIFEST"; then
        echo "First let's make sure your kit is complete.  Checking..." >&4
-       awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" |\
+       awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
                (split -l 50 2>/dev/null || split -50)
        rm -f missing
        tmppwd=`pwd`
@@ -5119,7 +5134,7 @@ default|recommended)
        # as that way the compiler can do the right implementation dependant
        # thing. (NWC)
        case "$gccversion" in
-       ?*)     set stack-protector -fstack-protector 'ldflags="$ldflags -fstack-protector"'
+       ?*)     set stack-protector -fstack-protector
                eval $checkccflag
                ;;
        esac
@@ -5261,6 +5276,15 @@ case "$ldflags" in
        ;;
 *) dflt="$ldflags";;
 esac
+# See note above about -fstack-protector
+case "$ccflags" in
+*-fstack-protector*) 
+       case "$dflt" in
+       *-fstack-protector*) ;; # Don't add it again
+       *) dflt="$dflt -fstack-protector" ;; 
+       esac
+       ;;
+esac
 
 : Try to guess additional flags to pick up local libraries.
 for thislibdir in $libpth; do
@@ -5382,6 +5406,11 @@ $rm_try gcctest gcctest.out
 compile='
 mc_file=$1;
 shift;
+case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
+echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to perlbug@perl.org" >&4;
+exit 1;
+fi;
+esac;
 $cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
 : define a shorthand compile call for compilations that should be ok.
 compile_ok='
@@ -6562,7 +6591,7 @@ echo " "
 $cat >try.c <<EOCP
 #include <stdlib.h>
 #include <malloc.h>
-$i_mallocmalloc I_MALLOCMALLOC
+#$i_mallocmalloc I_MALLOCMALLOC
 #ifdef I_MALLOCMALLOC
 # include <malloc/malloc.h>
 #endif
@@ -7427,9 +7456,10 @@ case "$nm_so_opt" in
        ;;
 esac
 
-: get list of predefined functions in a handy place
+: Figure out where the libc is located
 case "$runnm" in
 true)
+: get list of predefined functions in a handy place
 echo " "
 case "$libc" in
 '') libc=unknown
@@ -7656,31 +7686,31 @@ else
                echo " "
                echo "$nm didn't seem to work right. Trying $ar instead..." >&4
                com=''
-               if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
+               if $ar t $libc > libc.tmp && \
+                       $contains '^fprintf$' libc.tmp >/dev/null 2>&1
+               then
                        for thisname in $libnames $libc; do
                                $ar t $thisname >>libc.tmp
                        done
                        $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
                        echo "Ok." >&4
                elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
-                       # Repeat libc to extract forwarders to DLL entries too
                        for thisname in $libnames $libc; do
                                $ar tv $thisname >>libc.tmp
-                               # Revision 50 of EMX has bug in $ar.
-                               # it will not extract forwarders to DLL entries
-                               # Use emximp which will extract exactly them.
                                emximp -o tmp.imp $thisname \
                                    2>/dev/null && \
                                    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
                                    < tmp.imp >>libc.tmp
-                               $rm tmp.imp
+                               $rm -f tmp.imp
                        done
                        $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
                        echo "Ok." >&4
                else
                        echo "$ar didn't seem to work right." >&4
                        echo "Maybe this is a Cray...trying bld instead..." >&4
-                       if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
+                       if  bld t $libc | \
+                               $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list &&
+                               $test -s libc.list
                        then
                                for thisname in $libnames; do
                                        bld t $libnames | \
@@ -7705,7 +7735,8 @@ define)
 *)  if $test -f /lib/syscalls.exp; then
        echo " "
        echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
-       $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*[        ]*$/\1/p' /lib/syscalls.exp >>libc.list
+       $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*[        ]*$/\1/p' \
+               /lib/syscalls.exp >>libc.list
     fi
     ;;
 esac
@@ -7750,6 +7781,10 @@ case "$3" in
 -a) tf=libc.tmp; tdc="[]";;
 *) tlook="^$1\$"; tf=libc.list; tdc="()";;
 esac;
+case "$d_cplusplus" in
+    $define)   extern_C="extern \"C\"" ;;
+    *)         extern_C="extern"       ;;
+esac;
 tx=yes;
 case "$reuseval-$4" in
 true-) ;;
@@ -7758,20 +7793,17 @@ esac;
 case "$tx" in
 yes)
        tval=false;
-       case "$d_cplusplus" in
-               $define) extern_C=\"C\";;
-       esac;
        if $test "$runnm" = true; then
                if $contains $tlook $tf >/dev/null 2>&1; then
                        tval=true;
                elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
-                       echo "extern $extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
+                       echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
                        $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
                        $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
                        $rm_try;
                fi;
        else
-               echo "extern $extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
+               echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
                $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
                $rm_try;
        fi;
@@ -8018,6 +8050,16 @@ EOM
        ''|' ') dflt='none' ;;
        esac
 
+       case "$ldflags" in
+       *-fstack-protector*)
+           case "$dflt" in
+                       *-fstack-protector*) ;; # Don't add it again
+                       *) dflt="$dflt -fstack-protector" ;; 
+               esac
+               ;;
+       esac
+
+
     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
     . ./myread
     case "$ans" in
@@ -8119,9 +8161,9 @@ true)
                # a version-specific architecture-dependent library, the version
                # number isn't really that important, except for making cc/ld happy.
                #
-               # A name such as libperl.so.3.1
+               # A name such as libperl.so.10.1
                majmin="libperl.$so.$patchlevel.$subversion"
-               # A name such as libperl.so.301
+               # A name such as libperl.so.100
                majonly=`echo $patchlevel $subversion |
                        $awk '{printf "%d%02d", $1, $2}'`
                majonly=libperl.$so.$majonly
@@ -8135,8 +8177,12 @@ true)
                linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
                        dflt=libperl.$so
                        ;;
-               cygwin*) # ld links against an importlib
-                       dflt=libperl$lib_ext
+               cygwin*) # ld links now against the dll directly
+                       majmin="cygperl5_${patchlevel}_${subversion}.${so}"
+                       majonly=`echo $patchlevel $subversion |
+                               $awk '{printf "%03d%03d", $1, $2}'`
+                       majonly=cygperl5.$majonly.$so
+                       dflt=$majmin
                        ;;
                *)      # Try to guess based on whether libc has major.minor.
                        case "$libc" in
@@ -8232,6 +8278,9 @@ if "$useshrplib"; then
                # hpux doesn't like the default, either.
                tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
                ;;
+       cygwin)
+               # cygwin needs only ldlibpth
+               ;;
        *)
                tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
                ;;
@@ -8671,11 +8720,11 @@ case "$myhostname" in
                                echo "(Attempting domain name extraction from $tans)"
                                dflt=.`$sed -n -e 's/   / /g' \
                                  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
-                                 | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
+                                 -e 1q 2>/dev/null`
                                case "$dflt" in
                                .) dflt=.`$sed -n -e 's/        / /g' \
                                     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
-                                    | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
+                                    -e 1q 2>/dev/null`
                                        ;;
                                esac
                        fi
@@ -9875,6 +9924,26 @@ eval $inlibc
 set alarm d_alarm
 eval $inlibc
 
+: see if 64bit time functions exists
+
+set ctime64 d_ctime64
+eval $inlibc
+
+set localtime64 d_localtime64
+eval $inlibc
+
+set gmtime64 d_gmtime64
+eval $inlibc
+
+set mktime64 d_mktime64
+eval $inlibc
+
+set difftime64 d_difftime64
+eval $inlibc
+
+set asctime64 d_asctime64
+eval $inlibc
+
 : see if POSIX threads are available
 set pthread.h i_pthread
 eval $inhdr
@@ -10116,19 +10185,19 @@ case "$d_asctime_r" in
        define)
        case "$asctime_r_proto" in
        ''|0) try='char* asctime_r(const struct tm*, char*);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=B_SB ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SB ;;
        esac
        case "$asctime_r_proto" in
        ''|0) try='char* asctime_r(const struct tm*, char*, int);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=B_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SBI ;;
        esac
        case "$asctime_r_proto" in
        ''|0) try='int asctime_r(const struct tm*, char*);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=I_SB ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SB ;;
        esac
        case "$asctime_r_proto" in
        ''|0) try='int asctime_r(const struct tm*, char*, int);'
-       ./protochk "extern $try" $hdrs && asctime_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SBI ;;
        esac
        case "$asctime_r_proto" in
        ''|0)   d_asctime_r=undef
@@ -11261,11 +11330,11 @@ case "$d_crypt_r" in
        define)
        case "$crypt_r_proto" in
        ''|0) try='char* crypt_r(const char*, const char*, struct crypt_data*);'
-       ./protochk "extern $try" $hdrs && crypt_r_proto=B_CCS ;;
+       ./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCS ;;
        esac
        case "$crypt_r_proto" in
        ''|0) try='char* crypt_r(const char*, const char*, CRYPTD*);'
-       ./protochk "extern $try" $hdrs && crypt_r_proto=B_CCD ;;
+       ./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCD ;;
        esac
        case "$crypt_r_proto" in
        ''|0)   d_crypt_r=undef
@@ -11322,7 +11391,7 @@ case "$d_ctermid_r" in
        define)
        case "$ctermid_r_proto" in
        ''|0) try='char* ctermid_r(char*);'
-       ./protochk "extern $try" $hdrs && ctermid_r_proto=B_B ;;
+       ./protochk "$extern_C $try" $hdrs && ctermid_r_proto=B_B ;;
        esac
        case "$ctermid_r_proto" in
        ''|0)   d_ctermid_r=undef
@@ -11363,19 +11432,19 @@ case "$d_ctime_r" in
        define)
        case "$ctime_r_proto" in
        ''|0) try='char* ctime_r(const time_t*, char*);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=B_SB ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SB ;;
        esac
        case "$ctime_r_proto" in
        ''|0) try='char* ctime_r(const time_t*, char*, int);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=B_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SBI ;;
        esac
        case "$ctime_r_proto" in
        ''|0) try='int ctime_r(const time_t*, char*);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=I_SB ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SB ;;
        esac
        case "$ctime_r_proto" in
        ''|0) try='int ctime_r(const time_t*, char*, int);'
-       ./protochk "extern $try" $hdrs && ctime_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SBI ;;
        esac
        case "$ctime_r_proto" in
        ''|0)   d_ctime_r=undef
@@ -11781,7 +11850,7 @@ case "$d_drand48_r" in
        define)
        case "$drand48_r_proto" in
        ''|0) try='int drand48_r(struct drand48_data*, double*);'
-       ./protochk "extern $try" $hdrs && drand48_r_proto=I_ST ;;
+       ./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;;
        esac
        case "$drand48_r_proto" in
        ''|0)   d_drand48_r=undef
@@ -11864,11 +11933,11 @@ case "$d_endgrent_r" in
        define)
        case "$endgrent_r_proto" in
        ''|0) try='int endgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endgrent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && endgrent_r_proto=I_H ;;
        esac
        case "$endgrent_r_proto" in
        ''|0) try='void endgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endgrent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && endgrent_r_proto=V_H ;;
        esac
        case "$endgrent_r_proto" in
        ''|0)   d_endgrent_r=undef
@@ -11917,11 +11986,11 @@ case "$d_endhostent_r" in
        define)
        case "$endhostent_r_proto" in
        ''|0) try='int endhostent_r(struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && endhostent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endhostent_r_proto=I_D ;;
        esac
        case "$endhostent_r_proto" in
        ''|0) try='void endhostent_r(struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && endhostent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endhostent_r_proto=V_D ;;
        esac
        case "$endhostent_r_proto" in
        ''|0)   d_endhostent_r=undef
@@ -11966,11 +12035,11 @@ case "$d_endnetent_r" in
        define)
        case "$endnetent_r_proto" in
        ''|0) try='int endnetent_r(struct netent_data*);'
-       ./protochk "extern $try" $hdrs && endnetent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endnetent_r_proto=I_D ;;
        esac
        case "$endnetent_r_proto" in
        ''|0) try='void endnetent_r(struct netent_data*);'
-       ./protochk "extern $try" $hdrs && endnetent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endnetent_r_proto=V_D ;;
        esac
        case "$endnetent_r_proto" in
        ''|0)   d_endnetent_r=undef
@@ -12015,11 +12084,11 @@ case "$d_endprotoent_r" in
        define)
        case "$endprotoent_r_proto" in
        ''|0) try='int endprotoent_r(struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && endprotoent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=I_D ;;
        esac
        case "$endprotoent_r_proto" in
        ''|0) try='void endprotoent_r(struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && endprotoent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=V_D ;;
        esac
        case "$endprotoent_r_proto" in
        ''|0)   d_endprotoent_r=undef
@@ -12152,11 +12221,11 @@ case "$d_endpwent_r" in
        define)
        case "$endpwent_r_proto" in
        ''|0) try='int endpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endpwent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && endpwent_r_proto=I_H ;;
        esac
        case "$endpwent_r_proto" in
        ''|0) try='void endpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && endpwent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && endpwent_r_proto=V_H ;;
        esac
        case "$endpwent_r_proto" in
        ''|0)   d_endpwent_r=undef
@@ -12201,11 +12270,11 @@ case "$d_endservent_r" in
        define)
        case "$endservent_r_proto" in
        ''|0) try='int endservent_r(struct servent_data*);'
-       ./protochk "extern $try" $hdrs && endservent_r_proto=I_D ;;
+       ./protochk "$extern_C $try" $hdrs && endservent_r_proto=I_D ;;
        esac
        case "$endservent_r_proto" in
        ''|0) try='void endservent_r(struct servent_data*);'
-       ./protochk "extern $try" $hdrs && endservent_r_proto=V_D ;;
+       ./protochk "$extern_C $try" $hdrs && endservent_r_proto=V_D ;;
        esac
        case "$endservent_r_proto" in
        ''|0)   d_endservent_r=undef
@@ -13239,27 +13308,27 @@ case "$d_getgrent_r" in
        define)
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, size_t, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBWR ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, int, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIR ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='struct group* getgrent_r(struct group*, char*, size_t);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=S_SBW ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBW ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='struct group* getgrent_r(struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBI ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBI ;;
        esac
        case "$getgrent_r_proto" in
        ''|0) try='int getgrent_r(struct group*, char*, int, FILE**);'
-       ./protochk "extern $try" $hdrs && getgrent_r_proto=I_SBIH ;;
+       ./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIH ;;
        esac
        case "$getgrent_r_proto" in
        ''|0)   d_getgrent_r=undef
@@ -13300,19 +13369,19 @@ case "$d_getgrgid_r" in
        define)
        case "$getgrgid_r_proto" in
        ''|0) try='int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0) try='int getgrgid_r(gid_t, struct group*, char*, int, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0) try='int getgrgid_r(gid_t, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0) try='struct group* getgrgid_r(gid_t, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
        esac
        case "$getgrgid_r_proto" in
        ''|0)   d_getgrgid_r=undef
@@ -13353,23 +13422,23 @@ case "$d_getgrnam_r" in
        define)
        case "$getgrnam_r_proto" in
        ''|0) try='int getgrnam_r(const char*, struct group*, char*, size_t, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='int getgrnam_r(const char*, struct group*, char*, int, struct group**);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='struct group* getgrnam_r(const char*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=S_CBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CBI ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='int getgrnam_r(const char*, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0) try='struct group* getgrnam_r(const char*, struct group*, char*, int);'
-       ./protochk "extern $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
        esac
        case "$getgrnam_r_proto" in
        ''|0)   d_getgrnam_r=undef
@@ -13507,47 +13576,47 @@ case "$d_gethostbyaddr_r" in
        define)
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const void*, size_t, int, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, int, int, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const char*, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='struct hostent* gethostbyaddr_r(const void*, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, int, int, struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const char*, int, int);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0) try='int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
        esac
        case "$gethostbyaddr_r_proto" in
        ''|0)   d_gethostbyaddr_r=undef
@@ -13588,15 +13657,15 @@ case "$d_gethostbyname_r" in
        define)
        case "$gethostbyname_r_proto" in
        ''|0) try='int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
        esac
        case "$gethostbyname_r_proto" in
        ''|0) try='struct hostent* gethostbyname_r(const char*, struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
        esac
        case "$gethostbyname_r_proto" in
        ''|0) try='int gethostbyname_r(const char*, struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
        esac
        case "$gethostbyname_r_proto" in
        ''|0)   d_gethostbyname_r=undef
@@ -13637,27 +13706,27 @@ case "$d_gethostent_r" in
        define)
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, char*, size_t, struct hostent**, int*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBIE ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=S_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBIE ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBI ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, char*, int);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBI ;;
        esac
        case "$gethostent_r_proto" in
        ''|0) try='int gethostent_r(struct hostent*, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && gethostent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SD ;;
        esac
        case "$gethostent_r_proto" in
        ''|0)   d_gethostent_r=undef
@@ -13711,19 +13780,19 @@ case "$d_getlogin_r" in
        define)
        case "$getlogin_r_proto" in
        ''|0) try='int getlogin_r(char*, size_t);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=I_BW ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BW ;;
        esac
        case "$getlogin_r_proto" in
        ''|0) try='int getlogin_r(char*, int);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=I_BI ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BI ;;
        esac
        case "$getlogin_r_proto" in
        ''|0) try='char* getlogin_r(char*, size_t);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=B_BW ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BW ;;
        esac
        case "$getlogin_r_proto" in
        ''|0) try='char* getlogin_r(char*, int);'
-       ./protochk "extern $try" $hdrs && getlogin_r_proto=B_BI ;;
+       ./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BI ;;
        esac
        case "$getlogin_r_proto" in
        ''|0)   d_getlogin_r=undef
@@ -13784,35 +13853,35 @@ case "$d_getnetbyaddr_r" in
        define)
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(unsigned long, int, struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(long, int, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='struct netent* getnetbyaddr_r(in_addr_t, int, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='struct netent* getnetbyaddr_r(long, int, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(in_addr_t, int, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(long, int, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(int, int, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0) try='int getnetbyaddr_r(uint32_t, int, struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
        esac
        case "$getnetbyaddr_r_proto" in
        ''|0)   d_getnetbyaddr_r=undef
@@ -13853,19 +13922,19 @@ case "$d_getnetbyname_r" in
        define)
        case "$getnetbyname_r_proto" in
        ''|0) try='int getnetbyname_r(const char*, struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0) try='int getnetbyname_r(const char*, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0) try='struct netent* getnetbyname_r(const char*, struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0) try='int getnetbyname_r(const char*, struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
        esac
        case "$getnetbyname_r_proto" in
        ''|0)   d_getnetbyname_r=undef
@@ -13906,27 +13975,27 @@ case "$d_getnetent_r" in
        define)
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, char*, size_t, struct netent**, int*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBIE ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='struct netent* getnetent_r(struct netent*, char*, int, int*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=S_SBIE ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBIE ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='struct netent* getnetent_r(struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBI ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBI ;;
        esac
        case "$getnetent_r_proto" in
        ''|0) try='int getnetent_r(struct netent*, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && getnetent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SD ;;
        esac
        case "$getnetent_r_proto" in
        ''|0)   d_getnetent_r=undef
@@ -14006,15 +14075,15 @@ case "$d_getprotobyname_r" in
        define)
        case "$getprotobyname_r_proto" in
        ''|0) try='int getprotobyname_r(const char*, struct protoent*, char*, size_t, struct protoent**);'
-       ./protochk "extern $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
        esac
        case "$getprotobyname_r_proto" in
        ''|0) try='struct protoent* getprotobyname_r(const char*, struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
        esac
        case "$getprotobyname_r_proto" in
        ''|0) try='int getprotobyname_r(const char*, struct protoent*, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
        esac
        case "$getprotobyname_r_proto" in
        ''|0)   d_getprotobyname_r=undef
@@ -14055,15 +14124,15 @@ case "$d_getprotobynumber_r" in
        define)
        case "$getprotobynumber_r_proto" in
        ''|0) try='int getprotobynumber_r(int, struct protoent*, char*, size_t, struct protoent**);'
-       ./protochk "extern $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
        esac
        case "$getprotobynumber_r_proto" in
        ''|0) try='struct protoent* getprotobynumber_r(int, struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
        esac
        case "$getprotobynumber_r_proto" in
        ''|0) try='int getprotobynumber_r(int, struct protoent*, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
+       ./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
        esac
        case "$getprotobynumber_r_proto" in
        ''|0)   d_getprotobynumber_r=undef
@@ -14104,19 +14173,19 @@ case "$d_getprotoent_r" in
        define)
        case "$getprotoent_r_proto" in
        ''|0) try='int getprotoent_r(struct protoent*, char*, size_t, struct protoent**);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0) try='int getprotoent_r(struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBI ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0) try='struct protoent* getprotoent_r(struct protoent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=S_SBI ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0) try='int getprotoent_r(struct protoent*, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && getprotoent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SD ;;
        esac
        case "$getprotoent_r_proto" in
        ''|0)   d_getprotoent_r=undef
@@ -14170,27 +14239,27 @@ case "$d_getpwent_r" in
        define)
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, size_t, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBWR ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, int, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIR ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='struct passwd* getpwent_r(struct passwd*, char*, size_t);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=S_SBW ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBW ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='struct passwd* getpwent_r(struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBI ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBI ;;
        esac
        case "$getpwent_r_proto" in
        ''|0) try='int getpwent_r(struct passwd*, char*, int, FILE**);'
-       ./protochk "extern $try" $hdrs && getpwent_r_proto=I_SBIH ;;
+       ./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIH ;;
        esac
        case "$getpwent_r_proto" in
        ''|0)   d_getpwent_r=undef
@@ -14231,19 +14300,19 @@ case "$d_getpwnam_r" in
        define)
        case "$getpwnam_r_proto" in
        ''|0) try='int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0) try='struct passwd* getpwnam_r(const char*, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
        esac
        case "$getpwnam_r_proto" in
        ''|0)   d_getpwnam_r=undef
@@ -14284,19 +14353,19 @@ case "$d_getpwuid_r" in
        define)
        case "$getpwuid_r_proto" in
        ''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int, struct passwd**);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0) try='struct passwd* getpwuid_r(uid_t, struct passwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
        esac
        case "$getpwuid_r_proto" in
        ''|0)   d_getpwuid_r=undef
@@ -14351,15 +14420,15 @@ case "$d_getservbyname_r" in
        define)
        case "$getservbyname_r_proto" in
        ''|0) try='int getservbyname_r(const char*, const char*, struct servent*, char*, size_t, struct servent**);'
-       ./protochk "extern $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
        esac
        case "$getservbyname_r_proto" in
        ''|0) try='struct servent* getservbyname_r(const char*, const char*, struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
        esac
        case "$getservbyname_r_proto" in
        ''|0) try='int getservbyname_r(const char*, const char*, struct servent*, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
        esac
        case "$getservbyname_r_proto" in
        ''|0)   d_getservbyname_r=undef
@@ -14400,15 +14469,15 @@ case "$d_getservbyport_r" in
        define)
        case "$getservbyport_r_proto" in
        ''|0) try='int getservbyport_r(int, const char*, struct servent*, char*, size_t, struct servent**);'
-       ./protochk "extern $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
        esac
        case "$getservbyport_r_proto" in
        ''|0) try='struct servent* getservbyport_r(int, const char*, struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
        esac
        case "$getservbyport_r_proto" in
        ''|0) try='int getservbyport_r(int, const char*, struct servent*, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
+       ./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
        esac
        case "$getservbyport_r_proto" in
        ''|0)   d_getservbyport_r=undef
@@ -14449,19 +14518,19 @@ case "$d_getservent_r" in
        define)
        case "$getservent_r_proto" in
        ''|0) try='int getservent_r(struct servent*, char*, size_t, struct servent**);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=I_SBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBWR ;;
        esac
        case "$getservent_r_proto" in
        ''|0) try='int getservent_r(struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=I_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBI ;;
        esac
        case "$getservent_r_proto" in
        ''|0) try='struct servent* getservent_r(struct servent*, char*, int);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=S_SBI ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=S_SBI ;;
        esac
        case "$getservent_r_proto" in
        ''|0) try='int getservent_r(struct servent*, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && getservent_r_proto=I_SD ;;
+       ./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SD ;;
        esac
        case "$getservent_r_proto" in
        ''|0)   d_getservent_r=undef
@@ -14515,11 +14584,11 @@ case "$d_getspnam_r" in
        define)
        case "$getspnam_r_proto" in
        ''|0) try='int getspnam_r(const char*, struct spwd*, char*, size_t, struct spwd**);'
-       ./protochk "extern $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
+       ./protochk "$extern_C $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
        esac
        case "$getspnam_r_proto" in
        ''|0) try='struct spwd* getspnam_r(const char*, struct spwd*, char*, int);'
-       ./protochk "extern $try" $hdrs && getspnam_r_proto=S_CSBI ;;
+       ./protochk "$extern_C $try" $hdrs && getspnam_r_proto=S_CSBI ;;
        esac
        case "$getspnam_r_proto" in
        ''|0)   d_getspnam_r=undef
@@ -14579,11 +14648,11 @@ case "$d_gmtime_r" in
        define)
        case "$gmtime_r_proto" in
        ''|0) try='struct tm* gmtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && gmtime_r_proto=S_TS ;;
+       ./protochk "$extern_C $try" $hdrs && gmtime_r_proto=S_TS ;;
        esac
        case "$gmtime_r_proto" in
        ''|0) try='int gmtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && gmtime_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && gmtime_r_proto=I_TS ;;
        esac
        case "$gmtime_r_proto" in
        ''|0)   d_gmtime_r=undef
@@ -14859,11 +14928,11 @@ case "$d_localtime_r" in
        define)
        case "$localtime_r_proto" in
        ''|0) try='struct tm* localtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && localtime_r_proto=S_TS ;;
+       ./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;;
        esac
        case "$localtime_r_proto" in
        ''|0) try='int localtime_r(const time_t*, struct tm*);'
-       ./protochk "extern $try" $hdrs && localtime_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;;
        esac
        case "$localtime_r_proto" in
        ''|0)   d_localtime_r=undef
@@ -14895,11 +14964,32 @@ REENTRANT_PROTO*)
 /*  Does our libc's localtime_r call tzset ?
  *  return 0 if so, 1 otherwise.
  */
-#include <sys/types.h>
-#include <unistd.h>
-#include <time.h>
-#include <string.h>
-#include <malloc.h>
+#$i_systypes   I_SYS_TYPES
+#$i_unistd     I_UNISTD
+#$i_time       I_TIME
+#$i_stdlib     I_STDLIB
+#$i_string     I_STRING
+#$i_malloc     I_MALLOC
+#ifdef I_SYS_TYPES
+#  include <sys/types.h>
+#endif
+#ifdef I_UNISTD
+#  include <unistd.h>
+#endif
+#ifdef I_TIME
+#  include <time.h>
+#endif
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#ifdef I_STRING
+#  include <string.h>
+#else
+#  include <strings.h>
+#endif
+#ifdef I_MALLOC
+#  include <malloc.h>
+#endif
 int main()
 {
     time_t t = time(0L);
@@ -15988,15 +16078,15 @@ case "$d_random_r" in
        define)
        case "$random_r_proto" in
        ''|0) try='int random_r(int*, struct random_data*);'
-       ./protochk "extern $try" $hdrs && random_r_proto=I_iS ;;
+       ./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;;
        esac
        case "$random_r_proto" in
        ''|0) try='int random_r(long*, struct random_data*);'
-       ./protochk "extern $try" $hdrs && random_r_proto=I_lS ;;
+       ./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;;
        esac
        case "$random_r_proto" in
        ''|0) try='int random_r(struct random_data*, int32_t*);'
-       ./protochk "extern $try" $hdrs && random_r_proto=I_St ;;
+       ./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;;
        esac
        case "$random_r_proto" in
        ''|0)   d_random_r=undef
@@ -16047,11 +16137,11 @@ case "$d_readdir64_r" in
        define)
        case "$readdir64_r_proto" in
        ''|0) try='int readdir64_r(DIR*, struct dirent64*, struct dirent64**);'
-       ./protochk "extern $try" $hdrs && readdir64_r_proto=I_TSR ;;
+       ./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TSR ;;
        esac
        case "$readdir64_r_proto" in
        ''|0) try='int readdir64_r(DIR*, struct dirent64*);'
-       ./protochk "extern $try" $hdrs && readdir64_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TS ;;
        esac
        case "$readdir64_r_proto" in
        ''|0)   d_readdir64_r=undef
@@ -16092,11 +16182,11 @@ case "$d_readdir_r" in
        define)
        case "$readdir_r_proto" in
        ''|0) try='int readdir_r(DIR*, struct dirent*, struct dirent**);'
-       ./protochk "extern $try" $hdrs && readdir_r_proto=I_TSR ;;
+       ./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TSR ;;
        esac
        case "$readdir_r_proto" in
        ''|0) try='int readdir_r(DIR*, struct dirent*);'
-       ./protochk "extern $try" $hdrs && readdir_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TS ;;
        esac
        case "$readdir_r_proto" in
        ''|0)   d_readdir_r=undef
@@ -16648,11 +16738,11 @@ case "$d_setgrent_r" in
        define)
        case "$setgrent_r_proto" in
        ''|0) try='int setgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setgrent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && setgrent_r_proto=I_H ;;
        esac
        case "$setgrent_r_proto" in
        ''|0) try='void setgrent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setgrent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && setgrent_r_proto=V_H ;;
        esac
        case "$setgrent_r_proto" in
        ''|0)   d_setgrent_r=undef
@@ -16697,11 +16787,11 @@ case "$d_sethostent_r" in
        define)
        case "$sethostent_r_proto" in
        ''|0) try='int sethostent_r(int, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && sethostent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && sethostent_r_proto=I_ID ;;
        esac
        case "$sethostent_r_proto" in
        ''|0) try='void sethostent_r(int, struct hostent_data*);'
-       ./protochk "extern $try" $hdrs && sethostent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && sethostent_r_proto=V_ID ;;
        esac
        case "$sethostent_r_proto" in
        ''|0)   d_sethostent_r=undef
@@ -16758,7 +16848,7 @@ case "$d_setlocale_r" in
        define)
        case "$setlocale_r_proto" in
        ''|0) try='int setlocale_r(int, const char*, char*, int);'
-       ./protochk "extern $try" $hdrs && setlocale_r_proto=I_ICBI ;;
+       ./protochk "$extern_C $try" $hdrs && setlocale_r_proto=I_ICBI ;;
        esac
        case "$setlocale_r_proto" in
        ''|0)   d_setlocale_r=undef
@@ -16803,11 +16893,11 @@ case "$d_setnetent_r" in
        define)
        case "$setnetent_r_proto" in
        ''|0) try='int setnetent_r(int, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && setnetent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setnetent_r_proto=I_ID ;;
        esac
        case "$setnetent_r_proto" in
        ''|0) try='void setnetent_r(int, struct netent_data*);'
-       ./protochk "extern $try" $hdrs && setnetent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setnetent_r_proto=V_ID ;;
        esac
        case "$setnetent_r_proto" in
        ''|0)   d_setnetent_r=undef
@@ -16868,11 +16958,11 @@ case "$d_setprotoent_r" in
        define)
        case "$setprotoent_r_proto" in
        ''|0) try='int setprotoent_r(int, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && setprotoent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=I_ID ;;
        esac
        case "$setprotoent_r_proto" in
        ''|0) try='void setprotoent_r(int, struct protoent_data*);'
-       ./protochk "extern $try" $hdrs && setprotoent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=V_ID ;;
        esac
        case "$setprotoent_r_proto" in
        ''|0)   d_setprotoent_r=undef
@@ -16917,11 +17007,11 @@ case "$d_setpwent_r" in
        define)
        case "$setpwent_r_proto" in
        ''|0) try='int setpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setpwent_r_proto=I_H ;;
+       ./protochk "$extern_C $try" $hdrs && setpwent_r_proto=I_H ;;
        esac
        case "$setpwent_r_proto" in
        ''|0) try='void setpwent_r(FILE**);'
-       ./protochk "extern $try" $hdrs && setpwent_r_proto=V_H ;;
+       ./protochk "$extern_C $try" $hdrs && setpwent_r_proto=V_H ;;
        esac
        case "$setpwent_r_proto" in
        ''|0)   d_setpwent_r=undef
@@ -16986,11 +17076,11 @@ case "$d_setservent_r" in
        define)
        case "$setservent_r_proto" in
        ''|0) try='int setservent_r(int, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && setservent_r_proto=I_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setservent_r_proto=I_ID ;;
        esac
        case "$setservent_r_proto" in
        ''|0) try='void setservent_r(int, struct servent_data*);'
-       ./protochk "extern $try" $hdrs && setservent_r_proto=V_ID ;;
+       ./protochk "$extern_C $try" $hdrs && setservent_r_proto=V_ID ;;
        esac
        case "$setservent_r_proto" in
        ''|0)   d_setservent_r=undef
@@ -17430,7 +17520,6 @@ int main(int argc, char **argv) {
 EOP
 set try
 
-d_sprintf_returns_strlen="$undef"
 if eval $compile; then
     xxx="`$run ./try`"
     case "$?" in
@@ -17445,6 +17534,9 @@ EOM
        d_sprintf_returns_strlen="$undef"
         ;;
     esac
+else
+    echo "(I can't seem to compile the test program--assuming it doesn't)" >&4
+    d_sprintf_returns_strlen="$undef"
 fi
 $rm_try
 
@@ -17464,7 +17556,7 @@ case "$d_srand48_r" in
        define)
        case "$srand48_r_proto" in
        ''|0) try='int srand48_r(long, struct drand48_data*);'
-       ./protochk "extern $try" $hdrs && srand48_r_proto=I_LS ;;
+       ./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;;
        esac
        case "$srand48_r_proto" in
        ''|0)   d_srand48_r=undef
@@ -17505,7 +17597,7 @@ case "$d_srandom_r" in
        define)
        case "$srandom_r_proto" in
        ''|0) try='int srandom_r(unsigned int, struct random_data*);'
-       ./protochk "extern $try" $hdrs && srandom_r_proto=I_TS ;;
+       ./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;;
        esac
        case "$srandom_r_proto" in
        ''|0)   d_srandom_r=undef
@@ -17706,15 +17798,15 @@ case "$d_strerror_r" in
        define)
        case "$strerror_r_proto" in
        ''|0) try='int strerror_r(int, char*, size_t);'
-       ./protochk "extern $try" $hdrs && strerror_r_proto=I_IBW ;;
+       ./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBW ;;
        esac
        case "$strerror_r_proto" in
        ''|0) try='int strerror_r(int, char*, int);'
-       ./protochk "extern $try" $hdrs && strerror_r_proto=I_IBI ;;
+       ./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBI ;;
        esac
        case "$strerror_r_proto" in
        ''|0) try='char* strerror_r(int, char*, size_t);'
-       ./protochk "extern $try" $hdrs && strerror_r_proto=B_IBW ;;
+       ./protochk "$extern_C $try" $hdrs && strerror_r_proto=B_IBW ;;
        esac
        case "$strerror_r_proto" in
        ''|0)   d_strerror_r=undef
@@ -18074,6 +18166,10 @@ if test "X$d_time" = X -o X"$timetype" = X; then
     eval $setvar
 fi
 
+: see if timegm exists
+set timegm d_timegm
+eval $inlibc
+
 : see if this is a sys/times.h system
 set sys/times.h i_systimes
 eval $inhdr
@@ -18112,7 +18208,7 @@ case "$d_tmpnam_r" in
        define)
        case "$tmpnam_r_proto" in
        ''|0) try='char* tmpnam_r(char*);'
-       ./protochk "extern $try" $hdrs && tmpnam_r_proto=B_B ;;
+       ./protochk "$extern_C $try" $hdrs && tmpnam_r_proto=B_B ;;
        esac
        case "$tmpnam_r_proto" in
        ''|0)   d_tmpnam_r=undef
@@ -18157,15 +18253,15 @@ case "$d_ttyname_r" in
        define)
        case "$ttyname_r_proto" in
        ''|0) try='int ttyname_r(int, char*, size_t);'
-       ./protochk "extern $try" $hdrs && ttyname_r_proto=I_IBW ;;
+       ./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBW ;;
        esac
        case "$ttyname_r_proto" in
        ''|0) try='int ttyname_r(int, char*, int);'
-       ./protochk "extern $try" $hdrs && ttyname_r_proto=I_IBI ;;
+       ./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBI ;;
        esac
        case "$ttyname_r_proto" in
        ''|0) try='char* ttyname_r(int, char*, int);'
-       ./protochk "extern $try" $hdrs && ttyname_r_proto=B_IBI ;;
+       ./protochk "$extern_C $try" $hdrs && ttyname_r_proto=B_IBI ;;
        esac
        case "$ttyname_r_proto" in
        ''|0)   d_ttyname_r=undef
@@ -19066,7 +19162,7 @@ EOM
                        fi
                fi
        fi
-       $rm_try
+       $rm -f core try.core core.try.*
        case "$fflushNULL" in
        x)      $cat >&4 <<EOM
 Your fflush(NULL) works okay for output streams.
@@ -19773,7 +19869,7 @@ EOM
                for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
                        for yyy in size_t long int; do
                                case "$netdb_host_type" in
-                               '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
+                               '')     try="$extern_C struct hostent *gethostbyaddr($xxx, $yyy, int);"
                                        if ./protochk "$try" $hdrs; then
                                                echo "Your system accepts $xxx for the first arg."
                                                echo "...and $yyy for the second arg."
@@ -19822,7 +19918,7 @@ EOM
                        $i_unistd unistd.h"
                for xxx in "const char *" "char *"; do
                        case "$netdb_name_type" in
-                       '')     try="extern struct hostent *gethostbyname($xxx);"
+                       '')     try="$extern_C struct hostent *gethostbyname($xxx);"
                                if ./protochk "$try" $hdrs; then
                                        echo "Your system accepts $xxx."
                                        netdb_name_type="$xxx"
@@ -19860,7 +19956,7 @@ EOM
                        $i_unistd unistd.h"
                for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
                        case "$netdb_net_type" in
-                       '')     try="extern struct netent *getnetbyaddr($xxx, int);"
+                       '')     try="$extern_C struct netent *getnetbyaddr($xxx, int);"
                                if ./protochk "$try" $hdrs; then
                                        echo "Your system accepts $xxx."
                                        netdb_net_type="$xxx"
@@ -19904,9 +20000,6 @@ case "$pager" in
        esac
        ;;
 *)     dflt="$pager"
-       : Instruct ./getfile to trust the hinted or previous pager value,
-       : even if it does not begin with a slash.  For example, on os2,
-       : pager might be cmd /c more.  See comments in UU/getfile.
        fn="f/($pager)"
        ;;
 esac
@@ -19975,6 +20068,176 @@ else
 fi
 $rm -f foo* bar*
 
+: see if this is a values.h system
+set values.h i_values
+eval $inhdr
+
+: Check the max offset that gmtime and localtime accept
+echo "Checking max offsets that gmtime () accepts"
+
+case $i_values in
+    define) yyy="#include <values.h>" ;;
+    *)      yyy="" ;;
+    esac
+
+case "$sGMTIME_min/$sGMTIME_max" in
+    0/0|/)
+       $cat >try.c <<EOCP
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+$yyy
+
+int i;
+struct tm *tmp;
+time_t pt;
+
+void gm_check (time_t t, int min_year, int max_year)
+{
+    tmp = gmtime (&t);
+    if ( tmp == NULL ||
+       /* Check tm_year overflow */
+        tmp->tm_year < min_year || tmp->tm_year > max_year)
+       tmp = NULL;
+    else
+       pt = t;
+    } /* gm_check */
+
+int check_max ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MAXLONG
+    gm_check (MAXLONG, 69, 0x7fffffff);
+#endif
+    if (tmp == NULL || tmp->tm_year < 0) {
+       for (i = 63; i >= 0; i--) {
+           time_t x = pt | ((time_t)1 << i);
+           if (x < 0 || x < pt) continue;
+           gm_check (x, 69, 0x7fffffff);
+           }
+       }
+    printf ("sGMTIME_max=%ld\n", pt);
+    return (0);
+    } /* check_max */
+
+int check_min ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MINLONG
+    gm_check (MINLONG, -1900, 70);
+#endif
+    if (tmp == NULL) {
+       for (i = 36; i >= 0; i--) {
+           time_t x = pt - ((time_t)1 << i);
+           if (x > 0) continue;
+           gm_check (x, -1900, 70);
+           }
+       }
+    printf ("sGMTIME_min=%ld\n", pt);
+    return (0);
+    } /* check_min */
+
+int main (int argc, char *argv[])
+{
+    fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t));
+    check_max ();
+    check_min ();
+    return (0);
+    } /* main */
+EOCP
+       set try
+       if eval $compile; then
+           eval `$run ./try`
+       else
+           echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
+           fi
+       $rm_try
+       ;;
+    esac
+
+echo "Checking max offsets that localtime () accepts"
+
+case "$sLOCALTIME_min/$sLOCALTIME_max" in
+    0/0|/)
+       $cat >try.c <<EOCP
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+$yyy
+
+int i;
+struct tm *tmp;
+time_t pt;
+
+void local_check (time_t t, int min_year, int max_year)
+{
+    if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
+       tmp = NULL;
+    else
+       tmp = localtime (&t);
+    if ( tmp == NULL ||
+       /* Check tm_year overflow */
+        tmp->tm_year < min_year || tmp->tm_year > max_year)
+       tmp = NULL;
+    else
+       pt = t;
+    } /* local_check */
+
+int check_max ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MAXLONG
+    local_check (MAXLONG, 69, 0x7fffffff);
+#endif
+    if (tmp == NULL || tmp->tm_year < 0) {
+       for (i = 63; i >= 0; i--) {
+           time_t x = pt | ((time_t)1 << i);
+           if (x < 0 || x < pt) continue;
+           local_check (x, 69, 0x7fffffff);
+           }
+       }
+    printf ("sLOCALTIME_max=%ld\n", pt);
+    return (0);
+   } /* check_max */
+
+int check_min ()
+{
+    tmp = NULL;
+    pt  = 0;
+#ifdef MINLONG
+    local_check (MINLONG, -1900, 70);
+#endif
+    if (tmp == NULL) {
+       for (i = 36; i >= 0; i--) {
+           time_t x = pt - ((time_t)1 << i);
+           if (x > 0) continue;
+           local_check (x, -1900, 70);
+           }
+       }
+    printf ("sLOCALTIME_min=%ld\n", pt);
+    return (0);
+    } /* check_min */
+
+int main (int argc, char *argv[])
+{
+    check_max ();
+    check_min ();
+    return (0);
+    } /* main */
+EOCP
+       set try
+       if eval $compile; then
+           eval `$run ./try`
+       else
+           echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
+           fi
+       $rm_try
+       ;;
+    esac
+
 : check for type of arguments to select.
 case "$selecttype" in
 '') case "$d_select" in
@@ -19996,7 +20259,7 @@ EOM
                        for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
                                for tmo in 'struct timeval *' 'const struct timeval *'; do
                                        case "$val" in
-                                       '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
+                                       '')     try="$extern_C select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
                                                if ./protochk "$try" $hdrs; then
                                                        echo "Your system accepts $xxx."
                                                        val="$xxx"
@@ -20477,7 +20740,7 @@ EOM
        yyy="$yyy $sizetype int long unsigned"
        for xxx in $yyy; do
                case "$socksizetype" in
-               '')     try="extern int accept(int, struct sockaddr *, $xxx *);"
+               '')     try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
                        case "$usesocks" in
                        "$define")
                                if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
@@ -20555,8 +20818,7 @@ $rm_try
 
 : see what type of char stdio uses.
 echo " "
-echo '#include <stdio.h>' > stdio.c
-$cppstdin $cppminus < stdio.c > stdioh
+echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
 if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
        echo "Your stdio uses unsigned chars." >&4
        stdchar="unsigned char"
@@ -20564,7 +20826,7 @@ else
        echo "Your stdio uses signed chars." >&4
        stdchar="char"
 fi
-$rm -f stdio.* stdioh
+$rm -f stdioh
 
 : see what type uids are declared as in the kernel
 echo " "
@@ -20775,6 +21037,35 @@ val="$t_gdbm"
 set i_gdbm
 eval $setvar
 
+: see if ndbm.h is available
+set ndbm.h i_ndbm
+eval $inhdr
+: Compatibility location for RedHat 7.1
+set gdbm/ndbm.h i_gdbmndbm
+eval $inhdr
+: Compatibility location for Debian 4.0
+set gdbm-ndbm.h i_gdbm_ndbm
+eval $inhdr
+
+if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then
+       : see if dbm_open exists
+       set dbm_open d_dbm_open
+       eval $inlibc
+       case "$d_dbm_open" in
+       $undef)
+               i_ndbm="$undef"
+               i_gdbmndbm="$undef"
+               i_gdbm_ndbm="$undef"
+               echo "We won't be including <ndbm.h>"
+           val="$undef"
+               ;;
+       *) val="$define"
+          ;;
+       esac
+fi
+set d_ndbm
+eval $setvar
+
 : see if this is a ieeefp.h system
 case "$i_ieeefp" in
 '' ) set ieeefp.h i_ieeefp
 set mntent.h i_mntent
 eval $inhdr
 
-: see if ndbm.h is available
-set ndbm.h t_ndbm
-eval $inhdr
-
-case "$t_ndbm" in
-$undef)
-    # Some Linux distributions such as RedHat 7.1 put the
-    # ndbm.h header in /usr/include/gdbm/ndbm.h.
-    if $test -f /usr/include/gdbm/ndbm.h; then
-       echo '<gdbm/ndbm.h> found.'
-        ccflags="$ccflags -I/usr/include/gdbm"
-        cppflags="$cppflags -I/usr/include/gdbm"
-        t_ndbm=$define
-    fi
-    ;;
-esac
-
-case "$t_ndbm" in
-$define)
-       : see if dbm_open exists
-       set dbm_open d_dbm_open
-       eval $inlibc
-       case "$d_dbm_open" in
-       $undef)
-               t_ndbm="$undef"
-               echo "We won't be including <ndbm.h>"
-               ;;
-       esac
-       ;;
-esac
-val="$t_ndbm"
-set i_ndbm
-eval $setvar
-
 : see if net/errno.h is available
 val=''
 set net/errno.h val
@@ -21243,10 +21500,6 @@ eval $inhdr
 set utime.h i_utime
 eval $inhdr
 
-: see if this is a values.h system
-set values.h i_values
-eval $inhdr
-
 : see if this is a vfork system
 case "$d_vfork" in
 "$define")
@@ -21655,7 +21908,7 @@ sunos*X4*)
     ;;
 *) case "$usedl" in
     $define|true|[yY]*)
-           set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'` 
+           set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'` 
            shift
            perllibs="$*"
            ;;
@@ -21836,6 +22089,7 @@ d_accessx='$d_accessx'
 d_aintl='$d_aintl'
 d_alarm='$d_alarm'
 d_archlib='$d_archlib'
+d_asctime64='$d_asctime64'
 d_asctime_r='$d_asctime_r'
 d_atolf='$d_atolf'
 d_atoll='$d_atoll'
@@ -21873,10 +22127,12 @@ d_crypt_r='$d_crypt_r'
 d_csh='$d_csh'
 d_ctermid='$d_ctermid'
 d_ctermid_r='$d_ctermid_r'
+d_ctime64='$d_ctime64'
 d_ctime_r='$d_ctime_r'
 d_cuserid='$d_cuserid'
 d_dbl_dig='$d_dbl_dig'
 d_dbminitproto='$d_dbminitproto'
+d_difftime64='$d_difftime64'
 d_difftime='$d_difftime'
 d_dir_dd_fd='$d_dir_dd_fd'
 d_dirfd='$d_dirfd'
@@ -21991,6 +22247,7 @@ d_getservprotos='$d_getservprotos'
 d_getspnam='$d_getspnam'
 d_getspnam_r='$d_getspnam_r'
 d_gettimeod='$d_gettimeod'
+d_gmtime64='$d_gmtime64'
 d_gmtime_r='$d_gmtime_r'
 d_gnulibc='$d_gnulibc'
 d_grpasswd='$d_grpasswd'
@@ -22011,6 +22268,7 @@ d_lchown='$d_lchown'
 d_ldbl_dig='$d_ldbl_dig'
 d_libm_lib_version='$d_libm_lib_version'
 d_link='$d_link'
+d_localtime64='$d_localtime64'
 d_localtime_r='$d_localtime_r'
 d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
 d_locconv='$d_locconv'
@@ -22035,6 +22293,7 @@ d_mkdtemp='$d_mkdtemp'
 d_mkfifo='$d_mkfifo'
 d_mkstemp='$d_mkstemp'
 d_mkstemps='$d_mkstemps'
+d_mktime64='$d_mktime64'
 d_mktime='$d_mktime'
 d_mmap='$d_mmap'
 d_modfl='$d_modfl'
@@ -22055,6 +22314,7 @@ d_msgsnd='$d_msgsnd'
 d_msync='$d_msync'
 d_munmap='$d_munmap'
 d_mymalloc='$d_mymalloc'
+d_ndbm='$d_ndbm'
 d_nice='$d_nice'
 d_nl_langinfo='$d_nl_langinfo'
 d_nv_preserves_uv='$d_nv_preserves_uv'
@@ -22212,6 +22472,7 @@ d_tcsetpgrp='$d_tcsetpgrp'
 d_telldir='$d_telldir'
 d_telldirproto='$d_telldirproto'
 d_time='$d_time'
+d_timegm='$d_timegm'
 d_times='$d_times'
 d_tm_tm_gmtoff='$d_tm_tm_gmtoff'
 d_tm_tm_zone='$d_tm_tm_zone'
@@ -22276,6 +22537,7 @@ eunicefix='$eunicefix'
 exe_ext='$exe_ext'
 expr='$expr'
 extensions='$extensions'
+extern_C='$extern_C'
 extras='$extras'
 fflushNULL='$fflushNULL'
 fflushall='$fflushall'
@@ -22354,6 +22616,8 @@ i_float='$i_float'
 i_fp='$i_fp'
 i_fp_class='$i_fp_class'
 i_gdbm='$i_gdbm'
+i_gdbm_ndbm='$i_gdbm_ndbm'
+i_gdbmndbm='$i_gdbmndbm'
 i_grp='$i_grp'
 i_ieeefp='$i_ieeefp'
 i_inttypes='$i_inttypes'
@@ -22597,6 +22861,10 @@ rm_try='$rm_try'
 rmail='$rmail'
 run='$run'
 runnm='$runnm'
+sGMTIME_max='$sGMTIME_max'
+sGMTIME_min='$sGMTIME_min'
+sLOCALTIME_max='$sLOCALTIME_max'
+sLOCALTIME_min='$sLOCALTIME_min'
 sPRIEUldbl='$sPRIEUldbl'
 sPRIFUldbl='$sPRIFUldbl'
 sPRIGUldbl='$sPRIGUldbl'