xref: /openbsd-src/gnu/usr.bin/perl/Configure (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1#! /bin/sh
2#
3# If these # comments don't work, trim them. Don't worry about any other
4# shell scripts, Configure will trim # comments from them for you.
5#
6# (If you are trying to port this package to a machine without sh,
7# I would suggest you have a look at the prototypical config_h.SH file
8# and edit it to reflect your system. Some packages may include samples
9# of config.h for certain machines, so you might look for one of those.)
10#
11# Yes, you may rip this off to use in other distribution packages. This
12# script belongs to the public domain and cannot be copyrighted.
13#
14# Note: this Configure script was generated automatically. Rather than
15# working with this copy of Configure, you may wish to get metaconfig.
16# The dist package (which contains metaconfig) is available via SVN:
17#     svn co https://svn.code.sf.net/p/dist/code/trunk/dist
18#
19# Though this script was generated by metaconfig from metaunits, it is
20# OK to send patches against Configure itself. It's up to the Configure
21# pumpkin to backport the patch to the metaunits if it is accepted.
22# For more information on patching Configure, see pod/perlhack.pod
23#
24# The metaunits are also available from the public git repository:
25#     http://perl5.git.perl.org/metaconfig.git/ or
26#     $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
27#
28# See Porting/pumpkin.pod for more information on metaconfig.
29#
30
31# Generated on Wed Jun  4 08:58:13 CEST 2014 [metaconfig 3.5 PL0]
32# (with additional metaconfig patches by perlbug@perl.org)
33
34cat >c1$$ <<EOF
35ARGGGHHHH!!!!!
36
37SCO csh still thinks true is false.  Write to SCO today and tell them that next
38year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
39
40(Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
41we'd have to do is go in and swap the && and || tokens, wherever they are.)
42
43[End of diatribe. We now return you to your regularly scheduled programming...]
44EOF
45cat >c2$$ <<EOF
46
47OOPS!  You naughty creature!  You didn't run Configure with sh!
48I will attempt to remedy the situation by running sh for you...
49EOF
50
51true || cat c1$$ c2$$
52true || exec sh $0 $argv:q
53
54(exit $?0) || cat c2$$
55(exit $?0) || exec sh $0 $argv:q
56rm -f c1$$ c2$$
57
58if test -f /dev/cputype -a -f /dev/drivers -a -f /dev/osversion; then
59	cat <<EOF
60***
61*** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
62*** Configure that well.  (Plan 9 is close to UNIX but not close enough.)
63*** Please read the README.plan9 for further instructions.
64*** Cannot continue, aborting.
65***
66EOF
67	exit 1
68fi
69
70if test ! -c /dev/null ; then
71	cat <<EOF
72***
73*** I'm sorry, but /dev/null appears to be a file rather than a device.
74*** Please consult your operating sytem's notes for making a device
75*** in /dev.
76*** Cannot continue, aborting.
77***
78EOF
79	exit 1
80fi
81
82: compute my invocation name
83me=$0
84case "$0" in
85*/*)
86	me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
87	test "$me" || me=$0
88	;;
89esac
90
91: Proper separator for the PATH environment variable
92p_=:
93: On OS/2 this directory should exist if this is not floppy only system ":-]"
94if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' 2>&1 ) 2>&1 >/dev/null ; then
95	if test -n "$OS2_SHELL"; then
96		p_=\;
97		PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
98		OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
99		is_os2=yes
100	elif test -n "$DJGPP"; then
101		case "X${MACHTYPE:-nonesuchmach}" in
102		*cygwin|*msys) ;;
103		*) p_=\; ;;
104		esac
105	fi
106fi
107
108: Proper PATH setting
109paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
110paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
111paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
112paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
113paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
114paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /opt/ansic/bin /usr/ccs/bin"
115paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
116paths="$paths /sbin /usr/sbin /usr/libexec"
117paths="$paths /system/gnu_library/bin"
118
119for p in $paths
120do
121	case "$p_$PATH$p_" in
122	*$p_$p$p_*) ;;
123	*) test -d $p && PATH=$PATH$p_$p ;;
124	esac
125done
126
127PATH=.$p_$PATH
128export PATH
129
130: shall we be using ksh?
131inksh=''
132needksh=''
133avoidksh=''
134newsh=/bin/ksh
135changesh=''
136if (PATH=.; alias -x) >/dev/null 2>&1; then
137		inksh=true
138fi
139if test -f /hp-ux -a -f /bin/ksh; then
140	needksh='to avoid sh bug in "here document" expansion'
141fi
142if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
143	if test X`/usr/bin/uname -v` = X4; then
144		avoidksh="to avoid AIX 4's /bin/sh"
145		newsh=/usr/bin/bsh
146	fi
147fi
148if test -f /osf_boot -a -f /usr/sbin/setld; then
149	if test X`/usr/bin/uname -s` = XOSF1; then
150		avoidksh="to avoid Digital UNIX' ksh"
151		newsh=/bin/sh
152		unset BIN_SH
153	fi
154fi
155case "$inksh/$needksh" in
156/[a-z]*)
157		ENV=''
158		changesh=true
159		reason="$needksh"
160	;;
161esac
162case "$inksh/$avoidksh" in
163true/[a-z]*)
164	changesh=true
165	reason="$avoidksh"
166	;;
167esac
168case "$inksh/$needksh-$avoidksh-" in
169true/--)
170		cat <<EOM
171(I see you are using the Korn shell.  Some ksh's blow up on $me,
172mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
173EOM
174	;;
175esac
176case "$changesh" in
177true)
178	export newsh
179	echo "(Feeding myself to $newsh $reason.)"
180	case "$0" in
181	Configure|*/Configure) exec $newsh $0 "$@";;
182	*) exec $newsh Configure "$@";;
183	esac
184	;;
185esac
186test -x "${newsh}" || unset newsh
187
188: if needed, set CDPATH to a harmless value that is not chatty
189: avoid bash 2.02 problems with empty CDPATH.
190case "$CDPATH" in
191'')	;;
192*)	case "$SHELL" in
193	*bash*) CDPATH='.' ;;
194	*) CDPATH='' ;;
195	esac
196	;;
197esac
198
199: Configure runs within the UU subdirectory
200test -d UU || mkdir UU
201cd UU && rm -f ./*
202
203ccname=''
204ccversion=''
205ccsymbols=''
206cppccsymbols=''
207cppsymbols=''
208from=''
209hostgenerate=''
210hostosname=''
211hostperl=''
212run=''
213targetarch=''
214targetdir=''
215targetenv=''
216targethost=''
217targetmkdir=''
218targetport=''
219to=''
220usecrosscompile=''
221extern_C=''
222mistrustnm=''
223usedevel=''
224perllibs=''
225dynamic_ext=''
226extensions=''
227known_extensions=''
228nonxs_ext=''
229static_ext=''
230useopcode=''
231useposix=''
232extras=''
233d_bsd=''
234d_eunice=''
235d_xenix=''
236eunicefix=''
237ar=''
238awk=''
239bash=''
240bison=''
241byacc=''
242cat=''
243chgrp=''
244chmod=''
245chown=''
246comm=''
247compress=''
248cp=''
249cpio=''
250cpp=''
251csh=''
252date=''
253echo=''
254egrep=''
255emacs=''
256expr=''
257find=''
258flex=''
259gmake=''
260grep=''
261gzip=''
262inews=''
263ksh=''
264less=''
265line=''
266lint=''
267ln=''
268lp=''
269lpr=''
270ls=''
271mail=''
272mailx=''
273make=''
274mkdir=''
275more=''
276mv=''
277nm=''
278nroff=''
279perl=''
280pg=''
281pmake=''
282pr=''
283rm=''
284rmail=''
285sed=''
286sendmail=''
287shar=''
288sleep=''
289smail=''
290sort=''
291submit=''
292tail=''
293tar=''
294tbl=''
295tee=''
296test=''
297touch=''
298tr=''
299troff=''
300uname=''
301uniq=''
302uuname=''
303vi=''
304zcat=''
305zip=''
306full_ar=''
307full_sed=''
308libswanted=''
309hint=''
310myuname=''
311osname=''
312osvers=''
313Author=''
314Date=''
315Header=''
316Id=''
317Locker=''
318Log=''
319RCSfile=''
320Revision=''
321Source=''
322State=''
323sysroot=''
324_a=''
325_exe=''
326_o=''
327archobjs=''
328exe_ext=''
329firstmakefile=''
330lib_ext=''
331obj_ext=''
332path_sep=''
333rm_try=''
334afs=''
335afsroot=''
336alignbytes=''
337ansi2knr=''
338archlib=''
339archlibexp=''
340d_archlib=''
341installarchlib=''
342archname=''
343myarchname=''
344useversionedarchname=''
345d_atolf=''
346d_atoll=''
347baserev=''
348bin=''
349binexp=''
350initialinstalllocation=''
351installbin=''
352userelocatableinc=''
353byteorder=''
354cc=''
355ccflags=''
356cppflags=''
357ldflags=''
358lkflags=''
359locincpth=''
360optimize=''
361cf_email=''
362cf_by=''
363cf_time=''
364charbits=''
365charsize=''
366contains=''
367cpp_stuff=''
368cpplast=''
369cppminus=''
370cpprun=''
371cppstdin=''
372d__fwalk=''
373d_access=''
374d_accessx=''
375d_aintl=''
376d_alarm=''
377asctime_r_proto=''
378d_asctime_r=''
379d_attribute_deprecated=''
380d_attribute_format=''
381d_attribute_malloc=''
382d_attribute_nonnull=''
383d_attribute_noreturn=''
384d_attribute_pure=''
385d_attribute_unused=''
386d_attribute_warn_unused_result=''
387d_printf_format_null=''
388d_bcmp=''
389d_bcopy=''
390d_builtin_choose_expr=''
391d_builtin_expect=''
392d_bzero=''
393d_c99_variadic_macros=''
394d_casti32=''
395castflags=''
396d_castneg=''
397d_chown=''
398d_chroot=''
399d_chsize=''
400d_class=''
401d_clearenv=''
402d_closedir=''
403d_void_closedir=''
404d_cmsghdr_s=''
405d_const=''
406d_copysignl=''
407d_cplusplus=''
408cryptlib=''
409d_crypt=''
410crypt_r_proto=''
411d_crypt_r=''
412d_csh=''
413full_csh=''
414d_ctermid=''
415ctermid_r_proto=''
416d_ctermid_r=''
417ctime_r_proto=''
418d_ctime_r=''
419d_cuserid=''
420d_dbl_dig=''
421d_dbminitproto=''
422d_difftime=''
423d_dir_dd_fd=''
424d_dirfd=''
425d_dlerror=''
426d_dlopen=''
427d_dlsymun=''
428d_dosuid=''
429d_suidsafe=''
430d_drand48_r=''
431drand48_r_proto=''
432d_drand48proto=''
433d_dup2=''
434d_eaccess=''
435d_endgrent=''
436d_endgrent_r=''
437endgrent_r_proto=''
438d_endhent=''
439d_endhostent_r=''
440endhostent_r_proto=''
441d_endnent=''
442d_endnetent_r=''
443endnetent_r_proto=''
444d_endpent=''
445d_endprotoent_r=''
446endprotoent_r_proto=''
447d_endpwent=''
448d_endpwent_r=''
449endpwent_r_proto=''
450d_endsent=''
451d_endservent_r=''
452endservent_r_proto=''
453d_faststdio=''
454d_fchdir=''
455d_fchmod=''
456d_fchown=''
457d_fcntl=''
458d_fcntl_can_lock=''
459d_fd_macros=''
460d_fd_set=''
461d_fds_bits=''
462d_fgetpos=''
463d_finite=''
464d_finitel=''
465d_flexfnam=''
466d_flock=''
467d_flockproto=''
468d_fork=''
469d_fp_class=''
470d_fpclass=''
471d_fpclassify=''
472d_fpclassl=''
473d_fpos64_t=''
474d_frexpl=''
475d_fs_data_s=''
476d_fseeko=''
477d_fsetpos=''
478d_fstatfs=''
479d_fsync=''
480d_ftello=''
481d_ftime=''
482d_gettimeod=''
483d_futimes=''
484d_Gconvert=''
485d_getaddrinfo=''
486d_getcwd=''
487d_getespwnam=''
488d_getfsstat=''
489d_getgrent=''
490d_getgrent_r=''
491getgrent_r_proto=''
492d_getgrgid_r=''
493getgrgid_r_proto=''
494d_getgrnam_r=''
495getgrnam_r_proto=''
496d_getgrps=''
497d_gethbyaddr=''
498d_gethbyname=''
499d_gethent=''
500aphostname=''
501d_gethname=''
502d_phostname=''
503d_uname=''
504d_gethostbyaddr_r=''
505gethostbyaddr_r_proto=''
506d_gethostbyname_r=''
507gethostbyname_r_proto=''
508d_gethostent_r=''
509gethostent_r_proto=''
510d_gethostprotos=''
511d_getitimer=''
512d_getlogin=''
513d_getlogin_r=''
514getlogin_r_proto=''
515d_getmnt=''
516d_getmntent=''
517d_getnameinfo=''
518d_getnbyaddr=''
519d_getnbyname=''
520d_getnent=''
521d_getnetbyaddr_r=''
522getnetbyaddr_r_proto=''
523d_getnetbyname_r=''
524getnetbyname_r_proto=''
525d_getnetent_r=''
526getnetent_r_proto=''
527d_getnetprotos=''
528d_getpagsz=''
529d_getpent=''
530d_getpgid=''
531d_getpgrp2=''
532d_bsdgetpgrp=''
533d_getpgrp=''
534d_getppid=''
535d_getprior=''
536d_getpbyname=''
537d_getpbynumber=''
538d_getprotobyname_r=''
539getprotobyname_r_proto=''
540d_getprotobynumber_r=''
541getprotobynumber_r_proto=''
542d_getprotoent_r=''
543getprotoent_r_proto=''
544d_getprotoprotos=''
545d_getprpwnam=''
546d_getpwent=''
547d_getpwent_r=''
548getpwent_r_proto=''
549d_getpwnam_r=''
550getpwnam_r_proto=''
551d_getpwuid_r=''
552getpwuid_r_proto=''
553d_getsent=''
554d_getservbyname_r=''
555getservbyname_r_proto=''
556d_getservbyport_r=''
557getservbyport_r_proto=''
558d_getservent_r=''
559getservent_r_proto=''
560d_getservprotos=''
561d_getspnam=''
562d_getspnam_r=''
563getspnam_r_proto=''
564d_getsbyname=''
565d_getsbyport=''
566d_gmtime_r=''
567gmtime_r_proto=''
568d_gnulibc=''
569gnulibc_version=''
570d_hasmntopt=''
571d_htonl=''
572d_ilogbl=''
573d_inetaton=''
574d_inetntop=''
575d_inetpton=''
576d_int64_t=''
577d_isascii=''
578d_isblank=''
579d_isfinite=''
580d_isinf=''
581d_isnan=''
582d_isnanl=''
583d_killpg=''
584d_lchown=''
585d_ldbl_dig=''
586d_libm_lib_version=''
587d_link=''
588d_localtime_r=''
589d_localtime_r_needs_tzset=''
590localtime_r_proto=''
591d_locconv=''
592d_lc_monetary_2008=''
593d_lockf=''
594d_longdbl=''
595longdblsize=''
596d_longlong=''
597longlongsize=''
598d_lseekproto=''
599d_lstat=''
600d_madvise=''
601d_malloc_good_size=''
602d_malloc_size=''
603d_mblen=''
604d_mbstowcs=''
605d_mbtowc=''
606d_memchr=''
607d_memcmp=''
608d_memcpy=''
609d_memmove=''
610d_memset=''
611d_mkdir=''
612d_mkdtemp=''
613d_mkfifo=''
614d_mkstemp=''
615d_mkstemps=''
616d_mktime=''
617d_mmap=''
618mmaptype=''
619d_modfl=''
620d_modfl_pow32_bug=''
621d_modflproto=''
622d_mprotect=''
623d_msg=''
624d_msgctl=''
625d_msgget=''
626d_msghdr_s=''
627d_msgrcv=''
628d_msgsnd=''
629d_msync=''
630d_munmap=''
631d_nice=''
632d_nl_langinfo=''
633d_off64_t=''
634d_open3=''
635d_fpathconf=''
636d_pathconf=''
637d_pause=''
638d_pipe=''
639d_poll=''
640d_portable=''
641d_prctl=''
642d_prctl_set_name=''
643d_procselfexe=''
644procselfexe=''
645d_old_pthread_create_joinable=''
646old_pthread_create_joinable=''
647d_pthread_atfork=''
648d_pthread_attr_setscope=''
649d_pthread_yield=''
650d_sched_yield=''
651sched_yield=''
652d_qgcvt=''
653d_random_r=''
654random_r_proto=''
655d_readdir64_r=''
656readdir64_r_proto=''
657d_readdir=''
658d_rewinddir=''
659d_seekdir=''
660d_telldir=''
661d_readdir_r=''
662readdir_r_proto=''
663d_readlink=''
664d_readv=''
665d_recvmsg=''
666d_rename=''
667d_rmdir=''
668d_safebcpy=''
669d_safemcpy=''
670d_sanemcmp=''
671d_sbrkproto=''
672d_scalbnl=''
673d_select=''
674d_sem=''
675d_semctl=''
676d_semget=''
677d_semop=''
678d_sendmsg=''
679d_setegid=''
680d_seteuid=''
681d_setgrent=''
682d_setgrent_r=''
683setgrent_r_proto=''
684d_setgrps=''
685d_sethent=''
686d_sethostent_r=''
687sethostent_r_proto=''
688d_setitimer=''
689d_setlinebuf=''
690d_setlocale=''
691d_setlocale_r=''
692setlocale_r_proto=''
693d_setnent=''
694d_setnetent_r=''
695setnetent_r_proto=''
696d_setpent=''
697d_setpgid=''
698d_setpgrp2=''
699d_bsdsetpgrp=''
700d_setpgrp=''
701d_setprior=''
702d_setproctitle=''
703d_setprotoent_r=''
704setprotoent_r_proto=''
705d_setpwent=''
706d_setpwent_r=''
707setpwent_r_proto=''
708d_setregid=''
709d_setresgid=''
710d_setresuid=''
711d_setreuid=''
712d_setrgid=''
713d_setruid=''
714d_setsent=''
715d_setservent_r=''
716setservent_r_proto=''
717d_setsid=''
718d_setvbuf=''
719d_shm=''
720d_shmat=''
721d_shmatprototype=''
722shmattype=''
723d_shmctl=''
724d_shmdt=''
725d_shmget=''
726d_sigaction=''
727d_signbit=''
728d_sigprocmask=''
729d_sigsetjmp=''
730usesitecustomize=''
731d_snprintf=''
732d_vsnprintf=''
733d_sockatmark=''
734d_sockatmarkproto=''
735d_ip_mreq=''
736d_ip_mreq_source=''
737d_ipv6_mreq=''
738d_ipv6_mreq_source=''
739d_msg_ctrunc=''
740d_msg_dontroute=''
741d_msg_oob=''
742d_msg_peek=''
743d_msg_proxy=''
744d_oldsock=''
745d_scm_rights=''
746d_sin6_scope_id=''
747d_sockaddr_in6=''
748d_sockaddr_sa_len=''
749d_socket=''
750d_sockpair=''
751sockethdr=''
752socketlib=''
753d_socklen_t=''
754d_socks5_init=''
755d_sprintf_returns_strlen=''
756d_sqrtl=''
757d_srand48_r=''
758srand48_r_proto=''
759d_srandom_r=''
760srandom_r_proto=''
761d_sresgproto=''
762d_sresuproto=''
763d_statblks=''
764d_statfs_f_flags=''
765d_statfs_s=''
766d_static_inline=''
767perl_static_inline=''
768d_fstatvfs=''
769d_statvfs=''
770d_stdio_cnt_lval=''
771d_stdio_ptr_lval=''
772d_stdio_ptr_lval_nochange_cnt=''
773d_stdio_ptr_lval_sets_cnt=''
774d_stdiobase=''
775d_stdstdio=''
776stdio_base=''
777stdio_bufsiz=''
778stdio_cnt=''
779stdio_filbuf=''
780stdio_ptr=''
781d_index=''
782d_strchr=''
783d_strcoll=''
784d_strctcpy=''
785d_strerrm=''
786d_strerror=''
787d_sysernlst=''
788d_syserrlst=''
789d_strerror_r=''
790strerror_r_proto=''
791d_strftime=''
792d_strlcat=''
793d_strlcpy=''
794d_strtod=''
795d_strtol=''
796d_strtold=''
797d_strtoll=''
798d_strtoq=''
799d_strtoul=''
800d_strtoull=''
801d_strtouq=''
802d_strxfrm=''
803d_symlink=''
804d_syscall=''
805d_syscallproto=''
806d_sysconf=''
807d_system=''
808d_tcgetpgrp=''
809d_tcsetpgrp=''
810d_telldirproto=''
811d_time=''
812timetype=''
813d_asctime64=''
814d_ctime64=''
815d_difftime64=''
816d_gmtime64=''
817d_localtime64=''
818d_mktime64=''
819d_timegm=''
820clocktype=''
821d_times=''
822d_tmpnam_r=''
823tmpnam_r_proto=''
824d_truncate=''
825d_ttyname_r=''
826ttyname_r_proto=''
827d_tzname=''
828d_u32align=''
829d_ualarm=''
830d_umask=''
831d_semctl_semid_ds=''
832d_semctl_semun=''
833d_union_semun=''
834d_unordered=''
835d_unsetenv=''
836d_usleep=''
837d_usleepproto=''
838d_ustat=''
839d_pseudofork=''
840d_vfork=''
841usevfork=''
842d_voidsig=''
843signal_t=''
844d_volatile=''
845d_charvspr=''
846d_vprintf=''
847d_wait4=''
848d_waitpid=''
849d_wcstombs=''
850d_wctomb=''
851d_writev=''
852dlext=''
853bin_ELF=''
854cccdlflags=''
855ccdlflags=''
856dlsrc=''
857ld=''
858ld_can_script=''
859lddlflags=''
860usedl=''
861doublesize=''
862bootstrap_charset=''
863ebcdic=''
864fflushNULL=''
865fflushall=''
866fpossize=''
867fpostype=''
868gccansipedantic=''
869gccosandvers=''
870gccversion=''
871gidformat=''
872gidsign=''
873gidsize=''
874gidtype=''
875groupstype=''
876h_fcntl=''
877h_sysfile=''
878html1dir=''
879html1direxp=''
880installhtml1dir=''
881html3dir=''
882html3direxp=''
883installhtml3dir=''
884i_arpainet=''
885i_assert=''
886i_crypt=''
887db_hashtype=''
888db_prefixtype=''
889db_version_major=''
890db_version_minor=''
891db_version_patch=''
892i_db=''
893i_dbm=''
894i_rpcsvcdbm=''
895d_dirnamlen=''
896direntrytype=''
897i_dirent=''
898i_dlfcn=''
899i_fcntl=''
900i_float=''
901i_fp=''
902i_fp_class=''
903i_gdbm=''
904d_grpasswd=''
905i_grp=''
906i_ieeefp=''
907i_inttypes=''
908i_langinfo=''
909i_libutil=''
910i_limits=''
911i_locale=''
912i_machcthr=''
913i_malloc=''
914i_mallocmalloc=''
915i_math=''
916i_memory=''
917i_mntent=''
918d_gdbm_ndbm_h_uses_prototypes=''
919d_gdbmndbm_h_uses_prototypes=''
920d_ndbm=''
921d_ndbm_h_uses_prototypes=''
922i_gdbm_ndbm=''
923i_gdbmndbm=''
924i_ndbm=''
925i_netdb=''
926i_neterrno=''
927i_netinettcp=''
928i_niin=''
929i_sysin=''
930i_poll=''
931i_prot=''
932i_pthread=''
933d_pwage=''
934d_pwchange=''
935d_pwclass=''
936d_pwcomment=''
937d_pwexpire=''
938d_pwgecos=''
939d_pwpasswd=''
940d_pwquota=''
941i_pwd=''
942i_shadow=''
943i_socks=''
944i_stdbool=''
945i_stddef=''
946i_stdlib=''
947i_string=''
948strings=''
949i_sunmath=''
950i_sysaccess=''
951i_sysdir=''
952i_sysfile=''
953d_voidtty=''
954i_bsdioctl=''
955i_sysfilio=''
956i_sysioctl=''
957i_syssockio=''
958i_syslog=''
959i_sysmman=''
960i_sysmode=''
961i_sysmount=''
962i_sysndir=''
963i_sysparam=''
964i_syspoll=''
965i_sysresrc=''
966i_syssecrt=''
967i_sysselct=''
968i_sysstat=''
969i_sysstatfs=''
970i_sysstatvfs=''
971i_systimes=''
972i_systypes=''
973i_sysuio=''
974i_sysun=''
975i_sysutsname=''
976i_sysvfs=''
977i_syswait=''
978i_sgtty=''
979i_termio=''
980i_termios=''
981d_tm_tm_gmtoff=''
982d_tm_tm_zone=''
983i_systime=''
984i_systimek=''
985i_time=''
986timeincl=''
987i_unistd=''
988i_ustat=''
989i_utime=''
990i_values=''
991i_stdarg=''
992i_varargs=''
993i_varhdr=''
994i_vfork=''
995d_inc_version_list=''
996inc_version_list=''
997inc_version_list_init=''
998installprefix=''
999installprefixexp=''
1000installstyle=''
1001installusrbinperl=''
1002intsize=''
1003longsize=''
1004shortsize=''
1005issymlink=''
1006libc=''
1007ldlibpthname=''
1008libperl=''
1009shrpenv=''
1010useshrplib=''
1011glibpth=''
1012incpth=''
1013libpth=''
1014loclibpth=''
1015plibpth=''
1016xlibpth=''
1017ignore_versioned_solibs=''
1018libs=''
1019libsdirs=''
1020libsfiles=''
1021libsfound=''
1022libspath=''
1023lns=''
1024d_PRIEUldbl=''
1025d_PRIFUldbl=''
1026d_PRIGUldbl=''
1027d_PRIeldbl=''
1028d_PRIfldbl=''
1029d_PRIgldbl=''
1030d_SCNfldbl=''
1031sPRIEUldbl=''
1032sPRIFUldbl=''
1033sPRIGUldbl=''
1034sPRIeldbl=''
1035sPRIfldbl=''
1036sPRIgldbl=''
1037sSCNfldbl=''
1038lseeksize=''
1039lseektype=''
1040mad=''
1041madlyh=''
1042madlyobj=''
1043madlysrc=''
1044make_set_make=''
1045d_mymalloc=''
1046freetype=''
1047mallocobj=''
1048mallocsrc=''
1049malloctype=''
1050usemallocwrap=''
1051usemymalloc=''
1052installman1dir=''
1053man1dir=''
1054man1direxp=''
1055man1ext=''
1056installman3dir=''
1057man3dir=''
1058man3direxp=''
1059man3ext=''
1060modetype=''
1061multiarch=''
1062mydomain=''
1063myhostname=''
1064phostname=''
1065c=''
1066n=''
1067d_eofnblk=''
1068eagain=''
1069o_nonblock=''
1070rd_nodata=''
1071need_va_copy=''
1072netdb_hlen_type=''
1073netdb_host_type=''
1074netdb_name_type=''
1075netdb_net_type=''
1076groupcat=''
1077hostcat=''
1078passcat=''
1079orderlib=''
1080ranlib=''
1081d_perl_otherlibdirs=''
1082otherlibdirs=''
1083package=''
1084spackage=''
1085pager=''
1086api_revision=''
1087api_subversion=''
1088api_version=''
1089api_versionstring=''
1090patchlevel=''
1091perl_patchlevel=''
1092revision=''
1093subversion=''
1094version=''
1095version_patchlevel_string=''
1096perl5=''
1097perladmin=''
1098perlpath=''
1099d_nv_preserves_uv=''
1100d_nv_zero_is_allbits_zero=''
1101i16size=''
1102i16type=''
1103i32size=''
1104i32type=''
1105i64size=''
1106i64type=''
1107i8size=''
1108i8type=''
1109ivsize=''
1110ivtype=''
1111nv_overflows_integers_at=''
1112nv_preserves_uv_bits=''
1113nvsize=''
1114nvtype=''
1115u16size=''
1116u16type=''
1117u32size=''
1118u32type=''
1119u64size=''
1120u64type=''
1121u8size=''
1122u8type=''
1123uvsize=''
1124uvtype=''
1125ivdformat=''
1126nvEUformat=''
1127nvFUformat=''
1128nvGUformat=''
1129nveformat=''
1130nvfformat=''
1131nvgformat=''
1132uvXUformat=''
1133uvoformat=''
1134uvuformat=''
1135uvxformat=''
1136pidtype=''
1137prefix=''
1138prefixexp=''
1139installprivlib=''
1140privlib=''
1141privlibexp=''
1142prototype=''
1143ptrsize=''
1144d_PRIXU64=''
1145d_PRId64=''
1146d_PRIi64=''
1147d_PRIo64=''
1148d_PRIu64=''
1149d_PRIx64=''
1150sPRIXU64=''
1151sPRId64=''
1152sPRIi64=''
1153sPRIo64=''
1154sPRIu64=''
1155sPRIx64=''
1156d_quad=''
1157quadkind=''
1158quadtype=''
1159uquadtype=''
1160drand01=''
1161randbits=''
1162randfunc=''
1163randseedtype=''
1164seedfunc=''
1165installscript=''
1166scriptdir=''
1167scriptdirexp=''
1168selectminbits=''
1169selecttype=''
1170sh=''
1171targetsh=''
1172sig_count=''
1173sig_name=''
1174sig_name_init=''
1175sig_num=''
1176sig_num_init=''
1177sig_size=''
1178d_sitearch=''
1179installsitearch=''
1180sitearch=''
1181sitearchexp=''
1182installsitebin=''
1183sitebin=''
1184sitebinexp=''
1185installsitehtml1dir=''
1186sitehtml1dir=''
1187sitehtml1direxp=''
1188installsitehtml3dir=''
1189sitehtml3dir=''
1190sitehtml3direxp=''
1191installsitelib=''
1192sitelib=''
1193sitelib_stem=''
1194sitelibexp=''
1195installsiteman1dir=''
1196siteman1dir=''
1197siteman1direxp=''
1198installsiteman3dir=''
1199siteman3dir=''
1200siteman3direxp=''
1201siteprefix=''
1202siteprefixexp=''
1203installsitescript=''
1204sitescript=''
1205sitescriptexp=''
1206sizesize=''
1207sizetype=''
1208d_libname_unique=''
1209so=''
1210socksizetype=''
1211sharpbang=''
1212shsharp=''
1213spitshell=''
1214src=''
1215ssizetype=''
1216st_ino_sign=''
1217st_ino_size=''
1218startperl=''
1219startsh=''
1220stdchar=''
1221d_stdio_stream_array=''
1222stdio_stream_array=''
1223sysman=''
1224sGMTIME_max=''
1225sGMTIME_min=''
1226sLOCALTIME_max=''
1227sLOCALTIME_min=''
1228trnl=''
1229uidformat=''
1230uidsign=''
1231uidsize=''
1232uidtype=''
1233archname64=''
1234use64bitall=''
1235use64bitint=''
1236dtrace=''
1237usedtrace=''
1238usefaststdio=''
1239usekernprocpathname=''
1240ccflags_uselargefiles=''
1241ldflags_uselargefiles=''
1242libswanted_uselargefiles=''
1243uselargefiles=''
1244uselongdouble=''
1245usemorebits=''
1246usemultiplicity=''
1247nm_opt=''
1248nm_so_opt=''
1249runnm=''
1250usenm=''
1251usensgetexecutablepath=''
1252useperlio=''
1253usesocks=''
1254d_oldpthreads=''
1255use5005threads=''
1256useithreads=''
1257usereentrant=''
1258usethreads=''
1259incpath=''
1260mips_type=''
1261usrinc=''
1262vaproto=''
1263d_vendorarch=''
1264installvendorarch=''
1265vendorarch=''
1266vendorarchexp=''
1267d_vendorbin=''
1268installvendorbin=''
1269vendorbin=''
1270vendorbinexp=''
1271installvendorhtml1dir=''
1272vendorhtml1dir=''
1273vendorhtml1direxp=''
1274installvendorhtml3dir=''
1275vendorhtml3dir=''
1276vendorhtml3direxp=''
1277d_vendorlib=''
1278installvendorlib=''
1279vendorlib=''
1280vendorlib_stem=''
1281vendorlibexp=''
1282installvendorman1dir=''
1283vendorman1dir=''
1284vendorman1direxp=''
1285installvendorman3dir=''
1286vendorman3dir=''
1287vendorman3direxp=''
1288usevendorprefix=''
1289vendorprefix=''
1290vendorprefixexp=''
1291d_vendorscript=''
1292installvendorscript=''
1293vendorscript=''
1294vendorscriptexp=''
1295versiononly=''
1296yacc=''
1297yaccflags=''
1298CONFIG=''
1299
1300: Detect odd OSs
1301define='define'
1302undef='undef'
1303smallmach='pdp11 i8086 z8000 i80286 iAPX286'
1304rmlist=''
1305
1306: We must find out about Eunice early
1307eunicefix=':'
1308if test -f /etc/unixtovms; then
1309	eunicefix=/etc/unixtovms
1310fi
1311if test -f /etc/unixtovms.exe; then
1312	eunicefix=/etc/unixtovms.exe
1313fi
1314
1315: Set executable suffix now -- needed before hints available
1316if test -f "/libs/version.library"; then
1317: Amiga OS
1318    _exe=""
1319elif test -f "/system/gnu_library/bin/ar.pm"; then
1320: Stratus VOS
1321    _exe=".pm"
1322elif test -n "$DJGPP"; then
1323: DOS DJGPP
1324    _exe=".exe"
1325elif test -f /kern/cookiejar; then
1326: MiNT
1327    _exe=""
1328elif test -d c:/. -o -n "$is_os2" ; then
1329: OS/2 or cygwin
1330    _exe=".exe"
1331fi
1332
1333groupstype=''
1334i_whoami=''
1335: Trailing extension.  Override this in a hint file, if needed.
1336: Extra object files, if any, needed on this platform.
1337archobjs=''
1338archname=''
1339: Possible local include directories to search.
1340: Set locincpth to "" in a hint file to defeat local include searches.
1341locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
1342locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
1343:
1344: no include file wanted by default
1345inclwanted=''
1346
1347: Enable -DEBUGGING and -DDEBUGGING from the command line
1348EBUGGING=''
1349DEBUGGING=''
1350
1351libnames=''
1352: change the next line if compiling for Xenix/286 on Xenix/386
1353xlibpth='/usr/lib/386 /lib/386'
1354: Possible local library directories to search.
1355loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1356loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1357
1358: general looking path for locating libraries
1359glibpth="/lib /usr/lib $xlibpth"
1360glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
1361test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
1362test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
1363test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
1364
1365: Private path used by Configure to find libraries.  Its value
1366: is prepended to libpth. This variable takes care of special
1367: machines, like the mips.  Usually, it should be empty.
1368plibpth=''
1369
1370: default library list
1371libswanted=''
1372: some systems want to use only the non-versioned libso:s
1373ignore_versioned_solibs=''
1374: set usethreads on the Configure command line to enable threads.
1375usereentrant='undef'
1376ccname=''
1377ccversion=''
1378perllibs=''
1379: set useposix=false in your hint file to disable the POSIX extension.
1380useposix=true
1381: set useopcode=false in your hint file to disable the Opcode extension.
1382useopcode=true
1383archname64=''
1384ccflags_uselargefiles=''
1385ldflags_uselargefiles=''
1386libswanted_uselargefiles=''
1387: set usemultiplicity on the Configure command line to enable multiplicity.
1388: set usesocks on the Configure command line to enable socks.
1389: List of libraries we want.
1390: If anyone needs extra -lxxx, put those in a hint file.
1391libswanted="cl pthread socket bind inet nsl nm ndbm gdbm dbm db malloc dl ld"
1392libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
1393: We probably want to search /usr/shlib before most other libraries.
1394: This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
1395glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
1396glibpth="/usr/shlib $glibpth"
1397: Do not use vfork unless overridden by a hint file.
1398usevfork=false
1399
1400: Find the basic shell for Bourne shell scripts
1401case "$sh" in
1402'')
1403	case "$SYSTYPE" in
1404	*bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
1405	*) xxx='/bin/sh';;
1406	esac
1407	if test -f "$xxx"; then
1408		sh="$xxx"
1409	else
1410		: Build up a list and do a single loop so we can 'break' out.
1411		pth=`echo $PATH | sed -e "s/$p_/ /g"`
1412		for xxx in sh bash ksh pdksh ash; do
1413			for p in $pth; do
1414				try="$try ${p}/${xxx}"
1415			done
1416		done
1417		for xxx in $try; do
1418			if test -f "$xxx"; then
1419				sh="$xxx";
1420				break
1421			elif test "X$_exe" != X -a -f "$xxx$_exe"; then
1422				sh="$xxx";
1423				break
1424			elif test -f "$xxx.exe"; then
1425				sh="$xxx";
1426				break
1427			fi
1428		done
1429	fi
1430	;;
1431esac
1432
1433case "$sh" in
1434'')	cat >&2 <<EOM
1435$me:  Fatal Error:  I can't find a Bourne Shell anywhere.
1436
1437Usually it's in /bin/sh.  How did you even get this far?
1438Please contact me (Perl Maintainers) at perlbug@perl.org and
1439we'll try to straighten this all out.
1440EOM
1441	exit 1
1442	;;
1443esac
1444
1445: When cross-compiling we need to separate the sh-to-run-Configure-with from the sh-to-use-in-Perl
1446: default both to the same thing, cross-compilers can then set targetsh differently if they like
1447targetsh=$sh
1448
1449: see if sh knows # comments
1450if `$sh -c '#' >/dev/null 2>&1`; then
1451	shsharp=true
1452	spitshell=cat
1453	xcat=/bin/cat
1454	test -f $xcat$_exe || xcat=/usr/bin/cat
1455	if test ! -f $xcat$_exe; then
1456		for p in `echo $PATH | sed -e "s/$p_/ /g"` $paths; do
1457			if test -f $p/cat$_exe; then
1458				xcat=$p/cat
1459				break
1460			fi
1461		done
1462		if test ! -f $xcat$_exe; then
1463			echo "Can't find cat anywhere!"
1464			exit 1
1465		fi
1466	fi
1467	echo "#!$xcat" >sharp
1468	$eunicefix sharp
1469	chmod +x sharp
1470	./sharp > today 2>/dev/null
1471	if test -s today; then
1472		sharpbang='#!'
1473	else
1474		echo "#! $xcat" > sharp
1475		$eunicefix sharp
1476		chmod +x sharp
1477		./sharp > today 2>/dev/null
1478		if test -s today; then
1479			sharpbang='#! '
1480		else
1481			sharpbang=': use '
1482		fi
1483	fi
1484else
1485	echo " "
1486	echo "Your $sh doesn't grok # comments--I will strip them later on."
1487	shsharp=false
1488	cd ..
1489	echo "exec grep -v '^[ 	]*#'" >spitshell
1490	chmod +x spitshell
1491	$eunicefix spitshell
1492	spitshell=`pwd`/spitshell
1493	cd UU
1494	echo "I presume that if # doesn't work, #! won't work either!"
1495	sharpbang=': use '
1496fi
1497rm -f sharp today
1498
1499: figure out how to guarantee sh startup
1500case "$startsh" in
1501'') startsh=${sharpbang}${sh} ;;
1502*)
1503esac
1504cat >sharp <<EOSS
1505$startsh
1506set abc
1507test "$?abc" != 1
1508EOSS
1509
1510chmod +x sharp
1511$eunicefix sharp
1512if ./sharp; then
1513	: echo "Yup, it does."
1514else
1515	echo "Hmm... '$startsh' does not guarantee sh startup..."
1516	echo "You may have to fix up the shell scripts to make sure $sh runs them."
1517fi
1518rm -f sharp
1519
1520: Save command line options in file UU/cmdline.opt for later use in
1521: generating config.sh.
1522cat > cmdline.opt <<EOSH
1523: Configure command line arguments.
1524config_arg0='$0'
1525config_args='$*'
1526config_argc=$#
1527EOSH
1528argn=1
1529args_exp=''
1530args_sep=''
1531for arg in "$@"; do
1532	cat >>cmdline.opt <<EOSH
1533config_arg$argn='$arg'
1534EOSH
1535	cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
1536$arg
1537EOC
1538	arg_exp=`cat cmdl.opt`
1539	args_exp="$args_exp$args_sep'$arg_exp'"
1540	argn=`expr $argn + 1`
1541	args_sep=' '
1542done
1543rm -f cmdl.opt
1544
1545: produce awk script to parse command line options
1546cat >options.awk <<'EOF'
1547BEGIN {
1548	optstr = "A:dD:eEf:hKOrsSU:V";	# getopt-style specification
1549
1550	len = length(optstr);
1551	for (i = 1; i <= len; i++) {
1552		c = substr(optstr, i, 1);
1553		if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1554		if (a == ":") {
1555			arg[c] = 1;
1556			i++;
1557		}
1558		opt[c] = 1;
1559	}
1560}
1561{
1562	expect = 0;
1563	str = $0;
1564	if (substr(str, 1, 1) != "-") {
1565		printf("'%s'\n", str);
1566		next;
1567	}
1568	len = length($0);
1569	for (i = 2; i <= len; i++) {
1570		c = substr(str, i, 1);
1571		if (!opt[c]) {
1572			printf("-%s\n", substr(str, i));
1573			next;
1574		}
1575		printf("-%s\n", c);
1576		if (arg[c]) {
1577			if (i < len)
1578				printf("'%s'\n", substr(str, i + 1));
1579			else
1580				expect = 1;
1581			next;
1582		}
1583	}
1584}
1585END {
1586	if (expect)
1587		print "?";
1588}
1589EOF
1590
1591: process the command line options
1592set X `for arg in "$@"; do echo "X$arg"; done |
1593	sed -e s/X// | awk -f options.awk`
1594eval "set $*"
1595shift
1596rm -f options.awk
1597
1598: set up default values
1599fastread=''
1600reuseval=false
1601config_sh=''
1602alldone=''
1603error=''
1604silent=''
1605extractsh=''
1606override=''
1607knowitall=''
1608rm -f optdef.sh posthint.sh
1609cat >optdef.sh <<EOS
1610$startsh
1611EOS
1612
1613
1614: option parsing
1615while test $# -gt 0; do
1616	case "$1" in
1617	-d) shift; fastread=yes;;
1618	-e) shift; alldone=cont;;
1619	-f)
1620		shift
1621		cd ..
1622		if test -r "$1"; then
1623			config_sh="$1"
1624		else
1625			echo "$me: cannot read config file $1." >&2
1626			error=true
1627		fi
1628		cd UU
1629		shift;;
1630	--help|\
1631	-h) shift; error=true;;
1632	-r) shift; reuseval=true;;
1633	-s) shift; silent=true; realsilent=true;;
1634	-E) shift; alldone=exit;;
1635	-K) shift; knowitall=true;;
1636	-O) shift; override=true;;
1637	-S) shift; silent=true; extractsh=true;;
1638	-D)
1639		shift
1640		case "$1" in
1641		*=)
1642			echo "$me: use '-U symbol=', not '-D symbol='." >&2
1643			echo "$me: ignoring -D $1" >&2
1644			;;
1645		*=*) echo "$1" | \
1646				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1647		*) echo "$1='define'" >> optdef.sh;;
1648		esac
1649		shift
1650		;;
1651	-U)
1652		shift
1653		case "$1" in
1654		*=) echo "$1" >> optdef.sh;;
1655		*=*)
1656			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1657			echo "$me: ignoring -U $1" >&2
1658			;;
1659		*) echo "$1='undef'" >> optdef.sh;;
1660		esac
1661		shift
1662		;;
1663	-A)
1664	    shift
1665	    xxx=''
1666	    yyy="$1"
1667	    zzz=''
1668	    uuu=undef
1669	    case "$yyy" in
1670            *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1671                 case "$zzz" in
1672                 *:*) zzz='' ;;
1673                 *)   xxx=append
1674                      zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1675                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1676                 esac
1677                 ;;
1678            esac
1679            case "$xxx" in
1680            '')  case "$yyy" in
1681                 *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1682                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1683                      zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1684                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1685                 *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
1686                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1687                 esac
1688                 ;;
1689            esac
1690	    case "$xxx" in
1691	    append)
1692		echo "$yyy=\"\${$yyy}$zzz\""	>> posthint.sh ;;
1693	    clear)
1694		echo "$yyy=''"			>> posthint.sh ;;
1695	    define)
1696	        case "$zzz" in
1697		'') zzz=define ;;
1698		esac
1699		echo "$yyy='$zzz'"		>> posthint.sh ;;
1700	    eval)
1701		echo "eval \"$yyy=$zzz\""	>> posthint.sh ;;
1702	    prepend)
1703		echo "$yyy=\"$zzz\${$yyy}\""	>> posthint.sh ;;
1704	    undef)
1705	        case "$zzz" in
1706		'') zzz="$uuu" ;;
1707		esac
1708		echo "$yyy=$zzz"		>> posthint.sh ;;
1709            *)  echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1710	    esac
1711	    shift
1712	    ;;
1713	-V) echo "$me generated by metaconfig 3.5 PL0." >&2
1714	    exit 0;;
1715	--) break;;
1716	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
1717	*) break;;
1718	esac
1719done
1720
1721case "$error" in
1722true)
1723	cat >&2 <<EOM
1724Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1725                 [-U symbol] [-U symbol=] [-A command:symbol...]
1726  -d : use defaults for all answers.
1727  -e : go on without questioning past the production of config.sh.
1728  -f : specify an alternate default configuration file.
1729  -h : print this help message and exit (with an error status).
1730  -r : reuse C symbols value if possible (skips costly nm extraction).
1731  -s : silent mode, only echoes questions and essential information.
1732  -D : define symbol to have some value:
1733         -D symbol         symbol gets the value 'define'
1734         -D symbol=value   symbol gets the value 'value'
1735       common used examples (see INSTALL for more info):
1736         -Duse64bitint            use 64bit integers
1737         -Duse64bitall            use 64bit integers and pointers
1738         -Dusethreads             use thread support
1739         -Dinc_version_list=none  do not include older perl trees in @INC
1740         -DEBUGGING=none          DEBUGGING options
1741         -Dcc=gcc                 choose your compiler
1742         -Dprefix=/opt/perl5      choose your destination
1743  -E : stop at the end of questions, after having produced config.sh.
1744  -K : do not use unless you know what you are doing.
1745  -O : let -D and -U override definitions from loaded configuration file.
1746  -S : perform variable substitutions on all .SH files (can mix with -f)
1747  -U : undefine symbol:
1748         -U symbol    symbol gets the value 'undef'
1749         -U symbol=   symbol gets completely empty
1750       e.g.:  -Uversiononly
1751  -A : manipulate symbol after the platform specific hints have been applied:
1752         -A append:symbol=value   append value to symbol
1753         -A symbol=value          like append:, but with a separating space
1754         -A define:symbol=value   define symbol to have value
1755         -A clear:symbol          define symbol to be ''
1756         -A define:symbol         define symbol to be 'define'
1757         -A eval:symbol=value     define symbol to be eval of value
1758         -A prepend:symbol=value  prepend value to symbol
1759         -A undef:symbol          define symbol to be 'undef'
1760         -A undef:symbol=         define symbol to be ''
1761       e.g.:  -A prepend:libswanted='cl pthread '
1762              -A ccflags=-DSOME_MACRO
1763  -V : print version number and exit (with a zero status).
1764EOM
1765	exit 1
1766	;;
1767esac
1768
1769: Sanity checks
1770case "$fastread$alldone" in
1771yescont|yesexit) ;;
1772*)
1773	case "$extractsh" in
1774	true) ;;
1775	*)
1776		if test ! -t 0; then
1777			echo "Say 'sh Configure', not 'sh <Configure'"
1778			exit 1
1779		fi
1780		;;
1781	esac
1782	;;
1783esac
1784
1785exec 4>&1
1786case "$silent" in
1787true) exec 1>/dev/null;;
1788esac
1789
1790: run the defines and the undefines, if any, but leave the file out there...
1791touch optdef.sh
1792. ./optdef.sh
1793: create the posthint manipulation script and leave the file out there...
1794touch posthint.sh
1795
1796: set package name
1797package='perl5'
1798first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1799last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1800case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1801ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1802*) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1803esac
1804
1805: Some greps do not return status, grrr.
1806echo "grimblepritz" >grimble
1807if grep blurfldyick grimble >/dev/null 2>&1 ; then
1808	contains=contains
1809elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1810	contains=grep
1811else
1812	contains=contains
1813fi
1814rm -f grimble
1815: the following should work in any shell
1816case "$contains" in
1817contains*)
1818	echo " "
1819	echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1820	cat >contains <<'EOSS'
1821grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1822EOSS
1823chmod +x contains
1824esac
1825
1826: Find the path to the source tree
1827case "$src" in
1828'') case "$0" in
1829    */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
1830         case "$src" in
1831	 /*)	;;
1832	 .)	;;
1833         *)	src=`cd ../$src && pwd` ;;
1834	 esac
1835         ;;
1836    *)   src='.';;
1837    esac;;
1838esac
1839case "$src" in
1840'')	src=/
1841	rsrc=/
1842	;;
1843/*)	rsrc="$src";;
1844*)	rsrc="../$src";;
1845esac
1846if test -f $rsrc/Configure && \
1847	$contains "^package='$package'\$" $rsrc/Configure >/dev/null 2>&1
1848then
1849   : found it, so we are ok.
1850else
1851	rsrc=''
1852	for src in . .. ../.. ../../.. ../../../..; do
1853		if test -f ../$src/Configure && \
1854			$contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1855		then
1856			rsrc=../$src
1857			break
1858		fi
1859	done
1860fi
1861case "$rsrc" in
1862'')
1863	cat <<EOM >&4
1864
1865Sorry, I can't seem to locate the source dir for $package.  Please start
1866Configure with an explicit path -- i.e. /some/path/Configure.
1867
1868EOM
1869	exit 1
1870	;;
1871../.)	rsrc='..';;
1872*)
1873	echo " "
1874	echo "Sources for $package found in \"$src\"." >&4
1875	;;
1876esac
1877
1878: script used to extract .SH files with variable substitutions
1879cat >extract <<'EOS'
1880PERL_CONFIG_SH=true
1881echo "Doing variable substitutions on .SH files..."
1882if test -f MANIFEST; then
1883	set x `awk '{print $1}' < MANIFEST | grep '\.SH$'`
1884else
1885	echo "(Looking for .SH files under the source directory.)"
1886	set x `(cd "$src"; find . -name "*.SH" -print)`
1887fi
1888shift
1889case $# in
18900) set x `(cd "$src"; echo *.SH)`; shift;;
1891esac
1892if test ! -f "$src/$1"; then
1893	shift
1894fi
1895mkdir_p='
1896name=$1;
1897create="";
1898while test $name; do
1899	if test ! -d "$name"; then
1900		create="$name $create";
1901		name=`echo $name | sed -e "s|^[^/]*$||"`;
1902		name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1903	else
1904		name="";
1905	fi;
1906done;
1907for file in $create; do
1908	mkdir $file;
1909done
1910'
1911for file in $*; do
1912	case "$src" in
1913	".")
1914		case "$file" in
1915		*/*)
1916			dir=`expr X$file : 'X\(.*\)/'`
1917			file=`expr X$file : 'X.*/\(.*\)'`
1918			(cd "$dir" && . ./$file)
1919			;;
1920		*)
1921			. ./$file
1922			;;
1923		esac
1924		;;
1925	*)
1926		case "$file" in
1927		*/*)
1928			dir=`expr X$file : 'X\(.*\)/'`
1929			file=`expr X$file : 'X.*/\(.*\)'`
1930			(set x $dir; shift; eval $mkdir_p)
1931			sh <"$src/$dir/$file"
1932			;;
1933		*)
1934			sh <"$src/$file"
1935			;;
1936		esac
1937		;;
1938	esac
1939done
1940if test -f "$src/config_h.SH"; then
1941	if test ! -f config.h; then
1942	: oops, they left it out of MANIFEST, probably, so do it anyway.
1943	. "$src/config_h.SH"
1944	fi
1945fi
1946EOS
1947
1948: extract files and exit if asked to do so
1949case "$extractsh" in
1950true)
1951	case "$realsilent" in
1952	true) ;;
1953	*) exec 1>&4;;
1954	esac
1955	case "$config_sh" in
1956	'') config_sh='config.sh';;
1957	esac
1958	echo " "
1959	echo "Fetching answers from $config_sh..."
1960	cd ..
1961	. $config_sh
1962	test "$override" && . ./optdef.sh
1963	echo " "
1964	. UU/extract
1965	rm -rf UU
1966	echo "Extraction done."
1967	exit 0
1968	;;
1969esac
1970
1971: Eunice requires " " instead of "", can you believe it
1972echo " "
1973: Here we go...
1974echo "Beginning of configuration questions for $package."
1975
1976trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1977
1978: first determine how to suppress newline on echo command
1979echo " "
1980echo "Checking echo to see how to suppress newlines..."
1981(echo "hi there\c" ; echo " ") >.echotmp
1982if $contains c .echotmp >/dev/null 2>&1 ; then
1983	echo "...using -n."
1984	n='-n'
1985	c=''
1986else
1987	cat <<'EOM'
1988...using \c
1989EOM
1990	n=''
1991	c='\c'
1992fi
1993echo $n "The star should be here-->$c"
1994echo '*'
1995rm -f .echotmp
1996
1997: Now test for existence of everything in MANIFEST
1998echo " "
1999if test -f "$rsrc/MANIFEST"; then
2000	echo "First let's make sure your kit is complete.  Checking..." >&4
2001	awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
2002		(split -l 50 2>/dev/null || split -50)
2003	rm -f missing
2004	tmppwd=`pwd`
2005	for filelist in x??; do
2006		(cd "$rsrc"; ls `cat "$tmppwd/$filelist"` \
2007			>/dev/null 2>>"$tmppwd/missing")
2008	done
2009	if test -s missing; then
2010		cat missing >&4
2011		cat >&4 <<'EOM'
2012
2013THIS PACKAGE SEEMS TO BE INCOMPLETE.
2014
2015You have the option of continuing the configuration process, despite the
2016distinct possibility that your kit is damaged, by typing 'y'es.  If you
2017do, don't blame me if something goes wrong.  I advise you to type 'n'o
2018and contact the author (perlbug@perl.org).
2019
2020EOM
2021		echo $n "Continue? [n] $c" >&4
2022		read ans
2023		case "$ans" in
2024		y*)
2025			echo "Continuing..." >&4
2026			rm -f missing
2027			;;
2028		*)
2029			echo "ABORTING..." >&4
2030			kill $$
2031			;;
2032		esac
2033	else
2034		echo "Looks good..."
2035	fi
2036else
2037	echo "There is no MANIFEST file.  I hope your kit is complete !"
2038fi
2039rm -f missing x??
2040
2041: Find the appropriate value for a newline for tr
2042echo " "
2043if test -n "$DJGPP"; then
2044       trnl='\012'
2045fi
2046if test X"$trnl" = X; then
2047	case "`echo foo|tr '\n' x 2>/dev/null`" in
2048	foox) trnl='\n' ;;
2049	esac
2050fi
2051if test X"$trnl" = X; then
2052	case "`echo foo|tr '\012' x 2>/dev/null`" in
2053	foox) trnl='\012' ;;
2054	esac
2055fi
2056if test X"$trnl" = X; then
2057       case "`echo foo|tr '\r\n' xy 2>/dev/null`" in
2058       fooxy) trnl='\n\r' ;;
2059       esac
2060fi
2061if test X"$trnl" = X; then
2062	cat <<EOM >&2
2063
2064$me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
2065
2066EOM
2067	exit 1
2068fi
2069
2070: compute the number of columns on the terminal for proper question formatting
2071case "$COLUMNS" in
2072'') COLUMNS='80';;
2073esac
2074
2075: set up the echo used in my read
2076myecho="case \"\$xxxm\" in
2077'') echo $n \"\$rp $c\" >&4;;
2078*) case \"\$rp\" in
2079	'') echo $n \"[\$xxxm] $c\";;
2080	*)
2081		if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
2082			echo \"\$rp\" >&4
2083			echo $n \"[\$xxxm] $c\" >&4
2084		else
2085			echo $n \"\$rp [\$xxxm] $c\" >&4
2086		fi
2087		;;
2088	esac;;
2089esac"
2090
2091: now set up to do reads with possible shell escape and default assignment
2092cat <<EOSC >myread
2093$startsh
2094xxxm=\$dflt
2095$myecho
2096ans='!'
2097case "\$fastread" in
2098yes) case "\$dflt" in
2099	'') ;;
2100	*) ans='';
2101		case "\$silent-\$rp" in
2102		true-) ;;
2103		*) echo " " >&4;;
2104		esac;;
2105	esac;;
2106*) case "\$silent" in
2107	true) case "\$rp" in
2108		'') ans='';;
2109		esac;;
2110	esac;;
2111esac
2112while expr "X\$ans" : "X!" >/dev/null; do
2113	read answ
2114	set x \$xxxm
2115	shift
2116	aok=''; eval "ans=\\"\$answ\\"" && aok=y
2117	case  "\$answ" in
2118	"!")
2119		sh 1>&4
2120		echo " "
2121		$myecho
2122		;;
2123	!*)
2124		set x \`expr "X\$ans" : "X!\(.*\)\$"\`
2125		shift
2126		sh 1>&4 -c "\$*"
2127		echo " "
2128		$myecho
2129		;;
2130	"\$ans")
2131		case "\$ans" in
2132		\\&*)
2133			set x \`expr "X\$ans" : "X&\(.*\)\$"\`
2134			shift
2135			case "\$1" in
2136			-d)
2137				fastread=yes
2138				echo "(OK, I'll run with -d after this question.)" >&4
2139				;;
2140			-*)
2141				echo "*** Sorry, \$1 not supported yet." >&4
2142				;;
2143			esac
2144			$myecho
2145			ans=!
2146			;;
2147		esac;;
2148	*)
2149		case "\$aok" in
2150		y)
2151			echo "*** Substitution done -- please confirm."
2152			xxxm="\$ans"
2153			ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
2154			xxxm="\$ans"
2155			ans=!
2156			;;
2157		*)
2158			echo "*** Error -- try again."
2159			ans=!
2160			;;
2161		esac
2162		$myecho
2163		;;
2164	esac
2165	case "\$ans\$xxxm\$nostick" in
2166	'')
2167		ans=!
2168		$myecho
2169		;;
2170	esac
2171done
2172case "\$ans" in
2173'') ans="\$xxxm";;
2174esac
2175EOSC
2176
2177: create .config dir to save info across Configure sessions
2178test -d ../.config || mkdir ../.config
2179cat >../.config/README <<EOF
2180This directory created by Configure to save information that should
2181persist across sessions for $package.
2182
2183You may safely delete it if you wish.
2184EOF
2185
2186: See if we are using a devel version and want that
2187xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
2188case "$usedevel" in
2189$define|true|[yY]*)
2190    usedevel="$define" ;;
2191*) case "$xversion" in
2192   *[13579])
2193	cat >&4 <<EOH
2194*** WHOA THERE!!! ***
2195
2196    This is an UNSTABLE DEVELOPMENT release.
2197    The version of this $package distribution is $xversion, that is, odd,
2198    (as opposed to even) and that signifies a development release.
2199    If you want a maintenance release, you want an even-numbered version.
2200
2201    Do ***NOT*** install this into production use.
2202    Data corruption and crashes are possible.
2203
2204    It is most seriously suggested that you do not continue any further
2205    unless you want to help in developing and debugging Perl.
2206
2207    If you *still* want to build perl, you can answer 'y' now,
2208    or pass -Dusedevel to Configure.
2209
2210EOH
2211	rp='Do you really want to continue?'
2212	dflt='n'
2213	. ./myread
2214	case "$ans" in
2215	[yY]) echo >&4 "Okay, continuing."
2216	      usedevel="$define" ;;
2217	*) echo >&4 "Okay, bye."
2218	   exit 1
2219	   ;;
2220	esac
2221	;;
2222    esac
2223    usedevel="$undef"
2224    ;;
2225esac
2226case "$usedevel" in
2227$define|true|[yY]*)
2228	case "$versiononly" in
2229	'') versiononly="$define" ;;
2230	esac
2231	case "$installusrbinperl" in
2232	'') installusrbinperl="$undef" ;;
2233	esac
2234	;;
2235esac
2236
2237: general instructions
2238needman=true
2239firsttime=true
2240user=`(logname) 2>/dev/null`
2241case "$user" in
2242'') user=`whoami 2>&1`;;
2243esac
2244if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
2245	firsttime=false
2246	echo " "
2247	rp='Would you like to see the instructions?'
2248	dflt=n
2249	. ./myread
2250	case "$ans" in
2251	[yY]*) ;;
2252	*) needman=false;;
2253	esac
2254fi
2255if $needman; then
2256	cat <<EOH
2257
2258This installation shell script will examine your system and ask you questions
2259to determine how the perl5 package should be installed. If you get
2260stuck on a question, you may use a ! shell escape to start a subshell or
2261execute a command.  Many of the questions will have default answers in square
2262brackets; typing carriage return will give you the default.
2263
2264On some of the questions which ask for file or directory names you are allowed
2265to use the ~name construct to specify the login directory belonging to "name",
2266even if you don't have a shell which knows about that.  Questions where this is
2267allowed will be marked "(~name ok)".
2268
2269EOH
2270	rp=''
2271	dflt='Type carriage return to continue'
2272	. ./myread
2273	cat <<'EOH'
2274
2275The prompter used in this script allows you to use shell variables and
2276backticks in your answers.  You may use $1, $2, etc...  to refer to the words
2277in the default answer, as if the default line was a set of arguments given to a
2278script shell.  This means you may also use $* to repeat the whole default line,
2279so you do not have to re-type everything to add something to the default.
2280
2281Every time there is a substitution, you will have to confirm.  If there is an
2282error (e.g. an unmatched backtick), the default answer will remain unchanged
2283and you will be prompted again.
2284
2285If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
2286the questions and use the computed defaults (or the previous answers if there
2287was already a config.sh file). Type 'Configure -h' for a list of options.
2288You may also start interactively and then answer '& -d' at any prompt to turn
2289on the non-interactive behaviour for the remainder of the execution.
2290
2291EOH
2292	. ./myread
2293	cat <<EOH
2294
2295Much effort has been expended to ensure that this shell script will run on any
2296Unix system.  If despite that it blows up on yours, your best bet is to edit
2297Configure and run it again.  If you can't run Configure for some reason,
2298you'll have to generate a config.sh file by hand.  Whatever problems you
2299have, let me (perlbug@perl.org) know how I blew it.
2300
2301This installation script affects things in two ways:
2302
23031) it may do direct variable substitutions on some of the files included
2304   in this kit.
23052) it builds a config.h file for inclusion in C programs.  You may edit
2306   any of these files as the need arises after running this script.
2307
2308If you make a mistake on a question, there is no easy way to back up to it
2309currently.  The easiest thing to do is to edit config.sh and rerun all the SH
2310files.  Configure will offer to let you do this before it runs the SH files.
2311
2312EOH
2313	dflt='Type carriage return to continue'
2314	. ./myread
2315	case "$firsttime" in
2316	true) echo $user >>../.config/instruct;;
2317	esac
2318fi
2319
2320: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
2321: This is primarily meant for cross-compile environments, and may fail to be useful in other cases
2322if test "X$sysroot" = X; then
2323    sysroot=""
2324else
2325    case "$cc" in
2326	*gcc*|*g++*)
2327	    echo "Using $sysroot to find your headers and libraries, adding to ccflags"
2328	    # _sysroot is used in places where we need --sysroot=foo
2329	    # but using the rest of the flags could cause issues.
2330	    _sysroot="--sysroot=$sysroot";
2331	    case "$ccflags" in
2332		*sysroot*) ;;
2333		'undef'|*)
2334		ccflags="$ccflags $_sysroot"
2335	    esac
2336	    case "$ldflags" in
2337		*sysroot*) ;;
2338		'undef'|*)
2339		ldflags="$ldflags $_sysroot"
2340	    esac
2341	    case "$cppflags" in
2342		*sysroot*) ;;
2343		'undef'|*)
2344		cppflags="$cppflags $_sysroot"
2345	    esac
2346	    # lddlflags updated below in lddlflags section;
2347	    # same with cccdlflags
2348	    ;;
2349    esac
2350
2351    # Adjust some defaults to also use $sysroot
2352    for var in xlibpth loclibpth locincpth glibpth; do
2353	eval xxx=\$$var
2354	eval $var=''
2355	for path in $xxx; do
2356	    eval $var=\"\$$var $sysroot$path\"
2357	done
2358    done
2359
2360fi
2361
2362: find out where common programs are
2363echo " "
2364echo "Locating common programs..." >&4
2365cat <<EOSC >loc
2366$startsh
2367case \$# in
23680) exit 1;;
2369esac
2370thing=\$1
2371shift
2372dflt=\$1
2373shift
2374for dir in \$*; do
2375	case "\$thing" in
2376	.)
2377	if test -d \$dir/\$thing; then
2378		echo \$dir
2379		exit 0
2380	fi
2381	;;
2382	*)
2383	for thisthing in \$dir/\$thing; do
2384		: just loop through to pick last item
2385	done
2386	if test -f \$thisthing; then
2387		echo \$thisthing
2388		exit 0
2389	elif test "X$_exe" != X -a -f \$thisthing$_exe; then
2390		echo \$thisthing
2391		exit 0
2392	elif test -f \$dir/\$thing.exe; then
2393		if test -n "$DJGPP"; then
2394			echo \$dir/\$thing.exe
2395		elif test "$eunicefix" != ":"; then
2396			: on Eunice apparently
2397			echo \$dir/\$thing
2398		fi
2399		exit 0
2400	fi
2401	;;
2402	esac
2403done
2404echo \$dflt
2405exit 1
2406EOSC
2407chmod +x loc
2408$eunicefix loc
2409loclist="
2410awk
2411cat
2412chmod
2413comm
2414cp
2415echo
2416expr
2417grep
2418ls
2419mkdir
2420rm
2421sed
2422sort
2423touch
2424tr
2425uniq
2426"
2427trylist="
2428ar
2429bison
2430byacc
2431cpp
2432csh
2433date
2434egrep
2435gmake
2436gzip
2437less
2438ln
2439make
2440more
2441nm
2442nroff
2443perl
2444pg
2445test
2446uname
2447zip
2448"
2449pth=`echo $PATH | sed -e "s/$p_/ /g"`
2450pth="$pth $sysroot/lib $sysroot/usr/lib"
2451for file in $loclist; do
2452	eval xxx=\$$file
2453	case "$xxx" in
2454	/*|?:[\\/]*)
2455		if test -f "$xxx"; then
2456			: ok
2457		else
2458			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2459			xxx=`./loc $file $file $pth`
2460		fi
2461		;;
2462	'') xxx=`./loc $file $file $pth`;;
2463	*) xxx=`./loc $xxx $xxx $pth`;;
2464	esac
2465	eval $file=$xxx$_exe
2466	eval _$file=$xxx
2467	case "$xxx" in
2468	/*)
2469		echo $file is in $xxx.
2470		;;
2471	?:[\\/]*)
2472		echo $file is in $xxx.
2473		;;
2474	*)
2475		echo "I don't know where '$file' is, and my life depends on it." >&4
2476		echo "Go find a public domain implementation or fix your PATH setting!" >&4
2477		exit 1
2478		;;
2479	esac
2480done
2481echo " "
2482echo "Don't worry if any of the following aren't found..."
2483say=offhand
2484for file in $trylist; do
2485	eval xxx=\$$file
2486	case "$xxx" in
2487	/*|?:[\\/]*)
2488		if test -f "$xxx"; then
2489			: ok
2490		else
2491			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2492			xxx=`./loc $file $file $pth`
2493		fi
2494		;;
2495	'') xxx=`./loc $file $file $pth`;;
2496	*) xxx=`./loc $xxx $xxx $pth`;;
2497	esac
2498	eval $file=$xxx$_exe
2499	eval _$file=$xxx
2500	case "$xxx" in
2501	/*)
2502		echo $file is in $xxx.
2503		;;
2504	?:[\\/]*)
2505		echo $file is in $xxx.
2506		;;
2507	*)
2508		echo "I don't see $file out there, $say."
2509		say=either
2510		;;
2511	esac
2512done
2513case "$egrep" in
2514egrep)
2515	echo "Substituting grep for egrep."
2516	egrep=$grep
2517	_egrep=$grep
2518	;;
2519esac
2520case "$less" in
2521'')	;;
2522*)	if $less -R </dev/null >/dev/null 2>&1; then
2523	       echo "Substituting less -R for less."
2524	       less="$less -R"
2525	       _less=$less
2526	fi
2527	;;
2528esac
2529case "$ln" in
2530ln)
2531	echo "Substituting cp for ln."
2532	ln=$cp
2533	_ln=$cp
2534	;;
2535esac
2536case "$make" in
2537make)
2538	case "$gmake" in
2539	gmake)
2540	echo "I can't find make or gmake, and my life depends on it." >&4
2541	echo "Go find a public domain implementation or fix your PATH setting!" >&4
2542	exit 1
2543	;;
2544	esac
2545	;;
2546esac
2547case "$gmake" in
2548gmake)	;;
2549*)	# We can't have osname yet.
2550	if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
2551		# Assume that gmake, if found, is definitely GNU make
2552		# and prefer it over the system make.
2553		echo "Substituting gmake for make."
2554		make=$gmake
2555		_make=$gmake
2556	fi
2557	;;
2558esac
2559case "$test" in
2560test)
2561	echo "Hopefully test is built into your sh."
2562	;;
2563*)
2564	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
2565		echo "Using the test built into your sh."
2566		test=test
2567		_test=test
2568	fi
2569	;;
2570esac
2571case "$echo" in
2572echo)
2573	echo "Hopefully echo is built into your sh."
2574	;;
2575'') ;;
2576*)
2577	echo " "
2578echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
2579	$echo $n "hi there$c" >foo1
2580	echo $n "hi there$c" >foo2
2581	if cmp foo1 foo2 >/dev/null 2>&1; then
2582		echo "They are compatible.  In fact, they may be identical."
2583	else
2584		case "$n" in
2585		'-n') n='' c='\c';;
2586		*) n='-n' c='';;
2587		esac
2588		cat <<FOO
2589They are not compatible!  You are probably running ksh on a non-USG system.
2590I'll have to use $echo instead of the builtin, since Bourne shell doesn't
2591have echo built in and we may have to run some Bourne shell scripts.  That
2592means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
2593
2594FOO
2595		$echo $n "The star should be here-->$c"
2596		$echo "*"
2597	fi
2598	$rm -f foo1 foo2
2599	;;
2600esac
2601
2602# This question was auctioned at YAPC::Europe-2007 in Vienna
2603# I never promised you could answer it. I only auctioned the question.
2604cat <<FOO
2605The following message is sponsored by
2606
2607  Dresden.pm<--The stars should be here.
2608
2609Dear Perl user, system administrator or package
2610maintainer, the Perl community sends greetings to
2611you. Do you (emblematical) greet back [Y/n]? n
2612
2613FOO
2614
2615: Check what type of C compiler we use
2616cat <<EOS >trygcc
2617$startsh
2618EOS
2619cat <<'EOSC' >>trygcc
2620case "$cc" in
2621'') ;;
2622*)  $rm -f try try.*
2623    $cat >try.c <<EOM
2624int main(int argc, char *argv[]) {
2625  return 0;
2626}
2627EOM
2628    if $cc -o try $ccflags $ldflags try.c; then
2629       :
2630    else
2631        echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2632        despair=yes
2633        trygcc=yes
2634        case "$cc" in
2635        *gcc*) trygcc=no ;;
2636        esac
2637	# Skip this test because it gives a false match on output like:
2638	#    ./trygcc: line 23: cc: command not found
2639        # case "`$cc -v -c try.c 2>&1`" in
2640        # *gcc*) trygcc=no ;;
2641        # esac
2642        if $test X"$trygcc" = Xyes; then
2643            if gcc -o try -c try.c; then
2644                echo " "
2645                echo "You seem to have a working gcc, though." >&4
2646		# Switching compilers may undo the work of hints files.
2647		# The most common problem is -D_REENTRANT for threads.
2648		# This heuristic catches that case, but gets false positives
2649		# if -Dusethreads was not actually specified.  Better to
2650		# bail out here with a useful message than fail
2651		# mysteriously later. Should we perhaps just try to
2652		# re-invoke Configure -Dcc=gcc config_args ?
2653		if $test -f usethreads.cbu; then
2654			$cat >&4 <<EOM 
2655
2656*** However, any setting of the C compiler flags (e.g. for thread support)
2657*** will be lost.  It may be necessary for you to restart Configure and
2658*** add -Dcc=gcc to your Configure command line.
2659
2660EOM
2661			rp="Would you like to go ahead and try gcc anyway?"
2662			dflt=n
2663		else
2664			rp="Would you like to use it?"
2665			dflt=y
2666		fi
2667                if $test -f myread; then
2668                    . ./myread
2669                else
2670                    if $test -f UU/myread; then
2671                        . ./UU/myread
2672                    else
2673                        echo "Cannot find myread, sorry.  Aborting." >&2
2674                        exit 1
2675                    fi
2676                fi
2677                case "$ans" in
2678                [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
2679                esac
2680            fi
2681        fi
2682    fi
2683    $rm -f try try.*
2684    ;;
2685esac
2686EOSC
2687
2688cat <<EOS >checkcc
2689$startsh
2690EOS
2691cat <<'EOSC' >>checkcc
2692case "$cc" in
2693'') ;;
2694*)  $rm -f try try.*
2695    $cat >try.c <<EOM
2696int main(int argc, char *argv[]) {
2697  return 0;
2698}
2699EOM
2700    if $cc -o try $ccflags $ldflags try.c; then
2701       :
2702    else
2703        if $test X"$despair" = Xyes; then
2704           echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2705        fi
2706        $cat >&4 <<EOM         
2707You need to find a working C compiler.
2708Either (purchase and) install the C compiler supplied by your OS vendor,
2709or for a free C compiler try http://gcc.gnu.org/
2710I cannot continue any further, aborting.
2711EOM
2712        exit 1
2713    fi
2714    $rm -f try try.*
2715    ;;
2716esac
2717EOSC
2718
2719: determine whether symbolic links are supported
2720echo " "
2721$touch blurfl
2722if $ln -s blurfl sym > /dev/null 2>&1 ; then
2723	echo "Symbolic links are supported." >&4
2724	lns="$ln -s"
2725else
2726	echo "Symbolic links are NOT supported." >&4
2727	lns="$ln"
2728fi
2729$rm -f blurfl sym
2730
2731: determine whether symbolic links are supported
2732echo " "
2733case "$lns" in
2734*"ln"*" -s")
2735	echo "Checking how to test for symbolic links..." >&4
2736	$lns blurfl sym
2737	if $test "X$issymlink" = X; then
2738		case "$newsh" in
2739		'') sh     -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2740		*)  $newsh -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2741		esac
2742		if test $? = 0; then
2743			issymlink="test -h"
2744		else
2745			echo "Your builtin 'test -h' may be broken." >&4
2746			case "$test" in
2747			/*)	;;
2748			*)	pth=`echo $PATH | sed -e "s/$p_/ /g"`
2749				for p in $pth
2750				do
2751					if test -f "$p/$test"; then
2752						test="$p/$test"
2753						break
2754					fi
2755				done
2756				;;
2757			esac
2758			case "$test" in
2759			/*)
2760				echo "Trying external '$test -h'." >&4
2761				issymlink="$test -h"
2762				if $test ! -h sym >/dev/null 2>&1; then
2763					echo "External '$test -h' is broken, too." >&4
2764					issymlink=''
2765				fi
2766				;;
2767			*)	issymlink='' ;;
2768			esac
2769		fi
2770	fi
2771	if $test "X$issymlink" = X; then
2772		if $test -L sym 2>/dev/null; then
2773			issymlink="$test -L"
2774			echo "The builtin '$test -L' worked." >&4
2775		fi
2776	fi
2777	if $test "X$issymlink" != X; then
2778		echo "You can test for symbolic links with '$issymlink'." >&4
2779	else
2780		echo "I do not know how you can test for symbolic links." >&4
2781	fi
2782	$rm -f blurfl sym
2783	;;
2784*)	echo "No symbolic links, so not testing for their testing..." >&4
2785	;;
2786esac
2787echo " "
2788
2789: Make symlinks util
2790case "$mksymlinks" in
2791$define|true|[yY]*)
2792	case "$src" in
2793	''|'.')	echo "Cannot create symlinks in the original directory." >&4
2794		exit 1
2795		;;
2796	*)	case "$lns:$issymlink" in
2797		*"ln"*" -s:"*"test -"?)
2798			echo "Creating the symbolic links..." >&4
2799			cd ..
2800			awk -v src="$src" '{
2801				dir=$1;
2802				if (!sub(/\/[^\/]*$/, "", dir)) { dir = "." }
2803				mf[dir] = mf[dir]" "src"/"$1;
2804			} END {
2805				for (d in mf) {
2806					if (d != ".") { system("mkdir -p "d) }
2807					system("ln -sf "mf[d]" "d);
2808				}
2809			}' $src/MANIFEST
2810			# Sanity check 1.
2811			if test ! -d t/base; then
2812				echo "Failed to create the subdirectories.  Aborting." >&4
2813				exit 1
2814			fi
2815			# Sanity check 2.
2816			if test ! -f t/base/lex.t; then
2817				echo "Failed to create the symlinks (t/base/lex.t missing).  Aborting." >&4
2818				exit 1
2819			fi
2820			if test ! -f x2p/walk.c; then
2821				echo "Failed to create the symlinks (x2p/walk.c missing).  Aborting." >&4
2822				exit 1
2823			fi
2824			cd UU
2825			;;
2826		*)	echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
2827			;;
2828		esac
2829		;;
2830	esac
2831	;;
2832esac
2833
2834: Check for Cross-Compilation
2835if $test "X$targethost" = "X"; then
2836    targethost=""
2837fi
2838if $test "X$targetenv" = "X"; then
2839    targetenv=""
2840fi
2841case "$usecrosscompile" in
2842$define|true|[yY]*)
2843	$echo "Cross-compiling..."
2844	croak=''
2845	case "$cc" in
2846	*-gcc*|*-g++*) # A cross-compiling gcc, probably.
2847	    # arm-linux-androideabi-gcc  -> arm-linux-androideabi
2848	    # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
2849	    targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
2850	    ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
2851	    # leave out ld, choosing it is more complex
2852	    nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
2853	    ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
2854	    # We are in a weird spot. Just before us, some values
2855	    # were 'saved', to be restored after the hints are
2856	    # run.  This means that the changes we made to ar,
2857	    # nm and ranlib will get reverted.
2858	    # To avoid that, we hijack the saving mechanism and
2859	    # have it save our new values.
2860	    for file in ar nm ranlib; do
2861		eval xxx=\$$file
2862		eval $file=$xxx$_exe
2863		eval _$file=$xxx
2864	    done
2865	;;
2866	esac
2867	case "$targetarch" in
2868	'') echo "Targetarch not defined." >&4; croak=y ;;
2869	*)  echo "Using targetarch $targetarch." >&4 ;;
2870	esac
2871	case "$targethost" in
2872	'') echo "Targethost not defined." >&4; croak=y ;;
2873	*)  echo "Using targethost $targethost." >&4
2874	esac
2875	locincpth=' '
2876	loclibpth=' '
2877	case "$croak" in
2878	y) echo "Cannot continue, aborting." >&4; exit 1 ;;
2879	esac
2880    : compile a host miniperl and generate_uudmap, unless we got passed them
2881    if $test "X$hostperl" = X; then
2882      echo "Building host miniperl and generate_uudmap binaries" >&4
2883      before_host=`pwd`
2884      cd ..
2885      cd $src
2886      src=`pwd`
2887      rm -rf $src/host
2888      mkdir $src/host
2889      cd $src/host
2890      $src/Configure -des -Dusedevel -Dmksymlinks
2891      $make miniperl
2892      case "$hostgenerate" in
2893      '') $make generate_uudmap
2894          hostgenerate=$src/host/generate_uudmap
2895          ;;
2896       "$undef") hostgenerate=''
2897          ;;
2898      esac
2899      hostperl=$src/host/miniperl
2900      cd $before_host
2901    fi
2902    hostosname=`$hostperl -le 'print $^O'`
2903    ;;
2904*)
2905    usecrosscompile="$undef"
2906    ;;
2907esac
2908
2909: Define -Dtargethost=somecomputer to run compiled tests on another machine
2910case "$targethost" in
2911    '') echo "Checking for cross-compile" >&4
2912    case "$usecrosscompile$multiarch" in
2913       *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
2914         if [ -f Makefile ]; then
2915           echo " "
2916           echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
2917         else
2918           echo "Configure done."
2919         fi
2920       exit 0
2921       ;;
2922     *) echo "No targethost for running compiler tests against defined, running locally" >&4
2923        run=''
2924        to=:
2925        from=:
2926        ;;
2927    esac
2928    ;;
2929    *) echo "Using targethost $targethost." >&4
2930	case "$src" in
2931	/*) run=$src/Cross/run
2932	    targetmkdir=$src/Cross/mkdir
2933	    to=$src/Cross/to
2934	    from=$src/Cross/from
2935	    ;;
2936	*)  pwd=`$test -f ../Configure & cd ..; pwd`
2937	    run=$pwd/Cross/run
2938	    targetmkdir=$pwd/Cross/mkdir
2939	    to=$pwd/Cross/to
2940	    from=$pwd/Cross/from
2941	    ;;
2942	esac
2943	case "$targetrun" in
2944	'') targetrun=ssh ;;
2945	esac
2946	case "$targetto" in
2947	'') targetto=scp ;;
2948	esac
2949	case "$targetfrom" in
2950	'') targetfrom=scp ;;
2951	esac
2952	run=$run-$targetrun
2953	to=$to-$targetto
2954	from=$from-$targetfrom
2955	case "$targetdir" in
2956	'')  targetdir=/tmp
2957	     echo "Guessing targetdir $targetdir." >&4
2958	     ;;
2959	esac
2960	case "$targetuser" in
2961	'')  targetuser=root
2962	     echo "Guessing targetuser $targetuser." >&4
2963	     ;;
2964	esac
2965	case "$targetport" in
2966	'')  targetport=22
2967	     echo "Guessing targetport $targetport." >&4
2968	     ;;
2969	esac
2970	case "$targetfrom" in
2971	scp)	q=-q ;;
2972	*)	q='' ;;
2973	esac
2974	case "$targetrun" in
2975	ssh|rsh)
2976	    cat >$run <<EOF
2977#!/bin/sh
2978env=''
2979case "\$1" in
2980-cwd)
2981  shift
2982  cwd=\$1
2983  shift
2984  ;;
2985esac
2986case "\$1" in
2987-env)
2988  shift
2989  env=\$1
2990  shift
2991  ;;
2992esac
2993case "\$cwd" in
2994'') cwd=$targetdir ;;
2995esac
2996exe=\$1
2997shift
2998$to \$exe
2999$targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
3000EOF
3001	    ;;
3002	adb)
3003	    $touch $run
3004	    ;;
3005	*)  echo "Unknown targetrun '$targetrun'" >&4
3006	    exit 1
3007	    ;;
3008	esac
3009	case "$targetmkdir" in
3010	*/Cross/mkdir)
3011	    cat >$targetmkdir <<EOF
3012#!/bin/sh
3013$targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
3014EOF
3015	    $chmod a+rx $targetmkdir
3016	    ;;
3017	*)  echo "Unknown targetmkdir '$targetmkdir'" >&4
3018	    exit 1
3019	    ;;
3020	esac
3021	case "$targetto" in
3022	scp|rcp)
3023	    cat >$to <<EOF
3024#!/bin/sh
3025for f in \$@
3026do
3027  case "\$f" in
3028  /*)
3029    $targetmkdir \`dirname \$f\`
3030    $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f           2>/dev/null  || exit 1
3031    ;;
3032  *)
3033    $targetmkdir $targetdir/\`dirname \$f\`
3034    $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
3035    ;;
3036  esac
3037done
3038exit 0
3039EOF
3040	    ;;
3041	cp) cat >$to <<EOF
3042#!/bin/sh
3043for f in \$@
3044do
3045  case "\$f" in
3046  /*)
3047    $mkdir -p $targetdir/\`dirname \$f\`
3048    $cp \$f $targetdir/\$f || exit 1
3049    ;;
3050  *)
3051    $targetmkdir $targetdir/\`dirname \$f\`
3052    $cp \$f $targetdir/\$f || exit 1
3053    ;;
3054  esac
3055done
3056exit 0
3057EOF
3058	    ;;
3059	*)  echo "Unknown targetto '$targetto'" >&4
3060	    exit 1
3061	    ;;
3062	esac
3063	case "$targetfrom" in
3064	scp|rcp)
3065	  cat >$from <<EOF
3066#!/bin/sh
3067for f in \$@
3068do
3069  $rm -f \$f
3070  $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
3071done
3072exit 0
3073EOF
3074	    ;;
3075	cp) cat >$from <<EOF
3076#!/bin/sh
3077for f in \$@
3078do
3079  $rm -f \$f
3080  cp $targetdir/\$f . || exit 1
3081done
3082exit 0
3083EOF
3084	    ;;
3085	*)  echo "Unknown targetfrom '$targetfrom'" >&4
3086	    exit 1
3087	    ;;
3088	esac
3089	if $test ! -f $run; then
3090	    echo "Target 'run' script '$run' not found." >&4
3091	else
3092	    $chmod a+rx $run
3093	fi
3094	if $test ! -f $to; then
3095	    echo "Target 'to' script '$to' not found." >&4
3096	else
3097	    $chmod a+rx $to
3098	fi
3099	if $test ! -f $from; then
3100	    echo "Target 'from' script '$from' not found." >&4
3101	else
3102	    $chmod a+rx $from
3103	fi
3104	if $test ! -f $run -o ! -f $to -o ! -f $from; then
3105	    exit 1
3106	fi
3107	cat >&4 <<EOF
3108Using '$run' for remote execution,
3109and '$from' and '$to'
3110for remote file transfer.
3111EOF
3112	;;
3113*)	run=''
3114	to=:
3115	from=:
3116	usecrosscompile="$undef"
3117	targetarch=''
3118	;;
3119esac
3120
3121: see whether [:lower:] and [:upper:] are supported character classes
3122echo " "
3123case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
3124ABYZ)
3125	echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
3126	up='[:upper:]'
3127	low='[:lower:]'
3128	;;
3129*)	# There is a discontinuity in EBCDIC between 'R' and 'S'
3130	# (0xd9 and 0xe2), therefore that is a nice testing point.
3131	if test "X$up" = X -o "X$low" = X; then
3132	    case "`echo RS | $tr '[R-S]' '[r-s]' 2>/dev/null`" in
3133	    rs) up='[A-Z]'
3134		low='[a-z]'
3135		;;
3136	    esac
3137	fi
3138	if test "X$up" = X -o "X$low" = X; then
3139	    case "`echo RS | $tr R-S r-s 2>/dev/null`" in
3140	    rs) up='A-Z'
3141		low='a-z'
3142		;;
3143	    esac
3144	fi
3145	if test "X$up" = X -o "X$low" = X; then
3146	    case "`echo RS | od -x 2>/dev/null`" in
3147	    *D9E2*|*d9e2*)
3148		echo "Hey, this might be EBCDIC." >&4
3149		if test "X$up" = X -o "X$low" = X; then
3150		    case "`echo RS | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
3151		    rs) up='[A-IJ-RS-Z]'
3152			low='[a-ij-rs-z]'
3153			;;
3154		    esac
3155		fi
3156		if test "X$up" = X -o "X$low" = X; then
3157		    case "`echo RS | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
3158		    rs) up='A-IJ-RS-Z'
3159			low='a-ij-rs-z'
3160			;;
3161		    esac
3162		fi
3163		;;
3164	    esac
3165	fi
3166esac
3167case "`echo RS | $tr \"$up\" \"$low\" 2>/dev/null`" in
3168rs)
3169    echo "Using $up and $low to convert case." >&4
3170    ;;
3171*)
3172    echo "I don't know how to translate letters from upper to lower case." >&4
3173    echo "Your tr is not acting any way I know of." >&4
3174    exit 1
3175    ;;
3176esac
3177: set up the translation script tr, must be called with ./tr of course
3178cat >tr <<EOSC
3179$startsh
3180case "\$1\$2" in
3181'[A-Z][a-z]') exec $tr '$up' '$low';;
3182'[a-z][A-Z]') exec $tr '$low' '$up';;
3183esac
3184exec $tr "\$@"
3185EOSC
3186chmod +x tr
3187$eunicefix tr
3188
3189: Try to determine whether config.sh was made on this system
3190case "$config_sh" in
3191'')
3192myuname=`$uname -a 2>/dev/null`
3193$test -z "$myuname" && myuname=`hostname 2>/dev/null`
3194# Downcase everything to avoid ambiguity.
3195# Remove slashes and single quotes so we can use parts of this in
3196# directory and file names.
3197# Remove newlines so myuname is sane to use elsewhere.
3198# tr '[A-Z]' '[a-z]' would not work in EBCDIC
3199# because the A-Z/a-z are not consecutive.
3200myuname=`echo $myuname | $sed -e "s,['/],,g" | \
3201	./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
3202newmyuname="$myuname"
3203dflt=n
3204case "$knowitall" in
3205'')
3206	if test -f ../config.sh; then
3207		if $contains myuname= ../config.sh >/dev/null 2>&1; then
3208			eval "`grep myuname= ../config.sh`"
3209		fi
3210		if test "X$myuname" = "X$newmyuname"; then
3211			dflt=y
3212		fi
3213	fi
3214	;;
3215*) dflt=y;;
3216esac
3217
3218: Get old answers from old config file if Configure was run on the
3219: same system, otherwise use the hints.
3220hint=default
3221cd ..
3222if test -f config.sh; then
3223	echo " "
3224	rp="I see a config.sh file.  Shall I use it to set the defaults?"
3225	. UU/myread
3226	case "$ans" in
3227	n*|N*) echo "OK, I'll ignore it."
3228		mv config.sh config.sh.old
3229		myuname="$newmyuname"
3230		;;
3231	*)  echo "Fetching default answers from your old config.sh file..." >&4
3232		tmp_n="$n"
3233		tmp_c="$c"
3234		tmp_sh="$sh"
3235		. ./config.sh
3236		cp config.sh UU
3237		n="$tmp_n"
3238		c="$tmp_c"
3239		: Older versions did not always set $sh.  Catch re-use of such
3240		: an old config.sh.
3241		case "$sh" in
3242		'') sh="$tmp_sh" ;;
3243		esac
3244		hint=previous
3245		;;
3246	esac
3247fi
3248. ./UU/checkcc
3249if test ! -f config.sh; then
3250	$cat <<EOM
3251
3252First time through, eh?  I have some defaults handy for some systems
3253that need some extra help getting the Configure answers right:
3254
3255EOM
3256	(cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
3257	dflt=''
3258	: Half the following guesses are probably wrong... If you have better
3259	: tests or hints, please send them to perlbug@perl.org
3260	: The metaconfig authors would also appreciate a copy...
3261	$test -f /irix && osname=irix
3262	$test -f /xenix && osname=sco_xenix
3263	$test -f /dynix && osname=dynix
3264	$test -f /dnix && osname=dnix
3265	$test -f /lynx.os && osname=lynxos
3266	$test -f /unicos && osname=unicos && osvers=`$uname -r`
3267	$test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
3268	$test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
3269	$test -f /bin/mips && /bin/mips && osname=mips
3270	$test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
3271		$sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
3272	$test -d /usr/apollo/bin && osname=apollo
3273	$test -f /etc/saf/_sactab && osname=svr4
3274	$test -d /usr/include/minix && osname=minix && osvers=`$uname -r`
3275	$test -f /system/gnu_library/bin/ar.pm && osname=vos
3276	if $test -d /MachTen -o -d /MachTen_Folder; then
3277		osname=machten
3278		if $test -x /sbin/version; then
3279			osvers=`/sbin/version | $awk '{print $2}' |
3280			$sed -e 's/[A-Za-z]$//'`
3281		elif $test -x /usr/etc/version; then
3282			osvers=`/usr/etc/version | $awk '{print $2}' |
3283			$sed -e 's/[A-Za-z]$//'`
3284		else
3285			osvers="$2.$3"
3286		fi
3287	fi
3288
3289	$test -f /sys/posix.dll &&
3290		$test -f /usr/bin/what &&
3291		set X `/usr/bin/what /sys/posix.dll` &&
3292		$test "$3" = UWIN &&
3293		osname=uwin &&
3294		osvers="$5"
3295
3296	if $test -f $uname; then
3297		set X $myuname
3298		shift
3299
3300		case "$5" in
3301		fps*) osname=fps ;;
3302		mips*)
3303			case "$4" in
3304			umips) osname=umips ;;
3305			*) osname=mips ;;
3306			esac;;
3307		[23]100) osname=mips ;;
3308		next*) osname=next ;;
3309		i386*)
3310			tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
3311			if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
3312				osname='sco'
3313				osvers=$tmp
3314			elif $test -f /etc/kconfig; then
3315				osname=isc
3316				if test "$lns" = "$ln -s"; then
3317					osvers=4
3318				elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
3319					osvers=3
3320				elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
3321					osvers=2
3322				fi
3323			fi
3324			tmp=''
3325			;;
3326		pc*)
3327			if test -n "$DJGPP"; then
3328				osname=dos
3329				osvers=djgpp
3330			fi
3331			;;
3332		esac
3333
3334		case "$1" in
3335		aix) osname=aix
3336			tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
3337			case "$tmp" in
3338			# oslevel can fail with:
3339			# oslevel: Unable to acquire lock.
3340			*not\ found) osvers="$4"."$3" ;;
3341			'<3240'|'<>3240') osvers=3.2.0 ;;
3342			'=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
3343			'=3250'|'>3250') osvers=3.2.5 ;;
3344			*) osvers=$tmp;;
3345			esac
3346			;;
3347		bitrig) osname=bitrig
3348			osvers="$3"
3349			;;
3350		bsd386) osname=bsd386
3351			osvers=`$uname -r`
3352			;;
3353		cygwin*) osname=cygwin
3354			osvers="$3"
3355			;;
3356		*dc.osx) osname=dcosx
3357			osvers="$3"
3358			;;
3359		dnix) osname=dnix
3360			osvers="$3"
3361			;;
3362		domainos) osname=apollo
3363			osvers="$3"
3364			;;
3365		dgux)	osname=dgux
3366			osvers="$3"
3367			;;
3368		dragonfly) osname=dragonfly
3369			osvers="$3"
3370			;;
3371		dynixptx*) osname=dynixptx
3372			osvers=`echo "$4"|sed 's/^v//'`
3373			;;
3374		freebsd) osname=freebsd
3375			osvers="$3" ;;
3376		genix)	osname=genix ;;
3377		gnu)	osname=gnu
3378			osvers="$3" ;;
3379		hp*)	osname=hpux
3380			osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
3381			;;
3382		irix*)	osname=irix
3383			case "$3" in
3384			4*) osvers=4 ;;
3385			5*) osvers=5 ;;
3386			*)	osvers="$3" ;;
3387			esac
3388			;;
3389		linux)	osname=linux
3390			case "$3" in
3391			*)	osvers="$3" ;;
3392			esac
3393			$test -f /system/lib/libandroid.so && osname=linux-android
3394			;;
3395		MiNT)	osname=mint
3396			;;
3397		netbsd*) osname=netbsd
3398			osvers="$3"
3399			;;
3400		news-os) osvers="$3"
3401			case "$3" in
3402			4*) osname=newsos4 ;;
3403			*) osname=newsos ;;
3404			esac
3405			;;
3406		next*) osname=next ;;
3407		nonstop-ux) osname=nonstopux ;;
3408		openbsd) osname=openbsd
3409                	osvers="$3"
3410                	;;
3411		os2)	osname=os2
3412			osvers="$4"
3413			;;
3414		POSIX-BC | posix-bc ) osname=posix-bc
3415			osvers="$3"
3416			;;
3417		powerux | power_ux | powermax_os | powermaxos | \
3418		powerunix | power_unix) osname=powerux
3419			osvers="$3"
3420			;;
3421		qnx) osname=qnx
3422			osvers="$4"
3423			;;
3424		solaris) osname=solaris
3425			case "$3" in
3426			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3427			*)	osvers="$3" ;;
3428			esac
3429			;;
3430		sunos) osname=sunos
3431			case "$3" in
3432			5*) osname=solaris
3433				osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3434			*)	osvers="$3" ;;
3435			esac
3436			;;
3437		titanos) osname=titanos
3438			case "$3" in
3439			1*) osvers=1 ;;
3440			2*) osvers=2 ;;
3441			3*) osvers=3 ;;
3442			4*) osvers=4 ;;
3443			*)	osvers="$3" ;;
3444			esac
3445			;;
3446		ultrix) osname=ultrix
3447			osvers="$3"
3448			;;
3449		osf1|mls+)	case "$5" in
3450				alpha)
3451					osname=dec_osf
3452					osvers=`sizer -v | awk -FUNIX '{print $2}' | awk '{print $1}' |  tr '[A-Z]' '[a-z]' | sed 's/^[xvt]//'`
3453					case "$osvers" in
3454					[1-9].[0-9]*) ;;
3455					*) osvers=`echo "$3" | sed 's/^[xvt]//'` ;;
3456					esac
3457					;;
3458			hp*)	osname=hp_osf1	;;
3459			mips)	osname=mips_osf1 ;;
3460			esac
3461			;;
3462		# UnixWare 7.1.2 is known as Open UNIX 8
3463		openunix|unixware) osname=svr5
3464			osvers="$4"
3465			;;
3466		uts)	osname=uts
3467			osvers="$3"
3468			;;
3469		vos) osvers="$3"
3470			;;
3471		$2) case "$osname" in
3472			*isc*) ;;
3473			*freebsd*) ;;
3474			svr*)
3475				: svr4.x or possibly later
3476				case "svr$3" in
3477				${osname}*)
3478					osname=svr$3
3479					osvers=$4
3480					;;
3481				esac
3482				case "$osname" in
3483				svr4.0)
3484					: Check for ESIX
3485					if test -f /stand/boot ; then
3486						eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
3487						if test -n "$INITPROG" -a -f "$INITPROG"; then
3488			isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
3489							if test -n "$isesix"; then
3490								osname=esix4
3491							fi
3492						fi
3493					fi
3494					;;
3495				esac
3496				;;
3497			*)	if test -f /etc/systemid; then
3498					osname=sco
3499					set `echo $3 | $sed 's/\./ /g'` $4
3500					if $test -f $src/hints/sco_$1_$2_$3.sh; then
3501						osvers=$1.$2.$3
3502					elif $test -f $src/hints/sco_$1_$2.sh; then
3503						osvers=$1.$2
3504					elif $test -f $src/hints/sco_$1.sh; then
3505						osvers=$1
3506					fi
3507				else
3508					case "$osname" in
3509					'') : Still unknown.  Probably a generic Sys V.
3510						osname="sysv"
3511						osvers="$3"
3512						;;
3513					esac
3514				fi
3515				;;
3516			esac
3517			;;
3518		*)	case "$osname" in
3519			'') : Still unknown.  Probably a generic BSD.
3520				osname="$1"
3521				osvers="$3"
3522				;;
3523			esac
3524			;;
3525		esac
3526	else
3527		if test -f /vmunix -a -f $src/hints/news_os.sh; then
3528			(what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
3529			if $contains news-os UU/kernel.what >/dev/null 2>&1; then
3530				osname=news_os
3531			fi
3532			$rm -f UU/kernel.what
3533		elif test -d c:/. -o -n "$is_os2" ; then
3534			set X $myuname
3535			osname=os2
3536			osvers="$5"
3537		fi
3538	fi
3539
3540        case "$targetarch" in
3541        '') ;;
3542        *)  hostarch=$osname
3543            case "$targetarch" in
3544                nto*|*-nto-*)
3545                    # Will load qnx.sh, which should change osname to nto
3546                    osname=qnx
3547                    osvers=''
3548                    ;;
3549                *linux-android*)
3550                    # Catch arm-linux-androideabi, mipsel-linux-android,
3551                    # and i686-linux-android
3552                    osname=linux-android
3553                    osvers=''
3554                    ;;
3555                *linux*)
3556                    # Something like arm-linux-gnueabihf is really just
3557                    # plain linux.
3558                    osname=linux
3559                    osvers=''
3560                    ;;
3561                *solaris*|*sunos*)
3562                    osname=solaris
3563                    # XXX perhaps we should just assume
3564                    # osvers to be 2, or maybe take the value
3565                    # from targetarch. Using $run before the
3566                    # hints are run is somewhat icky.
3567                    set X `$run $uname -a 2>/dev/null`
3568                    shift
3569                    case "$3" in
3570                        5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3571                        *)  osvers="$3" ;;
3572                    esac
3573                    ;;
3574                *)
3575		    osname=`echo $targetarch|sed 's,^[^-]*-,,'`
3576		    osvers=''
3577                ;;
3578            esac
3579            ;;
3580        esac
3581
3582	: Now look for a hint file osname_osvers, unless one has been
3583	: specified already.
3584	case "$hintfile" in
3585	''|' ')
3586		file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'`
3587		: Also try without trailing minor version numbers.
3588		xfile=`echo $file | $sed -e 's%_[^_]*$%%'`
3589		xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'`
3590		xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'`
3591		xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'`
3592		case "$file" in
3593		'') dflt=none ;;
3594		*)  case "$osvers" in
3595			'') dflt=$file
3596				;;
3597			*)  if $test -f $src/hints/$file.sh ; then
3598					dflt=$file
3599				elif $test -f $src/hints/$xfile.sh ; then
3600					dflt=$xfile
3601				elif $test -f $src/hints/$xxfile.sh ; then
3602					dflt=$xxfile
3603				elif $test -f $src/hints/$xxxfile.sh ; then
3604					dflt=$xxxfile
3605				elif $test -f $src/hints/$xxxxfile.sh ; then
3606					dflt=$xxxxfile
3607				elif $test -f "$src/hints/${osname}.sh" ; then
3608					dflt="${osname}"
3609				else
3610					dflt=none
3611				fi
3612				;;
3613			esac
3614			;;
3615		esac
3616		if $test -f Policy.sh ; then
3617			case "$dflt" in
3618			*Policy*) ;;
3619			none) dflt="Policy" ;;
3620			*) dflt="Policy $dflt" ;;
3621			esac
3622		fi
3623		;;
3624	*)
3625		dflt=`echo $hintfile | $sed 's/\.sh$//'`
3626		;;
3627	esac
3628
3629	if $test -f Policy.sh ; then
3630		$cat <<EOM
3631
3632There's also a Policy hint file available, which should make the
3633site-specific (policy) questions easier to answer.
3634EOM
3635
3636	fi
3637
3638	$cat <<EOM
3639
3640You may give one or more space-separated answers, or "none" if appropriate.
3641If you have a handcrafted Policy.sh file or a Policy.sh file generated by a
3642previous run of Configure, you may specify it as well as or instead of
3643OS-specific hints.  If hints are provided for your OS, you should use them:
3644although Perl can probably be built without hints on many platforms, using
3645hints often improve performance and may enable features that Configure can't
3646set up on its own. If there are no hints that match your OS, specify "none";
3647DO NOT give a wrong version or a wrong OS.
3648
3649EOM
3650
3651	rp="Which of these apply, if any?"
3652	. UU/myread
3653	tans=$ans
3654	for file in $tans; do
3655		if $test X$file = XPolicy -a -f Policy.sh; then
3656			. Policy.sh
3657			$cat Policy.sh >> UU/config.sh
3658		elif $test -f $src/hints/$file.sh; then
3659			. $src/hints/$file.sh
3660			$cat $src/hints/$file.sh >> UU/config.sh
3661		elif $test X"$tans" = X -o X"$tans" = Xnone ; then
3662			: nothing
3663		else
3664			: Give one chance to correct a possible typo.
3665			echo "$file.sh does not exist"
3666			dflt=$file
3667			rp="hint to use instead?"
3668			. UU/myread
3669			for file in $ans; do
3670				if $test -f "$src/hints/$file.sh"; then
3671					. $src/hints/$file.sh
3672					$cat $src/hints/$file.sh >> UU/config.sh
3673				elif $test X$ans = X -o X$ans = Xnone ; then
3674					: nothing
3675				else
3676					echo "$file.sh does not exist -- ignored."
3677				fi
3678			done
3679		fi
3680	done
3681
3682	hint=recommended
3683	: Remember our hint file for later.
3684	if $test -f "$src/hints/$file.sh" ; then
3685		hintfile="$file"
3686	else
3687		hintfile=''
3688	fi
3689fi
3690cd UU
3691;;
3692*)
3693	echo " "
3694	echo "Fetching default answers from $config_sh..." >&4
3695	tmp_n="$n"
3696	tmp_c="$c"
3697	cd ..
3698	cp $config_sh config.sh 2>/dev/null
3699	chmod +w config.sh
3700	. ./config.sh
3701	cd UU
3702	cp ../config.sh .
3703	n="$tmp_n"
3704	c="$tmp_c"
3705	hint=previous
3706	;;
3707esac
3708test "$override" && . ./optdef.sh
3709
3710: Restore computed paths
3711for file in $loclist $trylist; do
3712	eval $file="\$_$file"
3713done
3714
3715cat << EOM
3716
3717Configure uses the operating system name and version to set some defaults.
3718The default value is probably right if the name rings a bell. Otherwise,
3719since spelling matters for me, either accept the default or answer "none"
3720to leave it blank.
3721
3722EOM
3723case "$osname" in
3724	''|' ')
3725		case "$hintfile" in
3726		''|' '|none) dflt=none ;;
3727		*)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
3728		esac
3729		;;
3730	*) dflt="$osname" ;;
3731esac
3732rp="Operating system name?"
3733. ./myread
3734case "$ans" in
3735none)  osname='' ;;
3736*) osname=`echo "$ans" | $sed -e 's/[ 	][	]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
3737esac
3738echo " "
3739case "$osvers" in
3740	''|' ')
3741		case "$hintfile" in
3742		''|' '|none) dflt=none ;;
3743		*)	dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
3744			dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
3745			case "$dflt" in
3746			''|' ') dflt=none ;;
3747			esac
3748			;;
3749		esac
3750		;;
3751	*) dflt="$osvers" ;;
3752esac
3753rp="Operating system version?"
3754. ./myread
3755case "$ans" in
3756none)  osvers='' ;;
3757*) osvers="$ans" ;;
3758esac
3759
3760
3761. ./posthint.sh
3762
3763: who configured the system
3764cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
3765case "$cf_by" in
3766"")
3767	cf_by=`(logname) 2>/dev/null`
3768	case "$cf_by" in
3769	"")
3770		cf_by=`(whoami) 2>/dev/null`
3771		case "$cf_by" in
3772		"") cf_by=unknown ;;
3773		esac ;;
3774	esac ;;
3775esac
3776
3777: decide how portable to be.  Allow command line overrides.
3778case "$d_portable" in
3779"$undef") ;;
3780*)	d_portable="$define" ;;
3781esac
3782
3783: set up shell script to do ~ expansion
3784cat >filexp <<EOSS
3785$startsh
3786: expand filename
3787case "\$1" in
3788 \~/*|\~)
3789	echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
3790	;;
3791 \~*)
3792	if $test -f /bin/csh; then
3793		/bin/csh -f -c "glob \$1"
3794		failed=\$?
3795		echo ""
3796		exit \$failed
3797	else
3798		name=\`$expr x\$1 : '..\([^/]*\)'\`
3799		dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
3800		if $test ! -d "\$dir"; then
3801			me=\`basename \$0\`
3802			echo "\$me: can't locate home directory for: \$name" >&2
3803			exit 1
3804		fi
3805		case "\$1" in
3806		*/*)
3807			echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
3808			;;
3809		*)
3810			echo \$dir
3811			;;
3812		esac
3813	fi
3814	;;
3815*)
3816	echo \$1
3817	;;
3818esac
3819EOSS
3820chmod +x filexp
3821$eunicefix filexp
3822
3823: now set up to get a file name
3824cat <<EOS >getfile
3825$startsh
3826EOS
3827cat <<'EOSC' >>getfile
3828tilde=''
3829fullpath=''
3830already=''
3831skip=''
3832none_ok=''
3833exp_file=''
3834nopath_ok=''
3835orig_rp="$rp"
3836orig_dflt="$dflt"
3837case "$gfpth" in
3838'') gfpth='.' ;;
3839esac
3840
3841case "$fn" in
3842*\(*)
3843	: getfile will accept an answer from the comma-separated list
3844	: enclosed in parentheses even if it does not meet other criteria.
3845	expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
3846	fn=`echo $fn | sed 's/(.*)//'`
3847	;;
3848esac
3849
3850case "$fn" in
3851*:*)
3852	loc_file=`expr $fn : '.*:\(.*\)'`
3853	fn=`expr $fn : '\(.*\):.*'`
3854	;;
3855esac
3856
3857case "$fn" in
3858*~*) tilde=true;;
3859esac
3860case "$fn" in
3861*/*) fullpath=true;;
3862esac
3863case "$fn" in
3864*+*) skip=true;;
3865esac
3866case "$fn" in
3867*n*) none_ok=true;;
3868esac
3869case "$fn" in
3870*e*) exp_file=true;;
3871esac
3872case "$fn" in
3873*p*) nopath_ok=true;;
3874esac
3875
3876case "$fn" in
3877*f*) type='File';;
3878*d*) type='Directory';;
3879*l*) type='Locate';;
3880esac
3881
3882what="$type"
3883case "$what" in
3884Locate) what='File';;
3885esac
3886
3887case "$exp_file" in
3888'')
3889	case "$d_portable" in
3890	"$define") ;;
3891	*) exp_file=true;;
3892	esac
3893	;;
3894esac
3895
3896cd ..
3897while test "$type"; do
3898	redo=''
3899	rp="$orig_rp"
3900	dflt="$orig_dflt"
3901	case "$tilde" in
3902	true) rp="$rp (~name ok)";;
3903	esac
3904	. UU/myread
3905	if test -f UU/getfile.ok && \
3906		$contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
3907	then
3908		value="$ans"
3909		ansexp="$ans"
3910		break
3911	fi
3912	case "$ans" in
3913	none)
3914		value=''
3915		ansexp=''
3916		case "$none_ok" in
3917		true) type='';;
3918		esac
3919		;;
3920	*)
3921		case "$tilde" in
3922		'') value="$ans"
3923			ansexp="$ans";;
3924		*)
3925			value=`UU/filexp $ans`
3926			case $? in
3927			0)
3928				if test "$ans" != "$value"; then
3929					echo "(That expands to $value on this system.)"
3930				fi
3931				;;
3932			*) value="$ans";;
3933			esac
3934			ansexp="$value"
3935			case "$exp_file" in
3936			'') value="$ans";;
3937			esac
3938			;;
3939		esac
3940		case "$fullpath" in
3941		true)
3942			case "$ansexp" in
3943			/*) value="$ansexp" ;;
3944			[a-zA-Z]:/*) value="$ansexp" ;;
3945			*)
3946				redo=true
3947				case "$already" in
3948				true)
3949				echo "I shall only accept a full path name, as in /bin/ls." >&4
3950				echo "Use a ! shell escape if you wish to check pathnames." >&4
3951					;;
3952				*)
3953				echo "Please give a full path name, starting with slash." >&4
3954					case "$tilde" in
3955					true)
3956				echo "Note that using ~name is ok provided it expands well." >&4
3957						already=true
3958						;;
3959					esac
3960				esac
3961				;;
3962			esac
3963			;;
3964		esac
3965		case "$redo" in
3966		'')
3967			case "$type" in
3968			File)
3969				for fp in $gfpth; do
3970					if test "X$fp" = X.; then
3971					    pf="$ansexp"
3972					else
3973					    pf="$fp/$ansexp"
3974					fi
3975					if test -f "$pf"; then
3976						type=''
3977					elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
3978					then
3979						echo "($value is not a plain file, but that's ok.)"
3980						type=''
3981					fi
3982					if test X"$type" = X; then
3983					    value="$pf"
3984					    break
3985					fi
3986				done
3987				;;
3988			Directory)
3989				for fp in $gfpth; do
3990					if test "X$fp" = X.; then
3991					    dir="$ans"
3992					    direxp="$ansexp"
3993					else
3994					    dir="$fp/$ansexp"
3995					    direxp="$fp/$ansexp"
3996					fi
3997					if test -d "$direxp"; then
3998						type=''
3999						value="$dir"
4000						break
4001					fi
4002				done
4003				;;
4004			Locate)
4005				if test -d "$ansexp"; then
4006					echo "(Looking for $loc_file in directory $value.)"
4007					value="$value/$loc_file"
4008					ansexp="$ansexp/$loc_file"
4009				fi
4010				if test -f "$ansexp"; then
4011					type=''
4012				fi
4013				case "$nopath_ok" in
4014				true)	case "$value" in
4015					*/*) ;;
4016					*)	echo "Assuming $value will be in people's path."
4017						type=''
4018						;;
4019					esac
4020					;;
4021				esac
4022				;;
4023			esac
4024
4025			case "$skip" in
4026			true) type='';
4027			esac
4028
4029			case "$type" in
4030			'') ;;
4031			*)
4032				if test "$fastread" = yes; then
4033					dflt=y
4034				else
4035					dflt=n
4036				fi
4037				rp="$what $value doesn't exist.  Use that name anyway?"
4038				. UU/myread
4039				dflt=''
4040				case "$ans" in
4041				y*) type='';;
4042				*) echo " ";;
4043				esac
4044				;;
4045			esac
4046			;;
4047		esac
4048		;;
4049	esac
4050done
4051cd UU
4052ans="$value"
4053rp="$orig_rp"
4054dflt="$orig_dflt"
4055rm -f getfile.ok
4056test "X$gfpthkeep" != Xy && gfpth=""
4057EOSC
4058
4059: determine root of directory hierarchy where package will be installed.
4060case "$prefix" in
4061'')
4062	dflt=`./loc . /usr/local /usr/local /local /opt /usr`
4063	;;
4064*?/)
4065	dflt=`echo "$prefix" | sed 's/.$//'`
4066	;;
4067*)
4068	dflt="$prefix"
4069	;;
4070esac
4071$cat <<EOM
4072
4073By default, $package will be installed in $dflt/bin, manual pages
4074under $dflt/man, etc..., i.e. with $dflt as prefix for all
4075installation directories. Typically this is something like /usr/local.
4076If you wish to have binaries under /usr/bin but other parts of the
4077installation under /usr/local, that's ok: you will be prompted
4078separately for each of the installation directories, the prefix being
4079only used to set the defaults.
4080
4081EOM
4082fn=d~
4083rp='Installation prefix to use?'
4084. ./getfile
4085oldprefix=''
4086case "$prefix" in
4087'') ;;
4088*)
4089	case "$ans" in
4090	"$prefix") ;;
4091	*) oldprefix="$prefix";;
4092	esac
4093	;;
4094esac
4095prefix="$ans"
4096prefixexp="$ansexp"
4097
4098: allow them to override the AFS root
4099case "$afsroot" in
4100'')	afsroot=/afs ;;
4101*)	afsroot=$afsroot ;;
4102esac
4103
4104: is AFS running?
4105echo " "
4106case "$afs" in
4107$define|true)	afs=true ;;
4108$undef|false)	afs=false ;;
4109*)	if $test -d $afsroot; then
4110		afs=true
4111	else
4112		afs=false
4113	fi
4114	;;
4115esac
4116if $afs; then
4117	echo "AFS may be running... I'll be extra cautious then..." >&4
4118else
4119	echo "AFS does not seem to be running..." >&4
4120fi
4121
4122: determine installation prefix for where package is to be installed.
4123if $afs; then
4124$cat <<EOM
4125
4126Since you are running AFS, I need to distinguish the directory in which
4127files will reside from the directory in which they are installed (and from
4128which they are presumably copied to the former directory by occult means).
4129
4130EOM
4131	case "$installprefix" in
4132	'') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
4133	*) dflt="$installprefix";;
4134	esac
4135else
4136$cat <<EOM
4137
4138In some special cases, particularly when building $package for distribution,
4139it is convenient to distinguish the directory in which files should be
4140installed from the directory ($prefix) in which they will
4141eventually reside.  For most users, these two directories are the same.
4142
4143EOM
4144	case "$installprefix" in
4145	'') dflt=$prefix ;;
4146	*) dflt=$installprefix;;
4147	esac
4148fi
4149fn=d~
4150rp='What installation prefix should I use for installing files?'
4151. ./getfile
4152installprefix="$ans"
4153installprefixexp="$ansexp"
4154
4155: Perform the prefixexp/installprefixexp correction if necessary
4156cat <<EOS >installprefix
4157$startsh
4158EOS
4159cat <<'EOSC' >>installprefix
4160: Change installation prefix, if necessary.
4161if $test X"$prefix" != X"$installprefix"; then
4162    eval "install${prefixvar}=\`echo \$${prefixvar}exp | sed \"s#^\$prefixexp#\$installprefixexp#\"\`"
4163else
4164    eval "install${prefixvar}=\"\$${prefixvar}exp\""
4165fi
4166EOSC
4167chmod +x installprefix
4168$eunicefix installprefix
4169
4170: Set variables such as privlib and privlibexp from the output of ./getfile
4171: performing the prefixexp/installprefixexp correction if necessary.
4172cat <<EOS >setprefixvar
4173$startsh
4174EOS
4175cat <<'EOSC' >>setprefixvar
4176eval "${prefixvar}=\"\$ans\""
4177eval "${prefixvar}exp=\"\$ansexp\""
4178. ./installprefix
4179EOSC
4180chmod +x setprefixvar
4181$eunicefix setprefixvar
4182
4183: set up the script used to warn in case of inconsistency
4184cat <<EOS >whoa
4185$startsh
4186EOS
4187cat <<'EOSC' >>whoa
4188dflt=y
4189case "$hint" in
4190    recommended)
4191	case "$hintfile" in
4192	'')	echo "The $hint value for \$$var on this machine was \"$was\"!" >&4
4193		;;
4194	*)	echo "Hmm.  Based on the hints in hints/$hintfile.sh, " >&4
4195		echo "the $hint value for \$$var on this machine was \"$was\"!" >&4
4196		;;
4197	esac
4198	;;
4199    *)	echo " "
4200	echo "*** WHOA THERE!!! ***" >&4
4201	echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
4202	;;
4203esac
4204rp="    Keep the $hint value?"
4205. ./myread
4206case "$ans" in
4207y) td=$was; tu=$was;;
4208esac
4209EOSC
4210
4211: function used to set '$1' to '$val'
4212setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
4213case "$val$was" in
4214$define$undef) . ./whoa; eval "$var=\$td";;
4215$undef$define) . ./whoa; eval "$var=\$tu";;
4216*) eval "$var=$val";;
4217esac'
4218
4219: get the patchlevel
4220echo " "
4221echo "Getting the current patchlevel..." >&4
4222if $test -r $rsrc/patchlevel.h;then
4223	revision=`awk '/define[ 	]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
4224	patchlevel=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
4225	subversion=`awk '/define[ 	]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
4226	api_revision=`awk '/define[ 	]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
4227	api_version=`awk '/define[ 	]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
4228	api_subversion=`awk '/define[ 	]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
4229	perl_patchlevel=`egrep ',"(MAINT|SMOKE)[0-9][0-9]*"' $rsrc/patchlevel.h|tail -1|sed 's/[^0-9]//g'`
4230else
4231	revision=0
4232	patchlevel=0
4233	subversion=0
4234	api_revision=0
4235	api_version=0
4236	api_subversion=0
4237	perl_patchlevel=0
4238	$echo "(You do not have patchlevel.h.  Eek.)"
4239fi
4240: Define a handy string here to avoid duplication in myconfig.SH and configpm.
4241version_patchlevel_string="version $patchlevel subversion $subversion"
4242case "$perl_patchlevel" in
42430|'') ;;
4244*)  perl_patchlevel=`echo $perl_patchlevel | sed 's/.* //'`
4245    version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel"
4246    ;;
4247esac
4248
4249$echo "(You have $package $version_patchlevel_string.)"
4250
4251case "$osname" in
4252dos|vms)
4253	: XXX Should be a Configure test for double-dots in filenames.
4254	version=`echo $revision $patchlevel $subversion | \
4255		 $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
4256	api_versionstring=`echo $api_revision $api_version $api_subversion | \
4257		 $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
4258	;;
4259*)
4260	version=`echo $revision $patchlevel $subversion | \
4261		 $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
4262	api_versionstring=`echo $api_revision $api_version $api_subversion | \
4263		 $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
4264	;;
4265esac
4266: Special case the 5.005_xx maintenance series, which used 5.005
4267: without any subversion label as a subdirectory in $sitelib
4268if test "${api_revision}${api_version}${api_subversion}" = "550"; then
4269	api_versionstring='5.005'
4270fi
4271
4272: Do we want threads support and if so, what type
4273case "$usethreads" in
4274$define|true|[yY]*)     dflt='y';;
4275*)     # Catch case where user specified ithreads or 5005threads but
4276       # forgot -Dusethreads (A.D. 4/2002)
4277       case "$useithreads$use5005threads" in
4278       *$define*)	dflt='y';;
4279       *)		dflt='n';;
4280       esac
4281       ;;
4282esac
4283cat <<EOM
4284
4285Perl can be built to offer a form of threading support on some systems
4286To do so, Configure can be run with -Dusethreads.
4287
4288Note that Perl built with threading support runs slightly slower
4289and uses slightly more memory than plain Perl.
4290
4291If this doesn't make any sense to you, just accept the default '$dflt'.
4292EOM
4293rp='Build a threading Perl?'
4294. ./myread
4295case "$ans" in
4296y|Y)    val="$define" ;;
4297*)      val="$undef" ;;
4298esac
4299set usethreads
4300eval $setvar
4301
4302if $test $patchlevel -lt 9; then
4303    case "$usethreads" in
4304    $define)
4305	: Default to ithreads unless overridden on command line or with
4306	: old config.sh
4307	dflt='y'
4308	case "$use5005threads" in
4309		$define|true|[yY]*)
4310			echo "5.005 threads are no longer supported"
4311			exit 1
4312		;;
4313	esac
4314	case "$useithreads" in
4315		$undef|false|[nN]*) dflt='n';;
4316	esac
4317	rp='Use the newer interpreter-based ithreads?'
4318	. ./myread
4319	case "$ans" in
4320	y|Y)    val="$define" ;;
4321	*)      val="$undef" ;;
4322	esac
4323	set useithreads
4324	eval $setvar
4325	: Now set use5005threads to the opposite value.
4326	case "$useithreads" in
4327	$define) val="$undef" ;;
4328	*) val="$define" ;;
4329	esac
4330	set use5005threads
4331	eval $setvar
4332	;;
4333    *)
4334	useithreads="$undef"
4335	use5005threads="$undef"
4336	;;
4337    esac
4338
4339    case "$useithreads$use5005threads" in
4340    "$define$define")
4341	$cat >&4 <<EOM
4342
4343You cannot have both the ithreads and the 5.005 threads enabled
4344at the same time.  Disabling the 5.005 threads since they are
4345much less stable than the ithreads.
4346
4347EOM
4348	use5005threads="$undef"
4349	;;
4350    esac
4351
4352else
4353: perl-5.9.x and later
4354
4355    if test X"$usethreads" = "X$define"; then
4356	case "$use5005threads" in
4357	    $define|true|[yY]*)
4358		$cat >&4 <<EOM
4359
43605.005 threads has been removed for 5.10.  Perl will be built using ithreads.
4361
4362EOM
4363	    ;;
4364	esac
4365    fi
4366
4367    use5005threads="$undef"
4368    useithreads="$usethreads"
4369fi
4370
4371case "$d_oldpthreads" in
4372'')	: Configure tests would be welcome here.  For now, assume undef.
4373	val="$undef" ;;
4374*)	val="$d_oldpthreads" ;;
4375esac
4376set d_oldpthreads
4377eval $setvar
4378
4379
4380: Look for a hint-file generated 'call-back-unit'.  If the
4381: user has specified that a threading perl is to be built,
4382: we may need to set or change some other defaults.
4383if $test -f usethreads.cbu; then
4384    echo "Your platform has some specific hints regarding threaded builds, using them..."
4385    . ./usethreads.cbu
4386else
4387    case "$usethreads" in
4388	"$define"|true|[yY]*)
4389		$cat <<EOM
4390(Your platform does not have any specific hints for threaded builds.
4391 Assuming POSIX threads, then.)
4392EOM
4393	;;
4394    esac
4395fi
4396
4397: Check if multiplicity is required
4398cat <<EOM
4399
4400Perl can be built so that multiple Perl interpreters can coexist
4401within the same Perl executable.
4402EOM
4403
4404case "$useithreads" in
4405$define)
4406	cat <<EOM
4407This multiple interpreter support is required for interpreter-based threads.
4408EOM
4409	val="$define"
4410	;;
4411*)	case "$usemultiplicity" in
4412	$define|true|[yY]*)	dflt='y';;
4413	*) dflt='n';;
4414	esac
4415	echo " "
4416	echo "If this doesn't make any sense to you, just accept the default '$dflt'."
4417	rp='Build Perl for multiplicity?'
4418	. ./myread
4419	case "$ans" in
4420	y|Y)	val="$define" ;;
4421	*)      val="$undef" ;;
4422	esac
4423	;;
4424esac
4425set usemultiplicity
4426eval $setvar
4427
4428: Check if morebits is requested
4429case "$usemorebits" in
4430"$define"|true|[yY]*)
4431	use64bitint="$define"
4432	uselongdouble="$define"
4433	usemorebits="$define"
4434	;;
4435*)	usemorebits="$undef"
4436	;;
4437esac
4438
4439: Determine the C compiler to be used
4440echo " "
4441case "$cc" in
4442'') dflt=cc;;
4443*) dflt="$cc";;
4444esac
4445rp="Use which C compiler?"
4446. ./myread
4447cc="$ans"
4448
4449: See whether they have no cc but they do have gcc
4450. ./trygcc
4451if $test -f cc.cbu; then
4452    . ./cc.cbu
4453fi
4454. ./checkcc
4455
4456: make some quick guesses about what we are up against
4457echo " "
4458$echo $n "Hmm...  $c"
4459echo exit 1 >bsd
4460echo exit 1 >usg
4461echo exit 1 >v7
4462echo exit 1 >osf1
4463echo exit 1 >eunice
4464echo exit 1 >xenix
4465echo exit 1 >venix
4466echo exit 1 >os2
4467d_bsd="$undef"
4468$cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null
4469if test -f /osf_boot || $contains 'OSF/1' $sysroot/usr/include/ctype.h >/dev/null 2>&1
4470then
4471	echo "Looks kind of like an OSF/1 system, but we'll see..."
4472	echo exit 0 >osf1
4473elif test `echo abc | $tr a-z A-Z` = Abc ; then
4474	xxx=`./loc addbib blurfl $pth`
4475	if $test -f $xxx; then
4476	echo "Looks kind of like a USG system with BSD features, but we'll see..."
4477		echo exit 0 >bsd
4478		echo exit 0 >usg
4479	else
4480		if $contains SIGTSTP foo >/dev/null 2>&1 ; then
4481			echo "Looks kind of like an extended USG system, but we'll see..."
4482		else
4483			echo "Looks kind of like a USG system, but we'll see..."
4484		fi
4485		echo exit 0 >usg
4486	fi
4487elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
4488	echo "Looks kind of like a BSD system, but we'll see..."
4489	d_bsd="$define"
4490	echo exit 0 >bsd
4491else
4492	echo "Looks kind of like a Version 7 system, but we'll see..."
4493	echo exit 0 >v7
4494fi
4495case "$eunicefix" in
4496*unixtovms*)
4497	$cat <<'EOI'
4498There is, however, a strange, musty smell in the air that reminds me of
4499something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
4500EOI
4501	echo exit 0 >eunice
4502	d_eunice="$define"
4503: it so happens the Eunice I know will not run shell scripts in Unix format
4504	;;
4505*)
4506	echo " "
4507	echo "Congratulations.  You aren't running Eunice."
4508	d_eunice="$undef"
4509	;;
4510esac
4511: Detect OS2.  The p_ variable is set above in the Head.U unit.
4512: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
4513: semicolon as a patch separator
4514case "$p_" in
4515:) ;;
4516*)
4517	$cat <<'EOI'
4518I have the feeling something is not exactly right, however...don't tell me...
4519lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
4520(Or you may be running DOS with DJGPP.)
4521EOI
4522	echo exit 0 >os2
4523	;;
4524esac
4525if test -f /xenix; then
4526	echo "Actually, this looks more like a XENIX system..."
4527	echo exit 0 >xenix
4528	d_xenix="$define"
4529else
4530	echo " "
4531	echo "It's not Xenix..."
4532	d_xenix="$undef"
4533fi
4534chmod +x xenix
4535$eunicefix xenix
4536if test -f /venix; then
4537	echo "Actually, this looks more like a VENIX system..."
4538	echo exit 0 >venix
4539else
4540	echo " "
4541	if ./xenix; then
4542		: null
4543	else
4544		echo "Nor is it Venix..."
4545	fi
4546fi
4547chmod +x bsd usg v7 osf1 eunice xenix venix os2
4548$eunicefix bsd usg v7 osf1 eunice xenix venix os2
4549$rm -f foo
4550
4551: Check if we are using GNU gcc and what its version is
4552echo " "
4553echo "Checking for GNU cc in disguise and/or its version number..." >&4
4554$cat >try.c <<EOM
4555#include <stdio.h>
4556int main() {
4557#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
4558#ifdef __VERSION__
4559	printf("%s\n", __VERSION__);
4560#else
4561	printf("%s\n", "1");
4562#endif
4563#endif
4564	return(0);
4565}
4566EOM
4567if $cc -o try $ccflags $ldflags try.c; then
4568	gccversion=`$run ./try`
4569	case "$gccversion" in
4570	'') echo "You are not using GNU cc." ;;
4571	*)  echo "You are using GNU cc $gccversion."
4572	    ccname=gcc
4573	    ;;
4574	esac
4575else
4576	echo " "
4577	echo "*** WHOA THERE!!! ***" >&4
4578	echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
4579	case "$knowitall" in
4580	'')
4581	echo "    You'd better start hunting for one and let me know about it." >&4
4582		exit 1
4583		;;
4584	esac
4585fi
4586$rm -f try try.*
4587case "$gccversion" in
45881*) cpp=`./loc gcc-cpp $cpp $pth` ;;
4589esac
4590case "$gccversion" in
4591'') gccosandvers='' ;;
4592*) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
4593   gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
4594   gccshortvers=''
4595   case "$gccosandvers" in
4596   $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
4597   $osname$osvers) ;; # looking good
4598   $osname*) cat <<EOM >&4
4599
4600*** WHOA THERE!!! ***
4601
4602    Your gcc has not been compiled for the exact release of
4603    your operating system ($gccosandvers versus $osname$osvers).
4604
4605    In general it is a good idea to keep gcc synchronized with
4606    the operating system because otherwise serious problems
4607    may ensue when trying to compile software, like Perl.
4608
4609    I'm trying to be optimistic here, though, and will continue.
4610    If later during the configuration and build icky compilation
4611    problems appear (headerfile conflicts being the most common
4612    manifestation), I suggest reinstalling the gcc to match
4613    your operating system release.
4614
4615EOM
4616      ;;
4617   *) gccosandvers='' ;; # failed to parse, better be silent
4618   esac
4619   ;;
4620esac
4621case "$ccname" in
4622'') ccname="$cc" ;;
4623esac
4624
4625# gcc 3.* complain about adding -Idirectories that they already know about,
4626# so we will take those off from locincpth.
4627case "$gccversion" in
46283*)
4629    echo "main(){}">try.c
4630    for incdir in $locincpth; do
4631       warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
4632	     grep '^c[cp]p*[01]: warning: changing search order '`
4633       if test "X$warn" != X; then
4634	   locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
4635       fi
4636    done
4637    $rm -f try try.*
4638esac
4639
4640# gcc 4.9 by default does some optimizations that break perl.
4641# see ticket 121505.
4642#
4643# The -fwrapv disables those optimizations (and probably others,) so
4644# for gcc 4.9 (and later, since the optimizations probably won't go
4645# away), add -fwrapv unless the user requests -fno-wrapv, which
4646# disables -fwrapv, or if the user requests -fsanitize=undefined,
4647# which turns the overflows -fwrapv ignores into runtime errors.
4648case "$gccversion" in
46494.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*)
4650    case "$ccflags" in
4651    *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
4652    *) ccflags="$ccflags -fwrapv" ;;
4653    esac
4654esac
4655
4656: What should the include directory be ?
4657: Use sysroot if set, so findhdr looks in the right place.
4658echo " "
4659$echo $n "Hmm...  $c"
4660dflt="$sysroot/usr/include"
4661incpath=''
4662mips_type=''
4663if $test -f /bin/mips && /bin/mips; then
4664	echo "Looks like a MIPS system..."
4665	$cat >usr.c <<'EOCP'
4666#ifdef SYSTYPE_BSD43
4667/bsd43
4668#endif
4669EOCP
4670	if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
4671		dflt='/bsd43/usr/include'
4672		incpath='/bsd43'
4673		mips_type='BSD 4.3'
4674	else
4675		mips_type='System V'
4676	fi
4677	$rm -f usr.c usr.out
4678	echo "and you're compiling with the $mips_type compiler and libraries."
4679	xxx_prompt=y
4680	echo "exit 0" >mips
4681else
4682	echo "Doesn't look like a MIPS system."
4683	xxx_prompt=n
4684	echo "exit 1" >mips
4685fi
4686chmod +x mips
4687$eunicefix mips
4688case "$usrinc" in
4689'') ;;
4690*) dflt="$usrinc";;
4691esac
4692case "$xxx_prompt" in
4693y)	fn=d/
4694	echo " "
4695	rp='Where are the include files you want to use?'
4696	. ./getfile
4697	usrinc="$ans"
4698	;;
4699*)	usrinc="$dflt"
4700	;;
4701esac
4702
4703: see how we invoke the C preprocessor
4704echo " "
4705echo "Now, how can we feed standard input to your C preprocessor..." >&4
4706cat <<'EOT' >testcpp.c
4707#define ABC abc
4708#define XYZ xyz
4709ABC.XYZ
4710EOT
4711cd ..
4712if test ! -f cppstdin; then
4713	if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
4714		# AIX cc -E doesn't show the absolute headerfile
4715		# locations but we'll cheat by using the -M flag.
4716		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
4717	else
4718		echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
4719	fi
4720else
4721	echo "Keeping your $hint cppstdin wrapper."
4722fi
4723chmod 755 cppstdin
4724wrapper=`pwd`/cppstdin
4725ok='false'
4726cd UU
4727
4728if $test "X$cppstdin" != "X" && \
4729	$cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
4730	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4731then
4732	echo "You used to use $cppstdin $cppminus so we'll use that again."
4733	case "$cpprun" in
4734	'') echo "But let's see if we can live without a wrapper..." ;;
4735	*)
4736		if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
4737			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4738		then
4739			echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
4740			ok='true'
4741		else
4742			echo "(However, $cpprun $cpplast does not work, let's see...)"
4743		fi
4744		;;
4745	esac
4746else
4747	case "$cppstdin" in
4748	'') ;;
4749	*)
4750		echo "Good old $cppstdin $cppminus does not seem to be of any help..."
4751		;;
4752	esac
4753fi
4754
4755if $ok; then
4756	: nothing
4757elif echo 'Maybe "'"$cc"' -E" will work...'; \
4758	$cc -E <testcpp.c >testcpp.out 2>&1; \
4759	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4760	echo "Yup, it does."
4761	x_cpp="$cc $cppflags -E"
4762	x_minus='';
4763elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
4764	$cc -E - <testcpp.c >testcpp.out 2>&1; \
4765	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4766	echo "Yup, it does."
4767	x_cpp="$cc $cppflags -E"
4768	x_minus='-';
4769elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
4770	$cc -P <testcpp.c >testcpp.out 2>&1; \
4771	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4772	echo "Yipee, that works!"
4773	x_cpp="$cc $cppflags -P"
4774	x_minus='';
4775elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
4776	$cc -P - <testcpp.c >testcpp.out 2>&1; \
4777	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4778	echo "At long last!"
4779	x_cpp="$cc $cppflags -P"
4780	x_minus='-';
4781elif echo 'No such luck, maybe "'$cpp'" will work...'; \
4782	$cpp <testcpp.c >testcpp.out 2>&1; \
4783	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4784	echo "It works!"
4785	x_cpp="$cpp $cppflags"
4786	x_minus='';
4787elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
4788	$cpp - <testcpp.c >testcpp.out 2>&1; \
4789	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4790	echo "Hooray, it works!  I was beginning to wonder."
4791	x_cpp="$cpp $cppflags"
4792	x_minus='-';
4793elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
4794	$wrapper <testcpp.c >testcpp.out 2>&1; \
4795	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4796	x_cpp="$wrapper"
4797	x_minus=''
4798	echo "Eureka!"
4799else
4800	dflt=''
4801	rp="No dice.  I can't find a C preprocessor.  Name one:"
4802	. ./myread
4803	x_cpp="$ans"
4804	x_minus=''
4805	$x_cpp <testcpp.c >testcpp.out 2>&1
4806	if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4807		echo "OK, that will do." >&4
4808	else
4809echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
4810		exit 1
4811	fi
4812fi
4813
4814case "$ok" in
4815false)
4816	cppstdin="$x_cpp"
4817	cppminus="$x_minus"
4818	cpprun="$x_cpp"
4819	cpplast="$x_minus"
4820	set X $x_cpp
4821	shift
4822	case "$1" in
4823	"$cpp")
4824		echo "Perhaps can we force $cc -E using a wrapper..."
4825		if $wrapper <testcpp.c >testcpp.out 2>&1; \
4826			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4827		then
4828			echo "Yup, we can."
4829			cppstdin="$wrapper"
4830			cppminus='';
4831		else
4832			echo "Nope, we'll have to live without it..."
4833		fi
4834		;;
4835	esac
4836	case "$cpprun" in
4837	"$wrapper")
4838		cpprun=''
4839		cpplast=''
4840		;;
4841	esac
4842	;;
4843esac
4844
4845case "$cppstdin" in
4846"$wrapper"|'cppstdin') ;;
4847*) $rm -f $wrapper;;
4848esac
4849$rm -f testcpp.c testcpp.out
4850
4851: Adjust cppfilter for path component separator
4852case "$osname" in
4853vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
4854os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
4855*)   cppfilter='' ;;
4856esac
4857
4858: Use gcc to determine libpth and incpth
4859# If using gcc or clang, we can get better values for libpth, incpth
4860# and usrinc directly from the compiler.
4861# Note that ccname for clang is also gcc.
4862case "$ccname" in
4863    gcc)
4864	$echo 'extern int foo;' > try.c
4865	set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
4866	shift
4867	if $test $# -gt 0; then
4868	    incpth="$incpth $*"
4869	    incpth="`$echo $incpth|$sed 's/^ //'`"
4870	    for i in $*; do
4871		j="`$echo $i|$sed 's,/include$,/lib,'`"
4872		if $test -d $j; then
4873		    libpth="$libpth $j"
4874		fi
4875	    done
4876	    libpth="`$echo $libpth|$sed 's/^ //'`"
4877	    for xxx in $libpth $loclibpth $plibpth $glibpth; do
4878		if $test -d $xxx; then
4879		    case " $libpth " in
4880		    *" $xxx "*) ;;
4881		    *) libpth="$libpth $xxx";;
4882		    esac
4883		fi
4884	    done
4885	fi
4886	$rm -f try.c
4887	case "$usrinc" in
4888	'') for i in $incpth; do
4889		if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
4890		    usrinc="$i"
4891		    break
4892		fi
4893	    done
4894	    ;;
4895	esac
4896
4897	case "$usecrosscompile" in
4898	$define|true|[yY]*)
4899	    case "$incpth" in
4900		'') echo "Incpth not defined." >&4; croak=y ;;
4901		*)  echo "Using incpth '$incpth'." >&4 ;;
4902	    esac
4903	    case "$libpth" in
4904		'') echo "Libpth not defined." >&4; croak=y ;;
4905		*)  echo "Using libpth '$libpth'." >&4 ;;
4906	    esac
4907	    case "$usrinc" in
4908		'') echo "Usrinc not defined." >&4; croak=y ;;
4909		*)  echo "Using usrinc $usrinc." >&4 ;;
4910	    esac
4911	    case "$croak" in
4912		y)
4913		if test "X$sysroot" = X; then
4914		    echo "Cannot continue, aborting." >&4; exit 1
4915		else
4916		    echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
4917		fi
4918		;;
4919	    esac
4920	    ;;
4921	esac
4922    ;;
4923esac
4924
4925: Default value for incpth is just usrinc
4926case "$incpth" in
4927'') incpth="$usrinc";;
4928esac
4929
4930: Set private lib path
4931case "$plibpth" in
4932'') if ./mips; then
4933	plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
4934    fi;;
4935esac
4936case "$libpth" in
4937' ') dlist='';;
4938'') dlist="$loclibpth $plibpth $glibpth";;
4939*) dlist="$libpth";;
4940esac
4941
4942: Now check and see which directories actually exist, avoiding duplicates
4943for xxx in $dlist
4944do
4945    if $test -d $xxx; then
4946		case " $libpth " in
4947		*" $xxx "*) ;;
4948		*) libpth="$libpth $xxx";;
4949		esac
4950    fi
4951done
4952$cat <<'EOM'
4953
4954Some systems have incompatible or broken versions of libraries.  Among
4955the directories listed in the question below, please remove any you
4956know not to be holding relevant libraries, and add any that are needed.
4957Say "none" for none.
4958
4959EOM
4960
4961if test "X$sysroot" != X; then
4962    $cat <<EOM
4963You have set sysroot to $sysroot, please supply the directories excluding sysroot
4964
4965EOM
4966fi
4967
4968case "$libpth" in
4969'') dflt='none';;
4970*)
4971	set X $libpth
4972	shift
4973	dflt=${1+"$@"}
4974	;;
4975esac
4976rp="Directories to use for library searches?"
4977. ./myread
4978case "$ans" in
4979none) libpth=' ';;
4980*) libpth="$ans";;
4981esac
4982
4983: compute shared library extension
4984case "$so" in
4985'')
4986	if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
4987		dflt='sl'
4988	else
4989		dflt='so'
4990	fi
4991	;;
4992*) dflt="$so";;
4993esac
4994$cat <<EOM
4995
4996On some systems, shared libraries may be available.  Answer 'none' if
4997you want to suppress searching of shared libraries for the remainder
4998of this configuration.
4999
5000EOM
5001rp='What is the file extension used for shared libraries?'
5002. ./myread
5003so="$ans"
5004
5005: Does target system insist that shared library basenames are unique
5006$cat << EOM
5007
5008Some dynamic loaders assume that the *basename* of shared library filenames
5009are globally unique.  We'll default this to undef as we assume your system
5010is not this weird. Set to defined if you're on one of them.
5011
5012EOM
5013
5014dflt='n'
5015rp='Make shared library basenames unique?'
5016. ./myread
5017case "$ans" in
5018y|Y) val="$define" ;;
5019*)   val="$undef"  ;;
5020esac
5021set d_libname_unique
5022eval $setvar
5023
5024: Define several unixisms.
5025: Hints files or command line option can be used to override them.
5026: The convoluted testing is in case hints files set either the old
5027: or the new name.
5028case "$_exe" in
5029'')	case "$exe_ext" in
5030	'')	;;
5031	*)	_exe="$exe_ext" ;;
5032	esac
5033	;;
5034esac
5035case "$_a" in
5036'')	case "$lib_ext" in
5037    '')	_a='.a';;
5038	*)	_a="$lib_ext" ;;
5039	esac
5040	;;
5041esac
5042case "$_o" in
5043'') case "$obj_ext" in
5044	'')	_o='.o';;
5045	*)	_o="$obj_ext";;
5046	esac
5047	;;
5048esac
5049case "$p_" in
5050'') case "$path_sep" in
5051	'')	p_=':';;
5052	*)	p_="$path_sep";;
5053	esac
5054	;;
5055esac
5056exe_ext=$_exe
5057lib_ext=$_a
5058obj_ext=$_o
5059path_sep=$p_
5060
5061rm_try="$rm -f try try$_exe a.out .out try.[cho] try.$_o core core.try* try.core*"
5062
5063: Which makefile gets called first.  This is used by make depend.
5064case "$firstmakefile" in
5065'') firstmakefile='makefile';;
5066esac
5067
5068: Check is we will use socks
5069case "$usesocks" in
5070$define|true|[yY]*)	dflt='y';;
5071*) dflt='n';;
5072esac
5073cat <<EOM
5074
5075Perl can be built to use the SOCKS proxy protocol library.  To do so,
5076Configure must be run with -Dusesocks.  If you use SOCKS you also need
5077to use the PerlIO abstraction layer, this will be implicitly selected.
5078
5079If this doesn't make any sense to you, just accept the default '$dflt'.
5080EOM
5081rp='Build Perl for SOCKS?'
5082. ./myread
5083case "$ans" in
5084y|Y)	val="$define" ;;
5085*)      val="$undef" ;;
5086esac
5087set usesocks
5088eval $setvar
5089
5090: Check for uselongdouble support
5091case "$ccflags" in
5092*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
5093esac
5094
5095case "$uselongdouble" in
5096$define|true|[yY]*)	dflt='y';;
5097*) dflt='n';;
5098esac
5099cat <<EOM
5100
5101Perl can be built to take advantage of long doubles which
5102(if available) may give more accuracy and range for floating point numbers.
5103
5104If this doesn't make any sense to you, just accept the default '$dflt'.
5105EOM
5106rp='Try to use long doubles if available?'
5107. ./myread
5108case "$ans" in
5109y|Y) 	val="$define"	;;
5110*)      val="$undef"	;;
5111esac
5112set uselongdouble
5113eval $setvar
5114
5115case "$uselongdouble" in
5116true|[yY]*) uselongdouble="$define" ;;
5117esac
5118
5119: Look for a hint-file generated 'call-back-unit'.  If the
5120: user has specified that long doubles should be used,
5121: we may need to set or change some other defaults.
5122if $test -f uselongdouble.cbu; then
5123    echo "Your platform has some specific hints regarding long doubles, using them..."
5124    . ./uselongdouble.cbu
5125else
5126    case "$uselongdouble" in
5127	$define)
5128		$cat <<EOM
5129(Your platform does not have any specific hints for long doubles.)
5130EOM
5131	;;
5132    esac
5133fi
5134
5135: Looking for optional libraries
5136echo " "
5137echo "Checking for optional libraries..." >&4
5138case "$libs" in
5139' '|'') dflt='';;
5140*) dflt="$libs";;
5141esac
5142case "$libswanted" in
5143'') libswanted='c_s';;
5144esac
5145case "$usesocks" in
5146"$define") libswanted="$libswanted socks5 socks5_sh" ;;
5147esac
5148libsfound=''
5149libsfiles=''
5150libsdirs=''
5151libspath=''
5152for thisdir in $libpth $xlibpth; do
5153  test -d $thisdir && libspath="$libspath $thisdir"
5154done
5155for thislib in $libswanted; do
5156	for thisdir in $libspath; do
5157	    xxx=''
5158	    if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
5159		xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|sed -n '$p'`
5160	        $test -f "$xxx" && eval $libscheck
5161		$test -f "$xxx" && libstyle=shared
5162	    fi
5163	    if test ! -f "$xxx"; then
5164		xxx=$thisdir/lib$thislib.$so
5165	        $test -f "$xxx" && eval $libscheck
5166		$test -f "$xxx" && libstyle=shared
5167	    fi
5168	    if test ! -f "$xxx"; then
5169		xxx=$thisdir/lib$thislib$_a
5170	        $test -f "$xxx" && eval $libscheck
5171		$test -f "$xxx" && libstyle=static
5172	    fi
5173	    if test ! -f "$xxx"; then
5174		xxx=$thisdir/$thislib$_a
5175	        $test -f "$xxx" && eval $libscheck
5176		$test -f "$xxx" && libstyle=static
5177	    fi
5178	    if test ! -f "$xxx"; then
5179		xxx=$thisdir/lib${thislib}_s$_a
5180	        $test -f "$xxx" && eval $libscheck
5181		$test -f "$xxx" && libstyle=static
5182		$test -f "$xxx" && thislib=${thislib}_s
5183	    fi
5184	    if test ! -f "$xxx"; then
5185		xxx=$thisdir/Slib$thislib$_a
5186	        $test -f "$xxx" && eval $libscheck
5187		$test -f "$xxx" && libstyle=static
5188	    fi
5189	    if $test -f "$xxx"; then
5190		case "$libstyle" in
5191		shared) echo "Found -l$thislib (shared)." ;;
5192		static) echo "Found -l$thislib." ;;
5193		*)      echo "Found -l$thislib ($libstyle)." ;;
5194		esac
5195		case " $dflt " in
5196		*"-l$thislib "*);;
5197		*) dflt="$dflt -l$thislib"
5198                   libsfound="$libsfound $xxx"
5199                   yyy=`basename $xxx`
5200                   libsfiles="$libsfiles $yyy"
5201                   yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"`
5202                   case " $libsdirs " in
5203                   *" $yyy "*) ;;
5204                   *) libsdirs="$libsdirs $yyy" ;;
5205                   esac
5206		   ;;
5207		esac
5208		break
5209	    fi
5210	done
5211	if $test ! -f "$xxx"; then
5212	    echo "No -l$thislib."
5213	fi
5214done
5215set X $dflt
5216shift
5217dflt="$*"
5218case "$libs" in
5219'') dflt="$dflt";;
5220*) dflt="$libs";;
5221esac
5222case "$dflt" in
5223' '|'') dflt='none';;
5224esac
5225
5226$cat <<EOM
5227
5228In order to compile $package on your machine, a number of libraries
5229are usually needed.  Include any other special libraries here as well.
5230Say "none" for none.  The default list is almost always right.
5231EOM
5232
5233echo " "
5234rp="What libraries to use?"
5235. ./myread
5236case "$ans" in
5237none) libs=' ';;
5238*) libs="$ans";;
5239esac
5240
5241: determine optimization, if desired, or use for debug flag also
5242case "$optimize" in
5243' '|$undef) dflt='none';;
5244'') dflt='-O';;
5245*) dflt="$optimize";;
5246esac
5247$cat <<EOH
5248
5249By default, $package compiles with the -O flag to use the optimizer.
5250Alternately, you might want to use the symbolic debugger, which uses
5251the -g flag (on traditional Unix systems).  Either flag can be
5252specified here.  To use neither flag, specify the word "none".
5253
5254EOH
5255rp="What optimizer/debugger flag should be used?"
5256. ./myread
5257optimize="$ans"
5258case "$optimize" in
5259'none') optimize=" ";;
5260esac
5261
5262: Check what DEBUGGING is required from the command line
5263: -DEBUGGING      or -DDEBUGGING or
5264: -DEBUGGING=both			= -g + -DDEBUGGING
5265: -DEBUGGING=-g   or -Doptimize=-g	= -g
5266: -DEBUGGING=none or -UDEBUGGING	=
5267: -DEBUGGING=old  or -DEBUGGING=default	= ? $optimize
5268case "$EBUGGING" in
5269'')	;;
5270*)	DEBUGGING=$EBUGGING ;;
5271esac
5272
5273case "$DEBUGGING" in
5274-g|both|$define)
5275    case "$optimize" in
5276	*-g*) ;;
5277	*)    optimize="$optimize -g" ;;
5278    esac ;;
5279none|$undef)
5280    case "$optimize" in
5281	*-g*)	set `echo "X $optimize " | sed 's/ -g / /'`
5282		shift
5283		optimize="$*"
5284		;;
5285    esac ;;
5286esac
5287
5288dflt=''
5289case "$DEBUGGING" in
5290both|$define) dflt='-DDEBUGGING'
5291esac
5292
5293: argument order is deliberate, as the flag will start with - which set could
5294: think is an option
5295checkccflag='check=$1; flag=$2; callback=$3;
5296echo " ";
5297echo "Checking if your compiler accepts $flag" 2>&1;
5298[ "X$sysroot" != "X" ] && echo "For sysroot = $sysroot";
5299echo "int main(void) { return 0; }" > gcctest.c;
5300if $cc $_sysroot -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
5301    echo "Yes, it does." 2>&1;
5302    if $test -s gcctest.out ; then
5303        echo "But your platform does not like it:";
5304        cat gcctest.out;
5305    else
5306	case "$ccflags" in
5307	*$check*)
5308	    echo "Leaving current flags $ccflags alone." 2>&1
5309	    ;;
5310	*) dflt="$dflt $flag";
5311	    eval $callback
5312	    ;;
5313	esac
5314    fi
5315else
5316    echo "Nope, it does not, but that is ok." 2>&1;
5317fi
5318'
5319
5320: We will not override a previous value, but we might want to
5321: augment a hint file
5322case "$hint" in
5323default|recommended)
5324	case "$gccversion" in
5325	1*) dflt="$dflt -fpcc-struct-return" ;;
5326	esac
5327	case "$optimize:$DEBUGGING" in
5328	*-g*:old) dflt="$dflt -DDEBUGGING";;
5329	esac
5330	case "$gccversion" in
5331	2*) if $test -d /etc/conf/kconfig.d &&
5332			$contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
5333		then
5334			# Interactive Systems (ISC) POSIX mode.
5335			dflt="$dflt -posix"
5336		fi
5337		;;
5338	esac
5339	case "$gccversion" in
5340	1*) ;;
5341	2.[0-8]*) ;;
5342	?*)	set strict-aliasing -fno-strict-aliasing
5343		eval $checkccflag
5344		;;
5345	esac
5346	case "$gccversion" in
5347	1*) ;;
5348	2*) ;;
5349	?*) 	echo " "
5350		echo "Checking if your compiler accepts -fno-delete-null-pointer-checks" 2>&1
5351		echo 'int main(void) { return 0; }' > gcctest.c
5352		if $cc -O2 -fno-delete-null-pointer-checks -o gcctest gcctest.c; then
5353			echo "Yes, it does." 2>&1
5354			case "$ccflags" in
5355			*delete-null-pointer-checks*)
5356				echo "Leaving current flags $ccflags alone." 2>&1
5357				;;
5358			*) dflt="$dflt -fno-delete-null-pointer-checks" ;;
5359			esac
5360		else
5361			echo "Nope, it doesn't, but that's ok." 2>&1
5362		fi
5363		;;
5364	esac
5365	# For gcc, adding -pipe speeds up compilations for some, but apparently
5366	# some assemblers can't read from stdin.  (It also slows down compilations
5367	# in other cases, but those are apparently rarer these days.)  AD 5/2004.
5368	case "$gccversion" in
5369	?*)	set pipe -pipe
5370		eval $checkccflag
5371		;;
5372	esac
5373
5374	# on x86_64 (at least) we require an extra library (libssp) in the
5375	# link command line. This library is not named, so I infer that it is
5376	# an implementation detail that may change. Hence the safest approach
5377	# is to add the flag to the flags passed to the compiler at link time,
5378	# as that way the compiler can do the right implementation dependant
5379	# thing. (NWC)
5380	case "$gccversion" in
5381	?*)	set stack-protector -fstack-protector
5382		eval $checkccflag
5383		;;
5384	esac
5385	;;
5386esac
5387
5388case "$mips_type" in
5389*BSD*|'') inclwanted="$locincpth $usrinc";;
5390*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
5391esac
5392for thisincl in $inclwanted; do
5393	if $test -d $thisincl; then
5394		if $test x$thisincl != x$usrinc; then
5395			case "$dflt" in
5396			*" -I$thisincl "*);;
5397			*) dflt="$dflt -I$thisincl ";;
5398			esac
5399		fi
5400	fi
5401done
5402
5403inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
5404	xxx=true;
5405elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
5406	xxx=true;
5407else
5408	xxx=false;
5409fi;
5410if $xxx; then
5411	case "$dflt" in
5412	*$2*);;
5413	*) dflt="$dflt -D$2";;
5414	esac;
5415fi'
5416
5417set signal.h LANGUAGE_C; eval $inctest
5418
5419case "$usesocks" in
5420$define)
5421	ccflags="$ccflags -DSOCKS"
5422	;;
5423esac
5424
5425case "$hint" in
5426default|recommended) dflt="$ccflags $dflt" ;;
5427*) dflt="$ccflags";;
5428esac
5429
5430case "$dflt" in
5431''|' ') dflt=none;;
5432esac
5433
5434$cat <<EOH
5435
5436Your C compiler may want other flags.  For this question you should include
5437-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
5438but you should NOT include libraries or ld flags like -lwhatever.  If you
5439want $package to honor its debug switch, you should include -DDEBUGGING here.
5440Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
5441
5442To use no flags, specify the word "none".
5443
5444EOH
5445set X $dflt
5446shift
5447dflt=${1+"$@"}
5448rp="Any additional cc flags?"
5449. ./myread
5450case "$ans" in
5451none) ccflags='';;
5452*) ccflags="$ans";;
5453esac
5454
5455: the following weeds options from ccflags that are of no interest to cpp
5456case "$cppflags" in
5457'') cppflags="$ccflags" ;;
5458*)  cppflags="$cppflags $ccflags" ;;
5459esac
5460case "$gccversion" in
54611*) cppflags="$cppflags -D__GNUC__"
5462esac
5463case "$mips_type" in
5464'');;
5465*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
5466esac
5467case "$cppflags" in
5468'');;
5469*)
5470	echo " "
5471	echo "Let me guess what the preprocessor flags are..." >&4
5472	set X $cppflags
5473	shift
5474	cppflags=''
5475	$cat >cpp.c <<'EOM'
5476#define BLURFL foo
5477
5478BLURFL xx LFRULB
5479EOM
5480	previous=''
5481	for flag in $*
5482	do
5483		case "$flag" in
5484		-*) ftry="$flag";;
5485		*) ftry="$previous $flag";;
5486		esac
5487		if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
5488			>cpp1.out 2>/dev/null && \
5489			$cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
5490			>cpp2.out 2>/dev/null && \
5491			$contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
5492			$contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
5493		then
5494			cppflags="$cppflags $ftry"
5495			previous=''
5496		else
5497			previous="$flag"
5498		fi
5499	done
5500	set X $cppflags
5501	shift
5502	cppflags=${1+"$@"}
5503	case "$cppflags" in
5504	*-*)  echo "They appear to be: $cppflags";;
5505	esac
5506	$rm -f cpp.c cpp?.out
5507	;;
5508esac
5509
5510: flags used in final linking phase
5511case "$ldflags" in
5512'') if ./venix; then
5513		dflt='-i -z'
5514	else
5515		dflt=''
5516	fi
5517	case "$ccflags" in
5518	*-posix*) dflt="$dflt -posix" ;;
5519	esac
5520	;;
5521*) dflt="$ldflags";;
5522esac
5523# See note above about -fstack-protector
5524case "$ccflags" in
5525*-fstack-protector*)
5526	case "$dflt" in
5527	*-fstack-protector*) ;; # Don't add it again
5528	*) dflt="$dflt -fstack-protector" ;;
5529	esac
5530	;;
5531esac
5532
5533: Try to guess additional flags to pick up local libraries.
5534for thislibdir in $libpth; do
5535	case " $loclibpth " in
5536	*" $thislibdir "*)
5537		case "$dflt " in
5538		*"-L$thislibdir "*) ;;
5539		*)  dflt="$dflt -L$thislibdir" ;;
5540		esac
5541		;;
5542	esac
5543done
5544
5545case "$dflt" in
5546'') dflt='none' ;;
5547esac
5548
5549$cat <<EOH
5550
5551Your C linker may need flags.  For this question you should
5552include -L/whatever and any other flags used by the C linker, but you
5553should NOT include libraries like -lwhatever.
5554
5555Make sure you include the appropriate -L/path flags if your C linker
5556does not normally search all of the directories you specified above,
5557namely
5558	$libpth
5559To use no flags, specify the word "none".
5560
5561EOH
5562
5563rp="Any additional ld flags (NOT including libraries)?"
5564. ./myread
5565case "$ans" in
5566none) ldflags='';;
5567*) ldflags="$ans";;
5568esac
5569rmlist="$rmlist pdp11"
5570
5571: coherency check
5572echo " "
5573echo "Checking your choice of C compiler and flags for coherency..." >&4
5574$cat > try.c <<'EOF'
5575#include <stdio.h>
5576int main() { printf("Ok\n"); return(0); }
5577EOF
5578set X $cc -o try $optimize $ccflags $ldflags try.c $libs
5579shift
5580$cat >try.msg <<'EOM'
5581I've tried to compile and run the following simple program:
5582
5583EOM
5584$cat try.c >> try.msg
5585
5586$cat >> try.msg <<EOM
5587
5588I used the command:
5589
5590	$*
5591	$run ./try
5592
5593and I got the following output:
5594
5595EOM
5596dflt=y
5597if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; then
5598	if $sh -c "$run ./try " >>try.msg 2>&1; then
5599		xxx=`$run ./try`
5600		case "$xxx" in
5601		"Ok") dflt=n ;;
5602		*)    echo 'The program compiled OK, but produced no output.' >> try.msg ;;
5603		esac
5604	else
5605		echo "The program compiled OK, but exited with status $?." >>try.msg
5606		rp="You have a problem.  Shall I abort Configure"
5607		dflt=y
5608	fi
5609else
5610	echo "I can't compile the test program." >>try.msg
5611	rp="You have a BIG problem.  Shall I abort Configure"
5612	dflt=y
5613fi
5614case "$dflt" in
5615y)
5616	$cat try.msg >&4
5617	case "$knowitall" in
5618	'')
5619		echo "(The supplied flags or libraries might be incorrect.)"
5620		;;
5621	*) dflt=n;;
5622	esac
5623	echo " "
5624	. ./myread
5625	case "$ans" in
5626	n*|N*) ;;
5627	*)	echo "Ok.  Stopping Configure." >&4
5628		exit 1
5629		;;
5630	esac
5631	;;
5632n) echo "OK, that should do.";;
5633esac
5634$rm_try gcctest gcctest.out
5635
5636: define a shorthand compile call
5637compile='
5638mc_file=$1;
5639shift;
5640case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
5641echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to perlbug@perl.org" >&4;
5642exit 1;
5643fi;
5644esac;
5645$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5646: define a shorthand compile call for compilations that should be ok.
5647compile_ok='
5648mc_file=$1;
5649shift;
5650$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs;'
5651
5652: determine filename position in cpp output
5653echo " "
5654echo "Computing filename position in cpp output for #include directives..." >&4
5655case "$osname" in
5656vos) testaccess=-e ;;
5657*)   testaccess=-r ;;
5658esac
5659echo '#include <stdio.h>' > foo.c
5660$cat >fieldn <<EOF
5661$startsh
5662$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
5663$grep '^[ 	]*#.*stdio\.h' | \
5664while read cline; do
5665	pos=1
5666	set \$cline
5667	while $test \$# -gt 0; do
5668		if $test $testaccess \`echo \$1 | $tr -d '"'\`; then
5669			echo "\$pos"
5670			exit 0
5671		fi
5672		shift
5673		pos=\`expr \$pos + 1\`
5674	done
5675done
5676EOF
5677chmod +x fieldn
5678fieldn=`./fieldn`
5679$rm -f foo.c fieldn
5680case $fieldn in
5681'') pos='???';;
56821) pos=first;;
56832) pos=second;;
56843) pos=third;;
5685*) pos="${fieldn}th";;
5686esac
5687echo "Your cpp writes the filename in the $pos field of the line."
5688
5689: locate header file
5690$cat >findhdr <<EOF
5691$startsh
5692wanted=\$1
5693name=''
5694for usrincdir in $incpth
5695do
5696	if test -f \$usrincdir/\$wanted; then
5697		echo "\$usrincdir/\$wanted"
5698		exit 0
5699	fi
5700done
5701awkprg='{ print \$$fieldn }'
5702echo "#include <\$wanted>" > foo\$\$.c
5703$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
5704$cppfilter $grep "^[ 	]*#.*\$wanted" | \
5705while read cline; do
5706	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
5707	case "\$name" in
5708	*[/\\\\]\$wanted) echo "\$name"; exit 1;;
5709	*[\\\\/]\$wanted) echo "\$name"; exit 1;;
5710	*) exit 2;;
5711	esac;
5712done;
5713#
5714# status = 0: grep returned 0 lines, case statement not executed
5715# status = 1: headerfile found
5716# status = 2: while loop executed, no headerfile found
5717#
5718status=\$?
5719$rm -f foo\$\$.c;
5720if test \$status -eq 1; then
5721	exit 0;
5722fi
5723exit 1
5724EOF
5725chmod +x findhdr
5726
5727: define an alternate in-header-list? function
5728inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
5729cont=true; xxf="echo \"<\$1> found.\" >&4";
5730case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
5731*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
5732esac;
5733case $# in 4) instead=instead;; *) instead="at last";; esac;
5734while $test "$cont"; do
5735	xxx=`./findhdr $1`
5736	var=$2; eval "was=\$$2";
5737	if $test "$xxx" && $test -r "$xxx";
5738	then eval $xxf;
5739	eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
5740		cont="";
5741	else eval $xxnf;
5742	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
5743	set $yyy; shift; shift; yyy=$@;
5744	case $# in 0) cont="";;
5745	2) xxf="echo \"but I found <\$1> $instead.\" >&4";
5746		xxnf="echo \"and I did not find <\$1> either.\" >&4";;
5747	*) xxf="echo \"but I found <\$1\> instead.\" >&4";
5748		xxnf="echo \"there is no <\$1>, ...\" >&4";;
5749	esac;
5750done;
5751while $test "$yyy";
5752do set $yyy; var=$2; eval "was=\$$2";
5753	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
5754	set $yyy; shift; shift; yyy=$@;
5755done'
5756
5757: see if stdlib is available
5758set stdlib.h i_stdlib
5759eval $inhdr
5760
5761: check for lengths of integral types
5762echo " "
5763case "$intsize" in
5764'')
5765	echo "Checking to see how big your integers are..." >&4
5766	$cat >try.c <<EOCP
5767#include <stdio.h>
5768#$i_stdlib I_STDLIB
5769#ifdef I_STDLIB
5770#include <stdlib.h>
5771#endif
5772int main()
5773{
5774	printf("intsize=%d;\n", (int)sizeof(int));
5775	printf("longsize=%d;\n", (int)sizeof(long));
5776	printf("shortsize=%d;\n", (int)sizeof(short));
5777	exit(0);
5778}
5779EOCP
5780	set try
5781	if eval $compile_ok && $run ./try > /dev/null; then
5782		eval `$run ./try`
5783		echo "Your integers are $intsize bytes long."
5784		echo "Your long integers are $longsize bytes long."
5785		echo "Your short integers are $shortsize bytes long."
5786	else
5787		$cat >&4 <<EOM
5788!
5789Help! I can't compile and run the intsize test program: please enlighten me!
5790(This is probably a misconfiguration in your system or libraries, and
5791you really ought to fix it.  Still, I'll try anyway.)
5792!
5793EOM
5794		dflt=4
5795		rp="What is the size of an integer (in bytes)?"
5796		. ./myread
5797		intsize="$ans"
5798		dflt=$intsize
5799		rp="What is the size of a long integer (in bytes)?"
5800		. ./myread
5801		longsize="$ans"
5802		dflt=2
5803		rp="What is the size of a short integer (in bytes)?"
5804		. ./myread
5805		shortsize="$ans"
5806	fi
5807	;;
5808esac
5809$rm_try
5810
5811: check for long long
5812echo " "
5813echo "Checking to see if you have long long..." >&4
5814echo 'int main() { long long x = 7; return 0; }' > try.c
5815set try
5816if eval $compile; then
5817	val="$define"
5818	echo "You have long long."
5819else
5820	val="$undef"
5821	echo "You do not have long long."
5822fi
5823$rm_try
5824set d_longlong
5825eval $setvar
5826
5827: check for length of long long
5828case "${d_longlong}${longlongsize}" in
5829$define)
5830	echo " "
5831	echo "Checking to see how big your long longs are..." >&4
5832	$cat >try.c <<'EOCP'
5833#include <stdio.h>
5834int main()
5835{
5836    printf("%d\n", (int)sizeof(long long));
5837    return(0);
5838}
5839EOCP
5840	set try
5841	if eval $compile_ok; then
5842		longlongsize=`$run ./try`
5843		echo "Your long longs are $longlongsize bytes long."
5844	else
5845		dflt='8'
5846		echo " "
5847		echo "(I can't seem to compile the test program.  Guessing...)"
5848		rp="What is the size of a long long (in bytes)?"
5849		. ./myread
5850		longlongsize="$ans"
5851	fi
5852	if $test "X$longsize" = "X$longlongsize"; then
5853		echo "(That isn't any different from an ordinary long.)"
5854	fi
5855	;;
5856esac
5857$rm_try
5858
5859: see if inttypes.h is available
5860: we want a real compile instead of Inhdr because some systems
5861: have an inttypes.h which includes non-existent headers
5862echo " "
5863$cat >try.c <<EOCP
5864#include <inttypes.h>
5865int main() {
5866	static int32_t foo32 = 0x12345678;
5867}
5868EOCP
5869set try
5870if eval $compile; then
5871	echo "<inttypes.h> found." >&4
5872	val="$define"
5873else
5874	echo "<inttypes.h> NOT found." >&4
5875	val="$undef"
5876fi
5877$rm_try
5878set i_inttypes
5879eval $setvar
5880
5881: check for int64_t
5882echo " "
5883echo "Checking to see if you have int64_t..." >&4
5884$cat >try.c <<EOCP
5885#include <sys/types.h>
5886#$i_inttypes I_INTTYPES
5887#ifdef I_INTTYPES
5888#include <inttypes.h>
5889#endif
5890int main() { int64_t x = 7; }
5891EOCP
5892set try
5893if eval $compile; then
5894	val="$define"
5895	echo "You have int64_t."
5896else
5897	val="$undef"
5898	echo "You do not have int64_t."
5899fi
5900$rm_try
5901set d_int64_t
5902eval $setvar
5903
5904: Check if 64bit ints have a quad type
5905echo " "
5906echo "Checking which 64-bit integer type we could use..." >&4
5907
5908case "$intsize" in
59098) val=int
5910   set quadtype
5911   eval $setvar
5912   val='"unsigned int"'
5913   set uquadtype
5914   eval $setvar
5915   quadkind=1
5916   ;;
5917*) case "$longsize" in
5918   8) val=long
5919      set quadtype
5920      eval $setvar
5921      val='"unsigned long"'
5922      set uquadtype
5923      eval $setvar
5924      quadkind=2
5925      ;;
5926   *) case "$d_longlong:$longlongsize" in
5927      define:8)
5928        val='"long long"'
5929        set quadtype
5930        eval $setvar
5931        val='"unsigned long long"'
5932        set uquadtype
5933        eval $setvar
5934        quadkind=3
5935        ;;
5936      *) case "$d_int64_t" in
5937         define)
5938           val=int64_t
5939           set quadtype
5940           eval $setvar
5941           val=uint64_t
5942           set uquadtype
5943           eval $setvar
5944           quadkind=4
5945           ;;
5946         esac
5947         ;;
5948      esac
5949      ;;
5950   esac
5951   ;;
5952esac
5953
5954case "$quadtype" in
5955'')	echo "Alas, no 64-bit integer types in sight." >&4
5956	d_quad="$undef"
5957	;;
5958*)	echo "We could use '$quadtype' for 64-bit integers." >&4
5959	d_quad="$define"
5960	;;
5961esac
5962
5963: Do we want 64bit support
5964case "$uselonglong" in
5965"$define"|true|[yY]*)
5966	cat <<EOM >&4
5967
5968*** Configure -Duselonglong is deprecated, using -Duse64bitint instead.
5969EOM
5970	use64bitint="$define"
5971	;;
5972esac
5973case "$use64bits" in
5974"$define"|true|[yY]*)
5975	cat <<EOM >&4
5976
5977*** Configure -Duse64bits is deprecated, using -Duse64bitint instead.
5978EOM
5979	use64bitint="$define"
5980	;;
5981esac
5982case "$use64bitints" in
5983"$define"|true|[yY]*)
5984	cat <<EOM >&4
5985
5986*** There is no Configure -Duse64bitints, using -Duse64bitint instead.
5987EOM
5988	use64bitint="$define"
5989	;;
5990esac
5991case "$use64bitsint" in
5992"$define"|true|[yY]*)
5993	cat <<EOM >&4
5994
5995*** There is no Configure -Duse64bitsint, using -Duse64bitint instead.
5996EOM
5997	use64bitint="$define"
5998	;;
5999esac
6000case "$uselonglongs" in
6001"$define"|true|[yY]*)
6002	cat <<EOM >&4
6003
6004*** There is no Configure -Duselonglongs, using -Duse64bitint instead.
6005EOM
6006	use64bitint="$define"
6007	;;
6008esac
6009case "$use64bitsall" in
6010"$define"|true|[yY]*)
6011	cat <<EOM >&4
6012
6013*** There is no Configure -Duse64bitsall, using -Duse64bitall instead.
6014EOM
6015	use64bitall="$define"
6016	;;
6017esac
6018
6019case "$ccflags" in
6020*-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
6021esac
6022case "$use64bitall" in
6023"$define"|true|[yY]*) use64bitint="$define" ;;
6024esac
6025
6026case "$longsize" in
60278) cat <<EOM
6028
6029You have natively 64-bit long integers.
6030EOM
6031   val="$define"
6032   ;;
6033*) case "$use64bitint" in
6034   "$define"|true|[yY]*) dflt='y';;
6035   *) dflt='n';;
6036   esac
6037   case "$d_quad" in
6038   "$define") ;;
6039   *) dflt='n' ;;
6040   esac
6041   cat <<EOM
6042
6043Perl can be built to take advantage of 64-bit integer types
6044on some systems.  To do so, Configure can be run with -Duse64bitint.
6045Choosing this option will most probably introduce binary incompatibilities.
6046
6047If this doesn't make any sense to you, just accept the default '$dflt'.
6048(The default has been chosen based on your configuration.)
6049EOM
6050   rp='Try to use 64-bit integers, if available?'
6051   . ./myread
6052   case "$ans" in
6053   [yY]*) val="$define" ;;
6054   *)     val="$undef"  ;;
6055   esac
6056   ;;
6057esac
6058set use64bitint
6059eval $setvar
6060
6061case "$use64bitall" in
6062"$define"|true|[yY]*) dflt='y' ;;
6063*) case "$longsize" in
6064   8) dflt='y' ;;
6065   *) dflt='n' ;;
6066   esac
6067   ;;
6068esac
6069cat <<EOM
6070
6071You may also choose to try maximal 64-bitness.  It means using as much
607264-bitness as possible on the platform.  This in turn means even more
6073binary incompatibilities.  On the other hand, your platform may not
6074have any more 64-bitness available than what you already have chosen.
6075
6076If this doesn't make any sense to you, just accept the default '$dflt'.
6077(The default has been chosen based on your configuration.)
6078EOM
6079rp='Try to use maximal 64-bit support, if available?'
6080. ./myread
6081case "$ans" in
6082[yY]*) val="$define" ;;
6083*)     val="$undef"  ;;
6084esac
6085set use64bitall
6086eval $setvar
6087case "$use64bitall" in
6088"$define")
6089	case "$use64bitint" in
6090	"$undef")
6091		cat <<EOM
6092
6093Since you have chosen a maximally 64-bit build, I'm also turning on
6094the use of 64-bit integers.
6095EOM
6096		use64bitint="$define" ;;
6097	esac
6098	;;
6099esac
6100
6101: Look for a hint-file generated 'call-back-unit'.  If the
6102: user has specified that a 64-bit perl is to be built,
6103: we may need to set or change some other defaults.
6104if $test -f use64bitint.cbu; then
6105	echo "Your platform has some specific hints regarding 64-bit integers, using them..."
6106	. ./use64bitint.cbu
6107fi
6108case "$use64bitint" in
6109"$define"|true|[yY]*)
6110	: This test was common to all the OpenBSD forks, and seems harmless for
6111	: other platforms:
6112	echo " "
6113	echo "Checking if your C library has broken 64-bit functions..." >&4
6114	cat >try.c <<EOCP
6115#include <stdio.h>
6116typedef $uquadtype myULL;
6117int main (void)
6118{
6119    struct {
6120	double d;
6121	myULL  u;
6122    } *p, test[] = {
6123	{4294967303.15, 4294967303ULL},
6124	{4294967294.2,  4294967294ULL},
6125	{4294967295.7,  4294967295ULL},
6126	{0.0, 0ULL}
6127    };
6128    for (p = test; p->u; p++) {
6129	myULL x = (myULL)p->d;
6130	if (x != p->u) {
6131	    printf("buggy\n");
6132	    return 0;
6133	}
6134    }
6135    printf("ok\n");
6136    return 0;
6137}
6138EOCP
6139	set try
6140	if eval $compile_ok; then
6141	    libcquad=`$run ./try`
6142	    echo "Your C library's 64-bit functions are $libcquad."
6143	else
6144	    echo "(I can't seem to compile the test program.)"
6145	    echo "Assuming that your C library's 64-bit functions are ok."
6146	    libcquad="ok"
6147	fi
6148	$rm_try
6149
6150	case "$libcquad" in
6151	    buggy*)
6152		cat >&4 <<EOM
6153
6154*** You have a C library with broken 64-bit functions.
6155*** 64-bit support does not work reliably in this configuration.
6156*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6157*** Cannot continue, aborting.
6158
6159EOM
6160		exit 1
6161		;;
6162	esac
6163	case "$longsize" in
6164	4) case "$archname64" in
6165	   '') archname64=64int ;;
6166	   esac
6167	   ;;
6168	esac
6169	;;
6170esac
6171
6172: Look for a hint-file generated 'call-back-unit'.  If the
6173: user has specified that a maximally 64-bit perl is to be built,
6174: we may need to set or change some other defaults.
6175if $test -f use64bitall.cbu; then
6176	echo "Your platform has some specific hints regarding 64-bit builds, using them..."
6177	. ./use64bitall.cbu
6178fi
6179case "$use64bitall" in
6180"$define"|true|[yY]*)
6181	case "$longsize" in
6182	4) case "$archname64" in
6183	   ''|64int) archname64=64all ;;
6184	   esac
6185	   ;;
6186	esac
6187	;;
6188esac
6189
6190case "$d_quad:$use64bitint" in
6191$undef:$define)
6192	cat >&4 <<EOF
6193
6194*** You have chosen to use 64-bit integers,
6195*** but none can be found.
6196*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6197*** Cannot continue, aborting.
6198
6199EOF
6200	exit 1
6201	;;
6202esac
6203
6204: check for length of double
6205echo " "
6206case "$doublesize" in
6207'')
6208	echo "Checking to see how big your double precision numbers are..." >&4
6209	$cat >try.c <<EOCP
6210#include <stdio.h>
6211#$i_stdlib I_STDLIB
6212#ifdef I_STDLIB
6213#include <stdlib.h>
6214#endif
6215int main()
6216{
6217    printf("%d\n", (int)sizeof(double));
6218    exit(0);
6219}
6220EOCP
6221	set try
6222	if eval $compile_ok; then
6223		doublesize=`$run ./try`
6224		echo "Your double is $doublesize bytes long."
6225	else
6226		dflt='8'
6227		echo "(I can't seem to compile the test program.  Guessing...)"
6228		rp="What is the size of a double precision number (in bytes)?"
6229		. ./myread
6230		doublesize="$ans"
6231	fi
6232	;;
6233esac
6234$rm_try
6235
6236: check for long doubles
6237echo " "
6238echo "Checking to see if you have long double..." >&4
6239echo 'int main() { long double x = 7.0; }' > try.c
6240set try
6241if eval $compile; then
6242	val="$define"
6243	echo "You have long double."
6244else
6245	val="$undef"
6246	echo "You do not have long double."
6247fi
6248$rm_try
6249set d_longdbl
6250eval $setvar
6251
6252: check for length of long double
6253case "${d_longdbl}${longdblsize}" in
6254$define)
6255	echo " "
6256	echo "Checking to see how big your long doubles are..." >&4
6257	$cat >try.c <<'EOCP'
6258#include <stdio.h>
6259int main()
6260{
6261	printf("%d\n", sizeof(long double));
6262}
6263EOCP
6264	set try
6265	set try
6266	if eval $compile; then
6267		longdblsize=`$run ./try`
6268		echo "Your long doubles are $longdblsize bytes long."
6269	else
6270		dflt='8'
6271		echo " "
6272		echo "(I can't seem to compile the test program.  Guessing...)" >&4
6273		rp="What is the size of a long double (in bytes)?"
6274		. ./myread
6275		longdblsize="$ans"
6276	fi
6277	if $test "X$doublesize" = "X$longdblsize"; then
6278		echo "That isn't any different from an ordinary double."
6279		echo "I'll keep your setting anyway, but you may see some"
6280		echo "harmless compilation warnings."
6281	fi
6282	;;
6283esac
6284$rm_try
6285
6286: determine the architecture name
6287echo " "
6288if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
6289	tarch=`arch`"-$osname"
6290elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
6291	if uname -m > tmparch 2>&1 ; then
6292		tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
6293			-e 's/$/'"-$osname/" tmparch`
6294	else
6295		tarch="$osname"
6296	fi
6297	$rm -f tmparch
6298else
6299	tarch="$osname"
6300fi
6301case "$myarchname" in
6302''|"$tarch") ;;
6303*)
6304	echo "(Your architecture name used to be $myarchname.)"
6305	archname=''
6306	;;
6307esac
6308case "$targetarch" in
6309'') ;;
6310*)  archname=`echo $targetarch|sed 's,^[^-]*-,,'` ;;
6311esac
6312myarchname="$tarch"
6313case "$archname" in
6314'') dflt="$tarch";;
6315*) dflt="$archname";;
6316esac
6317rp='What is your architecture name'
6318. ./myread
6319archname="$ans"
6320
6321: optionally add API version to the architecture for versioned archlibs
6322case "$useversionedarchname" in
6323$define|true|[yY]*) dflt='y';;
6324*)                  dflt='n';;
6325esac
6326rp='Add the Perl API version to your archname?'
6327. ./myread
6328case "$ans" in
6329y|Y)	useversionedarchname="$define" ;;
6330*)      useversionedarchname="$undef" ;;
6331esac
6332case "$useversionedarchname" in
6333$define)
6334        case "$archname" in
6335        *-$api_versionstring)
6336                echo "...and architecture name already has -$api_versionstring" >&4
6337                ;;
6338        *)
6339                archname="$archname-$api_versionstring"
6340                echo "...setting architecture name to $archname." >&4
6341                ;;
6342        esac
6343        ;;
6344esac
6345
6346case "$usethreads" in
6347$define)
6348	echo "Threads selected." >&4
6349	case "$archname" in
6350        *-thread*) echo "...and architecture name already has -thread." >&4
6351                ;;
6352        *)      archname="$archname-thread"
6353                echo "...setting architecture name to $archname." >&4
6354                ;;
6355        esac
6356	;;
6357esac
6358case "$usemultiplicity" in
6359$define)
6360	echo "Multiplicity selected." >&4
6361	case "$archname" in
6362        *-multi*) echo "...and architecture name already has -multi." >&4
6363                ;;
6364        *)      archname="$archname-multi"
6365                echo "...setting architecture name to $archname." >&4
6366                ;;
6367        esac
6368	;;
6369esac
6370case "$use64bitint$use64bitall" in
6371*"$define"*)
6372	case "$archname64" in
6373	'')
6374		echo "This architecture is naturally 64-bit, not changing architecture name." >&4
6375		;;
6376	*)
6377		case "$use64bitint" in
6378		"$define") echo "64 bit integers selected." >&4 ;;
6379		esac
6380		case "$use64bitall" in
6381		"$define") echo "Maximal 64 bitness selected." >&4 ;;
6382		esac
6383		case "$archname" in
6384	        *-$archname64*) echo "...and architecture name already has $archname64." >&4
6385	                ;;
6386	        *)      archname="$archname-$archname64"
6387	                echo "...setting architecture name to $archname." >&4
6388	                ;;
6389	        esac
6390		;;
6391	esac
6392esac
6393case "$uselongdouble" in
6394$define)
6395	echo "Long doubles selected." >&4
6396	case "$longdblsize" in
6397	$doublesize)
6398		echo "...but long doubles are equal to doubles, not changing architecture name." >&4
6399		;;
6400	*)
6401		case "$archname" in
6402	        *-ld*) echo "...and architecture name already has -ld." >&4
6403	                ;;
6404	        *)      archname="$archname-ld"
6405	                echo "...setting architecture name to $archname." >&4
6406        	        ;;
6407	        esac
6408		;;
6409	esac
6410	;;
6411esac
6412if $test -f archname.cbu; then
6413	echo "Your platform has some specific hints for architecture name, using them..."
6414	. ./archname.cbu
6415fi
6416
6417: set the prefixit variable, to compute a suitable default value
6418prefixit='case "$3" in
6419""|none)
6420	case "$oldprefix" in
6421	"") eval "$1=\"\$$2\"";;
6422	*)
6423		case "$3" in
6424		"") eval "$1=";;
6425		none)
6426			eval "tp=\"\$$2\"";
6427			case "$tp" in
6428			""|" ") eval "$1=\"\$$2\"";;
6429			*) eval "$1=";;
6430			esac;;
6431		esac;;
6432	esac;;
6433*)
6434	eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
6435	case "$tp" in
6436	--|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
6437	/*-$oldprefix/*|\~*-$oldprefix/*)
6438		eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
6439	*) eval "$1=\"\$$2\"";;
6440	esac;;
6441esac'
6442
6443: determine installation style
6444: For now, try to deduce it from prefix unless it is already set.
6445: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
6446case "$installstyle" in
6447'')	case "$prefix" in
6448		*perl*) dflt='lib';;
6449		*) dflt='lib/perl5' ;;
6450	esac
6451	;;
6452*)	dflt="$installstyle" ;;
6453esac
6454: Probably not worth prompting for this since we prompt for all
6455: the directories individually, and the prompt would be too long and
6456: confusing anyway.
6457installstyle=$dflt
6458
6459: determine where public executables go
6460echo " "
6461set dflt bin bin
6462eval $prefixit
6463fn=d~
6464rp='Pathname where the public executables will reside?'
6465. ./getfile
6466if $test "X$ansexp" != "X$binexp"; then
6467	installbin=''
6468fi
6469prefixvar=bin
6470: XXX Bug? -- ignores Configure -Dinstallprefix setting.
6471: XXX If this is fixed, also fix the "start perl" hunk below, which relies on
6472:     this via initialinstalllocation
6473. ./setprefixvar
6474
6475case "$userelocatableinc" in
6476$define|true|[yY]*)	dflt='y' ;;
6477*)			dflt='n' ;;
6478esac
6479cat <<EOM
6480
6481Would you like to build Perl so that the installation is relocatable, so that
6482library paths in @INC are determined relative to the path of the perl binary?
6483This is not advised for system Perl installs, or if you need to run setid
6484scripts or scripts under taint mode.
6485
6486If this doesn't make any sense to you, just accept the default '$dflt'.
6487EOM
6488rp='Use relocatable @INC?'
6489. ./myread
6490case "$ans" in
6491y|Y)	val="$define" ;;
6492*)	val="$undef"  ;;
6493esac
6494set userelocatableinc
6495eval $setvar
6496
6497initialinstalllocation="$binexp"
6498: Default prefix is now "up one level from where the binaries are"
6499case "$userelocatableinc" in
6500$define|true|[yY]*)
6501    bin=".../"
6502    binexp=".../"
6503    prefix=".../.."
6504    prefixexp=".../.."
6505    installprefixexp=".../.."
6506    ;;
6507esac
6508
6509: determine where private library files go
6510: Usual default is /usr/local/lib/perl5/$version.
6511: Also allow things like /opt/perl/lib/$version, since
6512: /opt/perl/lib/perl5... would be redundant.
6513: The default "style" setting is made in installstyle.U
6514case "$installstyle" in
6515*lib/perl5*) set dflt privlib lib/$package/$version ;;
6516*)	 set dflt privlib lib/$version ;;
6517esac
6518eval $prefixit
6519$cat <<EOM
6520
6521There are some auxiliary files for $package that need to be put into a
6522private library directory that is accessible by everyone.
6523
6524EOM
6525fn=$binexp
6526fn=d~+
6527rp='Pathname where the private library files will reside?'
6528. ./getfile
6529prefixvar=privlib
6530. ./setprefixvar
6531
6532: set the prefixup variable, to restore leading tilda escape
6533prefixup='case "$prefixexp" in
6534"$prefix") ;;
6535*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
6536esac'
6537
6538: determine where public architecture dependent libraries go
6539set archlib archlib
6540eval $prefixit
6541: privlib default is /usr/local/lib/$package/$version
6542: archlib default is /usr/local/lib/$package/$version/$archname
6543: privlib may have an optional trailing /share.
6544tdflt=`echo $privlib | $sed 's,/share$,,'`
6545tdflt=$tdflt/$archname
6546case "$archlib" in
6547'')	dflt=$tdflt
6548	;;
6549*)	dflt="$archlib"
6550    ;;
6551esac
6552$cat <<EOM
6553
6554$spackage contains architecture-dependent library files.  If you are
6555sharing libraries in a heterogeneous environment, you might store
6556these files in a separate location.  Otherwise, you can just include
6557them with the rest of the public library files.
6558
6559EOM
6560fn=$binexp
6561fn=d+~
6562rp='Where do you want to put the public architecture-dependent libraries?'
6563. ./getfile
6564prefixvar=archlib
6565. ./setprefixvar
6566if $test X"$archlib" = X"$privlib"; then
6567	d_archlib="$undef"
6568else
6569	d_archlib="$define"
6570fi
6571
6572: see if setuid scripts can be secure
6573$cat <<EOM
6574
6575Some kernels have a bug that prevents setuid #! scripts from being
6576secure.  Some sites have disabled setuid #! scripts because of this.
6577
6578First let's decide if your kernel supports secure setuid #! scripts.
6579(If setuid #! scripts would be secure but have been disabled anyway,
6580don't say that they are secure if asked.)
6581
6582EOM
6583
6584val="$undef"
6585if $test -d /dev/fd; then
6586	echo "#!$ls" >reflect
6587	chmod +x,u+s reflect
6588	./reflect >flect 2>&1
6589	if $contains "/dev/fd" flect >/dev/null; then
6590		echo "Congratulations, your kernel has secure setuid scripts!" >&4
6591		val="$define"
6592	else
6593		$cat <<EOM
6594If you are not sure if they are secure, I can check but I'll need a
6595username and password different from the one you are using right now.
6596If you don't have such a username or don't want me to test, simply
6597enter 'none'.
6598
6599EOM
6600		rp='Other username to test security of setuid scripts with?'
6601		dflt='none'
6602		. ./myread
6603		case "$ans" in
6604		n|none)
6605			case "$d_suidsafe" in
6606			'')	echo "I'll assume setuid scripts are *not* secure." >&4
6607				dflt=n;;
6608			"$undef")
6609				echo "Well, the $hint value is *not* secure." >&4
6610				dflt=n;;
6611			*)	echo "Well, the $hint value *is* secure." >&4
6612				dflt=y;;
6613			esac
6614			;;
6615		*)
6616			$rm -f reflect flect
6617			echo "#!$ls" >reflect
6618			chmod +x,u+s reflect
6619			echo >flect
6620			chmod a+w flect
6621			echo '"su" will (probably) prompt you for '"$ans's password."
6622			su $ans -c './reflect >flect'
6623			if $contains "/dev/fd" flect >/dev/null; then
6624				echo "Okay, it looks like setuid scripts are secure." >&4
6625				dflt=y
6626			else
6627				echo "I don't think setuid scripts are secure." >&4
6628				dflt=n
6629			fi
6630			;;
6631		esac
6632		rp='Does your kernel have *secure* setuid scripts?'
6633		. ./myread
6634		case "$ans" in
6635		[yY]*)	val="$define";;
6636		*)	val="$undef";;
6637		esac
6638	fi
6639else
6640	echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
6641	echo "(That's for file descriptors, not floppy disks.)"
6642	val="$undef"
6643fi
6644set d_suidsafe
6645eval $setvar
6646
6647$rm -f reflect flect
6648
6649: now see if they want to do setuid emulation
6650if $test $patchlevel -lt 11; then
6651echo " "
6652val="$undef"
6653case "$d_suidsafe" in
6654"$define")
6655	val="$undef"
6656	echo "No need to emulate SUID scripts since they are secure here." >&4
6657	;;
6658*)
6659	$cat <<EOM
6660Some systems have disabled setuid scripts, especially systems where
6661setuid scripts cannot be secure.  On systems where setuid scripts have
6662been disabled, the setuid/setgid bits on scripts are currently
6663useless.  It is possible for $package to detect those bits and emulate
6664setuid/setgid in a secure fashion.  This emulation will only work if
6665setuid scripts have been disabled in your kernel.
6666
6667EOM
6668	case "$d_dosuid" in
6669	"$define") dflt=y ;;
6670	*) dflt=n ;;
6671	esac
6672	rp="Do you want to do setuid/setgid emulation?"
6673	. ./myread
6674	case "$ans" in
6675	[yY]*)	val="$define";;
6676	*)	val="$undef";;
6677	esac
6678	;;
6679esac
6680set d_dosuid
6681eval $setvar
6682else
6683    case "$d_dosuid" in
6684	"$define")
6685	cat >&4 <<EOH
6686
6687SUID emulation has been removed for 5.12
6688Please re-run Configure without -Dd_dosuid
6689
6690EOH
6691	exit 1;
6692	;;
6693    esac
6694    d_dosuid=undef
6695fi
6696
6697: Find perl5.005 or later.
6698echo "Looking for a previously installed perl5.005 or later... "
6699case "$perl5" in
6700'')	for tdir in `echo "$binexp$path_sep$PATH" | $sed "s/$path_sep/ /g"`; do
6701		: Check if this perl is recent and can load a simple module
6702		if $test -x $tdir/perl$exe_ext && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
6703			perl5=$tdir/perl
6704			break;
6705		elif $test -x $tdir/perl5$exe_ext && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
6706			perl5=$tdir/perl5
6707			break;
6708		fi
6709	done
6710	;;
6711*)	perl5="$perl5"
6712	;;
6713esac
6714case "$perl5" in
6715'')	echo "None found.  That's ok.";;
6716*)	echo "Using $perl5." ;;
6717esac
6718
6719: Set the siteprefix variables
6720$cat <<EOM
6721
6722After $package is installed, you may wish to install various
6723add-on modules and utilities.  Typically, these add-ons will
6724be installed under $prefix with the rest
6725of this package.  However, you may wish to install such add-ons
6726elsewhere under a different prefix.
6727
6728If you do not wish to put everything under a single prefix, that's
6729ok.  You will be prompted for the individual locations; this siteprefix
6730is only used to suggest the defaults.
6731
6732The default should be fine for most people.
6733
6734EOM
6735fn=d~+
6736rp='Installation prefix to use for add-on modules and utilities?'
6737: XXX Here might be another good place for an installstyle setting.
6738case "$siteprefix" in
6739'') dflt=$prefix ;;
6740*)  dflt=$siteprefix ;;
6741esac
6742. ./getfile
6743: XXX Prefixit unit does not yet support siteprefix and vendorprefix
6744oldsiteprefix=''
6745case "$siteprefix" in
6746'') ;;
6747*)	case "$ans" in
6748	"$prefix") ;;
6749	*) oldsiteprefix="$prefix";;
6750	esac
6751	;;
6752esac
6753siteprefix="$ans"
6754siteprefixexp="$ansexp"
6755
6756: determine where site specific libraries go.
6757: Usual default is /usr/local/lib/perl5/site_perl/$version
6758: The default "style" setting is made in installstyle.U
6759: XXX No longer works with Prefixit stuff.
6760prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6761case "$sitelib" in
6762'') case "$installstyle" in
6763	*lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
6764	*)	 dflt=$siteprefix/lib/site_$prog/$version ;;
6765	esac
6766	;;
6767*)	dflt="$sitelib"
6768	;;
6769esac
6770$cat <<EOM
6771
6772The installation process will create a directory for
6773site-specific extensions and modules.  Most users find it convenient
6774to place all site-specific files in this directory rather than in the
6775main distribution directory.
6776
6777EOM
6778fn=d~+
6779rp='Pathname for the site-specific library files?'
6780. ./getfile
6781prefixvar=sitelib
6782. ./setprefixvar
6783sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
6784
6785: Determine list of previous versions to include in @INC
6786$cat > getverlist <<EOPL
6787#!$perl5 -w
6788use File::Basename;
6789\$api_versionstring = "$api_versionstring";
6790\$version = "$version";
6791\$stem = "$sitelib_stem";
6792\$archname = "$archname";
6793EOPL
6794	$cat >> getverlist <<'EOPL'
6795# The list found is store twice for each entry: the original name, and
6796# the binary broken down version as pack "sss", so sorting is easy and
6797# unambiguous. This will work for all versions that have a maximum of
6798# three digit groups, separate by '.'s or '_'s. Names are extended with
6799# ".0.0" to ensure at least three elements for the pack.
6800#					-- H.Merijn Brand (m)'06 23-10-2006
6801
6802# Can't have leading @ because metaconfig interprets it as a command!
6803;@inc_version_list=();
6804# XXX Redo to do opendir/readdir?
6805if (-d $stem) {
6806    chdir($stem);
6807    ;@candidates = map {
6808	[ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*");
6809    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
6810}
6811else {
6812    ;@candidates = ();
6813}
6814
6815($pversion, $aversion, $vsn5005) = map {
6816    pack "sss", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005";
6817foreach $d (@candidates) {
6818    if ($d->[1] lt $pversion) {
6819	if ($d->[1] ge $aversion) {
6820	    unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);
6821	}
6822	elsif ($d->[1] ge $vsn5005) {
6823	    unshift(@inc_version_list, grep { -d } $d->[0]);
6824	}
6825    }
6826    else {
6827	# Skip newer version.  I.e. don't look in
6828	# 5.7.0 if we're installing 5.6.1.
6829    }
6830}
6831
6832if (@inc_version_list) {
6833    print join(' ', @inc_version_list);
6834}
6835else {
6836    # Blank space to preserve value for next Configure run.
6837    print " ";
6838}
6839EOPL
6840chmod +x getverlist
6841case "$inc_version_list" in
6842'')	if test -x "$perl5$exe_ext"; then
6843		dflt=`$perl5 getverlist`
6844	else
6845		dflt='none'
6846	fi
6847	;;
6848$undef) dflt='none' ;;
6849*)  eval dflt=\"$inc_version_list\" ;;
6850esac
6851case "$dflt" in
6852''|' ') dflt=none ;;
6853esac
6854case "$dflt" in
68555.005) dflt=none ;;
6856esac
6857$cat <<EOM
6858
6859In order to ease the process of upgrading, this version of perl
6860can be configured to use modules built and installed with earlier
6861versions of perl that were installed under $prefix.  Specify here
6862the list of earlier versions that this version of perl should check.
6863If Configure detected no earlier versions of perl installed under
6864$prefix, then the list will be empty.  Answer 'none' to tell perl
6865to not search earlier versions.
6866
6867The default should almost always be sensible, so if you're not sure,
6868just accept the default.
6869EOM
6870
6871rp='List of earlier versions to include in @INC?'
6872. ./myread
6873case "$ans" in
6874[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
6875*) inc_version_list="$ans" ;;
6876esac
6877case "$inc_version_list" in
6878''|' ')
6879	inc_version_list_init='0'
6880	d_inc_version_list="$undef"
6881	;;
6882*)	inc_version_list_init=`echo $inc_version_list |
6883		$sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
6884	d_inc_version_list="$define"
6885	;;
6886esac
6887$rm -f getverlist
6888
6889: see if malloc/malloc.h has to be included
6890set malloc/malloc.h i_mallocmalloc
6891eval $inhdr
6892
6893: see if this is a malloc.h system
6894: we want a real compile instead of Inhdr because some systems have a
6895: malloc.h that just gives a compile error saying to use stdlib.h instead
6896echo " "
6897$cat >try.c <<EOCP
6898#include <stdlib.h>
6899#include <malloc.h>
6900#$i_mallocmalloc I_MALLOCMALLOC
6901#ifdef I_MALLOCMALLOC
6902# include <malloc/malloc.h>
6903#endif
6904
6905int main () { return 0; }
6906EOCP
6907set try
6908if eval $compile; then
6909    echo "<malloc.h> found." >&4
6910    val="$define"
6911else
6912    echo "<malloc.h> NOT found." >&4
6913    val="$undef"
6914fi
6915$rm_try
6916set i_malloc
6917eval $setvar
6918
6919: check for length of pointer
6920echo " "
6921case "$ptrsize" in
6922'')
6923	echo "Checking to see how big your pointers are..." >&4
6924	$cat >>try.c <<EOCP
6925#include <stdio.h>
6926#$i_stdlib I_STDLIB
6927#ifdef I_STDLIB
6928#include <stdlib.h>
6929#endif
6930int main()
6931{
6932    printf("%d\n", (int)sizeof(void *));
6933    exit(0);
6934}
6935EOCP
6936	set try
6937	if eval $compile_ok; then
6938		ptrsize=`$run ./try`
6939		echo "Your pointers are $ptrsize bytes long."
6940	else
6941		dflt='4'
6942		echo "(I can't seem to compile the test program.  Guessing...)" >&4
6943		rp="What is the size of a pointer (in bytes)?"
6944		. ./myread
6945		ptrsize="$ans"
6946	fi
6947	;;
6948esac
6949$rm_try
6950case "$use64bitall" in
6951"$define"|true|[yY]*)
6952	case "$ptrsize" in
6953	4)	cat <<EOM >&4
6954
6955*** You have chosen a maximally 64-bit build,
6956*** but your pointers are only 4 bytes wide.
6957*** Please rerun Configure without -Duse64bitall.
6958EOM
6959		case "$d_quad" in
6960		define)
6961			cat <<EOM >&4
6962*** Since you have quads, you could possibly try with -Duse64bitint.
6963EOM
6964			;;
6965		esac
6966		cat <<EOM >&4
6967*** Cannot continue, aborting.
6968
6969EOM
6970
6971		exit 1
6972		;;
6973	esac
6974	;;
6975esac
6976
6977
6978: determine whether to use malloc wrapping
6979echo " "
6980case "$usemallocwrap" in
6981[yY]*|true|$define)	dflt='y' ;;
6982[nN]*|false|$undef)	dflt='n' ;;
6983*)	case "$usedevel" in
6984	[yY]*|true|$define)	dflt='y' ;;
6985	*) dflt='n' ;;
6986	esac
6987	;;
6988esac
6989rp="Do you wish to wrap malloc calls to protect against potential overflows?"
6990. ./myread
6991usemallocwrap="$ans"
6992case "$ans" in
6993y*|true)
6994	usemallocwrap="$define" ;;
6995*)
6996	usemallocwrap="$undef" ;;
6997esac
6998
6999: determine which malloc to compile in
7000echo " "
7001case "$usemymalloc" in
7002[yY]*|true|$define)	dflt='y' ;;
7003[nN]*|false|$undef)	dflt='n' ;;
7004*)	case "$ptrsize" in
7005	4) dflt='y' ;;
7006	*) dflt='n' ;;
7007	esac
7008	if test "$useithreads" = "$define"; then dflt='n'; fi
7009	;;
7010esac
7011rp="Do you wish to attempt to use the malloc that comes with $package?"
7012. ./myread
7013usemymalloc="$ans"
7014case "$ans" in
7015y*|true)
7016	usemymalloc='y'
7017	mallocsrc='malloc.c'
7018	mallocobj="malloc$_o"
7019	d_mymalloc="$define"
7020	case "$libs" in
7021	*-lmalloc*)
7022		: Remove malloc from list of libraries to use
7023		echo "Removing unneeded -lmalloc from library list" >&4
7024		set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
7025		shift
7026		libs="$*"
7027		echo "libs = $libs" >&4
7028		;;
7029	esac
7030	;;
7031*)
7032	usemymalloc='n'
7033	mallocsrc=''
7034	mallocobj=''
7035	d_mymalloc="$undef"
7036	;;
7037esac
7038
7039: compute the return types of malloc and free
7040echo " "
7041$cat >malloc.c <<END
7042#$i_malloc I_MALLOC
7043#$i_stdlib I_STDLIB
7044#include <stdio.h>
7045#include <sys/types.h>
7046#ifdef I_MALLOC
7047#include <malloc.h>
7048#endif
7049#ifdef I_STDLIB
7050#include <stdlib.h>
7051#endif
7052#ifdef TRY_MALLOC
7053void *malloc();
7054#endif
7055#ifdef TRY_FREE
7056void free();
7057#endif
7058END
7059case "$malloctype" in
7060'')
7061	if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
7062		malloctype='void *'
7063	else
7064		malloctype='char *'
7065	fi
7066	;;
7067esac
7068echo "Your system wants malloc to return '$malloctype', it would seem." >&4
7069
7070case "$freetype" in
7071'')
7072	if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
7073		freetype='void'
7074	else
7075		freetype='int'
7076	fi
7077	;;
7078esac
7079echo "Your system uses $freetype free(), it would seem." >&4
7080$rm -f malloc.[co]
7081: determine where site specific architecture-dependent libraries go.
7082: sitelib  default is /usr/local/lib/perl5/site_perl/$version
7083: sitearch default is /usr/local/lib/perl5/site_perl/$version/$archname
7084: sitelib may have an optional trailing /share.
7085case "$sitearch" in
7086'')	dflt=`echo $sitelib | $sed 's,/share$,,'`
7087	dflt="$dflt/$archname"
7088	;;
7089*)	dflt="$sitearch"
7090	;;
7091esac
7092set sitearch sitearch none
7093eval $prefixit
7094$cat <<EOM
7095
7096The installation process will also create a directory for
7097architecture-dependent site-specific extensions and modules.
7098
7099EOM
7100fn=d~+
7101rp='Pathname for the site-specific architecture-dependent library files?'
7102. ./getfile
7103prefixvar=sitearch
7104. ./setprefixvar
7105if $test X"$sitearch" = X"$sitelib"; then
7106	d_sitearch="$undef"
7107else
7108	d_sitearch="$define"
7109fi
7110
7111: Set the vendorprefix variables
7112$cat <<EOM
7113
7114The installation process will also create a directory for
7115vendor-supplied add-ons.  Vendors who supply perl with their system
7116may find it convenient to place all vendor-supplied files in this
7117directory rather than in the main distribution directory.  This will
7118ease upgrades between binary-compatible maintenance versions of perl.
7119
7120Of course you may also use these directories in whatever way you see
7121fit.  For example, you might use them to access modules shared over a
7122company-wide network.
7123
7124The default answer should be fine for most people.
7125This causes further questions about vendor add-ons to be skipped
7126and no vendor-specific directories will be configured for perl.
7127
7128EOM
7129rp='Do you want to configure vendor-specific add-on directories?'
7130case "$usevendorprefix" in
7131define|true|[yY]*) dflt=y ;;
7132*)	: User may have set vendorprefix directly on Configure command line.
7133	case "$vendorprefix" in
7134	''|' ') dflt=n ;;
7135	*)	dflt=y ;;
7136	esac
7137	;;
7138esac
7139. ./myread
7140case "$ans" in
7141[yY]*)	fn=d~+
7142	rp='Installation prefix to use for vendor-supplied add-ons?'
7143	case "$vendorprefix" in
7144	'') dflt="$prefix" ;;
7145	*)  dflt=$vendorprefix ;;
7146	esac
7147	. ./getfile
7148	: XXX Prefixit unit does not yet support siteprefix and vendorprefix
7149	oldvendorprefix=''
7150	case "$vendorprefix" in
7151	'') ;;
7152	*)	case "$ans" in
7153		"$prefix") ;;
7154		*) oldvendorprefix="$prefix";;
7155		esac
7156		;;
7157	esac
7158	usevendorprefix="$define"
7159	vendorprefix="$ans"
7160	vendorprefixexp="$ansexp"
7161	;;
7162*)	usevendorprefix="$undef"
7163	vendorprefix=''
7164	vendorprefixexp=''
7165	;;
7166esac
7167
7168: Set the vendorlib variables
7169case "$vendorprefix" in
7170'')	d_vendorlib="$undef"
7171	vendorlib=''
7172	vendorlibexp=''
7173	;;
7174*)	d_vendorlib="$define"
7175	: determine where vendor-supplied modules go.
7176	: Usual default is /usr/local/lib/perl5/vendor_perl/$version
7177	case "$vendorlib" in
7178	'')
7179		prog=`echo $package | $sed 's/-*[0-9.]*$//'`
7180		case "$installstyle" in
7181		*lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
7182		*)	     dflt=$vendorprefix/lib/vendor_$prog/$version ;;
7183		esac
7184		;;
7185	*)	dflt="$vendorlib"
7186		;;
7187	esac
7188	fn=d~+
7189	rp='Pathname for the vendor-supplied library files?'
7190	. ./getfile
7191	vendorlib="$ans"
7192	vendorlibexp="$ansexp"
7193	;;
7194esac
7195vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
7196prefixvar=vendorlib
7197. ./installprefix
7198
7199: Set the vendorarch variables
7200case "$vendorprefix" in
7201'')	d_vendorarch="$undef"
7202	vendorarch=''
7203	vendorarchexp=''
7204	;;
7205*)	d_vendorarch="$define"
7206	: determine where vendor-supplied architecture-dependent libraries go.
7207	: vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
7208	: vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
7209	: vendorlib may have an optional trailing /share.
7210	case "$vendorarch" in
7211	'')	dflt=`echo $vendorlib | $sed 's,/share$,,'`
7212		dflt="$dflt/$archname"
7213		;;
7214	*)	dflt="$vendorarch" ;;
7215	esac
7216	fn=d~+
7217	rp='Pathname for vendor-supplied architecture-dependent files?'
7218	. ./getfile
7219	vendorarch="$ans"
7220	vendorarchexp="$ansexp"
7221	;;
7222esac
7223prefixvar=vendorarch
7224. ./installprefix
7225if $test X"$vendorarch" = X"$vendorlib"; then
7226	d_vendorarch="$undef"
7227else
7228	d_vendorarch="$define"
7229fi
7230
7231: Final catch-all directories to search
7232$cat <<EOM
7233
7234Lastly, you can have perl look in other directories for extensions and
7235modules in addition to those already specified.
7236These directories will be searched after
7237	$sitearch
7238	$sitelib
7239EOM
7240test X"$vendorlib" != "X" && echo '	' $vendorlib
7241test X"$vendorarch" != "X" && echo '	' $vendorarch
7242echo ' '
7243case "$otherlibdirs" in
7244''|' ') dflt='none' ;;
7245*)	dflt="$otherlibdirs" ;;
7246esac
7247$cat <<EOM
7248Enter a colon-separated set of extra paths to include in perl's @INC
7249search path, or enter 'none' for no extra paths.
7250
7251EOM
7252
7253rp='Colon-separated list of additional directories for perl to search?'
7254. ./myread
7255case "$ans" in
7256' '|''|none)	otherlibdirs=' ' ;;
7257*)	otherlibdirs="$ans" ;;
7258esac
7259case "$otherlibdirs" in
7260' ') val=$undef ;;
7261*)	val=$define ;;
7262esac
7263set d_perl_otherlibdirs
7264eval $setvar
7265
7266: Cruising for prototypes
7267echo " "
7268echo "Checking out function prototypes..." >&4
7269$cat >prototype.c <<EOCP
7270#$i_stdlib I_STDLIB
7271#ifdef I_STDLIB
7272#include <stdlib.h>
7273#endif
7274int main(int argc, char *argv[]) {
7275	exit(0);}
7276EOCP
7277if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
7278	echo "Your C compiler appears to support function prototypes."
7279	val="$define"
7280else
7281	echo "Your C compiler doesn't seem to understand function prototypes."
7282	val="$undef"
7283fi
7284set prototype
7285eval $setvar
7286$rm -f prototype*
7287
7288: Check if ansi2knr is required
7289case "$prototype" in
7290"$define") ;;
7291*)	ansi2knr='ansi2knr'
7292	echo " "
7293	cat <<EOM >&4
7294
7295$me:  FATAL ERROR:
7296This version of $package can only be compiled by a compiler that 
7297understands function prototypes.  Unfortunately, your C compiler 
7298	$cc $ccflags
7299doesn't seem to understand them.  Sorry about that.
7300
7301If GNU cc is available for your system, perhaps you could try that instead.  
7302
7303Eventually, we hope to support building Perl with pre-ANSI compilers.
7304If you would like to help in that effort, please contact <perlbug@perl.org>.
7305
7306Aborting Configure now.
7307EOM
7308	exit 2
7309	;;
7310esac
7311
7312: DTrace support
7313dflt_dtrace='/usr/sbin/dtrace'
7314$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/dtrace'
7315
7316cat <<EOM
7317
7318Perl can be built to support DTrace on platforms that support it.
7319DTrace is a diagnosis and performance analysis tool from Sun.
7320
7321If this doesn't make any sense to you, just accept the default '$dflt'.
7322EOM
7323
7324while $test 1 ; do
7325	case "$usedtrace" in
7326	$define|true|[yY]*)
7327		dflt='y'
7328		;;
7329	?*)
7330		dflt='y'
7331		dflt_dtrace=$usedtrace
7332		;;
7333	*)
7334		dflt='n'
7335		;;
7336	esac
7337
7338	rp='Support DTrace if available?'
7339	. ./myread
7340	case "$ans" in
7341	y|Y)	val="$define" ;;
7342	*)      val="$undef" ;;
7343	esac
7344	set usedtrace
7345	eval $setvar
7346
7347	test "X$usedtrace" != "X$define" && break
7348
7349	echo " "
7350	rp='Where is the dtrace executable?'
7351	dflt=$dflt_dtrace
7352	. ./getfile
7353	val="$ans"
7354	set dtrace
7355	eval $setvar
7356
7357	if $test -f $dtrace
7358	then
7359		if $dtrace -h -s ../perldtrace.d \
7360			-o perldtrace.tmp >/dev/null 2>&1 \
7361			&& rm -f perldtrace.tmp
7362		then
7363			echo " "
7364			echo "Good: your $dtrace knows about the -h flag."
7365		else
7366			cat >&2 <<EOM
7367
7368*** $me:  Fatal Error:  $dtrace doesn't support -h flag
7369***
7370*** Your installed dtrace doesn't support the -h switch to compile a D
7371*** program into a C header. Can't continue.
7372
7373EOM
7374			exit 1
7375		fi
7376		break;
7377	fi
7378
7379	case "$fastread" in
7380	yes)
7381		cat >&2 <<EOM
7382
7383*** $me:  Fatal Error:  $dtrace not found.
7384*** Can't continue.
7385
7386EOM
7387		exit 1
7388		;;
7389	*)
7390		echo "*** $dtrace was not found."
7391		echo " "
7392		;;
7393	esac
7394done
7395
7396: See if we want extra modules installed
7397echo " "
7398case "$extras" in
7399'') dflt='n';;
7400*) dflt='y';;
7401esac
7402cat <<EOM
7403Perl can be built with extra modules or bundles of modules which
7404will be fetched from the CPAN and installed alongside Perl.
7405
7406Notice that you will need access to the CPAN; either via the Internet,
7407or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
7408be asked later to configure the CPAN.pm module which will in turn do
7409the installation of the rest of the extra modules or bundles.)
7410
7411Notice also that if the modules require any external software such as
7412libraries and headers (the libz library and the zlib.h header for the
7413Compress::Zlib module, for example) you MUST have any such software
7414already installed, this configuration process will NOT install such
7415things for you.
7416
7417If this doesn't make any sense to you, just accept the default '$dflt'.
7418EOM
7419rp='Install any extra modules (y or n)?'
7420. ./myread
7421case "$ans" in
7422y|Y)
7423	cat <<EOM
7424
7425Please list any extra modules or bundles to be installed from CPAN,
7426with spaces between the names.  The names can be in any format the
7427'install' command of CPAN.pm will understand.  (Answer 'none',
7428without the quotes, to install no extra modules or bundles.)
7429EOM
7430	rp='Extras?'
7431	dflt="$extras"
7432	. ./myread
7433	extras="$ans"
7434esac
7435case "$extras" in
7436''|'none')
7437	val=''
7438	$rm -f ../extras.lst
7439	;;
7440*)	echo "(Saving the list of extras for later...)"
7441	echo "$extras" > ../extras.lst
7442	val="'$extras'"
7443	;;
7444esac
7445set extras
7446eval $setvar
7447echo " "
7448
7449: determine where html pages for programs go
7450set html1dir html1dir none
7451eval $prefixit
7452$cat <<EOM
7453
7454If you wish to install html files for programs in $spackage, indicate
7455the appropriate directory here.  To skip installing html files,
7456answer "none".
7457EOM
7458case "$html1dir" in
7459''|none|$undef|' ') dflt=none ;;
7460*) dflt=$html1dir ;;
7461esac
7462fn=dn+~
7463rp="Directory for the main $spackage html pages?"
7464. ./getfile
7465prefixvar=html1dir
7466. ./setprefixvar
7467: Use ' ' for none so value is preserved next time through Configure
7468$test X"$html1dir" = "X" && html1dir=' '
7469
7470: determine where html pages for libraries and modules go
7471set html3dir html3dir none
7472eval $prefixit
7473$cat <<EOM
7474
7475If you wish to install html files for modules associated with $spackage,
7476indicate the appropriate directory here.  To skip installing html files,
7477answer "none".
7478EOM
7479: There is no obvious default.  If they have specified html1dir, then
7480: try to key off that, possibly changing .../html1 into .../html3.
7481case "$html3dir" in
7482'') html3dir=`echo "$html1dir" | $sed 's/1$/3$/'` ;;
7483*) dflt=$html3dir ;;
7484esac
7485fn=dn+~
7486rp="Directory for the $spackage module html pages?"
7487. ./getfile
7488prefixvar=html3dir
7489. ./setprefixvar
7490: Use ' ' for none so value is preserved next time through Configure
7491$test X"$html3dir" = "X" && html3dir=' '
7492
7493: determine whether to install perl also as /usr/bin/perl
7494
7495echo " "
7496if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
7497	$cat <<EOM
7498Many scripts expect perl to be installed as /usr/bin/perl.
7499
7500If you want to, I can install the perl you are about to compile
7501as /usr/bin/perl (in addition to $bin/perl).
7502EOM
7503	if test -f /usr/bin/perl; then
7504	    $cat <<EOM
7505
7506However, please note that because you already have a /usr/bin/perl,
7507overwriting that with a new Perl would very probably cause problems.
7508Therefore I'm assuming you don't want to do that (unless you insist).
7509
7510EOM
7511	    case "$installusrbinperl" in
7512	    "$define"|[yY]*)	dflt='y';;
7513	    *)			dflt='n';;
7514	    esac
7515	else
7516	    $cat <<EOM
7517
7518Since you don't have a /usr/bin/perl I'm assuming creating one is okay.
7519
7520EOM
7521	    case "$installusrbinperl" in
7522	    "$undef"|[nN]*)	dflt='n';;
7523	    *)			dflt='y';;
7524	    esac
7525	fi
7526	rp="Do you want to install perl as /usr/bin/perl?"
7527	. ./myread
7528	case "$ans" in
7529	[yY]*)	val="$define";;
7530	*)	val="$undef" ;;
7531	esac
7532else
7533	val="$undef"
7534fi
7535set installusrbinperl
7536eval $setvar
7537
7538: Check if we are using the GNU C library
7539echo " "
7540echo "Checking for GNU C Library..." >&4
7541cat >try.c <<'EOCP'
7542/* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
7543   alone are insufficient to distinguish different versions, such as
7544   2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
7545   libc version 2.1.0.      A. Dougherty,  June 3, 2002.
7546*/
7547#include <stdio.h>
7548int main(void)
7549{
7550#ifdef __GLIBC__
7551#   ifdef __GLIBC_MINOR__
7552#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
7553#           include <gnu/libc-version.h>
7554	    printf("%s\n",  gnu_get_libc_version());
7555#       else
7556	    printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
7557#       endif
7558#   else
7559	printf("%d\n",  __GLIBC__);
7560#   endif
7561    return 0;
7562#else
7563    return 1;
7564#endif
7565}
7566EOCP
7567set try
7568if eval $compile_ok && $run ./try > glibc.ver; then
7569	val="$define"
7570	gnulibc_version=`$cat glibc.ver`
7571	echo "You are using the GNU C Library version $gnulibc_version"
7572else
7573	val="$undef"
7574	gnulibc_version=''
7575	echo "You are not using the GNU C Library"
7576fi
7577$rm_try glibc.ver
7578set d_gnulibc
7579eval $setvar
7580
7581: see if nm is to be used to determine whether a symbol is defined or not
7582case "$usenm" in
7583'')
7584	dflt=''
7585	case "$d_gnulibc" in
7586	"$define")
7587		echo " "
7588		echo "nm probably won't work on the GNU C Library." >&4
7589		dflt=n
7590		;;
7591	esac
7592	case "$dflt" in
7593	'')
7594		if $test "$osname" = aix -a "X$PASE" != "Xdefine" -a ! -f /lib/syscalls.exp; then
7595			echo " "
7596			echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
7597			echo "'nm' won't be sufficient on this system." >&4
7598			dflt=n
7599		fi
7600		;;
7601	esac
7602	case "$dflt" in
7603	'') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
7604		if $test $dflt -gt 20; then
7605			dflt=y
7606		else
7607			dflt=n
7608		fi
7609		;;
7610	esac
7611	;;
7612*)
7613	case "$usenm" in
7614	true|$define) dflt=y;;
7615	*) dflt=n;;
7616	esac
7617	;;
7618esac
7619$cat <<EOM
7620
7621I can use $nm to extract the symbols from your C libraries. This
7622is a time consuming task which may generate huge output on the disk (up
7623to 3 megabytes) but that should make the symbols extraction faster. The
7624alternative is to skip the 'nm' extraction part and to compile a small
7625test program instead to determine whether each symbol is present. If
7626you have a fast C compiler and/or if your 'nm' output cannot be parsed,
7627this may be the best solution.
7628
7629You probably shouldn't let me use 'nm' if you are using the GNU C Library.
7630
7631EOM
7632rp="Shall I use $nm to extract C symbols from the libraries?"
7633. ./myread
7634case "$ans" in
7635[Nn]*) usenm=false;;
7636*) usenm=true;;
7637esac
7638
7639runnm=$usenm
7640case "$reuseval" in
7641true) runnm=false;;
7642esac
7643
7644: nm options which may be necessary
7645case "$nm_opt" in
7646'') if $test -f /mach_boot; then
7647		nm_opt=''	# Mach
7648	elif $test -d /usr/ccs/lib; then
7649		nm_opt='-p'	# Solaris (and SunOS?)
7650	elif $test -f /dgux; then
7651		nm_opt='-p'	# DG-UX
7652	elif $test -f /lib64/rld; then
7653		nm_opt='-p'	# 64-bit Irix
7654	else
7655		nm_opt=''
7656	fi;;
7657esac
7658
7659: nm options which may be necessary for shared libraries but illegal
7660: for archive libraries.  Thank you, Linux.
7661case "$nm_so_opt" in
7662'')	case "$myuname" in
7663	*linux*|gnu*)
7664		if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
7665			nm_so_opt='--dynamic'
7666		fi
7667		;;
7668	esac
7669	;;
7670esac
7671
7672: Figure out where the libc is located
7673case "$runnm" in
7674true)
7675: get list of predefined functions in a handy place
7676echo " "
7677case "$libc" in
7678'') libc=unknown
7679	case "$libs" in
7680	*-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
7681	esac
7682	;;
7683esac
7684case "$libs" in
7685'') ;;
7686*)  for thislib in $libs; do
7687	case "$thislib" in
7688	-lc|-lc_s)
7689		: Handle C library specially below.
7690		;;
7691	-l*)
7692		thislib=`echo $thislib | $sed -e 's/^-l//'`
7693		if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
7694			:
7695		elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
7696			:
7697		elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
7698			:
7699		elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
7700			:
7701		elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
7702			:
7703		elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
7704			:
7705		elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
7706			:
7707		else
7708			try=''
7709		fi
7710		libnames="$libnames $try"
7711		;;
7712	*) libnames="$libnames $thislib" ;;
7713	esac
7714	done
7715	;;
7716esac
7717xxx=normal
7718case "$libc" in
7719unknown)
7720	set /lib/libc.$so
7721	for xxx in $libpth; do
7722		$test -r $1 || set $xxx/libc.$so
7723		: The messy sed command sorts on library version numbers.
7724		$test -r $1 || \
7725			set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
7726			tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
7727				h
7728				s/[0-9][0-9]*/0000&/g
7729				s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
7730				G
7731				s/\n/ /' | \
7732			 $sort | $sed -e 's/^.* //'`
7733		eval set \$$#
7734	done
7735	$test -r $1 || set $sysroot/usr/ccs/lib/libc.$so
7736	$test -r $1 || set $sysroot/lib/libsys_s$_a
7737	;;
7738*)
7739	set blurfl
7740	;;
7741esac
7742if $test -r "$1"; then
7743	echo "Your (shared) C library seems to be in $1."
7744	libc="$1"
7745elif $test -r /lib/libc && $test -r /lib/clib; then
7746	echo "Your C library seems to be in both /lib/clib and /lib/libc."
7747	xxx=apollo
7748	libc='/lib/clib /lib/libc'
7749	if $test -r /lib/syslib; then
7750		echo "(Your math library is in /lib/syslib.)"
7751		libc="$libc /lib/syslib"
7752	fi
7753elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
7754	echo "Your C library seems to be in $libc, as you said before."
7755elif $test -r $incpath/usr/lib/libc$_a; then
7756	libc=$incpath/usr/lib/libc$_a;
7757	echo "Your C library seems to be in $libc.  That's fine."
7758elif $test -r /lib/libc$_a; then
7759	libc=/lib/libc$_a;
7760	echo "Your C library seems to be in $libc.  You're normal."
7761else
7762	if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
7763		:
7764	elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
7765		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
7766	elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
7767		:
7768	elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
7769		:
7770	elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
7771		:
7772	else
7773		tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
7774	fi
7775	if $test -r "$tans"; then
7776		echo "Your C library seems to be in $tans, of all places."
7777		libc=$tans
7778	else
7779		libc='blurfl'
7780	fi
7781fi
7782if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
7783	dflt="$libc"
7784	cat <<EOM
7785
7786If the guess above is wrong (which it might be if you're using a strange
7787compiler, or your machine supports multiple models), you can override it here.
7788
7789EOM
7790else
7791	dflt=''
7792	echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
7793	cat >&4 <<EOM
7794I can't seem to find your C library.  I've looked in the following places:
7795
7796EOM
7797	$sed 's/^/	/' libpath
7798	cat <<EOM
7799
7800None of these seems to contain your C library. I need to get its name...
7801
7802EOM
7803fi
7804fn=f
7805rp='Where is your C library?'
7806. ./getfile
7807libc="$ans"
7808
7809echo " "
7810echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
7811set X `cat libnames`
7812shift
7813xxx=files
7814case $# in 1) xxx=file; esac
7815echo "Extracting names from the following $xxx for later perusal:" >&4
7816echo " "
7817$sed 's/^/	/' libnames >&4
7818echo " "
7819$echo $n "This may take a while...$c" >&4
7820
7821for file in $*; do
7822	case $file in
7823	*$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
7824	*) $nm $nm_opt $file 2>/dev/null;;
7825	esac
7826done >libc.tmp
7827
7828$echo $n ".$c"
7829$grep fprintf libc.tmp > libc.ptf
7830xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
7831xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
7832xxx='[ADTSIWi]'
7833if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
7834	eval $xscan;\
7835	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7836		eval $xrun
7837elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
7838	eval $xscan;\
7839	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7840		eval $xrun
7841elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
7842	eval $xscan;\
7843	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7844		eval $xrun
7845elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
7846	eval $xscan;\
7847	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7848		eval $xrun
7849elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
7850	eval $xscan;\
7851	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7852		eval $xrun
7853elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
7854	eval $xscan;\
7855	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7856		eval $xrun
7857elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
7858				-e '/ file/d' -e 's/^\([^ 	]*\).*/\1/p'";\
7859	eval $xscan;\
7860	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7861		eval $xrun
7862elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
7863	eval $xscan;\
7864	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7865		eval $xrun
7866elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
7867	eval $xscan;\
7868	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7869		eval $xrun
7870elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
7871	eval $xscan;\
7872	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7873		eval $xrun
7874elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
7875	eval $xscan;\
7876	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7877		eval $xrun
7878elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
7879	eval $xscan;\
7880	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7881		eval $xrun
7882elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
7883	eval $xscan;\
7884	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7885		eval $xrun
7886elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
7887	eval $xscan;\
7888	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
7889		eval $xrun
7890else
7891	$nm -p $* 2>/dev/null >libc.tmp
7892	$grep fprintf libc.tmp > libc.ptf
7893	if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
7894		eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
7895	then
7896		nm_opt='-p'
7897		eval $xrun
7898	else
7899		echo " "
7900		echo "$nm didn't seem to work right. Trying $ar instead..." >&4
7901		com=''
7902		if $ar t $libc > libc.tmp && \
7903			$contains '^fprintf$' libc.tmp >/dev/null 2>&1
7904		then
7905			for thisname in $libnames $libc; do
7906				$ar t $thisname >>libc.tmp
7907			done
7908			$sed -e "s/\\$_o\$//" < libc.tmp > libc.list
7909			echo "Ok." >&4
7910		elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
7911			for thisname in $libnames $libc; do
7912				$ar tv $thisname >>libc.tmp
7913				emximp -o tmp.imp $thisname \
7914				    2>/dev/null && \
7915				    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
7916				    < tmp.imp >>libc.tmp
7917				$rm -f tmp.imp
7918			done
7919			$sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
7920			echo "Ok." >&4
7921		else
7922			echo "$ar didn't seem to work right." >&4
7923			echo "Maybe this is a Cray...trying bld instead..." >&4
7924			if  bld t $libc | \
7925				$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list &&
7926				$test -s libc.list
7927			then
7928				for thisname in $libnames; do
7929					bld t $libnames | \
7930					$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
7931					$ar t $thisname >>libc.tmp
7932				done
7933				echo "Ok." >&4
7934			else
7935				echo "That didn't work either.  Giving up." >&4
7936				exit 1
7937			fi
7938		fi
7939	fi
7940fi
7941nm_extract="$com"
7942case "$PASE" in
7943define)
7944    echo " "
7945    echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
7946    dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
7947    ;;
7948*)  if $test -f /lib/syscalls.exp; then
7949	echo " "
7950	echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
7951	$sed -n 's/^\([^ 	]*\)[ 	]*syscall[0-9]*[ 	]*$/\1/p' \
7952		/lib/syscalls.exp >>libc.list
7953    fi
7954    ;;
7955esac
7956;;
7957esac
7958$rm -f libnames libpath
7959
7960: Check if we are using C++
7961echo " "
7962echo "Checking for C++..." >&4
7963$cat >try.c <<'EOCP'
7964#include <stdio.h>
7965int main(void)
7966{
7967#ifdef __cplusplus
7968    return 0;
7969#else
7970    return 1;
7971#endif
7972}
7973EOCP
7974set try
7975if eval $compile_ok && $run ./try; then
7976	val="$define"
7977	echo "You are using a C++ compiler."
7978else
7979	val="$undef"
7980	echo "You are not using a C++ compiler."
7981fi
7982$rm_try cplusplus$$
7983set d_cplusplus
7984eval $setvar
7985
7986: is a C symbol defined?
7987csym='tlook=$1;
7988case "$3" in
7989-v) tf=libc.tmp; tdc="";;
7990-a) tf=libc.tmp; tdc="[]";;
7991*) tlook="^$1\$"; tf=libc.list; tdc="()";;
7992esac;
7993case "$d_cplusplus" in
7994    $define)	extern_C="extern \"C\""	;;
7995    *)		extern_C="extern"	;;
7996esac;
7997tx=yes;
7998case "$reuseval-$4" in
7999true-) ;;
8000true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
8001esac;
8002case "$tx" in
8003yes)
8004	tval=false;
8005	if $test "$runnm" = true; then
8006		if $contains $tlook $tf >/dev/null 2>&1; then
8007			tval=true;
8008		elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
8009			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;
8010			$cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
8011			$test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
8012			$rm_try;
8013		fi;
8014	else
8015		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;
8016		$cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
8017		$rm_try;
8018	fi;
8019	;;
8020*)
8021	case "$tval" in
8022	$define) tval=true;;
8023	*) tval=false;;
8024	esac;
8025	;;
8026esac;
8027eval "$2=$tval"'
8028
8029: define an is-in-libc? function
8030inlibc='echo " "; td=$define; tu=$undef;
8031sym=$1; var=$2; eval "was=\$$2";
8032tx=yes;
8033case "$reuseval$was" in
8034true) ;;
8035true*) tx=no;;
8036esac;
8037case "$tx" in
8038yes)
8039	set $sym tres -f;
8040	eval $csym;
8041	case "$tres" in
8042	true)
8043		echo "$sym() found." >&4;
8044		case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
8045	*)
8046		echo "$sym() NOT found." >&4;
8047		case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
8048	esac;;
8049*)
8050	case "$was" in
8051	$define) echo "$sym() found." >&4;;
8052	*) echo "$sym() NOT found." >&4;;
8053	esac;;
8054esac'
8055
8056: see if dlopen exists
8057xxx_runnm="$runnm"
8058xxx_ccflags="$ccflags"
8059runnm=false
8060: with g++ one needs -shared to get is-in-libc to work for dlopen
8061case "$gccversion" in
8062'')	;;
8063*)	case "$d_cplusplus" in
8064	"$define") ccflags="$ccflags -shared" ;;
8065	esac
8066	;;
8067esac
8068set dlopen d_dlopen
8069eval $inlibc
8070runnm="$xxx_runnm"
8071ccflags="$xxx_ccflags"
8072
8073: see if this is a unistd.h system
8074set unistd.h i_unistd
8075eval $inhdr
8076
8077: determine which dynamic loading, if any, to compile in
8078echo " "
8079dldir="ext/DynaLoader"
8080case "$usedl" in
8081    $define|y|true)
8082	dflt='y'
8083	usedl="$define"
8084	;;
8085    $undef|n|false)
8086	dflt='n'
8087	usedl="$undef"
8088	;;
8089    *)
8090	dflt='n'
8091	case "$d_dlopen" in
8092	    $define) dflt='y' ;;
8093	esac
8094	: Does a dl_xxx.xs file exist for this operating system
8095	$test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
8096	;;
8097esac
8098rp="Do you wish to use dynamic loading?"
8099. ./myread
8100usedl="$ans"
8101bin_ELF="$undef"
8102case "$ans" in
8103    y*) usedl="$define"
8104	case "$dlsrc" in
8105	    '') if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
8106		    dflt="$dldir/dl_${osname}.xs"
8107		elif $test "$d_dlopen" = "$define" ; then
8108		    dflt="$dldir/dl_dlopen.xs"
8109		else
8110		    dflt=''
8111		fi
8112		;;
8113	    *)  dflt="$dldir/$dlsrc"
8114		;;
8115	esac
8116	echo "The following dynamic loading files are available:"
8117	: Can not go over to $dldir because getfile has path hard-coded in.
8118	tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir"
8119	rp="Source file to use for dynamic loading"
8120	fn="fne"
8121	gfpth="$src"
8122	. ./getfile
8123	usedl="$define"
8124	: emulate basename
8125	dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'`
8126
8127	$cat << EOM
8128
8129Some systems may require passing special flags to $cc -c to
8130compile modules that will be used to create a shared library.
8131To use no flags, say "none".
8132
8133EOM
8134	case "$cccdlflags" in
8135	    '') case "$gccversion" in
8136		'') case "$osname" in
8137			hpux)	dflt='+z' ;;
8138			next)	dflt='none' ;;
8139			irix*)	dflt='-KPIC' ;;
8140			svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
8141			sunos)	dflt='-pic' ;;
8142			*)	dflt='none' ;;
8143		    esac
8144		    ;;
8145		*)  case "$osname" in
8146			darwin) dflt='none' ;;
8147			*linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
8148			*)	dflt='-fpic' ;;
8149		    esac ;;
8150		esac ;;
8151	    ' ') dflt='none' ;;
8152	    *)   dflt="$cccdlflags" ;;
8153	esac
8154
8155	case "$dflt" in
8156	    none) dflt='' ;;
8157	esac
8158
8159	# If -Dsysroot was specified, now's the time to add it
8160	# to cccdlflags
8161	if test "X$sysroot" != X; then
8162	    case "$gccversion" in
8163		'') ;;
8164		*)  case "$dflt" in
8165			*sysroot*) ;;
8166			'undef'|*)
8167			    dflt="$dflt --sysroot=$sysroot" ;;
8168		    esac
8169		    ;;
8170	    esac
8171	fi
8172
8173	case "$dflt" in
8174	    '') dflt='none';;
8175	esac
8176
8177	rp="Any special flags to pass to $cc -c to compile shared library modules?"
8178	. ./myread
8179	case "$ans" in
8180	    none) cccdlflags=' ' ;;
8181	    *)    cccdlflags="$ans" ;;
8182	esac
8183
8184	cat << EOM
8185
8186Some systems use ld to create libraries that can be dynamically loaded,
8187while other systems (such as those using ELF) use $cc.
8188
8189EOM
8190
8191: Determine if this is ELF
8192	$cat >try.c <<EOM
8193/* Test for whether ELF binaries are produced */
8194#include <fcntl.h>
8195#$i_stdlib I_STDLIB
8196#ifdef I_STDLIB
8197#include <stdlib.h>
8198#endif
8199#$i_unistd I_UNISTD
8200#ifdef I_UNISTD
8201#include <unistd.h>
8202#endif
8203int main() {
8204    char b[4];
8205    int i = open("a.out",O_RDONLY);
8206    if(i == -1)
8207	exit(1); /* fail */
8208    if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
8209	exit(0); /* succeed (yes, it is ELF) */
8210    exit(1); /* fail */
8211}
8212EOM
8213	if $cc $ccflags $ldflags try.c >/dev/null 2>&1 && $run ./a.out; then
8214	    bin_ELF="$define"
8215	fi
8216	$rm_try
8217
8218	case "$ld" in
8219	    '') if $test $bin_ELF = "$define"; then
8220		    cat <<EOM
8221You appear to have ELF support.  I'll use $cc to build dynamic libraries.
8222EOM
8223		    dflt="$cc"
8224		else
8225		    echo "I'll use ld to build dynamic libraries."
8226		    dflt='ld'
8227		fi
8228		;;
8229	    *)  dflt="$ld"
8230		;;
8231	esac
8232
8233	rp="What command should be used to create dynamic libraries?"
8234	. ./myread
8235	ld="$ans"
8236
8237	cat << EOM
8238
8239Some systems may require passing special flags to $ld to create a
8240library that can be dynamically loaded.  If your ld flags include
8241-L/other/path options to locate libraries outside your loader's normal
8242search path, you may need to specify those -L options here as well.  To
8243use no flags, say "none".
8244
8245EOM
8246	case "$lddlflags" in
8247	    '') case "$osname" in
8248		    haiku) dflt='-shared' ;;
8249		    hpux) dflt='-b';
8250			  case "$gccversion" in
8251			      '') dflt="$dflt +vnocompatwarnings" ;;
8252			  esac
8253			  ;;
8254		    *linux*|irix*|gnu*)  dflt="-shared $optimize" ;;
8255		    next)  dflt='none' ;;
8256		    solaris) # See [perl #66604].
8257			    # On Solaris 11, gcc -m64 on amd64
8258			    # appears not to understand -G.  gcc versions at
8259			    # least as old as 3.4.3 support -shared, so just
8260			    # use that with Solaris 11 and later, but keep
8261			    # the old behavior for older Solaris versions.
8262			    case "$gccversion" in
8263				'') dflt='-G' ;;
8264				*)  case "$osvers" in
8265					2.?|2.10) dflt='-G' ;;
8266					*) dflt='-shared' ;;
8267				    esac
8268				    ;;
8269			    esac
8270			    ;;
8271		    sunos) dflt='-assert nodefinitions' ;;
8272		    svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
8273		    *)     dflt='none' ;;
8274		esac
8275		;;
8276	    *) dflt="$lddlflags" ;;
8277	esac
8278
8279	: Only do this for gcc, since, for example, qcc has no concept
8280	: of --sysroot.
8281	if $test "X$sysroot" != X; then
8282	    case "$gccversion" in
8283		'') ;;
8284		*)  dflt="$dflt --sysroot $sysroot" ;;
8285	    esac
8286	fi
8287
8288	: Try to guess additional flags to pick up local libraries.
8289	: Be careful not to append to a plain 'none'
8290	case "$dflt" in
8291	    none) dflt='' ;;
8292	esac
8293	for thisflag in $ldflags; do
8294	    case "$thisflag" in
8295		-L*|-R*|-Wl,-R*)
8296		    case " $dflt " in
8297			*" $thisflag "*) ;;
8298			*) dflt="$dflt $thisflag" ;;
8299		    esac
8300		    ;;
8301	    esac
8302	done
8303
8304	case "$dflt" in
8305	    ''|' ') dflt='none' ;;
8306	esac
8307
8308	case "$ldflags" in
8309	    *-fstack-protector*)
8310		case "$dflt" in
8311		    *-fstack-protector*) ;; # Don't add it again
8312		    *) dflt="$dflt -fstack-protector" ;;
8313		esac
8314		;;
8315	esac
8316
8317	rp="Any special flags to pass to $ld to create a dynamically loaded library?"
8318	. ./myread
8319	case "$ans" in
8320	    none) lddlflags=' ' ;;
8321	    *) lddlflags="$ans" ;;
8322	esac
8323
8324	cat <<EOM
8325
8326Some systems may require passing special flags to $cc to indicate that
8327the resulting executable will use dynamic linking.  To use no flags,
8328say "none".
8329
8330EOM
8331	case "$ccdlflags" in
8332	    '') case "$osname" in
8333		    *linux*|hpux|gnu*) dflt='-Wl,-E' ;;
8334		    next|sunos)      dflt='none'   ;;
8335		    *)               dflt='none'   ;;
8336		esac ;;
8337	    ' ') dflt='none' ;;
8338	    *)   dflt="$ccdlflags" ;;
8339	esac
8340	rp="Any special flags to pass to $cc to use dynamic linking?"
8341	. ./myread
8342	case "$ans" in
8343	    none) ccdlflags=' ' ;;
8344	    *)    ccdlflags="$ans" ;;
8345	esac
8346	;;
8347
8348    *)  usedl="$undef"
8349	ld='ld'
8350	dlsrc='dl_none.xs'
8351	lddlflags=''
8352	ccdlflags=''
8353	;;
8354esac
8355
8356ld_can_script="$undef"
8357case "$bin_ELF$usedl" in
8358    $define$define)
8359	# Abuse try.h and a.out names for neat cleanup
8360	$cat >try.c <<EOM
8361void foo() {}
8362void bar() {}
8363EOM
8364	$cat >try.h <<EOM
8365LIBTEST_42 {
8366 global:
8367  foo;
8368 local: *;
8369 };
8370EOM
8371	if $cc $cccdlflags $ccdlflags $ccflags \
8372	       $ldflags $lddlflags -o a.out try.c \
8373	       -Wl,--version-script=try.h >/dev/null 2>&1 \
8374	   &&  $test -s a.out ; then
8375	    echo "ld supports scripting" >&4
8376	    ld_can_script="$define"
8377	else
8378	    echo "ld does not support scripting" >&4
8379	fi
8380	$rm_try
8381	;;
8382esac
8383
8384: Do we want a shared libperl?
8385also=''
8386case "$usedl" in
8387$undef)
8388	# No dynamic loading being used, so don't bother even to prompt.
8389	useshrplib='false'
8390	;;
8391*)	case "$useshrplib" in
8392	'')	case "$osname" in
8393		svr4*|nonstopux|dgux|dynixptx|esix|powerux|haiku|cygwin*)
8394			dflt=y
8395			also='Building a shared libperl is required for dynamic loading to work on your system.'
8396			;;
8397		next*)
8398			case "$osvers" in
8399			4*)	dflt=y
8400				also='Building a shared libperl is needed for MAB support.'
8401				;;
8402			*)	dflt=n
8403				;;
8404			esac
8405			;;
8406		*)	dflt=n
8407			;;
8408		esac
8409		;;
8410	$define|true|[Yy]*)
8411		dflt=y
8412		;;
8413	*)	dflt=n
8414		;;
8415	esac
8416	$cat << EOM
8417
8418The perl executable is normally obtained by linking perlmain.c with
8419libperl${_a}, any static extensions (usually just DynaLoader), and
8420any other libraries needed on this system (such as -lm, etc.).  Since
8421your system supports dynamic loading, it is probably possible to build
8422a shared libperl.$so.  If you will have more than one executable linked
8423to libperl.$so, this will significantly reduce the size of each
8424executable, but it may have a noticeable effect on performance.  The
8425default is probably sensible for your system.
8426$also
8427
8428EOM
8429	rp="Build a shared libperl.$so (y/n)"
8430	. ./myread
8431	case "$ans" in
8432	true|$define|[Yy]*)
8433		useshrplib='true'  ;;
8434	*)	useshrplib='false' ;;
8435	esac
8436	;;
8437esac
8438
8439case "$useshrplib" in
8440true)
8441	case "$userelocatableinc" in
8442	true|define)
8443		echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
8444		echo "See INSTALL for an explanation why that won't work." >&4
8445		exit 4
8446		;;
8447	esac
8448	case "$libperl" in
8449	'')
8450		# Figure out a good name for libperl.so.  Since it gets stored in
8451		# a version-specific architecture-dependent library, the version
8452		# number isn't really that important, except for making cc/ld happy.
8453		#
8454		# A name such as libperl.so.10.1
8455		majmin="libperl.$so.$patchlevel.$subversion"
8456		# A name such as libperl.so.100
8457		majonly=`echo $patchlevel $subversion |
8458			$awk '{printf "%d%02d", $1, $2}'`
8459		majonly=libperl.$so.$majonly
8460		# I'd prefer to keep the os-specific stuff here to a minimum, and
8461		# rely on figuring it out from the naming of libc.
8462		case "${osname}${osvers}" in
8463		next4*)
8464			dflt=libperl.5.$so
8465			# XXX How handle the --version stuff for MAB?
8466			;;
8467		*linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
8468			dflt=libperl.$so
8469			;;
8470		cygwin*) # ld links now against the dll directly
8471			majmin="cygperl5_${patchlevel}_${subversion}.${so}"
8472			majonly=`echo $patchlevel $subversion |
8473				$awk '{printf "%03d%03d", $1, $2}'`
8474			majonly=cygperl5.$majonly.$so
8475			dflt=$majmin
8476			;;
8477		*)	# Try to guess based on whether libc has major.minor.
8478			case "$libc" in
8479			*libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
8480			*libc.$so.[0-9]*) dflt=$majonly ;;
8481			*)	dflt=libperl.$so ;;
8482			esac
8483			;;
8484		esac
8485		;;
8486	*)	dflt=$libperl
8487		;;
8488	esac
8489	cat << EOM
8490
8491I need to select a good name for the shared libperl.  If your system uses
8492library names with major and minor numbers, then you might want something
8493like $majmin.  Alternatively, if your system uses a single version
8494number for shared libraries, then you might want to use $majonly.
8495Or, your system might be quite happy with a simple libperl.$so.
8496
8497Since the shared libperl will get installed into a version-specific
8498architecture-dependent directory, the version number of the shared perl
8499library probably isn't important, so the default should be o.k.
8500
8501EOM
8502	rp='What name do you want to give to the shared libperl?'
8503	. ./myread
8504	libperl=$ans
8505	echo "Ok, I'll use $libperl"
8506	;;
8507*)
8508	libperl="libperl${_a}"
8509	;;
8510esac
8511
8512# Detect old use of shrpdir via undocumented Configure -Dshrpdir
8513case "$shrpdir" in
8514'') ;;
8515*)	$cat >&4 <<EOM
8516WARNING:  Use of the shrpdir variable for the installation location of
8517the shared $libperl is not supported.  It was never documented and
8518will not work in this version.  Let me (perlbug@perl.org)
8519know of any problems this may cause.
8520
8521EOM
8522	case "$shrpdir" in
8523	"$archlibexp/CORE")
8524		$cat >&4 <<EOM
8525But your current setting of $shrpdir is
8526the default anyway, so it's harmless.
8527EOM
8528		;;
8529	*)
8530		$cat >&4 <<EOM
8531Further, your current attempted setting of $shrpdir
8532conflicts with the value of $archlibexp/CORE
8533that installperl will use.
8534EOM
8535		;;
8536	esac
8537	;;
8538esac
8539
8540# How will the perl executable find the installed shared $libperl?
8541# Add $xxx to ccdlflags.
8542# If we can't figure out a command-line option, use $shrpenv to
8543# set env LD_RUN_PATH.  The main perl makefile uses this.
8544shrpdir=$archlibexp/CORE
8545xxx=''
8546tmp_shrpenv=''
8547if "$useshrplib"; then
8548    case "$osname" in
8549	aix)
8550		# We'll set it in Makefile.SH...
8551		;;
8552	solaris)
8553		xxx="-R $shrpdir"
8554		;;
8555	freebsd|mirbsd|netbsd|openbsd|interix|dragonfly|bitrig)
8556		xxx="-Wl,-R$shrpdir"
8557		;;
8558	bsdos|linux|irix*|dec_osf|gnu*|haiku)
8559		xxx="-Wl,-rpath,$shrpdir"
8560		;;
8561	next)
8562		# next doesn't like the default...
8563		;;
8564	hpux*)
8565		# hpux doesn't like the default, either.
8566		tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
8567		;;
8568	cygwin)
8569		# cygwin needs only ldlibpth
8570		;;
8571	*)
8572		tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
8573		;;
8574	esac
8575	case "$xxx" in
8576	'') ;;
8577	*)
8578		# Only add $xxx if it isn't already in ccdlflags.
8579		case " $ccdlflags " in
8580		*" $xxx "*)	;;
8581		*)	ccdlflags="$ccdlflags $xxx"
8582			cat <<EOM >&4
8583
8584Adding $xxx to the flags
8585passed to $ld so that the perl executable will find the
8586installed shared $libperl.
8587
8588EOM
8589			;;
8590		esac
8591		;;
8592	esac
8593fi
8594# Fix ccdlflags in AIX for building external extensions.
8595# (For building Perl itself bare -bE:perl.exp is needed,
8596#  Makefile.SH takes care of this.)
8597case "$osname" in
8598aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
8599esac
8600# Respect a hint or command-line value.
8601case "$shrpenv" in
8602'') shrpenv="$tmp_shrpenv" ;;
8603esac
8604case "$ldlibpthname" in
8605'')	ldlibpthname=LD_LIBRARY_PATH ;;
8606none)	ldlibpthname='' ;;
8607esac
8608
8609: determine where manual pages are on this system
8610echo " "
8611case "$sysman" in
8612'')
8613	syspath='/usr/share/man/man1 /usr/man/man1'
8614	syspath="$syspath /usr/man/mann /usr/man/manl /usr/man/local/man1"
8615	syspath="$syspath /usr/man/u_man/man1"
8616	syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
8617	syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
8618	syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
8619	sysman=`./loc . /usr/man/man1 $syspath`
8620	;;
8621esac
8622if $test -d "$sysman"; then
8623	echo "System manual is in $sysman." >&4
8624else
8625	echo "Could not find manual pages in source form." >&4
8626fi
8627
8628: determine where manual pages go
8629set man1dir man1dir none
8630eval $prefixit
8631$cat <<EOM
8632
8633$spackage has manual pages available in source form.
8634EOM
8635case "$nroff" in
8636nroff)
8637	echo "However, you don't have nroff, so they're probably useless to you."
8638	case "$man1dir" in
8639	'') man1dir="none";;
8640	esac;;
8641esac
8642echo "If you don't want the manual sources installed, answer 'none'."
8643case "$man1dir" in
8644' ') dflt=none
8645	;;
8646'')
8647	lookpath="$prefixexp/share/man/man1"
8648	lookpath="$lookpath $prefixexp/man/man1 $prefixexp/man/l_man/man1"
8649	lookpath="$lookpath $prefixexp/man/p_man/man1"
8650	lookpath="$lookpath $prefixexp/man/u_man/man1"
8651	lookpath="$lookpath $prefixexp/man/man.1"
8652	case "$sysman" in
8653	*/?_man*)	dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
8654	*)	dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
8655	esac
8656	set dflt
8657	eval $prefixup
8658	;;
8659*)  dflt="$man1dir"
8660	;;
8661esac
8662echo " "
8663fn=dn+~
8664rp="Where do the main $spackage manual pages (source) go?"
8665. ./getfile
8666if $test "X$man1direxp" != "X$ansexp"; then
8667	installman1dir=''
8668fi
8669prefixvar=man1dir
8670. ./setprefixvar
8671
8672case "$man1dir" in
8673'')	man1dir=' '
8674	installman1dir='';;
8675esac
8676
8677: What suffix to use on installed man pages
8678
8679case "$man1dir" in
8680' ')
8681	man1ext='0'
8682	;;
8683*)
8684	rp="What suffix should be used for the main $spackage man pages?"
8685	case "$man1ext" in
8686	'')	case "$man1dir" in
8687		*1)  dflt=1 ;;
8688		*1p) dflt=1p ;;
8689		*1pm) dflt=1pm ;;
8690		*l) dflt=l;;
8691		*n) dflt=n;;
8692		*o) dflt=o;;
8693		*p) dflt=p;;
8694		*C) dflt=C;;
8695		*L) dflt=L;;
8696		*L1) dflt=L1;;
8697		*) dflt=1;;
8698		esac
8699		;;
8700	*)	dflt="$man1ext";;
8701	esac
8702	. ./myread
8703	man1ext="$ans"
8704	;;
8705esac
8706
8707: see if we can have long filenames
8708echo " "
8709first=123456789abcdef
8710$rm -f $first
8711if (echo hi >$first) 2>/dev/null; then
8712	if $test -f 123456789abcde; then
8713		echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
8714		val="$undef"
8715	else
8716 		echo 'You can have filenames longer than 14 characters.'>&4
8717 		val="$define"
8718	fi
8719else
8720	$cat <<'EOM'
8721You can't have filenames longer than 14 chars.
8722You can't even think about them!
8723EOM
8724	val="$undef"
8725fi
8726set d_flexfnam
8727eval $setvar
8728$rm -rf 123456789abcde*
8729
8730: determine where library module manual pages go
8731set man3dir man3dir none
8732eval $prefixit
8733$cat <<EOM
8734
8735$spackage has manual pages for many of the library modules.
8736EOM
8737
8738case "$nroff" in
8739nroff)
8740	$cat <<'EOM'
8741However, you don't have nroff, so they're probably useless to you.
8742EOM
8743	case "$man3dir" in
8744	'') man3dir="none";;
8745	esac;;
8746esac
8747
8748case "$d_flexfnam" in
8749undef)
8750	$cat <<'EOM'
8751However, your system can't handle the long file names like File::Basename.3.
8752EOM
8753	case "$man3dir" in
8754	'') man3dir="none";;
8755	esac;;
8756esac
8757
8758echo "If you don't want the manual sources installed, answer 'none'."
8759prog=`echo $package | $sed 's/-*[0-9.]*$//'`
8760case "$man3dir" in
8761'')	dflt=`echo "$man1dir" | $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'`
8762	if $test -d "$privlib/man/man3"; then
8763		cat <<EOM >&4
8764
8765WARNING:  Previous versions of perl installed man3 pages into
8766$privlib/man/man3.  This version will suggest a
8767new default of $dflt.
8768EOM
8769		tdflt=$dflt
8770		dflt='n'
8771		rp='Do you wish to preserve the old behavior?(y/n)'
8772		. ./myread
8773		case "$ans" in
8774		y*) dflt="$privlib/man/man3" ;;
8775		*)  dflt=$tdflt ;;
8776		esac
8777    fi
8778	;;
8779*)	dflt="$man3dir" ;;
8780esac
8781case "$dflt" in
8782' ') dflt=none ;;
8783esac
8784echo " "
8785fn=dn+~
8786rp="Where do the $package library man pages (source) go?"
8787. ./getfile
8788prefixvar=man3dir
8789. ./setprefixvar
8790
8791case "$man3dir" in
8792'')	man3dir=' '
8793	installman3dir='';;
8794esac
8795
8796: What suffix to use on installed man pages
8797case "$man3dir" in
8798' ')
8799	man3ext='0'
8800	;;
8801*)
8802	rp="What suffix should be used for the $package library man pages?"
8803	case "$man3ext" in
8804	'')	case "$man3dir" in
8805		*3)  dflt=3 ;;
8806		*3p) dflt=3p ;;
8807		*3pm) dflt=3pm ;;
8808		*l) dflt=l;;
8809		*n) dflt=n;;
8810		*o) dflt=o;;
8811		*p) dflt=p;;
8812		*C) dflt=C;;
8813		*L) dflt=L;;
8814		*L3) dflt=L3;;
8815		*) dflt=3;;
8816		esac
8817		;;
8818	*)	dflt="$man3ext";;
8819	esac
8820	. ./myread
8821	man3ext="$ans"
8822	;;
8823esac
8824
8825: see if we have to deal with yellow pages, now NIS.
8826if $test -d /usr/etc/yp || $test -d /etc/yp || $test -d /usr/lib/yp; then
8827	if $test -f /usr/etc/nibindd; then
8828		echo " "
8829		echo "I'm fairly confident you're on a NeXT."
8830		echo " "
8831		rp='Do you get the hosts file via NetInfo?'
8832		dflt=y
8833		case "$hostcat" in
8834		nidump*) ;;
8835		'') ;;
8836		*) dflt=n;;
8837		esac
8838		. ./myread
8839		case "$ans" in
8840		y*) hostcat='nidump hosts .';;
8841		*)	case "$hostcat" in
8842			nidump*) hostcat='';;
8843			esac
8844			;;
8845		esac
8846	fi
8847	case "$hostcat" in
8848	nidump*) ;;
8849	*)
8850		case "$hostcat" in
8851		*ypcat*) dflt=y;;
8852		'') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
8853				dflt=y
8854			else
8855				dflt=n
8856			fi;;
8857		*) dflt=n;;
8858		esac
8859		echo " "
8860		rp='Are you getting the hosts file via yellow pages?'
8861		. ./myread
8862		case "$ans" in
8863		y*) hostcat='ypcat hosts';;
8864		*) hostcat='cat /etc/hosts';;
8865		esac
8866		;;
8867	esac
8868fi
8869case "$hostcat" in
8870'') test -f /etc/hosts && hostcat='cat /etc/hosts';;
8871esac
8872case "$groupcat" in
8873'') test -f /etc/group && groupcat='cat /etc/group';;
8874esac
8875case "$passcat" in
8876'') test -f /etc/passwd && passcat='cat /etc/passwd';;
8877esac
8878
8879: now get the host name
8880echo " "
8881echo "Figuring out host name..." >&4
8882case "$myhostname" in
8883'') cont=true
8884	echo 'Maybe "hostname" will work...'
8885	if tans=`sh -c hostname 2>&1` ; then
8886		myhostname=$tans
8887		phostname=hostname
8888		cont=''
8889	fi
8890	;;
8891*) cont='';;
8892esac
8893if $test "$cont"; then
8894	if ./xenix; then
8895		echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
8896		if tans=`cat /etc/systemid 2>&1` ; then
8897			myhostname=$tans
8898			phostname='cat /etc/systemid'
8899			echo "Whadyaknow.  Xenix always was a bit strange..."
8900			cont=''
8901		fi
8902	elif $test -r /etc/systemid; then
8903		echo "(What is a non-Xenix system doing with /etc/systemid?)"
8904	fi
8905fi
8906if $test "$cont"; then
8907	echo 'No, maybe "uuname -l" will work...'
8908	if tans=`sh -c 'uuname -l' 2>&1` ; then
8909		myhostname=$tans
8910		phostname='uuname -l'
8911	else
8912		echo 'Strange.  Maybe "uname -n" will work...'
8913		if tans=`sh -c 'uname -n' 2>&1` ; then
8914			myhostname=$tans
8915			phostname='uname -n'
8916		else
8917			echo 'Oh well, maybe I can mine it out of whoami.h...'
8918			if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
8919				myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
8920				phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
8921			else
8922				case "$myhostname" in
8923				'') echo "Does this machine have an identity crisis or something?"
8924					phostname='';;
8925				*)
8926					echo "Well, you said $myhostname before..."
8927					phostname='echo $myhostname';;
8928				esac
8929			fi
8930		fi
8931	fi
8932fi
8933case "$myhostname" in
8934'') myhostname=noname ;;
8935esac
8936: you do not want to know about this
8937set $myhostname
8938myhostname=$1
8939
8940: verify guess
8941if $test "$myhostname" ; then
8942	dflt=y
8943	rp='Your host name appears to be "'$myhostname'".'" Right?"
8944	. ./myread
8945	case "$ans" in
8946	y*) ;;
8947	*) myhostname='';;
8948	esac
8949fi
8950
8951: bad guess or no guess
8952while $test "X$myhostname" = X ; do
8953	dflt=''
8954	rp="Please type the (one word) name of your host:"
8955	. ./myread
8956	myhostname="$ans"
8957done
8958
8959: translate upper to lower if necessary
8960case "$myhostname" in
8961*[A-Z]*)
8962	echo "(Normalizing case in your host name)"
8963	myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
8964	;;
8965esac
8966
8967case "$myhostname" in
8968*.*)
8969	dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
8970	myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
8971	echo "(Trimming domain name from host name--host name is now $myhostname)"
8972	;;
8973*) case "$mydomain" in
8974	'')
8975		{
8976			test "X$hostcat" = "Xypcat hosts" &&
8977			ypmatch "$myhostname" hosts 2>/dev/null |\
8978				$sed -e 's/[	 ]*#.*//; s/$/ /' > hosts && \
8979			$test -s hosts
8980		} || {
8981			test "X$hostcat" != "X" &&
8982		     	$hostcat | $sed -n -e "s/[	 ]*#.*//; s/\$/ /
8983					/[	 ]$myhostname[	. ]/p" > hosts
8984		}
8985		tmp_re="[	. ]"
8986		if $test -f hosts; then
8987			$test x`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ { sum++ }
8988			     END { print sum }" hosts` = x1 || tmp_re="[	 ]"
8989			dflt=.`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
8990				hosts | $sort | $uniq | \
8991				$sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
8992			case `$echo X$dflt` in
8993			X*\ *)	echo "(Several hosts in the database matched hostname)"
8994				dflt=.
8995				;;
8996			X.) echo "(You do not have fully-qualified names in the hosts database)"
8997				;;
8998			esac
8999		else
9000			echo "(I cannot locate a hosts database anywhere)"
9001			dflt=.
9002		fi
9003		case "$dflt" in
9004		.)
9005			tans=`./loc resolv.conf X /etc /usr/etc`
9006			if $test -f "$tans"; then
9007				echo "(Attempting domain name extraction from $tans)"
9008				dflt=.`$sed -n -e 's/	/ /g' \
9009				  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
9010				  -e 1q 2>/dev/null`
9011				case "$dflt" in
9012				.) dflt=.`$sed -n -e 's/	/ /g' \
9013				     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
9014				     -e 1q 2>/dev/null`
9015  					;;
9016				esac
9017			fi
9018			;;
9019		esac
9020		case "$dflt" in
9021		.) echo "(No help from resolv.conf either -- attempting clever guess)"
9022			dflt=.`sh -c domainname 2>/dev/null`
9023			case "$dflt" in
9024			'') dflt='.';;
9025			.nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
9026			esac
9027			;;
9028		esac
9029		case "$dflt$osname" in
9030		.os390) echo "(Attempting domain name extraction from //'SYS1.TCPPARMS(TCPDATA)')"
9031			dflt=.`awk '/^DOMAINORIGIN/ {print $2}' "//'SYS1.TCPPARMS(TCPDATA)'" 2>/dev/null`
9032			;;
9033		esac
9034		case "$dflt" in
9035		.) echo "(Lost all hope -- silly guess then)"
9036			dflt='.nonet'
9037			;;
9038		esac
9039		$rm -f hosts
9040		;;
9041	*) dflt="$mydomain";;
9042	esac;;
9043esac
9044echo " "
9045rp="What is your domain name?"
9046. ./myread
9047tans="$ans"
9048case "$ans" in
9049'') ;;
9050.*) ;;
9051*) tans=".$tans";;
9052esac
9053mydomain="$tans"
9054
9055: translate upper to lower if necessary
9056case "$mydomain" in
9057*[A-Z]*)
9058	echo "(Normalizing case in your domain name)"
9059	mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
9060	;;
9061esac
9062
9063: a little sanity check here
9064case "$phostname" in
9065'') ;;
9066*)
9067	case `$phostname | ./tr '[A-Z]' '[a-z]'` in
9068	$myhostname$mydomain|$myhostname) ;;
9069	*)
9070		case "$phostname" in
9071		sed*)
9072			echo "(That doesn't agree with your whoami.h file, by the way.)"
9073			;;
9074		*)
9075			echo "(That doesn't agree with your $phostname command, by the way.)"
9076			;;
9077		esac
9078	;;
9079	esac
9080	;;
9081esac
9082
9083: determine the e-mail address of the user who is running us
9084$cat <<EOM
9085
9086I need to get your e-mail address in Internet format if possible, i.e.
9087something like user@host.domain. Please answer accurately since I have
9088no easy means to double check it. The default value provided below
9089is most probably close to reality but may not be valid from outside
9090your organization...
9091
9092EOM
9093cont=x
9094while test "$cont"; do
9095	case "$MAILDOMAIN" in
9096	'')
9097		if $test -s /etc/mailname; then
9098			maildomain=`$cat /etc/mailname`
9099		else
9100			maildomain="$myhostname$mydomain"
9101		fi
9102		;;
9103	*)  maildomain="$MAILDOMAIN";;
9104	esac
9105	case "$cf_email" in
9106	'') dflt="$cf_by@$maildomain";;
9107	*)  dflt="$cf_email";;
9108	esac
9109	rp='What is your e-mail address?'
9110	. ./myread
9111	cf_email="$ans"
9112	case "$cf_email" in
9113	*@*.*) cont='' ;;
9114	*)
9115		rp='Address does not look like an Internet one.  Use it anyway?'
9116		case "$fastread" in
9117		yes) dflt=y ;;
9118		*) dflt=n ;;
9119		esac
9120		. ./myread
9121		case "$ans" in
9122		y*) cont='' ;;
9123		*) echo " " ;;
9124		esac
9125		;;
9126	esac
9127done
9128
9129: Ask e-mail of administrator
9130$cat <<EOM
9131
9132If you or somebody else will be maintaining perl at your site, please
9133fill in the correct e-mail address here so that they may be contacted
9134if necessary. Currently, the "perlbug" program included with perl
9135will send mail to this address in addition to perlbug@perl.org. You may
9136enter "none" for no administrator.
9137
9138EOM
9139case "$perladmin" in
9140'') dflt="$cf_email";;
9141*) dflt="$perladmin";;
9142esac
9143rp='Perl administrator e-mail address'
9144. ./myread
9145perladmin="$ans"
9146
9147: determine whether to only install version-specific parts.
9148echo " "
9149$cat <<EOM
9150Do you want to install only the version-specific parts of the perl
9151distribution?  Usually you do *not* want to do this.
9152EOM
9153case "$versiononly" in
9154"$define"|[Yy]*|true) dflt='y' ;;
9155*) dflt='n';
9156esac
9157rp="Do you want to install only the version-specific parts of perl?"
9158. ./myread
9159case "$ans" in
9160[yY]*)	val="$define";;
9161*)	val="$undef" ;;
9162esac
9163set versiononly
9164eval $setvar
9165
9166case "$versiononly" in
9167"$define") inc_version_list=''
9168           inc_version_list_init=0
9169           ;;
9170esac
9171
9172: figure out how to guarantee perl startup
9173: XXX Note that this currently takes advantage of the bug that binexp ignores
9174:     the Configure -Dinstallprefix setting, which in turn means that under
9175:     relocatable @INC, initialinstalllocation is what binexp started as.
9176case "$startperl" in
9177'')
9178	case "$sharpbang" in
9179	*!)
9180		$cat <<EOH
9181
9182I can use the #! construct to start perl on your system. This will
9183make startup of perl scripts faster, but may cause problems if you
9184want to share those scripts and perl is not in a standard place
9185($initialinstalllocation/perl) on all your platforms. The alternative
9186is to force a shell by starting the script with a single ':' character.
9187
9188EOH
9189		case "$versiononly" in
9190		"$define")      dflt="$initialinstalllocation/perl$version";;
9191		*)              dflt="$initialinstalllocation/perl";;
9192		esac
9193		rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
9194		. ./myread
9195		case "$ans" in
9196		none)	startperl=": # use perl";;
9197		*)	startperl="#!$ans"
9198			if $test 30 -lt `echo "$ans" | wc -c`; then
9199				$cat >&4 <<EOM
9200
9201WARNING:  Some systems limit the #! command to 32 characters.
9202If you experience difficulty running Perl scripts with #!, try
9203installing Perl in a directory with a shorter pathname.
9204
9205EOM
9206			fi ;;
9207		esac
9208		;;
9209	*) startperl=": # use perl"
9210		;;
9211	esac
9212	;;
9213esac
9214echo "I'll use $startperl to start perl scripts."
9215
9216: figure best path for perl in scripts
9217case "$perlpath" in
9218'')
9219	case "$versiononly" in
9220	"$define")	perlpath="$initialinstalllocation/perl$version";;
9221	*)		perlpath="$initialinstalllocation/perl";;
9222	esac
9223	case "$startperl" in
9224	*!*) ;;
9225	*)
9226		$cat <<EOH
9227
9228I will use the "eval 'exec'" idiom to start Perl on your system.
9229I can use the full path of your Perl binary for this purpose, but
9230doing so may cause problems if you want to share those scripts and
9231Perl is not always in a standard place ($initialinstalllocation/perl).
9232
9233EOH
9234		dflt="$initialinstalllocation/perl"
9235		rp="What path shall I use in \"eval 'exec'\"?"
9236		. ./myread
9237		perlpath="$ans"
9238		;;
9239	esac
9240	;;
9241esac
9242case "$startperl" in
9243*!*)	;;
9244*)	echo "I'll use $perlpath in \"eval 'exec'\"" ;;
9245esac
9246
9247: determine where public executable scripts go
9248set scriptdir scriptdir
9249eval $prefixit
9250case "$scriptdir" in
9251'')
9252	dflt="$bin"
9253	: guess some guesses
9254	$test -d /usr/share/scripts && dflt=/usr/share/scripts
9255	$test -d /usr/share/bin     && dflt=/usr/share/bin
9256	$test -d /usr/local/script  && dflt=/usr/local/script
9257	$test -d /usr/local/scripts && dflt=/usr/local/scripts
9258	$test -d $prefixexp/script  && dflt=$prefixexp/script
9259	set dflt
9260	eval $prefixup
9261	;;
9262*)  dflt="$scriptdir"
9263	;;
9264esac
9265$cat <<EOM
9266
9267Some installations have a separate directory just for executable scripts so
9268that they can mount it across multiple architectures but keep the scripts in
9269one spot.  You might, for example, have a subdirectory of /usr/share for this.
9270Or you might just lump your scripts in with all your other executables.
9271
9272EOM
9273fn=d~
9274rp='Where do you keep publicly executable scripts?'
9275. ./getfile
9276if $test "X$ansexp" != "X$scriptdirexp"; then
9277	installscript=''
9278fi
9279installscriptdir=''
9280prefixvar=scriptdir
9281. ./setprefixvar
9282: A little fix up for an irregularly named variable.
9283installscript="$installscriptdir"
9284
9285: determine where add-on public executables go
9286case "$sitebin" in
9287'')	dflt=$siteprefix/bin ;;
9288*)	dflt=$sitebin ;;
9289esac
9290fn=d~
9291rp='Pathname where the add-on public executables should be installed?'
9292. ./getfile
9293prefixvar=sitebin
9294. ./setprefixvar
9295
9296: determine where add-on html pages go
9297: There is no standard location, so try to copy the previously-selected
9298: directory structure for the core html pages.
9299case "$sitehtml1dir" in
9300'')    dflt=`echo "$html1dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9301*)     dflt=$sitehtml1dir ;;
9302esac
9303case "$dflt" in
9304''|' ') dflt=none ;;
9305esac
9306fn=dn+~
9307rp='Pathname where the site-specific html pages should be installed?'
9308. ./getfile
9309prefixvar=sitehtml1dir
9310. ./setprefixvar
9311
9312: determine where add-on library html pages go
9313: There is no standard location, so try to copy the previously-selected
9314: directory structure for the core html pages.
9315case "$sitehtml3dir" in
9316'')    dflt=`echo "$html3dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9317*)     dflt=$sitehtml3dir ;;
9318esac
9319case "$dflt" in
9320''|' ') dflt=none ;;
9321esac
9322fn=dn+~
9323rp='Pathname where the site-specific library html pages should be installed?'
9324. ./getfile
9325prefixvar=sitehtml3dir
9326. ./setprefixvar
9327
9328: determine where add-on manual pages go
9329case "$siteman1dir" in
9330'')	dflt=`echo $man1dir | $sed "s#^$prefix#$siteprefix#"` ;;
9331*)	dflt=$siteman1dir ;;
9332esac
9333case "$dflt" in
9334''|' ') dflt=none ;;
9335esac
9336fn=dn+~
9337rp='Pathname where the site-specific manual pages should be installed?'
9338. ./getfile
9339prefixvar=siteman1dir
9340. ./setprefixvar
9341
9342: determine where add-on library man pages go
9343case "$siteman3dir" in
9344'')	dflt=`echo $man3dir | $sed "s#^$prefix#$siteprefix#"` ;;
9345*)	dflt=$siteman3dir ;;
9346esac
9347case "$dflt" in
9348''|' ') dflt=none ;;
9349esac
9350fn=dn+~
9351rp='Pathname where the site-specific library manual pages should be installed?'
9352. ./getfile
9353prefixvar=siteman3dir
9354. ./setprefixvar
9355
9356: determine where add-on public executable scripts go
9357case "$sitescript" in
9358'')	dflt=$siteprefix/script
9359	$test -d $dflt || dflt=$sitebin ;;
9360*)  dflt="$sitescript" ;;
9361esac
9362fn=d~+
9363rp='Pathname where add-on public executable scripts should be installed?'
9364. ./getfile
9365prefixvar=sitescript
9366. ./setprefixvar
9367
9368: Check if faststdio is requested and available
9369case "$usefaststdio" in
9370$define|true|[yY]*|'')
9371	xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
9372	case "$xversion" in
9373	[68])	dflt='y' ;;
9374	*)	dflt='n' ;;
9375	esac
9376	;;
9377*) dflt='n';;
9378esac
9379cat <<EOM
9380
9381Perl can be built to use 'fast stdio', which means using the stdio
9382library but also directly manipulating the stdio buffers to enable
9383faster I/O.  Using stdio is better for backward compatibility (especially
9384for Perl extensions), but on the other hand since Perl 5.8 the 'perlio'
9385interface has been preferred instead of stdio.
9386
9387If this doesn't make any sense to you, just accept the default '$dflt'.
9388EOM
9389rp='Use the "fast stdio" if available?'
9390. ./myread
9391case "$ans" in
9392y|Y)	val="$define" ;;
9393*)      val="$undef" ;;
9394esac
9395set usefaststdio
9396eval $setvar
9397
9398
9399: define an is-a-typedef? function
9400typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9401case "$inclist" in
9402"") inclist="sys/types.h";;
9403esac;
9404eval "varval=\$$var";
9405case "$varval" in
9406"")
9407	$rm -f temp.c;
9408	for inc in $inclist; do
9409		echo "#include <$inc>" >>temp.c;
9410	done;
9411	echo "#ifdef $type" >> temp.c;
9412	echo "printf(\"We have $type\");" >> temp.c;
9413	echo "#endif" >> temp.c;
9414	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9415	if $contains $type temp.E >/dev/null 2>&1; then
9416		eval "$var=\$type";
9417	else
9418		eval "$var=\$def";
9419	fi;
9420	$rm -f temp.?;;
9421*) eval "$var=\$varval";;
9422esac'
9423
9424: define an is-a-typedef? function that prompts if the type is not available.
9425typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9426case "$inclist" in
9427"") inclist="sys/types.h";;
9428esac;
9429eval "varval=\$$var";
9430case "$varval" in
9431"")
9432	$rm -f temp.c;
9433	for inc in $inclist; do
9434		echo "#include <$inc>" >>temp.c;
9435	done;
9436	echo "#ifdef $type" >> temp.c;
9437	echo "printf(\"We have $type\");" >> temp.c;
9438	echo "#endif" >> temp.c;
9439	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9440	echo " " ;
9441	echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
9442	if $contains $type temp.E >/dev/null 2>&1; then
9443		echo "$type found." >&4;
9444		eval "$var=\$type";
9445	else
9446		echo "$type NOT found." >&4;
9447		dflt="$def";
9448		. ./myread ;
9449		eval "$var=\$ans";
9450	fi;
9451	$rm -f temp.?;;
9452*) eval "$var=\$varval";;
9453esac'
9454
9455: see what type lseek is declared as in the kernel
9456rp="What is the type used for lseek's offset on this system?"
9457set off_t lseektype long stdio.h sys/types.h
9458eval $typedef_ask
9459
9460echo " "
9461echo "Checking to see how big your file offsets are..." >&4
9462$cat >try.c <<EOCP
9463#include <sys/types.h>
9464#include <stdio.h>
9465int main()
9466{
9467    printf("%d\n", (int)sizeof($lseektype));
9468    return(0);
9469}
9470EOCP
9471set try
9472if eval $compile_ok; then
9473	lseeksize=`$run ./try`
9474	echo "Your file offsets are $lseeksize bytes long."
9475else
9476	dflt=$longsize
9477	echo " "
9478	echo "(I can't seem to compile the test program.  Guessing...)"
9479	rp="What is the size of your file offsets (in bytes)?"
9480	. ./myread
9481	lseeksize="$ans"
9482fi
9483$rm_try
9484
9485: see what type file positions are declared as in the library
9486rp="What is the type for file position used by fsetpos()?"
9487set fpos_t fpostype long stdio.h sys/types.h
9488eval $typedef_ask
9489
9490: Check size for Fpos_t
9491echo " "
9492case "$fpostype" in
9493*_t) zzz="$fpostype"	;;
9494*)   zzz="fpos_t"	;;
9495esac
9496echo "Checking the size of $zzz..." >&4
9497cat > try.c <<EOCP
9498#include <sys/types.h>
9499#include <stdio.h>
9500#$i_stdlib I_STDLIB
9501#ifdef I_STDLIB
9502#include <stdlib.h>
9503#endif
9504int main() {
9505    printf("%d\n", (int)sizeof($fpostype));
9506    exit(0);
9507}
9508EOCP
9509set try
9510if eval $compile_ok; then
9511	yyy=`$run ./try`
9512	case "$yyy" in
9513	'')	fpossize=4
9514		echo "(I can't execute the test program--guessing $fpossize.)" >&4
9515		;;
9516	*)	fpossize=$yyy
9517		echo "Your $zzz is $fpossize bytes long."
9518		;;
9519	esac
9520else
9521	dflt="$longsize"
9522	echo " " >&4
9523	echo "(I can't compile the test program.  Guessing...)" >&4
9524	rp="What is the size of your file positions (in bytes)?"
9525	. ./myread
9526	fpossize="$ans"
9527fi
9528
9529: Check for large file support
9530# Backward compatibility (uselfs is deprecated).
9531case "$uselfs" in
9532"$define"|true|[yY]*)
9533	cat <<EOM >&4
9534
9535*** Configure -Duselfs is deprecated, using -Duselargefiles instead.
9536EOM
9537	uselargefiles="$define"
9538	;;
9539esac
9540
9541case "$lseeksize:$fpossize" in
95428:8) cat <<EOM
9543
9544You can have files larger than 2 gigabytes.
9545EOM
9546   val="$define" ;;
9547*)    case "$uselargefiles" in
9548   "$undef"|false|[nN]*) dflt='n' ;;
9549   *)	dflt='y' ;;
9550   esac
9551   cat <<EOM
9552
9553Perl can be built to understand large files (files larger than 2 gigabytes)
9554on some systems.  To do so, Configure can be run with -Duselargefiles.
9555
9556If this doesn't make any sense to you, just accept the default '$dflt'.
9557EOM
9558   rp='Try to understand large files, if available?'
9559   . ./myread
9560   case "$ans" in
9561   y|Y) 	val="$define" ;;
9562   *)   	val="$undef"  ;;
9563   esac
9564   ;;
9565esac
9566set uselargefiles
9567eval $setvar
9568: Look for a hint-file generated 'call-back-unit'.  If the
9569: user has specified that a large files perl is to be built,
9570: we may need to set or change some other defaults.
9571if $test -f uselargefiles.cbu; then
9572	echo "Your platform has some specific hints regarding large file builds, using them..."
9573	. ./uselargefiles.cbu
9574fi
9575case "$uselargefiles" in
9576"$define")
9577	if $test -f uselargefiles.cbu; then
9578		echo " "
9579		echo "Rechecking to see how big your file offsets are..." >&4
9580		$cat >try.c <<EOCP
9581#include <sys/types.h>
9582#include <stdio.h>
9583int main()
9584{
9585    printf("%d\n", (int)sizeof($lseektype));
9586    return(0);
9587}
9588EOCP
9589		set try
9590		if eval $compile_ok; then
9591			lseeksize=`$run ./try`
9592			$echo "Your file offsets are now $lseeksize bytes long."
9593		else
9594			dflt="$lseeksize"
9595			echo " "
9596			echo "(I can't seem to compile the test program.  Guessing...)"
9597			rp="What is the size of your file offsets (in bytes)?"
9598			. ./myread
9599			lseeksize="$ans"
9600		fi
9601		case "$fpostype" in
9602		*_t) zzz="$fpostype"	;;
9603		*)   zzz="fpos_t"	;;
9604		esac
9605		$echo $n "Rechecking the size of $zzz...$c" >&4
9606		$cat > try.c <<EOCP
9607#include <sys/types.h>
9608#include <stdio.h>
9609#$i_stdlib I_STDLIB
9610#ifdef I_STDLIB
9611#include <stdlib.h>
9612#endif
9613int main() {
9614    printf("%d\n", (int)sizeof($fpostype));
9615    return(0);
9616}
9617EOCP
9618		set try
9619		if eval $compile_ok; then
9620			yyy=`$run ./try`
9621			dflt="$lseeksize"
9622			case "$yyy" in
9623			'')	echo " "
9624				echo "(I can't execute the test program--guessing $fpossize.)" >&4
9625				;;
9626			*)	fpossize=$yyy
9627				echo " $fpossize bytes." >&4
9628				;;
9629			esac
9630		else
9631			dflt="$fpossize"
9632			echo " "
9633			echo "(I can't compile the test program.  Guessing...)" >&4
9634			rp="What is the size of your file positions (in bytes)?"
9635			. ./myread
9636			fpossize="$ans"
9637		fi
9638		$rm_try
9639	fi
9640	;;
9641esac
9642
9643: Check if we want perlio
9644useperlio="$define"
9645
9646: Set the vendorbin variables
9647case "$vendorprefix" in
9648'')	d_vendorbin="$undef"
9649	vendorbin=''
9650	vendorbinexp=''
9651	;;
9652*)	d_vendorbin="$define"
9653	: determine where vendor-supplied executables go.
9654	case "$vendorbin" in
9655	'') dflt=$vendorprefix/bin ;;
9656	*)	dflt="$vendorbin" ;;
9657	esac
9658	fn=d~+
9659	rp='Pathname for the vendor-supplied executables directory?'
9660	. ./getfile
9661	vendorbin="$ans"
9662	vendorbinexp="$ansexp"
9663	;;
9664esac
9665prefixvar=vendorbin
9666. ./installprefix
9667
9668: Set the vendorhtml1dir variables
9669case "$vendorprefix" in
9670'')	vendorhtml1dir=''
9671	vendorhtml1direxp=''
9672	;;
9673*)	: determine where vendor-supplied html pages go.
9674	: There is no standard location, so try to copy the previously-selected
9675	: directory structure for the core html pages.
9676	: XXX Better default suggestions would be welcome.
9677	case "$vendorhtml1dir" in
9678	'')	dflt=`echo "$html1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9679	*)	dflt=$vendorhtml1dir ;;
9680	esac
9681	case "$dflt" in
9682	''|' ') dflt=none ;;
9683	esac
9684	fn=dn+~
9685	rp='Pathname for the vendor-supplied html pages?'
9686	. ./getfile
9687	vendorhtml1dir="$ans"
9688	vendorhtml1direxp="$ansexp"
9689	;;
9690esac
9691: Use ' ' for none so value is preserved next time through Configure
9692$test X"$vendorhtml1dir" = "X" && vendorhtml1dir=' '
9693prefixvar=vendorhtml1dir
9694. ./installprefix
9695
9696: Set the vendorhtml3dir variables
9697case "$vendorprefix" in
9698'')	vendorhtml3dir=''
9699	vendorhtml3direxp=''
9700	;;
9701*)	: determine where vendor-supplied module html pages go.
9702	: There is no standard location, so try to copy the previously-selected
9703	: directory structure for the core html pages.
9704	: XXX Better default suggestions would be welcome.
9705	case "$vendorhtml3dir" in
9706	'')	dflt=`echo "$html3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9707	*)	dflt=$vendorhtml3dir ;;
9708	esac
9709	case "$dflt" in
9710	''|' ') dflt=none ;;
9711	esac
9712	fn=dn+~
9713	rp='Pathname for the vendor-supplied html pages?'
9714	. ./getfile
9715	vendorhtml3dir="$ans"
9716	vendorhtml3direxp="$ansexp"
9717	;;
9718esac
9719: Use ' ' for none so value is preserved next time through Configure
9720$test X"$vendorhtml3dir" = "X" && vendorhtml3dir=' '
9721prefixvar=vendorhtml3dir
9722. ./installprefix
9723
9724: Set the vendorman1dir variables
9725case "$vendorprefix" in
9726'')	vendorman1dir=''
9727	vendorman1direxp=''
9728	;;
9729*)	: determine where vendor-supplied manual pages go.
9730	case "$vendorman1dir" in
9731	'') dflt=`echo "$man1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9732	*)	dflt=$vendorman1dir ;;
9733	esac
9734	case "$dflt" in
9735	''|' ') dflt=none ;;
9736	esac
9737	fn=nd~+
9738	rp='Pathname for the vendor-supplied manual section 1 pages?'
9739	. ./getfile
9740	vendorman1dir="$ans"
9741	vendorman1direxp="$ansexp"
9742	;;
9743esac
9744: Use ' ' for none so value is preserved next time through Configure
9745$test X"$vendorman1dir" = "X" && vendorman1dir=' '
9746prefixvar=vendorman1dir
9747. ./installprefix
9748
9749: Set the vendorman3dir variables
9750case "$vendorprefix" in
9751'')	vendorman3dir=''
9752	vendorman3direxp=''
9753	;;
9754*)	: determine where vendor-supplied module manual pages go.
9755	case "$vendorman3dir" in
9756	'') dflt=`echo "$man3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9757	*)	dflt=$vendorman3dir ;;
9758	esac
9759	case "$dflt" in
9760	''|' ') dflt=none ;;
9761	esac
9762	fn=nd~+
9763	rp='Pathname for the vendor-supplied manual section 3 pages?'
9764	. ./getfile
9765	vendorman3dir="$ans"
9766	vendorman3direxp="$ansexp"
9767	;;
9768esac
9769: Use ' ' for none so value is preserved next time through Configure
9770$test X"$vendorman3dir" = "X" && vendorman3dir=' '
9771prefixvar=vendorman3dir
9772. ./installprefix
9773
9774: Set the vendorscript variables
9775case "$vendorprefix" in
9776'')	d_vendorscript="$undef"
9777	vendorscript=''
9778	vendorscriptexp=''
9779	;;
9780*)	d_vendorscript="$define"
9781	: determine where vendor-supplied scripts go.
9782	case "$vendorscript" in
9783	'')	dflt=$vendorprefix/script
9784		$test -d $dflt || dflt=$vendorbin ;;
9785	*)  dflt="$vendorscript" ;;
9786	esac
9787	$cat <<EOM
9788
9789The installation process will create a directory for
9790vendor-supplied scripts.
9791
9792EOM
9793	fn=d~+
9794	rp='Pathname for the vendor-supplied scripts directory?'
9795	. ./getfile
9796	vendorscript="$ans"
9797	vendorscriptexp="$ansexp"
9798	;;
9799esac
9800prefixvar=vendorscript
9801. ./installprefix
9802
9803: script used to emit important warnings
9804cat >warn <<EOS
9805$startsh
9806if test \$# -gt 0; then
9807	echo "\$@" >msg
9808else
9809	cat >msg
9810fi
9811echo "*** WARNING:" >&4
9812sed -e 's/^/*** /' <msg >&4
9813echo "*** " >&4
9814cat msg >>config.msg
9815echo " " >>config.msg
9816rm -f msg
9817EOS
9818chmod +x warn
9819$eunicefix warn
9820
9821: see which of string.h or strings.h is needed
9822echo " "
9823strings=`./findhdr string.h`
9824if $test "$strings" && $test -r "$strings"; then
9825	echo "Using <string.h> instead of <strings.h>." >&4
9826	val="$define"
9827else
9828	val="$undef"
9829	strings=`./findhdr strings.h`
9830	if $test "$strings" && $test -r "$strings"; then
9831		echo "Using <strings.h> instead of <string.h>." >&4
9832	else
9833		./warn "No string header found -- You'll surely have problems."
9834	fi
9835fi
9836set i_string
9837eval $setvar
9838case "$i_string" in
9839"$undef") strings=`./findhdr strings.h`;;
9840*)	  strings=`./findhdr string.h`;;
9841esac
9842
9843: see if qgcvt exists
9844set qgcvt d_qgcvt
9845eval $inlibc
9846
9847: Check print/scan long double stuff
9848echo " "
9849
9850if $test X"$d_longdbl" = X"$define"; then
9851
9852echo "Checking how to print long doubles..." >&4
9853
9854if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
9855	$cat >try.c <<'EOCP'
9856#include <sys/types.h>
9857#include <stdio.h>
9858int main() {
9859  double d = 123.456;
9860  printf("%.3f\n", d);
9861}
9862EOCP
9863	set try
9864	if eval $compile; then
9865		yyy=`$run ./try`
9866		case "$yyy" in
9867		123.456)
9868			sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
9869                	sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
9870			echo "We will use %f."
9871			;;
9872		esac
9873	fi
9874fi
9875
9876if $test X"$sPRIfldbl" = X; then
9877	$cat >try.c <<'EOCP'
9878#include <sys/types.h>
9879#include <stdio.h>
9880int main() {
9881  long double d = 123.456;
9882  printf("%.3Lf\n", d);
9883}
9884EOCP
9885	set try
9886	if eval $compile; then
9887		yyy=`$run ./try`
9888		case "$yyy" in
9889		123.456)
9890			sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
9891                	sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
9892			echo "We will use %Lf."
9893			;;
9894		esac
9895	fi
9896fi
9897
9898if $test X"$sPRIfldbl" = X; then
9899	$cat >try.c <<'EOCP'
9900#include <sys/types.h>
9901#include <stdio.h>
9902int main() {
9903  long double d = 123.456;
9904  printf("%.3llf\n", d);
9905}
9906EOCP
9907	set try
9908	if eval $compile; then
9909		yyy=`$run ./try`
9910		case "$yyy" in
9911		123.456)
9912			sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
9913                	sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
9914			echo "We will use %llf."
9915			;;
9916		esac
9917	fi
9918fi
9919
9920if $test X"$sPRIfldbl" = X; then
9921	$cat >try.c <<'EOCP'
9922#include <sys/types.h>
9923#include <stdio.h>
9924int main() {
9925  long double d = 123.456;
9926  printf("%.3lf\n", d);
9927}
9928EOCP
9929	set try
9930	if eval $compile; then
9931		yyy=`$run ./try`
9932		case "$yyy" in
9933		123.456)
9934			sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
9935                	sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
9936			echo "We will use %lf."
9937			;;
9938		esac
9939	fi
9940fi
9941
9942if $test X"$sPRIfldbl" = X; then
9943	echo "Cannot figure out how to print long doubles." >&4
9944else
9945	sSCNfldbl=$sPRIfldbl	# expect consistency
9946fi
9947
9948$rm_try
9949
9950fi # d_longdbl
9951
9952case "$sPRIfldbl" in
9953'')	d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
9954	d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
9955	d_SCNfldbl="$undef";
9956	;;
9957*)	d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
9958	d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
9959	d_SCNfldbl="$define";
9960	;;
9961esac
9962
9963: Check how to convert floats to strings.
9964
9965if test "X$d_Gconvert" = X; then
9966
9967echo " "
9968echo "Checking for an efficient way to convert floats to strings."
9969echo " " > try.c
9970case "$uselongdouble" in
9971"$define") echo "#define USE_LONG_DOUBLE" >>try.c ;;
9972esac
9973case "$d_longdbl" in
9974"$define") echo "#define HAS_LONG_DOUBLE" >>try.c ;;
9975esac
9976case "$d_PRIgldbl" in
9977"$define") echo "#define HAS_PRIgldbl"    >>try.c ;;
9978esac
9979$cat >>try.c <<EOP
9980#ifdef TRY_gconvert
9981#define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
9982char *myname = "gconvert";
9983#endif
9984#ifdef TRY_gcvt
9985#define Gconvert(x,n,t,b) gcvt((x),(n),(b))
9986char *myname = "gcvt";
9987#endif
9988#ifdef TRY_qgcvt
9989#define Gconvert(x,n,t,b) qgcvt((x),(n),(b))
9990char *myname = "qgcvt";
9991#define DOUBLETYPE long double
9992#endif
9993#ifdef TRY_sprintf
9994#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
9995#ifdef HAS_PRIgldbl
9996#define Gconvert(x,n,t,b) sprintf((b),"%.*"$sPRIgldbl,(n),(x))
9997#else
9998#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(double)(x))
9999#endif
10000#else
10001#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
10002#endif
10003char *myname = "sprintf";
10004#endif
10005
10006#ifndef DOUBLETYPE
10007#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10008#define DOUBLETYPE long double
10009#else
10010#define DOUBLETYPE double
10011#endif
10012#endif
10013
10014#include <stdio.h>
10015
10016#$i_stdlib I_STDLIB
10017#ifdef I_STDLIB
10018#include <stdlib.h>
10019#endif
10020#$i_string I_STRING
10021#ifdef I_STRING
10022#  include <string.h>
10023#else
10024#  include <strings.h>
10025#endif
10026
10027int checkit(char *expect, char *got)
10028{
10029    if (strcmp(expect, got)) {
10030		printf("%s oddity:  Expected %s, got %s\n",
10031			myname, expect, got);
10032		exit(1);
10033	}
10034}
10035
10036int main()
10037{
10038	char buf[64];
10039	buf[63] = '\0';
10040
10041	/* This must be 1st test on (which?) platform */
10042	/* Alan Burlison <AlanBurlsin@unn.unisys.com> */
10043	Gconvert((DOUBLETYPE)0.1, 8, 0, buf);
10044	checkit("0.1", buf);
10045
10046	Gconvert((DOUBLETYPE)0.01, 8, 0, buf);
10047	checkit("0.01", buf);
10048
10049	Gconvert((DOUBLETYPE)0.001, 8, 0, buf);
10050	checkit("0.001", buf);
10051
10052	Gconvert((DOUBLETYPE)0.0001, 8, 0, buf);
10053	checkit("0.0001", buf);
10054
10055	Gconvert((DOUBLETYPE)0.00009, 8, 0, buf);
10056	if (strlen(buf) > 5)
10057	    checkit("9e-005", buf); /* for Microsoft ?? */
10058	else
10059	    checkit("9e-05", buf);
10060
10061	Gconvert((DOUBLETYPE)1.0, 8, 0, buf);
10062	checkit("1", buf);
10063
10064	Gconvert((DOUBLETYPE)1.1, 8, 0, buf);
10065	checkit("1.1", buf);
10066
10067	Gconvert((DOUBLETYPE)1.01, 8, 0, buf);
10068	checkit("1.01", buf);
10069
10070	Gconvert((DOUBLETYPE)1.001, 8, 0, buf);
10071	checkit("1.001", buf);
10072
10073	Gconvert((DOUBLETYPE)1.0001, 8, 0, buf);
10074	checkit("1.0001", buf);
10075
10076	Gconvert((DOUBLETYPE)1.00001, 8, 0, buf);
10077	checkit("1.00001", buf);
10078
10079	Gconvert((DOUBLETYPE)1.000001, 8, 0, buf);
10080	checkit("1.000001", buf);
10081
10082	Gconvert((DOUBLETYPE)0.0, 8, 0, buf);
10083	checkit("0", buf);
10084
10085	Gconvert((DOUBLETYPE)-1.0, 8, 0, buf);
10086	checkit("-1", buf);
10087
10088	/* Some Linux gcvt's give 1.e+5 here. */
10089	Gconvert((DOUBLETYPE)100000.0, 8, 0, buf);
10090	checkit("100000", buf);
10091
10092	/* Some Linux gcvt's give -1.e+5 here. */
10093	Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf);
10094	checkit("-100000", buf);
10095
10096	Gconvert((DOUBLETYPE)123.456, 8, 0, buf);
10097	checkit("123.456", buf);
10098
10099	/* Testing of 1e+129 in bigintpm.t must not get extra '.' here. */
10100	Gconvert((DOUBLETYPE)1e34, 8, 0, buf);
10101	/* 34 should be enough to scare even long double
10102	 * places into using the e notation. */
10103	if (strlen(buf) > 5)
10104	    checkit("1e+034", buf); /* for Microsoft */
10105	else
10106	    checkit("1e+34", buf);
10107
10108	/* For Perl, if you add additional tests here, also add them to
10109	 * t/base/num.t for benefit of platforms not using Configure or
10110	 * overriding d_Gconvert */
10111
10112	exit(0);
10113}
10114EOP
10115: first add preferred functions to our list
10116xxx_list=""
10117for xxx_convert in $gconvert_preference; do
10118    case $xxx_convert in
10119    gcvt|gconvert|sprintf) xxx_list="$xxx_list $xxx_convert" ;;
10120    *) echo "Discarding unrecognized gconvert_preference $xxx_convert" >&4 ;;
10121    esac
10122done
10123: then add any others
10124for xxx_convert in gconvert gcvt sprintf; do
10125    case "$xxx_list" in
10126    *$xxx_convert*) ;;
10127    *) xxx_list="$xxx_list $xxx_convert" ;;
10128    esac
10129done
10130
10131case "$d_longdbl$uselongdouble" in
10132"$define$define")
10133    : again, add preferred functions to our list first
10134    xxx_ld_list=""
10135    for xxx_convert in $gconvert_ld_preference; do
10136        case $xxx_convert in
10137        qgcvt|gcvt|gconvert|sprintf) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10138        *) echo "Discarding unrecognized gconvert_ld_preference $xxx_convert" ;;
10139        esac
10140    done
10141    : then add qgcvt, sprintf--then, in xxx_list order, gconvert and gcvt
10142    for xxx_convert in qgcvt sprintf $xxx_list; do
10143        case "$xxx_ld_list" in
10144        $xxx_convert*|*" $xxx_convert"*) ;;
10145        *) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10146        esac
10147    done
10148    : if sprintf cannot do long doubles, move it to the end
10149    if test "$d_PRIgldbl" != "$define"; then
10150        xxx_ld_list="`echo $xxx_ld_list|sed s/sprintf//` sprintf"
10151    fi
10152    : if no qgcvt, remove it
10153    if test "$d_qgcvt" != "$define"; then
10154        xxx_ld_list="`echo $xxx_ld_list|sed s/qgcvt//`"
10155    fi
10156    : use the ld_list
10157    xxx_list="$xxx_ld_list"
10158    ;;
10159esac
10160
10161for xxx_convert in $xxx_list; do
10162	echo "Trying $xxx_convert..."
10163	$rm -f try try$_o core
10164	set try -DTRY_$xxx_convert
10165	if eval $compile; then
10166		echo "$xxx_convert() found." >&4
10167		if $run ./try; then
10168			echo "I'll use $xxx_convert to convert floats into a string." >&4
10169			break;
10170		else
10171			echo "...But $xxx_convert didn't work as I expected."
10172			xxx_convert=''
10173		fi
10174	else
10175		echo "$xxx_convert NOT found." >&4
10176	fi
10177done
10178
10179if test X$xxx_convert = X; then
10180    echo "*** WHOA THERE!!! ***" >&4
10181    echo "None of ($xxx_list)  seemed to work properly.  I'll use sprintf." >&4
10182    xxx_convert=sprintf
10183fi
10184
10185case "$xxx_convert" in
10186gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
10187gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
10188qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;;
10189*) case "$uselongdouble$d_longdbl$d_PRIgldbl" in
10190   "$define$define$define")
10191      d_Gconvert="sprintf((b),\"%.*\"$sPRIgldbl,(n),(x))" ;;
10192   "$define$define$undef")
10193      d_Gconvert='sprintf((b),"%.*g",(n),(double)(x))' ;;
10194   *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
10195   esac
10196   ;;
10197esac
10198
10199fi
10200$rm_try
10201
10202: see if _fwalk exists
10203set fwalk d__fwalk
10204eval $inlibc
10205
10206: Initialize h_fcntl
10207h_fcntl=false
10208
10209: Initialize h_sysfile
10210h_sysfile=false
10211
10212: access call always available on UNIX
10213set access d_access
10214eval $inlibc
10215
10216: locate the flags for 'access()'
10217case "$d_access" in
10218"$define")
10219	echo " "
10220	$cat >access.c <<EOCP
10221#include <sys/types.h>
10222#ifdef I_FCNTL
10223#include <fcntl.h>
10224#endif
10225#ifdef I_SYS_FILE
10226#include <sys/file.h>
10227#endif
10228#ifdef I_UNISTD
10229#include <unistd.h>
10230#endif
10231#$i_stdlib I_STDLIB
10232#ifdef I_STDLIB
10233#include <stdlib.h>
10234#endif
10235int main() {
10236	exit(R_OK);
10237}
10238EOCP
10239	: check sys/file.h first, no particular reason here
10240	if $test `./findhdr sys/file.h` && \
10241		$cc -o access $cppflags -DI_SYS_FILE access.c >/dev/null 2>&1 ; then
10242		h_sysfile=true;
10243		echo "<sys/file.h> defines the *_OK access constants." >&4
10244	elif $test `./findhdr fcntl.h` && \
10245		$cc -o access $cppflags -DI_FCNTL access.c >/dev/null 2>&1 ; then
10246		h_fcntl=true;
10247		echo "<fcntl.h> defines the *_OK access constants." >&4
10248	elif $test `./findhdr unistd.h` && \
10249		$cc -o access $cppflags -DI_UNISTD access.c >/dev/null 2>&1 ; then
10250		echo "<unistd.h> defines the *_OK access constants." >&4
10251	else
10252		echo "I can't find the four *_OK access constants--I'll use mine." >&4
10253	fi
10254	;;
10255esac
10256$rm -f access*
10257
10258: see if accessx exists
10259set accessx d_accessx
10260eval $inlibc
10261
10262: see if aintl exists
10263set aintl d_aintl
10264eval $inlibc
10265
10266: see if alarm exists
10267set alarm d_alarm
10268eval $inlibc
10269
10270: see if 64bit time functions exists
10271
10272set ctime64 d_ctime64
10273eval $inlibc
10274
10275set localtime64 d_localtime64
10276eval $inlibc
10277
10278set gmtime64 d_gmtime64
10279eval $inlibc
10280
10281set mktime64 d_mktime64
10282eval $inlibc
10283
10284set difftime64 d_difftime64
10285eval $inlibc
10286
10287set asctime64 d_asctime64
10288eval $inlibc
10289
10290: see if POSIX threads are available
10291set pthread.h i_pthread
10292eval $inhdr
10293
10294: define a function to check prototypes
10295$cat > protochk <<EOSH
10296$startsh
10297cc="$cc"
10298optimize="$optimize"
10299ccflags="$ccflags"
10300prototype="$prototype"
10301define="$define"
10302rm_try="$rm_try"
10303usethreads=$usethreads
10304i_pthread=$i_pthread
10305pthread_h_first=$pthread_h_first
10306EOSH
10307
10308$cat >> protochk <<'EOSH'
10309
10310$rm_try
10311foo="$1"
10312shift
10313while test $# -ge 2; do
10314	case "$1" in
10315		$define) echo "#include <$2>" >> try.c ;;
10316		literal) echo "$2" >> try.c ;;
10317	esac
10318    # Extra magic for the benefit of systems that need pthread.h
10319    # to be included early to correctly detect threadsafe functions.
10320    # Such functions must guarantee themselves, though, that the usethreads
10321    # and i_pthread have been defined, before calling protochk.
10322    if test "$usethreads" = "$define" -a "$i_pthread" = "$define" -a "$pthread_h_first" = "$define" -a "$pthread_h_done" = ""; then
10323	echo "#include <pthread.h>" >> try.c
10324	pthread_h_done=yes
10325    fi
10326    shift 2
10327done
10328test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
10329cat >> try.c <<'EOCP'
10330#ifdef CAN_PROTOTYPE
10331#define	_(args) args
10332#else
10333#define	_(args) ()
10334#endif
10335EOCP
10336echo "$foo" >> try.c
10337echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
10338$cc $optimize $ccflags -c try.c > /dev/null 2>&1
10339status=$?
10340$rm_try
10341exit $status
10342EOSH
10343chmod +x protochk
10344$eunicefix protochk
10345
10346: Define hasproto macro for Configure internal use
10347hasproto='varname=$1; func=$2; shift; shift;
10348while $test $# -ge 2; do
10349	case "$1" in
10350	$define) echo "#include <$2>";;
10351	esac ;
10352    shift 2;
10353done > try.c;
10354$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
10355if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
10356	echo "$func() prototype found.";
10357	val="$define";
10358else
10359	echo "$func() prototype NOT found.";
10360	val="$undef";
10361fi;
10362set $varname;
10363eval $setvar;
10364$rm_try tryout.c'
10365
10366: see if sys/types.h has to be included
10367set sys/types.h i_systypes
10368eval $inhdr
10369
10370: see if sys/select.h has to be included
10371set sys/select.h i_sysselct
10372eval $inhdr
10373
10374: Define hasfield macro for Configure internal use
10375hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
10376while $test $# -ge 2; do
10377	case "$1" in
10378	$define) echo "#include <$2>";;
10379	esac ;
10380    shift 2;
10381done > try.c;
10382echo "int main () { struct $struct foo; char* bar; bar = (char*)foo.$field; }" >> try.c;
10383set try;
10384if eval $compile; then
10385	val="$define";
10386else
10387	val="$undef";
10388fi;
10389set $varname;
10390eval $setvar;
10391$rm_try'
10392
10393: see if we should include time.h, sys/time.h, or both
10394echo " "
10395if test "X$timeincl" = X; then
10396	echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
10397	$echo $n "I'm now running the test program...$c"
10398	$cat >try.c <<EOCP
10399#include <sys/types.h>
10400#ifdef I_TIME
10401#include <time.h>
10402#endif
10403#ifdef I_SYSTIME
10404#ifdef SYSTIMEKERNEL
10405#define KERNEL
10406#endif
10407#include <sys/time.h>
10408#endif
10409#ifdef I_SYSSELECT
10410#include <sys/select.h>
10411#endif
10412#$i_stdlib I_STDLIB
10413#ifdef I_STDLIB
10414#include <stdlib.h>
10415#endif
10416int main()
10417{
10418	struct tm foo;
10419#ifdef S_TIMEVAL
10420	struct timeval bar;
10421#endif
10422#ifdef S_TIMEZONE
10423	struct timezone tzp;
10424#endif
10425	if (foo.tm_sec == foo.tm_sec)
10426		exit(0);
10427#ifdef S_TIMEVAL
10428	if (bar.tv_sec == bar.tv_sec)
10429		exit(0);
10430#endif
10431	exit(1);
10432}
10433EOCP
10434	flags=''
10435	for s_timezone in '-DS_TIMEZONE' ''; do
10436	sysselect=''
10437	for s_timeval in '-DS_TIMEVAL' ''; do
10438	for i_systimek in '' '-DSYSTIMEKERNEL'; do
10439	for i_time in '' '-DI_TIME'; do
10440	for i_systime in '-DI_SYSTIME' ''; do
10441		case "$flags" in
10442		'') $echo $n ".$c"
10443			set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
10444			if eval $compile; then
10445				set X $i_time $i_systime $i_systimek $sysselect $s_timeval
10446				shift
10447				flags="$*"
10448				echo " "
10449				$echo $n "Succeeded with $flags$c"
10450			fi
10451			;;
10452		esac
10453	done
10454	done
10455	done
10456	done
10457	done
10458	timeincl=''
10459	echo " "
10460	case "$flags" in
10461	*SYSTIMEKERNEL*) i_systimek="$define"
10462		timeincl=`./findhdr sys/time.h`
10463		echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
10464	*) i_systimek="$undef";;
10465	esac
10466	case "$flags" in
10467	*I_TIME*) i_time="$define"
10468		timeincl=`./findhdr time.h`" $timeincl"
10469		echo "We'll include <time.h>." >&4;;
10470	*) i_time="$undef";;
10471	esac
10472	case "$flags" in
10473	*I_SYSTIME*) i_systime="$define"
10474		timeincl=`./findhdr sys/time.h`" $timeincl"
10475		echo "We'll include <sys/time.h>." >&4;;
10476	*) i_systime="$undef";;
10477	esac
10478	$rm_try
10479fi
10480: see if struct tm knows about tm_zone
10481case "$i_systime$i_time" in
10482*$define*)
10483        echo " "
10484        echo "Checking to see if your struct tm has tm_zone field..." >&4
10485        set d_tm_tm_zone tm tm_zone $i_systime sys/time.h $i_time time.h
10486        eval $hasfield
10487        ;;
10488*)      val="$undef"
10489        set d_tm_tm_zone
10490        eval $setvar
10491        ;;
10492esac
10493case "$d_tm_tm_zone" in
10494"$define")      echo "Yes, it does."   ;;
10495*)              echo "No, it doesn't." ;;
10496esac
10497: see if struct tm knows about tm_gmtoff
10498case "$i_systime$i_time" in
10499*$define*)
10500        echo " "
10501        echo "Checking to see if your struct tm has tm_gmtoff field..." >&4
10502        set d_tm_tm_gmtoff tm tm_gmtoff $i_systime sys/time.h $i_time time.h
10503        eval $hasfield
10504        ;;
10505*)      val="$undef"
10506        set d_tm_tm_gmtoff
10507        eval $setvar
10508        ;;
10509esac
10510case "$d_tm_tm_gmtoff" in
10511"$define")      echo "Yes, it does."   ;;
10512*)              echo "No, it doesn't." ;;
10513esac
10514
10515: see if asctime_r exists
10516set asctime_r d_asctime_r
10517eval $inlibc
10518case "$d_asctime_r" in
10519"$define")
10520	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
10521	case "$d_asctime_r_proto:$usethreads" in
10522	":define")	d_asctime_r_proto=define
10523		set d_asctime_r_proto asctime_r $hdrs
10524		eval $hasproto ;;
10525	*)	;;
10526	esac
10527	case "$d_asctime_r_proto" in
10528	define)
10529	case "$asctime_r_proto" in
10530	''|0) try='char* asctime_r(const struct tm*, char*);'
10531	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SB ;;
10532	esac
10533	case "$asctime_r_proto" in
10534	''|0) try='char* asctime_r(const struct tm*, char*, int);'
10535	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SBI ;;
10536	esac
10537	case "$asctime_r_proto" in
10538	''|0) try='int asctime_r(const struct tm*, char*);'
10539	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SB ;;
10540	esac
10541	case "$asctime_r_proto" in
10542	''|0) try='int asctime_r(const struct tm*, char*, int);'
10543	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SBI ;;
10544	esac
10545	case "$asctime_r_proto" in
10546	''|0)	d_asctime_r=undef
10547 	        asctime_r_proto=0
10548		echo "Disabling asctime_r, cannot determine prototype." >&4 ;;
10549	* )	case "$asctime_r_proto" in
10550		REENTRANT_PROTO*) ;;
10551		*) asctime_r_proto="REENTRANT_PROTO_$asctime_r_proto" ;;
10552		esac
10553		echo "Prototype: $try" ;;
10554	esac
10555	;;
10556	*)	case "$usethreads" in
10557		define) echo "asctime_r has no prototype, not using it." >&4 ;;
10558		esac
10559		d_asctime_r=undef
10560		asctime_r_proto=0
10561		;;
10562	esac
10563	;;
10564*)	asctime_r_proto=0
10565	;;
10566esac
10567
10568: see if atolf exists
10569set atolf d_atolf
10570eval $inlibc
10571
10572: see if atoll exists
10573set atoll d_atoll
10574eval $inlibc
10575
10576: Look for GCC-style attribute format
10577case "$d_attribute_format" in
10578'')
10579echo " "
10580echo "Checking whether your compiler can handle __attribute__((format)) ..." >&4
10581$cat >attrib.c <<'EOCP'
10582#include <stdio.h>
10583void my_special_printf(char* pat,...) __attribute__((__format__(__printf__,1,2)));
10584EOCP
10585if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10586	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10587		echo "Your C compiler doesn't support __attribute__((format))."
10588		val="$undef"
10589	else
10590		echo "Your C compiler supports __attribute__((format))."
10591		val="$define"
10592	fi
10593else
10594	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10595	val="$undef"
10596fi
10597;;
10598*) val="$d_attribute_format" ;;
10599esac
10600set d_attribute_format
10601eval $setvar
10602$rm -f attrib*
10603
10604: Look for GCC-style attribute format with null format allowed
10605case "$d_printf_format_null" in
10606'') case "$d_attribute_format" in
10607    $define)
10608	echo " "
10609	echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
10610$cat >attrib.c <<EOCP
10611#include <stdio.h>
10612#$i_stdlib I_STDLIB
10613#ifdef I_STDLIB
10614#include <stdlib.h>
10615#endif
10616int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
10617int null_printf (char* pat,...) { return (int)pat; }
10618int main () { exit(null_printf(NULL)); }
10619EOCP
10620	if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
10621	    : run the executable in case it produces a run-time warning
10622	    if $run ./attrib >>attrib.out 2>&1; then
10623		if $contains 'warning' attrib.out >/dev/null 2>&1; then
10624		    echo "Your C compiler doesn't allow __printf__ format to be null."
10625		    val="$undef"
10626		else
10627		    echo "Your C compiler allows __printf__ format to be null."
10628		    val="$define"
10629		fi
10630	    else
10631	    echo "Your C compiler executable failed with __printf__ format null."
10632	    val="$undef"
10633	fi
10634    else
10635	echo "Your C compiler fails with __printf__ format null."
10636	val="$undef"
10637    fi
10638    ;;
10639    *)  val="$undef" ;;
10640    esac
10641;;
10642*)  val="$d_printf_format_null" ;;
10643esac
10644set d_printf_format_null
10645eval $setvar
10646$rm -f attrib*
10647
10648: Look for GCC-style attribute malloc
10649case "$d_attribute_malloc" in
10650'')
10651echo " "
10652echo "Checking whether your compiler can handle __attribute__((malloc)) ..." >&4
10653$cat >attrib.c <<'EOCP'
10654#include <stdio.h>
10655char *go_get_some_memory( int how_many_bytes ) __attribute__((malloc));
10656EOCP
10657if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10658	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10659		echo "Your C compiler doesn't support __attribute__((malloc))."
10660		val="$undef"
10661	else
10662		echo "Your C compiler supports __attribute__((malloc))."
10663		val="$define"
10664	fi
10665else
10666	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10667	val="$undef"
10668fi
10669;;
10670*) val="$d_attribute_malloc" ;;
10671esac
10672set d_attribute_malloc
10673eval $setvar
10674$rm -f attrib*
10675
10676: Look for GCC-style attribute nonnull
10677case "$d_attribute_nonnull" in
10678'')
10679echo " "
10680echo "Checking whether your compiler can handle __attribute__((nonnull(1))) ..." >&4
10681$cat >attrib.c <<'EOCP'
10682#include <stdio.h>
10683void do_something (char *some_pointer,...) __attribute__((nonnull(1)));
10684EOCP
10685if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10686	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10687		echo "Your C compiler doesn't support __attribute__((nonnull))."
10688		val="$undef"
10689	else
10690		echo "Your C compiler supports __attribute__((nonnull))."
10691		val="$define"
10692	fi
10693else
10694	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10695	val="$undef"
10696fi
10697;;
10698*) val="$d_attribute_nonnull" ;;
10699esac
10700set d_attribute_nonnull
10701eval $setvar
10702$rm -f attrib*
10703
10704: Look for GCC-style attribute noreturn
10705case "$d_attribute_noreturn" in
10706'')
10707echo " "
10708echo "Checking whether your compiler can handle __attribute__((noreturn)) ..." >&4
10709$cat >attrib.c <<'EOCP'
10710#include <stdio.h>
10711void fall_over_dead( void ) __attribute__((noreturn));
10712EOCP
10713if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10714	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10715		echo "Your C compiler doesn't support __attribute__((noreturn))."
10716		val="$undef"
10717	else
10718		echo "Your C compiler supports __attribute__((noreturn))."
10719		val="$define"
10720	fi
10721else
10722	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10723	val="$undef"
10724fi
10725;;
10726*) val="$d_attribute_noreturn" ;;
10727esac
10728set d_attribute_noreturn
10729eval $setvar
10730$rm -f attrib*
10731
10732: Look for GCC-style attribute pure
10733case "$d_attribute_pure" in
10734'')
10735echo " "
10736echo "Checking whether your compiler can handle __attribute__((pure)) ..." >&4
10737$cat >attrib.c <<'EOCP'
10738#include <stdio.h>
10739int square( int n ) __attribute__((pure));
10740EOCP
10741if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10742	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10743		echo "Your C compiler doesn't support __attribute__((pure))."
10744		val="$undef"
10745	else
10746		echo "Your C compiler supports __attribute__((pure))."
10747		val="$define"
10748	fi
10749else
10750	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10751	val="$undef"
10752fi
10753;;
10754*) val="$d_attribute_pure" ;;
10755esac
10756set d_attribute_pure
10757eval $setvar
10758$rm -f attrib*
10759
10760: Look for GCC-style attribute unused
10761case "$d_attribute_unused" in
10762'')
10763echo " "
10764echo "Checking whether your compiler can handle __attribute__((unused)) ..." >&4
10765$cat >attrib.c <<'EOCP'
10766#include <stdio.h>
10767int do_something( int dummy __attribute__((unused)), int n );
10768EOCP
10769if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10770	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10771		echo "Your C compiler doesn't support __attribute__((unused))."
10772		val="$undef"
10773	else
10774		echo "Your C compiler supports __attribute__((unused))."
10775		val="$define"
10776	fi
10777else
10778	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10779	val="$undef"
10780fi
10781;;
10782*) val="$d_attribute_unused" ;;
10783esac
10784set d_attribute_unused
10785eval $setvar
10786$rm -f attrib*
10787
10788: Look for GCC-style attribute deprecated
10789case "$d_attribute_deprecated" in
10790'')
10791echo " "
10792echo "Checking whether your compiler can handle __attribute__((deprecated)) ..." >&4
10793$cat >attrib.c <<'EOCP'
10794#include <stdio.h>
10795int I_am_deprecated(void) __attribute__((deprecated));
10796EOCP
10797if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10798	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10799		echo "Your C compiler doesn't support __attribute__((deprecated))."
10800		val="$undef"
10801	else
10802		echo "Your C compiler supports __attribute__((deprecated))."
10803		val="$define"
10804	fi
10805else
10806	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10807	val="$undef"
10808fi
10809;;
10810*) val="$d_attribute_deprecated" ;;
10811esac
10812set d_attribute_deprecated
10813eval $setvar
10814$rm -f attrib*
10815
10816: Look for GCC-style attribute warn_unused_result
10817case "$d_attribute_warn_unused_result" in
10818'')
10819echo " "
10820echo "Checking whether your compiler can handle __attribute__((warn_unused_result)) ..." >&4
10821$cat >attrib.c <<'EOCP'
10822#include <stdio.h>
10823int I_will_not_be_ignored(void) __attribute__((warn_unused_result));
10824EOCP
10825if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
10826	if $contains 'warning' attrib.out >/dev/null 2>&1; then
10827		echo "Your C compiler doesn't support __attribute__((warn_unused_result))."
10828		val="$undef"
10829	else
10830		echo "Your C compiler supports __attribute__((warn_unused_result))."
10831		val="$define"
10832	fi
10833else
10834	echo "Your C compiler doesn't seem to understand __attribute__ at all."
10835	val="$undef"
10836fi
10837;;
10838*) val="$d_attribute_warn_unused_result" ;;
10839esac
10840set d_attribute_warn_unused_result
10841eval $setvar
10842$rm -f attrib*
10843
10844: see if bcmp exists
10845set bcmp d_bcmp
10846eval $inlibc
10847
10848: see if bcopy exists
10849set bcopy d_bcopy
10850eval $inlibc
10851
10852: see if getpgrp exists
10853set getpgrp d_getpgrp
10854eval $inlibc
10855
10856case "$d_getpgrp" in
10857"$define")
10858	echo " "
10859	echo "Checking to see which flavor of getpgrp is in use..."
10860	$cat >try.c <<EOP
10861#$i_unistd I_UNISTD
10862#include <sys/types.h>
10863#ifdef I_UNISTD
10864#  include <unistd.h>
10865#endif
10866#$i_stdlib I_STDLIB
10867#ifdef I_STDLIB
10868#include <stdlib.h>
10869#endif
10870int main()
10871{
10872	if (getuid() == 0) {
10873		printf("(I see you are running Configure as super-user...)\n");
10874		setuid(1);
10875	}
10876#ifdef TRY_BSD_PGRP
10877	if (getpgrp(1) == 0)
10878		exit(0);
10879#else
10880	if (getpgrp() > 0)
10881		exit(0);
10882#endif
10883	exit(1);
10884}
10885EOP
10886	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
10887		echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
10888		val="$define"
10889	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
10890		echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
10891		val="$undef"
10892	else
10893		echo "I can't seem to compile and run the test program."
10894		if ./usg; then
10895			xxx="a USG one, i.e. you use getpgrp()."
10896		else
10897			# SVR4 systems can appear rather BSD-ish.
10898			case "$i_unistd" in
10899			$undef)
10900				xxx="a BSD one, i.e. you use getpgrp(pid)."
10901				val="$define"
10902				;;
10903			$define)
10904				xxx="probably a USG one, i.e. you use getpgrp()."
10905				val="$undef"
10906				;;
10907			esac
10908		fi
10909		echo "Assuming your getpgrp is $xxx" >&4
10910	fi
10911	;;
10912*) val="$undef";;
10913esac
10914set d_bsdgetpgrp
10915eval $setvar
10916$rm_try
10917
10918: see if setpgrp exists
10919set setpgrp d_setpgrp
10920eval $inlibc
10921
10922case "$d_setpgrp" in
10923"$define")
10924	echo " "
10925	echo "Checking to see which flavor of setpgrp is in use..."
10926	$cat >try.c <<EOP
10927#$i_unistd I_UNISTD
10928#include <sys/types.h>
10929#ifdef I_UNISTD
10930#  include <unistd.h>
10931#endif
10932#$i_stdlib I_STDLIB
10933#ifdef I_STDLIB
10934#include <stdlib.h>
10935#endif
10936int main()
10937{
10938	if (getuid() == 0) {
10939		printf("(I see you are running Configure as super-user...)\n");
10940		setuid(1);
10941	}
10942#ifdef TRY_BSD_PGRP
10943	if (-1 == setpgrp(1, 1))
10944		exit(0);
10945#else
10946	if (setpgrp() != -1)
10947		exit(0);
10948#endif
10949	exit(1);
10950}
10951EOP
10952	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
10953		echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
10954		val="$define"
10955	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
10956		echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
10957		val="$undef"
10958	else
10959		echo "(I can't seem to compile and run the test program.)"
10960		if ./usg; then
10961			xxx="a USG one, i.e. you use setpgrp()."
10962		else
10963			# SVR4 systems can appear rather BSD-ish.
10964			case "$i_unistd" in
10965			$undef)
10966				xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
10967				val="$define"
10968				;;
10969			$define)
10970				xxx="probably a USG one, i.e. you use setpgrp()."
10971				val="$undef"
10972				;;
10973			esac
10974		fi
10975		echo "Assuming your setpgrp is $xxx" >&4
10976	fi
10977	;;
10978*) val="$undef";;
10979esac
10980set d_bsdsetpgrp
10981eval $setvar
10982$rm_try
10983
10984: Look for GCC-style __builtin_choose_expr
10985case "$d_builtin_choose_expr" in
10986'')
10987    echo " "
10988    echo "Checking whether your compiler can handle __builtin_choose_expr ..." >&4
10989    $cat >try.c <<'EOCP'
10990#include <assert.h>
10991#include <stdlib.h>
10992#include <stdio.h>
10993
10994#define SYRINX(x) __builtin_choose_expr( x, (1056*2), (103*50) )
10995
10996int main(void) {
10997    assert( SYRINX(1) == 2112 );
10998    assert( SYRINX(1) != 5150 );
10999    assert( SYRINX(0) == 5150 );
11000    assert( SYRINX(0) != 2112 );
11001    puts( "All good!" );
11002    exit(0);
11003}
11004
11005EOCP
11006    set try
11007    if eval $compile && $run ./try; then
11008	echo "Your C compiler supports __builtin_choose_expr."
11009	val="$define"
11010    else
11011	echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
11012	val="$undef"
11013    fi
11014;;
11015*) val="$d_builtin_choose_expr" ;;
11016esac
11017
11018set d_builtin_choose_expr
11019eval $setvar
11020$rm_try
11021
11022: Look for GCC-style __builtin_expect
11023case "$d_builtin_expect" in
11024'')
11025    echo " "
11026    echo "Checking whether your compiler can handle __builtin_expect ..." >&4
11027    $cat >try.c <<'EOCP'
11028int main(void) {
11029    int n = 50;
11030    if ( __builtin_expect(n, 0) ) n = 1;
11031    /* Remember shell exit code truth is 0, C truth is non-zero */
11032    return !(n == 1);
11033}
11034EOCP
11035    set try
11036    if eval $compile && $run ./try; then
11037	echo "Your C compiler supports __builtin_expect."
11038	val="$define"
11039    else
11040	echo "Your C compiler doesn't seem to understand __builtin_expect."
11041	val="$undef"
11042    fi
11043    ;;
11044*) val="$d_builtin_expect" ;;
11045esac
11046
11047set d_builtin_expect
11048eval $setvar
11049$rm_try
11050
11051: see if bzero exists
11052set bzero d_bzero
11053eval $inlibc
11054
11055: see if stdarg is available
11056echo " "
11057if $test `./findhdr stdarg.h`; then
11058	echo "<stdarg.h> found." >&4
11059	valstd="$define"
11060else
11061	echo "<stdarg.h> NOT found." >&4
11062	valstd="$undef"
11063fi
11064
11065: see if varargs is available
11066echo " "
11067if $test `./findhdr varargs.h`; then
11068	echo "<varargs.h> found." >&4
11069else
11070	echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
11071fi
11072
11073: set up the varargs testing programs
11074$cat > varargs.c <<EOP
11075#ifdef I_STDARG
11076#include <stdarg.h>
11077#endif
11078#ifdef I_VARARGS
11079#include <varargs.h>
11080#endif
11081
11082#ifdef I_STDARG
11083int f(char *p, ...)
11084#else
11085int f(va_alist)
11086va_dcl
11087#endif
11088{
11089	va_list ap;
11090#ifndef I_STDARG
11091	char *p;
11092#endif
11093#ifdef I_STDARG
11094	va_start(ap,p);
11095#else
11096	va_start(ap);
11097	p = va_arg(ap, char *);
11098#endif
11099	va_end(ap);
11100	return 0;
11101}
11102EOP
11103$cat > varargs <<EOP
11104$startsh
11105if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
11106	echo "true"
11107else
11108	echo "false"
11109fi
11110$rm -f varargs$_o
11111EOP
11112chmod +x varargs
11113
11114: now check which varargs header should be included
11115echo " "
11116i_varhdr=''
11117val=''
11118case "$valstd" in
11119"$define")
11120	if `./varargs I_STDARG`; then
11121		val='stdarg.h'
11122	elif `./varargs I_VARARGS`; then
11123		val='varargs.h'
11124	fi
11125	;;
11126*)
11127	if `./varargs I_VARARGS`; then
11128		val='varargs.h'
11129	fi
11130	;;
11131esac
11132case "$val" in
11133'')
11134	echo " "
11135	echo "*** WHOA THERE!!! ***" >&4
11136	echo "    Your C compiler \"$cc\" doesn't seem to support stdarg or varargs!" >&4
11137	case "$knowitall" in
11138	'')
11139	echo "    I'm giving up; maybe you can try again with a different compiler?" >&4
11140		exit 1
11141		;;
11142	esac
11143echo "I could not find the definition for va_dcl... You have problems..." >&4
11144	val="$undef"; set i_stdarg; eval $setvar
11145	val="$undef"; set i_varargs; eval $setvar
11146	;;
11147*)
11148	set i_varhdr
11149	eval $setvar
11150	case "$i_varhdr" in
11151	stdarg.h)
11152		val="$define"; set i_stdarg; eval $setvar
11153		val="$undef"; set i_varargs; eval $setvar
11154		;;
11155	varargs.h)
11156		val="$undef"; set i_stdarg; eval $setvar
11157		val="$define"; set i_varargs; eval $setvar
11158		;;
11159	esac
11160	echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
11161esac
11162$rm -f varargs*
11163
11164: see if the Compiler supports C99 variadic macros
11165case "$i_stdarg$i_stdlib" in
11166    "$define$define")
11167    echo "You have <stdarg.h> and <stdlib.h>, so checking for C99 variadic macros." >&4
11168    $cat >try.c <<EOCP
11169#include <stdio.h>
11170#include <stdarg.h>
11171
11172#define foo(buffer, format, ...) sprintf(buffer, format, __VA_ARGS__)
11173
11174int main() {
11175  char buf[20];
11176  foo(buf, "%d %g %.*s", 123, 456.0, (int)3, "789fail");
11177  puts(buf);
11178  return 0;
11179}
11180EOCP
11181    set try
11182    if eval $compile && $run ./try 2>&1 >/dev/null; then
11183	case "`$run ./try`" in
11184	    "123 456 789")
11185	    echo "You have C99 variadic macros." >&4
11186	    d_c99_variadic_macros="$define"
11187	    ;;
11188	    *)
11189	    echo "You don't have functional C99 variadic macros." >&4
11190	    d_c99_variadic_macros="$undef"
11191	    ;;
11192	esac
11193    else
11194	echo "I couldn't compile and run the test program, so I assume that you don't have functional C99 variadic macros." >&4
11195	d_c99_variadic_macros="$undef"
11196    fi
11197    $rm_try
11198    ;;
11199    *)
11200    echo "You don't have <stdarg.h> and <stdlib.h>, so not checking for C99 variadic macros." >&4
11201    d_c99_variadic_macros="$undef"
11202    ;;
11203esac
11204
11205: see if signal is declared as pointer to function returning int or void
11206echo " "
11207xxx=`./findhdr signal.h`
11208$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
11209if $contains 'int.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11210	echo "You have int (*signal())() instead of void." >&4
11211	val="$undef"
11212elif $contains 'void.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11213	echo "You have void (*signal())()." >&4
11214	val="$define"
11215elif $contains 'extern[ 	]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
11216	echo "You have int (*signal())() instead of void." >&4
11217	val="$undef"
11218elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
11219	echo "You have void (*signal())()." >&4
11220	val="$define"
11221else
11222	case "$d_voidsig" in
11223	'')
11224	echo "I can't determine whether signal handler returns void or int..." >&4
11225		dflt=void
11226		rp="What type does your signal handler return?"
11227		. ./myread
11228		case "$ans" in
11229		v*) val="$define";;
11230		*) val="$undef";;
11231		esac;;
11232	"$define")
11233		echo "As you already told me, signal handler returns void." >&4
11234		val="$define"
11235		;;
11236	*)	echo "As you already told me, signal handler returns int." >&4
11237		val="$undef"
11238		;;
11239	esac
11240fi
11241set d_voidsig
11242eval $setvar
11243case "$d_voidsig" in
11244"$define") signal_t="void";;
11245*) signal_t="int";;
11246esac
11247$rm -f $$.tmp
11248
11249: check for ability to cast large floats to 32-bit ints.
11250echo " "
11251echo 'Checking whether your C compiler can cast large floats to int32.' >&4
11252if $test "$intsize" -ge 4; then
11253	xxx=int
11254else
11255	xxx=long
11256fi
11257$cat >try.c <<EOCP
11258#include <stdio.h>
11259#$i_stdlib I_STDLIB
11260#ifdef I_STDLIB
11261#include <stdlib.h>
11262#endif
11263#include <sys/types.h>
11264#include <signal.h>
11265$signal_t blech(int s) { exit(3); }
11266int main()
11267{
11268	$xxx i32;
11269	double f, g;
11270	int result = 0;
11271	char str[16];
11272	signal(SIGFPE, blech);
11273
11274	/* Don't let compiler optimize the test away.  Store the number
11275	   in a writable string for gcc to pass to sscanf under HP-UX.
11276	*/
11277	sprintf(str, "2147483647");
11278	sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
11279	g = 10 * f;
11280	i32  = ($xxx) g;
11281
11282	/* x86 processors will probably give 0x8000 0000, which is a
11283	   sign change.  We don't want that.  We want to mimic SPARC
11284	   behavior here, which is to preserve the sign and give
11285	   back 0x7fff ffff.
11286	*/
11287	if (i32 != ($xxx) f)
11288		result |= 1;
11289	exit(result);
11290}
11291EOCP
11292set try
11293if eval $compile_ok; then
11294	$run ./try
11295	yyy=$?
11296else
11297	echo "(I can't seem to compile the test program--assuming it can't)"
11298	yyy=1
11299fi
11300case "$yyy" in
113010)	val="$define"
11302	echo "Yup, it can."
11303	;;
11304*)	val="$undef"
11305	echo "Nope, it can't."
11306	;;
11307esac
11308set d_casti32
11309eval $setvar
11310$rm_try
11311
11312: check for ability to cast negative floats to unsigned
11313echo " "
11314echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
11315$cat >try.c <<EOCP
11316#include <stdio.h>
11317#$i_stdlib I_STDLIB
11318#ifdef I_STDLIB
11319#include <stdlib.h>
11320#endif
11321#include <sys/types.h>
11322#include <signal.h>
11323$signal_t blech(int s) { exit(7); }
11324$signal_t blech_in_list(int s) { exit(4); }
11325unsigned long dummy_long(unsigned long p) { return p; }
11326unsigned int dummy_int(unsigned int p) { return p; }
11327unsigned short dummy_short(unsigned short p) { return p; }
11328int main()
11329{
11330	double f;
11331	unsigned long along;
11332	unsigned int aint;
11333	unsigned short ashort;
11334	int result = 0;
11335	char str[16];
11336
11337	/* Frustrate gcc-2.7.2's optimizer which failed this test with
11338	   a direct f = -123. assignment.  gcc-2.8.0 reportedly
11339	   optimized the whole file away
11340	*/
11341	/* Store the number in a writable string for gcc to pass to
11342	   sscanf under HP-UX.
11343	*/
11344	sprintf(str, "-123");
11345	sscanf(str, "%lf", &f);  /* f = -123.; */
11346
11347	signal(SIGFPE, blech);
11348	along = (unsigned long)f;
11349	aint = (unsigned int)f;
11350	ashort = (unsigned short)f;
11351	if (along != (unsigned long)-123)
11352		result |= 1;
11353	if (aint != (unsigned int)-123)
11354		result |= 1;
11355	if (ashort != (unsigned short)-123)
11356		result |= 1;
11357	sprintf(str, "1073741824.");
11358	sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
11359	f = f + f;
11360	along = 0;
11361	along = (unsigned long)f;
11362	if (along != 0x80000000)
11363		result |= 2;
11364	f -= 1.;
11365	along = 0;
11366	along = (unsigned long)f;
11367	if (along != 0x7fffffff)
11368		result |= 1;
11369	f += 2.;
11370	along = 0;
11371	along = (unsigned long)f;
11372	if (along != 0x80000001)
11373		result |= 2;
11374	if (result)
11375		exit(result);
11376	signal(SIGFPE, blech_in_list);
11377	sprintf(str, "123.");
11378	sscanf(str, "%lf", &f);  /* f = 123.; */
11379	along = dummy_long((unsigned long)f);
11380	aint = dummy_int((unsigned int)f);
11381	ashort = dummy_short((unsigned short)f);
11382	if (along != (unsigned long)123)
11383		result |= 4;
11384	if (aint != (unsigned int)123)
11385		result |= 4;
11386	if (ashort != (unsigned short)123)
11387		result |= 4;
11388	exit(result);
11389
11390}
11391EOCP
11392set try
11393if eval $compile_ok; then
11394	$run ./try
11395	castflags=$?
11396else
11397	echo "(I can't seem to compile the test program--assuming it can't)"
11398	castflags=7
11399fi
11400case "$castflags" in
114010)	val="$define"
11402	echo "Yup, it can."
11403	;;
11404*)	val="$undef"
11405	echo "Nope, it can't."
11406	;;
11407esac
11408set d_castneg
11409eval $setvar
11410$rm_try
11411
11412: see if vprintf exists
11413echo " "
11414if set vprintf val -f d_vprintf; eval $csym; $val; then
11415	echo 'vprintf() found.' >&4
11416	val="$define"
11417	$cat >try.c <<EOF
11418#$i_stdarg I_STDARG  /* Only one of these can be defined by i_varhrd */
11419#$i_varargs I_VARARGS
11420
11421#$i_stdlib I_STDLIB
11422#$i_unistd I_UNISTD
11423
11424#ifdef I_STDARG
11425#  include <stdarg.h>
11426#else /* I_VARARGS */
11427#  include <varargs.h>
11428#endif
11429
11430#ifdef I_UNISTD
11431#  include <unistd.h>
11432#endif
11433
11434#ifdef I_STDLIB
11435#  include <stdlib.h>
11436#endif
11437
11438#include <stdio.h> /* vsprintf prototype */
11439
11440#ifdef I_STDARG
11441void xxx(int n, ...)
11442{
11443    va_list args;
11444    char buf[10];
11445    va_start(args, n);
11446    exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
11447}
11448int main() { xxx(1, "foo"); }
11449
11450#else /* I_VARARGS */
11451
11452xxx(va_alist)
11453va_dcl
11454{
11455    va_list args;
11456    char buf[10];
11457    va_start(args);
11458    exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
11459}
11460int main() { xxx("foo"); }
11461
11462#endif
11463
11464EOF
11465	set try
11466	if eval $compile_ok; then
11467		if $run ./try; then
11468			echo "Your vsprintf() returns (int)." >&4
11469			val2="$undef"
11470		else
11471			echo "Your vsprintf() returns (char*)." >&4
11472			val2="$define"
11473		fi
11474	else
11475		echo 'I am unable to compile the vsprintf() test program.' >&4
11476		# We shouldn't get here.  If we do, assume the standard signature,
11477		# not the old BSD one.
11478		echo 'Guessing that vsprintf() returns (int).' >&4
11479		val2="$undef"
11480	fi
11481else
11482	echo 'vprintf() NOT found.' >&4
11483	val="$undef"
11484	val2="$undef"
11485fi
11486$rm_try
11487set d_vprintf
11488eval $setvar
11489val=$val2
11490set d_charvspr
11491eval $setvar
11492
11493: see if chown exists
11494set chown d_chown
11495eval $inlibc
11496
11497: see if chroot exists
11498set chroot d_chroot
11499eval $inlibc
11500
11501: see if chsize exists
11502set chsize d_chsize
11503eval $inlibc
11504
11505: see if class exists
11506set class d_class
11507eval $inlibc
11508
11509: see if clearenv exists
11510set clearenv d_clearenv
11511eval $inlibc
11512
11513: Define hasstruct macro for Configure internal use
11514hasstruct='varname=$1; struct=$2; shift; shift;
11515while $test $# -ge 2; do
11516	case "$1" in
11517	$define) echo "#include <$2>";;
11518	esac ;
11519    shift 2;
11520done > try.c;
11521echo "int main () { struct $struct foo; }" >> try.c;
11522set try;
11523if eval $compile; then
11524	val="$define";
11525else
11526	val="$undef";
11527fi;
11528set $varname;
11529eval $setvar;
11530$rm_try'
11531
11532: see whether socket exists
11533socketlib=''
11534sockethdr=''
11535echo " "
11536$echo $n "Hmm... $c" >&4
11537if set socket val -f d_socket; eval $csym; $val; then
11538    echo "Looks like you have Berkeley networking support." >&4
11539    d_socket="$define"
11540    if set setsockopt val -f; eval $csym; $val; then
11541	d_oldsock="$undef"
11542    else
11543	echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
11544	d_oldsock="$define"
11545    fi
11546else
11547    if $contains socklib libc.list >/dev/null 2>&1; then
11548	echo "Looks like you have Berkeley networking support." >&4
11549	d_socket="$define"
11550	: we will have to assume that it supports the 4.2 BSD interface
11551	d_oldsock="$undef"
11552    else
11553	echo "You don't have Berkeley networking in libc$_a..." >&4
11554	if test "X$d_socket" = "X$define"; then
11555	    echo "...but you seem to believe that you have sockets." >&4
11556	else
11557	    for net in net socket
11558	    do
11559		if test -f $sysroot/usr/lib/lib$net$_a; then
11560		    ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) ||  \
11561		    $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list
11562		    if $contains socket libc.list >/dev/null 2>&1; then
11563			d_socket="$define"
11564			socketlib="-l$net"
11565			case "$net" in
11566			net)
11567			    echo "...but the Wollongong group seems to have hacked it in." >&4
11568			    sockethdr="-I$sysroot/usr/netinclude"
11569			    ;;
11570			esac
11571			echo "Found Berkeley sockets interface in lib$net." >&4
11572			if $contains setsockopt libc.list >/dev/null 2>&1; then
11573			    d_oldsock="$undef"
11574			else
11575			    echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
11576			    d_oldsock="$define"
11577			fi
11578			break
11579		    fi
11580		fi
11581	    done
11582	    if test "X$d_socket" != "X$define"; then
11583	       echo "or anywhere else I see." >&4
11584	       d_socket="$undef"
11585	       d_oldsock="$undef"
11586	    fi
11587	fi
11588    fi
11589fi
11590
11591: see if socketpair exists
11592set socketpair d_sockpair
11593eval $inlibc
11594
11595
11596echo " "
11597echo "Checking the availability sa_len in the sock struct ..." >&4
11598$cat >try.c <<EOF
11599#include <sys/types.h>
11600#include <sys/socket.h>
11601int main() {
11602struct sockaddr sa;
11603return (sa.sa_len);
11604}
11605EOF
11606val="$undef"
11607set try; if eval $compile; then
11608    val="$define"
11609fi
11610set d_sockaddr_sa_len; eval $setvar
11611$rm_try
11612
11613echo " "
11614echo "Checking the availability struct sockaddr_in6 ..." >&4
11615$cat >try.c <<EOF
11616#include <sys/types.h>
11617#include <sys/socket.h>
11618#include <netinet/in.h>
11619int main() {
11620struct sockaddr_in6 sin6;
11621return (sin6.sin6_family);
11622}
11623EOF
11624val="$undef"
11625set try; if eval $compile; then
11626    val="$define"
11627fi
11628set d_sockaddr_in6; eval $setvar
11629$rm_try
11630
11631echo " "
11632echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
11633$cat >try.c <<EOF
11634#include <sys/types.h>
11635#include <sys/socket.h>
11636#include <netinet/in.h>
11637int main() {
11638struct sockaddr_in6 sin6;
11639return (sin6.sin6_scope_id);
11640}
11641EOF
11642val="$undef"
11643set try; if eval $compile; then
11644    val="$define"
11645fi
11646set d_sin6_scope_id; eval $setvar
11647$rm_try
11648
11649echo " "
11650echo "Checking the availability struct ip_mreq ..." >&4
11651$cat >try.c <<EOF
11652#include <sys/types.h>
11653#include <sys/socket.h>
11654#include <netinet/in.h>
11655int main() {
11656struct ip_mreq mreq;
11657return (mreq.imr_multiaddr.s_addr);
11658}
11659EOF
11660val="$undef"
11661set try; if eval $compile; then
11662       val="$define"
11663fi
11664set d_ip_mreq; eval $setvar
11665$rm_try
11666
11667echo " "
11668echo "Checking the availability struct ip_mreq_source ..." >&4
11669$cat >try.c <<EOF
11670#include <sys/types.h>
11671#include <sys/socket.h>
11672#include <netinet/in.h>
11673int main() {
11674struct ip_mreq_source mreq;
11675return (mreq.imr_multiaddr.s_addr);
11676}
11677EOF
11678val="$undef"
11679set try; if eval $compile; then
11680       val="$define"
11681fi
11682set d_ip_mreq_source; eval $setvar
11683$rm_try
11684
11685echo " "
11686echo "Checking the availability struct ipv6_mreq ..." >&4
11687$cat >try.c <<EOF
11688#include <sys/types.h>
11689#include <sys/socket.h>
11690#include <netinet/in.h>
11691int main() {
11692struct ipv6_mreq mreq;
11693return (mreq.ipv6mr_interface);
11694}
11695EOF
11696val="$undef"
11697set try; if eval $compile; then
11698    val="$define"
11699fi
11700set d_ipv6_mreq; eval $setvar
11701$rm_try
11702
11703echo " "
11704echo "Checking the availability struct ipv6_mreq_source ..." >&4
11705$cat >try.c <<EOF
11706#include <sys/types.h>
11707#include <sys/socket.h>
11708#include <netinet/in.h>
11709int main() {
11710struct ipv6_mreq_source mreq;
11711return (mreq.imr_multiaddr.s_addr);
11712}
11713EOF
11714val="$undef"
11715set try; if eval $compile; then
11716       val="$define"
11717fi
11718set d_ipv6_mreq_source; eval $setvar
11719$rm_try
11720
11721echo " "
11722echo "Checking the availability of certain socket constants..." >&4
11723for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
11724    enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
11725    $cat >try.c <<EOF
11726#include <sys/types.h>
11727#include <sys/socket.h>
11728int main() {
11729    int i = $ENUM;
11730}
11731EOF
11732    val="$undef"
11733    set try; if eval $compile; then
11734	val="$define"
11735    fi
11736    set d_${enum}; eval $setvar
11737    $rm_try
11738done
11739
11740: see if this is a sys/uio.h system
11741set sys/uio.h i_sysuio
11742eval $inhdr
11743
11744: Check for cmsghdr support
11745echo " "
11746echo "Checking to see if your system supports struct cmsghdr..." >&4
11747set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
11748eval $hasstruct
11749case "$d_cmsghdr_s" in
11750"$define")      echo "Yes, it does."   ;;
11751*)              echo "No, it doesn't." ;;
11752esac
11753
11754
11755: check for const keyword
11756echo " "
11757echo 'Checking to see if your C compiler knows about "const"...' >&4
11758$cat >const.c <<'EOCP'
11759typedef struct spug { int drokk; } spug;
11760int main()
11761{
11762	const char *foo;
11763	const spug y = { 0 };
11764}
11765EOCP
11766if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
11767	val="$define"
11768	echo "Yup, it does."
11769else
11770	val="$undef"
11771	echo "Nope, it doesn't."
11772fi
11773set d_const
11774eval $setvar
11775
11776: see if copysignl exists
11777set copysignl d_copysignl
11778eval $inlibc
11779
11780: see if crypt exists
11781echo " "
11782set crypt d_crypt
11783eval $inlibc
11784case "$d_crypt" in
11785$define) cryptlib='' ;;
11786*)	if set crypt val -f d_crypt; eval $csym; $val; then
11787		echo 'crypt() found.' >&4
11788		val="$define"
11789		cryptlib=''
11790	else
11791		cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
11792		if $test -z "$cryptlib"; then
11793			cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
11794		else
11795			cryptlib=-lcrypt
11796		fi
11797		if $test -z "$cryptlib"; then
11798			cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
11799		else
11800			cryptlib=-lcrypt
11801		fi
11802		if $test -z "$cryptlib"; then
11803			cryptlib=`./loc libcrypt$_a "" $libpth`
11804		else
11805			cryptlib=-lcrypt
11806		fi
11807		if $test -z "$cryptlib"; then
11808			echo 'crypt() NOT found.' >&4
11809			val="$undef"
11810		else
11811			val="$define"
11812		fi
11813	fi
11814	set d_crypt
11815	eval $setvar
11816	;;
11817esac
11818
11819: see if this is a crypt.h system
11820set crypt.h i_crypt
11821eval $inhdr
11822
11823: see if crypt_r exists
11824set crypt_r d_crypt_r
11825eval $inlibc
11826case "$d_crypt_r" in
11827"$define")
11828	hdrs="$i_systypes sys/types.h define stdio.h $i_crypt crypt.h"
11829	case "$d_crypt_r_proto:$usethreads" in
11830	":define")	d_crypt_r_proto=define
11831		set d_crypt_r_proto crypt_r $hdrs
11832		eval $hasproto ;;
11833	*)	;;
11834	esac
11835	case "$d_crypt_r_proto" in
11836	define)
11837	case "$crypt_r_proto" in
11838	''|0) try='char* crypt_r(const char*, const char*, struct crypt_data*);'
11839	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCS ;;
11840	esac
11841	case "$crypt_r_proto" in
11842	''|0) try='char* crypt_r(const char*, const char*, CRYPTD*);'
11843	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCD ;;
11844	esac
11845	case "$crypt_r_proto" in
11846	''|0)	d_crypt_r=undef
11847 	        crypt_r_proto=0
11848		echo "Disabling crypt_r, cannot determine prototype." >&4 ;;
11849	* )	case "$crypt_r_proto" in
11850		REENTRANT_PROTO*) ;;
11851		*) crypt_r_proto="REENTRANT_PROTO_$crypt_r_proto" ;;
11852		esac
11853		echo "Prototype: $try" ;;
11854	esac
11855	;;
11856	*)	case "$usethreads" in
11857		define) echo "crypt_r has no prototype, not using it." >&4 ;;
11858		esac
11859		d_crypt_r=undef
11860		crypt_r_proto=0
11861		;;
11862	esac
11863	;;
11864*)	crypt_r_proto=0
11865	;;
11866esac
11867
11868: get csh whereabouts
11869case "$csh" in
11870'csh') val="$undef" ;;
11871*) val="$define" ;;
11872esac
11873set d_csh
11874eval $setvar
11875: Respect a hint or command line value for full_csh.
11876case "$full_csh" in
11877'') full_csh=$csh ;;
11878esac
11879
11880: see if ctermid exists
11881set ctermid d_ctermid
11882eval $inlibc
11883
11884: see if ctermid_r exists
11885set ctermid_r d_ctermid_r
11886eval $inlibc
11887case "$d_ctermid_r" in
11888"$define")
11889	hdrs="$i_systypes sys/types.h define stdio.h "
11890	case "$d_ctermid_r_proto:$usethreads" in
11891	":define")	d_ctermid_r_proto=define
11892		set d_ctermid_r_proto ctermid_r $hdrs
11893		eval $hasproto ;;
11894	*)	;;
11895	esac
11896	case "$d_ctermid_r_proto" in
11897	define)
11898	case "$ctermid_r_proto" in
11899	''|0) try='char* ctermid_r(char*);'
11900	./protochk "$extern_C $try" $hdrs && ctermid_r_proto=B_B ;;
11901	esac
11902	case "$ctermid_r_proto" in
11903	''|0)	d_ctermid_r=undef
11904 	        ctermid_r_proto=0
11905		echo "Disabling ctermid_r, cannot determine prototype." >&4 ;;
11906	* )	case "$ctermid_r_proto" in
11907		REENTRANT_PROTO*) ;;
11908		*) ctermid_r_proto="REENTRANT_PROTO_$ctermid_r_proto" ;;
11909		esac
11910		echo "Prototype: $try" ;;
11911	esac
11912	;;
11913	*)	case "$usethreads" in
11914		define) echo "ctermid_r has no prototype, not using it." >&4 ;;
11915		esac
11916		d_ctermid_r=undef
11917		ctermid_r_proto=0
11918		;;
11919	esac
11920	;;
11921*)	ctermid_r_proto=0
11922	;;
11923esac
11924
11925: see if ctime_r exists
11926set ctime_r d_ctime_r
11927eval $inlibc
11928case "$d_ctime_r" in
11929"$define")
11930	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
11931	case "$d_ctime_r_proto:$usethreads" in
11932	":define")	d_ctime_r_proto=define
11933		set d_ctime_r_proto ctime_r $hdrs
11934		eval $hasproto ;;
11935	*)	;;
11936	esac
11937	case "$d_ctime_r_proto" in
11938	define)
11939	case "$ctime_r_proto" in
11940	''|0) try='char* ctime_r(const time_t*, char*);'
11941	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SB ;;
11942	esac
11943	case "$ctime_r_proto" in
11944	''|0) try='char* ctime_r(const time_t*, char*, int);'
11945	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SBI ;;
11946	esac
11947	case "$ctime_r_proto" in
11948	''|0) try='int ctime_r(const time_t*, char*);'
11949	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SB ;;
11950	esac
11951	case "$ctime_r_proto" in
11952	''|0) try='int ctime_r(const time_t*, char*, int);'
11953	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SBI ;;
11954	esac
11955	case "$ctime_r_proto" in
11956	''|0)	d_ctime_r=undef
11957 	        ctime_r_proto=0
11958		echo "Disabling ctime_r, cannot determine prototype." >&4 ;;
11959	* )	case "$ctime_r_proto" in
11960		REENTRANT_PROTO*) ;;
11961		*) ctime_r_proto="REENTRANT_PROTO_$ctime_r_proto" ;;
11962		esac
11963		echo "Prototype: $try" ;;
11964	esac
11965	;;
11966	*)	case "$usethreads" in
11967		define) echo "ctime_r has no prototype, not using it." >&4 ;;
11968		esac
11969		d_ctime_r=undef
11970		ctime_r_proto=0
11971		;;
11972	esac
11973	;;
11974*)	ctime_r_proto=0
11975	;;
11976esac
11977
11978: see if cuserid exists
11979set cuserid d_cuserid
11980eval $inlibc
11981
11982: see if this is a limits.h system
11983set limits.h i_limits
11984eval $inhdr
11985
11986: see if this is a float.h system
11987set float.h i_float
11988eval $inhdr
11989
11990: See if number of significant digits in a double precision number is known
11991echo " "
11992$cat >dbl_dig.c <<EOM
11993#$i_limits I_LIMITS
11994#$i_float I_FLOAT
11995#ifdef I_LIMITS
11996#include <limits.h>
11997#endif
11998#ifdef I_FLOAT
11999#include <float.h>
12000#endif
12001#ifdef DBL_DIG
12002printf("Contains DBL_DIG");
12003#endif
12004EOM
12005$cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
12006if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
12007	echo "DBL_DIG found." >&4
12008	val="$define"
12009else
12010	echo "DBL_DIG NOT found." >&4
12011	val="$undef"
12012fi
12013$rm -f dbl_dig.?
12014set d_dbl_dig
12015eval $setvar
12016
12017: see if dbm.h is available
12018: see if dbmclose exists
12019set dbmclose d_dbmclose
12020eval $inlibc
12021
12022case "$d_dbmclose" in
12023$define)
12024	set dbm.h i_dbm
12025	eval $inhdr
12026	case "$i_dbm" in
12027	$define)
12028		val="$undef"
12029		set i_rpcsvcdbm
12030		eval $setvar
12031		;;
12032	*)	set rpcsvc/dbm.h i_rpcsvcdbm
12033		eval $inhdr
12034		;;
12035	esac
12036	;;
12037*)	echo "We won't be including <dbm.h>"
12038	val="$undef"
12039	set i_dbm
12040	eval $setvar
12041	val="$undef"
12042	set i_rpcsvcdbm
12043	eval $setvar
12044	;;
12045esac
12046
12047: see if prototype for dbminit is available
12048echo " "
12049set d_dbminitproto dbminit $i_dbm dbm.h
12050eval $hasproto
12051
12052: see if difftime exists
12053set difftime d_difftime
12054eval $inlibc
12055
12056: see if this is a dirent system
12057echo " "
12058if xinc=`./findhdr dirent.h`; $test "$xinc"; then
12059	val="$define"
12060	echo "<dirent.h> found." >&4
12061else
12062	val="$undef"
12063	if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
12064		echo "<sys/dir.h> found." >&4
12065		echo " "
12066	else
12067		xinc=`./findhdr sys/ndir.h`
12068	fi
12069	echo "<dirent.h> NOT found." >&4
12070fi
12071set i_dirent
12072eval $setvar
12073
12074: Look for type of directory structure.
12075echo " "
12076$cppstdin $cppflags $cppminus < "$xinc" > try.c
12077
12078case "$direntrytype" in
12079''|' ')
12080	case "$i_dirent" in
12081	$define) guess1='struct dirent' ;;
12082	*) guess1='struct direct'  ;;
12083	esac
12084	;;
12085*)	guess1="$direntrytype"
12086	;;
12087esac
12088
12089case "$guess1" in
12090'struct dirent') guess2='struct direct' ;;
12091*) guess2='struct dirent' ;;
12092esac
12093
12094if $contains "$guess1" try.c >/dev/null 2>&1; then
12095	direntrytype="$guess1"
12096	echo "Your directory entries are $direntrytype." >&4
12097elif $contains "$guess2" try.c >/dev/null 2>&1; then
12098	direntrytype="$guess2"
12099	echo "Your directory entries seem to be $direntrytype." >&4
12100else
12101	echo "I don't recognize your system's directory entries." >&4
12102	rp="What type is used for directory entries on this system?"
12103	dflt="$guess1"
12104	. ./myread
12105	direntrytype="$ans"
12106fi
12107$rm_try
12108
12109: see if the directory entry stores field length
12110echo " "
12111$cppstdin $cppflags $cppminus < "$xinc" > try.c
12112if $contains 'd_namlen' try.c >/dev/null 2>&1; then
12113	echo "Good, your directory entry keeps length information in d_namlen." >&4
12114	val="$define"
12115else
12116	echo "Your directory entry does not know about the d_namlen field." >&4
12117	val="$undef"
12118fi
12119set d_dirnamlen
12120eval $setvar
12121$rm_try
12122
12123: Look for DIR.dd_fd
12124case "$i_dirent" in
12125"$define")
12126    echo "Checking to see if DIR has a dd_fd member variable" >&4
12127    $cat >try.c <<EOCP
12128#$i_stdlib I_STDLIB
12129#ifdef I_STDLIB
12130#include <stdlib.h>
12131#endif
12132#include <dirent.h>
12133
12134int main() {
12135    DIR dir;
12136    dir.dd_fd = 1;
12137    return 0;
12138}
12139EOCP
12140    val=$undef
12141    set try
12142    if eval $compile; then
12143        echo "Yes, it does."
12144        val="$define"
12145    else
12146        echo "No, it does not."
12147        val="$undef"
12148    fi
12149    ;;
12150*)
12151    echo "You don't have a <dirent.h>, so not checking for dd_fd." >&4
12152    val="$undef"
12153    ;;
12154esac
12155set d_dir_dd_fd
12156eval $setvar
12157$rm_try
12158
12159: see if this is an sysdir system
12160set sys/dir.h i_sysdir
12161eval $inhdr
12162
12163: see if this is an sysndir system
12164set sys/ndir.h i_sysndir
12165eval $inhdr
12166
12167: Look for dirfd
12168echo " "
12169$cat >dirfd.c <<EOM
12170#include <stdio.h>
12171#$i_stdlib I_STDLIB
12172#ifdef I_STDLIB
12173#include <stdlib.h>
12174#endif
12175#$i_dirent I_DIRENT		/**/
12176#$i_sysdir I_SYS_DIR		/**/
12177#$i_sysndir I_SYS_NDIR		/**/
12178#$i_systypes I_SYS_TYPES	/**/
12179#if defined(I_SYS_TYPES)
12180#include <sys/types.h>
12181#endif
12182#if defined(I_DIRENT)
12183#include <dirent.h>
12184#if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
12185#include <sys/dir.h>
12186#endif
12187#else
12188#ifdef I_SYS_NDIR
12189#include <sys/ndir.h>
12190#else
12191#ifdef I_SYS_DIR
12192#ifdef hp9000s500
12193#include <ndir.h>	/* may be wrong in the future */
12194#else
12195#include <sys/dir.h>
12196#endif
12197#endif
12198#endif
12199#endif
12200int main() {
12201	DIR *dirp = opendir(".");
12202	if (dirfd(dirp) >= 0)
12203		exit(0);
12204	else
12205		exit(1);
12206}
12207EOM
12208val=$undef
12209set dirfd
12210if eval $compile; then
12211	val="$define"
12212fi
12213case "$val" in
12214$define)	echo "dirfd() found." >&4	;;
12215*)		echo "dirfd() NOT found." >&4	;;
12216esac
12217set d_dirfd
12218eval $setvar
12219$rm -f dirfd*
12220
12221: see if dlerror exists
12222xxx_runnm="$runnm"
12223runnm=false
12224set dlerror d_dlerror
12225eval $inlibc
12226runnm="$xxx_runnm"
12227
12228: see if dlfcn is available
12229set dlfcn.h i_dlfcn
12230eval $inhdr
12231
12232: Check what extension to use for shared libs
12233case "$usedl" in
12234$define|y|true)
12235	$cat << EOM
12236
12237On a few systems, the dynamically loaded modules that perl generates and uses
12238will need a different extension than shared libs. The default will probably
12239be appropriate.
12240
12241EOM
12242	case "$dlext" in
12243	'')	dflt="$so" ;;
12244	*)	dflt="$dlext" ;;
12245	esac
12246	rp='What is the extension of dynamically loaded modules'
12247	. ./myread
12248	dlext="$ans"
12249	;;
12250*)
12251	dlext="none"
12252	;;
12253esac
12254
12255: Check if dlsym need a leading underscore
12256echo " "
12257val="$undef"
12258
12259case "$dlsrc" in
12260dl_dlopen.xs)
12261	echo "Checking whether your dlsym() needs a leading underscore ..." >&4
12262	$cat >dyna.c <<'EOM'
12263fred () { }
12264EOM
12265
12266$cat >fred.c<<EOM
12267
12268#include <stdio.h>
12269#$i_stdlib I_STDLIB
12270#ifdef I_STDLIB
12271#include <stdlib.h>
12272#endif
12273#$i_dlfcn I_DLFCN
12274#ifdef I_DLFCN
12275#include <dlfcn.h>      /* the dynamic linker include file for SunOS/Solaris */
12276#else
12277#include <sys/types.h>
12278#include <nlist.h>
12279#include <link.h>
12280#endif
12281
12282extern int fred() ;
12283
12284int main()
12285{
12286    void * handle ;
12287    void * symbol ;
12288#ifndef RTLD_LAZY
12289    int mode = 1 ;
12290#else
12291    int mode = RTLD_LAZY ;
12292#endif
12293    handle = dlopen("./dyna.$dlext", mode) ;
12294    if (handle == NULL) {
12295	printf ("1\n") ;
12296	fflush (stdout) ;
12297	exit(0);
12298    }
12299    symbol = dlsym(handle, "fred") ;
12300    if (symbol == NULL) {
12301	/* try putting a leading underscore */
12302	symbol = dlsym(handle, "_fred") ;
12303	if (symbol == NULL) {
12304	    printf ("2\n") ;
12305	    fflush (stdout) ;
12306	    exit(0);
12307	}
12308	printf ("3\n") ;
12309    }
12310    else
12311	printf ("4\n") ;
12312    fflush (stdout) ;
12313    exit(0);
12314}
12315EOM
12316	: Call the object file tmp-dyna.o in case dlext=o.
12317	if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 &&
12318		mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 &&
12319		$ld -o dyna.$dlext $ldflags $lddlflags tmp-dyna${_o} > /dev/null 2>&1 &&
12320		$cc -o fred $ccflags $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1 && $to dyna.$dlext; then
12321		xxx=`$run ./fred`
12322		case $xxx in
12323		1)	echo "Test program failed using dlopen." >&4
12324			echo "Perhaps you should not use dynamic loading." >&4;;
12325		2)	echo "Test program failed using dlsym." >&4
12326			echo "Perhaps you should not use dynamic loading." >&4;;
12327		3)	echo "dlsym needs a leading underscore" >&4
12328			val="$define" ;;
12329		4)	echo "dlsym doesn't need a leading underscore." >&4;;
12330		esac
12331	else
12332		echo "I can't compile and run the test program." >&4
12333                echo "I'm guessing that dlsym doesn't need a leading underscore." >&4
12334	fi
12335	;;
12336esac
12337
12338$rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.*
12339
12340set d_dlsymun
12341eval $setvar
12342
12343: see if drand48_r exists
12344set drand48_r d_drand48_r
12345eval $inlibc
12346case "$d_drand48_r" in
12347"$define")
12348	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
12349	case "$d_drand48_r_proto:$usethreads" in
12350	":define")	d_drand48_r_proto=define
12351		set d_drand48_r_proto drand48_r $hdrs
12352		eval $hasproto ;;
12353	*)	;;
12354	esac
12355	case "$d_drand48_r_proto" in
12356	define)
12357	case "$drand48_r_proto" in
12358	''|0) try='int drand48_r(struct drand48_data*, double*);'
12359	./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;;
12360	esac
12361	case "$drand48_r_proto" in
12362	''|0)	d_drand48_r=undef
12363 	        drand48_r_proto=0
12364		echo "Disabling drand48_r, cannot determine prototype." >&4 ;;
12365	* )	case "$drand48_r_proto" in
12366		REENTRANT_PROTO*) ;;
12367		*) drand48_r_proto="REENTRANT_PROTO_$drand48_r_proto" ;;
12368		esac
12369		echo "Prototype: $try" ;;
12370	esac
12371	;;
12372	*)	case "$usethreads" in
12373		define) echo "drand48_r has no prototype, not using it." >&4 ;;
12374		esac
12375		d_drand48_r=undef
12376		drand48_r_proto=0
12377		;;
12378	esac
12379	;;
12380*)	drand48_r_proto=0
12381	;;
12382esac
12383
12384: see if prototype for drand48 is available
12385echo " "
12386set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
12387eval $hasproto
12388
12389: see if dup2 exists
12390set dup2 d_dup2
12391eval $inlibc
12392
12393: see if eaccess exists
12394set eaccess d_eaccess
12395eval $inlibc
12396
12397: see if endgrent exists
12398set endgrent d_endgrent
12399eval $inlibc
12400
12401: see if this is an grp system
12402set grp.h i_grp
12403eval $inhdr
12404
12405case "$i_grp" in
12406$define)
12407	xxx=`./findhdr grp.h`
12408	$cppstdin $cppflags $cppminus < $xxx >$$.h
12409
12410	if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
12411		val="$define"
12412	else
12413		val="$undef"
12414	fi
12415	set d_grpasswd
12416	eval $setvar
12417
12418	$rm -f $$.h
12419	;;
12420*)
12421	val="$undef";
12422	set d_grpasswd; eval $setvar
12423	;;
12424esac
12425
12426: see if endgrent_r exists
12427set endgrent_r d_endgrent_r
12428eval $inlibc
12429case "$d_endgrent_r" in
12430"$define")
12431	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
12432	case "$d_endgrent_r_proto:$usethreads" in
12433	":define")	d_endgrent_r_proto=define
12434		set d_endgrent_r_proto endgrent_r $hdrs
12435		eval $hasproto ;;
12436	*)	;;
12437	esac
12438	case "$d_endgrent_r_proto" in
12439	define)
12440	case "$endgrent_r_proto" in
12441	''|0) try='int endgrent_r(FILE**);'
12442	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=I_H ;;
12443	esac
12444	case "$endgrent_r_proto" in
12445	''|0) try='void endgrent_r(FILE**);'
12446	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=V_H ;;
12447	esac
12448	case "$endgrent_r_proto" in
12449	''|0)	d_endgrent_r=undef
12450 	        endgrent_r_proto=0
12451		echo "Disabling endgrent_r, cannot determine prototype." >&4 ;;
12452	* )	case "$endgrent_r_proto" in
12453		REENTRANT_PROTO*) ;;
12454		*) endgrent_r_proto="REENTRANT_PROTO_$endgrent_r_proto" ;;
12455		esac
12456		echo "Prototype: $try" ;;
12457	esac
12458	;;
12459	*)	case "$usethreads" in
12460		define) echo "endgrent_r has no prototype, not using it." >&4 ;;
12461		esac
12462		d_endgrent_r=undef
12463		endgrent_r_proto=0
12464		;;
12465	esac
12466	;;
12467*)	endgrent_r_proto=0
12468	;;
12469esac
12470
12471: see if endhostent exists
12472set endhostent d_endhent
12473eval $inlibc
12474
12475: see if this is a netdb.h system
12476set netdb.h i_netdb
12477eval $inhdr
12478
12479: see if endhostent_r exists
12480set endhostent_r d_endhostent_r
12481eval $inlibc
12482case "$d_endhostent_r" in
12483"$define")
12484	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12485	case "$d_endhostent_r_proto:$usethreads" in
12486	":define")	d_endhostent_r_proto=define
12487		set d_endhostent_r_proto endhostent_r $hdrs
12488		eval $hasproto ;;
12489	*)	;;
12490	esac
12491	case "$d_endhostent_r_proto" in
12492	define)
12493	case "$endhostent_r_proto" in
12494	''|0) try='int endhostent_r(struct hostent_data*);'
12495	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=I_D ;;
12496	esac
12497	case "$endhostent_r_proto" in
12498	''|0) try='void endhostent_r(struct hostent_data*);'
12499	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=V_D ;;
12500	esac
12501	case "$endhostent_r_proto" in
12502	''|0)	d_endhostent_r=undef
12503 	        endhostent_r_proto=0
12504		echo "Disabling endhostent_r, cannot determine prototype." >&4 ;;
12505	* )	case "$endhostent_r_proto" in
12506		REENTRANT_PROTO*) ;;
12507		*) endhostent_r_proto="REENTRANT_PROTO_$endhostent_r_proto" ;;
12508		esac
12509		echo "Prototype: $try" ;;
12510	esac
12511	;;
12512	*)	case "$usethreads" in
12513		define) echo "endhostent_r has no prototype, not using it." >&4 ;;
12514		esac
12515		d_endhostent_r=undef
12516		endhostent_r_proto=0
12517		;;
12518	esac
12519	;;
12520*)	endhostent_r_proto=0
12521	;;
12522esac
12523
12524: see if endnetent exists
12525set endnetent d_endnent
12526eval $inlibc
12527
12528: see if endnetent_r exists
12529set endnetent_r d_endnetent_r
12530eval $inlibc
12531case "$d_endnetent_r" in
12532"$define")
12533	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12534	case "$d_endnetent_r_proto:$usethreads" in
12535	":define")	d_endnetent_r_proto=define
12536		set d_endnetent_r_proto endnetent_r $hdrs
12537		eval $hasproto ;;
12538	*)	;;
12539	esac
12540	case "$d_endnetent_r_proto" in
12541	define)
12542	case "$endnetent_r_proto" in
12543	''|0) try='int endnetent_r(struct netent_data*);'
12544	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=I_D ;;
12545	esac
12546	case "$endnetent_r_proto" in
12547	''|0) try='void endnetent_r(struct netent_data*);'
12548	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=V_D ;;
12549	esac
12550	case "$endnetent_r_proto" in
12551	''|0)	d_endnetent_r=undef
12552 	        endnetent_r_proto=0
12553		echo "Disabling endnetent_r, cannot determine prototype." >&4 ;;
12554	* )	case "$endnetent_r_proto" in
12555		REENTRANT_PROTO*) ;;
12556		*) endnetent_r_proto="REENTRANT_PROTO_$endnetent_r_proto" ;;
12557		esac
12558		echo "Prototype: $try" ;;
12559	esac
12560	;;
12561	*)	case "$usethreads" in
12562		define) echo "endnetent_r has no prototype, not using it." >&4 ;;
12563		esac
12564		d_endnetent_r=undef
12565		endnetent_r_proto=0
12566		;;
12567	esac
12568	;;
12569*)	endnetent_r_proto=0
12570	;;
12571esac
12572
12573: see if endprotoent exists
12574set endprotoent d_endpent
12575eval $inlibc
12576
12577: see if endprotoent_r exists
12578set endprotoent_r d_endprotoent_r
12579eval $inlibc
12580case "$d_endprotoent_r" in
12581"$define")
12582	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12583	case "$d_endprotoent_r_proto:$usethreads" in
12584	":define")	d_endprotoent_r_proto=define
12585		set d_endprotoent_r_proto endprotoent_r $hdrs
12586		eval $hasproto ;;
12587	*)	;;
12588	esac
12589	case "$d_endprotoent_r_proto" in
12590	define)
12591	case "$endprotoent_r_proto" in
12592	''|0) try='int endprotoent_r(struct protoent_data*);'
12593	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=I_D ;;
12594	esac
12595	case "$endprotoent_r_proto" in
12596	''|0) try='void endprotoent_r(struct protoent_data*);'
12597	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=V_D ;;
12598	esac
12599	case "$endprotoent_r_proto" in
12600	''|0)	d_endprotoent_r=undef
12601 	        endprotoent_r_proto=0
12602		echo "Disabling endprotoent_r, cannot determine prototype." >&4 ;;
12603	* )	case "$endprotoent_r_proto" in
12604		REENTRANT_PROTO*) ;;
12605		*) endprotoent_r_proto="REENTRANT_PROTO_$endprotoent_r_proto" ;;
12606		esac
12607		echo "Prototype: $try" ;;
12608	esac
12609	;;
12610	*)	case "$usethreads" in
12611		define) echo "endprotoent_r has no prototype, not using it." >&4 ;;
12612		esac
12613		d_endprotoent_r=undef
12614		endprotoent_r_proto=0
12615		;;
12616	esac
12617	;;
12618*)	endprotoent_r_proto=0
12619	;;
12620esac
12621
12622: see if endpwent exists
12623set endpwent d_endpwent
12624eval $inlibc
12625
12626: see if this is a pwd.h system
12627set pwd.h i_pwd
12628eval $inhdr
12629
12630case "$i_pwd" in
12631$define)
12632	xxx=`./findhdr pwd.h`
12633	$cppstdin $cppflags $cppminus < $xxx >$$.h
12634
12635	if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
12636		val="$define"
12637	else
12638		val="$undef"
12639	fi
12640	set d_pwquota
12641	eval $setvar
12642
12643	if $contains 'pw_age' $$.h >/dev/null 2>&1; then
12644		val="$define"
12645	else
12646		val="$undef"
12647	fi
12648	set d_pwage
12649	eval $setvar
12650
12651	if $contains 'pw_change' $$.h >/dev/null 2>&1; then
12652		val="$define"
12653	else
12654		val="$undef"
12655	fi
12656	set d_pwchange
12657	eval $setvar
12658
12659	if $contains 'pw_class' $$.h >/dev/null 2>&1; then
12660		val="$define"
12661	else
12662		val="$undef"
12663	fi
12664	set d_pwclass
12665	eval $setvar
12666
12667	if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
12668		val="$define"
12669	else
12670		val="$undef"
12671	fi
12672	set d_pwexpire
12673	eval $setvar
12674
12675	if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
12676		val="$define"
12677	else
12678		val="$undef"
12679	fi
12680	set d_pwcomment
12681	eval $setvar
12682
12683	if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
12684		val="$define"
12685	else
12686		val="$undef"
12687	fi
12688	set d_pwgecos
12689	eval $setvar
12690
12691	if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
12692		val="$define"
12693	else
12694		val="$undef"
12695	fi
12696	set d_pwpasswd
12697	eval $setvar
12698
12699	$rm -f $$.h
12700	;;
12701*)
12702	val="$undef";
12703	set d_pwquota; eval $setvar
12704	set d_pwage; eval $setvar
12705	set d_pwchange; eval $setvar
12706	set d_pwclass; eval $setvar
12707	set d_pwexpire; eval $setvar
12708	set d_pwcomment; eval $setvar
12709	set d_pwgecos; eval $setvar
12710	set d_pwpasswd; eval $setvar
12711	;;
12712esac
12713
12714: see if endpwent_r exists
12715set endpwent_r d_endpwent_r
12716eval $inlibc
12717case "$d_endpwent_r" in
12718"$define")
12719	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
12720	case "$d_endpwent_r_proto:$usethreads" in
12721	":define")	d_endpwent_r_proto=define
12722		set d_endpwent_r_proto endpwent_r $hdrs
12723		eval $hasproto ;;
12724	*)	;;
12725	esac
12726	case "$d_endpwent_r_proto" in
12727	define)
12728	case "$endpwent_r_proto" in
12729	''|0) try='int endpwent_r(FILE**);'
12730	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=I_H ;;
12731	esac
12732	case "$endpwent_r_proto" in
12733	''|0) try='void endpwent_r(FILE**);'
12734	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=V_H ;;
12735	esac
12736	case "$endpwent_r_proto" in
12737	''|0)	d_endpwent_r=undef
12738 	        endpwent_r_proto=0
12739		echo "Disabling endpwent_r, cannot determine prototype." >&4 ;;
12740	* )	case "$endpwent_r_proto" in
12741		REENTRANT_PROTO*) ;;
12742		*) endpwent_r_proto="REENTRANT_PROTO_$endpwent_r_proto" ;;
12743		esac
12744		echo "Prototype: $try" ;;
12745	esac
12746	;;
12747	*)	case "$usethreads" in
12748		define) echo "endpwent_r has no prototype, not using it." >&4 ;;
12749		esac
12750		d_endpwent_r=undef
12751		endpwent_r_proto=0
12752		;;
12753	esac
12754	;;
12755*)	endpwent_r_proto=0
12756	;;
12757esac
12758
12759: see if endservent exists
12760set endservent d_endsent
12761eval $inlibc
12762
12763: see if endservent_r exists
12764set endservent_r d_endservent_r
12765eval $inlibc
12766case "$d_endservent_r" in
12767"$define")
12768	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12769	case "$d_endservent_r_proto:$usethreads" in
12770	":define")	d_endservent_r_proto=define
12771		set d_endservent_r_proto endservent_r $hdrs
12772		eval $hasproto ;;
12773	*)	;;
12774	esac
12775	case "$d_endservent_r_proto" in
12776	define)
12777	case "$endservent_r_proto" in
12778	''|0) try='int endservent_r(struct servent_data*);'
12779	./protochk "$extern_C $try" $hdrs && endservent_r_proto=I_D ;;
12780	esac
12781	case "$endservent_r_proto" in
12782	''|0) try='void endservent_r(struct servent_data*);'
12783	./protochk "$extern_C $try" $hdrs && endservent_r_proto=V_D ;;
12784	esac
12785	case "$endservent_r_proto" in
12786	''|0)	d_endservent_r=undef
12787 	        endservent_r_proto=0
12788		echo "Disabling endservent_r, cannot determine prototype." >&4 ;;
12789	* )	case "$endservent_r_proto" in
12790		REENTRANT_PROTO*) ;;
12791		*) endservent_r_proto="REENTRANT_PROTO_$endservent_r_proto" ;;
12792		esac
12793		echo "Prototype: $try" ;;
12794	esac
12795	;;
12796	*)	case "$usethreads" in
12797		define) echo "endservent_r has no prototype, not using it." >&4 ;;
12798		esac
12799		d_endservent_r=undef
12800		endservent_r_proto=0
12801		;;
12802	esac
12803	;;
12804*)	endservent_r_proto=0
12805	;;
12806esac
12807
12808: Locate the flags for 'open()'
12809echo " "
12810$cat >try.c <<EOCP
12811#include <sys/types.h>
12812#ifdef I_FCNTL
12813#include <fcntl.h>
12814#endif
12815#ifdef I_SYS_FILE
12816#include <sys/file.h>
12817#endif
12818#$i_stdlib I_STDLIB
12819#ifdef I_STDLIB
12820#include <stdlib.h>
12821#endif
12822int main() {
12823	if(O_RDONLY);
12824#ifdef O_TRUNC
12825	exit(0);
12826#else
12827	exit(1);
12828#endif
12829}
12830EOCP
12831: check sys/file.h first to get FREAD on Sun
12832if $test `./findhdr sys/file.h` && \
12833		set try -DI_SYS_FILE && eval $compile; then
12834	h_sysfile=true;
12835	echo "<sys/file.h> defines the O_* constants..." >&4
12836	if $run ./try; then
12837		echo "and you have the 3 argument form of open()." >&4
12838		val="$define"
12839	else
12840		echo "but not the 3 argument form of open().  Oh, well." >&4
12841		val="$undef"
12842	fi
12843elif $test `./findhdr fcntl.h` && \
12844		set try -DI_FCNTL && eval $compile; then
12845	h_fcntl=true;
12846	echo "<fcntl.h> defines the O_* constants..." >&4
12847	if $run ./try; then
12848		echo "and you have the 3 argument form of open()." >&4
12849		val="$define"
12850	else
12851		echo "but not the 3 argument form of open().  Oh, well." >&4
12852		val="$undef"
12853	fi
12854else
12855	val="$undef"
12856	echo "I can't find the O_* constant definitions!  You got problems." >&4
12857fi
12858set d_open3
12859eval $setvar
12860$rm_try
12861
12862: see if this is a sys/file.h system
12863val=''
12864set sys/file.h val
12865eval $inhdr
12866
12867: do we need to include sys/file.h ?
12868case "$val" in
12869"$define")
12870	echo " "
12871	if $h_sysfile; then
12872		val="$define"
12873		echo "We'll be including <sys/file.h>." >&4
12874	else
12875		val="$undef"
12876		echo "We won't be including <sys/file.h>." >&4
12877	fi
12878	;;
12879*)
12880	h_sysfile=false
12881	;;
12882esac
12883set i_sysfile
12884eval $setvar
12885
12886: see if fcntl.h is there
12887val=''
12888set fcntl.h val
12889eval $inhdr
12890
12891: see if we can include fcntl.h
12892case "$val" in
12893"$define")
12894	echo " "
12895	if $h_fcntl; then
12896		val="$define"
12897		echo "We'll be including <fcntl.h>." >&4
12898	else
12899		val="$undef"
12900		if $h_sysfile; then
12901	echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12902		else
12903			echo "We won't be including <fcntl.h>." >&4
12904		fi
12905	fi
12906	;;
12907*)
12908	h_fcntl=false
12909	val="$undef"
12910	;;
12911esac
12912set i_fcntl
12913eval $setvar
12914
12915: see if fork exists
12916set fork d_fork
12917eval $inlibc
12918
12919: see if pipe exists
12920set pipe d_pipe
12921eval $inlibc
12922
12923: check for non-blocking I/O stuff
12924case "$h_sysfile" in
12925true) echo "#include <sys/file.h>" > head.c;;
12926*)
12927       case "$h_fcntl" in
12928       true) echo "#include <fcntl.h>" > head.c;;
12929       *) echo "#include <sys/fcntl.h>" > head.c;;
12930       esac
12931       ;;
12932esac
12933echo " "
12934echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
12935case "$o_nonblock" in
12936'')
12937	$cat head.c > try.c
12938	$cat >>try.c <<EOCP
12939#include <stdio.h>
12940#$i_stdlib I_STDLIB
12941#ifdef I_STDLIB
12942#include <stdlib.h>
12943#endif
12944#$i_fcntl I_FCNTL
12945#ifdef I_FCNTL
12946#include <fcntl.h>
12947#endif
12948int main() {
12949#ifdef O_NONBLOCK
12950	printf("O_NONBLOCK\n");
12951	exit(0);
12952#endif
12953#ifdef O_NDELAY
12954	printf("O_NDELAY\n");
12955	exit(0);
12956#endif
12957#ifdef FNDELAY
12958	printf("FNDELAY\n");
12959	exit(0);
12960#endif
12961	exit(0);
12962}
12963EOCP
12964	set try
12965	if eval $compile_ok; then
12966		o_nonblock=`$run ./try`
12967		case "$o_nonblock" in
12968		'') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
12969		*) echo "Seems like we can use $o_nonblock.";;
12970		esac
12971	else
12972		echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
12973	fi
12974	;;
12975*) echo "Using $hint value $o_nonblock.";;
12976esac
12977$rm_try
12978
12979echo " "
12980echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
12981case "$eagain" in
12982'')
12983	case "$d_fork:$d_pipe" in
12984	define:define)
12985	$cat head.c > try.c
12986	$cat >>try.c <<EOCP
12987#include <errno.h>
12988#include <sys/types.h>
12989#include <signal.h>
12990#include <stdio.h>
12991#$i_stdlib I_STDLIB
12992#ifdef I_STDLIB
12993#include <stdlib.h>
12994#endif
12995#$i_fcntl I_FCNTL
12996#ifdef I_FCNTL
12997#include <fcntl.h>
12998#endif
12999#define MY_O_NONBLOCK $o_nonblock
13000#ifndef errno  /* XXX need better Configure test */
13001extern int errno;
13002#endif
13003#$i_unistd I_UNISTD
13004#ifdef I_UNISTD
13005#include <unistd.h>
13006#endif
13007#$i_string I_STRING
13008#ifdef I_STRING
13009#include <string.h>
13010#else
13011#include <strings.h>
13012#endif
13013$signal_t blech(int x) { exit(3); }
13014EOCP
13015	$cat >> try.c <<'EOCP'
13016int main()
13017{
13018	int pd[2];
13019	int pu[2];
13020	char buf[1];
13021	char string[100];
13022
13023	pipe(pd);	/* Down: child -> parent */
13024	pipe(pu);	/* Up: parent -> child */
13025	if (0 != fork()) {
13026		int ret;
13027		close(pd[1]);	/* Parent reads from pd[0] */
13028		close(pu[0]);	/* Parent writes (blocking) to pu[1] */
13029#ifdef F_SETFL
13030		if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
13031			exit(1);
13032#else
13033		exit(4);
13034#endif
13035		signal(SIGALRM, blech);
13036		alarm(5);
13037		if ((ret = read(pd[0], buf, 1)) > 0)	/* Nothing to read! */
13038			exit(2);
13039		sprintf(string, "%d\n", ret);
13040		write(2, string, strlen(string));
13041		alarm(0);
13042#ifdef EAGAIN
13043		if (errno == EAGAIN) {
13044			printf("EAGAIN\n");
13045			goto ok;
13046		}
13047#endif
13048#ifdef EWOULDBLOCK
13049		if (errno == EWOULDBLOCK)
13050			printf("EWOULDBLOCK\n");
13051#endif
13052	ok:
13053		write(pu[1], buf, 1);	/* Unblocks child, tell it to close our pipe */
13054		sleep(2);				/* Give it time to close our pipe */
13055		alarm(5);
13056		ret = read(pd[0], buf, 1);	/* Should read EOF */
13057		alarm(0);
13058		sprintf(string, "%d\n", ret);
13059		write(4, string, strlen(string));
13060		exit(0);
13061	}
13062
13063	close(pd[0]);			/* We write to pd[1] */
13064	close(pu[1]);			/* We read from pu[0] */
13065	read(pu[0], buf, 1);	/* Wait for parent to signal us we may continue */
13066	close(pd[1]);			/* Pipe pd is now fully closed! */
13067	exit(0);				/* Bye bye, thank you for playing! */
13068}
13069EOCP
13070	set try
13071	if eval $compile_ok; then
13072		echo "$startsh" >mtry
13073		echo "$run ./try >try.out 2>try.ret 4>try.err || exit 4" >>mtry
13074		chmod +x mtry
13075		$run ./mtry >/dev/null 2>&1
13076		case $? in
13077		0) eagain=`$cat try.out`;;
13078		1) echo "Could not perform non-blocking setting!";;
13079		2) echo "I did a successful read() for something that was not there!";;
13080		3) echo "Hmm... non-blocking I/O does not seem to be working!";;
13081		4) echo "Could not find F_SETFL!";;
13082		*) echo "Something terribly wrong happened during testing.";;
13083		esac
13084		rd_nodata=`$cat try.ret`
13085		echo "A read() system call with no data present returns $rd_nodata."
13086		case "$rd_nodata" in
13087		0|-1) ;;
13088		*)
13089			echo "(That's peculiar, fixing that to be -1.)"
13090			rd_nodata=-1
13091			;;
13092		esac
13093		case "$eagain" in
13094		'')
13095			echo "Forcing errno EAGAIN on read() with no data available."
13096			eagain=EAGAIN
13097			;;
13098		*)
13099			echo "Your read() sets errno to $eagain when no data is available."
13100			;;
13101		esac
13102		status=`$cat try.err`
13103		case "$status" in
13104		0) echo "And it correctly returns 0 to signal EOF.";;
13105		-1) echo "But it also returns -1 to signal EOF, so be careful!";;
13106		*) echo "However, your read() returns '$status' on EOF??";;
13107		esac
13108		val="$define"
13109		if test "$status" = "$rd_nodata"; then
13110			echo "WARNING: you can't distinguish between EOF and no data!"
13111			val="$undef"
13112		fi
13113	else
13114		echo "I can't compile the test program--assuming errno EAGAIN will do."
13115		eagain=EAGAIN
13116	fi
13117	;;
13118	*)	echo "Can't figure out how to test this--assuming errno EAGAIN will do."
13119		eagain=EAGAIN
13120		val="$define"
13121		;;
13122	esac
13123	set d_eofnblk
13124	eval $setvar
13125	;;
13126*)
13127	echo "Using $hint value $eagain."
13128	echo "Your read() returns $rd_nodata when no data is present."
13129	case "$d_eofnblk" in
13130	"$define") echo "And you can see EOF because read() returns 0.";;
13131	"$undef") echo "But you can't see EOF status from read() returned value.";;
13132	*)
13133		echo "(Assuming you can't see EOF status from read anyway.)"
13134		d_eofnblk=$undef
13135		;;
13136	esac
13137	;;
13138esac
13139$rm_try head.c mtry
13140
13141: see if _ptr and _cnt from stdio act std
13142echo " "
13143
13144if $contains '_lbfsize' `./findhdr stdio.h` >/dev/null 2>&1 ; then
13145	echo "(Looks like you have stdio.h from BSD.)"
13146	case "$stdio_ptr" in
13147	'') stdio_ptr='((fp)->_p)'
13148		ptr_lval=$define
13149		;;
13150	*)	ptr_lval=$d_stdio_ptr_lval;;
13151	esac
13152	case "$stdio_cnt" in
13153	'') stdio_cnt='((fp)->_r)'
13154		cnt_lval=$define
13155		;;
13156	*)	cnt_lval=$d_stdio_cnt_lval;;
13157	esac
13158	case "$stdio_base" in
13159	'') stdio_base='((fp)->_ub._base ? (fp)->_ub._base : (fp)->_bf._base)';;
13160	esac
13161	case "$stdio_bufsiz" in
13162	'') stdio_bufsiz='((fp)->_ub._base ? (fp)->_ub._size : (fp)->_bf._size)';;
13163	esac
13164elif $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
13165	echo "(Looks like you have stdio.h from Linux.)"
13166	case "$stdio_ptr" in
13167	'') stdio_ptr='((fp)->_IO_read_ptr)'
13168		ptr_lval=$define
13169		;;
13170	*)	ptr_lval=$d_stdio_ptr_lval;;
13171	esac
13172	case "$stdio_cnt" in
13173	'') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
13174		cnt_lval=$undef
13175		;;
13176	*)	cnt_lval=$d_stdio_cnt_lval;;
13177	esac
13178	case "$stdio_base" in
13179	'') stdio_base='((fp)->_IO_read_base)';;
13180	esac
13181	case "$stdio_bufsiz" in
13182	'') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
13183	esac
13184else
13185	case "$stdio_ptr" in
13186	'') stdio_ptr='((fp)->_ptr)'
13187		ptr_lval=$define
13188		;;
13189	*)	ptr_lval=$d_stdio_ptr_lval;;
13190	esac
13191	case "$stdio_cnt" in
13192	'') stdio_cnt='((fp)->_cnt)'
13193		cnt_lval=$define
13194		;;
13195	*)	cnt_lval=$d_stdio_cnt_lval;;
13196	esac
13197	case "$stdio_base" in
13198	'') stdio_base='((fp)->_base)';;
13199	esac
13200	case "$stdio_bufsiz" in
13201	'') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
13202	esac
13203fi
13204
13205: test whether _ptr and _cnt really work
13206echo "Checking how std your stdio is..." >&4
13207$cat >try.c <<EOP
13208#include <stdio.h>
13209#$i_stdlib I_STDLIB
13210#ifdef I_STDLIB
13211#include <stdlib.h>
13212#endif
13213#define FILE_ptr(fp)	$stdio_ptr
13214#define FILE_cnt(fp)	$stdio_cnt
13215int main() {
13216	FILE *fp = fopen("try.c", "r");
13217	char c = getc(fp);
13218	if (
13219		18 <= FILE_cnt(fp) &&
13220		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
13221	)
13222		exit(0);
13223	exit(1);
13224}
13225EOP
13226val="$undef"
13227set try
13228if eval $compile && $to try.c; then
13229	if $run ./try; then
13230		echo "Your stdio acts pretty std."
13231		val="$define"
13232	else
13233		echo "Your stdio isn't very std."
13234	fi
13235else
13236	echo "Your stdio doesn't appear very std."
13237fi
13238$rm_try
13239
13240# glibc 2.2.90 and above apparently change stdio streams so Perl's
13241# direct buffer manipulation no longer works.  The Configure tests
13242# should be changed to correctly detect this, but until then,
13243# the following check should at least let perl compile and run.
13244# (This quick fix should be updated before 5.8.1.)
13245# To be defensive, reject all unknown versions, and all versions  > 2.2.9.
13246# A. Dougherty, June 3, 2002.
13247case "$d_gnulibc" in
13248$define)
13249	case "$gnulibc_version" in
13250	2.[01]*)  ;;
13251	2.2) ;;
13252	2.2.[0-9]) ;;
13253	*)  echo "But I will not snoop inside glibc $gnulibc_version stdio buffers."
13254		val="$undef"
13255		;;
13256	esac
13257	;;
13258esac
13259set d_stdstdio
13260eval $setvar
13261
13262: Can _ptr be used as an lvalue?
13263case "$d_stdstdio$ptr_lval" in
13264$define$define) val=$define ;;
13265*) val=$undef ;;
13266esac
13267set d_stdio_ptr_lval
13268eval $setvar
13269
13270: Can _cnt be used as an lvalue?
13271case "$d_stdstdio$cnt_lval" in
13272$define$define) val=$define ;;
13273*) val=$undef ;;
13274esac
13275set d_stdio_cnt_lval
13276eval $setvar
13277
13278
13279: test whether setting _ptr sets _cnt as a side effect
13280d_stdio_ptr_lval_sets_cnt="$undef"
13281d_stdio_ptr_lval_nochange_cnt="$undef"
13282case "$d_stdio_ptr_lval$d_stdstdio" in
13283$define$define)
13284	echo "Checking to see what happens if we set the stdio ptr..." >&4
13285$cat >try.c <<EOP
13286#include <stdio.h>
13287/* Can we scream? */
13288/* Eat dust sed :-) */
13289/* In the buffer space, no one can hear you scream. */
13290#$i_stdlib I_STDLIB
13291#ifdef I_STDLIB
13292#include <stdlib.h>
13293#endif
13294#define FILE_ptr(fp)	$stdio_ptr
13295#define FILE_cnt(fp)	$stdio_cnt
13296#include <sys/types.h>
13297int main() {
13298	FILE *fp = fopen("try.c", "r");
13299	int c;
13300	char *ptr;
13301	size_t cnt;
13302	if (!fp) {
13303	    puts("Fail even to read");
13304	    exit(1);
13305	}
13306	c = getc(fp); /* Read away the first # */
13307	if (c == EOF) {
13308	    puts("Fail even to read");
13309	    exit(1);
13310	}
13311	if (!(
13312		18 <= FILE_cnt(fp) &&
13313		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
13314	)) {
13315		puts("Fail even to read");
13316		exit (1);
13317	}
13318	ptr = (char*) FILE_ptr(fp);
13319	cnt = (size_t)FILE_cnt(fp);
13320
13321	FILE_ptr(fp) += 42;
13322
13323	if ((char*)FILE_ptr(fp) != (ptr + 42)) {
13324		printf("Fail ptr check %p != %p", FILE_ptr(fp), (ptr + 42));
13325		exit (1);
13326	}
13327	if (FILE_cnt(fp) <= 20) {
13328		printf ("Fail (<20 chars to test)");
13329		exit (1);
13330	}
13331	if (strncmp(FILE_ptr(fp), "Eat dust sed :-) */\n", 20) != 0) {
13332		puts("Fail compare");
13333		exit (1);
13334	}
13335	if (cnt == FILE_cnt(fp)) {
13336		puts("Pass_unchanged");
13337		exit (0);
13338	}
13339	if (FILE_cnt(fp) == (cnt - 42)) {
13340		puts("Pass_changed");
13341		exit (0);
13342	}
13343	printf("Fail count was %d now %d\n", cnt, FILE_cnt(fp));
13344	return 1;
13345
13346}
13347EOP
13348	set try
13349	if eval $compile && $to try.c; then
13350 		case `$run ./try` in
13351		Pass_changed)
13352			echo "Increasing ptr in your stdio decreases cnt by the same amount.  Good." >&4
13353			d_stdio_ptr_lval_sets_cnt="$define" ;;
13354		Pass_unchanged)
13355			echo "Increasing ptr in your stdio leaves cnt unchanged.  Good." >&4
13356			d_stdio_ptr_lval_nochange_cnt="$define" ;;
13357		Fail*)
13358			echo "Increasing ptr in your stdio didn't do exactly what I expected.  We'll not be doing that then." >&4 ;;
13359		*)
13360			echo "It appears attempting to set ptr in your stdio is a bad plan." >&4 ;;
13361	esac
13362	else
13363		echo "It seems we can't set ptr in your stdio.  Nevermind." >&4
13364	fi
13365	$rm_try
13366	;;
13367esac
13368
13369: see if _base is also standard
13370val="$undef"
13371case "$d_stdstdio" in
13372$define)
13373	$cat >try.c <<EOP
13374#include <stdio.h>
13375#$i_stdlib I_STDLIB
13376#ifdef I_STDLIB
13377#include <stdlib.h>
13378#endif
13379#define FILE_base(fp)	$stdio_base
13380#define FILE_bufsiz(fp)	$stdio_bufsiz
13381int main() {
13382	FILE *fp = fopen("try.c", "r");
13383	char c = getc(fp);
13384	if (
13385		19 <= FILE_bufsiz(fp) &&
13386		strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
13387	)
13388		exit(0);
13389	exit(1);
13390}
13391EOP
13392	set try
13393	if eval $compile && $to try.c; then
13394		if $run ./try; then
13395			echo "And its _base field acts std."
13396			val="$define"
13397		else
13398			echo "But its _base field isn't std."
13399		fi
13400	else
13401		echo "However, it seems to be lacking the _base field."
13402	fi
13403	$rm_try
13404	;;
13405esac
13406set d_stdiobase
13407eval $setvar
13408
13409: see if fast_stdio exists
13410val="$undef"
13411case "$d_stdstdio:$d_stdio_ptr_lval" in
13412"$define:$define")
13413	case "$d_stdio_cnt_lval$d_stdio_ptr_lval_sets_cnt" in
13414	*$define*)
13415		echo "You seem to have 'fast stdio' to directly manipulate the stdio buffers." >& 4
13416		val="$define"
13417		;;
13418	esac
13419	;;
13420esac
13421set d_faststdio
13422eval $setvar
13423
13424
13425
13426: see if fchdir exists
13427set fchdir d_fchdir
13428eval $inlibc
13429
13430: see if fchmod exists
13431set fchmod d_fchmod
13432eval $inlibc
13433
13434: see if fchown exists
13435set fchown d_fchown
13436eval $inlibc
13437
13438: see if this is an fcntl system
13439set fcntl d_fcntl
13440eval $inlibc
13441
13442: See if fcntl-based locking works.
13443echo " "
13444$cat >try.c <<EOCP
13445#$i_stdlib I_STDLIB
13446#ifdef I_STDLIB
13447#include <stdlib.h>
13448#endif
13449#include <unistd.h>
13450#include <fcntl.h>
13451#include <signal.h>
13452$signal_t blech(int x) { exit(3); }
13453int main() {
13454#if defined(F_SETLK) && defined(F_SETLKW)
13455     struct flock flock;
13456     int retval, fd;
13457     fd = open("try.c", O_RDONLY);
13458     flock.l_type = F_RDLCK;
13459     flock.l_whence = SEEK_SET;
13460     flock.l_start = flock.l_len = 0;
13461     signal(SIGALRM, blech);
13462     alarm(10);
13463     retval = fcntl(fd, F_SETLK, &flock);
13464     close(fd);
13465     (retval < 0 ? exit(2) : exit(0));
13466#else
13467     exit(2);
13468#endif
13469}
13470EOCP
13471echo "Checking if fcntl-based file locking works... "
13472case "$d_fcntl" in
13473"$define")
13474	set try
13475	if eval $compile_ok; then
13476		if $run ./try; then
13477			echo "Yes, it seems to work."
13478			val="$define"
13479		else
13480			echo "Nope, it didn't work."
13481			val="$undef"
13482			case "$?" in
13483			3) $cat >&4 <<EOM
13484***
13485*** I had to forcibly timeout from fcntl(..., F_SETLK, ...).
13486*** This is (almost) impossible.
13487*** If your NFS lock daemons are not feeling well, something like
13488*** this may happen, please investigate.  Cannot continue, aborting.
13489***
13490EOM
13491				exit 1
13492				;;
13493			esac
13494		fi
13495	else
13496		echo "I'm unable to compile the test program, so I'll assume not."
13497		val="$undef"
13498	fi
13499	;;
13500*) val="$undef";
13501	echo "Nope, since you don't even have fcntl()."
13502	;;
13503esac
13504set d_fcntl_can_lock
13505eval $setvar
13506$rm_try
13507
13508: check for fd_set items
13509$cat <<EOM
13510
13511Checking to see how well your C compiler handles fd_set and friends ...
13512EOM
13513$cat >try.c <<EOCP
13514#$i_stdlib I_STDLIB
13515#ifdef I_STDLIB
13516#include <stdlib.h>
13517#endif
13518#$i_systime I_SYS_TIME
13519#$i_sysselct I_SYS_SELECT
13520#$d_socket HAS_SOCKET
13521#include <sys/types.h>
13522#ifdef HAS_SOCKET
13523#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
13524#endif
13525#ifdef I_SYS_TIME
13526#include <sys/time.h>
13527#endif
13528#ifdef I_SYS_SELECT
13529#include <sys/select.h>
13530#endif
13531int main() {
13532	fd_set fds;
13533
13534#ifdef TRYBITS
13535	if(fds.fds_bits);
13536#endif
13537
13538#if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
13539	exit(0);
13540#else
13541	exit(1);
13542#endif
13543}
13544EOCP
13545set try -DTRYBITS
13546if eval $compile; then
13547	d_fds_bits="$define"
13548	d_fd_set="$define"
13549	echo "Well, your system knows about the normal fd_set typedef..." >&4
13550	if $run ./try; then
13551		echo "and you have the normal fd_set macros (just as I'd expect)." >&4
13552		d_fd_macros="$define"
13553	else
13554		$cat >&4 <<'EOM'
13555but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
13556EOM
13557		d_fd_macros="$undef"
13558	fi
13559else
13560	$cat <<'EOM'
13561Hmm, your compiler has some difficulty with fd_set.  Checking further...
13562EOM
13563	set try
13564	if eval $compile; then
13565		d_fds_bits="$undef"
13566		d_fd_set="$define"
13567		echo "Well, your system has some sort of fd_set available..." >&4
13568		if $run ./try; then
13569			echo "and you have the normal fd_set macros." >&4
13570			d_fd_macros="$define"
13571		else
13572			$cat <<'EOM'
13573but not the normal fd_set macros!  Gross!  More work for me...
13574EOM
13575			d_fd_macros="$undef"
13576		fi
13577	else
13578	echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
13579		d_fd_set="$undef"
13580		d_fds_bits="$undef"
13581		d_fd_macros="$undef"
13582	fi
13583fi
13584$rm_try
13585
13586: see if fgetpos exists
13587set fgetpos d_fgetpos
13588eval $inlibc
13589
13590: see if finite exists
13591set finite d_finite
13592eval $inlibc
13593
13594: see if finitel exists
13595set finitel d_finitel
13596eval $inlibc
13597
13598: see if flock exists
13599set flock d_flock
13600eval $inlibc
13601
13602: see if prototype for flock is available
13603echo " "
13604set d_flockproto flock $i_sysfile sys/file.h
13605eval $hasproto
13606
13607: see if fp_class exists
13608set fp_class d_fp_class
13609eval $inlibc
13610
13611: see if pathconf exists
13612set pathconf d_pathconf
13613eval $inlibc
13614
13615: see if fpathconf exists
13616set fpathconf d_fpathconf
13617eval $inlibc
13618
13619: see if fpclass exists
13620set fpclass d_fpclass
13621eval $inlibc
13622
13623: see if fpclassify exists
13624set fpclassify d_fpclassify
13625eval $inlibc
13626
13627: see if fpclassl exists
13628set fpclassl d_fpclassl
13629eval $inlibc
13630
13631: check for fpos64_t
13632echo " "
13633echo "Checking to see if you have fpos64_t..." >&4
13634$cat >try.c <<EOCP
13635#include <stdio.h>
13636int main() { fpos64_t x = 7; }
13637EOCP
13638set try
13639if eval $compile; then
13640	val="$define"
13641	echo "You have fpos64_t."
13642else
13643	val="$undef"
13644	echo "You do not have fpos64_t."
13645	case "$fpossize" in
13646	8) echo "(Your fpos_t is 64 bits, so you could use that.)" ;;
13647	esac
13648fi
13649$rm_try
13650set d_fpos64_t
13651eval $setvar
13652
13653: see if frexpl exists
13654set frexpl d_frexpl
13655eval $inlibc
13656
13657: see if this is a sys/param system
13658set sys/param.h i_sysparam
13659eval $inhdr
13660
13661: see if this is a sys/mount.h system
13662set sys/mount.h i_sysmount
13663eval $inhdr
13664
13665: Check for fs_data_s
13666echo " "
13667echo "Checking to see if your system supports struct fs_data..." >&4
13668set d_fs_data_s fs_data $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h
13669eval $hasstruct
13670case "$d_fs_data_s" in
13671"$define")      echo "Yes, it does."   ;;
13672*)              echo "No, it doesn't." ;;
13673esac
13674
13675: see if fseeko exists
13676set fseeko d_fseeko
13677eval $inlibc
13678case "$longsize" in
136798) echo "(Your long is 64 bits, so you could use fseek.)" ;;
13680esac
13681
13682: see if fsetpos exists
13683set fsetpos d_fsetpos
13684eval $inlibc
13685
13686: see if fstatfs exists
13687set fstatfs d_fstatfs
13688eval $inlibc
13689
13690: see if statvfs exists
13691set statvfs d_statvfs
13692eval $inlibc
13693
13694: see if fstatvfs exists
13695set fstatvfs d_fstatvfs
13696eval $inlibc
13697
13698
13699: see if fsync exists
13700set fsync d_fsync
13701eval $inlibc
13702
13703: see if ftello exists
13704set ftello d_ftello
13705eval $inlibc
13706case "$longsize" in
137078) echo "(Your long is 64 bits, so you could use ftell.)" ;;
13708esac
13709
13710: check for a working futimes
13711d_futimes="$undef"
13712echo " "
13713echo "Checking if you have a working futimes()" >&4
13714$cat >try.c <<EOCP
13715#include <stdio.h>
13716#include <sys/time.h>
13717#include <errno.h>
13718#include <fcntl.h>
13719
13720int main ()
13721{
13722    int fd, rv;
13723    fd = open ("try.c", O_RDWR);
13724    if (-1 == fd) exit (1);
13725    rv = futimes (fd, NULL);
13726    exit (rv == -1 ? errno : 0);
13727}
13728EOCP
13729set try
13730if eval $compile; then
13731    `$run ./try`
13732    rc=$?
13733    case "$rc" in
13734	0)  echo "Yes, you have" >&4
13735	    d_futimes="$define"
13736	    ;;
13737	*)  echo "No, you have futimes, but it isn't working ($rc) (probably harmless)" >&4
13738	    ;;
13739    esac
13740else
13741    echo "No, it does not (probably harmless)" >&4
13742fi
13743$rm_try
13744
13745: see if ndbm.h is available
13746set ndbm.h i_ndbm
13747eval $inhdr
13748: Compatibility location for RedHat 7.1
13749set gdbm/ndbm.h i_gdbmndbm
13750eval $inhdr
13751: Compatibility location for Debian 4.0
13752set gdbm-ndbm.h i_gdbm_ndbm
13753eval $inhdr
13754
13755val="$undef"
13756if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then
13757	: see if dbm_open exists
13758	set dbm_open d_dbm_open
13759	eval $inlibc
13760	case "$d_dbm_open" in
13761	$undef)
13762		i_ndbm="$undef"
13763		i_gdbmndbm="$undef"
13764		i_gdbm_ndbm="$undef"
13765		echo "We won't be including <ndbm.h>"
13766		val="$undef"
13767		;;
13768	*) val="$define"
13769	   ;;
13770	esac
13771fi
13772set d_ndbm
13773eval $setvar
13774
13775ndbm_hdr_protochk='name=$1; hdr=$2;
13776eval "ihdr=\$""i_$name";
13777val="$undef";
13778if $test "$ihdr" = "$define"; then
13779	$echo "Checking if your <$hdr> uses prototypes..." >&4;
13780	case "$d_cplusplus" in
13781	$define) ./protochk "$extern_C void dbm_close(DBM *);" literal "extern \"C\" {" $ihdr $hdr literal "}" && val="$define" ;;
13782	*) ./protochk "$extern_C void dbm_close(int, int);" $ihdr $hdr || val="$define" ;;
13783	esac;
13784	case "$val" in
13785	$define) $echo "Your <$hdr> seems to have prototypes";;
13786	*) $echo "Your <$hdr> does not seem to have prototypes";;
13787	esac;
13788fi;
13789set "d_${name}_h_uses_prototypes";
13790eval $setvar'
13791
13792set ndbm ndbm.h
13793eval $ndbm_hdr_protochk
13794set gdbmndbm gdbm/ndbm.h
13795eval $ndbm_hdr_protochk
13796set gdbm_ndbm gdbm-ndbm.h
13797eval $ndbm_hdr_protochk
13798
13799: see if getaddrinfo exists
13800set getaddrinfo d_getaddrinfo
13801eval $inlibc
13802
13803: see if getcwd exists
13804set getcwd d_getcwd
13805eval $inlibc
13806
13807: see if getespwnam exists
13808set getespwnam d_getespwnam
13809eval $inlibc
13810
13811: see if getfsstat exists
13812set getfsstat d_getfsstat
13813eval $inlibc
13814
13815: see if getgrent exists
13816set getgrent d_getgrent
13817eval $inlibc
13818
13819: see if getgrent_r exists
13820set getgrent_r d_getgrent_r
13821eval $inlibc
13822case "$d_getgrent_r" in
13823"$define")
13824	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
13825	case "$d_getgrent_r_proto:$usethreads" in
13826	":define")	d_getgrent_r_proto=define
13827		set d_getgrent_r_proto getgrent_r $hdrs
13828		eval $hasproto ;;
13829	*)	;;
13830	esac
13831	case "$d_getgrent_r_proto" in
13832	define)
13833	case "$getgrent_r_proto" in
13834	''|0) try='int getgrent_r(struct group*, char*, size_t, struct group**);'
13835	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBWR ;;
13836	esac
13837	case "$getgrent_r_proto" in
13838	''|0) try='int getgrent_r(struct group*, char*, int, struct group**);'
13839	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIR ;;
13840	esac
13841	case "$getgrent_r_proto" in
13842	''|0) try='struct group* getgrent_r(struct group*, char*, size_t);'
13843	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBW ;;
13844	esac
13845	case "$getgrent_r_proto" in
13846	''|0) try='struct group* getgrent_r(struct group*, char*, int);'
13847	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBI ;;
13848	esac
13849	case "$getgrent_r_proto" in
13850	''|0) try='int getgrent_r(struct group*, char*, int);'
13851	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBI ;;
13852	esac
13853	case "$getgrent_r_proto" in
13854	''|0) try='int getgrent_r(struct group*, char*, int, FILE**);'
13855	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIH ;;
13856	esac
13857	case "$getgrent_r_proto" in
13858	''|0)	d_getgrent_r=undef
13859 	        getgrent_r_proto=0
13860		echo "Disabling getgrent_r, cannot determine prototype." >&4 ;;
13861	* )	case "$getgrent_r_proto" in
13862		REENTRANT_PROTO*) ;;
13863		*) getgrent_r_proto="REENTRANT_PROTO_$getgrent_r_proto" ;;
13864		esac
13865		echo "Prototype: $try" ;;
13866	esac
13867	;;
13868	*)	case "$usethreads" in
13869		define) echo "getgrent_r has no prototype, not using it." >&4 ;;
13870		esac
13871		d_getgrent_r=undef
13872		getgrent_r_proto=0
13873		;;
13874	esac
13875	;;
13876*)	getgrent_r_proto=0
13877	;;
13878esac
13879
13880: see if getgrgid_r exists
13881set getgrgid_r d_getgrgid_r
13882eval $inlibc
13883case "$d_getgrgid_r" in
13884"$define")
13885	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
13886	case "$d_getgrgid_r_proto:$usethreads" in
13887	":define")	d_getgrgid_r_proto=define
13888		set d_getgrgid_r_proto getgrgid_r $hdrs
13889		eval $hasproto ;;
13890	*)	;;
13891	esac
13892	case "$d_getgrgid_r_proto" in
13893	define)
13894	case "$getgrgid_r_proto" in
13895	''|0) try='int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**);'
13896	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
13897	esac
13898	case "$getgrgid_r_proto" in
13899	''|0) try='int getgrgid_r(gid_t, struct group*, char*, int, struct group**);'
13900	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
13901	esac
13902	case "$getgrgid_r_proto" in
13903	''|0) try='int getgrgid_r(gid_t, struct group*, char*, int);'
13904	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
13905	esac
13906	case "$getgrgid_r_proto" in
13907	''|0) try='struct group* getgrgid_r(gid_t, struct group*, char*, int);'
13908	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
13909	esac
13910	case "$getgrgid_r_proto" in
13911	''|0)	d_getgrgid_r=undef
13912 	        getgrgid_r_proto=0
13913		echo "Disabling getgrgid_r, cannot determine prototype." >&4 ;;
13914	* )	case "$getgrgid_r_proto" in
13915		REENTRANT_PROTO*) ;;
13916		*) getgrgid_r_proto="REENTRANT_PROTO_$getgrgid_r_proto" ;;
13917		esac
13918		echo "Prototype: $try" ;;
13919	esac
13920	;;
13921	*)	case "$usethreads" in
13922		define) echo "getgrgid_r has no prototype, not using it." >&4 ;;
13923		esac
13924		d_getgrgid_r=undef
13925		getgrgid_r_proto=0
13926		;;
13927	esac
13928	;;
13929*)	getgrgid_r_proto=0
13930	;;
13931esac
13932
13933: see if getgrnam_r exists
13934set getgrnam_r d_getgrnam_r
13935eval $inlibc
13936case "$d_getgrnam_r" in
13937"$define")
13938	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
13939	case "$d_getgrnam_r_proto:$usethreads" in
13940	":define")	d_getgrnam_r_proto=define
13941		set d_getgrnam_r_proto getgrnam_r $hdrs
13942		eval $hasproto ;;
13943	*)	;;
13944	esac
13945	case "$d_getgrnam_r_proto" in
13946	define)
13947	case "$getgrnam_r_proto" in
13948	''|0) try='int getgrnam_r(const char*, struct group*, char*, size_t, struct group**);'
13949	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
13950	esac
13951	case "$getgrnam_r_proto" in
13952	''|0) try='int getgrnam_r(const char*, struct group*, char*, int, struct group**);'
13953	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
13954	esac
13955	case "$getgrnam_r_proto" in
13956	''|0) try='struct group* getgrnam_r(const char*, char*, int);'
13957	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CBI ;;
13958	esac
13959	case "$getgrnam_r_proto" in
13960	''|0) try='int getgrnam_r(const char*, struct group*, char*, int);'
13961	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
13962	esac
13963	case "$getgrnam_r_proto" in
13964	''|0) try='struct group* getgrnam_r(const char*, struct group*, char*, int);'
13965	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
13966	esac
13967	case "$getgrnam_r_proto" in
13968	''|0)	d_getgrnam_r=undef
13969 	        getgrnam_r_proto=0
13970		echo "Disabling getgrnam_r, cannot determine prototype." >&4 ;;
13971	* )	case "$getgrnam_r_proto" in
13972		REENTRANT_PROTO*) ;;
13973		*) getgrnam_r_proto="REENTRANT_PROTO_$getgrnam_r_proto" ;;
13974		esac
13975		echo "Prototype: $try" ;;
13976	esac
13977	;;
13978	*)	case "$usethreads" in
13979		define) echo "getgrnam_r has no prototype, not using it." >&4 ;;
13980		esac
13981		d_getgrnam_r=undef
13982		getgrnam_r_proto=0
13983		;;
13984	esac
13985	;;
13986*)	getgrnam_r_proto=0
13987	;;
13988esac
13989
13990: see if gethostbyaddr exists
13991set gethostbyaddr d_gethbyaddr
13992eval $inlibc
13993
13994: see if gethostbyname exists
13995set gethostbyname d_gethbyname
13996eval $inlibc
13997
13998: see if gethostent exists
13999set gethostent d_gethent
14000eval $inlibc
14001
14002: see how we will look up host name
14003echo " "
14004call=''
14005if set gethostname val -f d_gethname; eval $csym; $val; then
14006	echo 'gethostname() found.' >&4
14007	d_gethname="$define"
14008	call=gethostname
14009fi
14010if set uname val -f d_uname; eval $csym; $val; then
14011	if ./xenix; then
14012		$cat <<'EOM'
14013uname() was found, but you're running xenix, and older versions of xenix
14014have a broken uname(). If you don't really know whether your xenix is old
14015enough to have a broken system call, use the default answer.
14016
14017EOM
14018		dflt=y
14019		case "$d_uname" in
14020		"$define") dflt=n;;
14021		esac
14022		rp='Is your uname() broken?'
14023		. ./myread
14024		case "$ans" in
14025		n*) d_uname="$define"; call=uname;;
14026		esac
14027	else
14028		echo 'uname() found.' >&4
14029		d_uname="$define"
14030		case "$call" in
14031		'') call=uname ;;
14032		esac
14033	fi
14034fi
14035case "$d_gethname" in
14036'') d_gethname="$undef";;
14037esac
14038case "$d_uname" in
14039'') d_uname="$undef";;
14040esac
14041case "$d_uname$d_gethname" in
14042*define*)
14043	dflt=n
14044	cat <<EOM
14045
14046Every now and then someone has a $call() that lies about the hostname
14047but can't be fixed for political or economic reasons.  If you wish, I can
14048pretend $call() isn't there and maybe compute hostname at run-time
14049thanks to the '$phostname' command.
14050
14051EOM
14052	rp="Shall I ignore $call() from now on?"
14053	. ./myread
14054	case "$ans" in
14055	y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
14056	esac;;
14057esac
14058case "$phostname" in
14059'') aphostname='';;
14060*) case "$aphostname" in
14061	/*) ;;
14062	*) set X $phostname
14063		shift
14064		file=$1
14065		shift
14066		file=`./loc $file $file $pth`
14067		aphostname=`echo $file $*`
14068		;;
14069	esac
14070	;;
14071esac
14072case "$d_uname$d_gethname" in
14073*define*) ;;
14074*)
14075	case "$phostname" in
14076	'')
14077		echo "There will be no way for $package to get your hostname." >&4;;
14078	*)
14079	echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
14080		;;
14081	esac;;
14082esac
14083case "$d_phostname" in
14084'') d_phostname="$undef";;
14085esac
14086
14087: see if gethostbyaddr_r exists
14088set gethostbyaddr_r d_gethostbyaddr_r
14089eval $inlibc
14090case "$d_gethostbyaddr_r" in
14091"$define")
14092	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14093	case "$d_gethostbyaddr_r_proto:$usethreads" in
14094	":define")	d_gethostbyaddr_r_proto=define
14095		set d_gethostbyaddr_r_proto gethostbyaddr_r $hdrs
14096		eval $hasproto ;;
14097	*)	;;
14098	esac
14099	case "$d_gethostbyaddr_r_proto" in
14100	define)
14101	case "$gethostbyaddr_r_proto" in
14102	''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
14103	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
14104	esac
14105	case "$gethostbyaddr_r_proto" in
14106	''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, int, int*);'
14107	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
14108	esac
14109	case "$gethostbyaddr_r_proto" in
14110	''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, int, int*);'
14111	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
14112	esac
14113	case "$gethostbyaddr_r_proto" in
14114	''|0) try='struct hostent* gethostbyaddr_r(const void*, size_t, int, struct hostent*, char*, int, int*);'
14115	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
14116	esac
14117	case "$gethostbyaddr_r_proto" in
14118	''|0) try='struct hostent* gethostbyaddr_r(const char*, int, int, struct hostent*, char*, int, int*);'
14119	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
14120	esac
14121	case "$gethostbyaddr_r_proto" in
14122	''|0) try='struct hostent* gethostbyaddr_r(const char*, struct hostent*, char*, int, int*);'
14123	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
14124	esac
14125	case "$gethostbyaddr_r_proto" in
14126	''|0) try='struct hostent* gethostbyaddr_r(const void*, struct hostent*, char*, int, int*);'
14127	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
14128	esac
14129	case "$gethostbyaddr_r_proto" in
14130	''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, struct hostent_data*);'
14131	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
14132	esac
14133	case "$gethostbyaddr_r_proto" in
14134	''|0) try='int gethostbyaddr_r(const char*, int, int, struct hostent*, struct hostent_data*);'
14135	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
14136	esac
14137	case "$gethostbyaddr_r_proto" in
14138	''|0) try='int gethostbyaddr_r(const char*, int, int);'
14139	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
14140	esac
14141	case "$gethostbyaddr_r_proto" in
14142	''|0) try='int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
14143	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
14144	esac
14145	case "$gethostbyaddr_r_proto" in
14146	''|0)	d_gethostbyaddr_r=undef
14147 	        gethostbyaddr_r_proto=0
14148		echo "Disabling gethostbyaddr_r, cannot determine prototype." >&4 ;;
14149	* )	case "$gethostbyaddr_r_proto" in
14150		REENTRANT_PROTO*) ;;
14151		*) gethostbyaddr_r_proto="REENTRANT_PROTO_$gethostbyaddr_r_proto" ;;
14152		esac
14153		echo "Prototype: $try" ;;
14154	esac
14155	;;
14156	*)	case "$usethreads" in
14157		define) echo "gethostbyaddr_r has no prototype, not using it." >&4 ;;
14158		esac
14159		d_gethostbyaddr_r=undef
14160		gethostbyaddr_r_proto=0
14161		;;
14162	esac
14163	;;
14164*)	gethostbyaddr_r_proto=0
14165	;;
14166esac
14167
14168: see if gethostbyname_r exists
14169set gethostbyname_r d_gethostbyname_r
14170eval $inlibc
14171case "$d_gethostbyname_r" in
14172"$define")
14173	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14174	case "$d_gethostbyname_r_proto:$usethreads" in
14175	":define")	d_gethostbyname_r_proto=define
14176		set d_gethostbyname_r_proto gethostbyname_r $hdrs
14177		eval $hasproto ;;
14178	*)	;;
14179	esac
14180	case "$d_gethostbyname_r_proto" in
14181	define)
14182	case "$gethostbyname_r_proto" in
14183	''|0) try='int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);'
14184	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
14185	esac
14186	case "$gethostbyname_r_proto" in
14187	''|0) try='struct hostent* gethostbyname_r(const char*, struct hostent*, char*, int, int*);'
14188	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
14189	esac
14190	case "$gethostbyname_r_proto" in
14191	''|0) try='int gethostbyname_r(const char*, struct hostent*, struct hostent_data*);'
14192	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
14193	esac
14194	case "$gethostbyname_r_proto" in
14195	''|0)	d_gethostbyname_r=undef
14196 	        gethostbyname_r_proto=0
14197		echo "Disabling gethostbyname_r, cannot determine prototype." >&4 ;;
14198	* )	case "$gethostbyname_r_proto" in
14199		REENTRANT_PROTO*) ;;
14200		*) gethostbyname_r_proto="REENTRANT_PROTO_$gethostbyname_r_proto" ;;
14201		esac
14202		echo "Prototype: $try" ;;
14203	esac
14204	;;
14205	*)	case "$usethreads" in
14206		define) echo "gethostbyname_r has no prototype, not using it." >&4 ;;
14207		esac
14208		d_gethostbyname_r=undef
14209		gethostbyname_r_proto=0
14210		;;
14211	esac
14212	;;
14213*)	gethostbyname_r_proto=0
14214	;;
14215esac
14216
14217: see if gethostent_r exists
14218set gethostent_r d_gethostent_r
14219eval $inlibc
14220case "$d_gethostent_r" in
14221"$define")
14222	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14223	case "$d_gethostent_r_proto:$usethreads" in
14224	":define")	d_gethostent_r_proto=define
14225		set d_gethostent_r_proto gethostent_r $hdrs
14226		eval $hasproto ;;
14227	*)	;;
14228	esac
14229	case "$d_gethostent_r_proto" in
14230	define)
14231	case "$gethostent_r_proto" in
14232	''|0) try='int gethostent_r(struct hostent*, char*, size_t, struct hostent**, int*);'
14233	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
14234	esac
14235	case "$gethostent_r_proto" in
14236	''|0) try='int gethostent_r(struct hostent*, char*, int, int*);'
14237	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBIE ;;
14238	esac
14239	case "$gethostent_r_proto" in
14240	''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int, int*);'
14241	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBIE ;;
14242	esac
14243	case "$gethostent_r_proto" in
14244	''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int);'
14245	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBI ;;
14246	esac
14247	case "$gethostent_r_proto" in
14248	''|0) try='int gethostent_r(struct hostent*, char*, int);'
14249	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBI ;;
14250	esac
14251	case "$gethostent_r_proto" in
14252	''|0) try='int gethostent_r(struct hostent*, struct hostent_data*);'
14253	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SD ;;
14254	esac
14255	case "$gethostent_r_proto" in
14256	''|0)	d_gethostent_r=undef
14257 	        gethostent_r_proto=0
14258		echo "Disabling gethostent_r, cannot determine prototype." >&4 ;;
14259	* )	case "$gethostent_r_proto" in
14260		REENTRANT_PROTO*) ;;
14261		*) gethostent_r_proto="REENTRANT_PROTO_$gethostent_r_proto" ;;
14262		esac
14263		echo "Prototype: $try" ;;
14264	esac
14265	;;
14266	*)	case "$usethreads" in
14267		define) echo "gethostent_r has no prototype, not using it." >&4 ;;
14268		esac
14269		d_gethostent_r=undef
14270		gethostent_r_proto=0
14271		;;
14272	esac
14273	;;
14274*)	gethostent_r_proto=0
14275	;;
14276esac
14277
14278: see if prototypes for various gethostxxx netdb.h functions are available
14279echo " "
14280set d_gethostprotos gethostent $i_netdb netdb.h
14281eval $hasproto
14282
14283: see if getitimer exists
14284set getitimer d_getitimer
14285eval $inlibc
14286
14287: see if getlogin exists
14288set getlogin d_getlogin
14289eval $inlibc
14290
14291: see if getlogin_r exists
14292set getlogin_r d_getlogin_r
14293eval $inlibc
14294case "$d_getlogin_r" in
14295"$define")
14296	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
14297	case "$d_getlogin_r_proto:$usethreads" in
14298	":define")	d_getlogin_r_proto=define
14299		set d_getlogin_r_proto getlogin_r $hdrs
14300		eval $hasproto ;;
14301	*)	;;
14302	esac
14303	case "$d_getlogin_r_proto" in
14304	define)
14305	case "$getlogin_r_proto" in
14306	''|0) try='int getlogin_r(char*, size_t);'
14307	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BW ;;
14308	esac
14309	case "$getlogin_r_proto" in
14310	''|0) try='int getlogin_r(char*, int);'
14311	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BI ;;
14312	esac
14313	case "$getlogin_r_proto" in
14314	''|0) try='char* getlogin_r(char*, size_t);'
14315	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BW ;;
14316	esac
14317	case "$getlogin_r_proto" in
14318	''|0) try='char* getlogin_r(char*, int);'
14319	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BI ;;
14320	esac
14321	case "$getlogin_r_proto" in
14322	''|0)	d_getlogin_r=undef
14323 	        getlogin_r_proto=0
14324		echo "Disabling getlogin_r, cannot determine prototype." >&4 ;;
14325	* )	case "$getlogin_r_proto" in
14326		REENTRANT_PROTO*) ;;
14327		*) getlogin_r_proto="REENTRANT_PROTO_$getlogin_r_proto" ;;
14328		esac
14329		echo "Prototype: $try" ;;
14330	esac
14331	;;
14332	*)	case "$usethreads" in
14333		define) echo "getlogin_r has no prototype, not using it." >&4 ;;
14334		esac
14335		d_getlogin_r=undef
14336		getlogin_r_proto=0
14337		;;
14338	esac
14339	;;
14340*)	getlogin_r_proto=0
14341	;;
14342esac
14343
14344: see if getmnt exists
14345set getmnt d_getmnt
14346eval $inlibc
14347
14348: see if getmntent exists
14349set getmntent d_getmntent
14350eval $inlibc
14351
14352: see if getnameinfo exists
14353set getnameinfo d_getnameinfo
14354eval $inlibc
14355
14356: see if getnetbyaddr exists
14357set getnetbyaddr d_getnbyaddr
14358eval $inlibc
14359
14360: see if getnetbyname exists
14361set getnetbyname d_getnbyname
14362eval $inlibc
14363
14364: see if getnetent exists
14365set getnetent d_getnent
14366eval $inlibc
14367
14368: see if getnetbyaddr_r exists
14369set getnetbyaddr_r d_getnetbyaddr_r
14370eval $inlibc
14371case "$d_getnetbyaddr_r" in
14372"$define")
14373	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14374	case "$d_getnetbyaddr_r_proto:$usethreads" in
14375	":define")	d_getnetbyaddr_r_proto=define
14376		set d_getnetbyaddr_r_proto getnetbyaddr_r $hdrs
14377		eval $hasproto ;;
14378	*)	;;
14379	esac
14380	case "$d_getnetbyaddr_r_proto" in
14381	define)
14382	case "$getnetbyaddr_r_proto" in
14383	''|0) try='int getnetbyaddr_r(unsigned long, int, struct netent*, char*, size_t, struct netent**, int*);'
14384	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
14385	esac
14386	case "$getnetbyaddr_r_proto" in
14387	''|0) try='int getnetbyaddr_r(long, int, struct netent*, char*, int);'
14388	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
14389	esac
14390	case "$getnetbyaddr_r_proto" in
14391	''|0) try='struct netent* getnetbyaddr_r(in_addr_t, int, struct netent*, char*, int);'
14392	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
14393	esac
14394	case "$getnetbyaddr_r_proto" in
14395	''|0) try='struct netent* getnetbyaddr_r(long, int, struct netent*, char*, int);'
14396	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
14397	esac
14398	case "$getnetbyaddr_r_proto" in
14399	''|0) try='int getnetbyaddr_r(in_addr_t, int, struct netent*, struct netent_data*);'
14400	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
14401	esac
14402	case "$getnetbyaddr_r_proto" in
14403	''|0) try='int getnetbyaddr_r(long, int, struct netent*, struct netent_data*);'
14404	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
14405	esac
14406	case "$getnetbyaddr_r_proto" in
14407	''|0) try='int getnetbyaddr_r(int, int, struct netent*, struct netent_data*);'
14408	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
14409	esac
14410	case "$getnetbyaddr_r_proto" in
14411	''|0) try='int getnetbyaddr_r(uint32_t, int, struct netent*, char*, size_t, struct netent**, int*);'
14412	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
14413	esac
14414	case "$getnetbyaddr_r_proto" in
14415	''|0)	d_getnetbyaddr_r=undef
14416 	        getnetbyaddr_r_proto=0
14417		echo "Disabling getnetbyaddr_r, cannot determine prototype." >&4 ;;
14418	* )	case "$getnetbyaddr_r_proto" in
14419		REENTRANT_PROTO*) ;;
14420		*) getnetbyaddr_r_proto="REENTRANT_PROTO_$getnetbyaddr_r_proto" ;;
14421		esac
14422		echo "Prototype: $try" ;;
14423	esac
14424	;;
14425	*)	case "$usethreads" in
14426		define) echo "getnetbyaddr_r has no prototype, not using it." >&4 ;;
14427		esac
14428		d_getnetbyaddr_r=undef
14429		getnetbyaddr_r_proto=0
14430		;;
14431	esac
14432	;;
14433*)	getnetbyaddr_r_proto=0
14434	;;
14435esac
14436
14437: see if getnetbyname_r exists
14438set getnetbyname_r d_getnetbyname_r
14439eval $inlibc
14440case "$d_getnetbyname_r" in
14441"$define")
14442	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14443	case "$d_getnetbyname_r_proto:$usethreads" in
14444	":define")	d_getnetbyname_r_proto=define
14445		set d_getnetbyname_r_proto getnetbyname_r $hdrs
14446		eval $hasproto ;;
14447	*)	;;
14448	esac
14449	case "$d_getnetbyname_r_proto" in
14450	define)
14451	case "$getnetbyname_r_proto" in
14452	''|0) try='int getnetbyname_r(const char*, struct netent*, char*, size_t, struct netent**, int*);'
14453	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
14454	esac
14455	case "$getnetbyname_r_proto" in
14456	''|0) try='int getnetbyname_r(const char*, struct netent*, char*, int);'
14457	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
14458	esac
14459	case "$getnetbyname_r_proto" in
14460	''|0) try='struct netent* getnetbyname_r(const char*, struct netent*, char*, int);'
14461	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
14462	esac
14463	case "$getnetbyname_r_proto" in
14464	''|0) try='int getnetbyname_r(const char*, struct netent*, struct netent_data*);'
14465	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
14466	esac
14467	case "$getnetbyname_r_proto" in
14468	''|0)	d_getnetbyname_r=undef
14469 	        getnetbyname_r_proto=0
14470		echo "Disabling getnetbyname_r, cannot determine prototype." >&4 ;;
14471	* )	case "$getnetbyname_r_proto" in
14472		REENTRANT_PROTO*) ;;
14473		*) getnetbyname_r_proto="REENTRANT_PROTO_$getnetbyname_r_proto" ;;
14474		esac
14475		echo "Prototype: $try" ;;
14476	esac
14477	;;
14478	*)	case "$usethreads" in
14479		define) echo "getnetbyname_r has no prototype, not using it." >&4 ;;
14480		esac
14481		d_getnetbyname_r=undef
14482		getnetbyname_r_proto=0
14483		;;
14484	esac
14485	;;
14486*)	getnetbyname_r_proto=0
14487	;;
14488esac
14489
14490: see if getnetent_r exists
14491set getnetent_r d_getnetent_r
14492eval $inlibc
14493case "$d_getnetent_r" in
14494"$define")
14495	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14496	case "$d_getnetent_r_proto:$usethreads" in
14497	":define")	d_getnetent_r_proto=define
14498		set d_getnetent_r_proto getnetent_r $hdrs
14499		eval $hasproto ;;
14500	*)	;;
14501	esac
14502	case "$d_getnetent_r_proto" in
14503	define)
14504	case "$getnetent_r_proto" in
14505	''|0) try='int getnetent_r(struct netent*, char*, size_t, struct netent**, int*);'
14506	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
14507	esac
14508	case "$getnetent_r_proto" in
14509	''|0) try='int getnetent_r(struct netent*, char*, int, int*);'
14510	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBIE ;;
14511	esac
14512	case "$getnetent_r_proto" in
14513	''|0) try='struct netent* getnetent_r(struct netent*, char*, int, int*);'
14514	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBIE ;;
14515	esac
14516	case "$getnetent_r_proto" in
14517	''|0) try='struct netent* getnetent_r(struct netent*, char*, int);'
14518	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBI ;;
14519	esac
14520	case "$getnetent_r_proto" in
14521	''|0) try='int getnetent_r(struct netent*, char*, int);'
14522	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBI ;;
14523	esac
14524	case "$getnetent_r_proto" in
14525	''|0) try='int getnetent_r(struct netent*, struct netent_data*);'
14526	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SD ;;
14527	esac
14528	case "$getnetent_r_proto" in
14529	''|0)	d_getnetent_r=undef
14530 	        getnetent_r_proto=0
14531		echo "Disabling getnetent_r, cannot determine prototype." >&4 ;;
14532	* )	case "$getnetent_r_proto" in
14533		REENTRANT_PROTO*) ;;
14534		*) getnetent_r_proto="REENTRANT_PROTO_$getnetent_r_proto" ;;
14535		esac
14536		echo "Prototype: $try" ;;
14537	esac
14538	;;
14539	*)	case "$usethreads" in
14540		define) echo "getnetent_r has no prototype, not using it." >&4 ;;
14541		esac
14542		d_getnetent_r=undef
14543		getnetent_r_proto=0
14544		;;
14545	esac
14546	;;
14547*)	getnetent_r_proto=0
14548	;;
14549esac
14550
14551: see if prototypes for various getnetxxx netdb.h functions are available
14552echo " "
14553set d_getnetprotos getnetent $i_netdb netdb.h
14554eval $hasproto
14555
14556: see if getpagesize exists
14557set getpagesize d_getpagsz
14558eval $inlibc
14559
14560: Optional checks for getprotobyname and getprotobynumber
14561
14562: see if getprotobyname exists
14563set getprotobyname d_getpbyname
14564eval $inlibc
14565
14566: see if getprotobynumber exists
14567set getprotobynumber d_getpbynumber
14568eval $inlibc
14569
14570: see if getprotoent exists
14571set getprotoent d_getpent
14572eval $inlibc
14573
14574: see if getpgid exists
14575set getpgid d_getpgid
14576eval $inlibc
14577
14578: see if getpgrp2 exists
14579set getpgrp2 d_getpgrp2
14580eval $inlibc
14581
14582: see if getppid exists
14583set getppid d_getppid
14584eval $inlibc
14585
14586: see if getpriority exists
14587set getpriority d_getprior
14588eval $inlibc
14589
14590: see if getprotobyname_r exists
14591set getprotobyname_r d_getprotobyname_r
14592eval $inlibc
14593case "$d_getprotobyname_r" in
14594"$define")
14595	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14596	case "$d_getprotobyname_r_proto:$usethreads" in
14597	":define")	d_getprotobyname_r_proto=define
14598		set d_getprotobyname_r_proto getprotobyname_r $hdrs
14599		eval $hasproto ;;
14600	*)	;;
14601	esac
14602	case "$d_getprotobyname_r_proto" in
14603	define)
14604	case "$getprotobyname_r_proto" in
14605	''|0) try='int getprotobyname_r(const char*, struct protoent*, char*, size_t, struct protoent**);'
14606	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
14607	esac
14608	case "$getprotobyname_r_proto" in
14609	''|0) try='struct protoent* getprotobyname_r(const char*, struct protoent*, char*, int);'
14610	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
14611	esac
14612	case "$getprotobyname_r_proto" in
14613	''|0) try='int getprotobyname_r(const char*, struct protoent*, struct protoent_data*);'
14614	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
14615	esac
14616	case "$getprotobyname_r_proto" in
14617	''|0)	d_getprotobyname_r=undef
14618 	        getprotobyname_r_proto=0
14619		echo "Disabling getprotobyname_r, cannot determine prototype." >&4 ;;
14620	* )	case "$getprotobyname_r_proto" in
14621		REENTRANT_PROTO*) ;;
14622		*) getprotobyname_r_proto="REENTRANT_PROTO_$getprotobyname_r_proto" ;;
14623		esac
14624		echo "Prototype: $try" ;;
14625	esac
14626	;;
14627	*)	case "$usethreads" in
14628		define) echo "getprotobyname_r has no prototype, not using it." >&4 ;;
14629		esac
14630		d_getprotobyname_r=undef
14631		getprotobyname_r_proto=0
14632		;;
14633	esac
14634	;;
14635*)	getprotobyname_r_proto=0
14636	;;
14637esac
14638
14639: see if getprotobynumber_r exists
14640set getprotobynumber_r d_getprotobynumber_r
14641eval $inlibc
14642case "$d_getprotobynumber_r" in
14643"$define")
14644	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14645	case "$d_getprotobynumber_r_proto:$usethreads" in
14646	":define")	d_getprotobynumber_r_proto=define
14647		set d_getprotobynumber_r_proto getprotobynumber_r $hdrs
14648		eval $hasproto ;;
14649	*)	;;
14650	esac
14651	case "$d_getprotobynumber_r_proto" in
14652	define)
14653	case "$getprotobynumber_r_proto" in
14654	''|0) try='int getprotobynumber_r(int, struct protoent*, char*, size_t, struct protoent**);'
14655	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
14656	esac
14657	case "$getprotobynumber_r_proto" in
14658	''|0) try='struct protoent* getprotobynumber_r(int, struct protoent*, char*, int);'
14659	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
14660	esac
14661	case "$getprotobynumber_r_proto" in
14662	''|0) try='int getprotobynumber_r(int, struct protoent*, struct protoent_data*);'
14663	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
14664	esac
14665	case "$getprotobynumber_r_proto" in
14666	''|0)	d_getprotobynumber_r=undef
14667 	        getprotobynumber_r_proto=0
14668		echo "Disabling getprotobynumber_r, cannot determine prototype." >&4 ;;
14669	* )	case "$getprotobynumber_r_proto" in
14670		REENTRANT_PROTO*) ;;
14671		*) getprotobynumber_r_proto="REENTRANT_PROTO_$getprotobynumber_r_proto" ;;
14672		esac
14673		echo "Prototype: $try" ;;
14674	esac
14675	;;
14676	*)	case "$usethreads" in
14677		define) echo "getprotobynumber_r has no prototype, not using it." >&4 ;;
14678		esac
14679		d_getprotobynumber_r=undef
14680		getprotobynumber_r_proto=0
14681		;;
14682	esac
14683	;;
14684*)	getprotobynumber_r_proto=0
14685	;;
14686esac
14687
14688: see if getprotoent_r exists
14689set getprotoent_r d_getprotoent_r
14690eval $inlibc
14691case "$d_getprotoent_r" in
14692"$define")
14693	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14694	case "$d_getprotoent_r_proto:$usethreads" in
14695	":define")	d_getprotoent_r_proto=define
14696		set d_getprotoent_r_proto getprotoent_r $hdrs
14697		eval $hasproto ;;
14698	*)	;;
14699	esac
14700	case "$d_getprotoent_r_proto" in
14701	define)
14702	case "$getprotoent_r_proto" in
14703	''|0) try='int getprotoent_r(struct protoent*, char*, size_t, struct protoent**);'
14704	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
14705	esac
14706	case "$getprotoent_r_proto" in
14707	''|0) try='int getprotoent_r(struct protoent*, char*, int);'
14708	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBI ;;
14709	esac
14710	case "$getprotoent_r_proto" in
14711	''|0) try='struct protoent* getprotoent_r(struct protoent*, char*, int);'
14712	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=S_SBI ;;
14713	esac
14714	case "$getprotoent_r_proto" in
14715	''|0) try='int getprotoent_r(struct protoent*, struct protoent_data*);'
14716	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SD ;;
14717	esac
14718	case "$getprotoent_r_proto" in
14719	''|0)	d_getprotoent_r=undef
14720 	        getprotoent_r_proto=0
14721		echo "Disabling getprotoent_r, cannot determine prototype." >&4 ;;
14722	* )	case "$getprotoent_r_proto" in
14723		REENTRANT_PROTO*) ;;
14724		*) getprotoent_r_proto="REENTRANT_PROTO_$getprotoent_r_proto" ;;
14725		esac
14726		echo "Prototype: $try" ;;
14727	esac
14728	;;
14729	*)	case "$usethreads" in
14730		define) echo "getprotoent_r has no prototype, not using it." >&4 ;;
14731		esac
14732		d_getprotoent_r=undef
14733		getprotoent_r_proto=0
14734		;;
14735	esac
14736	;;
14737*)	getprotoent_r_proto=0
14738	;;
14739esac
14740
14741: see if prototypes for various getprotoxxx netdb.h functions are available
14742echo " "
14743set d_getprotoprotos getprotoent $i_netdb netdb.h
14744eval $hasproto
14745
14746: see if getprpwnam exists
14747set getprpwnam d_getprpwnam
14748eval $inlibc
14749
14750: see if getpwent exists
14751set getpwent d_getpwent
14752eval $inlibc
14753
14754: see if getpwent_r exists
14755set getpwent_r d_getpwent_r
14756eval $inlibc
14757case "$d_getpwent_r" in
14758"$define")
14759	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
14760	case "$d_getpwent_r_proto:$usethreads" in
14761	":define")	d_getpwent_r_proto=define
14762		set d_getpwent_r_proto getpwent_r $hdrs
14763		eval $hasproto ;;
14764	*)	;;
14765	esac
14766	case "$d_getpwent_r_proto" in
14767	define)
14768	case "$getpwent_r_proto" in
14769	''|0) try='int getpwent_r(struct passwd*, char*, size_t, struct passwd**);'
14770	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBWR ;;
14771	esac
14772	case "$getpwent_r_proto" in
14773	''|0) try='int getpwent_r(struct passwd*, char*, int, struct passwd**);'
14774	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIR ;;
14775	esac
14776	case "$getpwent_r_proto" in
14777	''|0) try='struct passwd* getpwent_r(struct passwd*, char*, size_t);'
14778	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBW ;;
14779	esac
14780	case "$getpwent_r_proto" in
14781	''|0) try='struct passwd* getpwent_r(struct passwd*, char*, int);'
14782	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBI ;;
14783	esac
14784	case "$getpwent_r_proto" in
14785	''|0) try='int getpwent_r(struct passwd*, char*, int);'
14786	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBI ;;
14787	esac
14788	case "$getpwent_r_proto" in
14789	''|0) try='int getpwent_r(struct passwd*, char*, int, FILE**);'
14790	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIH ;;
14791	esac
14792	case "$getpwent_r_proto" in
14793	''|0)	d_getpwent_r=undef
14794 	        getpwent_r_proto=0
14795		echo "Disabling getpwent_r, cannot determine prototype." >&4 ;;
14796	* )	case "$getpwent_r_proto" in
14797		REENTRANT_PROTO*) ;;
14798		*) getpwent_r_proto="REENTRANT_PROTO_$getpwent_r_proto" ;;
14799		esac
14800		echo "Prototype: $try" ;;
14801	esac
14802	;;
14803	*)	case "$usethreads" in
14804		define) echo "getpwent_r has no prototype, not using it." >&4 ;;
14805		esac
14806		d_getpwent_r=undef
14807		getpwent_r_proto=0
14808		;;
14809	esac
14810	;;
14811*)	getpwent_r_proto=0
14812	;;
14813esac
14814
14815: see if getpwnam_r exists
14816set getpwnam_r d_getpwnam_r
14817eval $inlibc
14818case "$d_getpwnam_r" in
14819"$define")
14820	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
14821	case "$d_getpwnam_r_proto:$usethreads" in
14822	":define")	d_getpwnam_r_proto=define
14823		set d_getpwnam_r_proto getpwnam_r $hdrs
14824		eval $hasproto ;;
14825	*)	;;
14826	esac
14827	case "$d_getpwnam_r_proto" in
14828	define)
14829	case "$getpwnam_r_proto" in
14830	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);'
14831	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
14832	esac
14833	case "$getpwnam_r_proto" in
14834	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int, struct passwd**);'
14835	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
14836	esac
14837	case "$getpwnam_r_proto" in
14838	''|0) try='struct passwd* getpwnam_r(const char*, struct passwd*, char*, int);'
14839	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
14840	esac
14841	case "$getpwnam_r_proto" in
14842	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int);'
14843	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
14844	esac
14845	case "$getpwnam_r_proto" in
14846	''|0)	d_getpwnam_r=undef
14847 	        getpwnam_r_proto=0
14848		echo "Disabling getpwnam_r, cannot determine prototype." >&4 ;;
14849	* )	case "$getpwnam_r_proto" in
14850		REENTRANT_PROTO*) ;;
14851		*) getpwnam_r_proto="REENTRANT_PROTO_$getpwnam_r_proto" ;;
14852		esac
14853		echo "Prototype: $try" ;;
14854	esac
14855	;;
14856	*)	case "$usethreads" in
14857		define) echo "getpwnam_r has no prototype, not using it." >&4 ;;
14858		esac
14859		d_getpwnam_r=undef
14860		getpwnam_r_proto=0
14861		;;
14862	esac
14863	;;
14864*)	getpwnam_r_proto=0
14865	;;
14866esac
14867
14868: see if getpwuid_r exists
14869set getpwuid_r d_getpwuid_r
14870eval $inlibc
14871case "$d_getpwuid_r" in
14872"$define")
14873	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
14874	case "$d_getpwuid_r_proto:$usethreads" in
14875	":define")	d_getpwuid_r_proto=define
14876		set d_getpwuid_r_proto getpwuid_r $hdrs
14877		eval $hasproto ;;
14878	*)	;;
14879	esac
14880	case "$d_getpwuid_r_proto" in
14881	define)
14882	case "$getpwuid_r_proto" in
14883	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);'
14884	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
14885	esac
14886	case "$getpwuid_r_proto" in
14887	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int, struct passwd**);'
14888	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
14889	esac
14890	case "$getpwuid_r_proto" in
14891	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int);'
14892	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
14893	esac
14894	case "$getpwuid_r_proto" in
14895	''|0) try='struct passwd* getpwuid_r(uid_t, struct passwd*, char*, int);'
14896	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
14897	esac
14898	case "$getpwuid_r_proto" in
14899	''|0)	d_getpwuid_r=undef
14900 	        getpwuid_r_proto=0
14901		echo "Disabling getpwuid_r, cannot determine prototype." >&4 ;;
14902	* )	case "$getpwuid_r_proto" in
14903		REENTRANT_PROTO*) ;;
14904		*) getpwuid_r_proto="REENTRANT_PROTO_$getpwuid_r_proto" ;;
14905		esac
14906		echo "Prototype: $try" ;;
14907	esac
14908	;;
14909	*)	case "$usethreads" in
14910		define) echo "getpwuid_r has no prototype, not using it." >&4 ;;
14911		esac
14912		d_getpwuid_r=undef
14913		getpwuid_r_proto=0
14914		;;
14915	esac
14916	;;
14917*)	getpwuid_r_proto=0
14918	;;
14919esac
14920
14921: Optional checks for getsbyname and getsbyport
14922
14923: see if getservbyname exists
14924set getservbyname d_getsbyname
14925eval $inlibc
14926
14927: see if getservbyport exists
14928set getservbyport d_getsbyport
14929eval $inlibc
14930
14931: see if getservent exists
14932set getservent d_getsent
14933eval $inlibc
14934
14935: see if getservbyname_r exists
14936set getservbyname_r d_getservbyname_r
14937eval $inlibc
14938case "$d_getservbyname_r" in
14939"$define")
14940	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14941	case "$d_getservbyname_r_proto:$usethreads" in
14942	":define")	d_getservbyname_r_proto=define
14943		set d_getservbyname_r_proto getservbyname_r $hdrs
14944		eval $hasproto ;;
14945	*)	;;
14946	esac
14947	case "$d_getservbyname_r_proto" in
14948	define)
14949	case "$getservbyname_r_proto" in
14950	''|0) try='int getservbyname_r(const char*, const char*, struct servent*, char*, size_t, struct servent**);'
14951	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
14952	esac
14953	case "$getservbyname_r_proto" in
14954	''|0) try='struct servent* getservbyname_r(const char*, const char*, struct servent*, char*, int);'
14955	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
14956	esac
14957	case "$getservbyname_r_proto" in
14958	''|0) try='int getservbyname_r(const char*, const char*, struct servent*, struct servent_data*);'
14959	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
14960	esac
14961	case "$getservbyname_r_proto" in
14962	''|0)	d_getservbyname_r=undef
14963 	        getservbyname_r_proto=0
14964		echo "Disabling getservbyname_r, cannot determine prototype." >&4 ;;
14965	* )	case "$getservbyname_r_proto" in
14966		REENTRANT_PROTO*) ;;
14967		*) getservbyname_r_proto="REENTRANT_PROTO_$getservbyname_r_proto" ;;
14968		esac
14969		echo "Prototype: $try" ;;
14970	esac
14971	;;
14972	*)	case "$usethreads" in
14973		define) echo "getservbyname_r has no prototype, not using it." >&4 ;;
14974		esac
14975		d_getservbyname_r=undef
14976		getservbyname_r_proto=0
14977		;;
14978	esac
14979	;;
14980*)	getservbyname_r_proto=0
14981	;;
14982esac
14983
14984: see if getservbyport_r exists
14985set getservbyport_r d_getservbyport_r
14986eval $inlibc
14987case "$d_getservbyport_r" in
14988"$define")
14989	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14990	case "$d_getservbyport_r_proto:$usethreads" in
14991	":define")	d_getservbyport_r_proto=define
14992		set d_getservbyport_r_proto getservbyport_r $hdrs
14993		eval $hasproto ;;
14994	*)	;;
14995	esac
14996	case "$d_getservbyport_r_proto" in
14997	define)
14998	case "$getservbyport_r_proto" in
14999	''|0) try='int getservbyport_r(int, const char*, struct servent*, char*, size_t, struct servent**);'
15000	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
15001	esac
15002	case "$getservbyport_r_proto" in
15003	''|0) try='struct servent* getservbyport_r(int, const char*, struct servent*, char*, int);'
15004	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
15005	esac
15006	case "$getservbyport_r_proto" in
15007	''|0) try='int getservbyport_r(int, const char*, struct servent*, struct servent_data*);'
15008	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
15009	esac
15010	case "$getservbyport_r_proto" in
15011	''|0)	d_getservbyport_r=undef
15012 	        getservbyport_r_proto=0
15013		echo "Disabling getservbyport_r, cannot determine prototype." >&4 ;;
15014	* )	case "$getservbyport_r_proto" in
15015		REENTRANT_PROTO*) ;;
15016		*) getservbyport_r_proto="REENTRANT_PROTO_$getservbyport_r_proto" ;;
15017		esac
15018		echo "Prototype: $try" ;;
15019	esac
15020	;;
15021	*)	case "$usethreads" in
15022		define) echo "getservbyport_r has no prototype, not using it." >&4 ;;
15023		esac
15024		d_getservbyport_r=undef
15025		getservbyport_r_proto=0
15026		;;
15027	esac
15028	;;
15029*)	getservbyport_r_proto=0
15030	;;
15031esac
15032
15033: see if getservent_r exists
15034set getservent_r d_getservent_r
15035eval $inlibc
15036case "$d_getservent_r" in
15037"$define")
15038	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15039	case "$d_getservent_r_proto:$usethreads" in
15040	":define")	d_getservent_r_proto=define
15041		set d_getservent_r_proto getservent_r $hdrs
15042		eval $hasproto ;;
15043	*)	;;
15044	esac
15045	case "$d_getservent_r_proto" in
15046	define)
15047	case "$getservent_r_proto" in
15048	''|0) try='int getservent_r(struct servent*, char*, size_t, struct servent**);'
15049	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBWR ;;
15050	esac
15051	case "$getservent_r_proto" in
15052	''|0) try='int getservent_r(struct servent*, char*, int);'
15053	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBI ;;
15054	esac
15055	case "$getservent_r_proto" in
15056	''|0) try='struct servent* getservent_r(struct servent*, char*, int);'
15057	./protochk "$extern_C $try" $hdrs && getservent_r_proto=S_SBI ;;
15058	esac
15059	case "$getservent_r_proto" in
15060	''|0) try='int getservent_r(struct servent*, struct servent_data*);'
15061	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SD ;;
15062	esac
15063	case "$getservent_r_proto" in
15064	''|0)	d_getservent_r=undef
15065 	        getservent_r_proto=0
15066		echo "Disabling getservent_r, cannot determine prototype." >&4 ;;
15067	* )	case "$getservent_r_proto" in
15068		REENTRANT_PROTO*) ;;
15069		*) getservent_r_proto="REENTRANT_PROTO_$getservent_r_proto" ;;
15070		esac
15071		echo "Prototype: $try" ;;
15072	esac
15073	;;
15074	*)	case "$usethreads" in
15075		define) echo "getservent_r has no prototype, not using it." >&4 ;;
15076		esac
15077		d_getservent_r=undef
15078		getservent_r_proto=0
15079		;;
15080	esac
15081	;;
15082*)	getservent_r_proto=0
15083	;;
15084esac
15085
15086: see if prototypes for various getservxxx netdb.h functions are available
15087echo " "
15088set d_getservprotos getservent $i_netdb netdb.h
15089eval $hasproto
15090
15091: see if getspnam exists
15092set getspnam d_getspnam
15093eval $inlibc
15094
15095: see if this is a shadow.h system
15096set shadow.h i_shadow
15097eval $inhdr
15098
15099: see if getspnam_r exists
15100set getspnam_r d_getspnam_r
15101eval $inlibc
15102case "$d_getspnam_r" in
15103"$define")
15104	hdrs="$i_systypes sys/types.h define stdio.h $i_shadow shadow.h"
15105	case "$d_getspnam_r_proto:$usethreads" in
15106	":define")	d_getspnam_r_proto=define
15107		set d_getspnam_r_proto getspnam_r $hdrs
15108		eval $hasproto ;;
15109	*)	;;
15110	esac
15111	case "$d_getspnam_r_proto" in
15112	define)
15113	case "$getspnam_r_proto" in
15114	''|0) try='int getspnam_r(const char*, struct spwd*, char*, size_t, struct spwd**);'
15115	./protochk "$extern_C $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
15116	esac
15117	case "$getspnam_r_proto" in
15118	''|0) try='struct spwd* getspnam_r(const char*, struct spwd*, char*, int);'
15119	./protochk "$extern_C $try" $hdrs && getspnam_r_proto=S_CSBI ;;
15120	esac
15121	case "$getspnam_r_proto" in
15122	''|0)	d_getspnam_r=undef
15123 	        getspnam_r_proto=0
15124		echo "Disabling getspnam_r, cannot determine prototype." >&4 ;;
15125	* )	case "$getspnam_r_proto" in
15126		REENTRANT_PROTO*) ;;
15127		*) getspnam_r_proto="REENTRANT_PROTO_$getspnam_r_proto" ;;
15128		esac
15129		echo "Prototype: $try" ;;
15130	esac
15131	;;
15132	*)	case "$usethreads" in
15133		define) echo "getspnam_r has no prototype, not using it." >&4 ;;
15134		esac
15135		d_getspnam_r=undef
15136		getspnam_r_proto=0
15137		;;
15138	esac
15139	;;
15140*)	getspnam_r_proto=0
15141	;;
15142esac
15143
15144: see if gettimeofday or ftime exists
15145set gettimeofday d_gettimeod
15146eval $inlibc
15147case "$d_gettimeod" in
15148"$undef")
15149	set ftime d_ftime
15150	eval $inlibc
15151	;;
15152*)
15153	val="$undef"; set d_ftime; eval $setvar
15154	;;
15155esac
15156case "$d_gettimeod$d_ftime" in
15157"$undef$undef")
15158	echo " "
15159	echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
15160	;;
15161esac
15162
15163: see if gmtime_r exists
15164set gmtime_r d_gmtime_r
15165eval $inlibc
15166case "$d_gmtime_r" in
15167"$define")
15168	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
15169	case "$d_gmtime_r_proto:$usethreads" in
15170	":define")	d_gmtime_r_proto=define
15171		set d_gmtime_r_proto gmtime_r $hdrs
15172		eval $hasproto ;;
15173	*)	;;
15174	esac
15175	case "$d_gmtime_r_proto" in
15176	define)
15177	case "$gmtime_r_proto" in
15178	''|0) try='struct tm* gmtime_r(const time_t*, struct tm*);'
15179	./protochk "$extern_C $try" $hdrs && gmtime_r_proto=S_TS ;;
15180	esac
15181	case "$gmtime_r_proto" in
15182	''|0) try='int gmtime_r(const time_t*, struct tm*);'
15183	./protochk "$extern_C $try" $hdrs && gmtime_r_proto=I_TS ;;
15184	esac
15185	case "$gmtime_r_proto" in
15186	''|0)	d_gmtime_r=undef
15187 	        gmtime_r_proto=0
15188		echo "Disabling gmtime_r, cannot determine prototype." >&4 ;;
15189	* )	case "$gmtime_r_proto" in
15190		REENTRANT_PROTO*) ;;
15191		*) gmtime_r_proto="REENTRANT_PROTO_$gmtime_r_proto" ;;
15192		esac
15193		echo "Prototype: $try" ;;
15194	esac
15195	;;
15196	*)	case "$usethreads" in
15197		define) echo "gmtime_r has no prototype, not using it." >&4 ;;
15198		esac
15199		d_gmtime_r=undef
15200		gmtime_r_proto=0
15201		;;
15202	esac
15203	;;
15204*)	gmtime_r_proto=0
15205	;;
15206esac
15207
15208: see if hasmntopt exists
15209set hasmntopt d_hasmntopt
15210eval $inlibc
15211
15212: see if this is a netinet/in.h or sys/in.h system
15213set netinet/in.h i_niin sys/in.h i_sysin
15214eval $inhdr
15215
15216: see if arpa/inet.h has to be included
15217set arpa/inet.h i_arpainet
15218eval $inhdr
15219
15220: see if htonl --and friends-- exists
15221val=''
15222set htonl val
15223eval $inlibc
15224
15225: Maybe they are macros.
15226case "$val" in
15227$undef)
15228	$cat >htonl.c <<EOM
15229#include <stdio.h>
15230#include <sys/types.h>
15231#$i_niin I_NETINET_IN
15232#$i_sysin I_SYS_IN
15233#$i_arpainet I_ARPA_INET
15234#ifdef I_NETINET_IN
15235#include <netinet/in.h>
15236#endif
15237#ifdef I_SYS_IN
15238#include <sys/in.h>
15239#endif
15240#ifdef I_ARPA_INET
15241#include <arpa/inet.h>
15242#endif
15243#ifdef htonl
15244printf("Defined as a macro.");
15245#endif
15246EOM
15247	$cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
15248	if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
15249		val="$define"
15250		echo "But it seems to be defined as a macro." >&4
15251	fi
15252	$rm -f htonl.?
15253	;;
15254esac
15255set d_htonl
15256eval $setvar
15257
15258: see if ilogbl exists
15259set ilogbl d_ilogbl
15260eval $inlibc
15261
15262: index or strchr
15263echo " "
15264if set index val -f; eval $csym; $val; then
15265	if set strchr val -f d_strchr; eval $csym; $val; then
15266		if $contains strchr "$strings" >/dev/null 2>&1 ; then
15267			val="$define"
15268			vali="$undef"
15269			echo "strchr() found." >&4
15270		else
15271			val="$undef"
15272			vali="$define"
15273			echo "index() found." >&4
15274		fi
15275	else
15276		val="$undef"
15277		vali="$define"
15278		echo "index() found." >&4
15279	fi
15280else
15281	if set strchr val -f d_strchr; eval $csym; $val; then
15282		val="$define"
15283		vali="$undef"
15284		echo "strchr() found." >&4
15285	else
15286		echo "No index() or strchr() found!" >&4
15287		val="$undef"
15288		vali="$undef"
15289	fi
15290fi
15291set d_strchr; eval $setvar
15292val="$vali"
15293set d_index; eval $setvar
15294
15295: check whether inet_aton exists
15296set inet_aton d_inetaton
15297eval $inlibc
15298
15299: see if inet_ntop exists
15300set inet_ntop d_inetntop
15301eval $inlibc
15302
15303: see if inet_pton exists
15304set inet_pton d_inetpton
15305eval $inlibc
15306
15307: Look for isascii
15308echo " "
15309$cat >isascii.c <<EOCP
15310#include <stdio.h>
15311#include <ctype.h>
15312#$i_stdlib I_STDLIB
15313#ifdef I_STDLIB
15314#include <stdlib.h>
15315#endif
15316int main() {
15317	int c = 'A';
15318	if (isascii(c))
15319		exit(0);
15320	else
15321		exit(1);
15322}
15323EOCP
15324set isascii
15325if eval $compile; then
15326	echo "isascii() found." >&4
15327	val="$define"
15328else
15329	echo "isascii() NOT found." >&4
15330	val="$undef"
15331fi
15332set d_isascii
15333eval $setvar
15334$rm -f isascii*
15335
15336: Look for isblank
15337echo " "
15338$cat >isblank.c <<'EOCP'
15339#include <stdio.h>
15340#include <ctype.h>
15341int main() {
15342	int c = ' ';
15343	if (isblank(c))
15344		return 0 ;
15345	else
15346		return 1 ;
15347}
15348EOCP
15349if $cc $ccflags $ldflags -o isblank isblank.c $libs >/dev/null 2>&1 ; then
15350	echo "isblank() found." >&4
15351	val="$define"
15352else
15353	echo "isblank() NOT found." >&4
15354	val="$undef"
15355fi
15356set d_isblank
15357eval $setvar
15358$rm -f isblank*
15359
15360: see if isfinite exists
15361set isfinite d_isfinite
15362eval $inlibc
15363
15364: see if isinf exists
15365set isinf d_isinf
15366eval $inlibc
15367
15368: see if isnan exists
15369set isnan d_isnan
15370eval $inlibc
15371
15372: see if isnanl exists
15373set isnanl d_isnanl
15374eval $inlibc
15375
15376: see if killpg exists
15377set killpg d_killpg
15378eval $inlibc
15379
15380: see if lchown exists
15381echo " "
15382$cat > try.c <<'EOCP'
15383/* System header to define __stub macros and hopefully few prototypes,
15384    which can conflict with char lchown(); below.  */
15385#include <assert.h>
15386/* Override any gcc2 internal prototype to avoid an error.  */
15387/* We use char because int might match the return type of a gcc2
15388   builtin and then its argument prototype would still apply.  */
15389char lchown();
15390int main() {
15391    /*  The GNU C library defines this for functions which it implements
15392        to always fail with ENOSYS.  Some functions are actually named
15393	something starting with __ and the normal name is an alias.  */
15394#if defined (__stub_lchown) || defined (__stub___lchown)
15395choke me
15396#else
15397lchown();
15398#endif
15399; return 0; }
15400EOCP
15401set try
15402if eval $compile; then
15403    $echo "lchown() found." >&4
15404    val="$define"
15405else
15406    $echo "lchown() NOT found." >&4
15407    val="$undef"
15408fi
15409set d_lchown
15410eval $setvar
15411
15412: See if number of significant digits in a double precision number is known
15413echo " "
15414$cat >ldbl_dig.c <<EOM
15415#$i_limits I_LIMITS
15416#$i_float I_FLOAT
15417#ifdef I_LIMITS
15418#include <limits.h>
15419#endif
15420#ifdef I_FLOAT
15421#include <float.h>
15422#endif
15423#ifdef LDBL_DIG
15424printf("Contains LDBL_DIG");
15425#endif
15426EOM
15427$cppstdin $cppflags $cppminus < ldbl_dig.c >ldbl_dig.E 2>/dev/null
15428if $contains 'LDBL_DIG' ldbl_dig.E >/dev/null 2>&1; then
15429	echo "LDBL_DIG found." >&4
15430	val="$define"
15431else
15432	echo "LDBL_DIG NOT found." >&4
15433	val="$undef"
15434fi
15435$rm -f ldbl_dig.?
15436set d_ldbl_dig
15437eval $setvar
15438
15439: see if this is a math.h system
15440set math.h i_math
15441eval $inhdr
15442
15443: check to see if math.h defines _LIB_VERSION
15444d_libm_lib_version="$undef"
15445case $i_math in
15446    $define)
15447	echo " "
15448	echo "Checking to see if your libm supports _LIB_VERSION..." >&4
15449	$cat >try.c <<EOCP
15450#include <unistd.h>
15451#include <math.h>
15452int main (int argc, char *argv[])
15453{
15454    printf ("%d\n", _LIB_VERSION);
15455    return (0);
15456    } /* main */
15457EOCP
15458	set try
15459	if eval $compile; then
15460	    foo=`$run ./try`
15461	    echo "Yes, it does ($foo)" >&4
15462	    d_libm_lib_version="$define"
15463	else
15464	    echo "No, it does not (probably harmless)" >&4
15465	    fi
15466	$rm_try
15467	;;
15468
15469    esac
15470
15471: see if link exists
15472set link d_link
15473eval $inlibc
15474
15475: see if localtime_r exists
15476set localtime_r d_localtime_r
15477eval $inlibc
15478case "$d_localtime_r" in
15479"$define")
15480	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
15481	case "$d_localtime_r_proto:$usethreads" in
15482	":define")	d_localtime_r_proto=define
15483		set d_localtime_r_proto localtime_r $hdrs
15484		eval $hasproto ;;
15485	*)	;;
15486	esac
15487	case "$d_localtime_r_proto" in
15488	define)
15489	case "$localtime_r_proto" in
15490	''|0) try='struct tm* localtime_r(const time_t*, struct tm*);'
15491	./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;;
15492	esac
15493	case "$localtime_r_proto" in
15494	''|0) try='int localtime_r(const time_t*, struct tm*);'
15495	./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;;
15496	esac
15497	case "$localtime_r_proto" in
15498	''|0)	d_localtime_r=undef
15499 	        localtime_r_proto=0
15500		echo "Disabling localtime_r, cannot determine prototype." >&4 ;;
15501	* )	case "$localtime_r_proto" in
15502		REENTRANT_PROTO*) ;;
15503		*) localtime_r_proto="REENTRANT_PROTO_$localtime_r_proto" ;;
15504		esac
15505		echo "Prototype: $try" ;;
15506	esac
15507	;;
15508	*)	case "$usethreads" in
15509		define) echo "localtime_r has no prototype, not using it." >&4 ;;
15510		esac
15511		d_localtime_r=undef
15512		localtime_r_proto=0
15513		;;
15514	esac
15515	;;
15516*)	localtime_r_proto=0
15517	;;
15518esac
15519
15520: see if localtime_r calls tzset
15521case "$localtime_r_proto" in
15522REENTRANT_PROTO*)
15523	$cat >try.c <<EOCP
15524/*  Does our libc's localtime_r call tzset ?
15525 *  return 0 if so, 1 otherwise.
15526 */
15527#$i_systypes	I_SYS_TYPES
15528#$i_unistd	I_UNISTD
15529#$i_time	I_TIME
15530#$i_stdlib	I_STDLIB
15531#$i_string	I_STRING
15532#$i_malloc	I_MALLOC
15533#ifdef I_SYS_TYPES
15534#  include <sys/types.h>
15535#endif
15536#ifdef I_UNISTD
15537#  include <unistd.h>
15538#endif
15539#ifdef I_TIME
15540#  include <time.h>
15541#endif
15542#ifdef I_STDLIB
15543#include <stdlib.h>
15544#endif
15545#ifdef I_STRING
15546#  include <string.h>
15547#else
15548#  include <strings.h>
15549#endif
15550#ifdef I_MALLOC
15551#  include <malloc.h>
15552#endif
15553int main()
15554{
15555    time_t t = time(0L);
15556    char w_tz[]="TZ" "=GMT+5",
15557	 e_tz[]="TZ" "=GMT-5",
15558	*tz_e = (char*)malloc(16),
15559	*tz_w = (char*)malloc(16);
15560    struct tm tm_e, tm_w;
15561    memset(&tm_e,'\0',sizeof(struct tm));
15562    memset(&tm_w,'\0',sizeof(struct tm));
15563    strcpy(tz_e,e_tz);
15564    strcpy(tz_w,w_tz);
15565
15566    putenv(tz_e);
15567    localtime_r(&t, &tm_e);
15568
15569    putenv(tz_w);
15570    localtime_r(&t, &tm_w);
15571
15572    if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
15573	return 1;
15574    return 0;
15575}
15576EOCP
15577	set try
15578	if eval $compile; then
15579	    if $run ./try; then
15580		d_localtime_r_needs_tzset=undef;
15581	    else
15582		d_localtime_r_needs_tzset=define;
15583	    fi;
15584	else
15585	    d_localtime_r_needs_tzset=undef;
15586	fi;
15587     ;;
15588  *)
15589     d_localtime_r_needs_tzset=undef;
15590     ;;
15591esac
15592$rm_try
15593
15594: see if localeconv exists
15595set localeconv d_locconv
15596eval $inlibc
15597
15598: see if localtime_r calls tzset
15599case "$d_locconv:$d_lc_monetary_2008" in
15600define:)
15601	$cat >try.c <<EOCP
15602#include <locale.h>
15603int main() {
15604	struct lconv *lc = localeconv();
15605	char int_p_cs_precedes = lc->int_p_cs_precedes;
15606	return 0;
15607}
15608EOCP
15609	set try
15610	if eval $compile; then
15611		d_lc_monetary_2008="$define"
15612	else
15613		d_lc_monetary_2008="$undef"
15614	fi;
15615	$rm_try
15616	;;
15617esac
15618
15619: see if lockf exists
15620set lockf d_lockf
15621eval $inlibc
15622
15623: see if prototype for lseek is available
15624echo " "
15625set d_lseekproto lseek $i_systypes sys/types.h $i_unistd unistd.h
15626eval $hasproto
15627
15628: see if lstat exists
15629set lstat d_lstat
15630eval $inlibc
15631
15632: see if madvise exists
15633set madvise d_madvise
15634eval $inlibc
15635
15636: see if malloc_size exists
15637set malloc_size d_malloc_size
15638eval $inlibc
15639
15640: see if malloc_size_good exists
15641set malloc_good_size d_malloc_good_size
15642eval $inlibc
15643
15644: see if mblen exists
15645set mblen d_mblen
15646eval $inlibc
15647
15648: see if mbstowcs exists
15649set mbstowcs d_mbstowcs
15650eval $inlibc
15651
15652: see if mbtowc exists
15653set mbtowc d_mbtowc
15654eval $inlibc
15655
15656: see if memchr exists
15657set memchr d_memchr
15658eval $inlibc
15659
15660: see if memcmp exists
15661set memcmp d_memcmp
15662eval $inlibc
15663
15664: see if memcpy exists
15665set memcpy d_memcpy
15666eval $inlibc
15667
15668: see if memmove exists
15669set memmove d_memmove
15670eval $inlibc
15671
15672: see if memset exists
15673set memset d_memset
15674eval $inlibc
15675
15676: see if mkdir exists
15677set mkdir d_mkdir
15678eval $inlibc
15679
15680: see if mkdtemp exists
15681set mkdtemp d_mkdtemp
15682eval $inlibc
15683
15684: see if mkfifo exists
15685set mkfifo d_mkfifo
15686eval $inlibc
15687
15688: see if mkstemp exists
15689set mkstemp d_mkstemp
15690eval $inlibc
15691
15692: see if mkstemps exists
15693set mkstemps d_mkstemps
15694eval $inlibc
15695
15696: see if mktime exists
15697set mktime d_mktime
15698eval $inlibc
15699
15700: see if this is a sys/mman.h system
15701set sys/mman.h i_sysmman
15702eval $inhdr
15703
15704: see if mmap exists
15705set mmap d_mmap
15706eval $inlibc
15707: see what shmat returns
15708: default to something harmless
15709mmaptype='void *'
15710case "$i_sysmman$d_mmap" in
15711"$define$define")
15712	$cat >mmap.c <<'END'
15713#include <sys/mman.h>
15714void *mmap();
15715END
15716	if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
15717		mmaptype='void *'
15718	else
15719		mmaptype='caddr_t'
15720	fi
15721	echo "and it returns ($mmaptype)." >&4
15722	;;
15723esac
15724
15725
15726
15727: see if sqrtl exists
15728set sqrtl d_sqrtl
15729eval $inlibc
15730
15731: see if scalbnl exists
15732set scalbnl d_scalbnl
15733eval $inlibc
15734
15735: see if modfl exists
15736set modfl d_modfl
15737eval $inlibc
15738
15739: see if prototype for modfl is available
15740echo " "
15741set d_modflproto modfl $i_math math.h
15742eval $hasproto
15743
15744d_modfl_pow32_bug="$undef"
15745
15746case "$d_longdbl$d_modfl" in
15747$define$define)
15748	$cat <<EOM
15749Checking to see whether your modfl() is okay for large values...
15750EOM
15751$cat >try.c <<EOCP
15752#include <math.h>
15753#include <stdio.h>
15754EOCP
15755if $test "X$d_modflproto" != "X$define"; then
15756	$cat >>try.c <<EOCP
15757/* Sigh. many current glibcs provide the function, but do not prototype it. */
15758long double modfl (long double, long double *);
15759EOCP
15760fi
15761$cat >>try.c <<EOCP
15762int main() {
15763    long double nv = 4294967303.15;
15764    long double v, w;
15765    v = modfl(nv, &w);
15766#ifdef __GLIBC__
15767    printf("glibc");
15768#endif
15769    printf(" %"$sPRIfldbl" %"$sPRIfldbl" %"$sPRIfldbl"\n", nv, v, w);
15770    return 0;
15771}
15772EOCP
15773	case "$osname:$gccversion" in
15774	aix:)	saveccflags="$ccflags"
15775		ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
15776	esac
15777	set try
15778	if eval $compile; then
15779		foo=`$run ./try`
15780		case "$foo" in
15781		*" 4294967303.150000 1.150000 4294967302.000000")
15782			echo >&4 "Your modfl() is broken for large values."
15783			d_modfl_pow32_bug="$define"
15784			case "$foo" in
15785			glibc)	echo >&4 "You should upgrade your glibc to at least 2.2.2 to get a fixed modfl()."
15786			;;
15787			esac
15788			;;
15789		*" 4294967303.150000 0.150000 4294967303.000000")
15790			echo >&4 "Your modfl() seems okay for large values."
15791			;;
15792		*)	echo >&4 "I don't understand your modfl() at all."
15793			d_modfl="$undef"
15794			;;
15795		esac
15796		$rm_try
15797	else
15798		echo "I cannot figure out whether your modfl() is okay, assuming it isn't."
15799		d_modfl="$undef"
15800	fi
15801	case "$osname:$gccversion" in
15802	aix:)	ccflags="$saveccflags" ;; # restore
15803	esac
15804	;;
15805esac
15806
15807if $test "$uselongdouble" = "$define"; then
15808    message=""
15809    if $test "$d_sqrtl" != "$define"; then
15810	message="$message sqrtl"
15811    fi
15812    if $test "$d_modfl" != "$define"; then
15813	if $test "$d_aintl:$d_copysignl" = "$define:$define"; then
15814	    echo "You have both aintl and copysignl, so I can emulate modfl."
15815	else
15816	    message="$message modfl"
15817	fi
15818    fi
15819    if $test "$d_frexpl" != "$define"; then
15820	if $test "$d_ilogbl:$d_scalbnl" = "$define:$define"; then
15821	    echo "You have both ilogbl and scalbnl, so I can emulate frexpl."
15822	else
15823	    message="$message frexpl"
15824	fi
15825    fi
15826
15827    if $test "$message" != ""; then
15828	$cat <<EOM >&4
15829
15830*** You requested the use of long doubles but you do not seem to have
15831*** the following mathematical functions needed for long double support:
15832***    $message
15833*** Please rerun Configure without -Duselongdouble and/or -Dusemorebits.
15834*** Cannot continue, aborting.
15835
15836EOM
15837
15838	exit 1
15839    fi
15840fi
15841
15842: see if mprotect exists
15843set mprotect d_mprotect
15844eval $inlibc
15845
15846: see if msgctl exists
15847set msgctl d_msgctl
15848eval $inlibc
15849
15850: see if msgget exists
15851set msgget d_msgget
15852eval $inlibc
15853
15854: see if msgsnd exists
15855set msgsnd d_msgsnd
15856eval $inlibc
15857
15858: see if msgrcv exists
15859set msgrcv d_msgrcv
15860eval $inlibc
15861
15862: see how much of the 'msg*(2)' library is present.
15863h_msg=true
15864echo " "
15865case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
15866*"$undef"*) h_msg=false;;
15867esac
15868case "$osname" in
15869freebsd)
15870    case "`ipcs 2>&1`" in
15871    "SVID messages"*"not configured"*)
15872	echo "Your $osname does not have the msg*(2) configured." >&4
15873        h_msg=false
15874	val="$undef"
15875	set msgctl d_msgctl
15876	eval $setvar
15877	set msgget d_msgget
15878	eval $setvar
15879	set msgsnd d_msgsnd
15880	eval $setvar
15881	set msgrcv d_msgrcv
15882	eval $setvar
15883	;;
15884    esac
15885    ;;
15886esac
15887: we could also check for sys/ipc.h ...
15888if $h_msg && $test `./findhdr sys/msg.h`; then
15889	echo "You have the full msg*(2) library." >&4
15890	val="$define"
15891else
15892	echo "You don't have the full msg*(2) library." >&4
15893	val="$undef"
15894fi
15895set d_msg
15896eval $setvar
15897
15898: Check for msghdr_s
15899echo " "
15900echo "Checking to see if your system supports struct msghdr..." >&4
15901set d_msghdr_s msghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
15902eval $hasstruct
15903case "$d_msghdr_s" in
15904"$define")      echo "Yes, it does."   ;;
15905*)              echo "No, it doesn't." ;;
15906esac
15907
15908
15909: see if msync exists
15910set msync d_msync
15911eval $inlibc
15912
15913: see if munmap exists
15914set munmap d_munmap
15915eval $inlibc
15916
15917: see if nice exists
15918set nice d_nice
15919eval $inlibc
15920
15921: see if this is a langinfo.h system
15922set langinfo.h i_langinfo
15923eval $inhdr
15924
15925: see if nl_langinfo exists
15926set nl_langinfo d_nl_langinfo
15927eval $inlibc
15928
15929: check for volatile keyword
15930echo " "
15931echo 'Checking to see if your C compiler knows about "volatile"...' >&4
15932$cat >try.c <<'EOCP'
15933int main()
15934{
15935	typedef struct _goo_struct goo_struct;
15936	goo_struct * volatile goo = ((goo_struct *)0);
15937	struct _goo_struct {
15938		long long_int;
15939		int reg_int;
15940		char char_var;
15941	};
15942	typedef unsigned short foo_t;
15943	char *volatile foo;
15944	volatile int bar;
15945	volatile foo_t blech;
15946	foo = foo;
15947}
15948EOCP
15949if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
15950	val="$define"
15951	echo "Yup, it does."
15952else
15953	val="$undef"
15954	echo "Nope, it doesn't."
15955fi
15956set d_volatile
15957eval $setvar
15958$rm_try
15959
15960: Check basic sizes
15961echo " "
15962$echo "Choosing the C types to be used for Perl's internal types..." >&4
15963
15964case "$use64bitint:$d_quad:$quadtype" in
15965define:define:?*)
15966	ivtype="$quadtype"
15967	uvtype="$uquadtype"
15968	ivsize=8
15969	uvsize=8
15970	;;
15971*)	ivtype="long"
15972	uvtype="unsigned long"
15973	ivsize=$longsize
15974	uvsize=$longsize
15975	;;
15976esac
15977
15978case "$uselongdouble:$d_longdbl" in
15979define:define)
15980	nvtype="long double"
15981	nvsize=$longdblsize
15982	;;
15983*)	nvtype=double
15984	nvsize=$doublesize
15985	;;
15986esac
15987
15988$echo "(IV will be "$ivtype", $ivsize bytes)"
15989$echo "(UV will be "$uvtype", $uvsize bytes)"
15990$echo "(NV will be "$nvtype", $nvsize bytes)"
15991
15992$cat >try.c <<EOCP
15993#$i_inttypes I_INTTYPES
15994#ifdef I_INTTYPES
15995#include <inttypes.h>
15996#endif
15997#include <stdio.h>
15998int main() {
15999#ifdef INT8
16000   int8_t i =  INT8_MAX;
16001  uint8_t u = UINT8_MAX;
16002  printf("int8_t\n");
16003#endif
16004#ifdef INT16
16005   int16_t i =  INT16_MAX;
16006  uint16_t u = UINT16_MAX;
16007  printf("int16_t\n");
16008#endif
16009#ifdef INT32
16010   int32_t i =  INT32_MAX;
16011  uint32_t u = UINT32_MAX;
16012  printf("int32_t\n");
16013#endif
16014}
16015EOCP
16016
16017i8type="signed char"
16018u8type="unsigned char"
16019i8size=1
16020u8size=1
16021
16022case "$i16type" in
16023'')	case "$shortsize" in
16024	2)	i16type=short
16025		u16type="unsigned short"
16026		i16size=$shortsize
16027		u16size=$shortsize
16028		;;
16029	esac
16030	;;
16031esac
16032case "$i16type" in
16033'')	set try -DINT16
16034	if eval $compile; then
16035		case "`$run ./try`" in
16036		int16_t)
16037			i16type=int16_t
16038			u16type=uint16_t
16039			i16size=2
16040			u16size=2
16041			;;
16042		esac
16043	fi
16044	;;
16045esac
16046case "$i16type" in
16047'')	if $test $shortsize -ge 2; then
16048		i16type=short
16049		u16type="unsigned short"
16050		i16size=$shortsize
16051		u16size=$shortsize
16052	fi
16053	;;
16054esac
16055
16056case "$i32type" in
16057'')	case "$longsize" in
16058	4)	i32type=long
16059		u32type="unsigned long"
16060		i32size=$longsize
16061		u32size=$longsize
16062		;;
16063	*)	case "$intsize" in
16064		4)	i32type=int
16065			u32type="unsigned int"
16066			i32size=$intsize
16067			u32size=$intsize
16068			;;
16069		esac
16070		;;
16071	esac
16072	;;
16073esac
16074case "$i32type" in
16075'')	set try -DINT32
16076	if eval $compile; then
16077		case "`$run ./try`" in
16078		int32_t)
16079			i32type=int32_t
16080			u32type=uint32_t
16081			i32size=4
16082			u32size=4
16083			;;
16084		esac
16085	fi
16086	;;
16087esac
16088case "$i32type" in
16089'')	if $test $intsize -ge 4; then
16090		i32type=int
16091		u32type="unsigned int"
16092		i32size=$intsize
16093		u32size=$intsize
16094	fi
16095	;;
16096esac
16097
16098case "$i64type" in
16099'')	case "$d_quad:$quadtype" in
16100	define:?*)
16101		i64type="$quadtype"
16102		u64type="$uquadtype"
16103		i64size=8
16104		u64size=8
16105		;;
16106	esac
16107	;;
16108esac
16109
16110$echo "Checking how many bits of your UVs your NVs can preserve..." >&4
16111: volatile so that the compiler has to store it out to memory.
16112if test X"$d_volatile" = X"$define"; then
16113	volatile=volatile
16114fi
16115$cat <<EOP >try.c
16116#include <stdio.h>
16117#$i_stdlib I_STDLIB
16118#ifdef I_STDLIB
16119#include <stdlib.h>
16120#endif
16121#include <sys/types.h>
16122#include <signal.h>
16123#ifdef SIGFPE
16124$volatile int bletched = 0;
16125$signal_t blech(int s) { bletched = 1; }
16126#endif
16127int main() {
16128    $uvtype u = 0;
16129    $nvtype d;
16130    int     n = 8 * $uvsize;
16131    int     i;
16132#ifdef SIGFPE
16133    signal(SIGFPE, blech);
16134#endif
16135
16136    for (i = 0; i < n; i++) {
16137      u = u << 1 | ($uvtype)1;
16138      d = ($nvtype)u;
16139      if (($uvtype)d != u)
16140        break;
16141      if (d <= 0)
16142	break;
16143      d = ($nvtype)(u - 1);
16144      if (($uvtype)d != (u - 1))
16145        break;
16146#ifdef SIGFPE
16147      if (bletched)
16148	break;
16149#endif
16150    }
16151    printf("%d\n", ((i == n) ? -n : i));
16152    exit(0);
16153}
16154EOP
16155set try
16156
16157d_nv_preserves_uv="$undef"
16158if eval $compile; then
16159	nv_preserves_uv_bits="`$run ./try`"
16160fi
16161case "$nv_preserves_uv_bits" in
16162\-[1-9]*)
16163	nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
16164	$echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs."  2>&1
16165	d_nv_preserves_uv="$define"
16166	;;
16167[1-9]*)	$echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs."  2>&1
16168	d_nv_preserves_uv="$undef" ;;
16169*)	$echo "Can't figure out how many bits your NVs preserve." 2>&1
16170	nv_preserves_uv_bits="0" ;;
16171esac
16172$rm_try
16173
16174$echo "Checking to find the largest integer value your NVs can hold..." >&4
16175: volatile so that the compiler has to store it out to memory.
16176if test X"$d_volatile" = X"$define"; then
16177	volatile=volatile
16178fi
16179$cat <<EOP >try.c
16180#include <stdio.h>
16181
16182typedef $nvtype NV;
16183
16184int
16185main() {
16186  NV value = 2;
16187  int count = 1;
16188
16189  while(count < 256) {
16190    $volatile NV up = value + 1.0;
16191    $volatile NV negated = -value;
16192    $volatile NV down = negated - 1.0;
16193    $volatile NV got_up = up - value;
16194    int up_good = got_up == 1.0;
16195    int got_down = down - negated;
16196    int down_good = got_down == -1.0;
16197
16198    if (down_good != up_good) {
16199      fprintf(stderr,
16200	      "Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n",
16201	      up_good, (double) got_up, down_good, (double) got_down,
16202	      count, (double) value);
16203      return 1;
16204    }
16205    if (!up_good) {
16206      while (1) {
16207	if (count > 8) {
16208	  count -= 8;
16209	  fputs("256.0", stdout);
16210	} else {
16211	  count--;
16212	  fputs("2.0", stdout);
16213	}
16214	if (!count) {
16215	  puts("");
16216	  return 0;
16217	}
16218	fputs("*", stdout);
16219      }
16220    }
16221    value *= 2;
16222    ++count;
16223  }
16224  fprintf(stderr, "Cannot overflow integer range, even at 2**%d (%.20f)\n",
16225	  count, (double) value);
16226  return 1;
16227}
16228EOP
16229set try
16230
16231nv_overflows_integers_at='0'
16232if eval $compile; then
16233    xxx="`$run ./try`"
16234    case "$?" in
16235	0)
16236	    case "$xxx" in
16237		2*)  cat >&4 <<EOM
16238The largest integer your NVs can preserve is equal to $xxx
16239EOM
16240		    nv_overflows_integers_at="$xxx"
16241		    ;;
16242		*)  cat >&4 <<EOM
16243Cannot determine the largest integer value your NVs can hold, unexpected output
16244'$xxx'
16245EOM
16246		    ;;
16247	    esac
16248	    ;;
16249	*)  cat >&4 <<EOM
16250Cannot determine the largest integer value your NVs can hold
16251EOM
16252	    ;;
16253    esac
16254fi
16255$rm_try
16256
16257$echo "Checking whether NV 0.0 is all bits zero in memory..." >&4
16258: volatile so that the compiler has to store it out to memory.
16259if test X"$d_volatile" = X"$define"; then
16260	volatile=volatile
16261fi
16262$cat <<EOP >try.c
16263#include <stdio.h>
16264#$i_stdlib I_STDLIB
16265#ifdef I_STDLIB
16266#include <stdlib.h>
16267#endif
16268#$i_string I_STRING
16269#ifdef I_STRING
16270#  include <string.h>
16271#else
16272#  include <strings.h>
16273#endif
16274#include <sys/types.h>
16275#include <signal.h>
16276#ifdef SIGFPE
16277$volatile int bletched = 0;
16278$signal_t blech(int s) { bletched = 1; }
16279#endif
16280
16281int checkit($nvtype d, char *where) {
16282    unsigned char *p = (char *)&d;
16283    unsigned char *end = p + sizeof(d);
16284    int fail = 0;
16285
16286    while (p < end)
16287	fail += *p++;
16288
16289    if (!fail)
16290	return 0;
16291
16292    p = (char *)&d;
16293    printf("No - %s: 0x", where);
16294    while (p < end)
16295	printf ("%02X", *p++);
16296    printf("\n");
16297    return 1;
16298}
16299
16300int main(int argc, char **argv) {
16301    $nvtype d = 0.0;
16302    int fail = 0;
16303    fail += checkit(d, "0.0");
16304
16305    /* The compiler shouldn't be assuming that bletched is 0  */
16306    d = bletched;
16307
16308    fail += checkit(d, "bleched");
16309
16310#ifdef SIGFPE
16311    signal(SIGFPE, blech);
16312#endif
16313
16314    /* Paranoia - the compiler should have no way of knowing that ANSI says
16315       that argv[argc] will always be NULL.  Actually, if it did assume this it
16316       would be buggy, as this is C and main() can be called from elsewhere in
16317       the program.  */
16318    d = argv[argc] ? 1 : 0;
16319
16320    if (d) {
16321	printf("Odd argv[argc]=%p, d=%g\n", argv[argc], d);
16322    }
16323
16324    fail += checkit(d, "ternary");
16325
16326    memset(&d, sizeof(d), argv[argc] ? 1 : 0);
16327
16328    if (d != 0.0) {
16329	printf("No - memset doesn't give 0.0\n");
16330	/* This might just blow up:  */
16331	printf("(gives %g)\n", d);
16332	return 1;
16333    }
16334
16335#ifdef SIGFPE
16336    if (bletched) {
16337	printf("No - something bleched\n");
16338	return 1;
16339    }
16340#endif
16341    if (fail) {
16342      printf("No - %d fail(s)\n", fail);
16343      return 1;
16344    }
16345    printf("Yes\n");
16346    return 0;
16347}
16348EOP
16349set try
16350
16351d_nv_zero_is_allbits_zero="$undef"
16352if eval $compile; then
16353    xxx="`$run ./try`"
16354    case "$?" in
16355	0)
16356	    case "$xxx" in
16357		Yes)  cat >&4 <<EOM
163580.0 is represented as all bits zero in memory
16359EOM
16360		    d_nv_zero_is_allbits_zero="$define"
16361		    ;;
16362		*)  cat >&4 <<EOM
163630.0 is not represented as all bits zero in memory
16364EOM
16365		    d_nv_zero_is_allbits_zero="$undef"
16366		    ;;
16367	    esac
16368	    ;;
16369	*)  cat >&4 <<EOM
163700.0 is not represented as all bits zero in memory
16371EOM
16372	    d_nv_zero_is_allbits_zero="$undef"
16373	    ;;
16374    esac
16375fi
16376$rm_try
16377
16378: check for off64_t
16379echo " "
16380echo "Checking to see if you have off64_t..." >&4
16381$cat >try.c <<EOCP
16382#include <sys/types.h>
16383#include <unistd.h>
16384int main() { off64_t x = 7; }
16385EOCP
16386set try
16387if eval $compile; then
16388	val="$define"
16389	echo "You have off64_t."
16390else
16391	val="$undef"
16392	echo "You do not have off64_t."
16393	case "$lseeksize" in
16394	8) echo "(Your off_t is 64 bits, so you could use that.)" ;;
16395	esac
16396fi
16397$rm_try
16398set d_off64_t
16399eval $setvar
16400
16401: how to create joinable pthreads
16402if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
16403	echo " "
16404	echo "Checking what constant to use for creating joinable pthreads..." >&4
16405	$cat >try.c <<'EOCP'
16406#include <pthread.h>
16407int main() {
16408    int detachstate = JOINABLE;
16409}
16410EOCP
16411	set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
16412	if eval $compile; then
16413		echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
16414		val="$undef" # Yes, undef.
16415		set d_old_pthread_create_joinable
16416		eval $setvar
16417		val=""
16418		set old_pthread_create_joinable
16419		eval $setvar
16420	else
16421		set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
16422		if eval $compile; then
16423			echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
16424			val="$define"
16425			set d_old_pthread_create_joinable
16426			eval $setvar
16427			val=PTHREAD_CREATE_UNDETACHED
16428			set old_pthread_create_joinable
16429			eval $setvar
16430		else
16431			set try -DJOINABLE=__UNDETACHED
16432			if eval $compile; then
16433				echo "You seem to use __UNDETACHED." >&4
16434				val="$define"
16435				set d_old_pthread_create_joinable
16436				eval $setvar
16437				val=__UNDETACHED
16438				set old_pthread_create_joinable
16439				eval $setvar
16440			else
16441				echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
16442				val="$define"
16443				set d_old_pthread_create_joinable
16444				eval $setvar
16445				val=0
16446				set old_pthread_create_joinable
16447				eval $setvar
16448			fi
16449		fi
16450	fi
16451	$rm_try
16452else
16453    d_old_pthread_create_joinable="$undef"
16454    old_pthread_create_joinable=""
16455fi
16456
16457: see if pause exists
16458set pause d_pause
16459eval $inlibc
16460
16461: see if poll exists
16462set poll d_poll
16463eval $inlibc
16464
16465: see if prctl exists
16466set prctl d_prctl
16467eval $inlibc
16468
16469: see if prctl supports PR_SET_NAME
16470d_prctl_set_name=$undef
16471case $d_prctl in
16472    $define)
16473	$cat >try.c <<EOM
16474#include <sys/prctl.h>
16475
16476int main (int argc, char *argv[])
16477{
16478    return (prctl (PR_SET_NAME, "Test"));
16479    } /* main */
16480EOM
16481	set try
16482	if eval $compile_ok && $run ./try; then
16483	    echo "Your prctl (PR_SET_NAME, ...) works"
16484	    d_prctl_set_name=$define
16485	    fi
16486	$rm_try
16487	;;
16488    esac
16489
16490: see if readlink exists
16491set readlink d_readlink
16492eval $inlibc
16493
16494: Check if exe is symlink to abs path of executing program
16495echo " "
16496procselfexe=''
16497val="$undef"
16498case "$d_readlink" in
16499    "$define")
16500	: NetBSD first as /proc/self is a symlink to /proc/curproc, and it feels
16501	: more tidy to avoid an extra level of symlink
16502	set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
16503	while test $# -gt 0; do
16504	    type=$1; try=$2
16505	    shift; shift
16506	    if $issymlink $try; then
16507		$ls -l $try > reflect
16508		if $contains /`basename $ls` reflect >/dev/null 2>&1; then
16509		    echo "You have $type-like $try."
16510		    procselfexe='"'$try'"'
16511		    val="$define"
16512		    : This will break out of the loop
16513		    set X; shift
16514		fi
16515	    fi
16516	done
16517	;;
16518esac
16519$rm -f reflect
16520set d_procselfexe
16521eval $setvar
16522
16523: backward compatibility for d_hvfork
16524if test X$d_hvfork != X; then
16525	d_vfork="$d_hvfork"
16526	d_hvfork=''
16527fi
16528: see if there is a vfork
16529val=''
16530set vfork val
16531eval $inlibc
16532
16533d_pseudofork=$undef
16534
16535: Ok, but do we want to use it. vfork is reportedly unreliable in
16536: perl on Solaris 2.x, and probably elsewhere.
16537case "$val" in
16538$define)
16539	echo " "
16540	case "$usevfork" in
16541	false) dflt='n';;
16542	*) dflt='y';;
16543	esac
16544	cat <<'EOM'
16545
16546Perl can only use a vfork() that doesn't suffer from strict
16547restrictions on calling functions or modifying global data in
16548the child.  For example, glibc-2.1 contains such a vfork()
16549that is unsuitable.  If your system provides a proper fork()
16550call, chances are that you do NOT want perl to use vfork().
16551
16552EOM
16553	rp="Do you still want to use vfork()?"
16554	. ./myread
16555	case "$ans" in
16556	y|Y) ;;
16557	*)
16558		echo "Ok, we won't use vfork()."
16559		val="$undef"
16560		;;
16561	esac
16562	;;
16563esac
16564set d_vfork
16565eval $setvar
16566case "$d_vfork" in
16567$define) usevfork='true';;
16568*) usevfork='false';;
16569esac
16570
16571: see whether the pthread_atfork exists
16572$cat >try.c <<EOP
16573#include <pthread.h>
16574#include <stdio.h>
16575int main() {
16576#ifdef  PTHREAD_ATFORK
16577        pthread_atfork(NULL,NULL,NULL);
16578#endif
16579}
16580EOP
16581
16582: see if pthread_atfork exists
16583set try -DPTHREAD_ATFORK
16584if eval $compile; then
16585    val="$define"
16586else
16587    val="$undef"
16588fi
16589case "$usethreads" in
16590$define)
16591        case "$val" in
16592        $define) echo 'pthread_atfork found.' >&4        ;;
16593        *)       echo 'pthread_atfork NOT found.' >&4    ;;
16594        esac
16595esac
16596set d_pthread_atfork
16597eval $setvar
16598
16599: see if pthread_attr_setscope exists
16600set pthread_attr_setscope d_pthread_attr_setscope
16601eval $inlibc
16602
16603: see whether the various POSIXish _yields exist
16604$cat >try.c <<EOP
16605#include <pthread.h>
16606#include <stdio.h>
16607int main() {
16608#ifdef SCHED_YIELD
16609	sched_yield();
16610#else
16611#ifdef PTHREAD_YIELD
16612	pthread_yield();
16613#else
16614#ifdef PTHREAD_YIELD_NULL
16615	pthread_yield(NULL);
16616#endif
16617#endif
16618#endif
16619}
16620EOP
16621: see if sched_yield exists
16622set try -DSCHED_YIELD
16623if eval $compile; then
16624    val="$define"
16625    sched_yield='sched_yield()'
16626else
16627    val="$undef"
16628fi
16629case "$usethreads" in
16630$define)
16631	case "$val" in
16632	$define) echo 'sched_yield() found.' >&4	;;
16633	*)	 echo 'sched_yield() NOT found.' >&4	;;
16634	esac
16635esac
16636set d_sched_yield
16637eval $setvar
16638
16639: see if pthread_yield exists
16640set try -DPTHREAD_YIELD
16641if eval $compile; then
16642    val="$define"
16643    case "$sched_yield" in
16644    '') sched_yield='pthread_yield()' ;;
16645    esac
16646else
16647    set try -DPTHREAD_YIELD_NULL
16648    if eval $compile; then
16649	val="$define"
16650	case "$sched_yield" in
16651	'') sched_yield='pthread_yield(NULL)' ;;
16652	esac
16653    else
16654	val="$undef"
16655    fi
16656fi
16657case "$usethreads" in
16658$define)
16659	case "$val" in
16660	$define) echo 'pthread_yield() found.' >&4	;;
16661	*)	 echo 'pthread_yield() NOT found.' >&4	;;
16662	esac
16663	;;
16664esac
16665set d_pthread_yield
16666eval $setvar
16667case "$sched_yield" in
16668'') sched_yield=undef ;;
16669esac
16670$rm_try
16671
16672: see if random_r exists
16673set random_r d_random_r
16674eval $inlibc
16675case "$d_random_r" in
16676"$define")
16677	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
16678	case "$d_random_r_proto:$usethreads" in
16679	":define")	d_random_r_proto=define
16680		set d_random_r_proto random_r $hdrs
16681		eval $hasproto ;;
16682	*)	;;
16683	esac
16684	case "$d_random_r_proto" in
16685	define)
16686	case "$random_r_proto" in
16687	''|0) try='int random_r(int*, struct random_data*);'
16688	./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;;
16689	esac
16690	case "$random_r_proto" in
16691	''|0) try='int random_r(long*, struct random_data*);'
16692	./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;;
16693	esac
16694	case "$random_r_proto" in
16695	''|0) try='int random_r(struct random_data*, int32_t*);'
16696	./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;;
16697	esac
16698	case "$random_r_proto" in
16699	''|0)	d_random_r=undef
16700 	        random_r_proto=0
16701		echo "Disabling random_r, cannot determine prototype." >&4 ;;
16702	* )	case "$random_r_proto" in
16703		REENTRANT_PROTO*) ;;
16704		*) random_r_proto="REENTRANT_PROTO_$random_r_proto" ;;
16705		esac
16706		echo "Prototype: $try" ;;
16707	esac
16708	;;
16709	*)	case "$usethreads" in
16710		define) echo "random_r has no prototype, not using it." >&4 ;;
16711		esac
16712		d_random_r=undef
16713		random_r_proto=0
16714		;;
16715	esac
16716	;;
16717*)	random_r_proto=0
16718	;;
16719esac
16720
16721: see if readdir and friends exist
16722set readdir d_readdir
16723eval $inlibc
16724set seekdir d_seekdir
16725eval $inlibc
16726set telldir d_telldir
16727eval $inlibc
16728set rewinddir d_rewinddir
16729eval $inlibc
16730
16731: see if readdir64_r exists
16732set readdir64_r d_readdir64_r
16733eval $inlibc
16734case "$d_readdir64_r" in
16735"$define")
16736	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
16737	case "$d_readdir64_r_proto:$usethreads" in
16738	":define")	d_readdir64_r_proto=define
16739		set d_readdir64_r_proto readdir64_r $hdrs
16740		eval $hasproto ;;
16741	*)	;;
16742	esac
16743	case "$d_readdir64_r_proto" in
16744	define)
16745	case "$readdir64_r_proto" in
16746	''|0) try='int readdir64_r(DIR*, struct dirent64*, struct dirent64**);'
16747	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TSR ;;
16748	esac
16749	case "$readdir64_r_proto" in
16750	''|0) try='int readdir64_r(DIR*, struct dirent64*);'
16751	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TS ;;
16752	esac
16753	case "$readdir64_r_proto" in
16754	''|0)	d_readdir64_r=undef
16755 	        readdir64_r_proto=0
16756		echo "Disabling readdir64_r, cannot determine prototype." >&4 ;;
16757	* )	case "$readdir64_r_proto" in
16758		REENTRANT_PROTO*) ;;
16759		*) readdir64_r_proto="REENTRANT_PROTO_$readdir64_r_proto" ;;
16760		esac
16761		echo "Prototype: $try" ;;
16762	esac
16763	;;
16764	*)	case "$usethreads" in
16765		define) echo "readdir64_r has no prototype, not using it." >&4 ;;
16766		esac
16767		d_readdir64_r=undef
16768		readdir64_r_proto=0
16769		;;
16770	esac
16771	;;
16772*)	readdir64_r_proto=0
16773	;;
16774esac
16775
16776: see if readdir_r exists
16777set readdir_r d_readdir_r
16778eval $inlibc
16779case "$d_readdir_r" in
16780"$define")
16781	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
16782	case "$d_readdir_r_proto:$usethreads" in
16783	":define")	d_readdir_r_proto=define
16784		set d_readdir_r_proto readdir_r $hdrs
16785		eval $hasproto ;;
16786	*)	;;
16787	esac
16788	case "$d_readdir_r_proto" in
16789	define)
16790	case "$readdir_r_proto" in
16791	''|0) try='int readdir_r(DIR*, struct dirent*, struct dirent**);'
16792	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TSR ;;
16793	esac
16794	case "$readdir_r_proto" in
16795	''|0) try='int readdir_r(DIR*, struct dirent*);'
16796	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TS ;;
16797	esac
16798	case "$readdir_r_proto" in
16799	''|0)	d_readdir_r=undef
16800 	        readdir_r_proto=0
16801		echo "Disabling readdir_r, cannot determine prototype." >&4 ;;
16802	* )	case "$readdir_r_proto" in
16803		REENTRANT_PROTO*) ;;
16804		*) readdir_r_proto="REENTRANT_PROTO_$readdir_r_proto" ;;
16805		esac
16806		echo "Prototype: $try" ;;
16807	esac
16808	;;
16809	*)	case "$usethreads" in
16810		define) echo "readdir_r has no prototype, not using it." >&4 ;;
16811		esac
16812		d_readdir_r=undef
16813		readdir_r_proto=0
16814		;;
16815	esac
16816	;;
16817*)	readdir_r_proto=0
16818	;;
16819esac
16820
16821: see if readv exists
16822set readv d_readv
16823eval $inlibc
16824
16825: see if recvmsg exists
16826set recvmsg d_recvmsg
16827eval $inlibc
16828
16829: see if rename exists
16830set rename d_rename
16831eval $inlibc
16832
16833: see if rmdir exists
16834set rmdir d_rmdir
16835eval $inlibc
16836
16837: see if memory.h is available.
16838val=''
16839set memory.h val
16840eval $inhdr
16841
16842: See if it conflicts with string.h
16843case "$val" in
16844$define)
16845	case "$strings" in
16846	'') ;;
16847	*)
16848		$cppstdin $cppflags $cppminus < $strings > mem.h
16849		if $contains 'memcpy' mem.h >/dev/null 2>&1; then
16850			echo " "
16851			echo "We won't be including <memory.h>."
16852			val="$undef"
16853		fi
16854		$rm -f mem.h
16855		;;
16856	esac
16857esac
16858set i_memory
16859eval $setvar
16860
16861: can bcopy handle overlapping blocks?
16862echo " "
16863val="$undef"
16864case "$d_memmove" in
16865"$define") echo "I'll use memmove() instead of bcopy() for overlapping copies." ;;
16866*)	case "$d_bcopy" in
16867	"$define")
16868		echo "Checking to see if bcopy() can do overlapping copies..." >&4
16869		$cat >try.c <<EOCP
16870#$i_memory I_MEMORY
16871#$i_stdlib I_STDLIB
16872#$i_string I_STRING
16873#$i_unistd I_UNISTD
16874EOCP
16875	$cat >>try.c <<'EOCP'
16876#include <stdio.h>
16877#ifdef I_MEMORY
16878#  include <memory.h>
16879#endif
16880#ifdef I_STDLIB
16881#  include <stdlib.h>
16882#endif
16883#ifdef I_STRING
16884#  include <string.h>
16885#else
16886#  include <strings.h>
16887#endif
16888#ifdef I_UNISTD
16889#  include <unistd.h>  /* Needed for NetBSD */
16890#endif
16891int main()
16892{
16893char buf[128], abc[128];
16894char *b;
16895int len;
16896int off;
16897int align;
16898
16899/* Copy "abcde..." string to char abc[] so that gcc doesn't
16900   try to store the string in read-only memory. */
16901bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
16902
16903for (align = 7; align >= 0; align--) {
16904	for (len = 36; len; len--) {
16905		b = buf+align;
16906		bcopy(abc, b, len);
16907		for (off = 1; off <= len; off++) {
16908			bcopy(b, b+off, len);
16909			bcopy(b+off, b, len);
16910			if (bcmp(b, abc, len))
16911				exit(1);
16912		}
16913	}
16914}
16915exit(0);
16916}
16917EOCP
16918		set try
16919		if eval $compile_ok; then
16920			if $run ./try 2>/dev/null; then
16921				echo "Yes, it can."
16922				val="$define"
16923			else
16924				echo "It can't, sorry."
16925			fi
16926		else
16927			echo "(I can't compile the test program, so we'll assume not...)"
16928		fi
16929		;;
16930	esac
16931	$rm_try
16932	;;
16933esac
16934set d_safebcpy
16935eval $setvar
16936
16937: can memcpy handle overlapping blocks?
16938echo " "
16939val="$undef"
16940case "$d_memmove" in
16941"$define") echo "I'll use memmove() instead of memcpy() for overlapping copies." ;;
16942*)	case "$d_memcpy" in
16943	"$define")
16944		echo "Checking to see if memcpy() can do overlapping copies..." >&4
16945		$cat >try.c <<EOCP
16946#$i_memory I_MEMORY
16947#$i_stdlib I_STDLIB
16948#$i_string I_STRING
16949#$i_unistd I_UNISTD
16950EOCP
16951	$cat >>try.c <<'EOCP'
16952#include <stdio.h>
16953#ifdef I_MEMORY
16954#  include <memory.h>
16955#endif
16956#ifdef I_STDLIB
16957#  include <stdlib.h>
16958#endif
16959#ifdef I_STRING
16960#  include <string.h>
16961#else
16962#  include <strings.h>
16963#endif
16964#ifdef I_UNISTD
16965#  include <unistd.h>  /* Needed for NetBSD */
16966#endif
16967int main()
16968{
16969char buf[128], abc[128];
16970char *b;
16971int len;
16972int off;
16973int align;
16974
16975/* Copy "abcde..." string to char abc[] so that gcc doesn't
16976   try to store the string in read-only memory. */
16977memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
16978
16979for (align = 7; align >= 0; align--) {
16980	for (len = 36; len; len--) {
16981		b = buf+align;
16982		memcpy(b, abc, len);
16983		for (off = 1; off <= len; off++) {
16984			memcpy(b+off, b, len);
16985			memcpy(b, b+off, len);
16986			if (memcmp(b, abc, len))
16987				exit(1);
16988		}
16989	}
16990}
16991exit(0);
16992}
16993EOCP
16994		set try
16995		if eval $compile_ok; then
16996			if $run ./try 2>/dev/null; then
16997				echo "Yes, it can."
16998				val="$define"
16999			else
17000				echo "It can't, sorry."
17001			fi
17002		else
17003			echo "(I can't compile the test program, so we'll assume not...)"
17004		fi
17005		;;
17006	esac
17007	$rm_try
17008	;;
17009esac
17010set d_safemcpy
17011eval $setvar
17012
17013: can memcmp be trusted to compare relative magnitude?
17014val="$undef"
17015case "$d_memcmp" in
17016"$define")
17017	echo " "
17018	echo "Checking if your memcmp() can compare relative magnitude..." >&4
17019	$cat >try.c <<EOCP
17020#$i_memory I_MEMORY
17021#$i_stdlib I_STDLIB
17022#$i_string I_STRING
17023#$i_unistd I_UNISTD
17024EOCP
17025	$cat >>try.c <<'EOCP'
17026#include <stdio.h>
17027#ifdef I_MEMORY
17028#  include <memory.h>
17029#endif
17030#ifdef I_STDLIB
17031#  include <stdlib.h>
17032#endif
17033#ifdef I_STRING
17034#  include <string.h>
17035#else
17036#  include <strings.h>
17037#endif
17038#ifdef I_UNISTD
17039#  include <unistd.h>  /* Needed for NetBSD */
17040#endif
17041int main()
17042{
17043char a = -1;
17044char b = 0;
17045if ((a < b) && memcmp(&a, &b, 1) < 0)
17046	exit(1);
17047exit(0);
17048}
17049EOCP
17050	set try
17051	if eval $compile_ok; then
17052		if $run ./try 2>/dev/null; then
17053			echo "Yes, it can."
17054			val="$define"
17055		else
17056			echo "No, it can't (it uses signed chars)."
17057		fi
17058	else
17059		echo "(I can't compile the test program, so we'll assume not...)"
17060	fi
17061	;;
17062esac
17063$rm_try
17064set d_sanemcmp
17065eval $setvar
17066
17067: see if prototype for sbrk is available
17068echo " "
17069set d_sbrkproto sbrk $i_unistd unistd.h
17070eval $hasproto
17071
17072: see if select exists
17073set select d_select
17074eval $inlibc
17075
17076: see if semctl exists
17077set semctl d_semctl
17078eval $inlibc
17079
17080: see if semget exists
17081set semget d_semget
17082eval $inlibc
17083
17084: see if semop exists
17085set semop d_semop
17086eval $inlibc
17087
17088: see how much of the 'sem*(2)' library is present.
17089h_sem=true
17090echo " "
17091case "$d_semctl$d_semget$d_semop" in
17092*"$undef"*) h_sem=false;;
17093esac
17094case "$osname" in
17095freebsd)
17096    case "`ipcs 2>&1`" in
17097    "SVID messages"*"not configured"*)
17098	echo "Your $osname does not have the sem*(2) configured." >&4
17099        h_sem=false
17100	val="$undef"
17101	set semctl d_semctl
17102	eval $setvar
17103	set semget d_semget
17104	eval $setvar
17105	set semop d_semop
17106	eval $setvar
17107	;;
17108    esac
17109    ;;
17110esac
17111: we could also check for sys/ipc.h ...
17112if $h_sem && $test `./findhdr sys/sem.h`; then
17113	echo "You have the full sem*(2) library." >&4
17114	val="$define"
17115else
17116	echo "You don't have the full sem*(2) library." >&4
17117	val="$undef"
17118fi
17119set d_sem
17120eval $setvar
17121
17122: see whether sys/sem.h defines union semun
17123echo " "
17124$cat > try.c <<'END'
17125#include <sys/types.h>
17126#include <sys/ipc.h>
17127#include <sys/sem.h>
17128int main () { union semun semun; semun.buf = 0; }
17129END
17130set try
17131if eval $compile; then
17132    echo "You have union semun in <sys/sem.h>." >&4
17133    val="$define"
17134else
17135    echo "You do not have union semun in <sys/sem.h>." >&4
17136    val="$undef"
17137fi
17138$rm_try
17139set d_union_semun
17140eval $setvar
17141
17142: see how to do semctl IPC_STAT
17143case "$d_sem" in
17144$define)
17145    echo " "
17146    $cat > tryh.h <<END
17147#ifndef S_IRUSR
17148#   ifdef S_IREAD
17149#	define S_IRUSR S_IREAD
17150#	define S_IWUSR S_IWRITE
17151#	define S_IXUSR S_IEXEC
17152#   else
17153#	define S_IRUSR 0400
17154#	define S_IWUSR 0200
17155#	define S_IXUSR 0100
17156#   endif
17157#   define S_IRGRP (S_IRUSR>>3)
17158#   define S_IWGRP (S_IWUSR>>3)
17159#   define S_IXGRP (S_IXUSR>>3)
17160#   define S_IROTH (S_IRUSR>>6)
17161#   define S_IWOTH (S_IWUSR>>6)
17162#   define S_IXOTH (S_IXUSR>>6)
17163#endif
17164#ifndef S_IRWXU
17165#   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
17166#   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
17167#   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
17168#endif
17169END
17170    : see whether semctl IPC_STAT can use union semun
17171    case "$d_semctl_semun" in
17172    '')
17173      val="$undef"
17174      $cat > try.c <<END
17175#include <sys/types.h>
17176#include <sys/ipc.h>
17177#include <sys/sem.h>
17178#include <sys/stat.h>
17179#include <stdio.h>
17180#include <errno.h>
17181#include "tryh.h"
17182#ifndef errno
17183extern int errno;
17184#endif
17185#$d_union_semun HAS_UNION_SEMUN
17186int main() {
17187    union semun
17188#ifndef HAS_UNION_SEMUN
17189    {
17190	int val;
17191	struct semid_ds *buf;
17192	unsigned short *array;
17193    }
17194#endif
17195    arg;
17196    int sem, st;
17197
17198#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
17199    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17200    if (sem > -1) {
17201	struct semid_ds argbuf;
17202	arg.buf = &argbuf;
17203#	ifdef IPC_STAT
17204	st = semctl(sem, 0, IPC_STAT, arg);
17205	if (st == 0)
17206	    printf("semun\n");
17207	else
17208#	endif /* IPC_STAT */
17209	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
17210#	ifdef IPC_RMID
17211	if (semctl(sem, 0, IPC_RMID, arg) != 0)
17212#	endif /* IPC_RMID */
17213	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
17214    } else
17215#endif /* IPC_PRIVATE && ... */
17216	printf("semget failed: errno = %d\n", errno);
17217  return 0;
17218}
17219END
17220      set try
17221      if eval $compile; then
17222	  xxx=`$run ./try`
17223          case "$xxx" in
17224          semun) val="$define" ;;
17225          esac
17226      fi
17227      $rm_try
17228      set d_semctl_semun
17229      eval $setvar
17230      ;;
17231    esac
17232    case "$d_semctl_semun" in
17233    $define)
17234        echo "You can use union semun for semctl IPC_STAT." >&4
17235	also='also'
17236        ;;
17237    *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
17238	also=''
17239        ;;
17240    esac
17241
17242    : see whether semctl IPC_STAT can use struct semid_ds pointer
17243    case "$d_semctl_semid_ds" in
17244    '')
17245      val="$undef"
17246      $cat > try.c <<'END'
17247#include <sys/types.h>
17248#include <sys/ipc.h>
17249#include <sys/sem.h>
17250#include <sys/stat.h>
17251#include "tryh.h"
17252#include <stdio.h>
17253#include <errno.h>
17254#ifndef errno
17255extern int errno;
17256#endif
17257int main() {
17258    struct semid_ds arg;
17259    int sem, st;
17260
17261#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
17262    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17263    if (sem > -1) {
17264#	ifdef IPC_STAT
17265	st = semctl(sem, 0, IPC_STAT, &arg);
17266	if (st == 0)
17267	    printf("semid_ds\n");
17268	else
17269#	endif /* IPC_STAT */
17270	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
17271#	ifdef IPC_RMID
17272	if (semctl(sem, 0, IPC_RMID, &arg) != 0)
17273#	endif /* IPC_RMID */
17274	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
17275    } else
17276#endif /* IPC_PRIVATE && ... */
17277	printf("semget failed: errno = %d\n", errno);
17278
17279    return 0;
17280}
17281END
17282      set try
17283      if eval $compile; then
17284          xxx=`$run ./try`
17285          case "$xxx" in
17286          semid_ds) val="$define" ;;
17287          esac
17288      fi
17289      $rm_try
17290      set d_semctl_semid_ds
17291      eval $setvar
17292      ;;
17293    esac
17294    case "$d_semctl_semid_ds" in
17295    $define)
17296        echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
17297        ;;
17298    *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
17299        ;;
17300    esac
17301    ;;
17302*)  val="$undef"
17303
17304    # We do not have the full sem*(2) library, so assume we can not
17305    # use either.
17306
17307    set d_semctl_semun
17308    eval $setvar
17309
17310    set d_semctl_semid_ds
17311    eval $setvar
17312    ;;
17313esac
17314$rm_try tryh.h
17315
17316: see if sendmsg exists
17317set sendmsg d_sendmsg
17318eval $inlibc
17319
17320: see if setegid exists
17321set setegid d_setegid
17322eval $inlibc
17323
17324: see if seteuid exists
17325set seteuid d_seteuid
17326eval $inlibc
17327
17328: see if setgrent exists
17329set setgrent d_setgrent
17330eval $inlibc
17331
17332: see if setgrent_r exists
17333set setgrent_r d_setgrent_r
17334eval $inlibc
17335case "$d_setgrent_r" in
17336"$define")
17337	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
17338	case "$d_setgrent_r_proto:$usethreads" in
17339	":define")	d_setgrent_r_proto=define
17340		set d_setgrent_r_proto setgrent_r $hdrs
17341		eval $hasproto ;;
17342	*)	;;
17343	esac
17344	case "$d_setgrent_r_proto" in
17345	define)
17346	case "$setgrent_r_proto" in
17347	''|0) try='int setgrent_r(FILE**);'
17348	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=I_H ;;
17349	esac
17350	case "$setgrent_r_proto" in
17351	''|0) try='void setgrent_r(FILE**);'
17352	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=V_H ;;
17353	esac
17354	case "$setgrent_r_proto" in
17355	''|0)	d_setgrent_r=undef
17356 	        setgrent_r_proto=0
17357		echo "Disabling setgrent_r, cannot determine prototype." >&4 ;;
17358	* )	case "$setgrent_r_proto" in
17359		REENTRANT_PROTO*) ;;
17360		*) setgrent_r_proto="REENTRANT_PROTO_$setgrent_r_proto" ;;
17361		esac
17362		echo "Prototype: $try" ;;
17363	esac
17364	;;
17365	*)	case "$usethreads" in
17366		define) echo "setgrent_r has no prototype, not using it." >&4 ;;
17367		esac
17368		d_setgrent_r=undef
17369		setgrent_r_proto=0
17370		;;
17371	esac
17372	;;
17373*)	setgrent_r_proto=0
17374	;;
17375esac
17376
17377: see if sethostent exists
17378set sethostent d_sethent
17379eval $inlibc
17380
17381: see if sethostent_r exists
17382set sethostent_r d_sethostent_r
17383eval $inlibc
17384case "$d_sethostent_r" in
17385"$define")
17386	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
17387	case "$d_sethostent_r_proto:$usethreads" in
17388	":define")	d_sethostent_r_proto=define
17389		set d_sethostent_r_proto sethostent_r $hdrs
17390		eval $hasproto ;;
17391	*)	;;
17392	esac
17393	case "$d_sethostent_r_proto" in
17394	define)
17395	case "$sethostent_r_proto" in
17396	''|0) try='int sethostent_r(int, struct hostent_data*);'
17397	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=I_ID ;;
17398	esac
17399	case "$sethostent_r_proto" in
17400	''|0) try='void sethostent_r(int, struct hostent_data*);'
17401	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=V_ID ;;
17402	esac
17403	case "$sethostent_r_proto" in
17404	''|0)	d_sethostent_r=undef
17405 	        sethostent_r_proto=0
17406		echo "Disabling sethostent_r, cannot determine prototype." >&4 ;;
17407	* )	case "$sethostent_r_proto" in
17408		REENTRANT_PROTO*) ;;
17409		*) sethostent_r_proto="REENTRANT_PROTO_$sethostent_r_proto" ;;
17410		esac
17411		echo "Prototype: $try" ;;
17412	esac
17413	;;
17414	*)	case "$usethreads" in
17415		define) echo "sethostent_r has no prototype, not using it." >&4 ;;
17416		esac
17417		d_sethostent_r=undef
17418		sethostent_r_proto=0
17419		;;
17420	esac
17421	;;
17422*)	sethostent_r_proto=0
17423	;;
17424esac
17425
17426: see if setitimer exists
17427set setitimer d_setitimer
17428eval $inlibc
17429
17430: see if setlinebuf exists
17431set setlinebuf d_setlinebuf
17432eval $inlibc
17433
17434: see if setlocale exists
17435set setlocale d_setlocale
17436eval $inlibc
17437
17438: see if locale.h is available
17439set locale.h i_locale
17440eval $inhdr
17441
17442: see if setlocale_r exists
17443set setlocale_r d_setlocale_r
17444eval $inlibc
17445case "$d_setlocale_r" in
17446"$define")
17447	hdrs="$i_systypes sys/types.h define stdio.h $i_locale locale.h"
17448	case "$d_setlocale_r_proto:$usethreads" in
17449	":define")	d_setlocale_r_proto=define
17450		set d_setlocale_r_proto setlocale_r $hdrs
17451		eval $hasproto ;;
17452	*)	;;
17453	esac
17454	case "$d_setlocale_r_proto" in
17455	define)
17456	case "$setlocale_r_proto" in
17457	''|0) try='int setlocale_r(int, const char*, char*, int);'
17458	./protochk "$extern_C $try" $hdrs && setlocale_r_proto=I_ICBI ;;
17459	esac
17460	case "$setlocale_r_proto" in
17461	''|0)	d_setlocale_r=undef
17462 	        setlocale_r_proto=0
17463		echo "Disabling setlocale_r, cannot determine prototype." >&4 ;;
17464	* )	case "$setlocale_r_proto" in
17465		REENTRANT_PROTO*) ;;
17466		*) setlocale_r_proto="REENTRANT_PROTO_$setlocale_r_proto" ;;
17467		esac
17468		echo "Prototype: $try" ;;
17469	esac
17470	;;
17471	*)	case "$usethreads" in
17472		define) echo "setlocale_r has no prototype, not using it." >&4 ;;
17473		esac
17474		d_setlocale_r=undef
17475		setlocale_r_proto=0
17476		;;
17477	esac
17478	;;
17479*)	setlocale_r_proto=0
17480	;;
17481esac
17482
17483: see if setnetent exists
17484set setnetent d_setnent
17485eval $inlibc
17486
17487: see if setnetent_r exists
17488set setnetent_r d_setnetent_r
17489eval $inlibc
17490case "$d_setnetent_r" in
17491"$define")
17492	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
17493	case "$d_setnetent_r_proto:$usethreads" in
17494	":define")	d_setnetent_r_proto=define
17495		set d_setnetent_r_proto setnetent_r $hdrs
17496		eval $hasproto ;;
17497	*)	;;
17498	esac
17499	case "$d_setnetent_r_proto" in
17500	define)
17501	case "$setnetent_r_proto" in
17502	''|0) try='int setnetent_r(int, struct netent_data*);'
17503	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=I_ID ;;
17504	esac
17505	case "$setnetent_r_proto" in
17506	''|0) try='void setnetent_r(int, struct netent_data*);'
17507	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=V_ID ;;
17508	esac
17509	case "$setnetent_r_proto" in
17510	''|0)	d_setnetent_r=undef
17511 	        setnetent_r_proto=0
17512		echo "Disabling setnetent_r, cannot determine prototype." >&4 ;;
17513	* )	case "$setnetent_r_proto" in
17514		REENTRANT_PROTO*) ;;
17515		*) setnetent_r_proto="REENTRANT_PROTO_$setnetent_r_proto" ;;
17516		esac
17517		echo "Prototype: $try" ;;
17518	esac
17519	;;
17520	*)	case "$usethreads" in
17521		define) echo "setnetent_r has no prototype, not using it." >&4 ;;
17522		esac
17523		d_setnetent_r=undef
17524		setnetent_r_proto=0
17525		;;
17526	esac
17527	;;
17528*)	setnetent_r_proto=0
17529	;;
17530esac
17531
17532: see if setprotoent exists
17533set setprotoent d_setpent
17534eval $inlibc
17535
17536: see if setpgid exists
17537set setpgid d_setpgid
17538eval $inlibc
17539
17540: see if setpgrp2 exists
17541set setpgrp2 d_setpgrp2
17542eval $inlibc
17543
17544: see if setpriority exists
17545set setpriority d_setprior
17546eval $inlibc
17547
17548: see if setproctitle exists
17549set setproctitle d_setproctitle
17550eval $inlibc
17551
17552: see if setprotoent_r exists
17553set setprotoent_r d_setprotoent_r
17554eval $inlibc
17555case "$d_setprotoent_r" in
17556"$define")
17557	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
17558	case "$d_setprotoent_r_proto:$usethreads" in
17559	":define")	d_setprotoent_r_proto=define
17560		set d_setprotoent_r_proto setprotoent_r $hdrs
17561		eval $hasproto ;;
17562	*)	;;
17563	esac
17564	case "$d_setprotoent_r_proto" in
17565	define)
17566	case "$setprotoent_r_proto" in
17567	''|0) try='int setprotoent_r(int, struct protoent_data*);'
17568	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=I_ID ;;
17569	esac
17570	case "$setprotoent_r_proto" in
17571	''|0) try='void setprotoent_r(int, struct protoent_data*);'
17572	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=V_ID ;;
17573	esac
17574	case "$setprotoent_r_proto" in
17575	''|0)	d_setprotoent_r=undef
17576 	        setprotoent_r_proto=0
17577		echo "Disabling setprotoent_r, cannot determine prototype." >&4 ;;
17578	* )	case "$setprotoent_r_proto" in
17579		REENTRANT_PROTO*) ;;
17580		*) setprotoent_r_proto="REENTRANT_PROTO_$setprotoent_r_proto" ;;
17581		esac
17582		echo "Prototype: $try" ;;
17583	esac
17584	;;
17585	*)	case "$usethreads" in
17586		define) echo "setprotoent_r has no prototype, not using it." >&4 ;;
17587		esac
17588		d_setprotoent_r=undef
17589		setprotoent_r_proto=0
17590		;;
17591	esac
17592	;;
17593*)	setprotoent_r_proto=0
17594	;;
17595esac
17596
17597: see if setpwent exists
17598set setpwent d_setpwent
17599eval $inlibc
17600
17601: see if setpwent_r exists
17602set setpwent_r d_setpwent_r
17603eval $inlibc
17604case "$d_setpwent_r" in
17605"$define")
17606	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
17607	case "$d_setpwent_r_proto:$usethreads" in
17608	":define")	d_setpwent_r_proto=define
17609		set d_setpwent_r_proto setpwent_r $hdrs
17610		eval $hasproto ;;
17611	*)	;;
17612	esac
17613	case "$d_setpwent_r_proto" in
17614	define)
17615	case "$setpwent_r_proto" in
17616	''|0) try='int setpwent_r(FILE**);'
17617	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=I_H ;;
17618	esac
17619	case "$setpwent_r_proto" in
17620	''|0) try='void setpwent_r(FILE**);'
17621	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=V_H ;;
17622	esac
17623	case "$setpwent_r_proto" in
17624	''|0)	d_setpwent_r=undef
17625 	        setpwent_r_proto=0
17626		echo "Disabling setpwent_r, cannot determine prototype." >&4 ;;
17627	* )	case "$setpwent_r_proto" in
17628		REENTRANT_PROTO*) ;;
17629		*) setpwent_r_proto="REENTRANT_PROTO_$setpwent_r_proto" ;;
17630		esac
17631		echo "Prototype: $try" ;;
17632	esac
17633	;;
17634	*)	case "$usethreads" in
17635		define) echo "setpwent_r has no prototype, not using it." >&4 ;;
17636		esac
17637		d_setpwent_r=undef
17638		setpwent_r_proto=0
17639		;;
17640	esac
17641	;;
17642*)	setpwent_r_proto=0
17643	;;
17644esac
17645
17646: see if setregid exists
17647set setregid d_setregid
17648eval $inlibc
17649set setresgid d_setresgid
17650eval $inlibc
17651
17652: see if setreuid exists
17653set setreuid d_setreuid
17654eval $inlibc
17655set setresuid d_setresuid
17656eval $inlibc
17657
17658: see if setrgid exists
17659set setrgid d_setrgid
17660eval $inlibc
17661
17662: see if setruid exists
17663set setruid d_setruid
17664eval $inlibc
17665
17666: see if setservent exists
17667set setservent d_setsent
17668eval $inlibc
17669
17670: see if setservent_r exists
17671set setservent_r d_setservent_r
17672eval $inlibc
17673case "$d_setservent_r" in
17674"$define")
17675	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
17676	case "$d_setservent_r_proto:$usethreads" in
17677	":define")	d_setservent_r_proto=define
17678		set d_setservent_r_proto setservent_r $hdrs
17679		eval $hasproto ;;
17680	*)	;;
17681	esac
17682	case "$d_setservent_r_proto" in
17683	define)
17684	case "$setservent_r_proto" in
17685	''|0) try='int setservent_r(int, struct servent_data*);'
17686	./protochk "$extern_C $try" $hdrs && setservent_r_proto=I_ID ;;
17687	esac
17688	case "$setservent_r_proto" in
17689	''|0) try='void setservent_r(int, struct servent_data*);'
17690	./protochk "$extern_C $try" $hdrs && setservent_r_proto=V_ID ;;
17691	esac
17692	case "$setservent_r_proto" in
17693	''|0)	d_setservent_r=undef
17694 	        setservent_r_proto=0
17695		echo "Disabling setservent_r, cannot determine prototype." >&4 ;;
17696	* )	case "$setservent_r_proto" in
17697		REENTRANT_PROTO*) ;;
17698		*) setservent_r_proto="REENTRANT_PROTO_$setservent_r_proto" ;;
17699		esac
17700		echo "Prototype: $try" ;;
17701	esac
17702	;;
17703	*)	case "$usethreads" in
17704		define) echo "setservent_r has no prototype, not using it." >&4 ;;
17705		esac
17706		d_setservent_r=undef
17707		setservent_r_proto=0
17708		;;
17709	esac
17710	;;
17711*)	setservent_r_proto=0
17712	;;
17713esac
17714
17715: see if setsid exists
17716set setsid d_setsid
17717eval $inlibc
17718
17719: see if setvbuf exists
17720set setvbuf d_setvbuf
17721eval $inlibc
17722
17723: see if shmctl exists
17724set shmctl d_shmctl
17725eval $inlibc
17726
17727: see if shmget exists
17728set shmget d_shmget
17729eval $inlibc
17730
17731: see if shmat exists
17732set shmat d_shmat
17733eval $inlibc
17734: see what shmat returns
17735case "$d_shmat" in
17736"$define")
17737	$cat >shmat.c <<'END'
17738#include <sys/shm.h>
17739void *shmat();
17740END
17741	if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
17742		shmattype='void *'
17743	else
17744		shmattype='char *'
17745	fi
17746	echo "and it returns ($shmattype)." >&4
17747	: see if a prototype for shmat is available
17748	xxx=`./findhdr sys/shm.h`
17749	$cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
17750	if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
17751		val="$define"
17752	else
17753		val="$undef"
17754	fi
17755	$rm -f shmat.[co]
17756	;;
17757*)
17758	val="$undef"
17759	;;
17760esac
17761set d_shmatprototype
17762eval $setvar
17763
17764: see if shmdt exists
17765set shmdt d_shmdt
17766eval $inlibc
17767
17768: see how much of the 'shm*(2)' library is present.
17769h_shm=true
17770echo " "
17771case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
17772*"$undef"*) h_shm=false;;
17773esac
17774case "$osname" in
17775freebsd)
17776    case "`ipcs 2>&1`" in
17777    "SVID shared memory"*"not configured"*)
17778	echo "Your $osname does not have the shm*(2) configured." >&4
17779        h_shm=false
17780	val="$undef"
17781	set shmctl d_shmctl
17782	eval $setvar
17783	set shmget d_shmget
17784	eval $setvar
17785	set shmat d_shmat
17786	eval $setvar
17787	set shmdt d_shmdt
17788	eval $setvar
17789	;;
17790    esac
17791    ;;
17792esac
17793: we could also check for sys/ipc.h ...
17794if $h_shm && $test `./findhdr sys/shm.h`; then
17795	echo "You have the full shm*(2) library." >&4
17796	val="$define"
17797else
17798	echo "You don't have the full shm*(2) library." >&4
17799	val="$undef"
17800fi
17801set d_shm
17802eval $setvar
17803
17804: see if we have sigaction
17805echo " "
17806if set sigaction val -f d_sigaction; eval $csym; $val; then
17807	echo 'sigaction() found.' >&4
17808	$cat > try.c <<EOP
17809#include <stdio.h>
17810#include <sys/types.h>
17811#include <signal.h>
17812#$i_stdlib I_STDLIB
17813#ifdef I_STDLIB
17814#include <stdlib.h>
17815#endif
17816int main()
17817{
17818    struct sigaction act, oact;
17819    act.sa_flags = 0;
17820    oact.sa_handler = 0;
17821    /* so that act and oact are used */
17822    exit(act.sa_flags == 0 &&  oact.sa_handler == 0);
17823}
17824EOP
17825	set try
17826	if eval $compile_ok; then
17827		val="$define"
17828	else
17829		echo "But you don't seem to have a usable struct sigaction." >&4
17830		val="$undef"
17831	fi
17832else
17833	echo 'sigaction NOT found.' >&4
17834	val="$undef"
17835fi
17836set d_sigaction; eval $setvar
17837$rm_try
17838
17839: see if this is a sunmath.h system
17840set sunmath.h i_sunmath
17841eval $inhdr
17842
17843: see if signbit exists
17844$echo $n "Checking to see if you have signbit() available to work on $nvtype... $c" >&4
17845$cat >try.c <<EOCP
17846#$i_math I_MATH
17847#$i_sunmath I_SUNMATH
17848#ifdef I_MATH
17849#  include <math.h>
17850#endif
17851#ifdef I_SUNMATH  /* Solaris special math library */
17852#  include <sunmath.h>
17853#endif
17854#define NV $nvtype
17855int main(int argc, char **argv)
17856{
17857    NV x = 0.0;
17858    NV y = -0.0;
17859    if ((signbit(x) == 0) && (signbit(y) != 0))
17860	return 0;
17861    else
17862	return 1;
17863}
17864EOCP
17865val="$undef"
17866set try
17867if eval $compile; then
17868    if $run ./try; then
17869        $echo "Yes." >&4
17870	val="$define"
17871    else
17872        $echo "Signbit seems to be available, but doesn't work as I expected."
17873        $echo "I won't use it." >&4
17874	val="$undef"
17875    fi
17876else
17877    $echo "Nope." >&4
17878    dflt="$undef"
17879fi
17880set d_signbit
17881eval $setvar
17882$rm_try
17883
17884: see if sigprocmask exists
17885set sigprocmask d_sigprocmask
17886eval $inlibc
17887
17888: see if sigsetjmp exists
17889echo " "
17890case "$d_sigsetjmp" in
17891'')
17892	$cat >try.c <<EOP
17893#include <setjmp.h>
17894#$i_stdlib I_STDLIB
17895#ifdef I_STDLIB
17896#include <stdlib.h>
17897#endif
17898sigjmp_buf env;
17899int set = 1;
17900int main()
17901{
17902	if (sigsetjmp(env,1))
17903		exit(set);
17904	set = 0;
17905	siglongjmp(env, 1);
17906	exit(1);
17907}
17908EOP
17909	set try
17910	if eval $compile; then
17911		if $run ./try >/dev/null 2>&1; then
17912			echo "POSIX sigsetjmp found." >&4
17913			val="$define"
17914		else
17915			$cat >&4 <<EOM
17916Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
17917I'll ignore them.
17918EOM
17919			val="$undef"
17920		fi
17921	else
17922		echo "sigsetjmp not found." >&4
17923		val="$undef"
17924	fi
17925	;;
17926*) val="$d_sigsetjmp"
17927	case "$d_sigsetjmp" in
17928	$define) echo "POSIX sigsetjmp found." >&4;;
17929	$undef) echo "sigsetjmp not found." >&4;;
17930	esac
17931	;;
17932esac
17933set d_sigsetjmp
17934eval $setvar
17935$rm_try
17936
17937: see if snprintf exists
17938set snprintf d_snprintf
17939eval $inlibc
17940
17941: see if vsnprintf exists
17942set vsnprintf d_vsnprintf
17943eval $inlibc
17944
17945case "$d_snprintf-$d_vsnprintf" in
17946"$define-$define")
17947    $cat <<EOM
17948Checking whether your snprintf() and vsnprintf() work okay...
17949EOM
17950    $cat >try.c <<'EOCP'
17951/* v?snprintf testing logic courtesy of Russ Allbery.
17952 * According to C99:
17953 * - if the buffer is too short it still must be \0-terminated
17954 * - if the buffer is too short the potentially required length
17955 *   must be returned and not -1
17956 * - if the buffer is NULL the potentially required length
17957 *   must be returned and not -1 or core dump
17958 */
17959#include <stdio.h>
17960#include <stdarg.h>
17961
17962char buf[2];
17963
17964int test (char *format, ...)
17965{
17966    va_list args;
17967    int count;
17968
17969    va_start (args, format);
17970    count = vsnprintf (buf, sizeof buf, format, args);
17971    va_end (args);
17972    return count;
17973}
17974
17975int main ()
17976{
17977    return ((test ("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0'
17978             && snprintf (NULL, 0, "%s", "abcd") == 4) ? 0 : 1);
17979}
17980EOCP
17981    set try
17982    if eval $compile; then
17983	`$run ./try`
17984	case "$?" in
17985	0) echo "Your snprintf() and vsnprintf() seem to be working okay." ;;
17986	*) cat <<EOM >&4
17987Your snprintf() and snprintf() don't seem to be working okay.
17988EOM
17989	   d_snprintf="$undef"
17990	   d_vsnprintf="$undef"
17991	   ;;
17992	esac
17993    else
17994	echo "(I can't seem to compile the test program--assuming they don't)"
17995	d_snprintf="$undef"
17996	d_vsnprintf="$undef"
17997    fi
17998    $rm_try
17999    ;;
18000esac
18001
18002: see if sockatmark exists
18003set sockatmark d_sockatmark
18004eval $inlibc
18005
18006: see if prototype for sockatmark is available
18007echo " "
18008set d_sockatmarkproto sockatmark $d_socket sys/socket.h
18009eval $hasproto
18010
18011: see if socks5_init exists
18012set socks5_init d_socks5_init
18013eval $inlibc
18014
18015: see if sprintf returns the length of the string in the buffer as per ANSI
18016$echo "Checking whether sprintf returns the length of the string..." >&4
18017$cat <<EOP >try.c
18018#include <stdio.h>
18019#$i_stdlib I_STDLIB
18020#ifdef I_STDLIB
18021#include <stdlib.h>
18022#endif
18023#$i_string I_STRING
18024#ifdef I_STRING
18025#  include <string.h>
18026#else
18027#  include <strings.h>
18028#endif
18029#$i_math I_MATH
18030#ifdef I_MATH
18031#include <math.h>
18032#endif
18033
18034char buffer[256];
18035
18036int check (size_t expect, int test) {
18037  size_t got = strlen(buffer);
18038  if (expect == got)
18039    return 0;
18040
18041  printf("expected %ld, got %ld in test %d '%s'\n", (long) expect, (long) got,
18042       test, buffer);
18043  exit (test);
18044}
18045
18046int main(int argc, char **argv) {
18047  int test = 0;
18048
18049  check(sprintf(buffer, ""), ++test);
18050  check(sprintf(buffer, "%s %s", "perl", "rules"), ++test);
18051  check(sprintf(buffer, "I like %g", atan2(0,-1)), ++test);
18052
18053  return 0;
18054}
18055EOP
18056set try
18057
18058if eval $compile; then
18059    xxx="`$run ./try`"
18060    case "$?" in
18061	0) cat >&4 <<EOM
18062sprintf returns the length of the string (as ANSI says it should)
18063EOM
18064	d_sprintf_returns_strlen="$define"
18065	;;
18066	*) cat >&4 <<EOM
18067sprintf does not return the length of the string (how old is this system?)
18068EOM
18069	d_sprintf_returns_strlen="$undef"
18070        ;;
18071    esac
18072else
18073    echo "(I can't seem to compile the test program--assuming it doesn't)" >&4
18074    d_sprintf_returns_strlen="$undef"
18075fi
18076$rm_try
18077
18078: see if srand48_r exists
18079set srand48_r d_srand48_r
18080eval $inlibc
18081case "$d_srand48_r" in
18082"$define")
18083	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
18084	case "$d_srand48_r_proto:$usethreads" in
18085	":define")	d_srand48_r_proto=define
18086		set d_srand48_r_proto srand48_r $hdrs
18087		eval $hasproto ;;
18088	*)	;;
18089	esac
18090	case "$d_srand48_r_proto" in
18091	define)
18092	case "$srand48_r_proto" in
18093	''|0) try='int srand48_r(long, struct drand48_data*);'
18094	./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;;
18095	esac
18096	case "$srand48_r_proto" in
18097	''|0)	d_srand48_r=undef
18098 	        srand48_r_proto=0
18099		echo "Disabling srand48_r, cannot determine prototype." >&4 ;;
18100	* )	case "$srand48_r_proto" in
18101		REENTRANT_PROTO*) ;;
18102		*) srand48_r_proto="REENTRANT_PROTO_$srand48_r_proto" ;;
18103		esac
18104		echo "Prototype: $try" ;;
18105	esac
18106	;;
18107	*)	case "$usethreads" in
18108		define) echo "srand48_r has no prototype, not using it." >&4 ;;
18109		esac
18110		d_srand48_r=undef
18111		srand48_r_proto=0
18112		;;
18113	esac
18114	;;
18115*)	srand48_r_proto=0
18116	;;
18117esac
18118
18119: see if srandom_r exists
18120set srandom_r d_srandom_r
18121eval $inlibc
18122case "$d_srandom_r" in
18123"$define")
18124	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
18125	case "$d_srandom_r_proto:$usethreads" in
18126	":define")	d_srandom_r_proto=define
18127		set d_srandom_r_proto srandom_r $hdrs
18128		eval $hasproto ;;
18129	*)	;;
18130	esac
18131	case "$d_srandom_r_proto" in
18132	define)
18133	case "$srandom_r_proto" in
18134	''|0) try='int srandom_r(unsigned int, struct random_data*);'
18135	./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;;
18136	esac
18137	case "$srandom_r_proto" in
18138	''|0)	d_srandom_r=undef
18139 	        srandom_r_proto=0
18140		echo "Disabling srandom_r, cannot determine prototype." >&4 ;;
18141	* )	case "$srandom_r_proto" in
18142		REENTRANT_PROTO*) ;;
18143		*) srandom_r_proto="REENTRANT_PROTO_$srandom_r_proto" ;;
18144		esac
18145		echo "Prototype: $try" ;;
18146	esac
18147	;;
18148	*)	case "$usethreads" in
18149		define) echo "srandom_r has no prototype, not using it." >&4 ;;
18150		esac
18151		d_srandom_r=undef
18152		srandom_r_proto=0
18153		;;
18154	esac
18155	;;
18156*)	srandom_r_proto=0
18157	;;
18158esac
18159
18160: see if prototype for setresgid is available
18161echo " "
18162set d_sresgproto setresgid $i_unistd unistd.h
18163eval $hasproto
18164
18165: see if prototype for setresuid is available
18166echo " "
18167set d_sresuproto setresuid $i_unistd unistd.h
18168eval $hasproto
18169
18170: see if sys/stat.h is available
18171set sys/stat.h i_sysstat
18172eval $inhdr
18173
18174: see if stat knows about block sizes
18175echo " "
18176echo "Checking to see if your struct stat has st_blocks field..." >&4
18177set d_statblks stat st_blocks $i_sysstat sys/stat.h
18178eval $hasfield
18179
18180: see if this is a sys/vfs.h system
18181set sys/vfs.h i_sysvfs
18182eval $inhdr
18183
18184: see if this is a sys/statfs.h system
18185set sys/statfs.h i_sysstatfs
18186eval $inhdr
18187
18188: Check for statfs_s
18189echo " "
18190echo "Checking to see if your system supports struct statfs..." >&4
18191set d_statfs_s statfs $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h $i_sysvfs sys/vfs.h $i_sysstatfs sys/statfs.h
18192eval $hasstruct
18193case "$d_statfs_s" in
18194"$define")      echo "Yes, it does."   ;;
18195*)              echo "No, it doesn't." ;;
18196esac
18197
18198
18199: see if struct statfs knows about f_flags
18200case "$d_statfs_s" in
18201define)
18202	echo " "
18203	echo "Checking to see if your struct statfs has f_flags field..." >&4
18204	set d_statfs_f_flags statfs f_flags $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h $i_sysvfs sys/vfs.h $i_sysstatfs sys/statfs.h
18205	eval $hasfield
18206	;;
18207*)	val="$undef"
18208	set d_statfs_f_flags
18209	eval $setvar
18210	;;
18211esac
18212case "$d_statfs_f_flags" in
18213"$define")      echo "Yes, it does."   ;;
18214*)              echo "No, it doesn't." ;;
18215esac
18216
18217: see what flavor, if any, of static inline is supported
18218echo " "
18219echo "Checking to see if your system supports static inline..."
18220$cat > try.c <<'EOCP'
18221#include <stdlib.h>
18222extern int f_via_a(int x);
18223extern int f_via_b(int x);
18224int main(int argc, char **argv)
18225{
18226    int y;
18227
18228    y = f_via_a(0);
18229#ifdef USE_B
18230    y = f_via_b(0);
18231#endif
18232    if (y == 42) {
18233        return EXIT_SUCCESS;
18234    }
18235    else {
18236        return EXIT_FAILURE;
18237    }
18238}
18239EOCP
18240$cat > a.c <<'EOCP'
18241static INLINE int f(int x) {
18242    int y;
18243    y = x + 42;
18244    return y;
18245}
18246
18247int f_via_a(int x)
18248{
18249    return f(x);
18250}
18251EOCP
18252$cat > b.c <<'EOCP'
18253extern int f(int x);
18254
18255int f_via_b(int x)
18256{
18257    return f(x);
18258}
18259EOCP
18260
18261# Respect a hint (or previous) value for perl_static_inline, if there is one.
18262case "$perl_static_inline" in
18263'')	# Check the various possibilities, and break out on success.
18264	# For gcc, prefer __inline__, which will still permit
18265	# cflags.SH to add in -ansi.
18266	case "$gccversion" in
18267		'') xxx="inline __inline__ __inline _inline";;
18268		*)  xxx="__inline__ inline __inline _inline";;
18269	esac
18270	for inline in $xxx; do
18271		set try -DINLINE=$inline a.c
18272		if eval $compile && $run ./try; then
18273			# Now make sure there is no external linkage of static
18274			# functions
18275			set try -DINLINE=$inline -DUSE_B a.c b.c
18276			if eval $compile && $run ./try; then
18277				$echo "Your compiler supports static $inline, " >&4
18278				$echo "but it also creates an external definition," >&4
18279				$echo "so I won't use it." >&4
18280				val=$undef
18281			else
18282				$echo "Your compiler supports static $inline." >&4
18283				val=$define
18284				perl_static_inline="static $inline";
18285				break;
18286			fi
18287		else
18288			$echo "Your compiler does NOT support static $inline." >&4
18289			val="$undef"
18290		fi
18291	done
18292	;;
18293*inline*) # Some variant of inline exists.
18294	echo "Keeping your $hint value of $perl_static_inline."
18295	val=$define
18296	;;
18297static)  # No inline capabilities
18298	echo "Keeping your $hint value of $perl_static_inline."
18299	val=$undef
18300	;;
18301*)  # Unrecognized previous value -- blindly trust the supplied
18302	# value and hope it makes sense.  Use old value for
18303	# d_static_inline, if there is one.
18304	echo "Keeping your $hint value of $perl_static_inline."
18305	case "$d_static_inline" in
18306		'') val=$define ;;
18307		*)  val=$d_static_inline ;;
18308	esac
18309	;;
18310esac
18311# Fallback to plain 'static' if nothing worked.
18312case "$perl_static_inline" in
18313'')
18314	perl_static_inline="static"
18315	val=$undef
18316	;;
18317esac
18318set d_static_inline
18319eval $setvar
18320$rm -f a.[co] b.[co]
18321$rm_try
18322
18323: Check stream access
18324$cat >&4 <<EOM
18325Checking how to access stdio streams by file descriptor number...
18326EOM
18327case "$stdio_stream_array" in
18328'') 	$cat >try.c <<EOCP
18329#include <stdio.h>
18330int main() {
18331  if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
18332    printf("yes\n");
18333}
18334EOCP
18335	for s in _iob __iob __sF
18336	do
18337	        set try -DSTDIO_STREAM_ARRAY=$s
18338		if eval $compile; then
18339		    	case "`$run ./try`" in
18340			yes)	stdio_stream_array=$s; break ;;
18341			esac
18342		fi
18343	done
18344	$rm_try
18345esac
18346case "$stdio_stream_array" in
18347'')	$cat >&4 <<EOM
18348I can't figure out how to access stdio streams by file descriptor number.
18349EOM
18350	d_stdio_stream_array="$undef"
18351	;;
18352*)	$cat >&4 <<EOM
18353You can access stdio streams by file descriptor number by the $stdio_stream_array array.
18354EOM
18355	d_stdio_stream_array="$define"
18356	;;
18357esac
18358
18359: see if strcoll exists
18360set strcoll d_strcoll
18361eval $inlibc
18362
18363: check for structure copying
18364echo " "
18365echo "Checking to see if your C compiler can copy structs..." >&4
18366$cat >try.c <<'EOCP'
18367int main()
18368{
18369	struct blurfl {
18370		int dyick;
18371	} foo, bar;
18372
18373	foo = bar;
18374}
18375EOCP
18376if $cc -c try.c >/dev/null 2>&1 ; then
18377	val="$define"
18378	echo "Yup, it can."
18379else
18380	val="$undef"
18381	echo "Nope, it can't."
18382fi
18383set d_strctcpy
18384eval $setvar
18385$rm_try
18386
18387: see if strerror and/or sys_errlist[] exist
18388echo " "
18389if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
18390    if set strerror val -f d_strerror; eval $csym; $val; then
18391		echo 'strerror() found.' >&4
18392		d_strerror="$define"
18393		d_strerrm='strerror(e)'
18394		if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
18395			echo "(You also have sys_errlist[], so we could roll our own strerror.)"
18396			d_syserrlst="$define"
18397		else
18398			echo "(Since you don't have sys_errlist[], strerror() is welcome.)"
18399			d_syserrlst="$undef"
18400		fi
18401    elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
18402			$contains '#[ 	]*define.*strerror' "$xxx" >/dev/null 2>&1; then
18403		echo 'strerror() found in string header.' >&4
18404		d_strerror="$define"
18405		d_strerrm='strerror(e)'
18406		if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
18407			echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
18408				d_syserrlst="$define"
18409		else
18410			echo "(You don't appear to have any sys_errlist[], how can this be?)"
18411			d_syserrlst="$undef"
18412		fi
18413    elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
18414		echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
18415		d_strerror="$undef"
18416		d_syserrlst="$define"
18417		d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
18418    else
18419		echo 'strerror() and sys_errlist[] NOT found.' >&4
18420		d_strerror="$undef"
18421		d_syserrlst="$undef"
18422		d_strerrm='"unknown"'
18423    fi
18424fi
18425
18426: see if strerror_r exists
18427set strerror_r d_strerror_r
18428eval $inlibc
18429case "$d_strerror_r" in
18430"$define")
18431	hdrs="$i_systypes sys/types.h define stdio.h $i_string string.h"
18432	case "$d_strerror_r_proto:$usethreads" in
18433	":define")	d_strerror_r_proto=define
18434		set d_strerror_r_proto strerror_r $hdrs
18435		eval $hasproto ;;
18436	*)	;;
18437	esac
18438	case "$d_strerror_r_proto" in
18439	define)
18440	case "$strerror_r_proto" in
18441	''|0) try='int strerror_r(int, char*, size_t);'
18442	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBW ;;
18443	esac
18444	case "$strerror_r_proto" in
18445	''|0) try='int strerror_r(int, char*, int);'
18446	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBI ;;
18447	esac
18448	case "$strerror_r_proto" in
18449	''|0) try='char* strerror_r(int, char*, size_t);'
18450	./protochk "$extern_C $try" $hdrs && strerror_r_proto=B_IBW ;;
18451	esac
18452	case "$strerror_r_proto" in
18453	''|0)	d_strerror_r=undef
18454 	        strerror_r_proto=0
18455		echo "Disabling strerror_r, cannot determine prototype." >&4 ;;
18456	* )	case "$strerror_r_proto" in
18457		REENTRANT_PROTO*) ;;
18458		*) strerror_r_proto="REENTRANT_PROTO_$strerror_r_proto" ;;
18459		esac
18460		echo "Prototype: $try" ;;
18461	esac
18462	;;
18463	*)	case "$usethreads" in
18464		define) echo "strerror_r has no prototype, not using it." >&4 ;;
18465		esac
18466		d_strerror_r=undef
18467		strerror_r_proto=0
18468		;;
18469	esac
18470	;;
18471*)	strerror_r_proto=0
18472	;;
18473esac
18474
18475: see if strftime exists
18476set strftime d_strftime
18477eval $inlibc
18478
18479: see if strlcat exists
18480set strlcat d_strlcat
18481eval $inlibc
18482
18483: see if strlcpy exists
18484set strlcpy d_strlcpy
18485eval $inlibc
18486
18487: see if strtod exists
18488set strtod d_strtod
18489eval $inlibc
18490
18491: see if strtol exists
18492set strtol d_strtol
18493eval $inlibc
18494
18495: see if strtold exists
18496set strtold d_strtold
18497eval $inlibc
18498
18499: see if strtoll exists
18500set strtoll d_strtoll
18501eval $inlibc
18502
18503case "$d_longlong-$d_strtoll" in
18504"$define-$define")
18505	$cat <<EOM
18506Checking whether your strtoll() works okay...
18507EOM
18508	$cat >try.c <<'EOCP'
18509#include <errno.h>
18510#ifdef __hpux
18511#define strtoll __strtoll
18512#endif
18513#ifdef __EMX__
18514#define strtoll _strtoll
18515#endif
18516#include <stdio.h>
18517extern long long int strtoll(char *s, char **, int);
18518static int bad = 0;
18519int check(char *s, long long ell, int een) {
18520	long long gll;
18521	errno = 0;
18522	gll = strtoll(s, 0, 10);
18523	if (!((gll == ell) && (errno == een)))
18524		bad++;
18525}
18526int main() {
18527	check(" 1",                                      1LL, 0);
18528	check(" 0",                                      0LL, 0);
18529	check("-1",                                     -1LL, 0);
18530	check("-9223372036854775808", -9223372036854775808LL, 0);
18531	check("-9223372036854775808", -9223372036854775808LL, 0);
18532	check(" 9223372036854775807",  9223372036854775807LL, 0);
18533	check("-9223372036854775808", -9223372036854775808LL, 0);
18534	check(" 9223372036854775808",  9223372036854775807LL, ERANGE);
18535	check("-9223372036854775809", -9223372036854775808LL, ERANGE);
18536	if (!bad)
18537		printf("ok\n");
18538}
18539EOCP
18540	set try
18541	if eval $compile; then
18542		yyy=`$run ./try`
18543		case "$yyy" in
18544		ok) echo "Your strtoll() seems to be working okay." ;;
18545		*) cat <<EOM >&4
18546Your strtoll() doesn't seem to be working okay.
18547EOM
18548		   d_strtoll="$undef"
18549		   ;;
18550		esac
18551	else
18552		echo "(I can't seem to compile the test program--assuming it doesn't)"
18553		d_strtoll="$undef"
18554	fi
18555	;;
18556esac
18557
18558: see if strtoq exists
18559set strtoq d_strtoq
18560eval $inlibc
18561
18562: see if strtoul exists
18563set strtoul d_strtoul
18564eval $inlibc
18565
18566case "$d_strtoul" in
18567"$define")
18568	$cat <<EOM
18569Checking whether your strtoul() works okay...
18570EOM
18571	$cat >try.c <<'EOCP'
18572#include <errno.h>
18573#include <stdio.h>
18574extern unsigned long int strtoul(char *s, char **, int);
18575static int bad = 0;
18576void check(char *s, unsigned long eul, int een) {
18577	unsigned long gul;
18578	errno = 0;
18579	gul = strtoul(s, 0, 10);
18580	if (!((gul == eul) && (errno == een)))
18581		bad++;
18582}
18583int main() {
18584	check(" 1", 1L, 0);
18585	check(" 0", 0L, 0);
18586EOCP
18587	case "$longsize" in
18588	8)
18589	    $cat >>try.c <<'EOCP'
18590	check("18446744073709551615", 18446744073709551615UL, 0);
18591	check("18446744073709551616", 18446744073709551615UL, ERANGE);
18592#if 0 /* strtoul() for /^-/ strings is undefined. */
18593	check("-1", 18446744073709551615UL, 0);
18594	check("-18446744073709551614", 2, 0);
18595	check("-18446744073709551615", 1, 0);
18596       	check("-18446744073709551616", 18446744073709551615UL, ERANGE);
18597	check("-18446744073709551617", 18446744073709551615UL, ERANGE);
18598#endif
18599EOCP
18600		;;
18601	4)
18602		    $cat >>try.c <<'EOCP'
18603	check("4294967295", 4294967295UL, 0);
18604	check("4294967296", 4294967295UL, ERANGE);
18605#if 0 /* strtoul() for /^-/ strings is undefined. */
18606	check("-1", 4294967295UL, 0);
18607	check("-4294967294", 2, 0);
18608	check("-4294967295", 1, 0);
18609       	check("-4294967296", 4294967295UL, ERANGE);
18610	check("-4294967297", 4294967295UL, ERANGE);
18611#endif
18612EOCP
18613		;;
18614	*)
18615: Should we write these tests to be more portable by sprintf-ing
18616: ~0 and then manipulating that char string as input for strtol?
18617		;;
18618	esac
18619	$cat >>try.c <<'EOCP'
18620	if (!bad)
18621		printf("ok\n");
18622	return 0;
18623}
18624EOCP
18625	set try
18626	if eval $compile; then
18627		case "`$run ./try`" in
18628		ok) echo "Your strtoul() seems to be working okay." ;;
18629		*) cat <<EOM >&4
18630Your strtoul() doesn't seem to be working okay.
18631EOM
18632		   d_strtoul="$undef"
18633		   ;;
18634		esac
18635	else
18636		echo "(I can't seem to compile the test program--assuming it doesn't)"
18637		d_strtoul="$undef"
18638	fi
18639	;;
18640esac
18641
18642: see if strtoull exists
18643set strtoull d_strtoull
18644eval $inlibc
18645
18646case "$d_longlong-$d_strtoull" in
18647"$define-$define")
18648	$cat <<EOM
18649Checking whether your strtoull() works okay...
18650EOM
18651	$cat >try.c <<'EOCP'
18652#include <errno.h>
18653#ifdef __hpux
18654#define strtoull __strtoull
18655#endif
18656#include <stdio.h>
18657extern unsigned long long int strtoull(char *s, char **, int);
18658static int bad = 0;
18659int check(char *s, long long eull, int een) {
18660	long long gull;
18661	errno = 0;
18662	gull = strtoull(s, 0, 10);
18663	if (!((gull == eull) && (errno == een)))
18664		bad++;
18665}
18666int main() {
18667	check(" 1",                                        1LL, 0);
18668	check(" 0",                                        0LL, 0);
18669	check("18446744073709551615",  18446744073709551615ULL, 0);
18670	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
18671#if 0 /* strtoull() for /^-/ strings is undefined. */
18672	check("-1",                    18446744073709551615ULL, 0);
18673	check("-18446744073709551614",                     2LL, 0);
18674	check("-18446744073709551615",                     1LL, 0);
18675       	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
18676	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
18677#endif
18678	if (!bad)
18679		printf("ok\n");
18680}
18681EOCP
18682	set try
18683	if eval $compile; then
18684		case "`$run ./try`" in
18685		ok) echo "Your strtoull() seems to be working okay." ;;
18686		*) cat <<EOM >&4
18687Your strtoull() doesn't seem to be working okay.
18688EOM
18689		   d_strtoull="$undef"
18690		   ;;
18691		esac
18692	else
18693		echo "(I can't seem to compile the test program--assuming it doesn't)"
18694		d_strtoull="$undef"
18695	fi
18696	;;
18697esac
18698
18699: see if strtouq exists
18700set strtouq d_strtouq
18701eval $inlibc
18702
18703case "$d_strtouq" in
18704"$define")
18705	$cat <<EOM
18706Checking whether your strtouq() works okay...
18707EOM
18708	$cat >try.c <<'EOCP'
18709#include <errno.h>
18710#include <stdio.h>
18711extern unsigned long long int strtouq(char *s, char **, int);
18712static int bad = 0;
18713void check(char *s, unsigned long long eull, int een) {
18714	unsigned long long gull;
18715	errno = 0;
18716	gull = strtouq(s, 0, 10);
18717	if (!((gull == eull) && (errno == een)))
18718		bad++;
18719}
18720int main() {
18721	check(" 1",                                        1LL, 0);
18722	check(" 0",                                        0LL, 0);
18723	check("18446744073709551615",  18446744073709551615ULL, 0);
18724	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
18725#if 0 /* strtouq() for /^-/ strings is undefined. */
18726	check("-1",                    18446744073709551615ULL, 0);
18727	check("-18446744073709551614",                     2LL, 0);
18728	check("-18446744073709551615",                     1LL, 0);
18729       	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
18730	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
18731#endif
18732	if (!bad)
18733		printf("ok\n");
18734	return 0;
18735}
18736EOCP
18737	set try
18738	if eval $compile; then
18739		case "`$run ./try`" in
18740		ok) echo "Your strtouq() seems to be working okay." ;;
18741		*) cat <<EOM >&4
18742Your strtouq() doesn't seem to be working okay.
18743EOM
18744		   d_strtouq="$undef"
18745		   ;;
18746		esac
18747	else
18748		echo "(I can't seem to compile the test program--assuming it doesn't)"
18749		d_strtouq="$undef"
18750	fi
18751	;;
18752esac
18753
18754: see if strxfrm exists
18755set strxfrm d_strxfrm
18756eval $inlibc
18757
18758: see if symlink exists
18759set symlink d_symlink
18760eval $inlibc
18761
18762: see if syscall exists
18763set syscall d_syscall
18764eval $inlibc
18765
18766: see if prototype for syscall is available
18767echo " "
18768set d_syscallproto syscall $i_unistd unistd.h
18769eval $hasproto
18770
18771: see if sysconf exists
18772set sysconf d_sysconf
18773eval $inlibc
18774
18775: see if system exists
18776set system d_system
18777eval $inlibc
18778
18779: see if tcgetpgrp exists
18780set tcgetpgrp d_tcgetpgrp
18781eval $inlibc
18782
18783: see if tcsetpgrp exists
18784set tcsetpgrp d_tcsetpgrp
18785eval $inlibc
18786
18787: see if prototype for telldir is available
18788echo " "
18789set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
18790eval $hasproto
18791
18792: see if time exists
18793echo " "
18794if test "X$d_time" = X -o X"$timetype" = X; then
18795    if set time val -f d_time; eval $csym; $val; then
18796		echo 'time() found.' >&4
18797		val="$define"
18798		rp="What is the type returned by time() on this system?"
18799		set time_t timetype long stdio.h sys/types.h
18800		eval $typedef_ask
18801    else
18802		echo 'time() not found, hope that will do.' >&4
18803		val="$undef"
18804		timetype='int';
18805    fi
18806    set d_time
18807    eval $setvar
18808fi
18809
18810: see if timegm exists
18811set timegm d_timegm
18812eval $inlibc
18813
18814: see if this is a sys/times.h system
18815set sys/times.h i_systimes
18816eval $inhdr
18817
18818: see if times exists
18819echo " "
18820if set times val -f d_times; eval $csym; $val; then
18821	echo 'times() found.' >&4
18822	d_times="$define"
18823	inc=''
18824	case "$i_systimes" in
18825	"$define") inc='sys/times.h';;
18826	esac
18827	rp="What is the type returned by times() on this system?"
18828	set clock_t clocktype long stdio.h sys/types.h $inc
18829	eval $typedef_ask
18830else
18831	echo 'times() NOT found, hope that will do.' >&4
18832	d_times="$undef"
18833	clocktype='int'
18834fi
18835
18836: see if tmpnam_r exists
18837set tmpnam_r d_tmpnam_r
18838eval $inlibc
18839case "$d_tmpnam_r" in
18840"$define")
18841	hdrs="$i_systypes sys/types.h define stdio.h "
18842	case "$d_tmpnam_r_proto:$usethreads" in
18843	":define")	d_tmpnam_r_proto=define
18844		set d_tmpnam_r_proto tmpnam_r $hdrs
18845		eval $hasproto ;;
18846	*)	;;
18847	esac
18848	case "$d_tmpnam_r_proto" in
18849	define)
18850	case "$tmpnam_r_proto" in
18851	''|0) try='char* tmpnam_r(char*);'
18852	./protochk "$extern_C $try" $hdrs && tmpnam_r_proto=B_B ;;
18853	esac
18854	case "$tmpnam_r_proto" in
18855	''|0)	d_tmpnam_r=undef
18856 	        tmpnam_r_proto=0
18857		echo "Disabling tmpnam_r, cannot determine prototype." >&4 ;;
18858	* )	case "$tmpnam_r_proto" in
18859		REENTRANT_PROTO*) ;;
18860		*) tmpnam_r_proto="REENTRANT_PROTO_$tmpnam_r_proto" ;;
18861		esac
18862		echo "Prototype: $try" ;;
18863	esac
18864	;;
18865	*)	case "$usethreads" in
18866		define) echo "tmpnam_r has no prototype, not using it." >&4 ;;
18867		esac
18868		d_tmpnam_r=undef
18869		tmpnam_r_proto=0
18870		;;
18871	esac
18872	;;
18873*)	tmpnam_r_proto=0
18874	;;
18875esac
18876
18877: see if truncate exists
18878set truncate d_truncate
18879eval $inlibc
18880
18881: see if ttyname_r exists
18882set ttyname_r d_ttyname_r
18883eval $inlibc
18884case "$d_ttyname_r" in
18885"$define")
18886	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
18887	case "$d_ttyname_r_proto:$usethreads" in
18888	":define")	d_ttyname_r_proto=define
18889		set d_ttyname_r_proto ttyname_r $hdrs
18890		eval $hasproto ;;
18891	*)	;;
18892	esac
18893	case "$d_ttyname_r_proto" in
18894	define)
18895	case "$ttyname_r_proto" in
18896	''|0) try='int ttyname_r(int, char*, size_t);'
18897	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBW ;;
18898	esac
18899	case "$ttyname_r_proto" in
18900	''|0) try='int ttyname_r(int, char*, int);'
18901	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBI ;;
18902	esac
18903	case "$ttyname_r_proto" in
18904	''|0) try='char* ttyname_r(int, char*, int);'
18905	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=B_IBI ;;
18906	esac
18907	case "$ttyname_r_proto" in
18908	''|0)	d_ttyname_r=undef
18909 	        ttyname_r_proto=0
18910		echo "Disabling ttyname_r, cannot determine prototype." >&4 ;;
18911	* )	case "$ttyname_r_proto" in
18912		REENTRANT_PROTO*) ;;
18913		*) ttyname_r_proto="REENTRANT_PROTO_$ttyname_r_proto" ;;
18914		esac
18915		echo "Prototype: $try" ;;
18916	esac
18917	;;
18918	*)	case "$usethreads" in
18919		define) echo "ttyname_r has no prototype, not using it." >&4 ;;
18920		esac
18921		d_ttyname_r=undef
18922		ttyname_r_proto=0
18923		;;
18924	esac
18925	;;
18926*)	ttyname_r_proto=0
18927	;;
18928esac
18929
18930: see if tzname[] exists
18931echo " "
18932if set tzname val -a d_tzname; eval $csym; $val; then
18933	val="$define"
18934	echo 'tzname[] found.' >&4
18935else
18936	val="$undef"
18937	echo 'tzname[] NOT found.' >&4
18938fi
18939set d_tzname
18940eval $setvar
18941
18942: Check if is a multiplatform env
18943case "$osname" in
18944next|darwin) multiarch="$define" ;;
18945esac
18946case "$multiarch" in
18947''|[nN]*) multiarch="$undef" ;;
18948esac
18949
18950: check for ordering of bytes in a UV
18951echo " "
18952case "$multiarch" in
18953*$define*)
18954	$cat <<EOM
18955You seem to be doing a multiarchitecture build,
18956skipping the byteorder check.
18957
18958EOM
18959	byteorder='ffff'
18960	;;
18961*)
18962	case "$byteorder" in
18963	'')
18964		$cat <<'EOM'
18965In the following, larger digits indicate more significance.  A big-endian
18966machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
18967little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
18968machines may have weird orders like 3412.  A Cray will report 87654321,
18969an Alpha will report 12345678. If the test program works the default is
18970probably right.
18971I'm now running the test program...
18972EOM
18973		$cat >try.c <<EOCP
18974#include <stdio.h>
18975#$i_stdlib I_STDLIB
18976#ifdef I_STDLIB
18977#include <stdlib.h>
18978#endif
18979#include <sys/types.h>
18980typedef $uvtype UV;
18981int main()
18982{
18983	int i;
18984	union {
18985		UV l;
18986		char c[$uvsize];
18987	} u;
18988
18989	if ($uvsize > 4)
18990		u.l = (((UV)0x08070605) << 32) | (UV)0x04030201;
18991	else
18992		u.l = (UV)0x04030201;
18993	for (i = 0; i < $uvsize; i++)
18994		printf("%c", u.c[i]+'0');
18995	printf("\n");
18996	exit(0);
18997}
18998EOCP
18999		xxx_prompt=y
19000		set try
19001		if eval $compile && $run ./try > /dev/null; then
19002			dflt=`$run ./try`
19003			case "$dflt" in
19004			[1-4][1-4][1-4][1-4]|12345678|87654321)
19005				echo "(The test program ran ok.)"
19006				echo "byteorder=$dflt"
19007				xxx_prompt=n
19008			;;
19009			????|????????) echo "(The test program ran ok.)" ;;
19010			*) echo "(The test program didn't run right for some reason.)" ;;
19011			esac
19012		else
19013			dflt='4321'
19014			cat <<'EOM'
19015(I can't seem to compile the test program.  Guessing big-endian...)
19016EOM
19017		fi
19018		case "$xxx_prompt" in
19019		y)
19020			rp="What is the order of bytes in $uvtype?"
19021			. ./myread
19022			byteorder="$ans"
19023			;;
19024		*)	byteorder=$dflt
19025			;;
19026		esac
19027		;;
19028	esac
19029	$rm_try
19030	;;
19031esac
19032
19033: Checking 32bit alignedness
19034$cat <<EOM
19035
19036Checking to see whether you can access character data unalignedly...
19037EOM
19038case "$d_u32align" in
19039'')   $cat >try.c <<EOCP
19040#include <stdio.h>
19041#$i_stdlib I_STDLIB
19042#ifdef I_STDLIB
19043#include <stdlib.h>
19044#endif
19045#define U32 $u32type
19046#define BYTEORDER 0x$byteorder
19047#define U8 $u8type
19048#include <signal.h>
19049#ifdef SIGBUS
19050$signal_t bletch(int s) { exit(4); }
19051#endif
19052int main() {
19053#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
19054    volatile U8 buf[8];
19055    volatile U32 *up;
19056    int i;
19057
19058    if (sizeof(U32) != 4) {
19059	printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
19060	exit(1);
19061    }
19062
19063    fflush(stdout);
19064
19065#ifdef SIGBUS
19066    signal(SIGBUS, bletch);
19067#endif
19068
19069    buf[0] = 0;
19070    buf[1] = 0;
19071    buf[2] = 0;
19072    buf[3] = 1;
19073    buf[4] = 0;
19074    buf[5] = 0;
19075    buf[6] = 0;
19076    buf[7] = 1;
19077
19078    for (i = 0; i < 4; i++) {
19079	up = (U32*)(buf + i);
19080	if (! ((*up == 1 << (8*i)) ||   /* big-endian */
19081	       (*up == 1 << (8*(3-i)))  /* little-endian */
19082	      )
19083	   )
19084	{
19085	    printf("read failed (%x)\n", *up);
19086	    exit(2);
19087	}
19088    }
19089
19090    /* write test */
19091    for (i = 0; i < 4; i++) {
19092	up = (U32*)(buf + i);
19093	*up = 0xBeef;
19094	if (*up != 0xBeef) {
19095	    printf("write failed (%x)\n", *up);
19096	    exit(3);
19097	}
19098    }
19099
19100    exit(0);
19101#else
19102    printf("1\n");
19103    exit(1);
19104#endif
19105    return 0;
19106}
19107EOCP
19108set try
19109if eval $compile_ok; then
19110	echo "(Testing for character data alignment may crash the test.  That's okay.)" >&4
19111	$run ./try 2>&1 >/dev/null
19112	case "$?" in
19113	0)	cat >&4 <<EOM
19114You can access character data pretty unalignedly.
19115EOM
19116		d_u32align="$undef"
19117		;;
19118	*)	cat >&4 <<EOM
19119It seems that you must access character data in an aligned manner.
19120EOM
19121		d_u32align="$define"
19122		;;
19123	esac
19124else
19125	rp='Can you access character data at unaligned addresses?'
19126	dflt='n'
19127	. ./myread
19128	case "$ans" in
19129	[yY]*)	d_u32align="$undef"  ;;
19130	*)	d_u32align="$define" ;;
19131	esac
19132fi
19133$rm_try
19134;;
19135esac
19136
19137: see if ualarm exists
19138set ualarm d_ualarm
19139eval $inlibc
19140
19141: see if umask exists
19142set umask d_umask
19143eval $inlibc
19144
19145: see if unordered exists
19146set unordered d_unordered
19147eval $inlibc
19148
19149: see if unsetenv exists
19150set unsetenv d_unsetenv
19151eval $inlibc
19152
19153: see if usleep exists
19154set usleep d_usleep
19155eval $inlibc
19156
19157: see if prototype for usleep is available
19158echo " "
19159set d_usleepproto usleep $i_unistd unistd.h
19160eval $hasproto
19161
19162: see if ustat exists
19163set ustat d_ustat
19164eval $inlibc
19165
19166: see if closedir exists
19167set closedir d_closedir
19168eval $inlibc
19169
19170case "$d_closedir" in
19171"$define")
19172	echo " "
19173	echo "Checking whether closedir() returns a status..." >&4
19174	cat > try.c <<EOM
19175#$i_dirent I_DIRENT		/**/
19176#$i_sysdir I_SYS_DIR		/**/
19177#$i_sysndir I_SYS_NDIR		/**/
19178#$i_systypes I_SYS_TYPES	/**/
19179
19180#if defined(I_SYS_TYPES)
19181#include <sys/types.h>
19182#endif
19183#if defined(I_DIRENT)
19184#include <dirent.h>
19185#if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
19186#include <sys/dir.h>
19187#endif
19188#else
19189#ifdef I_SYS_NDIR
19190#include <sys/ndir.h>
19191#else
19192#ifdef I_SYS_DIR
19193#ifdef hp9000s500
19194#include <ndir.h>	/* may be wrong in the future */
19195#else
19196#include <sys/dir.h>
19197#endif
19198#endif
19199#endif
19200#endif
19201int main() { return closedir(opendir(".")); }
19202EOM
19203	set try
19204	if eval $compile_ok; then
19205		if $run ./try > /dev/null 2>&1 ; then
19206			echo "Yes, it does."
19207			val="$undef"
19208		else
19209			echo "No, it doesn't."
19210			val="$define"
19211		fi
19212	else
19213		echo "(I can't seem to compile the test program--assuming it doesn't)"
19214		val="$define"
19215	fi
19216	;;
19217*)
19218	val="$undef";
19219	;;
19220esac
19221set d_void_closedir
19222eval $setvar
19223$rm_try
19224
19225: see if there is a wait4
19226set wait4 d_wait4
19227eval $inlibc
19228
19229: see if waitpid exists
19230set waitpid d_waitpid
19231eval $inlibc
19232
19233: see if wcstombs exists
19234set wcstombs d_wcstombs
19235eval $inlibc
19236
19237: see if wctomb exists
19238set wctomb d_wctomb
19239eval $inlibc
19240
19241: see if writev exists
19242set writev d_writev
19243eval $inlibc
19244
19245: preserve RCS keywords in files with variable substitution, grrr
19246Date='$Date'
19247Id='$Id'
19248Log='$Log'
19249RCSfile='$RCSfile'
19250Revision='$Revision'
19251
19252: check for alignment requirements
19253echo " "
19254case "$alignbytes" in
19255    '') echo "Checking alignment constraints..." >&4
19256	if $test "X$uselongdouble" = Xdefine -a "X$d_longdbl" = Xdefine; then
19257	    $cat >try.c <<'EOCP'
19258typedef long double NV;
19259EOCP
19260	else
19261	    $cat >try.c <<'EOCP'
19262typedef double NV;
19263EOCP
19264	fi
19265	$cat >>try.c <<'EOCP'
19266#include <stdio.h>
19267struct foobar {
19268    char foo;
19269    NV bar;
19270} try_algn;
19271int main()
19272{
19273    printf("%d\n", (int)((char *)&try_algn.bar - (char *)&try_algn.foo));
19274    return(0);
19275}
19276EOCP
19277	set try
19278	if eval $compile_ok; then
19279	    dflt=`$run ./try`
19280	else
19281	    dflt='8'
19282	    echo "(I can't seem to compile the test program...)"
19283	fi
19284	case "$multiarch" in
19285	    *$define*)
19286		: The usual safe value is 8, but Darwin with -Duselongdouble
19287		: needs 16.  Hence, we will take 8 as a minimum, but allow
19288		: Configure to pick a larger value if needed.
19289		if $test "$dflt" -lt 8; then
19290		    dflt='8'
19291		    echo "Setting alignment to 8 for multiarch support.">&4
19292		fi
19293		;;
19294	esac
19295	;;
19296    *) dflt="$alignbytes"
19297	;;
19298esac
19299rp="Doubles must be aligned on a how-many-byte boundary?"
19300. ./myread
19301alignbytes="$ans"
19302$rm_try
19303
19304: set the base revision
19305baserev=5.0
19306
19307: Determine if this is an EBCDIC system
19308echo " "
19309echo "Determining whether or not we are on an EBCDIC system..." >&4
19310$cat >try.c <<'EOM'
19311int main()
19312{
19313  if ('M'==0xd4) return 0;
19314  return 1;
19315}
19316EOM
19317
19318case "$BOOTSTRAP_CHARSET" in
19319    Y|y|define) bootstrap_charset=$define	;;
19320    *)		bootstrap_charset=$undef	;;
19321esac
19322
19323val=$undef
19324set try
19325if eval $compile_ok; then
19326	if $run ./try; then
19327		echo "You seem to speak EBCDIC." >&4
19328		val="$define"
19329	else
19330		echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF-8." >&4
19331	fi
19332else
19333	echo "I'm unable to compile the test program." >&4
19334	echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
19335fi
19336$rm_try
19337set ebcdic
19338eval $setvar
19339
19340: length of character in bytes. Is always 1, otherwise it is not C
19341: This used to be a test using sizeof
19342charsize=1
19343
19344: Check for the number of bits in a character
19345case "$charbits" in
19346'')	echo "Checking how long a character is (in bits)..." >&4
19347	$cat >try.c <<EOCP
19348#include <stdio.h>
19349int main ()
19350{
19351    int n;
19352    unsigned char c;
19353    for (c = 1, n = 0; c; c <<= 1, n++) ;
19354    printf ("%d\n", n);
19355    return (0);
19356    }
19357EOCP
19358	set try
19359	if eval $compile_ok; then
19360		dflt=`$run ./try`
19361	else
19362		dflt='8'
19363		echo "(I can't seem to compile the test program.  Guessing...)"
19364	fi
19365	;;
19366*)
19367	dflt="$charbits"
19368	;;
19369esac
19370rp="What is the length of a character (in bits)?"
19371. ./myread
19372charbits="$ans"
19373$rm_try
19374case "$charbits" in
193758)	;;
19376*)	cat >&4 << EOM
19377Your system has an unsigned character size of $charbits bits, which
19378is rather unusual (normally it is 8 bits).  Perl likely will not work
19379correctly on your system, with subtle bugs in various places.
19380EOM
19381	rp='Do you really want to continue?'
19382	dflt='n'
19383	. ./myread
19384	case "$ans" in
19385		[yY])	echo >&4 "Okay, continuing."	;;
19386		*)	exit 1				;;
19387	esac
19388esac
19389
19390: how do we concatenate cpp tokens here?
19391echo " "
19392echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
19393$cat >cpp_stuff.c <<'EOCP'
19394#define RCAT(a,b)a/**/b
19395#define ACAT(a,b)a ## b
19396RCAT(Rei,ser)
19397ACAT(Cir,cus)
19398EOCP
19399$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
19400if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
19401	echo "Oh!  Smells like ANSI's been here." >&4
19402	echo "We can catify or stringify, separately or together!"
19403	cpp_stuff=42
19404elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
19405	echo "Ah, yes!  The good old days!" >&4
19406	echo "However, in the good old days we don't know how to stringify and"
19407	echo "catify at the same time."
19408	cpp_stuff=1
19409else
19410	$cat >&4 <<EOM
19411Hmm, I don't seem to be able to concatenate tokens with your cpp.
19412You're going to have to edit the values of CAT[2-5] in config.h...
19413EOM
19414	cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
19415fi
19416$rm -f cpp_stuff.*
19417
19418: see if this is a db.h system
19419set db.h i_db
19420eval $inhdr
19421
19422case "$i_db" in
19423$define)
19424	: Check db version.
19425	echo " "
19426	echo "Checking Berkeley DB version ..." >&4
19427	$cat >try.c <<EOCP
19428#$d_const HASCONST
19429#ifndef HASCONST
19430#define const
19431#endif
19432#include <sys/types.h>
19433#include <stdio.h>
19434#$i_stdlib I_STDLIB
19435#ifdef I_STDLIB
19436#include <stdlib.h>
19437#endif
19438#include <db.h>
19439int main(int argc, char *argv[])
19440{
19441#ifdef DB_VERSION_MAJOR	/* DB version >= 2 */
19442    int Major, Minor, Patch ;
19443    unsigned long Version ;
19444    (void)db_version(&Major, &Minor, &Patch) ;
19445    if (argc == 2) {
19446        printf("%d %d %d %d %d %d\n",
19447               DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
19448               Major, Minor, Patch);
19449        exit(0);
19450    }
19451    printf("You have Berkeley DB Version 2 or greater.\n");
19452
19453    printf("db.h is from Berkeley DB Version %d.%d.%d\n",
19454		DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
19455    printf("libdb is from Berkeley DB Version %d.%d.%d\n",
19456		Major, Minor, Patch) ;
19457
19458    /* check that db.h & libdb are compatible */
19459    if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
19460	printf("db.h and libdb are incompatible.\n") ;
19461        exit(3);
19462    }
19463
19464    printf("db.h and libdb are compatible.\n") ;
19465
19466    Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
19467		+ DB_VERSION_PATCH ;
19468
19469    /* needs to be >= 2.3.4 */
19470    if (Version < 2003004) {
19471    /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
19472	printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
19473        exit(2);
19474    }
19475
19476    exit(0);
19477#else
19478#if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
19479    if (argc == 2) {
19480        printf("1 0 0\n");
19481        exit(0);
19482    }
19483    printf("You have Berkeley DB Version 1.\n");
19484    exit(0);	/* DB version < 2: the coast is clear. */
19485#else
19486    exit(1);	/* <db.h> not Berkeley DB? */
19487#endif
19488#endif
19489}
19490EOCP
19491	set try
19492	if eval $compile_ok && $run ./try; then
19493		echo 'Looks OK.' >&4
19494		set `$run ./try 1`
19495		db_version_major=$1
19496		db_version_minor=$2
19497		db_version_patch=$3
19498	else
19499		echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
19500		i_db=$undef
19501		case " $libs " in
19502		*"-ldb "*)
19503			: Remove db from list of libraries to use
19504			echo "Removing unusable -ldb from library list" >&4
19505			set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
19506			shift
19507			libs="$*"
19508			echo "libs = $libs" >&4
19509			;;
19510		esac
19511	fi
19512	$rm_try
19513	;;
19514esac
19515
19516case "$i_db" in
19517define)
19518	: Check the return type needed for hash
19519	echo " "
19520	echo "Checking return type needed for hash for Berkeley DB ..." >&4
19521	$cat >try.c <<EOCP
19522#$d_const HASCONST
19523#ifndef HASCONST
19524#define const
19525#endif
19526#include <sys/types.h>
19527#include <db.h>
19528
19529#ifndef DB_VERSION_MAJOR
19530u_int32_t hash_cb (ptr, size)
19531const void *ptr;
19532size_t size;
19533{
19534}
19535HASHINFO info;
19536int main()
19537{
19538	info.hash = hash_cb;
19539}
19540#endif
19541EOCP
19542	if $cc $ccflags -c try.c >try.out 2>&1 ; then
19543		if $contains warning try.out >>/dev/null 2>&1 ; then
19544			db_hashtype='int'
19545		else
19546			db_hashtype='u_int32_t'
19547		fi
19548	else
19549		: XXX Maybe we should just give up here.
19550		db_hashtype=u_int32_t
19551		$cat try.out >&4
19552		echo "Help:  I can't seem to compile the db test program." >&4
19553		echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
19554	fi
19555	$rm_try
19556	echo "Your version of Berkeley DB uses $db_hashtype for hash."
19557	;;
19558*)	db_hashtype=u_int32_t
19559	;;
19560esac
19561case "$i_db" in
19562define)
19563	: Check the return type needed for prefix
19564	echo " "
19565	echo "Checking return type needed for prefix for Berkeley DB ..." >&4
19566	cat >try.c <<EOCP
19567#$d_const HASCONST
19568#ifndef HASCONST
19569#define const
19570#endif
19571#include <sys/types.h>
19572#include <db.h>
19573
19574#ifndef DB_VERSION_MAJOR
19575size_t prefix_cb (key1, key2)
19576const DBT *key1;
19577const DBT *key2;
19578{
19579}
19580BTREEINFO info;
19581int main()
19582{
19583	info.prefix = prefix_cb;
19584}
19585#endif
19586EOCP
19587	if $cc $ccflags -c try.c  >try.out 2>&1 ; then
19588		if $contains warning try.out >>/dev/null 2>&1 ; then
19589			db_prefixtype='int'
19590		else
19591			db_prefixtype='size_t'
19592		fi
19593	else
19594		db_prefixtype='size_t'
19595		: XXX Maybe we should just give up here.
19596		$cat try.out >&4
19597		echo "Help:  I can't seem to compile the db test program." >&4
19598		echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
19599	fi
19600	$rm_try
19601	echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
19602	;;
19603*)	db_prefixtype='size_t'
19604	;;
19605esac
19606
19607: How can we generate normalized random numbers ?
19608echo " "
19609echo "Using our internal random number implementation..." >&4
19610
19611case "$ccflags" in
19612*-Dmy_rand=*|*-Dmy_srand=*)
19613	echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
19614	ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
19615	ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
19616	ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
19617	;;
19618esac
19619
19620randfunc=drand48
19621drand01="drand48()"
19622seedfunc="srand48"
19623randbits=48
19624randseedtype=U32
19625
19626: Check how to flush
19627echo " "
19628$cat >&4 <<EOM
19629Checking how to flush all pending stdio output...
19630EOM
19631# I only know how to find the first 32 possibly open files on SunOS.
19632# See also hints/sunos_4_1.sh and util.c  --AD
19633case "$osname" in
19634sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
19635esac
19636$cat >>try.c <<EOCP
19637#include <stdio.h>
19638#$i_stdlib I_STDLIB
19639#ifdef I_STDLIB
19640#include <stdlib.h>
19641#endif
19642#$i_unistd I_UNISTD
19643#ifdef I_UNISTD
19644# include <unistd.h>
19645#endif
19646#$d_sysconf HAS_SYSCONF
19647#$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
19648#ifdef HAS_STDIO_STREAM_ARRAY
19649# define STDIO_STREAM_ARRAY $stdio_stream_array
19650#endif
19651int main() {
19652  FILE* p;
19653  unlink("try.out");
19654  p = fopen("try.out", "w");
19655#ifdef TRY_FPUTC
19656  fputc('x', p);
19657#else
19658# ifdef TRY_FPRINTF
19659  fprintf(p, "x");
19660# endif
19661#endif
19662#ifdef TRY_FFLUSH_NULL
19663  fflush(NULL);
19664#endif
19665#ifdef TRY_FFLUSH_ALL
19666  {
19667    long open_max = -1;
19668# ifdef PERL_FFLUSH_ALL_FOPEN_MAX
19669    open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
19670# else
19671#  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
19672    open_max = sysconf(_SC_OPEN_MAX);
19673#  else
19674#   ifdef FOPEN_MAX
19675    open_max = FOPEN_MAX;
19676#   else
19677#    ifdef OPEN_MAX
19678    open_max = OPEN_MAX;
19679#    else
19680#     ifdef _NFILE
19681    open_max = _NFILE;
19682#     endif
19683#    endif
19684#   endif
19685#  endif
19686# endif
19687# ifdef HAS_STDIO_STREAM_ARRAY
19688    if (open_max > 0) {
19689      long i;
19690      for (i = 0; i < open_max; i++)
19691	    if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
19692		STDIO_STREAM_ARRAY[i]._file < open_max &&
19693		STDIO_STREAM_ARRAY[i]._flag)
19694		fflush(&STDIO_STREAM_ARRAY[i]);
19695    }
19696  }
19697# endif
19698#endif
19699  _exit(42);
19700}
19701EOCP
19702: first we have to find out how _not_ to flush
19703$to try.c
19704if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
19705    output=''
19706    set try -DTRY_FPUTC
19707    if eval $compile; then
19708	    $run ./try 2>/dev/null
19709	    code="$?"
19710	    $from try.out
19711	    if $test ! -s try.out -a "X$code" = X42; then
19712		output=-DTRY_FPUTC
19713	    fi
19714    fi
19715    case "$output" in
19716    '')
19717	    set try -DTRY_FPRINTF
19718	    if eval $compile; then
19719		    $run ./try 2>/dev/null
19720		    code="$?"
19721		    $from try.out
19722		    if $test ! -s try.out -a "X$code" = X42; then
19723			output=-DTRY_FPRINTF
19724		    fi
19725	    fi
19726	;;
19727    esac
19728fi
19729: check for fflush NULL behavior
19730case "$fflushNULL" in
19731'') 	set try -DTRY_FFLUSH_NULL $output
19732	if eval $compile; then
19733		$run ./try 2>/dev/null
19734		code="$?"
19735		$from try.out
19736		if $test -s try.out -a "X$code" = X42; then
19737			fflushNULL="`$cat try.out`"
19738		else
19739			if $test "X$code" != X42; then
19740				$cat >&4 <<EOM
19741(If this test failed, don't worry, we'll try another method shortly.)
19742EOM
19743			fi
19744		fi
19745	fi
19746	$rm -f core try.core core.try.*
19747	case "$fflushNULL" in
19748	x)	$cat >&4 <<EOM
19749Your fflush(NULL) works okay for output streams.
19750Let's see if it clobbers input pipes...
19751EOM
19752# As of mid-March 2000 all versions of Solaris appear to have a stdio
19753# bug that improperly flushes the input end of pipes.  So we avoid the
19754# autoflush on fork/system/exec support for now. :-(
19755$cat >tryp.c <<EOCP
19756#include <stdio.h>
19757int
19758main(int argc, char **argv)
19759{
19760    char buf[1024];
19761    int i;
19762    char *bp = buf;
19763    while (1) {
19764	while ((i = getc(stdin)) != -1
19765	       && (*bp++ = i) != '\n'
19766	       && bp < &buf[1024])
19767	/* DO NOTHING */ ;
19768	*bp = '\0';
19769	fprintf(stdout, "%s", buf);
19770	fflush(NULL);
19771	if (i == -1)
19772	    return 0;
19773	bp = buf;
19774    }
19775}
19776EOCP
19777		fflushNULL="$define"
19778		set tryp
19779		if eval $compile; then
19780		    $rm -f tryp.out
19781		    # Copy the .c file to the remote host ($to is an ssh-alike if targethost is set)
19782		    if $test "X$targethost" != X; then
19783			$to tryp.c
19784			$to tryp
19785			$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
19786		    else
19787			$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
19788		    fi
19789		    if cmp tryp.c tryp.out >/dev/null 2>&1; then
19790		       $cat >&4 <<EOM
19791fflush(NULL) seems to behave okay with input streams.
19792EOM
19793			fflushNULL="$define"
19794		    else
19795			$cat >&4 <<EOM
19796Ouch, fflush(NULL) clobbers input pipes!  We will not use it.
19797EOM
19798			fflushNULL="$undef"
19799		    fi
19800		fi
19801		$rm -f core tryp.c tryp.core core.tryp.*
19802		;;
19803	'')	$cat >&4 <<EOM
19804Your fflush(NULL) isn't working (contrary to ANSI C).
19805EOM
19806		fflushNULL="$undef"
19807		;;
19808	*)	$cat >&4 <<EOM
19809Cannot figure out whether your fflush(NULL) works or not.
19810I'm assuming it doesn't (contrary to ANSI C).
19811EOM
19812		fflushNULL="$undef"
19813		;;
19814	esac
19815	;;
19816$define|true|[yY]*)
19817	fflushNULL="$define"
19818	;;
19819*)
19820	fflushNULL="$undef"
19821	;;
19822esac
19823: check explicit looping only if NULL did not work, and if the pipe
19824: bug does not show up on an explicit flush too
19825case "$fflushNULL" in
19826"$undef")
19827	$cat >tryp.c <<EOCP
19828#include <stdio.h>
19829int
19830main(int argc, char **argv)
19831{
19832    char buf[1024];
19833    int i;
19834    char *bp = buf;
19835    while (1) {
19836	while ((i = getc(stdin)) != -1
19837	       && (*bp++ = i) != '\n'
19838	       && bp < &buf[1024])
19839	/* DO NOTHING */ ;
19840	*bp = '\0';
19841	fprintf(stdout, "%s", buf);
19842	fflush(stdin);
19843	if (i == -1)
19844	    return 0;
19845	bp = buf;
19846    }
19847}
19848EOCP
19849	set tryp
19850	if eval $compile; then
19851	    $rm -f tryp.out
19852	    if $test "X$targethost" != X; then
19853		$to tryp.c
19854		$to tryp
19855		$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
19856	    else
19857		$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
19858	    fi
19859	    if cmp tryp.c tryp.out >/dev/null 2>&1; then
19860	       $cat >&4 <<EOM
19861Good, at least fflush(stdin) seems to behave okay when stdin is a pipe.
19862EOM
19863		: now check for fflushall behaviour
19864		case "$fflushall" in
19865		'') 	set try -DTRY_FFLUSH_ALL $output
19866			if eval $compile; then
19867				$cat >&4 <<EOM
19868(Now testing the other method--but note that this also may fail.)
19869EOM
19870				$run ./try 2>/dev/null
19871				code=$?
19872				$from try.out
19873				if $test -s try.out -a "X$code" = X42; then
19874					fflushall="`$cat try.out`"
19875				fi
19876			fi
19877			$rm_try
19878			case "$fflushall" in
19879			x)	$cat >&4 <<EOM
19880Whew. Flushing explicitly all the stdio streams works.
19881EOM
19882				fflushall="$define"
19883				;;
19884			'')	$cat >&4 <<EOM
19885Sigh. Flushing explicitly all the stdio streams doesn't work.
19886EOM
19887				fflushall="$undef"
19888				;;
19889			*)	$cat >&4 <<EOM
19890Cannot figure out whether flushing stdio streams explicitly works or not.
19891I'm assuming it doesn't.
19892EOM
19893				fflushall="$undef"
19894				;;
19895			esac
19896			;;
19897		"$define"|true|[yY]*)
19898			fflushall="$define"
19899			;;
19900		*)
19901			fflushall="$undef"
19902			;;
19903		esac
19904	    else
19905		$cat >&4 <<EOM
19906All is futile.  Even fflush(stdin) clobbers input pipes!
19907EOM
19908		fflushall="$undef"
19909	    fi
19910	else
19911	    fflushall="$undef"
19912	fi
19913	$rm -f core tryp.c tryp.core core.tryp.*
19914	;;
19915*)	fflushall="$undef"
19916	;;
19917esac
19918
19919case "$fflushNULL$fflushall" in
19920undefundef)
19921	$cat <<EOM
19922OK, I give up.  I cannot figure out how to flush pending stdio output.
19923We won't be flushing handles at all before fork/exec/popen.
19924EOM
19925	;;
19926esac
19927$rm_try tryp
19928
19929: Store the full pathname to the ar program for use in the C program
19930: Respect a hint or command line value for full_ar.
19931case "$full_ar" in
19932'') full_ar=$ar ;;
19933esac
19934
19935: Store the full pathname to the sed program for use in the C program
19936full_sed=$sed
19937
19938: see what type gids are declared as in the kernel
19939echo " "
19940echo "Looking for the type for group ids returned by getgid()."
19941set gid_t gidtype xxx stdio.h sys/types.h
19942eval $typedef
19943case "$gidtype" in
19944xxx)
19945	xxx=`./findhdr sys/user.h`
19946	set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
19947	case $1 in
19948	unsigned) dflt="$1 $2" ;;
19949	*) dflt="$1" ;;
19950	esac
19951	;;
19952*) dflt="$gidtype";;
19953esac
19954case "$gidtype" in
19955gid_t) echo "gid_t found." ;;
19956*)	rp="What is the type for group ids returned by getgid()?"
19957	. ./myread
19958	gidtype="$ans"
19959	;;
19960esac
19961
19962: Check the size of GID
19963echo " "
19964case "$gidtype" in
19965*_t) zzz="$gidtype"	;;
19966*)   zzz="gid"		;;
19967esac
19968echo "Checking the size of $zzz..." >&4
19969cat > try.c <<EOCP
19970#include <sys/types.h>
19971#include <stdio.h>
19972#$i_stdlib I_STDLIB
19973#ifdef I_STDLIB
19974#include <stdlib.h>
19975#endif
19976int main() {
19977    printf("%d\n", (int)sizeof($gidtype));
19978    exit(0);
19979}
19980EOCP
19981set try
19982if eval $compile_ok; then
19983	yyy=`$run ./try`
19984	case "$yyy" in
19985	'')	gidsize=4
19986		echo "(I can't execute the test program--guessing $gidsize.)" >&4
19987		;;
19988	*)	gidsize=$yyy
19989		echo "Your $zzz is $gidsize bytes long."
19990		;;
19991	esac
19992else
19993	gidsize=4
19994	echo "(I can't compile the test program--guessing $gidsize.)" >&4
19995fi
19996
19997
19998: Check if GID is signed
19999echo " "
20000case "$gidtype" in
20001*_t) zzz="$gidtype"	;;
20002*)   zzz="gid"		;;
20003esac
20004echo "Checking the sign of $zzz..." >&4
20005cat > try.c <<EOCP
20006#include <sys/types.h>
20007#include <stdio.h>
20008int main() {
20009	$gidtype foo = -1;
20010	if (foo < 0)
20011		printf("-1\n");
20012	else
20013		printf("1\n");
20014}
20015EOCP
20016set try
20017if eval $compile; then
20018	yyy=`$run ./try`
20019	case "$yyy" in
20020	'')	gidsign=1
20021		echo "(I can't execute the test program--guessing unsigned.)" >&4
20022		;;
20023	*)	gidsign=$yyy
20024		case "$gidsign" in
20025		 1) echo "Your $zzz is unsigned." ;;
20026		-1) echo "Your $zzz is signed."   ;;
20027		esac
20028		;;
20029	esac
20030else
20031	gidsign=1
20032	echo "(I can't compile the test program--guessing unsigned.)" >&4
20033fi
20034
20035
20036: Check 64bit sizes
20037echo " "
20038
20039if $test X"$quadtype" != X; then
20040
20041echo "Checking how to print 64-bit integers..." >&4
20042
20043if $test X"$sPRId64" = X -a X"$quadtype" = Xint; then
20044	$cat >try.c <<'EOCP'
20045#include <sys/types.h>
20046#include <stdio.h>
20047int main() {
20048  int q = 12345678901;
20049  printf("%ld\n", q);
20050}
20051EOCP
20052	set try
20053	if eval $compile; then
20054		yyy=`$run ./try`
20055		case "$yyy" in
20056		12345678901)
20057			sPRId64='"d"'; sPRIi64='"i"'; sPRIu64='"u"';
20058                	sPRIo64='"o"'; sPRIx64='"x"'; sPRIXU64='"X"';
20059			echo "We will use %d."
20060			;;
20061		esac
20062	fi
20063fi
20064
20065if $test X"$sPRId64" = X -a X"$quadtype" = Xlong; then
20066	$cat >try.c <<'EOCP'
20067#include <sys/types.h>
20068#include <stdio.h>
20069int main() {
20070  long q = 12345678901;
20071  printf("%ld\n", q);
20072}
20073EOCP
20074	set try
20075	if eval $compile; then
20076		yyy=`$run ./try`
20077		case "$yyy" in
20078		12345678901)
20079			sPRId64='"ld"'; sPRIi64='"li"'; sPRIu64='"lu"';
20080                	sPRIo64='"lo"'; sPRIx64='"lx"'; sPRIXU64='"lX"';
20081			echo "We will use %ld."
20082			;;
20083		esac
20084	fi
20085fi
20086
20087if $test X"$sPRId64" = X -a X"$i_inttypes" = X"$define" -a X"$quadtype" = Xint64_t; then
20088	$cat >try.c <<'EOCP'
20089#include <sys/types.h>
20090#include <inttypes.h>
20091#include <stdio.h>
20092int main() {
20093  int64_t q = 12345678901;
20094  printf("%" PRId64 "\n", q);
20095}
20096EOCP
20097	set try
20098	if eval $compile; then
20099		yyy=`$run ./try`
20100		case "$yyy" in
20101		12345678901)
20102			sPRId64=PRId64; sPRIi64=PRIi64; sPRIu64=PRIu64;
20103                	sPRIo64=PRIo64; sPRIx64=PRIx64; sPRIXU64=PRIXU64;
20104			echo "We will use the C9X style."
20105			;;
20106		esac
20107	fi
20108fi
20109
20110if $test X"$sPRId64" = X -a X"$quadtype" != X; then
20111	$cat >try.c <<EOCP
20112#include <sys/types.h>
20113#include <stdio.h>
20114int main() {
20115  $quadtype q = 12345678901;
20116  printf("%Ld\n", q);
20117}
20118EOCP
20119	set try
20120	if eval $compile; then
20121		yyy=`$run ./try`
20122		case "$yyy" in
20123		12345678901)
20124			sPRId64='"Ld"'; sPRIi64='"Li"'; sPRIu64='"Lu"';
20125                	sPRIo64='"Lo"'; sPRIx64='"Lx"'; sPRIXU64='"LX"';
20126			echo "We will use %Ld."
20127			;;
20128		esac
20129	fi
20130fi
20131
20132if $test X"$sPRId64" = X -a X"$quadtype" = X"long long"; then
20133	$cat >try.c <<'EOCP'
20134#include <sys/types.h>
20135#include <stdio.h>
20136int main() {
20137  long long q = 12345678901LL; /* AIX cc requires the LL suffix. */
20138  printf("%lld\n", q);
20139}
20140EOCP
20141	set try
20142	if eval $compile; then
20143		yyy=`$run ./try`
20144		case "$yyy" in
20145		12345678901)
20146			sPRId64='"lld"'; sPRIi64='"lli"'; sPRIu64='"llu"';
20147                	sPRIo64='"llo"'; sPRIx64='"llx"'; sPRIXU64='"llX"';
20148			echo "We will use the %lld style."
20149			;;
20150		esac
20151	fi
20152fi
20153
20154if $test X"$sPRId64" = X -a X"$quadtype" != X; then
20155	$cat >try.c <<EOCP
20156#include <sys/types.h>
20157#include <stdio.h>
20158int main() {
20159  $quadtype q = 12345678901;
20160  printf("%qd\n", q);
20161}
20162EOCP
20163	set try
20164	if eval $compile; then
20165		yyy=`$run ./try`
20166		case "$yyy" in
20167		12345678901)
20168			sPRId64='"qd"'; sPRIi64='"qi"'; sPRIu64='"qu"';
20169                	sPRIo64='"qo"'; sPRIx64='"qx"'; sPRIXU64='"qX"';
20170			echo "We will use %qd."
20171			;;
20172		esac
20173	fi
20174fi
20175
20176if $test X"$sPRId64" = X; then
20177	echo "Cannot figure out how to print 64-bit integers." >&4
20178fi
20179$rm_try
20180
20181fi
20182
20183case "$sPRId64" in
20184'')	d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef";
20185	d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef";
20186	;;
20187*)	d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define";
20188	d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define";
20189	;;
20190esac
20191
20192: Check format strings for internal types
20193echo " "
20194$echo "Checking the format strings to be used for Perl's internal types..." >&4
20195
20196if $test X"$ivsize" = X8; then
20197	ivdformat="$sPRId64"
20198	uvuformat="$sPRIu64"
20199	uvoformat="$sPRIo64"
20200	uvxformat="$sPRIx64"
20201	uvXUformat="$sPRIXU64"
20202else
20203	if $test X"$ivsize" = X"$longsize"; then
20204		ivdformat='"ld"'
20205		uvuformat='"lu"'
20206		uvoformat='"lo"'
20207		uvxformat='"lx"'
20208		uvXUformat='"lX"'
20209	else
20210		if $test X"$ivsize" = X"$intsize"; then
20211			ivdformat='"d"'
20212			uvuformat='"u"'
20213			uvoformat='"o"'
20214			uvxformat='"x"'
20215			uvXUformat='"X"'
20216		else
20217			: far out
20218			if $test X"$ivsize" = X"$shortsize"; then
20219				ivdformat='"hd"'
20220				uvuformat='"hu"'
20221				uvoformat='"ho"'
20222				uvxformat='"hx"'
20223				uvXUformat='"hX"'
20224			fi
20225		fi
20226	fi
20227fi
20228
20229if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
20230	nveformat="$sPRIeldbl"
20231	nvfformat="$sPRIfldbl"
20232	nvgformat="$sPRIgldbl"
20233	nvEUformat="$sPRIEUldbl"
20234	nvFUformat="$sPRIFUldbl"
20235	nvGUformat="$sPRIGUldbl"
20236else
20237	nveformat='"e"'
20238	nvfformat='"f"'
20239	nvgformat='"g"'
20240	nvEUformat='"E"'
20241	nvFUformat='"F"'
20242	nvGUformat='"G"'
20243fi
20244
20245case "$ivdformat" in
20246'') echo "$0: Fatal: failed to find format strings, cannot continue." >&4
20247    exit 1
20248    ;;
20249esac
20250
20251: Check format string for GID
20252
20253echo " "
20254$echo "Checking the format string to be used for gids..." >&4
20255
20256case "$gidsign" in
20257-1)	if $test X"$gidsize" = X"$ivsize"; then
20258		gidformat="$ivdformat"
20259	else
20260		if $test X"$gidsize" = X"$longsize"; then
20261			gidformat='"ld"'
20262		else
20263			if $test X"$gidsize" = X"$intsize"; then
20264				gidformat='"d"'
20265			else
20266				if $test X"$gidsize" = X"$shortsize"; then
20267					gidformat='"hd"'
20268				fi
20269			fi
20270		fi
20271	fi
20272	;;
20273*)	if $test X"$gidsize" = X"$uvsize"; then
20274		gidformat="$uvuformat"
20275	else
20276		if $test X"$gidsize" = X"$longsize"; then
20277			gidformat='"lu"'
20278		else
20279			if $test X"$gidsize" = X"$intsize"; then
20280				gidformat='"u"'
20281			else
20282				if $test X"$gidsize" = X"$shortsize"; then
20283					gidformat='"hu"'
20284				fi
20285			fi
20286		fi
20287	fi
20288	;;
20289esac
20290
20291: see if getgroups exists
20292set getgroups d_getgrps
20293eval $inlibc
20294
20295: see if setgroups exists
20296set setgroups d_setgrps
20297eval $inlibc
20298
20299: Find type of 2nd arg to 'getgroups()' and 'setgroups()'
20300echo " "
20301case "$d_getgrps$d_setgrps" in
20302*define*)
20303	case "$groupstype" in
20304	'') dflt="$gidtype" ;;
20305	*)  dflt="$groupstype" ;;
20306	esac
20307	$cat <<EOM
20308What type of pointer is the second argument to getgroups() and setgroups()?
20309Usually this is the same as group ids, $gidtype, but not always.
20310
20311EOM
20312	rp='What type pointer is the second argument to getgroups() and setgroups()?'
20313	. ./myread
20314	groupstype="$ans"
20315	;;
20316*)  groupstype="$gidtype";;
20317esac
20318
20319: MAD = Misc Attribute Definition
20320
20321if $test $patchlevel -lt 9; then
20322: MAD is not available in 5.8.x or earlier.
20323    ans=n;
20324else
20325    case "$mad" in
20326    $define|true|[yY]*)	dflt='y' ;;
20327    *)			dflt='n' ;;
20328    esac
20329    cat <<EOM
20330
20331Would you like to build with Misc Attribute Decoration? This is development
20332work leading to a Perl 5 to Perl 6 convertor, which imposes a space and speed
20333overhead on the interpreter.
20334
20335If this doesn't make any sense to you, just accept the default '$dflt'.
20336EOM
20337    rp='Build Perl with MAD?'
20338    . ./myread
20339fi
20340case "$ans" in
20341y|Y)	val="$define"
20342	madlyh='madly.h madly.act madly.tab'
20343	madlysrc='madly.c'
20344	madlyobj="madly$_o" ;;
20345*)	val="$undef"
20346	madlyh=''
20347	madlysrc=''
20348	madlyobj='' ;;
20349esac
20350set mad
20351eval $setvar
20352
20353: check whether make sets MAKE
20354echo " "
20355echo "Checking if your $make program sets \$(MAKE)..." >&4
20356case "$make_set_make" in
20357'')
20358	$sed 's/^X //' > testmake.mak << 'EOF'
20359Xall:
20360X 	@echo 'maketemp="$(MAKE)"'
20361EOF
20362	case "`$make -f testmake.mak 2>/dev/null`" in
20363	*maketemp=*) make_set_make='#' ;;
20364	*)	make_set_make="MAKE=$make" ;;
20365	esac
20366	$rm -f testmake.mak
20367	;;
20368esac
20369case "$make_set_make" in
20370'#') echo "Yup, it does.";;
20371*) echo "Nope, it doesn't.";;
20372esac
20373
20374: see what type is used for mode_t
20375rp="What is the type used for file modes for system calls (e.g. fchmod())?"
20376set mode_t modetype int stdio.h sys/types.h
20377eval $typedef_ask
20378
20379: see if we need va_copy
20380echo " "
20381case "$i_stdarg" in
20382"$define")
20383	$cat >try.c <<EOCP
20384#include <stdarg.h>
20385#include <stdio.h>
20386#$i_stdlib I_STDLIB
20387#ifdef I_STDLIB
20388#include <stdlib.h>
20389#endif
20390#include <signal.h>
20391
20392int
20393ivfprintf(FILE *f, const char *fmt, va_list *valp)
20394{
20395  return vfprintf(f, fmt, *valp);
20396}
20397
20398int
20399myvfprintf(FILE *f, const  char *fmt, va_list val)
20400{
20401  return ivfprintf(f, fmt, &val);
20402}
20403
20404int
20405myprintf(char *fmt, ...)
20406{
20407  va_list val;
20408  va_start(val, fmt);
20409  return myvfprintf(stdout, fmt, val);
20410}
20411
20412int
20413main(int ac, char **av)
20414{
20415  signal(SIGSEGV, exit);
20416
20417  myprintf("%s%cs all right, then\n", "that", '\'');
20418  exit(0);
20419}
20420EOCP
20421	set try
20422	if eval $compile && $run ./try 2>&1 >/dev/null; then
20423		case "`$run ./try`" in
20424		"that's all right, then")
20425			okay=yes
20426			;;
20427		esac
20428	fi
20429	case "$okay" in
20430	yes)	echo "It seems that you don't need va_copy()." >&4
20431		need_va_copy="$undef"
20432		;;
20433	*)	echo "It seems that va_copy() or similar will be needed." >&4
20434		need_va_copy="$define"
20435		;;
20436	esac
20437	$rm_try
20438	;;
20439*)	echo "You don't have <stdarg.h>, not checking for va_copy()." >&4
20440	need_va_copy="$undef"
20441	;;
20442esac
20443
20444: see what type is used for size_t
20445rp="What is the type used for the length parameter for string functions?"
20446set size_t sizetype 'unsigned int' stdio.h sys/types.h
20447eval $typedef_ask
20448
20449: check for type of arguments to gethostbyaddr.
20450if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
20451	case "$d_gethbyaddr" in
20452	$define)
20453		$cat <<EOM
20454
20455Checking to see what type of arguments are accepted by gethostbyaddr().
20456EOM
20457		hdrs="$define sys/types.h
20458			$d_socket sys/socket.h
20459			$i_niin netinet/in.h
20460			$i_netdb netdb.h
20461			$i_unistd unistd.h"
20462		: The first arg can 'char *' or 'void *'
20463		: The second arg is some of integral type
20464		for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
20465			for yyy in size_t long int; do
20466				case "$netdb_host_type" in
20467				'')	try="$extern_C struct hostent *gethostbyaddr($xxx, $yyy, int);"
20468					if ./protochk "$try" $hdrs; then
20469						echo "Your system accepts $xxx for the first arg."
20470						echo "...and $yyy for the second arg."
20471						netdb_host_type="$xxx"
20472						netdb_hlen_type="$yyy"
20473					fi
20474					;;
20475				esac
20476			done
20477		done
20478		: In case none of those worked, prompt the user.
20479		case "$netdb_host_type" in
20480		'')	rp='What is the type for the 1st argument to gethostbyaddr?'
20481			dflt='char *'
20482			. ./myread
20483			netdb_host_type=$ans
20484			rp='What is the type for the 2nd argument to gethostbyaddr?'
20485			dflt="$sizetype"
20486			. ./myread
20487			netdb_hlen_type=$ans
20488			;;
20489		esac
20490		;;
20491	*)	: no gethostbyaddr, so pick harmless defaults
20492		netdb_host_type='char *'
20493		netdb_hlen_type="$sizetype"
20494		;;
20495	esac
20496	# Remove the "const" if needed. -- but then we'll have a
20497	# prototype clash!
20498	# netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
20499fi
20500
20501: check for type of argument to gethostbyname.
20502if test "X$netdb_name_type" = X ; then
20503	case "$d_gethbyname" in
20504	$define)
20505		$cat <<EOM
20506
20507Checking to see what type of argument is accepted by gethostbyname().
20508EOM
20509		hdrs="$define sys/types.h
20510			$d_socket sys/socket.h
20511			$i_niin netinet/in.h
20512			$i_netdb netdb.h
20513			$i_unistd unistd.h"
20514		for xxx in "const char *" "char *"; do
20515			case "$netdb_name_type" in
20516			'')	try="$extern_C struct hostent *gethostbyname($xxx);"
20517				if ./protochk "$try" $hdrs; then
20518					echo "Your system accepts $xxx."
20519					netdb_name_type="$xxx"
20520				fi
20521				;;
20522			esac
20523		done
20524		: In case none of those worked, prompt the user.
20525		case "$netdb_name_type" in
20526		'')	rp='What is the type for the 1st argument to gethostbyname?'
20527			dflt='char *'
20528			. ./myread
20529			netdb_name_type=$ans
20530			;;
20531		esac
20532		;;
20533	*)	: no gethostbyname, so pick harmless default
20534		netdb_name_type='char *'
20535		;;
20536	esac
20537fi
20538
20539: check for type of 1st argument to getnetbyaddr.
20540if test "X$netdb_net_type" = X ; then
20541	case "$d_getnbyaddr" in
20542	$define)
20543		$cat <<EOM
20544
20545Checking to see what type of 1st argument is accepted by getnetbyaddr().
20546EOM
20547		hdrs="$define sys/types.h
20548			$d_socket sys/socket.h
20549			$i_niin netinet/in.h
20550			$i_netdb netdb.h
20551			$i_unistd unistd.h"
20552		for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
20553			case "$netdb_net_type" in
20554			'')	try="$extern_C struct netent *getnetbyaddr($xxx, int);"
20555				if ./protochk "$try" $hdrs; then
20556					echo "Your system accepts $xxx."
20557					netdb_net_type="$xxx"
20558				fi
20559				;;
20560			esac
20561		done
20562		: In case none of those worked, prompt the user.
20563		case "$netdb_net_type" in
20564		'')	rp='What is the type for the 1st argument to getnetbyaddr?'
20565			dflt='long'
20566			. ./myread
20567			netdb_net_type=$ans
20568			;;
20569		esac
20570		;;
20571	*)	: no getnetbyaddr, so pick harmless default
20572		netdb_net_type='long'
20573		;;
20574	esac
20575fi
20576: locate the preferred pager for this system
20577fn=f/
20578case "$pager" in
20579'')
20580	dflt=''
20581	case "$pg" in
20582	/*) dflt=$pg;;
20583	[a-zA-Z]:/*) dflt=$pg;;
20584	esac
20585	case "$more" in
20586	/*) dflt=$more;;
20587	[a-zA-Z]:/*) dflt=$more;;
20588	esac
20589	case "$less" in
20590	/*) dflt=$less;;
20591	[a-zA-Z]:/*) dflt=$less;;
20592	esac
20593	case "$dflt" in
20594	'') dflt=/usr/ucb/more;;
20595	esac
20596	;;
20597*)	dflt="$pager"
20598	;;
20599esac
20600fn="f/($dflt)"
20601echo " "
20602rp='What pager is used on your system?'
20603. ./getfile
20604pager="$ans"
20605
20606: see what type pids are declared as in the kernel
20607rp="What is the type of process ids on this system?"
20608set pid_t pidtype int stdio.h sys/types.h
20609eval $typedef_ask
20610
20611: see if ar generates random libraries by itself
20612echo " "
20613echo "Checking how to generate random libraries on your machine..." >&4
20614echo 'int bar1() { return bar2(); }' > bar1.c
20615echo 'int bar2() { return 2; }' > bar2.c
20616$cat > foo.c <<EOP
20617#$i_stdlib I_STDLIB
20618#ifdef I_STDLIB
20619#include <stdlib.h>
20620#endif
20621int main() { printf("%d\n", bar1()); exit(0); }
20622EOP
20623$cc $ccflags -c bar1.c >/dev/null 2>&1
20624$cc $ccflags -c bar2.c >/dev/null 2>&1
20625$cc $ccflags -c foo.c >/dev/null 2>&1
20626$ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
20627if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
20628	$run ./foobar >/dev/null 2>&1; then
20629	echo "$ar appears to generate random libraries itself."
20630	orderlib=false
20631	if [ "X$ranlib" = "X" ]; then
20632	    ranlib=":"
20633	fi
20634elif $ar s bar$_a >/dev/null 2>&1 &&
20635	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
20636	$run ./foobar >/dev/null 2>&1; then
20637		echo "a table of contents needs to be added with '$ar s'."
20638		orderlib=false
20639		ranlib="$ar s"
20640elif $ar ts bar$_a >/dev/null 2>&1 &&
20641	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
20642	$run ./foobar >/dev/null 2>&1; then
20643		echo "a table of contents needs to be added with '$ar ts'."
20644		orderlib=false
20645		ranlib="$ar ts"
20646else
20647	case "$ranlib" in
20648	:) ranlib='';;
20649	'')
20650		ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
20651		$test -f $ranlib || ranlib=''
20652		;;
20653	esac
20654	if $test -n "$ranlib"; then
20655		echo "your system has '$ranlib'; we'll use that."
20656		orderlib=false
20657	else
20658		echo "your system doesn't seem to support random libraries"
20659		echo "so we'll use lorder and tsort to order the libraries."
20660		orderlib=true
20661		ranlib=":"
20662	fi
20663fi
20664$rm -f foo* bar*
20665
20666: see if this is a values.h system
20667set values.h i_values
20668eval $inhdr
20669
20670: Check the max offset that gmtime and localtime accept
20671echo "Checking max offsets that gmtime () accepts"
20672
20673case $i_values in
20674    define) yyy="#include <values.h>" ;;
20675    *)      yyy="" ;;
20676    esac
20677
20678case "$sGMTIME_min/$sGMTIME_max" in
20679    0/0|/)
20680	$cat >try.c <<EOCP
20681#include <sys/types.h>
20682#include <stdio.h>
20683#include <time.h>
20684$yyy
20685
20686int i;
20687struct tm *tmp;
20688time_t pt;
20689
20690void gm_check (time_t t, int min_year, int max_year)
20691{
20692    tmp = gmtime (&t);
20693    if ( tmp == NULL ||
20694	/* Check tm_year overflow */
20695	 tmp->tm_year < min_year || tmp->tm_year > max_year)
20696	tmp = NULL;
20697    else
20698	pt = t;
20699    } /* gm_check */
20700
20701int check_max ()
20702{
20703    tmp = NULL;
20704    pt  = 0;
20705#ifdef MAXLONG
20706    gm_check (MAXLONG, 69, 0x7fffffff);
20707#endif
20708    if (tmp == NULL || tmp->tm_year < 0) {
20709	for (i = 63; i >= 0; i--) {
20710	    time_t x = pt | ((time_t)1 << i);
20711	    if (x < 0 || x < pt) continue;
20712	    gm_check (x, 69, 0x7fffffff);
20713	    }
20714	}
20715    printf ("sGMTIME_max=%ld\n", pt);
20716    return (0);
20717    } /* check_max */
20718
20719int check_min ()
20720{
20721    tmp = NULL;
20722    pt  = 0;
20723#ifdef MINLONG
20724    gm_check (MINLONG, -1900, 70);
20725#endif
20726    if (tmp == NULL) {
20727	for (i = 36; i >= 0; i--) {
20728	    time_t x = pt - ((time_t)1 << i);
20729	    if (x > 0) continue;
20730	    gm_check (x, -1900, 70);
20731	    }
20732	}
20733    printf ("sGMTIME_min=%ld\n", pt);
20734    return (0);
20735    } /* check_min */
20736
20737int main (int argc, char *argv[])
20738{
20739    /* fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t)); */
20740    check_max ();
20741    check_min ();
20742    return (0);
20743    } /* main */
20744EOCP
20745	set try
20746	if eval $compile; then
20747	    eval `$run ./try`
20748	else
20749	    echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
20750	    fi
20751	$rm_try
20752	;;
20753    esac
20754
20755echo "Checking max offsets that localtime () accepts"
20756
20757case "$sLOCALTIME_min/$sLOCALTIME_max" in
20758    0/0|/)
20759	$cat >try.c <<EOCP
20760#include <sys/types.h>
20761#include <stdio.h>
20762#include <time.h>
20763$yyy
20764
20765int i;
20766struct tm *tmp;
20767time_t pt;
20768
20769void local_check (time_t t, int min_year, int max_year)
20770{
20771    if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
20772	tmp = NULL;
20773    else
20774	tmp = localtime (&t);
20775    if ( tmp == NULL ||
20776	/* Check tm_year overflow */
20777	 tmp->tm_year < min_year || tmp->tm_year > max_year)
20778	tmp = NULL;
20779    else
20780	pt = t;
20781    } /* local_check */
20782
20783int check_max ()
20784{
20785    tmp = NULL;
20786    pt  = 0;
20787#ifdef MAXLONG
20788    local_check (MAXLONG, 69, 0x7fffffff);
20789#endif
20790    if (tmp == NULL || tmp->tm_year < 0) {
20791	for (i = 63; i >= 0; i--) {
20792	    time_t x = pt | ((time_t)1 << i);
20793	    if (x < 0 || x < pt) continue;
20794	    local_check (x, 69, 0x7fffffff);
20795	    }
20796	}
20797    printf ("sLOCALTIME_max=%ld\n", pt);
20798    return (0);
20799   } /* check_max */
20800
20801int check_min ()
20802{
20803    tmp = NULL;
20804    pt  = 0;
20805#ifdef MINLONG
20806    local_check (MINLONG, -1900, 70);
20807#endif
20808    if (tmp == NULL) {
20809	for (i = 36; i >= 0; i--) {
20810	    time_t x = pt - ((time_t)1 << i);
20811	    if (x > 0) continue;
20812	    local_check (x, -1900, 70);
20813	    }
20814	}
20815    printf ("sLOCALTIME_min=%ld\n", pt);
20816    return (0);
20817    } /* check_min */
20818
20819int main (int argc, char *argv[])
20820{
20821    check_max ();
20822    check_min ();
20823    return (0);
20824    } /* main */
20825EOCP
20826	set try
20827	if eval $compile; then
20828	    eval `$run ./try`
20829	else
20830	    echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
20831	    fi
20832	$rm_try
20833	;;
20834    esac
20835
20836: check for type of arguments to select.
20837case "$selecttype" in
20838'') case "$d_select" in
20839	$define)
20840		echo " "
20841		$cat <<EOM
20842Checking to see what type of arguments are accepted by select().
20843EOM
20844		hdrs="$define sys/types.h
20845			$i_systime sys/time.h
20846			$i_sysselct sys/select.h
20847			$d_socket sys/socket.h"
20848		: The first arg can be int, unsigned, or size_t
20849		: The last arg may or may not be 'const'
20850		val=''
20851		: void pointer has been seen but using that
20852		: breaks the selectminbits test
20853		for xxx in 'fd_set *' 'int *'; do
20854			for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
20855				for tmo in 'struct timeval *' 'const struct timeval *'; do
20856					case "$val" in
20857					'')	try="$extern_C select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
20858						if ./protochk "$try" $hdrs; then
20859							echo "Your system accepts $xxx."
20860							val="$xxx"
20861						fi
20862						;;
20863					esac
20864				done
20865			done
20866		done
20867		case "$val" in
20868		'')	rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
20869			case "$d_fd_set" in
20870				$define) dflt="fd_set *" ;;
20871				*)		dflt="int *" ;;
20872			esac
20873			. ./myread
20874			val=$ans
20875			;;
20876		esac
20877		selecttype="$val"
20878		;;
20879	*)	: no select, so pick a harmless default
20880		selecttype='int *'
20881		;;
20882	esac
20883	;;
20884esac
20885
20886: check for the select 'width'
20887case "$selectminbits" in
20888'') safebits=`expr $ptrsize \* 8`
20889    case "$d_select" in
20890	$define)
20891		$cat <<EOM
20892
20893Checking to see on how many bits at a time your select() operates...
20894EOM
20895		$cat >try.c <<EOCP
20896#include <sys/types.h>
20897#$i_time I_TIME
20898#$i_systime I_SYS_TIME
20899#$i_systimek I_SYS_TIME_KERNEL
20900#ifdef I_TIME
20901#   include <time.h>
20902#endif
20903#ifdef I_SYS_TIME
20904#   ifdef I_SYS_TIME_KERNEL
20905#	define KERNEL
20906#   endif
20907#   include <sys/time.h>
20908#   ifdef I_SYS_TIME_KERNEL
20909#	undef KERNEL
20910#   endif
20911#endif
20912#$i_sysselct I_SYS_SELECT
20913#ifdef I_SYS_SELECT
20914#include <sys/select.h>
20915#endif
20916#$d_socket HAS_SOCKET
20917#ifdef HAS_SOCKET
20918#   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
20919#endif
20920#include <stdio.h>
20921#$i_stdlib I_STDLIB
20922#ifdef I_STDLIB
20923#include <stdlib.h>
20924#endif
20925$selecttype b;
20926#define S sizeof(*(b))
20927#define MINBITS	64
20928#define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
20929#define NBITS  (NBYTES * 8)
20930int main() {
20931    char *s = (char *)malloc(NBYTES);
20932    struct timeval t;
20933    int i;
20934    FILE* fp;
20935    int fd;
20936
20937    if (!s)
20938	exit(1);
20939    fclose(stdin);
20940    fp = fopen("try.c", "r");
20941    if (fp == 0)
20942      exit(2);
20943    fd = fileno(fp);
20944    if (fd < 0)
20945      exit(3);
20946    b = ($selecttype)s;
20947    for (i = 0; i < NBITS; i++)
20948	FD_SET(i, b);
20949    t.tv_sec  = 0;
20950    t.tv_usec = 0;
20951    select(fd + 1, b, 0, 0, &t);
20952    for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
20953    free(s);
20954    printf("%d\n", i + 1);
20955    return 0;
20956}
20957EOCP
20958		set try
20959		if eval $compile_ok; then
20960			selectminbits=`$run ./try`
20961			case "$selectminbits" in
20962			'')	cat >&4 <<EOM
20963Cannot figure out on how many bits at a time your select() operates.
20964I'll play safe and guess it is $safebits bits.
20965EOM
20966				selectminbits=$safebits
20967				bits="$safebits bits"
20968				;;
20969			1)	bits="1 bit" ;;
20970			*)	bits="$selectminbits bits" ;;
20971			esac
20972			echo "Your select() operates on $bits at a time." >&4
20973		else
20974			rp='What is the minimum number of bits your select() operates on?'
20975			case "$byteorder" in
20976			12345678)	dflt=64 ;;
20977			1234)		dflt=32 ;;
20978			*)		dflt=1	;;
20979			esac
20980			. ./myread
20981			val=$ans
20982			selectminbits="$val"
20983		fi
20984		$rm_try
20985		;;
20986	*)	: no select, so pick a harmless default
20987		selectminbits=$safebits
20988		;;
20989	esac
20990	;;
20991esac
20992
20993: Trace out the files included by signal.h, then look for SIGxxx names.
20994if [ "X$fieldn" = X ]; then
20995	: Just make some guesses.  We check them later.
20996	xxx="$sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h"
20997else
20998	xxx=`echo '#include <signal.h>' |
20999	$cppstdin $cppminus $cppflags 2>/dev/null |
21000	$grep '^[ 	]*#.*include' |
21001	$awk "{print \\$$fieldn}" | $sed 's!"!!g' |\
21002		$sed 's!\\\\\\\\!/!g' | $sort | $uniq`
21003fi
21004xxxfiles=''
21005for xx in $xxx /dev/null ; do
21006	$test -f "$xx" && xxxfiles="$xxxfiles $xx"
21007done
21008case "$xxxfiles" in
21009'')	xxxfiles=`./findhdr signal.h` ;;
21010esac
21011xxx=`awk '
21012$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
21013	print substr($2, 4, 20)
21014}
21015$1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
21016	print substr($3, 4, 20)
21017}' $xxxfiles`
21018: Append some common names just in case the awk scan failed.
21019xxx="$xxx ABRT ALRM BUS CANCEL CHLD CLD CONT DIL EMT FPE"
21020xxx="$xxx FREEZE HUP ILL INT IO IOT KILL LOST LWP PHONE"
21021xxx="$xxx PIPE POLL PROF PWR QUIT RTMAX RTMIN SEGV STKFLT STOP"
21022xxx="$xxx SYS TERM THAW TRAP TSTP TTIN TTOU URG USR1 USR2"
21023xxx="$xxx USR3 USR4 VTALRM WAITING WINCH WIND WINDOW XCPU XFSZ"
21024
21025: generate a few handy files for later
21026$cat > signal.c <<EOCP
21027#include <sys/types.h>
21028#include <signal.h>
21029#$i_stdlib I_STDLIB
21030#ifdef I_STDLIB
21031#include <stdlib.h>
21032#endif
21033#include <stdio.h>
21034int main() {
21035
21036/* Strange style to avoid deeply-nested #if/#else/#endif */
21037#ifndef NSIG
21038#  ifdef _NSIG
21039#    define NSIG (_NSIG)
21040#  endif
21041#endif
21042
21043#ifndef NSIG
21044#  ifdef SIGMAX
21045#    define NSIG (SIGMAX+1)
21046#  endif
21047#endif
21048
21049#ifndef NSIG
21050#  ifdef SIG_MAX
21051#    define NSIG (SIG_MAX+1)
21052#  endif
21053#endif
21054
21055#ifndef NSIG
21056#  ifdef _SIG_MAX
21057#    define NSIG (_SIG_MAX+1)
21058#  endif
21059#endif
21060
21061#ifndef NSIG
21062#  ifdef MAXSIG
21063#    define NSIG (MAXSIG+1)
21064#  endif
21065#endif
21066
21067#ifndef NSIG
21068#  ifdef MAX_SIG
21069#    define NSIG (MAX_SIG+1)
21070#  endif
21071#endif
21072
21073#ifndef NSIG
21074#  ifdef SIGARRAYSIZE
21075#    define NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */
21076#  endif
21077#endif
21078
21079#ifndef NSIG
21080#  ifdef _sys_nsig
21081#    define NSIG (_sys_nsig) /* Solaris 2.5 */
21082#  endif
21083#endif
21084
21085/* Default to some arbitrary number that's big enough to get most
21086   of the common signals.
21087*/
21088#ifndef NSIG
21089#    define NSIG 50
21090#endif
21091
21092printf("NSIG %d\n", NSIG);
21093
21094#ifndef JUST_NSIG
21095
21096EOCP
21097
21098echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
21099{
21100	printf "#ifdef SIG"; printf $1; printf "\n"
21101	printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
21102	printf $1; printf ");\n"
21103	printf "#endif\n"
21104}
21105END {
21106	printf "#endif /* JUST_NSIG */\n";
21107	printf "exit(0);\n}\n";
21108}
21109' >>signal.c
21110$cat >signal.awk <<'EOP'
21111BEGIN { ndups = 0 }
21112$1 ~ /^NSIG$/ { nsig = $2 }
21113($1 !~ /^NSIG$/) && (NF == 2) && ($2 ~ /^[0-9][0-9]*$/) {
21114    if ($2 > maxsig) { maxsig = $2 }
21115    if (sig_name[$2]) {
21116	dup_name[ndups] = $1
21117	dup_num[ndups] = $2
21118	ndups++
21119    }
21120    else {
21121	sig_name[$2] = $1
21122	sig_num[$2] = $2
21123    }
21124}
21125END {
21126    if (nsig == 0) {
21127    	nsig = maxsig + 1
21128    }
21129    printf("NSIG %d\n", nsig);
21130    for (n = 1; n < nsig; n++) {
21131 	if (sig_name[n]) {
21132 	    printf("%s %d\n", sig_name[n], sig_num[n])
21133	}
21134 	else {
21135 	    printf("NUM%d %d\n", n, n)
21136 	}
21137    }
21138    for (n = 0; n < ndups; n++) {
21139 	printf("%s %d\n", dup_name[n], dup_num[n])
21140    }
21141}
21142EOP
21143$cat >signal_cmd <<EOS
21144$startsh
21145if $test -s signal.lst; then
21146    echo "Using your existing signal.lst file"
21147	exit 0
21148fi
21149xxx="$xxx"
21150EOS
21151$cat >>signal_cmd <<'EOS'
21152
21153set signal
21154if eval $compile_ok; then
21155	$run ./signal$_exe | ($sort -n -k 2 2>/dev/null || $sort -n +1) |\
21156		$uniq | $awk -f signal.awk >signal.lst
21157else
21158	echo "(I can't seem be able to compile the whole test program)" >&4
21159	echo "(I'll try it in little pieces.)" >&4
21160	set signal -DJUST_NSIG
21161	if eval $compile_ok; then
21162		$run ./signal$_exe > signal.nsg
21163		$cat signal.nsg
21164	else
21165		echo "I can't seem to figure out how many signals you have." >&4
21166		echo "Guessing 50." >&4
21167		echo 'NSIG 50' > signal.nsg
21168	fi
21169	: Now look at all the signal names, one at a time.
21170	for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
21171		$cat > signal.c <<EOCP
21172#include <sys/types.h>
21173#include <signal.h>
21174#include <stdio.h>
21175int main() {
21176printf("$xx %d\n", SIG${xx});
21177return 0;
21178}
21179EOCP
21180		set signal
21181		if eval $compile; then
21182			echo "SIG${xx} found."
21183			$run ./signal$_exe  >> signal.ls1
21184		else
21185			echo "SIG${xx} NOT found."
21186		fi
21187	done
21188	if $test -s signal.ls1; then
21189		$cat signal.nsg signal.ls1 |
21190			$sort -n | $uniq | $awk -f signal.awk >signal.lst
21191	fi
21192
21193fi
21194if $test -s signal.lst; then
21195	:
21196else
21197	echo "(AAK! I can't compile the test programs -- Guessing)" >&4
21198	echo 'kill -l' >signal
21199	set X `csh -f <signal`
21200	$rm -f signal
21201	shift
21202	case $# in
21203	0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
21204	esac
21205	echo $@ | $tr ' ' $trnl | \
21206 	    $awk '{ printf "%s %d\n", $1, ++s; }
21207 		  END { printf "NSIG %d\n", ++s }' >signal.lst
21208fi
21209$rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
21210EOS
21211chmod a+x signal_cmd
21212$eunicefix signal_cmd
21213
21214: generate list of signal names
21215echo " "
21216case "$sig_name_init" in
21217'') doinit=yes ;;
21218*)  case "$sig_num_init" in
21219    ''|*,*) doinit=yes ;;
21220    esac ;;
21221esac
21222case "$doinit" in
21223yes)
21224	echo "Generating a list of signal names and numbers..." >&4
21225	. ./signal_cmd
21226 	sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
21227 	sig_name=`$awk 'BEGIN { printf "ZERO " }
21228 			!/^NSIG/ { printf "%s ", $1 }' signal.lst`
21229 	sig_num=`$awk  'BEGIN { printf "0 " }
21230 			!/^NSIG/ { printf "%d ", $2 }' signal.lst`
21231 	sig_name_init=`$awk 'BEGIN	{ printf "\"ZERO\", " }
21232 			     !/^NSIG/	{ printf "\"%s\", ", $1 }
21233 			     END	{ printf "0\n" }' signal.lst`
21234 	sig_num_init=`$awk  'BEGIN	{ printf "0, " }
21235 			     !/^NSIG/	{ printf "%d, ", $2}
21236 			     END	{ printf "0\n"}' signal.lst`
21237	;;
21238esac
21239echo "The following $sig_count signals are available:"
21240echo " "
21241echo $sig_name | $awk \
21242'BEGIN { linelen = 0 }
21243{
21244	for (i = 1; i <= NF; i++) {
21245		name = "SIG" $i " "
21246		linelen = linelen + length(name)
21247		if (linelen > 70) {
21248			printf "\n"
21249			linelen = length(name)
21250		}
21251		printf "%s", name
21252	}
21253	printf "\n"
21254}'
21255sig_size=`echo $sig_name | awk '{print NF}'`
21256$rm -f signal signal.c signal.awk signal.lst signal_cmd
21257
21258: Check size of size
21259echo " "
21260case "$sizetype" in
21261*_t) zzz="$sizetype"	;;
21262*)   zzz="filesize"	;;
21263esac
21264echo "Checking the size of $zzz..." >&4
21265cat > try.c <<EOCP
21266#include <sys/types.h>
21267#include <stdio.h>
21268#$i_stdlib I_STDLIB
21269#ifdef I_STDLIB
21270#include <stdlib.h>
21271#endif
21272int main() {
21273    printf("%d\n", (int)sizeof($sizetype));
21274    exit(0);
21275}
21276EOCP
21277set try
21278if eval $compile_ok; then
21279	yyy=`$run ./try`
21280	case "$yyy" in
21281	'')	sizesize=4
21282		echo "(I can't execute the test program--guessing $sizesize.)" >&4
21283		;;
21284	*)	sizesize=$yyy
21285		echo "Your $zzz size is $sizesize bytes."
21286		;;
21287	esac
21288else
21289	sizesize=4
21290	echo "(I can't compile the test program--guessing $sizesize.)" >&4
21291fi
21292
21293
21294: check for socklen_t
21295echo " "
21296echo "Checking to see if you have socklen_t..." >&4
21297$cat >try.c <<EOCP
21298#include <sys/types.h>
21299#$d_socket HAS_SOCKET
21300#ifdef HAS_SOCKET
21301#include <sys/socket.h>
21302#endif
21303int main() { socklen_t x = 16; }
21304EOCP
21305set try
21306if eval $compile; then
21307	val="$define"
21308	echo "You have socklen_t."
21309else
21310	val="$undef"
21311	echo "You do not have socklen_t."
21312	case "$sizetype" in
21313	size_t) echo "(You do have size_t, that might work. Some people are happy with just an int.)" ;;
21314	esac
21315fi
21316$rm_try
21317set d_socklen_t
21318eval $setvar
21319
21320: see if this is a socks.h system
21321set socks.h i_socks
21322eval $inhdr
21323
21324: check for type of the size argument to socket calls
21325case "$d_socket" in
21326"$define")
21327	$cat <<EOM
21328
21329Checking to see what type is the last argument of accept().
21330EOM
21331	yyy=''
21332	case "$d_socklen_t" in
21333	"$define") yyy="$yyy socklen_t"
21334	esac
21335	yyy="$yyy $sizetype int long unsigned"
21336	for xxx in $yyy; do
21337		case "$socksizetype" in
21338		'')	try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
21339			case "$usesocks" in
21340			"$define")
21341				if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
21342					echo "Your system accepts '$xxx *' for the last argument of accept()."
21343					socksizetype="$xxx"
21344				fi
21345				;;
21346			*)	if ./protochk "$try"  $i_systypes sys/types.h $d_socket sys/socket.h; then
21347					echo "Your system accepts '$xxx *' for the last argument of accept()."
21348					socksizetype="$xxx"
21349				fi
21350				;;
21351			esac
21352			;;
21353		esac
21354	done
21355: In case none of those worked, prompt the user.
21356	case "$socksizetype" in
21357	'')	rp='What is the type for socket address structure sizes?'
21358		dflt='int'
21359		. ./myread
21360		socksizetype=$ans
21361		;;
21362	esac
21363	;;
21364*)	: no sockets, so pick relatively harmless default
21365	socksizetype='int'
21366	;;
21367esac
21368
21369: see what type is used for signed size_t
21370set ssize_t ssizetype int stdio.h sys/types.h
21371eval $typedef
21372dflt="$ssizetype"
21373$cat > try.c <<EOM
21374#include <stdio.h>
21375#$i_stdlib I_STDLIB
21376#ifdef I_STDLIB
21377#include <stdlib.h>
21378#endif
21379#include <sys/types.h>
21380#define Size_t $sizetype
21381#define SSize_t $dflt
21382int main()
21383{
21384	if (sizeof(Size_t) == sizeof(SSize_t))
21385		printf("$dflt\n");
21386	else if (sizeof(Size_t) == sizeof(int))
21387		printf("int\n");
21388	else
21389		printf("long\n");
21390	exit(0);
21391}
21392EOM
21393echo " "
21394set try
21395if eval $compile_ok && $run ./try > /dev/null; then
21396	ssizetype=`$run ./try`
21397	echo "I'll be using $ssizetype for functions returning a byte count." >&4
21398else
21399	$cat >&4 <<EOM
21400Help! I can't compile and run the ssize_t test program: please enlighten me!
21401(This is probably a misconfiguration in your system or libraries, and
21402you really ought to fix it.  Still, I'll try anyway.)
21403
21404I need a type that is the same size as $sizetype, but is guaranteed to
21405be signed.  Common values are ssize_t, int and long.
21406
21407EOM
21408	rp="What signed type is the same size as $sizetype?"
21409	. ./myread
21410	ssizetype="$ans"
21411fi
21412$rm_try
21413
21414: Check the size of st_ino
21415$echo " "
21416$echo "Checking the size of st_ino..." >&4
21417$cat > try.c <<EOCP
21418#include <sys/stat.h>
21419#include <stdio.h>
21420#$i_stdlib I_STDLIB
21421#ifdef I_STDLIB
21422#include <stdlib.h>
21423#endif
21424int main() {
21425    struct stat st;
21426    printf("%d\n", (int)sizeof(st.st_ino));
21427    exit(0);
21428}
21429EOCP
21430set try
21431if eval $compile_ok; then
21432	val=`$run ./try`
21433	case "$val" in
21434	'')	st_ino_size=4
21435		$echo "(I can't execute the test program--guessing $st_ino_size.)" >&4
21436		;;
21437	*)	st_ino_size=$val
21438		$echo "Your st_ino is $st_ino_size bytes long."
21439		;;
21440	esac
21441else
21442	st_ino_size=4
21443	$echo "(I can't compile the test program--guessing $st_ino_size.)" >&4
21444fi
21445$rm_try
21446
21447: Check if st_ino is signed
21448$echo " "
21449$echo "Checking the sign of st_ino..." >&4
21450$cat > try.c <<EOCP
21451#include <sys/stat.h>
21452#include <stdio.h>
21453int main() {
21454	struct stat foo;
21455        foo.st_ino = -1;
21456	if (foo.st_ino < 0)
21457		printf("-1\n");
21458	else
21459		printf("1\n");
21460}
21461EOCP
21462set try
21463if eval $compile; then
21464	val=`$run ./try`
21465	case "$val" in
21466	'')	st_ino_sign=1
21467		$echo "(I can't execute the test program--guessing unsigned.)" >&4
21468		;;
21469	*)	st_ino_sign=$val
21470		case "$st_ino_sign" in
21471		 1) $echo "Your st_ino is unsigned." ;;
21472		-1) $echo "Your st_ino is signed."   ;;
21473		esac
21474		;;
21475	esac
21476else
21477	st_ino_sign=1
21478	$echo "(I can't compile the test program--guessing unsigned.)" >&4
21479fi
21480$rm_try
21481
21482: see what type of char stdio uses.
21483echo " "
21484echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
21485if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
21486	echo "Your stdio uses unsigned chars." >&4
21487	stdchar="unsigned char"
21488else
21489	echo "Your stdio uses signed chars." >&4
21490	stdchar="char"
21491fi
21492$rm -f stdioh
21493
21494: see what type uids are declared as in the kernel
21495echo " "
21496echo "Looking for the type for user ids returned by getuid()."
21497set uid_t uidtype xxx stdio.h sys/types.h
21498eval $typedef
21499case "$uidtype" in
21500xxx)
21501	xxx=`./findhdr sys/user.h`
21502	set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
21503	case $1 in
21504	unsigned) dflt="$1 $2" ;;
21505	*) dflt="$1" ;;
21506	esac
21507	;;
21508*) dflt="$uidtype";;
21509esac
21510case "$uidtype" in
21511uid_t)	echo "uid_t found." ;;
21512*)	rp="What is the type for user ids returned by getuid()?"
21513	. ./myread
21514	uidtype="$ans"
21515	;;
21516esac
21517
21518: Check size of UID
21519echo " "
21520case "$uidtype" in
21521*_t) zzz="$uidtype"	;;
21522*)   zzz="uid"		;;
21523esac
21524echo "Checking the size of $zzz..." >&4
21525cat > try.c <<EOCP
21526#include <sys/types.h>
21527#include <stdio.h>
21528#$i_stdlib I_STDLIB
21529#ifdef I_STDLIB
21530#include <stdlib.h>
21531#endif
21532int main() {
21533    printf("%d\n", (int)sizeof($uidtype));
21534    exit(0);
21535}
21536EOCP
21537set try
21538if eval $compile_ok; then
21539	yyy=`$run ./try`
21540	case "$yyy" in
21541	'')	uidsize=4
21542		echo "(I can't execute the test program--guessing $uidsize.)" >&4
21543		;;
21544	*)	uidsize=$yyy
21545		echo "Your $zzz is $uidsize bytes long."
21546		;;
21547	esac
21548else
21549	uidsize=4
21550	echo "(I can't compile the test program--guessing $uidsize.)" >&4
21551fi
21552
21553: Check if UID is signed
21554echo " "
21555case "$uidtype" in
21556*_t) zzz="$uidtype"	;;
21557*)   zzz="uid"		;;
21558esac
21559echo "Checking the sign of $zzz..." >&4
21560cat > try.c <<EOCP
21561#include <sys/types.h>
21562#include <stdio.h>
21563int main() {
21564	$uidtype foo = -1;
21565	if (foo < 0)
21566		printf("-1\n");
21567	else
21568		printf("1\n");
21569}
21570EOCP
21571set try
21572if eval $compile; then
21573	yyy=`$run ./try`
21574	case "$yyy" in
21575	'')	uidsign=1
21576		echo "(I can't execute the test program--guessing unsigned.)" >&4
21577		;;
21578	*)	uidsign=$yyy
21579		case "$uidsign" in
21580		 1) echo "Your $zzz is unsigned." ;;
21581		-1) echo "Your $zzz is signed."   ;;
21582		esac
21583		;;
21584	esac
21585else
21586	uidsign=1
21587	echo "(I can't compile the test program--guessing unsigned.)" >&4
21588fi
21589
21590
21591: Check format string for UID
21592echo " "
21593$echo "Checking the format string to be used for uids..." >&4
21594
21595case "$uidsign" in
21596-1)	if $test X"$uidsize" = X"$ivsize"; then
21597		uidformat="$ivdformat"
21598	else
21599		if $test X"$uidsize" = X"$longsize"; then
21600			uidformat='"ld"'
21601		else
21602			if $test X"$uidsize" = X"$intsize"; then
21603				uidformat='"d"'
21604			else
21605				if $test X"$uidsize" = X"$shortsize"; then
21606					uidformat='"hd"'
21607				fi
21608			fi
21609		fi
21610	fi
21611	;;
21612*)	if $test X"$uidsize" = X"$uvsize"; then
21613		uidformat="$uvuformat"
21614	else
21615		if $test X"$uidsize" = X"$longsize"; then
21616			uidformat='"lu"'
21617		else
21618			if $test X"$uidsize" = X"$intsize"; then
21619				uidformat='"u"'
21620			else
21621				if $test X"$uidsize" = X"$shortsize"; then
21622					uidformat='"hu"'
21623				fi
21624			fi
21625		fi
21626	fi
21627	;;
21628esac
21629
21630: Determine if we can use sysctl with KERN_PROC_PATHNAME to find executing program
21631echo " "
21632echo "Determining whether we can use sysctl with KERN_PROC_PATHNAME to find executing program..." >&4
21633$cat >try.c <<'EOM'
21634/* Intentionally a long probe as I'd like to sanity check that the exact
21635   approach is going to work, as thinking it will work, but only having it
21636   part working at runtime is worse than not having it.  */
21637
21638#include <sys/types.h>
21639#include <sys/sysctl.h>
21640#include <sys/param.h>
21641#include <stdio.h>
21642#include <string.h>
21643#include <stdlib.h>
21644#include <unistd.h>
21645
21646int
21647main(int argc, char **argv) {
21648    char *buffer;
21649    char *argv_leaf = strrchr(argv[0], '/');
21650    char *buffer_leaf;
21651    size_t size = 0;
21652    int mib[4];
21653
21654    mib[0] = CTL_KERN;
21655    mib[1] = KERN_PROC;
21656    mib[2] = KERN_PROC_PATHNAME;
21657    mib[3] = -1;
21658
21659    if (!argv_leaf) {
21660	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
21661	return 1;
21662    }
21663
21664    if (sysctl(mib, 4, NULL, &size, NULL, 0)) {
21665	perror("sysctl");
21666	return 2;
21667    }
21668
21669    if (size < strlen(argv_leaf) + 1) {
21670	fprintf(stderr, "size %lu is too short for a path\n",
21671		(unsigned long) size);
21672	return 3;
21673    }
21674
21675    if (size > MAXPATHLEN * MAXPATHLEN) {
21676	fprintf(stderr, "size %lu is too long for a path\n",
21677		(unsigned long) size);
21678	return 4;
21679    }
21680
21681    buffer = malloc(size);
21682    if (!buffer) {
21683	perror("malloc");
21684	return 5;
21685    }
21686
21687    if (sysctl(mib, 4, buffer, &size, NULL, 0)) {
21688	perror("sysctl");
21689	return 6;
21690    }
21691
21692    if (strlen(buffer) + 1 != size) {
21693	fprintf(stderr, "size != strlen(buffer) + 1 (%lu != %lu)\n",
21694		(unsigned long)size, (unsigned long)strlen(buffer) + 1);
21695        return 7;
21696    }
21697
21698
21699    if (*buffer != '/') {
21700	fprintf(stderr, "Not an absolute path: '%s'\n", buffer);
21701	return 8;
21702    }
21703
21704    if (strstr(buffer, "/./")) {
21705	fprintf(stderr, "Contains /./: '%s'\n", buffer);
21706	return 9;
21707    }
21708
21709    if (strstr(buffer, "/../")) {
21710	fprintf(stderr, "Contains /../: '%s'\n", buffer);
21711	return 10;
21712    }
21713
21714    buffer_leaf = strrchr(buffer, '/');
21715    if (strcmp(buffer_leaf, argv_leaf) != 0) {
21716	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], buffer);
21717	return 11;
21718    }
21719
21720    free(buffer);
21721
21722    return 0;
21723}
21724EOM
21725
21726val=$undef
21727set try
21728if eval $compile; then
21729	if $run ./try; then
21730		echo "You can use sysctl with KERN_PROC_PATHNAME to find the executing program." >&4
21731		val="$define"
21732	else
21733		echo "Nope, sysctl with KERN_PROC_PATHNAME doesn't work here." >&4
21734		val="$undef"
21735	fi
21736else
21737	echo "I'm unable to compile the test program." >&4
21738	echo "I'll assume no sysctl with KERN_PROC_PATHNAME here." >&4
21739	val="$undef"
21740fi
21741$rm_try
21742set usekernprocpathname
21743eval $setvar
21744
21745: Determine if we can use _NSGetExecutablePath to find executing program
21746echo " "
21747echo "Determining whether we can use _NSGetExecutablePath to find executing program..." >&4
21748$cat >try.c <<'EOM'
21749/* Intentionally a long probe as I'd like to sanity check that the exact
21750   approach is going to work, as thinking it will work, but only having it
21751   part working at runtime is worse than not having it.  */
21752#include <mach-o/dyld.h>
21753#include <stdio.h>
21754#include <stdlib.h>
21755#include <sys/param.h>
21756#include <string.h>
21757
21758int
21759main(int argc, char **argv) {
21760    char buf[1];
21761    uint32_t size = sizeof(buf);
21762    int result;
21763    char *buffer;
21764    char *tidied;
21765    char *argv_leaf = strrchr(argv[0], '/');
21766    char *tidied_leaf;
21767
21768    if (!argv_leaf) {
21769	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
21770	return 1;
21771    }
21772
21773    _NSGetExecutablePath(buf, &size);
21774    if (size > MAXPATHLEN * MAXPATHLEN) {
21775	fprintf(stderr, "_NSGetExecutablePath size %u is too long for a path\n",
21776		(unsigned int) size);
21777	return 2;
21778    }
21779
21780    buffer = malloc(size);
21781    if (!buffer) {
21782	perror("malloc");
21783	return 3;
21784    }
21785
21786    result = _NSGetExecutablePath(buffer, &size);
21787    if (result != 0) {
21788	fprintf(stderr, "_NSGetExecutablePath returned %i for a size of %u\n",
21789		result, (unsigned int) size);
21790	return 4;
21791    }
21792
21793    tidied = realpath(buffer, NULL);
21794    if (!tidied) {
21795	perror("realpath");
21796	return 5;
21797    }
21798
21799    free(buffer);
21800
21801    if (*tidied != '/') {
21802	fprintf(stderr, "Not an absolute path: '%s'\n", tidied);
21803	return 6;
21804    }
21805
21806    if (strstr(tidied, "/./")) {
21807	fprintf(stderr, "Contains /./: '%s'\n", tidied);
21808	return 7;
21809    }
21810
21811    if (strstr(tidied, "/../")) {
21812	fprintf(stderr, "Contains /../: '%s'\n", tidied);
21813	return 8;
21814    }
21815
21816    tidied_leaf = strrchr(tidied, '/');
21817    if (strcmp(tidied_leaf, argv_leaf) != 0) {
21818	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], tidied);
21819	return 9;
21820    }
21821
21822    free(tidied);
21823
21824    return 0;
21825}
21826EOM
21827
21828val=$undef
21829set try
21830if eval $compile; then
21831	if $run ./try; then
21832		echo "You can use _NSGetExecutablePath to find the executing program." >&4
21833		val="$define"
21834	else
21835		echo "Nope, _NSGetExecutablePath doesn't work here." >&4
21836	fi
21837else
21838	echo "I'm unable to compile the test program." >&4
21839	echo "I'll assume no _NSGetExecutablePath here." >&4
21840fi
21841$rm_try
21842set usensgetexecutablepath
21843eval $setvar
21844
21845: Check if site customization support was requested
21846case "$usesitecustomize" in
21847    $define|true|[Yy]*)
21848	usesitecustomize="$define"
21849	;;
21850    *)
21851	usesitecustomize="$undef"
21852	;;
21853    esac
21854
21855: see if prototypes support variable argument declarations
21856echo " "
21857case "$prototype$i_stdarg" in
21858$define$define)
21859	echo "It appears we'll be able to prototype varargs functions." >&4
21860	val="$define"
21861	;;
21862*)
21863	echo "Too bad... We won't be using prototyped varargs functions..." >&4
21864	val="$undef"
21865	;;
21866esac
21867set vaproto
21868eval $setvar
21869
21870: determine compiler compiler
21871case "$yacc" in
21872'')
21873	dflt=yacc;;
21874*)
21875	dflt="$yacc";;
21876esac
21877echo " "
21878comp='yacc'
21879if $test -f "$byacc$_exe"; then
21880	dflt="$byacc"
21881	comp="byacc or $comp"
21882fi
21883if $test -f "$bison$_exe"; then
21884	comp="$comp or bison -y"
21885fi
21886rp="Which compiler compiler ($comp) shall I use?"
21887. ./myread
21888yacc="$ans"
21889case "$yacc" in
21890*bis*)
21891	case "$yacc" in
21892	*-y*) ;;
21893	*)
21894		yacc="$yacc -y"
21895		echo "(Adding -y option to bison to get yacc-compatible behavior.)"
21896		;;
21897	esac
21898	;;
21899esac
21900
21901: see if this is a assert.h system
21902set assert.h i_assert
21903eval $inhdr
21904
21905: see if this is a fp.h system
21906set fp.h i_fp
21907eval $inhdr
21908
21909: see if this is a fp_class.h system
21910set fp_class.h i_fp_class
21911eval $inhdr
21912
21913: see if gdbm.h is available
21914set gdbm.h t_gdbm
21915eval $inhdr
21916case "$t_gdbm" in
21917$define)
21918	: see if gdbm_open exists
21919	set gdbm_open d_gdbm_open
21920	eval $inlibc
21921	case "$d_gdbm_open" in
21922	$undef)
21923		t_gdbm="$undef"
21924		echo "We won't be including <gdbm.h>"
21925		;;
21926	esac
21927	;;
21928esac
21929val="$t_gdbm"
21930set i_gdbm
21931eval $setvar
21932
21933: see if this is a ieeefp.h system
21934case "$i_ieeefp" in
21935'' ) set ieeefp.h i_ieeefp
21936     eval $inhdr
21937     ;;
21938esac
21939
21940: see if this is a libutil.h system
21941set libutil.h i_libutil
21942eval $inhdr
21943
21944: see if mach cthreads are available
21945if test "X$usethreads" = "X$define"; then
21946	set mach/cthreads.h i_machcthr
21947	eval $inhdr
21948else
21949	i_machcthr="$undef"
21950fi
21951
21952: see if this is a mntent.h system
21953set mntent.h i_mntent
21954eval $inhdr
21955
21956: see if net/errno.h is available
21957val=''
21958set net/errno.h val
21959eval $inhdr
21960
21961: Unfortunately, it causes problems on some systems.  Arrgh.
21962case "$val" in
21963$define)
21964	cat > try.c <<'EOM'
21965#include <stdio.h>
21966#include <errno.h>
21967#include <net/errno.h>
21968int func()
21969{
21970	return ENOTSOCK;
21971}
21972EOM
21973	if $cc $ccflags -c try.c >/dev/null 2>&1; then
21974		echo "We'll be including <net/errno.h>." >&4
21975	else
21976		echo "We won't be including <net/errno.h>." >&4
21977		val="$undef"
21978	fi
21979	$rm_try
21980	;;
21981esac
21982set i_neterrno
21983eval $setvar
21984
21985: see if netinet/tcp.h is available
21986set netinet/tcp.h i_netinettcp
21987eval $inhdr
21988
21989: see if this is a poll.h system
21990set poll.h i_poll
21991eval $inhdr
21992
21993: see if this is a prot.h system
21994set prot.h i_prot
21995eval $inhdr
21996
21997: Preprocessor symbols
21998echo " "
21999$echo "Guessing which symbols your C compiler and preprocessor define..." >&4
22000$cat <<'EOSH' > Cppsym.know
22001a29k ABI64 aegis AES_SOURCE AIX AIX32 AIX370
22002AIX41 AIX42 AIX43 AIX_SOURCE aixpc ALL_SOURCE
22003alliant alpha am29000 AM29000 AMD64 amd64 amiga AMIGAOS AMIX
22004ansi ANSI_C_SOURCE apollo ardent ARM32 atarist att386 att3b
22005BeOS BIG_ENDIAN BIT_MSF bsd BSD bsd43 bsd4_2 bsd4_3 BSD4_3 bsd4_4
22006BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES BSDCOMPAT bsdi
22007bull c cadmus clipper CMU COFF COMPILER_VERSION
22008concurrent convex cpu cray CRAY CRAYMPP ctix CX_UX
22009CYGWIN DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO
22010Dynix DynixPTX ELF encore EPI EXTENSIONS FAVOR_BSD
22011FILE_OFFSET_BITS FreeBSD GCC_NEW_VARARGS gcos gcx gimpel
22012GLIBC GLIBC_MINOR
22013GNU_SOURCE GNUC GNUC_MINOR GNU_LIBRARY GO32 gould GOULD_PN
22014H3050R H3050RX hbullx20 hcx host_mips
22015hp200 hp300 hp700 HP700 hp800 hp9000
22016hp9000s200 hp9000s300 hp9000s400 hp9000s500
22017hp9000s700 hp9000s800 hp9k8 hp_osf hppa hpux HPUX_SOURCE
22018i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960
22019IA64 iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
22020INLINE_INTRINSICS INTRINSICS INT64 interdata is68k ksr1
22021LANGUAGE_C LARGE_FILE_API LARGEFILE64_SOURCE
22022LARGEFILE_SOURCE LFS64_LARGEFILE LFS_LARGEFILE
22023LIBCATAMOUNT Linux LITTLE_ENDIAN LONG64 LONG_DOUBLE LONG_LONG
22024LONGDOUBLE LONGLONG LP64 luna luna88k Lynx
22025M68000 m68k m88100 m88k M88KBCS_TARGET M_COFF
22026M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM M_SYS3
22027M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX MACH machine MachTen
22028MATH_HAS_NO_SIDE_EFFECTS
22029mc300 mc500 mc68000 mc68010 mc68020 mc68030 mc68040
22030mc68060 mc68k mc68k32 mc700 mc88000 mc88100 merlin
22031mert MiNT mips MIPS_FPSET MIPS_ISA MIPS_SIM MIPS_SZINT
22032MIPS_SZLONG MIPS_SZPTR MIPSEB MIPSEL MODERN_C motorola
22033mpeix MSDOS MTXINU MULTIMAX mvs MVS n16 ncl_el ncl_mr
22034NetBSD news1500 news1700 news1800 news1900 news3700
22035news700 news800 news900 NeXT NLS nonstopux ns16000 ns32000
22036ns32016 ns32332 ns32k nsc32000
22037OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
22038pa_risc PA_RISC1_1 PA_RISC2_0 PARAGON parisc
22039pc532 pdp11 PGC PIC plexus PORTAR posix
22040POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
22041POSIX_C_SOURCE POSIX_SOURCE POWER
22042PROTOTYPES PWB pyr QNX QK_USER R3000 REENTRANT RES Rhapsody RISC6000
22043riscix riscos RT S390 SA110 scs SCO sequent sgi SGI_SOURCE SH3 sinix
22044SIZE_INT SIZE_LONG SIZE_PTR SOCKET_SOURCE SOCKETS_SOURCE
22045sony sony_news sonyrisc sparc sparclite spectrum
22046stardent stdc STDC_EXT stratos sun sun3 sun386
22047Sun386i svr3 svr4 SVR4_2 SVR4_SOURCE svr5
22048SX system SYSTYPE_BSD SYSTYPE_BSD43 SYSTYPE_BSD44
22049SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3 SYSV4 SYSV5
22050sysV68 sysV88 Tek4132 Tek4300 titan
22051TM3200 TM5400 TM5600
22052tower tower32 tower32_200 tower32_600 tower32_700
22053tower32_800 tower32_850 tss
22054u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5
22055ultrix UMAXV UnicomPBB UnicomPBD UNICOS UNICOSMK
22056unix UNIX95 UNIX99 unixpc unos
22057USE_BSD USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE USE_LARGEFILE64
22058USE_MISC USE_POSIX USE_POSIX199309 USE_POSIX199506 USE_POSIX2
22059USE_REENTRANT USE_SVID USE_UNIX98 USE_XOPEN USE_XOPEN_EXTENDED
22060USGr4 USGr4_2
22061Utek UTek UTS UWIN uxpm uxps vax venix VMESA vms x86_64 xenix Xenix286
22062XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2 XPG2_EXTENDED
22063XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
22064z8000
22065EOSH
22066# Maybe put other stuff here too.
22067./tr '-' '_' <<EOSH >>Cppsym.know
22068$osname
22069EOSH
22070./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
22071./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b
22072$cat Cppsym.know > Cppsym.c
22073$cat Cppsym.a Cppsym.b Cppsym.c | $tr ' ' $trnl | $sort | $uniq > Cppsym.know
22074$rm -f Cppsym.a Cppsym.b Cppsym.c
22075cat <<EOSH > Cppsym
22076$startsh
22077if $test \$# -gt 0; then
22078    echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
22079    if $test -s Cppsym.got; then
22080        $rm -f Cppsym.got
22081        exit 0
22082    fi
22083    $rm -f Cppsym.got
22084    exit 1
22085else
22086    $tr " " "$trnl" | ./Cppsym.try
22087    exit 0
22088fi
22089EOSH
22090chmod +x Cppsym
22091$eunicefix Cppsym
22092cat <<EOSH > Cppsym.try
22093$startsh
22094cat <<'EOCP' > try.c
22095#include <stdio.h>
22096#if cpp_stuff == 1
22097#define STRINGIFY(a)    "a"
22098#endif
22099#if cpp_stuff == 42
22100#define StGiFy(a)  #a
22101#define STRINGIFY(a)    StGiFy(a)
22102#endif
22103#if $cpp_stuff != 1 && $cpp_stuff != 42
22104#   include "Bletch: How does this C preprocessor stringify macros?"
22105#endif
22106int main() {
22107EOCP
22108$awk \\
22109EOSH
22110cat <<'EOSH' >> Cppsym.try
22111'length($1) > 0 {
22112    printf "#ifdef %s\nprintf(\"%s=%%s\\n\", STRINGIFY(%s));\n#endif\n", $1, $1, $1
22113    printf "#ifdef _%s\nprintf(\"_%s=%%s\\n\", STRINGIFY(_%s));\n#endif\n", $1, $1, $1
22114    printf "#ifdef __%s\nprintf(\"__%s=%%s\\n\", STRINGIFY(__%s));\n#endif\n", $1, $1, $1
22115    printf "#ifdef __%s__\nprintf(\"__%s__=%%s\\n\", STRINGIFY(__%s__));\n#endif\n", $1, $1, $1
22116}'	 >> try.c
22117echo 'return 0;}' >> try.c
22118EOSH
22119cat <<EOSH >> Cppsym.try
22120ccflags="$ccflags"
22121case "$osname-$gccversion" in
22122irix-) ccflags="\$ccflags -woff 1178" ;;
22123os2-*) ccflags="\$ccflags -Zlinker /PM:VIO" ;;
22124esac
22125$cc -o try -Dcpp_stuff=$cpp_stuff $optimize \$ccflags $ldflags try.c $libs && $run ./try | $sed 's/ /\\\\ /g'
22126EOSH
22127chmod +x Cppsym.try
22128$eunicefix Cppsym.try
22129./Cppsym < Cppsym.know | $sort | $uniq > Cppsym.true
22130: Add in any Linux cpp "predefined macros":
22131case "$osname::$gccversion" in
22132  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
22133    tHdrH=_tmpHdr
22134    rm -f $tHdrH'.h' $tHdrH
22135    touch $tHdrH'.h'
22136    # Filter out macro arguments, such as Linux's __INT8_C(c)
22137    if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
22138       sed -e 's/#define[\ \  ]*//;s/[\ \     ].*$//' -e 's/(.*//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
22139       if [ -s $tHdrH'_cppsym.real' ]; then
22140	  cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
22141       fi
22142    fi
22143    rm -f $tHdrH'.h' $tHdrH'_cppsym.h' $tHdrH'_cppsym.real'
22144  ;;
22145esac
22146: now check the C compiler for additional symbols
22147postprocess_cc_v=''
22148case "$osname" in
22149aix) postprocess_cc_v="|$tr , ' '" ;;
22150esac
22151$cat >ccsym <<EOS
22152$startsh
22153$cat >tmp.c <<EOF
22154extern int foo;
22155EOF
22156for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
22157do
22158	case "\$i" in
22159	-D*) echo "\$i" | $sed 's/^-D//';;
22160	-A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A//' | $sed 's/\(.*\)(\(.*\))/\1=\2/';;
22161	esac
22162done
22163$rm_try
22164EOS
22165postprocess_cc_v=''
22166chmod +x ccsym
22167$eunicefix ccsym
22168./ccsym > ccsym1.raw
22169if $test -s ccsym1.raw; then
22170       $sort ccsym1.raw | $uniq >ccsym.raw
22171else
22172       mv ccsym1.raw ccsym.raw
22173fi
22174
22175$awk '/\=/ { print $0; next }
22176	{ print $0"=1" }' ccsym.raw >ccsym.list
22177$comm -13 Cppsym.true ccsym.list >ccsym.own
22178$comm -12 Cppsym.true ccsym.list >ccsym.com
22179$comm -23 Cppsym.true ccsym.list >ccsym.cpp
22180also=''
22181if $test -z ccsym.raw; then
22182	echo "Your C compiler doesn't seem to define any symbols!" >&4
22183	echo " "
22184	echo "However, your C preprocessor defines the following symbols:"
22185	$cat Cppsym.true
22186    	ccsymbols=''
22187	cppsymbols=`$cat Cppsym.true`
22188        cppsymbols=`echo $cppsymbols`
22189	cppccsymbols="$cppsymbols"
22190else
22191	if $test -s ccsym.com; then
22192		echo "Your C compiler and pre-processor define these symbols:"
22193		$sed -e 's/\(..*\)=.*/\1/' ccsym.com
22194		also='also '
22195		symbols='ones'
22196		cppccsymbols=`$cat ccsym.com`
22197		cppccsymbols=`echo $cppccsymbols`
22198		$test "$silent" || sleep 1
22199	fi
22200	if $test -s ccsym.cpp; then
22201		$test "$also" && echo " "
22202		echo "Your C pre-processor ${also}defines the following symbols:"
22203		$sed -e 's/\(..*\)=.*/\1/' ccsym.cpp
22204		also='further '
22205		cppsymbols=`$cat ccsym.cpp`
22206		cppsymbols=`echo $cppsymbols`
22207		$test "$silent" || sleep 1
22208	fi
22209	if $test -s ccsym.own; then
22210		$test "$also" && echo " "
22211		echo "Your C compiler ${also}defines the following cpp symbols:"
22212		$sed -e 's/\(..*\)=1/\1/' ccsym.own
22213		$sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
22214	        ccsymbols=`$cat ccsym.own`
22215	        ccsymbols=`echo $ccsymbols`
22216		$test "$silent" || sleep 1
22217	fi
22218fi
22219
22220: see if this is a termio system
22221val="$undef"
22222val2="$undef"
22223val3="$undef"
22224if $test `./findhdr termios.h`; then
22225    set tcsetattr i_termios
22226    eval $inlibc
22227    val3="$i_termios"
22228fi
22229echo " "
22230case "$val3" in
22231    "$define") echo "You have POSIX termios.h... good!" >&4;;
22232    *)  if ./Cppsym pyr; then
22233	    case "`$run /bin/universe`" in
22234		ucb) if $test `./findhdr sgtty.h`; then
22235			val2="$define"
22236			echo "<sgtty.h> found." >&4
22237		    else
22238			echo "System is pyramid with BSD universe."
22239			./warn "<sgtty.h> not found--you could have problems."
22240		    fi;;
22241		*)  if $test `./findhdr termio.h`; then
22242			val="$define"
22243			echo "<termio.h> found." >&4
22244		    else
22245			echo "System is pyramid with USG universe."
22246			./warn "<termio.h> not found--you could have problems."
22247		    fi;;
22248	    esac
22249	elif ./usg; then
22250	    if $test `./findhdr termio.h`; then
22251		echo "<termio.h> found." >&4
22252		val="$define"
22253	    elif $test `./findhdr sgtty.h`; then
22254		echo "<sgtty.h> found." >&4
22255		val2="$define"
22256	    else
22257		./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
22258	    fi
22259	else
22260	    if $test `./findhdr sgtty.h`; then
22261		echo "<sgtty.h> found." >&4
22262		val2="$define"
22263	    elif $test `./findhdr termio.h`; then
22264		echo "<termio.h> found." >&4
22265		val="$define"
22266	    else
22267		./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
22268	    fi
22269	fi;;
22270esac
22271set i_termio; eval $setvar
22272val=$val2; set i_sgtty; eval $setvar
22273val=$val3; set i_termios; eval $setvar
22274
22275: see if stdbool is available
22276: we want a real compile instead of Inhdr because some Solaris systems
22277: have stdbool.h, but it can only be used if the compiler indicates it
22278: is sufficiently c99-compliant.
22279echo " "
22280$cat >try.c <<EOCP
22281#include <stdio.h>
22282#include <stdbool.h>
22283int func(bool x)
22284{
22285    return x ? 1 : 0;
22286}
22287int main(int argc, char **argv)
22288{
22289    return func(0);
22290}
22291EOCP
22292set try
22293if eval $compile; then
22294	echo "<stdbool.h> found." >&4
22295	val="$define"
22296else
22297	echo "<stdbool.h> NOT found." >&4
22298	val="$undef"
22299fi
22300$rm_try
22301set i_stdbool
22302eval $setvar
22303
22304: see if stddef is available
22305set stddef.h i_stddef
22306eval $inhdr
22307
22308: see if sys/access.h is available
22309set sys/access.h i_sysaccess
22310eval $inhdr
22311
22312: see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
22313set sys/filio.h i_sysfilio
22314eval $inhdr
22315echo " "
22316if $test `./findhdr sys/ioctl.h`; then
22317	val="$define"
22318	echo '<sys/ioctl.h> found.' >&4
22319else
22320	val="$undef"
22321	if $test $i_sysfilio = "$define"; then
22322	    echo '<sys/ioctl.h> NOT found.' >&4
22323	else
22324		$test $i_sgtty = "$define" && xxx="sgtty.h"
22325		$test $i_termio = "$define" && xxx="termio.h"
22326		$test $i_termios = "$define" && xxx="termios.h"
22327echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
22328	fi
22329fi
22330set i_sysioctl
22331eval $setvar
22332
22333: see if socket ioctl defs are in sys/sockio.h
22334echo " "
22335xxx=`./findhdr sys/sockio.h`
22336if $test "$xxx"; then
22337	if $contains SIOCATMARK $xxx >/dev/null 2>&1; then
22338		val="$define"
22339		echo "You have socket ioctls defined in <sys/sockio.h>." >&4
22340	else
22341		val="$undef"
22342		echo "No socket ioctls found in <sys/sockio.h>." >&4
22343	fi
22344else
22345	val="$undef"
22346	$cat <<EOM
22347<sys/sockio.h> not found, assuming socket ioctls are in <sys/ioctl.h>.
22348EOM
22349fi
22350set i_syssockio
22351eval $setvar
22352
22353: see if this is a syslog.h system
22354set syslog.h i_syslog
22355eval $inhdr
22356
22357: see if this is a sys/mode.h system
22358set sys/mode.h i_sysmode
22359eval $inhdr
22360
22361: see if there is a sys/poll.h file
22362set sys/poll.h i_syspoll
22363eval $inhdr
22364
22365: see if sys/resource.h has to be included
22366set sys/resource.h i_sysresrc
22367eval $inhdr
22368
22369: see if sys/security.h is available
22370set sys/security.h i_syssecrt
22371eval $inhdr
22372
22373: see if this is a sys/statvfs.h system
22374set sys/statvfs.h i_sysstatvfs
22375eval $inhdr
22376
22377: see if this is a sys/un.h system
22378set sys/un.h i_sysun
22379eval $inhdr
22380
22381: see if this is a sys/utsname.h system
22382set sys/utsname.h i_sysutsname
22383eval $inhdr
22384
22385: see if this is a syswait system
22386set sys/wait.h i_syswait
22387eval $inhdr
22388
22389: see if this is a ustat.h system
22390set ustat.h i_ustat
22391eval $inhdr
22392
22393: see if this is an utime system
22394set utime.h i_utime
22395eval $inhdr
22396
22397: see if this is a vfork system
22398case "$d_vfork" in
22399"$define")
22400	set vfork.h i_vfork
22401	eval $inhdr
22402	;;
22403*)
22404	i_vfork="$undef"
22405	;;
22406esac
22407
22408: Check extensions
22409echo " "
22410echo "Looking for extensions..." >&4
22411: If we are using the old config.sh, nonxs_extensions and xs_extensions may
22412: contain old or inaccurate or duplicate values.
22413nonxs_extensions=''
22414xs_extensions=''
22415: We do not use find because it might not be available.
22416: We do not just use MANIFEST because the user may have dropped
22417: some additional extensions into the source tree and expect them
22418: to be built.
22419
22420: Function to recursively find available extensions, ignoring DynaLoader
22421: NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
22422: In 5.10.1 and later, extensions are stored in directories
22423: like File-Glob instead of the older File/Glob/.
22424find_extensions='
22425    for xxx in *; do
22426	case "$xxx" in
22427	    CVS) ;;
22428	    DynaLoader|dynaload) ;;
22429	    *)
22430	    this_ext=`echo $xxx | $sed -e s/-/\\\//g`;
22431	    case "$this_ext" in
22432		Scalar/List/Utils) this_ext="List/Util"	;;
22433		PathTools)         this_ext="Cwd"	;;
22434	    esac;
22435	    echo " $xs_extensions $nonxs_extensions" > $tdir/$$.tmp;
22436	    if $contains " $this_ext " $tdir/$$.tmp; then
22437		echo >&4;
22438		echo "Duplicate directories detected for extension $xxx" >&4;
22439		echo "Configure cannot correctly recover from this - shall I abort?" >&4;
22440		case "$knowitall" in
22441		"") dflt=y;;
22442		*) dflt=n;;
22443		esac;
22444		. ../UU/myread;
22445		case "$ans" in
22446		n*|N*) ;;
22447		*) echo >&4;
22448		    echo "Ok.  Stopping Configure." >&4;
22449		    echo "Please remove the duplicate directory (e.g. using git clean) and then re-run Configure" >&4;
22450		    exit 1;;
22451		esac;
22452		echo "Ok.  You will need to correct config.sh before running make." >&4;
22453	    fi;
22454	    $ls -1 $xxx > $tdir/$$.tmp;
22455	    if   $contains "\.xs$" $tdir/$$.tmp > /dev/null 2>&1; then
22456		xs_extensions="$xs_extensions $this_ext";
22457	    elif $contains "\.c$"  $tdir/$$.tmp > /dev/null 2>&1; then
22458		xs_extensions="$xs_extensions $this_ext";
22459	    elif $test -d $xxx; then
22460		nonxs_extensions="$nonxs_extensions $this_ext";
22461	    fi;
22462	    $rm -f $tdir/$$.tmp;
22463	    ;;
22464	esac;
22465    done'
22466tdir=`pwd`
22467cd "$rsrc/cpan"
22468set X
22469shift
22470eval $find_extensions
22471cd "$rsrc/dist"
22472set X
22473shift
22474eval $find_extensions
22475cd "$rsrc/ext"
22476set X
22477shift
22478eval $find_extensions
22479set X $xs_extensions
22480shift
22481xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
22482set X $nonxs_extensions
22483shift
22484nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
22485cd "$tdir"
22486known_extensions=`echo $nonxs_extensions $xs_extensions  | tr ' ' $trnl | $sort | tr $trnl ' '`
22487
22488: Now see which are supported on this system.
22489avail_ext=''
22490for xxx in $xs_extensions ; do
22491	case "$xxx" in
22492	DB_File|db_file)
22493		case "$i_db" in
22494		$define) avail_ext="$avail_ext $xxx" ;;
22495		esac
22496		;;
22497	GDBM_File|gdbm_fil)
22498		case "$i_gdbm" in
22499		$define) avail_ext="$avail_ext $xxx" ;;
22500		esac
22501		;;
22502	I18N/Langinfo|i18n_lan)
22503		case "$i_langinfo$d_nl_langinfo" in
22504		$define$define) avail_ext="$avail_ext $xxx" ;;
22505		esac
22506		;;
22507	IPC/SysV|ipc/sysv)
22508		: XXX Do we need a useipcsysv variable here
22509		case "${d_msg}${d_sem}${d_shm}" in
22510		*"${define}"*) avail_ext="$avail_ext $xxx" ;;
22511		esac
22512		;;
22513	NDBM_File|ndbm_fil)
22514		case "$d_ndbm" in
22515		$define)
22516		    case "$osname-$use64bitint" in
22517		    hpux-define)
22518			case "$libs" in
22519			*-lndbm*) avail_ext="$avail_ext $xxx" ;;
22520			esac
22521			;;
22522		    *) avail_ext="$avail_ext $xxx" ;;
22523		    esac
22524		    ;;
22525		esac
22526		;;
22527	ODBM_File|odbm_fil)
22528		case "${i_dbm}${i_rpcsvcdbm}" in
22529		*"${define}"*)
22530		    case "$d_cplusplus" in
22531		    define) ;; # delete as a function name will not work
22532		    *)  case "$osname-$use64bitint" in
22533			hpux-define)
22534			    case "$libs" in
22535			    *-ldbm*) avail_ext="$avail_ext $xxx" ;;
22536			    esac
22537			    ;;
22538			*) avail_ext="$avail_ext $xxx" ;;
22539			esac
22540			;;
22541		    esac
22542		    ;;
22543		esac
22544		;;
22545	Opcode|opcode)
22546		case "$useopcode" in
22547		true|define|y) avail_ext="$avail_ext $xxx" ;;
22548		esac
22549		;;
22550	POSIX|posix)
22551		case "$useposix" in
22552		true|define|y) avail_ext="$avail_ext $xxx" ;;
22553		esac
22554		;;
22555	Socket|socket)
22556		case "$d_socket" in
22557		true|$define|y) avail_ext="$avail_ext $xxx" ;;
22558		esac
22559		;;
22560	Sys/Syslog|sys/syslog)
22561		: XXX syslog requires socket
22562		case "$d_socket" in
22563		true|$define|y) avail_ext="$avail_ext $xxx" ;;
22564		esac
22565		;;
22566	Thread|thread)
22567                case "$usethreads" in
22568                true|$define|y)
22569                        case "$use5005threads" in
22570                        $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
22571                        esac
22572		esac
22573		;;
22574	threads|threads/shared)
22575		# threads and threads::shared are special cases.
22576		# To stop people from asking "Perl 5.8.0 was supposed
22577		# to have this new fancy threads implementation but my
22578		# perl doesn't have it" and from people trying to
22579		# (re)install the threads module using CPAN.pm and
22580		# CPAN.pm then offering to reinstall Perl 5.8.0,
22581		# the threads.pm and threads/shared.pm will always be
22582		# there, croaking informatively ("you need to rebuild
22583		# all of Perl with threads, sorry") when threads haven't
22584		# been compiled in.
22585		# --jhi
22586		avail_ext="$avail_ext $xxx"
22587		;;
22588	VMS*)
22589		;;
22590	Win32*)
22591		case "$osname" in
22592		cygwin) avail_ext="$avail_ext $xxx" ;;
22593		esac
22594		;;
22595	XS/APItest|xs/apitest)
22596		# This is just for testing.  Skip it unless we have dynamic loading.
22597
22598		case "$usedl" in
22599		$define) avail_ext="$avail_ext $xxx" ;;
22600		esac
22601		;;
22602	XS/Typemap|xs/typemap)
22603		# This is just for testing.  Skip it unless we have dynamic loading.
22604		case "$usedl" in
22605		$define) avail_ext="$avail_ext $xxx" ;;
22606		esac
22607		;;
22608	*)	avail_ext="$avail_ext $xxx"
22609		;;
22610	esac
22611done
22612
22613set X $avail_ext
22614shift
22615avail_ext="$*"
22616
22617case "$onlyextensions" in
22618'') ;;
22619*)  keepextensions=''
22620    echo "You have requested that only certain extensions be included..." >&4
22621    for i in $onlyextensions; do
22622        case " $avail_ext " in
22623        *" $i "*)
22624            echo "Keeping extension $i."
22625            keepextensions="$keepextensions $i"
22626            ;;
22627        *) echo "Ignoring extension $i." ;;
22628        esac
22629    done
22630    avail_ext="$keepextensions"
22631    ;;
22632esac
22633
22634case "$noextensions" in
22635'') ;;
22636*)  keepextensions=''
22637    echo "You have requested that certain extensions be ignored..." >&4
22638    for i in $avail_ext; do
22639        case " $noextensions " in
22640        *" $i "*) echo "Ignoring extension $i." ;;
22641        *) echo "Keeping extension $i.";
22642           keepextensions="$keepextensions $i"
22643           ;;
22644        esac
22645    done
22646    avail_ext="$keepextensions"
22647    ;;
22648esac
22649
22650: Now see which nonxs extensions are supported on this system.
22651: For now assume all are.
22652nonxs_ext=''
22653for xxx in $nonxs_extensions ; do
22654	case "$xxx" in
22655	CVS|RCS|SCCS|.svn)
22656		;;
22657	VMS*)
22658		;;
22659	*)	nonxs_ext="$nonxs_ext $xxx"
22660		;;
22661	esac
22662done
22663
22664set X $nonxs_ext
22665shift
22666nonxs_ext="$*"
22667
22668case $usedl in
22669$define)
22670	$cat <<EOM
22671A number of extensions are supplied with $package.  You may choose to
22672compile these extensions for dynamic loading (the default), compile
22673them into the $package executable (static loading), or not include
22674them at all.  Answer "none" to include no extensions.
22675Note that DynaLoader is always built and need not be mentioned here.
22676
22677EOM
22678	case "$dynamic_ext" in
22679	'')
22680		: Exclude those listed in static_ext
22681		dflt=''
22682		for xxx in $avail_ext; do
22683			case " $static_ext " in
22684			*" $xxx "*) ;;
22685			*) dflt="$dflt $xxx" ;;
22686			esac
22687		done
22688		set X $dflt
22689		shift
22690		dflt="$*"
22691		;;
22692	*)	dflt="$dynamic_ext"
22693		# Perhaps we are reusing an old out-of-date config.sh.
22694		case "$hint" in
22695		previous)
22696			if test X"$dynamic_ext" != X"$avail_ext"; then
22697				$cat <<EOM
22698NOTICE:  Your previous config.sh list may be incorrect.
22699The extensions now available to you are
22700	${avail_ext}
22701but the default list from your previous config.sh is
22702	${dynamic_ext}
22703
22704EOM
22705			fi
22706			;;
22707		esac
22708		;;
22709	esac
22710	case "$dflt" in
22711	'')	dflt=none;;
22712	esac
22713	rp="What extensions do you wish to load dynamically?"
22714	. ./myread
22715	case "$ans" in
22716	none) dynamic_ext=' ' ;;
22717	*) dynamic_ext="$ans" ;;
22718	esac
22719
22720	case "$static_ext" in
22721	'')
22722		: Exclude those already listed in dynamic linking
22723		dflt=''
22724		for xxx in $avail_ext; do
22725			case " $dynamic_ext " in
22726			*" $xxx "*) ;;
22727			*) dflt="$dflt $xxx" ;;
22728			esac
22729		done
22730		set X $dflt
22731		shift
22732		dflt="$*"
22733		;;
22734	*)  dflt="$static_ext"
22735		;;
22736	esac
22737
22738	case "$dflt" in
22739	'')	dflt=none;;
22740	esac
22741	rp="What extensions do you wish to load statically?"
22742	. ./myread
22743	case "$ans" in
22744	none) static_ext=' ' ;;
22745	*) static_ext="$ans" ;;
22746	esac
22747	;;
22748*)
22749	$cat <<EOM
22750A number of extensions are supplied with $package.  Answer "none"
22751to include no extensions.
22752Note that DynaLoader is always built and need not be mentioned here.
22753
22754EOM
22755	case "$static_ext" in
22756	'') dflt="$avail_ext" ;;
22757	*)	dflt="$static_ext"
22758		# Perhaps we are reusing an old out-of-date config.sh.
22759		case "$hint" in
22760		previous)
22761			if test X"$static_ext" != X"$avail_ext"; then
22762				$cat <<EOM
22763NOTICE:  Your previous config.sh list may be incorrect.
22764The extensions now available to you are
22765	${avail_ext}
22766but the default list from your previous config.sh is
22767	${static_ext}
22768
22769EOM
22770			fi
22771			;;
22772		esac
22773		;;
22774	esac
22775	: Exclude those that are not xs extensions
22776	case "$dflt" in
22777	'')	dflt=none;;
22778	esac
22779	rp="What extensions do you wish to include?"
22780	. ./myread
22781	case "$ans" in
22782	none) static_ext=' ' ;;
22783	*) static_ext="$ans" ;;
22784	esac
22785	;;
22786esac
22787#
22788# Encode is a special case.  If we are building Encode as a static
22789# extension, we need to explicitly list its subextensions as well.
22790# For other nested extensions, this is handled automatically by
22791# the appropriate Makefile.PL.
22792case " $static_ext " in
22793	*" Encode "*) # Add the subextensions of Encode
22794	cd "$rsrc/cpan"
22795	for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
22796		static_ext="$static_ext Encode/$xxx"
22797		known_extensions="$known_extensions Encode/$xxx"
22798	done
22799	cd "$tdir"
22800	;;
22801esac
22802
22803set X $dynamic_ext $static_ext $nonxs_ext
22804shift
22805extensions="$*"
22806
22807# Sanity check:  We require an extension suitable for use with
22808# AnyDBM_File, as well as Fcntl and IO.  (Failure to have these
22809# should show up as failures in the test suite, but it's helpful to
22810# catch them now.) The 'extensions' list is normally sorted
22811# alphabetically, so we need to accept either
22812#    DB_File ... Fcntl ... IO  ....
22813# or something like
22814#    Fcntl ... NDBM_File ... IO  ....
22815case " $extensions"  in
22816*"_File "*" Fcntl "*" IO "*) ;; # DB_File
22817*" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
22818*" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
22819*) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
22820   echo "WARNING: The Perl you are building will be quite crippled." >& 4
22821   ;;
22822esac
22823
22824: Remove libraries needed only for extensions
22825: The appropriate ext/Foo/Makefile.PL will add them back in, if necessary.
22826: The exception is SunOS 4.x, which needs them.
22827case "${osname}X${osvers}" in
22828sunos*X4*)
22829    perllibs="$libs"
22830    ;;
22831*) case "$usedl" in
22832    $define|true|[yY]*)
22833	    set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
22834	    shift
22835	    perllibs="$*"
22836	    ;;
22837    *)	perllibs="$libs"
22838	    ;;
22839    esac
22840    ;;
22841esac
22842
22843: Remove build directory name from cppstdin so it can be used from
22844: either the present location or the final installed location.
22845echo " "
22846: Get out of the UU directory to get correct path name.
22847cd ..
22848case "$cppstdin" in
22849`pwd`/cppstdin)
22850	echo "Stripping down cppstdin path name"
22851	cppstdin=cppstdin
22852	;;
22853esac
22854cd UU
22855
22856: end of configuration questions
22857echo " "
22858echo "End of configuration questions."
22859echo " "
22860
22861: back to where it started
22862if test -d ../UU; then
22863	cd ..
22864fi
22865
22866: configuration may be unconditionally patched via a 'config.arch' file
22867if $test -f config.arch; then
22868	echo "I see a config.arch file, loading it." >&4
22869	. ./config.arch
22870fi
22871
22872: configuration may be patched via a 'config.over' file
22873if $test -f config.over; then
22874	echo " "
22875	dflt=y
22876	rp='I see a config.over file.  Do you wish to load it?'
22877	. UU/myread
22878	case "$ans" in
22879	n*) echo "OK, I'll ignore it.";;
22880	*)	. ./config.over
22881		echo "Configuration override changes have been loaded."
22882		;;
22883	esac
22884fi
22885
22886: in case they want portability, strip down executable paths
22887case "$d_portable" in
22888"$define")
22889	echo " "
22890	echo "Stripping down executable paths..." >&4
22891	for file in $loclist $trylist; do
22892		eval temp=\$$file
22893		eval $file=`basename $temp`
22894	done
22895	;;
22896esac
22897
22898: create config.sh file
22899echo " "
22900echo "Creating config.sh..." >&4
22901$spitshell <<EOT >config.sh
22902$startsh
22903#
22904# This file was produced by running the Configure script. It holds all the
22905# definitions figured out by Configure. Should you modify one of these values,
22906# do not forget to propagate your changes by running "Configure -der". You may
22907# instead choose to run each of the .SH files by yourself, or "Configure -S".
22908#
22909
22910# Package name      : $package
22911# Source directory  : $src
22912# Configuration time: $cf_time
22913# Configured by     : $cf_by
22914# Target system     : $myuname
22915
22916EOT
22917: Add in command line options if available
22918$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
22919
22920$spitshell <<EOT >>config.sh
22921
22922Author='$Author'
22923Date='$Date'
22924Header='$Header'
22925Id='$Id'
22926Locker='$Locker'
22927Log='$Log'
22928RCSfile='$RCSfile'
22929Revision='$Revision'
22930Source='$Source'
22931State='$State'
22932_a='$_a'
22933_exe='$_exe'
22934_o='$_o'
22935afs='$afs'
22936afsroot='$afsroot'
22937alignbytes='$alignbytes'
22938ansi2knr='$ansi2knr'
22939aphostname='$aphostname'
22940api_revision='$api_revision'
22941api_subversion='$api_subversion'
22942api_version='$api_version'
22943api_versionstring='$api_versionstring'
22944ar='$ar'
22945archlib='$archlib'
22946archlibexp='$archlibexp'
22947archname64='$archname64'
22948archname='$archname'
22949archobjs='$archobjs'
22950asctime_r_proto='$asctime_r_proto'
22951awk='$awk'
22952baserev='$baserev'
22953bash='$bash'
22954bin='$bin'
22955bin_ELF='$bin_ELF'
22956binexp='$binexp'
22957bison='$bison'
22958bootstrap_charset='$bootstrap_charset'
22959byacc='$byacc'
22960byteorder='$byteorder'
22961c='$c'
22962castflags='$castflags'
22963cat='$cat'
22964cc='$cc'
22965cccdlflags='$cccdlflags'
22966ccdlflags='$ccdlflags'
22967ccflags='$ccflags'
22968ccflags_uselargefiles='$ccflags_uselargefiles'
22969ccname='$ccname'
22970ccsymbols='$ccsymbols'
22971ccversion='$ccversion'
22972cf_by='$cf_by'
22973cf_email='$cf_email'
22974cf_time='$cf_time'
22975charbits='$charbits'
22976charsize='$charsize'
22977chgrp='$chgrp'
22978chmod='$chmod'
22979chown='$chown'
22980clocktype='$clocktype'
22981comm='$comm'
22982compress='$compress'
22983contains='$contains'
22984cp='$cp'
22985cpio='$cpio'
22986cpp='$cpp'
22987cpp_stuff='$cpp_stuff'
22988cppccsymbols='$cppccsymbols'
22989cppflags='$cppflags'
22990cpplast='$cpplast'
22991cppminus='$cppminus'
22992cpprun='$cpprun'
22993cppstdin='$cppstdin'
22994cppsymbols='$cppsymbols'
22995crypt_r_proto='$crypt_r_proto'
22996cryptlib='$cryptlib'
22997csh='$csh'
22998ctermid_r_proto='$ctermid_r_proto'
22999ctime_r_proto='$ctime_r_proto'
23000d_Gconvert='$d_Gconvert'
23001d_PRIEUldbl='$d_PRIEUldbl'
23002d_PRIFUldbl='$d_PRIFUldbl'
23003d_PRIGUldbl='$d_PRIGUldbl'
23004d_PRIXU64='$d_PRIXU64'
23005d_PRId64='$d_PRId64'
23006d_PRIeldbl='$d_PRIeldbl'
23007d_PRIfldbl='$d_PRIfldbl'
23008d_PRIgldbl='$d_PRIgldbl'
23009d_PRIi64='$d_PRIi64'
23010d_PRIo64='$d_PRIo64'
23011d_PRIu64='$d_PRIu64'
23012d_PRIx64='$d_PRIx64'
23013d_SCNfldbl='$d_SCNfldbl'
23014d__fwalk='$d__fwalk'
23015d_access='$d_access'
23016d_accessx='$d_accessx'
23017d_aintl='$d_aintl'
23018d_alarm='$d_alarm'
23019d_archlib='$d_archlib'
23020d_asctime64='$d_asctime64'
23021d_asctime_r='$d_asctime_r'
23022d_atolf='$d_atolf'
23023d_atoll='$d_atoll'
23024d_attribute_deprecated='$d_attribute_deprecated'
23025d_attribute_format='$d_attribute_format'
23026d_attribute_malloc='$d_attribute_malloc'
23027d_attribute_nonnull='$d_attribute_nonnull'
23028d_attribute_noreturn='$d_attribute_noreturn'
23029d_attribute_pure='$d_attribute_pure'
23030d_attribute_unused='$d_attribute_unused'
23031d_attribute_warn_unused_result='$d_attribute_warn_unused_result'
23032d_bcmp='$d_bcmp'
23033d_bcopy='$d_bcopy'
23034d_bsd='$d_bsd'
23035d_bsdgetpgrp='$d_bsdgetpgrp'
23036d_bsdsetpgrp='$d_bsdsetpgrp'
23037d_builtin_choose_expr='$d_builtin_choose_expr'
23038d_builtin_expect='$d_builtin_expect'
23039d_bzero='$d_bzero'
23040d_c99_variadic_macros='$d_c99_variadic_macros'
23041d_casti32='$d_casti32'
23042d_castneg='$d_castneg'
23043d_charvspr='$d_charvspr'
23044d_chown='$d_chown'
23045d_chroot='$d_chroot'
23046d_chsize='$d_chsize'
23047d_class='$d_class'
23048d_clearenv='$d_clearenv'
23049d_closedir='$d_closedir'
23050d_cmsghdr_s='$d_cmsghdr_s'
23051d_const='$d_const'
23052d_copysignl='$d_copysignl'
23053d_cplusplus='$d_cplusplus'
23054d_crypt='$d_crypt'
23055d_crypt_r='$d_crypt_r'
23056d_csh='$d_csh'
23057d_ctermid='$d_ctermid'
23058d_ctermid_r='$d_ctermid_r'
23059d_ctime64='$d_ctime64'
23060d_ctime_r='$d_ctime_r'
23061d_cuserid='$d_cuserid'
23062d_dbl_dig='$d_dbl_dig'
23063d_dbminitproto='$d_dbminitproto'
23064d_difftime64='$d_difftime64'
23065d_difftime='$d_difftime'
23066d_dir_dd_fd='$d_dir_dd_fd'
23067d_dirfd='$d_dirfd'
23068d_dirnamlen='$d_dirnamlen'
23069d_dlerror='$d_dlerror'
23070d_dlopen='$d_dlopen'
23071d_dlsymun='$d_dlsymun'
23072d_dosuid='$d_dosuid'
23073d_drand48_r='$d_drand48_r'
23074d_drand48proto='$d_drand48proto'
23075d_dup2='$d_dup2'
23076d_eaccess='$d_eaccess'
23077d_endgrent='$d_endgrent'
23078d_endgrent_r='$d_endgrent_r'
23079d_endhent='$d_endhent'
23080d_endhostent_r='$d_endhostent_r'
23081d_endnent='$d_endnent'
23082d_endnetent_r='$d_endnetent_r'
23083d_endpent='$d_endpent'
23084d_endprotoent_r='$d_endprotoent_r'
23085d_endpwent='$d_endpwent'
23086d_endpwent_r='$d_endpwent_r'
23087d_endsent='$d_endsent'
23088d_endservent_r='$d_endservent_r'
23089d_eofnblk='$d_eofnblk'
23090d_eunice='$d_eunice'
23091d_faststdio='$d_faststdio'
23092d_fchdir='$d_fchdir'
23093d_fchmod='$d_fchmod'
23094d_fchown='$d_fchown'
23095d_fcntl='$d_fcntl'
23096d_fcntl_can_lock='$d_fcntl_can_lock'
23097d_fd_macros='$d_fd_macros'
23098d_fd_set='$d_fd_set'
23099d_fds_bits='$d_fds_bits'
23100d_fgetpos='$d_fgetpos'
23101d_finite='$d_finite'
23102d_finitel='$d_finitel'
23103d_flexfnam='$d_flexfnam'
23104d_flock='$d_flock'
23105d_flockproto='$d_flockproto'
23106d_fork='$d_fork'
23107d_fp_class='$d_fp_class'
23108d_fpathconf='$d_fpathconf'
23109d_fpclass='$d_fpclass'
23110d_fpclassify='$d_fpclassify'
23111d_fpclassl='$d_fpclassl'
23112d_fpos64_t='$d_fpos64_t'
23113d_frexpl='$d_frexpl'
23114d_fs_data_s='$d_fs_data_s'
23115d_fseeko='$d_fseeko'
23116d_fsetpos='$d_fsetpos'
23117d_fstatfs='$d_fstatfs'
23118d_fstatvfs='$d_fstatvfs'
23119d_fsync='$d_fsync'
23120d_ftello='$d_ftello'
23121d_ftime='$d_ftime'
23122d_futimes='$d_futimes'
23123d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
23124d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
23125d_getaddrinfo='$d_getaddrinfo'
23126d_getcwd='$d_getcwd'
23127d_getespwnam='$d_getespwnam'
23128d_getfsstat='$d_getfsstat'
23129d_getgrent='$d_getgrent'
23130d_getgrent_r='$d_getgrent_r'
23131d_getgrgid_r='$d_getgrgid_r'
23132d_getgrnam_r='$d_getgrnam_r'
23133d_getgrps='$d_getgrps'
23134d_gethbyaddr='$d_gethbyaddr'
23135d_gethbyname='$d_gethbyname'
23136d_gethent='$d_gethent'
23137d_gethname='$d_gethname'
23138d_gethostbyaddr_r='$d_gethostbyaddr_r'
23139d_gethostbyname_r='$d_gethostbyname_r'
23140d_gethostent_r='$d_gethostent_r'
23141d_gethostprotos='$d_gethostprotos'
23142d_getitimer='$d_getitimer'
23143d_getlogin='$d_getlogin'
23144d_getlogin_r='$d_getlogin_r'
23145d_getmnt='$d_getmnt'
23146d_getmntent='$d_getmntent'
23147d_getnameinfo='$d_getnameinfo'
23148d_getnbyaddr='$d_getnbyaddr'
23149d_getnbyname='$d_getnbyname'
23150d_getnent='$d_getnent'
23151d_getnetbyaddr_r='$d_getnetbyaddr_r'
23152d_getnetbyname_r='$d_getnetbyname_r'
23153d_getnetent_r='$d_getnetent_r'
23154d_getnetprotos='$d_getnetprotos'
23155d_getpagsz='$d_getpagsz'
23156d_getpbyname='$d_getpbyname'
23157d_getpbynumber='$d_getpbynumber'
23158d_getpent='$d_getpent'
23159d_getpgid='$d_getpgid'
23160d_getpgrp2='$d_getpgrp2'
23161d_getpgrp='$d_getpgrp'
23162d_getppid='$d_getppid'
23163d_getprior='$d_getprior'
23164d_getprotobyname_r='$d_getprotobyname_r'
23165d_getprotobynumber_r='$d_getprotobynumber_r'
23166d_getprotoent_r='$d_getprotoent_r'
23167d_getprotoprotos='$d_getprotoprotos'
23168d_getprpwnam='$d_getprpwnam'
23169d_getpwent='$d_getpwent'
23170d_getpwent_r='$d_getpwent_r'
23171d_getpwnam_r='$d_getpwnam_r'
23172d_getpwuid_r='$d_getpwuid_r'
23173d_getsbyname='$d_getsbyname'
23174d_getsbyport='$d_getsbyport'
23175d_getsent='$d_getsent'
23176d_getservbyname_r='$d_getservbyname_r'
23177d_getservbyport_r='$d_getservbyport_r'
23178d_getservent_r='$d_getservent_r'
23179d_getservprotos='$d_getservprotos'
23180d_getspnam='$d_getspnam'
23181d_getspnam_r='$d_getspnam_r'
23182d_gettimeod='$d_gettimeod'
23183d_gmtime64='$d_gmtime64'
23184d_gmtime_r='$d_gmtime_r'
23185d_gnulibc='$d_gnulibc'
23186d_grpasswd='$d_grpasswd'
23187d_hasmntopt='$d_hasmntopt'
23188d_htonl='$d_htonl'
23189d_ilogbl='$d_ilogbl'
23190d_inc_version_list='$d_inc_version_list'
23191d_index='$d_index'
23192d_inetaton='$d_inetaton'
23193d_inetntop='$d_inetntop'
23194d_inetpton='$d_inetpton'
23195d_int64_t='$d_int64_t'
23196d_ip_mreq='$d_ip_mreq'
23197d_ip_mreq_source='$d_ip_mreq_source'
23198d_ipv6_mreq='$d_ipv6_mreq'
23199d_ipv6_mreq_source='$d_ipv6_mreq_source'
23200d_isascii='$d_isascii'
23201d_isblank='$d_isblank'
23202d_isfinite='$d_isfinite'
23203d_isinf='$d_isinf'
23204d_isnan='$d_isnan'
23205d_isnanl='$d_isnanl'
23206d_killpg='$d_killpg'
23207d_lchown='$d_lchown'
23208d_ldbl_dig='$d_ldbl_dig'
23209d_libm_lib_version='$d_libm_lib_version'
23210d_libname_unique='$d_libname_unique'
23211d_link='$d_link'
23212d_localtime64='$d_localtime64'
23213d_localtime_r='$d_localtime_r'
23214d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
23215d_locconv='$d_locconv'
23216d_lc_monetary_2008='$d_lc_monetary_2008'
23217d_lockf='$d_lockf'
23218d_longdbl='$d_longdbl'
23219d_longlong='$d_longlong'
23220d_lseekproto='$d_lseekproto'
23221d_lstat='$d_lstat'
23222d_madvise='$d_madvise'
23223d_malloc_good_size='$d_malloc_good_size'
23224d_malloc_size='$d_malloc_size'
23225d_mblen='$d_mblen'
23226d_mbstowcs='$d_mbstowcs'
23227d_mbtowc='$d_mbtowc'
23228d_memchr='$d_memchr'
23229d_memcmp='$d_memcmp'
23230d_memcpy='$d_memcpy'
23231d_memmove='$d_memmove'
23232d_memset='$d_memset'
23233d_mkdir='$d_mkdir'
23234d_mkdtemp='$d_mkdtemp'
23235d_mkfifo='$d_mkfifo'
23236d_mkstemp='$d_mkstemp'
23237d_mkstemps='$d_mkstemps'
23238d_mktime64='$d_mktime64'
23239d_mktime='$d_mktime'
23240d_mmap='$d_mmap'
23241d_modfl='$d_modfl'
23242d_modfl_pow32_bug='$d_modfl_pow32_bug'
23243d_modflproto='$d_modflproto'
23244d_mprotect='$d_mprotect'
23245d_msg='$d_msg'
23246d_msg_ctrunc='$d_msg_ctrunc'
23247d_msg_dontroute='$d_msg_dontroute'
23248d_msg_oob='$d_msg_oob'
23249d_msg_peek='$d_msg_peek'
23250d_msg_proxy='$d_msg_proxy'
23251d_msgctl='$d_msgctl'
23252d_msgget='$d_msgget'
23253d_msghdr_s='$d_msghdr_s'
23254d_msgrcv='$d_msgrcv'
23255d_msgsnd='$d_msgsnd'
23256d_msync='$d_msync'
23257d_munmap='$d_munmap'
23258d_mymalloc='$d_mymalloc'
23259d_ndbm='$d_ndbm'
23260d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
23261d_nice='$d_nice'
23262d_nl_langinfo='$d_nl_langinfo'
23263d_nv_preserves_uv='$d_nv_preserves_uv'
23264d_nv_zero_is_allbits_zero='$d_nv_zero_is_allbits_zero'
23265d_off64_t='$d_off64_t'
23266d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
23267d_oldpthreads='$d_oldpthreads'
23268d_oldsock='$d_oldsock'
23269d_open3='$d_open3'
23270d_pathconf='$d_pathconf'
23271d_pause='$d_pause'
23272d_perl_otherlibdirs='$d_perl_otherlibdirs'
23273d_phostname='$d_phostname'
23274d_pipe='$d_pipe'
23275d_poll='$d_poll'
23276d_portable='$d_portable'
23277d_prctl='$d_prctl'
23278d_prctl_set_name='$d_prctl_set_name'
23279d_printf_format_null='$d_printf_format_null'
23280d_procselfexe='$d_procselfexe'
23281d_pseudofork='$d_pseudofork'
23282d_pthread_atfork='$d_pthread_atfork'
23283d_pthread_attr_setscope='$d_pthread_attr_setscope'
23284d_pthread_yield='$d_pthread_yield'
23285d_pwage='$d_pwage'
23286d_pwchange='$d_pwchange'
23287d_pwclass='$d_pwclass'
23288d_pwcomment='$d_pwcomment'
23289d_pwexpire='$d_pwexpire'
23290d_pwgecos='$d_pwgecos'
23291d_pwpasswd='$d_pwpasswd'
23292d_pwquota='$d_pwquota'
23293d_qgcvt='$d_qgcvt'
23294d_quad='$d_quad'
23295d_random_r='$d_random_r'
23296d_readdir64_r='$d_readdir64_r'
23297d_readdir='$d_readdir'
23298d_readdir_r='$d_readdir_r'
23299d_readlink='$d_readlink'
23300d_readv='$d_readv'
23301d_recvmsg='$d_recvmsg'
23302d_rename='$d_rename'
23303d_rewinddir='$d_rewinddir'
23304d_rmdir='$d_rmdir'
23305d_safebcpy='$d_safebcpy'
23306d_safemcpy='$d_safemcpy'
23307d_sanemcmp='$d_sanemcmp'
23308d_sbrkproto='$d_sbrkproto'
23309d_scalbnl='$d_scalbnl'
23310d_sched_yield='$d_sched_yield'
23311d_scm_rights='$d_scm_rights'
23312d_seekdir='$d_seekdir'
23313d_select='$d_select'
23314d_sem='$d_sem'
23315d_semctl='$d_semctl'
23316d_semctl_semid_ds='$d_semctl_semid_ds'
23317d_semctl_semun='$d_semctl_semun'
23318d_semget='$d_semget'
23319d_semop='$d_semop'
23320d_sendmsg='$d_sendmsg'
23321d_setegid='$d_setegid'
23322d_seteuid='$d_seteuid'
23323d_setgrent='$d_setgrent'
23324d_setgrent_r='$d_setgrent_r'
23325d_setgrps='$d_setgrps'
23326d_sethent='$d_sethent'
23327d_sethostent_r='$d_sethostent_r'
23328d_setitimer='$d_setitimer'
23329d_setlinebuf='$d_setlinebuf'
23330d_setlocale='$d_setlocale'
23331d_setlocale_r='$d_setlocale_r'
23332d_setnent='$d_setnent'
23333d_setnetent_r='$d_setnetent_r'
23334d_setpent='$d_setpent'
23335d_setpgid='$d_setpgid'
23336d_setpgrp2='$d_setpgrp2'
23337d_setpgrp='$d_setpgrp'
23338d_setprior='$d_setprior'
23339d_setproctitle='$d_setproctitle'
23340d_setprotoent_r='$d_setprotoent_r'
23341d_setpwent='$d_setpwent'
23342d_setpwent_r='$d_setpwent_r'
23343d_setregid='$d_setregid'
23344d_setresgid='$d_setresgid'
23345d_setresuid='$d_setresuid'
23346d_setreuid='$d_setreuid'
23347d_setrgid='$d_setrgid'
23348d_setruid='$d_setruid'
23349d_setsent='$d_setsent'
23350d_setservent_r='$d_setservent_r'
23351d_setsid='$d_setsid'
23352d_setvbuf='$d_setvbuf'
23353d_shm='$d_shm'
23354d_shmat='$d_shmat'
23355d_shmatprototype='$d_shmatprototype'
23356d_shmctl='$d_shmctl'
23357d_shmdt='$d_shmdt'
23358d_shmget='$d_shmget'
23359d_sigaction='$d_sigaction'
23360d_signbit='$d_signbit'
23361d_sigprocmask='$d_sigprocmask'
23362d_sigsetjmp='$d_sigsetjmp'
23363d_sin6_scope_id='$d_sin6_scope_id'
23364d_sitearch='$d_sitearch'
23365d_snprintf='$d_snprintf'
23366d_sockaddr_in6='$d_sockaddr_in6'
23367d_sockaddr_sa_len='$d_sockaddr_sa_len'
23368d_sockatmark='$d_sockatmark'
23369d_sockatmarkproto='$d_sockatmarkproto'
23370d_socket='$d_socket'
23371d_socklen_t='$d_socklen_t'
23372d_sockpair='$d_sockpair'
23373d_socks5_init='$d_socks5_init'
23374d_sprintf_returns_strlen='$d_sprintf_returns_strlen'
23375d_sqrtl='$d_sqrtl'
23376d_srand48_r='$d_srand48_r'
23377d_srandom_r='$d_srandom_r'
23378d_sresgproto='$d_sresgproto'
23379d_sresuproto='$d_sresuproto'
23380d_statblks='$d_statblks'
23381d_statfs_f_flags='$d_statfs_f_flags'
23382d_statfs_s='$d_statfs_s'
23383d_static_inline='$d_static_inline'
23384d_statvfs='$d_statvfs'
23385d_stdio_cnt_lval='$d_stdio_cnt_lval'
23386d_stdio_ptr_lval='$d_stdio_ptr_lval'
23387d_stdio_ptr_lval_nochange_cnt='$d_stdio_ptr_lval_nochange_cnt'
23388d_stdio_ptr_lval_sets_cnt='$d_stdio_ptr_lval_sets_cnt'
23389d_stdio_stream_array='$d_stdio_stream_array'
23390d_stdiobase='$d_stdiobase'
23391d_stdstdio='$d_stdstdio'
23392d_strchr='$d_strchr'
23393d_strcoll='$d_strcoll'
23394d_strctcpy='$d_strctcpy'
23395d_strerrm='$d_strerrm'
23396d_strerror='$d_strerror'
23397d_strerror_r='$d_strerror_r'
23398d_strftime='$d_strftime'
23399d_strlcat='$d_strlcat'
23400d_strlcpy='$d_strlcpy'
23401d_strtod='$d_strtod'
23402d_strtol='$d_strtol'
23403d_strtold='$d_strtold'
23404d_strtoll='$d_strtoll'
23405d_strtoq='$d_strtoq'
23406d_strtoul='$d_strtoul'
23407d_strtoull='$d_strtoull'
23408d_strtouq='$d_strtouq'
23409d_strxfrm='$d_strxfrm'
23410d_suidsafe='$d_suidsafe'
23411d_symlink='$d_symlink'
23412d_syscall='$d_syscall'
23413d_syscallproto='$d_syscallproto'
23414d_sysconf='$d_sysconf'
23415d_sysernlst='$d_sysernlst'
23416d_syserrlst='$d_syserrlst'
23417d_system='$d_system'
23418d_tcgetpgrp='$d_tcgetpgrp'
23419d_tcsetpgrp='$d_tcsetpgrp'
23420d_telldir='$d_telldir'
23421d_telldirproto='$d_telldirproto'
23422d_time='$d_time'
23423d_timegm='$d_timegm'
23424d_times='$d_times'
23425d_tm_tm_gmtoff='$d_tm_tm_gmtoff'
23426d_tm_tm_zone='$d_tm_tm_zone'
23427d_tmpnam_r='$d_tmpnam_r'
23428d_truncate='$d_truncate'
23429d_ttyname_r='$d_ttyname_r'
23430d_tzname='$d_tzname'
23431d_u32align='$d_u32align'
23432d_ualarm='$d_ualarm'
23433d_umask='$d_umask'
23434d_uname='$d_uname'
23435d_union_semun='$d_union_semun'
23436d_unordered='$d_unordered'
23437d_unsetenv='$d_unsetenv'
23438d_usleep='$d_usleep'
23439d_usleepproto='$d_usleepproto'
23440d_ustat='$d_ustat'
23441d_vendorarch='$d_vendorarch'
23442d_vendorbin='$d_vendorbin'
23443d_vendorlib='$d_vendorlib'
23444d_vendorscript='$d_vendorscript'
23445d_vfork='$d_vfork'
23446d_void_closedir='$d_void_closedir'
23447d_voidsig='$d_voidsig'
23448d_voidtty='$d_voidtty'
23449d_volatile='$d_volatile'
23450d_vprintf='$d_vprintf'
23451d_vsnprintf='$d_vsnprintf'
23452d_wait4='$d_wait4'
23453d_waitpid='$d_waitpid'
23454d_wcstombs='$d_wcstombs'
23455d_wctomb='$d_wctomb'
23456d_writev='$d_writev'
23457d_xenix='$d_xenix'
23458date='$date'
23459db_hashtype='$db_hashtype'
23460db_prefixtype='$db_prefixtype'
23461db_version_major='$db_version_major'
23462db_version_minor='$db_version_minor'
23463db_version_patch='$db_version_patch'
23464direntrytype='$direntrytype'
23465dlext='$dlext'
23466dlsrc='$dlsrc'
23467doublesize='$doublesize'
23468drand01='$drand01'
23469drand48_r_proto='$drand48_r_proto'
23470dtrace='$dtrace'
23471dynamic_ext='$dynamic_ext'
23472eagain='$eagain'
23473ebcdic='$ebcdic'
23474echo='$echo'
23475egrep='$egrep'
23476emacs='$emacs'
23477endgrent_r_proto='$endgrent_r_proto'
23478endhostent_r_proto='$endhostent_r_proto'
23479endnetent_r_proto='$endnetent_r_proto'
23480endprotoent_r_proto='$endprotoent_r_proto'
23481endpwent_r_proto='$endpwent_r_proto'
23482endservent_r_proto='$endservent_r_proto'
23483eunicefix='$eunicefix'
23484exe_ext='$exe_ext'
23485expr='$expr'
23486extensions='$extensions'
23487extern_C='$extern_C'
23488extras='$extras'
23489fflushNULL='$fflushNULL'
23490fflushall='$fflushall'
23491find='$find'
23492firstmakefile='$firstmakefile'
23493flex='$flex'
23494fpossize='$fpossize'
23495fpostype='$fpostype'
23496freetype='$freetype'
23497from='$from'
23498full_ar='$full_ar'
23499full_csh='$full_csh'
23500full_sed='$full_sed'
23501gccansipedantic='$gccansipedantic'
23502gccosandvers='$gccosandvers'
23503gccversion='$gccversion'
23504getgrent_r_proto='$getgrent_r_proto'
23505getgrgid_r_proto='$getgrgid_r_proto'
23506getgrnam_r_proto='$getgrnam_r_proto'
23507gethostbyaddr_r_proto='$gethostbyaddr_r_proto'
23508gethostbyname_r_proto='$gethostbyname_r_proto'
23509gethostent_r_proto='$gethostent_r_proto'
23510getlogin_r_proto='$getlogin_r_proto'
23511getnetbyaddr_r_proto='$getnetbyaddr_r_proto'
23512getnetbyname_r_proto='$getnetbyname_r_proto'
23513getnetent_r_proto='$getnetent_r_proto'
23514getprotobyname_r_proto='$getprotobyname_r_proto'
23515getprotobynumber_r_proto='$getprotobynumber_r_proto'
23516getprotoent_r_proto='$getprotoent_r_proto'
23517getpwent_r_proto='$getpwent_r_proto'
23518getpwnam_r_proto='$getpwnam_r_proto'
23519getpwuid_r_proto='$getpwuid_r_proto'
23520getservbyname_r_proto='$getservbyname_r_proto'
23521getservbyport_r_proto='$getservbyport_r_proto'
23522getservent_r_proto='$getservent_r_proto'
23523getspnam_r_proto='$getspnam_r_proto'
23524gidformat='$gidformat'
23525gidsign='$gidsign'
23526gidsize='$gidsize'
23527gidtype='$gidtype'
23528glibpth='$glibpth'
23529gmake='$gmake'
23530gmtime_r_proto='$gmtime_r_proto'
23531gnulibc_version='$gnulibc_version'
23532grep='$grep'
23533groupcat='$groupcat'
23534groupstype='$groupstype'
23535gzip='$gzip'
23536h_fcntl='$h_fcntl'
23537h_sysfile='$h_sysfile'
23538hint='$hint'
23539hostcat='$hostcat'
23540hostgenerate='$hostgenerate'
23541hostosname='$hostosname'
23542hostperl='$hostperl'
23543html1dir='$html1dir'
23544html1direxp='$html1direxp'
23545html3dir='$html3dir'
23546html3direxp='$html3direxp'
23547i16size='$i16size'
23548i16type='$i16type'
23549i32size='$i32size'
23550i32type='$i32type'
23551i64size='$i64size'
23552i64type='$i64type'
23553i8size='$i8size'
23554i8type='$i8type'
23555i_arpainet='$i_arpainet'
23556i_assert='$i_assert'
23557i_bsdioctl='$i_bsdioctl'
23558i_crypt='$i_crypt'
23559i_db='$i_db'
23560i_dbm='$i_dbm'
23561i_dirent='$i_dirent'
23562i_dlfcn='$i_dlfcn'
23563i_fcntl='$i_fcntl'
23564i_float='$i_float'
23565i_fp='$i_fp'
23566i_fp_class='$i_fp_class'
23567i_gdbm='$i_gdbm'
23568i_gdbm_ndbm='$i_gdbm_ndbm'
23569i_gdbmndbm='$i_gdbmndbm'
23570i_grp='$i_grp'
23571i_ieeefp='$i_ieeefp'
23572i_inttypes='$i_inttypes'
23573i_langinfo='$i_langinfo'
23574i_libutil='$i_libutil'
23575i_limits='$i_limits'
23576i_locale='$i_locale'
23577i_machcthr='$i_machcthr'
23578i_malloc='$i_malloc'
23579i_mallocmalloc='$i_mallocmalloc'
23580i_math='$i_math'
23581i_memory='$i_memory'
23582i_mntent='$i_mntent'
23583i_ndbm='$i_ndbm'
23584i_netdb='$i_netdb'
23585i_neterrno='$i_neterrno'
23586i_netinettcp='$i_netinettcp'
23587i_niin='$i_niin'
23588i_poll='$i_poll'
23589i_prot='$i_prot'
23590i_pthread='$i_pthread'
23591i_pwd='$i_pwd'
23592i_rpcsvcdbm='$i_rpcsvcdbm'
23593i_sgtty='$i_sgtty'
23594i_shadow='$i_shadow'
23595i_socks='$i_socks'
23596i_stdarg='$i_stdarg'
23597i_stdbool='$i_stdbool'
23598i_stddef='$i_stddef'
23599i_stdlib='$i_stdlib'
23600i_string='$i_string'
23601i_sunmath='$i_sunmath'
23602i_sysaccess='$i_sysaccess'
23603i_sysdir='$i_sysdir'
23604i_sysfile='$i_sysfile'
23605i_sysfilio='$i_sysfilio'
23606i_sysin='$i_sysin'
23607i_sysioctl='$i_sysioctl'
23608i_syslog='$i_syslog'
23609i_sysmman='$i_sysmman'
23610i_sysmode='$i_sysmode'
23611i_sysmount='$i_sysmount'
23612i_sysndir='$i_sysndir'
23613i_sysparam='$i_sysparam'
23614i_syspoll='$i_syspoll'
23615i_sysresrc='$i_sysresrc'
23616i_syssecrt='$i_syssecrt'
23617i_sysselct='$i_sysselct'
23618i_syssockio='$i_syssockio'
23619i_sysstat='$i_sysstat'
23620i_sysstatfs='$i_sysstatfs'
23621i_sysstatvfs='$i_sysstatvfs'
23622i_systime='$i_systime'
23623i_systimek='$i_systimek'
23624i_systimes='$i_systimes'
23625i_systypes='$i_systypes'
23626i_sysuio='$i_sysuio'
23627i_sysun='$i_sysun'
23628i_sysutsname='$i_sysutsname'
23629i_sysvfs='$i_sysvfs'
23630i_syswait='$i_syswait'
23631i_termio='$i_termio'
23632i_termios='$i_termios'
23633i_time='$i_time'
23634i_unistd='$i_unistd'
23635i_ustat='$i_ustat'
23636i_utime='$i_utime'
23637i_values='$i_values'
23638i_varargs='$i_varargs'
23639i_varhdr='$i_varhdr'
23640i_vfork='$i_vfork'
23641ignore_versioned_solibs='$ignore_versioned_solibs'
23642inc_version_list='$inc_version_list'
23643inc_version_list_init='$inc_version_list_init'
23644incpath='$incpath'
23645incpth='$incpth'
23646inews='$inews'
23647initialinstalllocation='$initialinstalllocation'
23648installarchlib='$installarchlib'
23649installbin='$installbin'
23650installhtml1dir='$installhtml1dir'
23651installhtml3dir='$installhtml3dir'
23652installman1dir='$installman1dir'
23653installman3dir='$installman3dir'
23654installprefix='$installprefix'
23655installprefixexp='$installprefixexp'
23656installprivlib='$installprivlib'
23657installscript='$installscript'
23658installsitearch='$installsitearch'
23659installsitebin='$installsitebin'
23660installsitehtml1dir='$installsitehtml1dir'
23661installsitehtml3dir='$installsitehtml3dir'
23662installsitelib='$installsitelib'
23663installsiteman1dir='$installsiteman1dir'
23664installsiteman3dir='$installsiteman3dir'
23665installsitescript='$installsitescript'
23666installstyle='$installstyle'
23667installusrbinperl='$installusrbinperl'
23668installvendorarch='$installvendorarch'
23669installvendorbin='$installvendorbin'
23670installvendorhtml1dir='$installvendorhtml1dir'
23671installvendorhtml3dir='$installvendorhtml3dir'
23672installvendorlib='$installvendorlib'
23673installvendorman1dir='$installvendorman1dir'
23674installvendorman3dir='$installvendorman3dir'
23675installvendorscript='$installvendorscript'
23676intsize='$intsize'
23677issymlink='$issymlink'
23678ivdformat='$ivdformat'
23679ivsize='$ivsize'
23680ivtype='$ivtype'
23681known_extensions='$known_extensions'
23682ksh='$ksh'
23683ld='$ld'
23684ld_can_script='$ld_can_script'
23685lddlflags='$lddlflags'
23686ldflags='$ldflags'
23687ldflags_uselargefiles='$ldflags_uselargefiles'
23688ldlibpthname='$ldlibpthname'
23689less='$less'
23690lib_ext='$lib_ext'
23691libc='$libc'
23692libperl='$libperl'
23693libpth='$libpth'
23694libs='$libs'
23695libsdirs='$libsdirs'
23696libsfiles='$libsfiles'
23697libsfound='$libsfound'
23698libspath='$libspath'
23699libswanted='$libswanted'
23700libswanted_uselargefiles='$libswanted_uselargefiles'
23701line='$line'
23702lint='$lint'
23703lkflags='$lkflags'
23704ln='$ln'
23705lns='$lns'
23706localtime_r_proto='$localtime_r_proto'
23707locincpth='$locincpth'
23708loclibpth='$loclibpth'
23709longdblsize='$longdblsize'
23710longlongsize='$longlongsize'
23711longsize='$longsize'
23712lp='$lp'
23713lpr='$lpr'
23714ls='$ls'
23715lseeksize='$lseeksize'
23716lseektype='$lseektype'
23717mad='$mad'
23718madlyh='$madlyh'
23719madlyobj='$madlyobj'
23720madlysrc='$madlysrc'
23721mail='$mail'
23722mailx='$mailx'
23723make='$make'
23724make_set_make='$make_set_make'
23725mallocobj='$mallocobj'
23726mallocsrc='$mallocsrc'
23727malloctype='$malloctype'
23728man1dir='$man1dir'
23729man1direxp='$man1direxp'
23730man1ext='$man1ext'
23731man3dir='$man3dir'
23732man3direxp='$man3direxp'
23733man3ext='$man3ext'
23734mips_type='$mips_type'
23735mistrustnm='$mistrustnm'
23736mkdir='$mkdir'
23737mmaptype='$mmaptype'
23738modetype='$modetype'
23739more='$more'
23740multiarch='$multiarch'
23741mv='$mv'
23742myarchname='$myarchname'
23743mydomain='$mydomain'
23744myhostname='$myhostname'
23745myuname='$myuname'
23746n='$n'
23747need_va_copy='$need_va_copy'
23748netdb_hlen_type='$netdb_hlen_type'
23749netdb_host_type='$netdb_host_type'
23750netdb_name_type='$netdb_name_type'
23751netdb_net_type='$netdb_net_type'
23752nm='$nm'
23753nm_opt='$nm_opt'
23754nm_so_opt='$nm_so_opt'
23755nonxs_ext='$nonxs_ext'
23756nroff='$nroff'
23757nvEUformat='$nvEUformat'
23758nvFUformat='$nvFUformat'
23759nvGUformat='$nvGUformat'
23760nv_overflows_integers_at='$nv_overflows_integers_at'
23761nv_preserves_uv_bits='$nv_preserves_uv_bits'
23762nveformat='$nveformat'
23763nvfformat='$nvfformat'
23764nvgformat='$nvgformat'
23765nvsize='$nvsize'
23766nvtype='$nvtype'
23767o_nonblock='$o_nonblock'
23768obj_ext='$obj_ext'
23769old_pthread_create_joinable='$old_pthread_create_joinable'
23770optimize='$optimize'
23771orderlib='$orderlib'
23772osname='$osname'
23773osvers='$osvers'
23774otherlibdirs='$otherlibdirs'
23775package='$package'
23776pager='$pager'
23777passcat='$passcat'
23778patchlevel='$patchlevel'
23779path_sep='$path_sep'
23780perl5='$perl5'
23781perl='$perl'
23782perl_patchlevel='$perl_patchlevel'
23783perl_static_inline='$perl_static_inline'
23784perladmin='$perladmin'
23785perllibs='$perllibs'
23786perlpath='$perlpath'
23787pg='$pg'
23788phostname='$phostname'
23789pidtype='$pidtype'
23790plibpth='$plibpth'
23791pmake='$pmake'
23792pr='$pr'
23793prefix='$prefix'
23794prefixexp='$prefixexp'
23795privlib='$privlib'
23796privlibexp='$privlibexp'
23797procselfexe='$procselfexe'
23798prototype='$prototype'
23799ptrsize='$ptrsize'
23800quadkind='$quadkind'
23801quadtype='$quadtype'
23802randbits='$randbits'
23803randfunc='$randfunc'
23804random_r_proto='$random_r_proto'
23805randseedtype='$randseedtype'
23806ranlib='$ranlib'
23807rd_nodata='$rd_nodata'
23808readdir64_r_proto='$readdir64_r_proto'
23809readdir_r_proto='$readdir_r_proto'
23810revision='$revision'
23811rm='$rm'
23812rm_try='$rm_try'
23813rmail='$rmail'
23814run='$run'
23815runnm='$runnm'
23816sGMTIME_max='$sGMTIME_max'
23817sGMTIME_min='$sGMTIME_min'
23818sLOCALTIME_max='$sLOCALTIME_max'
23819sLOCALTIME_min='$sLOCALTIME_min'
23820sPRIEUldbl='$sPRIEUldbl'
23821sPRIFUldbl='$sPRIFUldbl'
23822sPRIGUldbl='$sPRIGUldbl'
23823sPRIXU64='$sPRIXU64'
23824sPRId64='$sPRId64'
23825sPRIeldbl='$sPRIeldbl'
23826sPRIfldbl='$sPRIfldbl'
23827sPRIgldbl='$sPRIgldbl'
23828sPRIi64='$sPRIi64'
23829sPRIo64='$sPRIo64'
23830sPRIu64='$sPRIu64'
23831sPRIx64='$sPRIx64'
23832sSCNfldbl='$sSCNfldbl'
23833sched_yield='$sched_yield'
23834scriptdir='$scriptdir'
23835scriptdirexp='$scriptdirexp'
23836sed='$sed'
23837seedfunc='$seedfunc'
23838selectminbits='$selectminbits'
23839selecttype='$selecttype'
23840sendmail='$sendmail'
23841setgrent_r_proto='$setgrent_r_proto'
23842sethostent_r_proto='$sethostent_r_proto'
23843setlocale_r_proto='$setlocale_r_proto'
23844setnetent_r_proto='$setnetent_r_proto'
23845setprotoent_r_proto='$setprotoent_r_proto'
23846setpwent_r_proto='$setpwent_r_proto'
23847setservent_r_proto='$setservent_r_proto'
23848sh='$sh'
23849shar='$shar'
23850sharpbang='$sharpbang'
23851shmattype='$shmattype'
23852shortsize='$shortsize'
23853shrpenv='$shrpenv'
23854shsharp='$shsharp'
23855sig_count='$sig_count'
23856sig_name='$sig_name'
23857sig_name_init='$sig_name_init'
23858sig_num='$sig_num'
23859sig_num_init='$sig_num_init'
23860sig_size='$sig_size'
23861signal_t='$signal_t'
23862sitearch='$sitearch'
23863sitearchexp='$sitearchexp'
23864sitebin='$sitebin'
23865sitebinexp='$sitebinexp'
23866sitehtml1dir='$sitehtml1dir'
23867sitehtml1direxp='$sitehtml1direxp'
23868sitehtml3dir='$sitehtml3dir'
23869sitehtml3direxp='$sitehtml3direxp'
23870sitelib='$sitelib'
23871sitelib_stem='$sitelib_stem'
23872sitelibexp='$sitelibexp'
23873siteman1dir='$siteman1dir'
23874siteman1direxp='$siteman1direxp'
23875siteman3dir='$siteman3dir'
23876siteman3direxp='$siteman3direxp'
23877siteprefix='$siteprefix'
23878siteprefixexp='$siteprefixexp'
23879sitescript='$sitescript'
23880sitescriptexp='$sitescriptexp'
23881sizesize='$sizesize'
23882sizetype='$sizetype'
23883sleep='$sleep'
23884smail='$smail'
23885so='$so'
23886sockethdr='$sockethdr'
23887socketlib='$socketlib'
23888socksizetype='$socksizetype'
23889sort='$sort'
23890spackage='$spackage'
23891spitshell='$spitshell'
23892srand48_r_proto='$srand48_r_proto'
23893srandom_r_proto='$srandom_r_proto'
23894src='$src'
23895ssizetype='$ssizetype'
23896st_ino_sign='$st_ino_sign'
23897st_ino_size='$st_ino_size'
23898startperl='$startperl'
23899startsh='$startsh'
23900static_ext='$static_ext'
23901stdchar='$stdchar'
23902stdio_base='$stdio_base'
23903stdio_bufsiz='$stdio_bufsiz'
23904stdio_cnt='$stdio_cnt'
23905stdio_filbuf='$stdio_filbuf'
23906stdio_ptr='$stdio_ptr'
23907stdio_stream_array='$stdio_stream_array'
23908strerror_r_proto='$strerror_r_proto'
23909strings='$strings'
23910submit='$submit'
23911subversion='$subversion'
23912sysman='$sysman'
23913sysroot='$sysroot'
23914tail='$tail'
23915tar='$tar'
23916targetarch='$targetarch'
23917targetdir='$targetdir'
23918targetenv='$targetenv'
23919targethost='$targethost'
23920targetmkdir='$targetmkdir'
23921targetport='$targetport'
23922targetsh='$targetsh'
23923tbl='$tbl'
23924tee='$tee'
23925test='$test'
23926timeincl='$timeincl'
23927timetype='$timetype'
23928tmpnam_r_proto='$tmpnam_r_proto'
23929to='$to'
23930touch='$touch'
23931tr='$tr'
23932trnl='$trnl'
23933troff='$troff'
23934ttyname_r_proto='$ttyname_r_proto'
23935u16size='$u16size'
23936u16type='$u16type'
23937u32size='$u32size'
23938u32type='$u32type'
23939u64size='$u64size'
23940u64type='$u64type'
23941u8size='$u8size'
23942u8type='$u8type'
23943uidformat='$uidformat'
23944uidsign='$uidsign'
23945uidsize='$uidsize'
23946uidtype='$uidtype'
23947uname='$uname'
23948uniq='$uniq'
23949uquadtype='$uquadtype'
23950use5005threads='$use5005threads'
23951use64bitall='$use64bitall'
23952use64bitint='$use64bitint'
23953usecrosscompile='$usecrosscompile'
23954usedevel='$usedevel'
23955usedl='$usedl'
23956usedtrace='$usedtrace'
23957usefaststdio='$usefaststdio'
23958useithreads='$useithreads'
23959usekernprocpathname='$usekernprocpathname'
23960uselargefiles='$uselargefiles'
23961uselongdouble='$uselongdouble'
23962usemallocwrap='$usemallocwrap'
23963usemorebits='$usemorebits'
23964usemultiplicity='$usemultiplicity'
23965usemymalloc='$usemymalloc'
23966usenm='$usenm'
23967usensgetexecutablepath='$usensgetexecutablepath'
23968useopcode='$useopcode'
23969useperlio='$useperlio'
23970useposix='$useposix'
23971usereentrant='$usereentrant'
23972userelocatableinc='$userelocatableinc'
23973useshrplib='$useshrplib'
23974usesitecustomize='$usesitecustomize'
23975usesocks='$usesocks'
23976usethreads='$usethreads'
23977usevendorprefix='$usevendorprefix'
23978useversionedarchname='$useversionedarchname'
23979usevfork='$usevfork'
23980usrinc='$usrinc'
23981uuname='$uuname'
23982uvXUformat='$uvXUformat'
23983uvoformat='$uvoformat'
23984uvsize='$uvsize'
23985uvtype='$uvtype'
23986uvuformat='$uvuformat'
23987uvxformat='$uvxformat'
23988vaproto='$vaproto'
23989vendorarch='$vendorarch'
23990vendorarchexp='$vendorarchexp'
23991vendorbin='$vendorbin'
23992vendorbinexp='$vendorbinexp'
23993vendorhtml1dir='$vendorhtml1dir'
23994vendorhtml1direxp='$vendorhtml1direxp'
23995vendorhtml3dir='$vendorhtml3dir'
23996vendorhtml3direxp='$vendorhtml3direxp'
23997vendorlib='$vendorlib'
23998vendorlib_stem='$vendorlib_stem'
23999vendorlibexp='$vendorlibexp'
24000vendorman1dir='$vendorman1dir'
24001vendorman1direxp='$vendorman1direxp'
24002vendorman3dir='$vendorman3dir'
24003vendorman3direxp='$vendorman3direxp'
24004vendorprefix='$vendorprefix'
24005vendorprefixexp='$vendorprefixexp'
24006vendorscript='$vendorscript'
24007vendorscriptexp='$vendorscriptexp'
24008version='$version'
24009version_patchlevel_string='$version_patchlevel_string'
24010versiononly='$versiononly'
24011vi='$vi'
24012xlibpth='$xlibpth'
24013yacc='$yacc'
24014yaccflags='$yaccflags'
24015zcat='$zcat'
24016zip='$zip'
24017EOT
24018
24019: add special variables
24020$test -f $src/patchlevel.h && \
24021awk '/^#define[ 	]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
24022echo "PERL_PATCHLEVEL='$perl_patchlevel'" >>config.sh
24023echo "PERL_CONFIG_SH=true" >>config.sh
24024
24025: propagate old symbols
24026if $test -f UU/config.sh; then
24027	<UU/config.sh $sort | $uniq >UU/oldconfig.sh
24028	$sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' \
24029		config.sh config.sh UU/oldconfig.sh |\
24030		$sort | $uniq -u >UU/oldsyms
24031	set X `$cat UU/oldsyms`
24032	shift
24033	case $# in
24034	0) ;;
24035	*)
24036		$cat <<EOM
24037Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
24038EOM
24039		echo ": Variables propagated from previous config.sh file." >>config.sh
24040		for sym in `$cat UU/oldsyms`; do
24041			echo "    Propagating $hint variable "'$'"$sym..."
24042			eval 'tmp="$'"${sym}"'"'
24043			echo "$tmp" | \
24044				sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
24045		done
24046		;;
24047	esac
24048fi
24049
24050: Finish up by extracting the .SH files
24051case "$alldone" in
24052exit)
24053	$rm -rf UU
24054	echo "Extraction done."
24055	exit 0
24056	;;
24057cont)
24058	;;
24059'')
24060	dflt=''
24061	nostick=true
24062	$cat <<EOM
24063
24064If you'd like to make any changes to the config.sh file before I begin
24065to configure things, do it as a shell escape now (e.g. !vi config.sh).
24066
24067EOM
24068	rp="Press return or use a shell escape to edit config.sh:"
24069	. UU/myread
24070	nostick=''
24071	case "$ans" in
24072	'') ;;
24073	*) : in case they cannot read
24074		sh 1>&4 -c "$ans";;
24075	esac
24076	;;
24077esac
24078
24079: if this fails, just run all the .SH files by hand
24080. ./config.sh
24081
24082echo " "
24083exec 1>&4
24084pwd=`pwd`
24085. ./UU/extract
24086cd "$pwd"
24087
24088if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
24089	dflt=y
24090	case "$silent" in
24091	true) ;;
24092	*)
24093		$cat <<EOM
24094
24095Now you need to generate make dependencies by running "$make depend".
24096You might prefer to run it in background: "$make depend > makedepend.out &"
24097It can take a while, so you might not want to run it right now.
24098
24099EOM
24100		;;
24101	esac
24102	rp="Run $make depend now?"
24103	. UU/myread
24104	case "$ans" in
24105	y*)
24106		$make depend && echo "Now you must run '$make'."
24107		;;
24108	*)
24109		echo "You must run '$make depend' then '$make'."
24110		;;
24111	esac
24112elif test -f [Mm]akefile; then
24113	echo " "
24114	echo "Now you must run a $make."
24115else
24116	echo "Configure done."
24117fi
24118
24119if $test -f Policy.sh; then
24120    $cat <<EOM
24121
24122If you compile $package on a different machine or from a different object
24123directory, copy the Policy.sh file from this object directory to the
24124new one before you run Configure -- this will help you with most of
24125the policy defaults.
24126
24127EOM
24128fi
24129if $test -f config.msg; then
24130    echo "Hmm.  I also noted the following information while running:"
24131    echo " "
24132    $cat config.msg >&4
24133    $rm -f config.msg
24134fi
24135$rm -f kit*isdone ark*isdone
24136$rm -rf UU
24137
24138: End of Configure
24139
24140