xref: /openbsd/gnu/usr.bin/perl/Configure (revision e5dd7070)
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 by the tool
15# called "metaconfig". Rather than working with this copy of Configure,
16# you should use metaconfig. Perl uses a modified version of this
17# tool, and this, together with the metaconfig units, are available
18# in the git repository:
19#    $ git clone https://github.com/perl5-metaconfig/metaconfig metaconfig
20# The original dist package (including metaconfig) is available on github:
21#    $ git clone https://github.com/rmanfredi/dist.git dist-git
22#
23# Though this script was generated by metaconfig from metaunits, it is
24# OK to send patches against Configure itself (but not to commit them
25# to blead). It's up to
26# the Configure maintainers to backport the patch to the metaunits if it
27# is accepted. Exceptions to this rule, and more information, is in
28# Porting/pumpkin.pod.
29
30# Generated using [metaconfig 3.5 PL0]
31# (with additional metaconfig patches by perlbug@perl.org)
32
33cat >c1$$ <<EOF
34ARGGGHHHH!!!!!
35
36SCO csh still thinks true is false.  Write to SCO today and tell them that next
37year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
38
39(Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
40we'd have to do is go in and swap the && and || tokens, wherever they are.)
41
42[End of diatribe. We now return you to your regularly scheduled programming...]
43EOF
44cat >c2$$ <<EOF
45
46OOPS!  You naughty creature!  You didn't run Configure with sh!
47I will attempt to remedy the situation by running sh for you...
48EOF
49
50true || cat c1$$ c2$$
51true || exec sh $0 $argv:q
52
53(exit $?0) || cat c2$$
54(exit $?0) || exec sh $0 $argv:q
55rm -f c1$$ c2$$
56
57if test -f /dev/cputype -a -f /dev/drivers -a -f /dev/osversion; then
58	cat <<EOF
59***
60*** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
61*** Configure that well.  (Plan 9 is close to UNIX but not close enough.)
62*** Please read the README.plan9 for further instructions.
63*** Cannot continue, aborting.
64***
65EOF
66	exit 1
67fi
68
69if test -f /sys/utilities/MultiView ; then
70	# AmigaOS, test -c for /dev/null is not useful
71	:
72elif test ! -c /dev/null ; then
73	cat <<EOF
74***
75*** I'm sorry, but /dev/null appears to be a file rather than a device.
76*** Please consult your operating sytem's notes for making a device
77*** in /dev.
78*** Cannot continue, aborting.
79***
80EOF
81	exit 1
82fi
83
84: compute my invocation name
85me=$0
86case "$0" in
87*/*)
88	me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
89	test "$me" || me=$0
90	;;
91esac
92
93: Proper separator for the PATH environment variable
94p_=:
95: On OS/2 this directory should exist if this is not floppy only system ":-]"
96if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' 2>&1 ) 2>&1 >/dev/null ; then
97	if test -n "$OS2_SHELL"; then
98		p_=\;
99		PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
100		OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
101		is_os2=yes
102	elif test -n "$DJGPP"; then
103		case "X${MACHTYPE:-nonesuchmach}" in
104		*cygwin|*msys) ;;
105		*) p_=\; ;;
106		esac
107	fi
108fi
109
110: Proper PATH setting
111paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
112paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
113paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
114paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
115paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
116paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /opt/ansic/bin /usr/ccs/bin"
117paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
118paths="$paths /sbin /usr/sbin /usr/libexec"
119paths="$paths /system/gnu_library/bin"
120
121for p in $paths
122do
123	case "$p_$PATH$p_" in
124	*$p_$p$p_*) ;;
125	*) test -d $p && PATH=$PATH$p_$p ;;
126	esac
127done
128
129PATH=.$p_$PATH
130export PATH
131
132: shall we be using ksh?
133inksh=''
134needksh=''
135avoidksh=''
136newsh=/bin/ksh
137changesh=''
138if (PATH=.; alias -x) >/dev/null 2>&1; then
139		inksh=true
140fi
141if test -f /hp-ux -a -f /bin/ksh; then
142	needksh='to avoid sh bug in "here document" expansion'
143fi
144if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
145	if test X`/usr/bin/uname -v` = X4; then
146		avoidksh="to avoid AIX 4's /bin/sh"
147		newsh=/usr/bin/bsh
148	fi
149fi
150if test -f /osf_boot -a -f /usr/sbin/setld; then
151	if test X`/usr/bin/uname -s` = XOSF1; then
152		avoidksh="to avoid Digital UNIX' ksh"
153		newsh=/bin/sh
154		unset BIN_SH
155	fi
156fi
157case "$inksh/$needksh" in
158/[a-z]*)
159		ENV=''
160		changesh=true
161		reason="$needksh"
162	;;
163esac
164case "$inksh/$avoidksh" in
165true/[a-z]*)
166	changesh=true
167	reason="$avoidksh"
168	;;
169esac
170case "$inksh/$needksh-$avoidksh-" in
171true/--)
172		cat <<EOM
173(I see you are using the Korn shell.  Some ksh's blow up on $me,
174mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
175EOM
176	;;
177esac
178case "$changesh" in
179true)
180	export newsh
181	echo "(Feeding myself to $newsh $reason.)"
182	case "$0" in
183	Configure|*/Configure) exec $newsh $0 "$@";;
184	*) exec $newsh Configure "$@";;
185	esac
186	;;
187esac
188test -x "${newsh}" || unset newsh
189
190: if needed, set CDPATH to a harmless value that is not chatty
191: avoid bash 2.02 problems with empty CDPATH.
192case "$CDPATH" in
193'')	;;
194*)	case "$SHELL" in
195	*bash*) CDPATH='.' ;;
196	*) CDPATH='' ;;
197	esac
198	;;
199esac
200
201: Configure runs within the UU subdirectory
202test -d UU || mkdir UU
203cd UU && rm -f ./*
204
205ccname=''
206ccversion=''
207ccsymbols=''
208cppccsymbols=''
209cppsymbols=''
210from=''
211hostgenerate=''
212hostosname=''
213hostperl=''
214run=''
215targetarch=''
216targetdir=''
217targetenv=''
218targethost=''
219targetmkdir=''
220targetport=''
221to=''
222usecrosscompile=''
223extern_C=''
224mistrustnm=''
225usedevel=''
226perllibs=''
227dynamic_ext=''
228extensions=''
229known_extensions=''
230nonxs_ext=''
231static_ext=''
232uselanginfo=''
233useopcode=''
234useposix=''
235extras=''
236d_bsd=''
237d_eunice=''
238d_xenix=''
239eunicefix=''
240ar=''
241awk=''
242bash=''
243bison=''
244byacc=''
245cat=''
246chgrp=''
247chmod=''
248chown=''
249comm=''
250compress=''
251cp=''
252cpio=''
253cpp=''
254csh=''
255date=''
256echo=''
257egrep=''
258emacs=''
259expr=''
260find=''
261flex=''
262gmake=''
263grep=''
264gzip=''
265inews=''
266ksh=''
267less=''
268line=''
269lint=''
270ln=''
271lp=''
272lpr=''
273ls=''
274mail=''
275mailx=''
276make=''
277mkdir=''
278more=''
279mv=''
280nm=''
281nroff=''
282perl=''
283pg=''
284pmake=''
285pr=''
286rm=''
287rmail=''
288sed=''
289sendmail=''
290shar=''
291sleep=''
292smail=''
293sort=''
294submit=''
295tail=''
296tar=''
297tbl=''
298tee=''
299test=''
300touch=''
301tr=''
302troff=''
303uname=''
304uniq=''
305uuname=''
306vi=''
307zcat=''
308zip=''
309full_ar=''
310full_sed=''
311libswanted=''
312hint=''
313myuname=''
314osname=''
315osvers=''
316Author=''
317Date=''
318Header=''
319Id=''
320Locker=''
321Log=''
322RCSfile=''
323Revision=''
324Source=''
325State=''
326sysroot=''
327_a=''
328_exe=''
329_o=''
330archobjs=''
331exe_ext=''
332firstmakefile=''
333lib_ext=''
334obj_ext=''
335path_sep=''
336rm_try=''
337afs=''
338afsroot=''
339alignbytes=''
340archlib=''
341archlibexp=''
342d_archlib=''
343installarchlib=''
344archname=''
345myarchname=''
346useversionedarchname=''
347d_atolf=''
348d_atoll=''
349baserev=''
350bin=''
351binexp=''
352initialinstalllocation=''
353installbin=''
354userelocatableinc=''
355byteorder=''
356cc=''
357ccflags=''
358cppflags=''
359ldflags=''
360lkflags=''
361locincpth=''
362optimize=''
363cf_email=''
364cf_by=''
365cf_time=''
366charbits=''
367charsize=''
368contains=''
369cpp_stuff=''
370cpplast=''
371cppminus=''
372cpprun=''
373cppstdin=''
374d__fwalk=''
375d_accept4=''
376d_access=''
377d_accessx=''
378d_acosh=''
379d_aintl=''
380d_alarm=''
381asctime_r_proto=''
382d_asctime_r=''
383d_asinh=''
384d_atanh=''
385d_attribute_deprecated=''
386d_attribute_format=''
387d_attribute_malloc=''
388d_attribute_nonnull=''
389d_attribute_noreturn=''
390d_attribute_pure=''
391d_attribute_unused=''
392d_attribute_warn_unused_result=''
393d_printf_format_null=''
394d_backtrace=''
395d_builtin_choose_expr=''
396d_builtin_expect=''
397d_builtin_add_overflow=''
398d_builtin_mul_overflow=''
399d_builtin_sub_overflow=''
400d_c99_variadic_macros=''
401d_casti32=''
402castflags=''
403d_castneg=''
404d_cbrt=''
405d_chown=''
406d_chroot=''
407d_chsize=''
408d_class=''
409d_clearenv=''
410d_closedir=''
411d_void_closedir=''
412d_cmsghdr_s=''
413d_copysign=''
414d_copysignl=''
415d_cplusplus=''
416cryptlib=''
417d_crypt=''
418crypt_r_proto=''
419d_crypt_r=''
420d_csh=''
421full_csh=''
422d_ctermid=''
423ctermid_r_proto=''
424d_ctermid_r=''
425ctime_r_proto=''
426d_ctime_r=''
427d_cuserid=''
428d_dbminitproto=''
429d_difftime=''
430d_dir_dd_fd=''
431d_dirfd=''
432d_dladdr=''
433d_dlerror=''
434d_dlopen=''
435d_dlsymun=''
436d_dosuid=''
437d_suidsafe=''
438d_drand48_r=''
439drand48_r_proto=''
440d_drand48proto=''
441d_dup2=''
442d_dup3=''
443d_eaccess=''
444d_endgrent=''
445d_endgrent_r=''
446endgrent_r_proto=''
447d_endhent=''
448d_endhostent_r=''
449endhostent_r_proto=''
450d_endnent=''
451d_endnetent_r=''
452endnetent_r_proto=''
453d_endpent=''
454d_endprotoent_r=''
455endprotoent_r_proto=''
456d_endpwent=''
457d_endpwent_r=''
458endpwent_r_proto=''
459d_endsent=''
460d_endservent_r=''
461endservent_r_proto=''
462d_erf=''
463d_erfc=''
464d_exp2=''
465d_expm1=''
466d_faststdio=''
467d_fchdir=''
468d_fchmod=''
469d_fchown=''
470d_fcntl=''
471d_fcntl_can_lock=''
472d_fd_macros=''
473d_fd_set=''
474d_fds_bits=''
475d_fdclose=''
476d_fdim=''
477d_fegetround=''
478d_fgetpos=''
479d_finite=''
480d_finitel=''
481d_flexfnam=''
482d_flock=''
483d_flockproto=''
484d_fma=''
485d_fmax=''
486d_fmin=''
487d_fork=''
488d_fp_class=''
489d_fp_classl=''
490d_fpclass=''
491d_fp_classify=''
492d_fpclassify=''
493d_fpclassl=''
494d_fpgetround=''
495d_fpos64_t=''
496d_frexpl=''
497d_fs_data_s=''
498d_fchmodat=''
499d_linkat=''
500d_openat=''
501d_renameat=''
502d_unlinkat=''
503d_fseeko=''
504d_fsetpos=''
505d_fstatfs=''
506d_fsync=''
507d_ftello=''
508d_ftime=''
509d_gettimeod=''
510d_futimes=''
511d_gai_strerror=''
512d_Gconvert=''
513d_getaddrinfo=''
514d_getcwd=''
515d_getespwnam=''
516d_getfsstat=''
517d_getgrent=''
518d_getgrent_r=''
519getgrent_r_proto=''
520d_getgrgid_r=''
521getgrgid_r_proto=''
522d_getgrnam_r=''
523getgrnam_r_proto=''
524d_getgrps=''
525d_gethbyaddr=''
526d_gethbyname=''
527d_gethent=''
528aphostname=''
529d_gethname=''
530d_phostname=''
531d_uname=''
532d_gethostbyaddr_r=''
533gethostbyaddr_r_proto=''
534d_gethostbyname_r=''
535gethostbyname_r_proto=''
536d_gethostent_r=''
537gethostent_r_proto=''
538d_gethostprotos=''
539d_getitimer=''
540d_getlogin=''
541d_getlogin_r=''
542getlogin_r_proto=''
543d_getmnt=''
544d_getmntent=''
545d_getnameinfo=''
546d_getnbyaddr=''
547d_getnbyname=''
548d_getnent=''
549d_getnetbyaddr_r=''
550getnetbyaddr_r_proto=''
551d_getnetbyname_r=''
552getnetbyname_r_proto=''
553d_getnetent_r=''
554getnetent_r_proto=''
555d_getnetprotos=''
556d_getpagsz=''
557d_getpent=''
558d_getpgid=''
559d_getpgrp2=''
560d_bsdgetpgrp=''
561d_getpgrp=''
562d_getppid=''
563d_getprior=''
564d_getpbyname=''
565d_getpbynumber=''
566d_getprotobyname_r=''
567getprotobyname_r_proto=''
568d_getprotobynumber_r=''
569getprotobynumber_r_proto=''
570d_getprotoent_r=''
571getprotoent_r_proto=''
572d_getprotoprotos=''
573d_getprpwnam=''
574d_getpwent=''
575d_getpwent_r=''
576getpwent_r_proto=''
577d_getpwnam_r=''
578getpwnam_r_proto=''
579d_getpwuid_r=''
580getpwuid_r_proto=''
581d_getsent=''
582d_getservbyname_r=''
583getservbyname_r_proto=''
584d_getservbyport_r=''
585getservbyport_r_proto=''
586d_getservent_r=''
587getservent_r_proto=''
588d_getservprotos=''
589d_getspnam=''
590d_getspnam_r=''
591getspnam_r_proto=''
592d_getsbyname=''
593d_getsbyport=''
594d_gmtime_r=''
595gmtime_r_proto=''
596d_gnulibc=''
597gnulibc_version=''
598d_hasmntopt=''
599d_htonl=''
600d_hypot=''
601d_ilogb=''
602d_ilogbl=''
603d_inetaton=''
604d_inetntop=''
605d_inetpton=''
606d_int64_t=''
607d_isascii=''
608d_isblank=''
609d_isfinite=''
610d_isfinitel=''
611d_isinf=''
612d_isinfl=''
613d_isless=''
614d_isnan=''
615d_isnanl=''
616d_isnormal=''
617d_j0=''
618d_j0l=''
619d_killpg=''
620d_lc_monetary_2008=''
621d_lchown=''
622d_ldbl_dig=''
623d_lgamma=''
624d_lgamma_r=''
625d_libm_lib_version=''
626d_link=''
627d_llrint=''
628d_llrintl=''
629d_llround=''
630d_llroundl=''
631d_localeconv_l=''
632d_localtime_r=''
633d_localtime_r_needs_tzset=''
634localtime_r_proto=''
635d_locconv=''
636d_lockf=''
637d_log1p=''
638d_log2=''
639d_logb=''
640d_ldexpl=''
641d_long_double_style_ieee=''
642d_long_double_style_ieee_doubledouble=''
643d_long_double_style_ieee_extended=''
644d_long_double_style_ieee_std=''
645d_long_double_style_vax=''
646d_longdbl=''
647longdblkind=''
648longdblsize=''
649d_longlong=''
650longlongsize=''
651d_lrint=''
652d_lrintl=''
653d_lround=''
654d_lroundl=''
655d_lseekproto=''
656d_lstat=''
657d_madvise=''
658d_malloc_good_size=''
659d_malloc_size=''
660d_mblen=''
661d_mbrlen=''
662d_mbrtowc=''
663d_mbstowcs=''
664d_mbtowc=''
665d_memmem=''
666d_memrchr=''
667d_mkdir=''
668d_mkdtemp=''
669d_mkfifo=''
670d_mkostemp=''
671d_mkstemp=''
672d_mkstemps=''
673d_mktime=''
674d_mmap=''
675mmaptype=''
676d_modfl=''
677d_modflproto=''
678d_mprotect=''
679d_msg=''
680d_msgctl=''
681d_msgget=''
682d_msghdr_s=''
683d_msgrcv=''
684d_msgsnd=''
685d_msync=''
686d_munmap=''
687d_nan=''
688d_nanosleep=''
689d_nearbyint=''
690d_duplocale=''
691d_freelocale=''
692d_newlocale=''
693d_querylocale=''
694d_uselocale=''
695i_xlocale=''
696d_nextafter=''
697d_nexttoward=''
698d_nice=''
699d_nl_langinfo=''
700d_thread_safe_nl_langinfo_l=''
701d_off64_t=''
702d_open3=''
703d_fpathconf=''
704d_pathconf=''
705d_pause=''
706d_pipe2=''
707d_pipe=''
708d_poll=''
709d_portable=''
710d_prctl=''
711d_prctl_set_name=''
712d_procselfexe=''
713procselfexe=''
714d_old_pthread_create_joinable=''
715old_pthread_create_joinable=''
716d_pthread_atfork=''
717d_pthread_attr_setscope=''
718d_pthread_yield=''
719d_sched_yield=''
720sched_yield=''
721d_ptrdiff_t=''
722d_qgcvt=''
723d_random_r=''
724random_r_proto=''
725d_readdir64_r=''
726readdir64_r_proto=''
727d_readdir=''
728d_rewinddir=''
729d_seekdir=''
730d_telldir=''
731d_readdir_r=''
732readdir_r_proto=''
733d_readlink=''
734d_readv=''
735d_recvmsg=''
736d_re_comp=''
737d_regcmp=''
738d_regcomp=''
739d_remainder=''
740d_remquo=''
741d_rename=''
742d_rint=''
743d_rmdir=''
744d_round=''
745d_sbrkproto=''
746d_scalbn=''
747d_scalbnl=''
748d_select=''
749d_sem=''
750d_semctl=''
751d_semget=''
752d_semop=''
753d_sendmsg=''
754d_setegid=''
755d_seteuid=''
756d_setgrent=''
757d_setgrent_r=''
758setgrent_r_proto=''
759d_setgrps=''
760d_sethent=''
761d_sethostent_r=''
762sethostent_r_proto=''
763d_setitimer=''
764d_setlinebuf=''
765d_has_C_UTF8=''
766d_setlocale=''
767d_setlocale_accepts_any_locale_name=''
768d_setlocale_r=''
769setlocale_r_proto=''
770d_setnent=''
771d_setnetent_r=''
772setnetent_r_proto=''
773d_setpent=''
774d_setpgid=''
775d_setpgrp2=''
776d_bsdsetpgrp=''
777d_setpgrp=''
778d_setprior=''
779d_setproctitle=''
780d_setprotoent_r=''
781setprotoent_r_proto=''
782d_setpwent=''
783d_setpwent_r=''
784setpwent_r_proto=''
785d_setregid=''
786d_setresgid=''
787d_setresuid=''
788d_setreuid=''
789d_setrgid=''
790d_setruid=''
791d_setsent=''
792d_setservent_r=''
793setservent_r_proto=''
794d_setsid=''
795d_setvbuf=''
796d_shm=''
797d_shmat=''
798d_shmatprototype=''
799shmattype=''
800d_shmctl=''
801d_shmdt=''
802d_shmget=''
803d_sigaction=''
804d_siginfo_si_addr=''
805d_siginfo_si_band=''
806d_siginfo_si_errno=''
807d_siginfo_si_fd=''
808d_siginfo_si_pid=''
809d_siginfo_si_status=''
810d_siginfo_si_uid=''
811d_siginfo_si_value=''
812d_signbit=''
813d_sigprocmask=''
814d_sigsetjmp=''
815usesitecustomize=''
816d_snprintf=''
817d_vsnprintf=''
818d_sockatmark=''
819d_sockatmarkproto=''
820d_ip_mreq=''
821d_ip_mreq_source=''
822d_ipv6_mreq=''
823d_ipv6_mreq_source=''
824d_msg_ctrunc=''
825d_msg_dontroute=''
826d_msg_oob=''
827d_msg_peek=''
828d_msg_proxy=''
829d_oldsock=''
830d_scm_rights=''
831d_sin6_scope_id=''
832d_sockaddr_in6=''
833d_sockaddr_sa_len=''
834d_socket=''
835d_sockpair=''
836sockethdr=''
837socketlib=''
838d_socklen_t=''
839d_socks5_init=''
840d_sqrtl=''
841d_srand48_r=''
842srand48_r_proto=''
843d_srandom_r=''
844srandom_r_proto=''
845d_sresgproto=''
846d_sresuproto=''
847d_stat=''
848d_statblks=''
849d_statfs_f_flags=''
850d_statfs_s=''
851d_static_inline=''
852perl_static_inline=''
853d_fstatvfs=''
854d_statvfs=''
855d_stdio_cnt_lval=''
856d_stdio_ptr_lval=''
857d_stdio_ptr_lval_nochange_cnt=''
858d_stdio_ptr_lval_sets_cnt=''
859d_stdiobase=''
860d_stdstdio=''
861stdio_base=''
862stdio_bufsiz=''
863stdio_cnt=''
864stdio_filbuf=''
865stdio_ptr=''
866d_strcoll=''
867d_sysernlst=''
868d_syserrlst=''
869d_strerror_l=''
870d_strerror_r=''
871strerror_r_proto=''
872d_strftime=''
873d_strlcat=''
874d_strlcpy=''
875d_strnlen=''
876d_strtod=''
877d_strtod_l=''
878d_strtol=''
879d_strtold=''
880d_strtold_l=''
881d_strtoll=''
882d_strtoq=''
883d_strtoul=''
884d_strtoull=''
885d_strtouq=''
886d_strxfrm=''
887d_symlink=''
888d_syscall=''
889d_syscallproto=''
890d_sysconf=''
891d_system=''
892d_tcgetpgrp=''
893d_tcsetpgrp=''
894d_telldirproto=''
895d_tgamma=''
896d_time=''
897timetype=''
898d_asctime64=''
899d_ctime64=''
900d_difftime64=''
901d_gmtime64=''
902d_localtime64=''
903d_mktime64=''
904d_timegm=''
905clocktype=''
906d_times=''
907d_tmpnam_r=''
908tmpnam_r_proto=''
909d_towlower=''
910d_towupper=''
911d_trunc=''
912d_truncate=''
913d_truncl=''
914d_ttyname_r=''
915ttyname_r_proto=''
916d_tzname=''
917d_u32align=''
918d_ualarm=''
919d_umask=''
920d_semctl_semid_ds=''
921d_semctl_semun=''
922d_union_semun=''
923d_unordered=''
924d_unsetenv=''
925d_usleep=''
926d_usleepproto=''
927d_ustat=''
928d_pseudofork=''
929d_vfork=''
930usevfork=''
931d_voidsig=''
932signal_t=''
933d_wait4=''
934d_waitpid=''
935d_wcscmp=''
936d_wcstombs=''
937d_wcsxfrm=''
938d_wctomb=''
939d_writev=''
940default_inc_excludes_dot=''
941dlext=''
942bin_ELF=''
943cccdlflags=''
944ccdlflags=''
945dlsrc=''
946ld=''
947ld_can_script=''
948lddlflags=''
949usedl=''
950doublesize=''
951dtraceobject=''
952dtracexnolibs=''
953ebcdic=''
954fflushNULL=''
955fflushall=''
956fpossize=''
957fpostype=''
958gccansipedantic=''
959gccosandvers=''
960gccversion=''
961gidformat=''
962gidsign=''
963gidsize=''
964gidtype=''
965groupstype=''
966h_fcntl=''
967h_sysfile=''
968html1dir=''
969html1direxp=''
970installhtml1dir=''
971html3dir=''
972html3direxp=''
973installhtml3dir=''
974i_arpainet=''
975i_bfd=''
976i_crypt=''
977db_hashtype=''
978db_prefixtype=''
979db_version_major=''
980db_version_minor=''
981db_version_patch=''
982i_db=''
983i_dbm=''
984i_rpcsvcdbm=''
985d_dirnamlen=''
986direntrytype=''
987i_dirent=''
988i_dlfcn=''
989i_execinfo=''
990i_fcntl=''
991i_fenv=''
992i_fp=''
993i_fp_class=''
994i_gdbm=''
995d_grpasswd=''
996i_grp=''
997i_ieeefp=''
998i_inttypes=''
999i_langinfo=''
1000i_libutil=''
1001i_locale=''
1002i_machcthr=''
1003i_malloc=''
1004i_mallocmalloc=''
1005i_mntent=''
1006d_gdbm_ndbm_h_uses_prototypes=''
1007d_gdbmndbm_h_uses_prototypes=''
1008d_ndbm=''
1009d_ndbm_h_uses_prototypes=''
1010i_gdbm_ndbm=''
1011i_gdbmndbm=''
1012i_ndbm=''
1013i_netdb=''
1014i_neterrno=''
1015i_netinettcp=''
1016i_niin=''
1017i_sysin=''
1018i_poll=''
1019i_prot=''
1020i_pthread=''
1021d_pwage=''
1022d_pwchange=''
1023d_pwclass=''
1024d_pwcomment=''
1025d_pwexpire=''
1026d_pwgecos=''
1027d_pwpasswd=''
1028d_pwquota=''
1029i_pwd=''
1030i_quadmath=''
1031i_shadow=''
1032i_socks=''
1033i_stdbool=''
1034i_stdint=''
1035i_stdlib=''
1036i_sunmath=''
1037i_sysaccess=''
1038i_sysdir=''
1039i_sysfile=''
1040d_voidtty=''
1041i_bsdioctl=''
1042i_sysfilio=''
1043i_sysioctl=''
1044i_syssockio=''
1045i_syslog=''
1046i_sysmman=''
1047i_sysmode=''
1048i_sysmount=''
1049i_sysndir=''
1050i_sysparam=''
1051i_syspoll=''
1052i_sysresrc=''
1053i_syssecrt=''
1054i_sysselct=''
1055i_sysstat=''
1056i_sysstatfs=''
1057i_sysstatvfs=''
1058i_systimes=''
1059i_systypes=''
1060i_sysuio=''
1061i_sysun=''
1062i_sysutsname=''
1063i_sysvfs=''
1064i_syswait=''
1065i_sgtty=''
1066i_termio=''
1067i_termios=''
1068d_tm_tm_gmtoff=''
1069d_tm_tm_zone=''
1070i_systime=''
1071i_systimek=''
1072i_time=''
1073timeincl=''
1074i_unistd=''
1075i_ustat=''
1076i_utime=''
1077i_vfork=''
1078i_wchar=''
1079i_wctype=''
1080d_inc_version_list=''
1081inc_version_list=''
1082inc_version_list_init=''
1083doubleinfbytes=''
1084doublenanbytes=''
1085longdblinfbytes=''
1086longdblnanbytes=''
1087installprefix=''
1088installprefixexp=''
1089installstyle=''
1090installusrbinperl=''
1091intsize=''
1092longsize=''
1093shortsize=''
1094issymlink=''
1095libc=''
1096ldlibpthname=''
1097libperl=''
1098shrpenv=''
1099useshrplib=''
1100glibpth=''
1101incpth=''
1102libpth=''
1103loclibpth=''
1104plibpth=''
1105xlibpth=''
1106ignore_versioned_solibs=''
1107libs=''
1108libsdirs=''
1109libsfiles=''
1110libsfound=''
1111libspath=''
1112lns=''
1113d_PRIEUldbl=''
1114d_PRIFUldbl=''
1115d_PRIGUldbl=''
1116d_PRIeldbl=''
1117d_PRIfldbl=''
1118d_PRIgldbl=''
1119d_SCNfldbl=''
1120d_double_has_inf=''
1121d_double_has_nan=''
1122d_double_has_negative_zero=''
1123d_double_has_subnormals=''
1124d_double_style_cray=''
1125d_double_style_ibm=''
1126d_double_style_ieee=''
1127d_double_style_vax=''
1128doublekind=''
1129sPRIEUldbl=''
1130sPRIFUldbl=''
1131sPRIGUldbl=''
1132sPRIeldbl=''
1133sPRIfldbl=''
1134sPRIgldbl=''
1135sSCNfldbl=''
1136lseeksize=''
1137lseektype=''
1138make_set_make=''
1139d_mymalloc=''
1140freetype=''
1141mallocobj=''
1142mallocsrc=''
1143malloctype=''
1144usemallocwrap=''
1145usemymalloc=''
1146installman1dir=''
1147man1dir=''
1148man1direxp=''
1149man1ext=''
1150installman3dir=''
1151man3dir=''
1152man3direxp=''
1153man3ext=''
1154doublemantbits=''
1155longdblmantbits=''
1156nvmantbits=''
1157modetype=''
1158multiarch=''
1159mydomain=''
1160myhostname=''
1161phostname=''
1162c=''
1163n=''
1164d_eofnblk=''
1165eagain=''
1166o_nonblock=''
1167rd_nodata=''
1168need_va_copy=''
1169netdb_hlen_type=''
1170netdb_host_type=''
1171netdb_name_type=''
1172netdb_net_type=''
1173groupcat=''
1174hostcat=''
1175passcat=''
1176orderlib=''
1177ranlib=''
1178d_perl_otherlibdirs=''
1179otherlibdirs=''
1180package=''
1181spackage=''
1182pager=''
1183api_revision=''
1184api_subversion=''
1185api_version=''
1186api_versionstring=''
1187patchlevel=''
1188perl_patchlevel=''
1189revision=''
1190subversion=''
1191version=''
1192version_patchlevel_string=''
1193perl5=''
1194perladmin=''
1195perlpath=''
1196d_nv_preserves_uv=''
1197d_nv_zero_is_allbits_zero=''
1198i16size=''
1199i16type=''
1200i32size=''
1201i32type=''
1202i64size=''
1203i64type=''
1204i8size=''
1205i8type=''
1206ivsize=''
1207ivtype=''
1208nv_overflows_integers_at=''
1209nv_preserves_uv_bits=''
1210nvsize=''
1211nvtype=''
1212u16size=''
1213u16type=''
1214u32size=''
1215u32type=''
1216u64size=''
1217u64type=''
1218u8size=''
1219u8type=''
1220uvsize=''
1221uvtype=''
1222ivdformat=''
1223nvEUformat=''
1224nvFUformat=''
1225nvGUformat=''
1226nveformat=''
1227nvfformat=''
1228nvgformat=''
1229uvXUformat=''
1230uvoformat=''
1231uvuformat=''
1232uvxformat=''
1233pidtype=''
1234prefix=''
1235prefixexp=''
1236installprivlib=''
1237privlib=''
1238privlibexp=''
1239ptrsize=''
1240d_PRIXU64=''
1241d_PRId64=''
1242d_PRIi64=''
1243d_PRIo64=''
1244d_PRIu64=''
1245d_PRIx64=''
1246sPRIXU64=''
1247sPRId64=''
1248sPRIi64=''
1249sPRIo64=''
1250sPRIu64=''
1251sPRIx64=''
1252d_quad=''
1253quadkind=''
1254quadtype=''
1255uquadtype=''
1256drand01=''
1257randbits=''
1258randfunc=''
1259randseedtype=''
1260seedfunc=''
1261installscript=''
1262scriptdir=''
1263scriptdirexp=''
1264selectminbits=''
1265selecttype=''
1266sh=''
1267targetsh=''
1268sig_count=''
1269sig_name=''
1270sig_name_init=''
1271sig_num=''
1272sig_num_init=''
1273sig_size=''
1274d_sitearch=''
1275installsitearch=''
1276sitearch=''
1277sitearchexp=''
1278installsitebin=''
1279sitebin=''
1280sitebinexp=''
1281installsitehtml1dir=''
1282sitehtml1dir=''
1283sitehtml1direxp=''
1284installsitehtml3dir=''
1285sitehtml3dir=''
1286sitehtml3direxp=''
1287installsitelib=''
1288sitelib=''
1289sitelib_stem=''
1290sitelibexp=''
1291installsiteman1dir=''
1292siteman1dir=''
1293siteman1direxp=''
1294installsiteman3dir=''
1295siteman3dir=''
1296siteman3direxp=''
1297siteprefix=''
1298siteprefixexp=''
1299installsitescript=''
1300sitescript=''
1301sitescriptexp=''
1302sizesize=''
1303sizetype=''
1304d_libname_unique=''
1305so=''
1306socksizetype=''
1307sharpbang=''
1308shsharp=''
1309spitshell=''
1310src=''
1311ssizetype=''
1312st_ino_sign=''
1313st_ino_size=''
1314startperl=''
1315startsh=''
1316stdchar=''
1317d_stdio_stream_array=''
1318stdio_stream_array=''
1319sysman=''
1320sGMTIME_max=''
1321sGMTIME_min=''
1322sLOCALTIME_max=''
1323sLOCALTIME_min=''
1324trnl=''
1325uidformat=''
1326uidsign=''
1327uidsize=''
1328uidtype=''
1329archname64=''
1330use64bitall=''
1331use64bitint=''
1332usecbacktrace=''
1333dtrace=''
1334usedtrace=''
1335usefaststdio=''
1336usekernprocpathname=''
1337ccflags_uselargefiles=''
1338ldflags_uselargefiles=''
1339libswanted_uselargefiles=''
1340uselargefiles=''
1341uselongdouble=''
1342usemorebits=''
1343usemultiplicity=''
1344nm_opt=''
1345nm_so_opt=''
1346runnm=''
1347usenm=''
1348usensgetexecutablepath=''
1349useperlio=''
1350usequadmath=''
1351usesocks=''
1352d_oldpthreads=''
1353use5005threads=''
1354useithreads=''
1355usereentrant=''
1356usethreads=''
1357incpath=''
1358mips_type=''
1359usrinc=''
1360d_vendorarch=''
1361installvendorarch=''
1362vendorarch=''
1363vendorarchexp=''
1364d_vendorbin=''
1365installvendorbin=''
1366vendorbin=''
1367vendorbinexp=''
1368installvendorhtml1dir=''
1369vendorhtml1dir=''
1370vendorhtml1direxp=''
1371installvendorhtml3dir=''
1372vendorhtml3dir=''
1373vendorhtml3direxp=''
1374d_vendorlib=''
1375installvendorlib=''
1376vendorlib=''
1377vendorlib_stem=''
1378vendorlibexp=''
1379installvendorman1dir=''
1380vendorman1dir=''
1381vendorman1direxp=''
1382installvendorman3dir=''
1383vendorman3dir=''
1384vendorman3direxp=''
1385usevendorprefix=''
1386vendorprefix=''
1387vendorprefixexp=''
1388d_vendorscript=''
1389installvendorscript=''
1390vendorscript=''
1391vendorscriptexp=''
1392versiononly=''
1393yacc=''
1394yaccflags=''
1395CONFIG=''
1396
1397: Detect odd OSs
1398define='define'
1399undef='undef'
1400smallmach='pdp11 i8086 z8000 i80286 iAPX286'
1401rmlist=''
1402
1403: We must find out about Eunice early
1404eunicefix=':'
1405if test -f /etc/unixtovms; then
1406	eunicefix=/etc/unixtovms
1407fi
1408if test -f /etc/unixtovms.exe; then
1409	eunicefix=/etc/unixtovms.exe
1410fi
1411
1412: Set executable suffix now -- needed before hints available
1413if test -f "/libs/version.library"; then
1414: Amiga OS
1415    _exe=""
1416elif test -f "/system/gnu_library/bin/ar.pm"; then
1417: Stratus VOS
1418    _exe=".pm"
1419elif test -n "$DJGPP"; then
1420: DOS DJGPP
1421    _exe=".exe"
1422elif test -f /kern/cookiejar; then
1423: MiNT
1424    _exe=""
1425elif test -d c:/. -o -n "$is_os2" ; then
1426: OS/2 or cygwin
1427    _exe=".exe"
1428fi
1429
1430groupstype=''
1431i_whoami=''
1432: Possible local include directories to search.
1433: Set locincpth to "" in a hint file to defeat local include searches.
1434locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
1435locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
1436:
1437: no include file wanted by default
1438inclwanted=''
1439
1440: Enable -DEBUGGING and -DDEBUGGING from the command line
1441EBUGGING=''
1442DEBUGGING=''
1443
1444: Trailing extension.  Override this in a hint file, if needed.
1445: Extra object files, if any, needed on this platform.
1446archobjs=''
1447libnames=''
1448: change the next line if compiling for Xenix/286 on Xenix/386
1449xlibpth='/usr/lib/386 /lib/386'
1450: Possible local library directories to search.
1451loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1452loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1453
1454: general looking path for locating libraries
1455glibpth="/lib /usr/lib $xlibpth"
1456glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
1457test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
1458test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
1459test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
1460
1461: Private path used by Configure to find libraries.  Its value
1462: is prepended to libpth. This variable takes care of special
1463: machines, like the mips.  Usually, it should be empty.
1464plibpth=''
1465
1466: default library list
1467libswanted=''
1468: some systems want to use only the non-versioned libso:s
1469ignore_versioned_solibs=''
1470ccname=''
1471ccversion=''
1472perllibs=''
1473: set useposix=false in your hint file to disable the POSIX extension.
1474useposix=true
1475: set useopcode=false in your hint file to disable the Opcode extension.
1476useopcode=true
1477: set uselanginfo=false in your hint file to disable the I18N::Langinfo extension.
1478uselanginfo=true
1479archname64=''
1480ccflags_uselargefiles=''
1481ldflags_uselargefiles=''
1482libswanted_uselargefiles=''
1483: set usemultiplicity on the Configure command line to enable multiplicity.
1484: set usesocks on the Configure command line to enable socks.
1485archname=''
1486: set usethreads on the Configure command line to enable threads.
1487usereentrant='undef'
1488: List of libraries we want.
1489: If anyone needs extra -lxxx, put those in a hint file.
1490libswanted="cl pthread socket bind inet nsl ndbm gdbm dbm db malloc dl ld"
1491libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
1492: We probably want to search /usr/shlib before most other libraries.
1493: This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
1494glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
1495glibpth="/usr/shlib $glibpth"
1496: Do not use vfork unless overridden by a hint file.
1497usevfork=false
1498
1499: Find the basic shell for Bourne shell scripts
1500case "$sh" in
1501'')
1502	case "$SYSTYPE" in
1503	*bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
1504	*) xxx='/bin/sh';;
1505	esac
1506	if test -f "$xxx"; then
1507		sh="$xxx"
1508	else
1509		: Build up a list and do a single loop so we can 'break' out.
1510		pth=`echo $PATH | sed -e "s/$p_/ /g"`
1511		for xxx in sh bash ksh pdksh ash; do
1512			for p in $pth; do
1513				try="$try ${p}/${xxx}"
1514			done
1515		done
1516		for xxx in $try; do
1517			if test -f "$xxx"; then
1518				sh="$xxx";
1519				break
1520			elif test "X$_exe" != X -a -f "$xxx$_exe"; then
1521				sh="$xxx";
1522				break
1523			elif test -f "$xxx.exe"; then
1524				sh="$xxx";
1525				break
1526			fi
1527		done
1528	fi
1529	;;
1530esac
1531
1532case "$sh" in
1533'')	cat >&2 <<EOM
1534$me:  Fatal Error:  I can't find a Bourne Shell anywhere.
1535
1536Usually it's in /bin/sh.  How did you even get this far?
1537Please contact me (Perl Maintainers) at https://github.com/Perl/perl5/issues
1538and we'll try to straighten this all out.
1539EOM
1540	exit 1
1541	;;
1542esac
1543
1544: When cross-compiling we need to separate the sh-to-run-Configure-with from the sh-to-use-in-Perl
1545: default both to the same thing, cross-compilers can then set targetsh differently if they like
1546targetsh=$sh
1547
1548: see if sh knows # comments
1549if `$sh -c '#' >/dev/null 2>&1`; then
1550	shsharp=true
1551	spitshell=cat
1552	xcat=/bin/cat
1553	test -f $xcat$_exe || xcat=/usr/bin/cat
1554	if test ! -f $xcat$_exe; then
1555		for p in `echo $PATH | sed -e "s/$p_/ /g"` $paths; do
1556			if test -f $p/cat$_exe; then
1557				xcat=$p/cat
1558				break
1559			fi
1560		done
1561		if test ! -f $xcat$_exe; then
1562			echo "Can't find cat anywhere!"
1563			exit 1
1564		fi
1565	fi
1566	echo "#!$xcat" >sharp
1567	$eunicefix sharp
1568	chmod +x sharp
1569	./sharp > today 2>/dev/null
1570	if test -s today; then
1571		sharpbang='#!'
1572	else
1573		echo "#! $xcat" > sharp
1574		$eunicefix sharp
1575		chmod +x sharp
1576		./sharp > today 2>/dev/null
1577		if test -s today; then
1578			sharpbang='#! '
1579		else
1580			sharpbang=': use '
1581		fi
1582	fi
1583else
1584	echo " "
1585	echo "Your $sh doesn't grok # comments--I will strip them later on."
1586	shsharp=false
1587	cd ..
1588	echo "exec grep -v '^[ 	]*#'" >spitshell
1589	chmod +x spitshell
1590	$eunicefix spitshell
1591	spitshell=`pwd`/spitshell
1592	cd UU
1593	echo "I presume that if # doesn't work, #! won't work either!"
1594	sharpbang=': use '
1595fi
1596rm -f sharp today
1597
1598: figure out how to guarantee sh startup
1599case "$startsh" in
1600'') startsh=${sharpbang}${sh} ;;
1601*)
1602esac
1603cat >sharp <<EOSS
1604$startsh
1605set abc
1606test "$?abc" != 1
1607EOSS
1608
1609chmod +x sharp
1610$eunicefix sharp
1611if ./sharp; then
1612	: echo "Yup, it does."
1613else
1614	echo "Hmm... '$startsh' does not guarantee sh startup..."
1615	echo "You may have to fix up the shell scripts to make sure $sh runs them."
1616fi
1617rm -f sharp
1618
1619: Save command line options in file UU/cmdline.opt for later use in
1620: generating config.sh.
1621cat > cmdline.opt <<EOSH
1622: Configure command line arguments.
1623config_arg0='$0'
1624config_args='$*'
1625config_argc=$#
1626EOSH
1627argn=1
1628args_exp=''
1629args_sep=''
1630for arg in "$@"; do
1631	cat >>cmdline.opt <<EOSH
1632config_arg$argn='$arg'
1633EOSH
1634	cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
1635$arg
1636EOC
1637	arg_exp=`cat cmdl.opt`
1638	args_exp="$args_exp$args_sep'$arg_exp'"
1639	argn=`expr $argn + 1`
1640	args_sep=' '
1641done
1642rm -f cmdl.opt
1643
1644: produce awk script to parse command line options
1645cat >options.awk <<'EOF'
1646BEGIN {
1647	optstr = "A:dD:eEf:hKOrsSU:V";	# getopt-style specification
1648
1649	len = length(optstr);
1650	for (i = 1; i <= len; i++) {
1651		c = substr(optstr, i, 1);
1652		if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1653		if (a == ":") {
1654			arg[c] = 1;
1655			i++;
1656		}
1657		opt[c] = 1;
1658	}
1659}
1660{
1661	expect = 0;
1662	str = $0;
1663	if (substr(str, 1, 1) != "-") {
1664		printf("'%s'\n", str);
1665		next;
1666	}
1667	len = length($0);
1668	for (i = 2; i <= len; i++) {
1669		c = substr(str, i, 1);
1670		if (!opt[c]) {
1671			printf("-%s\n", substr(str, i));
1672			next;
1673		}
1674		printf("-%s\n", c);
1675		if (arg[c]) {
1676			if (i < len)
1677				printf("'%s'\n", substr(str, i + 1));
1678			else
1679				expect = 1;
1680			next;
1681		}
1682	}
1683}
1684END {
1685	if (expect)
1686		print "?";
1687}
1688EOF
1689
1690: process the command line options
1691set X `for arg in "$@"; do echo "X$arg"; done |
1692	sed -e s/X// | awk -f options.awk`
1693eval "set $*"
1694shift
1695rm -f options.awk
1696
1697: set up default values
1698fastread=''
1699reuseval=false
1700config_sh=''
1701alldone=''
1702error=''
1703silent=''
1704extractsh=''
1705knowitall=''
1706rm -f optdef.sh posthint.sh
1707cat >optdef.sh <<EOS
1708$startsh
1709EOS
1710
1711
1712: option parsing
1713while test $# -gt 0; do
1714	case "$1" in
1715	-d) shift; fastread=yes;;
1716	-e) shift; alldone=cont;;
1717	-f)
1718		shift
1719		cd ..
1720		if test -r "$1"; then
1721			config_sh="$1"
1722		else
1723			echo "$me: cannot read config file $1." >&2
1724			error=true
1725		fi
1726		cd UU
1727		shift;;
1728	--help|\
1729	-h) shift; error=true;;
1730	-r) shift; reuseval=true;;
1731	-s) shift; silent=true; realsilent=true;;
1732	-E) shift; alldone=exit;;
1733	-K) shift; knowitall=true;;
1734	-O) shift;;
1735	-S) shift; silent=true; extractsh=true;;
1736	-D)
1737		shift
1738		case "$1" in
1739		*=)
1740			echo "$me: use '-U symbol=', not '-D symbol='." >&2
1741			echo "$me: ignoring -D $1" >&2
1742			;;
1743		*=*) echo "$1" | \
1744				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1745		*) echo "$1='define'" >> optdef.sh;;
1746		esac
1747		shift
1748		;;
1749	-U)
1750		shift
1751		case "$1" in
1752		*=) echo "$1" >> optdef.sh;;
1753		*=*)
1754			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1755			echo "$me: ignoring -U $1" >&2
1756			;;
1757		*) echo "$1='undef'" >> optdef.sh;;
1758		esac
1759		shift
1760		;;
1761	-A)
1762	    shift
1763	    xxx=''
1764	    yyy="$1"
1765	    zzz=''
1766	    uuu=undef
1767	    case "$yyy" in
1768            *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1769                 case "$zzz" in
1770                 *:*) zzz='' ;;
1771                 *)   xxx=append
1772                      zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1773                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1774                 esac
1775                 ;;
1776            esac
1777            case "$xxx" in
1778            '')  case "$yyy" in
1779                 *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1780                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1781                      zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1782                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1783                 *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
1784                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1785                 esac
1786                 ;;
1787            esac
1788	    case "$xxx" in
1789	    append)
1790		echo "$yyy=\"\${$yyy}$zzz\""	>> posthint.sh ;;
1791	    clear)
1792		echo "$yyy=''"			>> posthint.sh ;;
1793	    define)
1794	        case "$zzz" in
1795		'') zzz=define ;;
1796		esac
1797		echo "$yyy='$zzz'"		>> posthint.sh ;;
1798	    eval)
1799		echo "eval \"$yyy=$zzz\""	>> posthint.sh ;;
1800	    prepend)
1801		echo "$yyy=\"$zzz\${$yyy}\""	>> posthint.sh ;;
1802	    undef)
1803	        case "$zzz" in
1804		'') zzz="$uuu" ;;
1805		esac
1806		echo "$yyy=$zzz"		>> posthint.sh ;;
1807            *)  echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1808	    esac
1809	    shift
1810	    ;;
1811	-V) echo "$me generated by metaconfig 3.5 PL0." >&2
1812	    exit 0;;
1813	--) break;;
1814	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
1815	*) break;;
1816	esac
1817done
1818
1819case "$error" in
1820true)
1821	cat >&2 <<EOM
1822Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1823                 [-U symbol] [-U symbol=] [-A command:symbol...]
1824  -d : use defaults for all answers.
1825  -e : go on without questioning past the production of config.sh.
1826  -f : specify an alternate default configuration file.
1827  -h : print this help message and exit (with an error status).
1828  -r : reuse C symbols value if possible (skips costly nm extraction).
1829  -s : silent mode, only echoes questions and essential information.
1830  -D : define symbol to have some value:
1831         -D symbol         symbol gets the value 'define'
1832         -D symbol=value   symbol gets the value 'value'
1833       common used examples (see INSTALL for more info):
1834         -Duse64bitint            use 64bit integers
1835         -Duse64bitall            use 64bit integers and pointers
1836         -Dusethreads             use thread support
1837         -Dinc_version_list=none  do not include older perl trees in @INC
1838         -DEBUGGING=none          DEBUGGING options
1839         -Dcc=gcc                 choose your compiler
1840         -Dprefix=/opt/perl5      choose your destination
1841  -E : stop at the end of questions, after having produced config.sh.
1842  -K : do not use unless you know what you are doing.
1843  -O : ignored for backward compatibility
1844  -S : perform variable substitutions on all .SH files (can mix with -f)
1845  -U : undefine symbol:
1846         -U symbol    symbol gets the value 'undef'
1847         -U symbol=   symbol gets completely empty
1848       e.g.:  -Uversiononly
1849  -A : manipulate symbol after the platform specific hints have been applied:
1850         -A append:symbol=value   append value to symbol
1851         -A symbol=value          like append:, but with a separating space
1852         -A define:symbol=value   define symbol to have value
1853         -A clear:symbol          define symbol to be ''
1854         -A define:symbol         define symbol to be 'define'
1855         -A eval:symbol=value     define symbol to be eval of value
1856         -A prepend:symbol=value  prepend value to symbol
1857         -A undef:symbol          define symbol to be 'undef'
1858         -A undef:symbol=         define symbol to be ''
1859       e.g.:  -A prepend:libswanted='cl pthread '
1860              -A ccflags=-DSOME_MACRO
1861  -V : print version number and exit (with a zero status).
1862EOM
1863	exit 1
1864	;;
1865esac
1866
1867: Sanity checks
1868case "$fastread$alldone" in
1869yescont|yesexit) ;;
1870*)
1871	case "$extractsh" in
1872	true) ;;
1873	*)
1874		if test ! -t 0; then
1875			echo "Say 'sh Configure', not 'sh <Configure'"
1876			exit 1
1877		fi
1878		;;
1879	esac
1880	;;
1881esac
1882
1883exec 4>&1
1884case "$silent" in
1885true) exec 1>/dev/null;;
1886esac
1887
1888: run the defines and the undefines, if any, but leave the file out there...
1889touch optdef.sh
1890grep '\\' optdef.sh >/dev/null 2>&1
1891if test $? = 0; then
1892    echo "Configure does not support \\ in -D arguments"
1893    exit 1
1894fi
1895. ./optdef.sh
1896: create the posthint manipulation script and leave the file out there...
1897touch posthint.sh
1898
1899: set package name
1900package='perl5'
1901first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1902last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1903case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
1904ABYZ-abyz) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1905*) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1906esac
1907
1908: Some greps do not return status, grrr.
1909echo "grimblepritz" >grimble
1910if grep blurfldyick grimble >/dev/null 2>&1 ; then
1911	contains=contains
1912elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1913	contains=grep
1914else
1915	contains=contains
1916fi
1917rm -f grimble
1918: the following should work in any shell
1919case "$contains" in
1920contains*)
1921	echo " "
1922	echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1923	cat >contains <<'EOSS'
1924grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1925EOSS
1926chmod +x contains
1927esac
1928
1929: Find the path to the source tree
1930case "$src" in
1931'') case "$0" in
1932    */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
1933         case "$src" in
1934	 /*)	;;
1935	 .)	;;
1936         *)	src=`cd ../$src && pwd` ;;
1937	 esac
1938         ;;
1939    *)   src='.';;
1940    esac;;
1941esac
1942case "$src" in
1943'')	src=/
1944	rsrc=/
1945	;;
1946/*)	rsrc="$src";;
1947*)	rsrc="../$src";;
1948esac
1949if test -f $rsrc/Configure && \
1950	$contains "^package='$package'\$" $rsrc/Configure >/dev/null 2>&1
1951then
1952   : found it, so we are ok.
1953else
1954	rsrc=''
1955	for src in . .. ../.. ../../.. ../../../..; do
1956		if test -f ../$src/Configure && \
1957			$contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1958		then
1959			rsrc=../$src
1960			break
1961		fi
1962	done
1963fi
1964case "$rsrc" in
1965'')
1966	cat <<EOM >&4
1967
1968Sorry, I can't seem to locate the source dir for $package.  Please start
1969Configure with an explicit path -- i.e. /some/path/Configure.
1970
1971EOM
1972	exit 1
1973	;;
1974../.)	rsrc='..';;
1975*)
1976	echo " "
1977	echo "Sources for $package found in \"$src\"." >&4
1978	;;
1979esac
1980
1981: script used to extract .SH files with variable substitutions
1982cat >extract <<'EOS'
1983PERL_CONFIG_SH=true
1984echo "Doing variable substitutions on .SH files..."
1985if test -f MANIFEST; then
1986	set x `awk '{print $1}' < MANIFEST | grep '\.SH$'`
1987else
1988	echo "(Looking for .SH files under the source directory.)"
1989	set x `(cd "$src"; find . -name "*.SH" -print)`
1990fi
1991shift
1992case $# in
19930) set x `(cd "$src"; echo *.SH)`; shift;;
1994esac
1995if test ! -f "$src/$1"; then
1996	shift
1997fi
1998mkdir_p='
1999name=$1;
2000create="";
2001while test $name; do
2002	if test ! -d "$name"; then
2003		create="$name $create";
2004		name=`echo $name | sed -e "s|^[^/]*$||"`;
2005		name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
2006	else
2007		name="";
2008	fi;
2009done;
2010for file in $create; do
2011	mkdir $file;
2012done
2013'
2014for file in $*; do
2015	case "$src" in
2016	".")
2017		case "$file" in
2018		*/*)
2019			dir=`expr X$file : 'X\(.*\)/'`
2020			file=`expr X$file : 'X.*/\(.*\)'`
2021			(cd "$dir" && . ./$file)
2022			;;
2023		*)
2024			. ./$file
2025			;;
2026		esac
2027		;;
2028	*)
2029		case "$file" in
2030		*/*)
2031			dir=`expr X$file : 'X\(.*\)/'`
2032			file=`expr X$file : 'X.*/\(.*\)'`
2033			(set x $dir; shift; eval $mkdir_p)
2034			sh <"$src/$dir/$file"
2035			;;
2036		*)
2037			sh <"$src/$file"
2038			;;
2039		esac
2040		;;
2041	esac
2042done
2043if test -f "$src/config_h.SH"; then
2044	if test ! -f config.h; then
2045	: oops, they left it out of MANIFEST, probably, so do it anyway.
2046	. "$src/config_h.SH"
2047	fi
2048fi
2049EOS
2050
2051: extract files and exit if asked to do so
2052case "$extractsh" in
2053true)
2054	case "$realsilent" in
2055	true) ;;
2056	*) exec 1>&4;;
2057	esac
2058	case "$config_sh" in
2059	'') config_sh='config.sh';;
2060	esac
2061	echo " "
2062	echo "Fetching answers from $config_sh..."
2063	cd ..
2064	. $config_sh
2065	. UU/optdef.sh
2066	echo " "
2067	. UU/extract
2068	rm -rf UU
2069	echo "Extraction done."
2070	exit 0
2071	;;
2072esac
2073
2074: Eunice requires " " instead of "", can you believe it
2075echo " "
2076: Here we go...
2077echo "Beginning of configuration questions for $package."
2078
2079trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
2080
2081: first determine how to suppress newline on echo command
2082echo " "
2083echo "Checking echo to see how to suppress newlines..."
2084(echo "hi there\c" ; echo " ") >.echotmp
2085if $contains c .echotmp >/dev/null 2>&1 ; then
2086	echo "...using -n."
2087	n='-n'
2088	c=''
2089else
2090	cat <<'EOM'
2091...using \c
2092EOM
2093	n=''
2094	c='\c'
2095fi
2096echo $n "The star should be here-->$c"
2097echo '*'
2098rm -f .echotmp
2099
2100: Now test for existence of everything in MANIFEST
2101echo " "
2102if test -f "$rsrc/MANIFEST"; then
2103	echo "First let's make sure your kit is complete.  Checking..." >&4
2104	awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
2105		(split -l 50 2>/dev/null || split -50)
2106	rm -f missing
2107	tmppwd=`pwd`
2108	for filelist in x??; do
2109		(cd "$rsrc"; ls `cat "$tmppwd/$filelist"` \
2110			>/dev/null 2>>"$tmppwd/missing")
2111	done
2112	if test -s missing; then
2113		cat missing >&4
2114		cat >&4 <<'EOM'
2115
2116THIS PACKAGE SEEMS TO BE INCOMPLETE.
2117
2118You have the option of continuing the configuration process, despite the
2119distinct possibility that your kit is damaged, by typing 'y'es.  If you
2120do, don't blame me if something goes wrong.  I advise you to type 'n'o
2121and contact the author (https://github.com/Perl/perl5/issues).
2122
2123EOM
2124		echo $n "Continue? [n] $c" >&4
2125		read ans
2126		case "$ans" in
2127		y*)
2128			echo "Continuing..." >&4
2129			rm -f missing
2130			;;
2131		*)
2132			echo "ABORTING..." >&4
2133			kill $$
2134			;;
2135		esac
2136	else
2137		echo "Looks good..."
2138	fi
2139else
2140	echo "There is no MANIFEST file.  I hope your kit is complete !"
2141fi
2142rm -f missing x??
2143
2144: Find the appropriate value for a newline for tr
2145if test -n "$DJGPP"; then
2146       trnl='\012'
2147fi
2148if test X"$trnl" = X; then
2149	case "`echo foo | tr '\n' x 2>/dev/null`" in
2150	foox) trnl='\n' ;;
2151	esac
2152fi
2153if test X"$trnl" = X; then
2154	case "`echo foo | tr '\012' x 2>/dev/null`" in
2155	foox) trnl='\012' ;;
2156	esac
2157fi
2158if test X"$trnl" = X; then
2159       case "`echo foo | tr '\r\n' xy 2>/dev/null`" in
2160       fooxy) trnl='\n\r' ;;
2161       esac
2162fi
2163if test X"$trnl" = X; then
2164	cat <<EOM >&2
2165
2166$me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
2167
2168EOM
2169	exit 1
2170fi
2171
2172: compute the number of columns on the terminal for proper question formatting
2173case "$COLUMNS" in
2174'') COLUMNS='80';;
2175esac
2176
2177: set up the echo used in my read
2178myecho="case \"\$xxxm\" in
2179'') echo $n \"\$rp $c\" >&4;;
2180*) case \"\$rp\" in
2181	'') echo $n \"[\$xxxm] $c\";;
2182	*)
2183		if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
2184			echo \"\$rp\" >&4
2185			echo $n \"[\$xxxm] $c\" >&4
2186		else
2187			echo $n \"\$rp [\$xxxm] $c\" >&4
2188		fi
2189		;;
2190	esac;;
2191esac"
2192
2193: now set up to do reads with possible shell escape and default assignment
2194cat <<EOSC >myread
2195$startsh
2196xxxm=\$dflt
2197$myecho
2198ans='!'
2199case "\$fastread" in
2200yes) case "\$dflt" in
2201	'') ;;
2202	*) ans='';
2203		case "\$silent-\$rp" in
2204		true-) ;;
2205		*) echo " " >&4;;
2206		esac;;
2207	esac;;
2208*) case "\$silent" in
2209	true) case "\$rp" in
2210		'') ans='';;
2211		esac;;
2212	esac;;
2213esac
2214while expr "X\$ans" : "X!" >/dev/null; do
2215	read answ
2216	set x \$xxxm
2217	shift
2218	aok=''; eval "ans=\\"\$answ\\"" && aok=y
2219	case  "\$answ" in
2220	"!")
2221		sh 1>&4
2222		echo " "
2223		$myecho
2224		;;
2225	!*)
2226		set x \`expr "X\$ans" : "X!\(.*\)\$"\`
2227		shift
2228		sh 1>&4 -c "\$*"
2229		echo " "
2230		$myecho
2231		;;
2232	"\$ans")
2233		case "\$ans" in
2234		\\&*)
2235			set x \`expr "X\$ans" : "X&\(.*\)\$"\`
2236			shift
2237			case "\$1" in
2238			-d)
2239				fastread=yes
2240				echo "(OK, I'll run with -d after this question.)" >&4
2241				;;
2242			-*)
2243				echo "*** Sorry, \$1 not supported yet." >&4
2244				;;
2245			esac
2246			$myecho
2247			ans=!
2248			;;
2249		esac;;
2250	*)
2251		case "\$aok" in
2252		y)
2253			echo "*** Substitution done -- please confirm."
2254			xxxm="\$ans"
2255			ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
2256			xxxm="\$ans"
2257			ans=!
2258			;;
2259		*)
2260			echo "*** Error -- try again."
2261			ans=!
2262			;;
2263		esac
2264		$myecho
2265		;;
2266	esac
2267	case "\$ans\$xxxm\$nostick" in
2268	'')
2269		ans=!
2270		$myecho
2271		;;
2272	esac
2273done
2274case "\$ans" in
2275'') ans="\$xxxm";;
2276esac
2277EOSC
2278
2279: create .config dir to save info across Configure sessions
2280test -d ../.config || mkdir ../.config
2281cat >../.config/README <<EOF
2282This directory created by Configure to save information that should
2283persist across sessions for $package.
2284
2285You may safely delete it if you wish.
2286EOF
2287
2288: See if we are using a devel version and want that
2289xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
2290case "$usedevel" in
2291$define|true|[yY]*)
2292    usedevel="$define" ;;
2293*) case "$xversion" in
2294   *[13579])
2295	cat >&4 <<EOH
2296*** WHOA THERE!!! ***
2297
2298    This is an UNSTABLE DEVELOPMENT release.
2299    The version of this $package distribution is $xversion, that is, odd,
2300    (as opposed to even) and that signifies a development release.
2301    If you want a maintenance release, you want an even-numbered version.
2302
2303    Do ***NOT*** install this into production use.
2304    Data corruption and crashes are possible.
2305
2306    It is most seriously suggested that you do not continue any further
2307    unless you want to help in developing and debugging Perl.
2308
2309    If you *still* want to build perl, you can answer 'y' now,
2310    or pass -Dusedevel to Configure.
2311
2312EOH
2313	rp='Do you really want to continue?'
2314	dflt='n'
2315	. ./myread
2316	case "$ans" in
2317	[yY]) echo >&4 "Okay, continuing."
2318	      usedevel="$define" ;;
2319	*) echo >&4 "Okay, bye."
2320	   exit 1
2321	   ;;
2322	esac
2323	;;
2324    esac
2325    usedevel="$undef"
2326    ;;
2327esac
2328case "$usedevel" in
2329$define|true|[yY]*)
2330	case "$versiononly" in
2331	'') versiononly="$define" ;;
2332	esac
2333	case "$installusrbinperl" in
2334	'') installusrbinperl="$undef" ;;
2335	esac
2336	;;
2337esac
2338
2339: general instructions
2340needman=true
2341firsttime=true
2342user=`(logname) 2>/dev/null`
2343case "$user" in
2344'') user=`whoami 2>&1`;;
2345esac
2346if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
2347	firsttime=false
2348	echo " "
2349	rp='Would you like to see the instructions?'
2350	dflt=n
2351	. ./myread
2352	case "$ans" in
2353	[yY]*) ;;
2354	*) needman=false;;
2355	esac
2356fi
2357if $needman; then
2358	cat <<EOH
2359
2360This installation shell script will examine your system and ask you questions
2361to determine how the perl5 package should be installed. If you get
2362stuck on a question, you may use a ! shell escape to start a subshell or
2363execute a command.  Many of the questions will have default answers in square
2364brackets; typing carriage return will give you the default.
2365
2366On some of the questions which ask for file or directory names you are allowed
2367to use the ~name construct to specify the login directory belonging to "name",
2368even if you don't have a shell which knows about that.  Questions where this is
2369allowed will be marked "(~name ok)".
2370
2371EOH
2372	rp=''
2373	dflt='Type carriage return to continue'
2374	. ./myread
2375	cat <<'EOH'
2376
2377The prompter used in this script allows you to use shell variables and
2378backticks in your answers.  You may use $1, $2, etc...  to refer to the words
2379in the default answer, as if the default line was a set of arguments given to a
2380script shell.  This means you may also use $* to repeat the whole default line,
2381so you do not have to re-type everything to add something to the default.
2382
2383Every time there is a substitution, you will have to confirm.  If there is an
2384error (e.g. an unmatched backtick), the default answer will remain unchanged
2385and you will be prompted again.
2386
2387If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
2388the questions and use the computed defaults (or the previous answers if there
2389was already a config.sh file). Type 'Configure -h' for a list of options.
2390You may also start interactively and then answer '& -d' at any prompt to turn
2391on the non-interactive behaviour for the remainder of the execution.
2392
2393EOH
2394	. ./myread
2395	cat <<EOH
2396
2397Much effort has been expended to ensure that this shell script will run on any
2398Unix system.  If despite that it blows up on yours, your best bet is to edit
2399Configure and run it again.  If you can't run Configure for some reason,
2400you'll have to generate a config.sh file by hand.  Whatever problems you
2401have, let me (https://github.com/Perl/perl5/issues) know how I blew it.
2402
2403This installation script affects things in two ways:
2404
24051) it may do direct variable substitutions on some of the files included
2406   in this kit.
24072) it builds a config.h file for inclusion in C programs.  You may edit
2408   any of these files as the need arises after running this script.
2409
2410If you make a mistake on a question, there is no easy way to back up to it
2411currently.  The easiest thing to do is to edit config.sh and rerun all the SH
2412files.  Configure will offer to let you do this before it runs the SH files.
2413
2414EOH
2415	dflt='Type carriage return to continue'
2416	. ./myread
2417	case "$firsttime" in
2418	true) echo $user >>../.config/instruct;;
2419	esac
2420fi
2421
2422: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
2423: This is primarily meant for cross-compile environments, and may fail to be useful in other cases
2424if test "X$sysroot" = X; then
2425    sysroot=""
2426else
2427    case "$cc" in
2428	*gcc*|*g++*)
2429	    echo "Using $sysroot to find your headers and libraries, adding to ccflags"
2430	    # _sysroot is used in places where we need --sysroot=foo
2431	    # but using the rest of the flags could cause issues.
2432	    _sysroot="--sysroot=$sysroot";
2433	    case "$ccflags" in
2434		*sysroot*) ;;
2435		'undef'|*)
2436		ccflags="$ccflags $_sysroot"
2437	    esac
2438	    case "$ldflags" in
2439		*sysroot*) ;;
2440		'undef'|*)
2441		ldflags="$ldflags $_sysroot"
2442	    esac
2443	    case "$cppflags" in
2444		*sysroot*) ;;
2445		'undef'|*)
2446		cppflags="$cppflags $_sysroot"
2447	    esac
2448	    # lddlflags updated below in lddlflags section;
2449	    # same with cccdlflags
2450	    ;;
2451    esac
2452
2453    # Adjust some defaults to also use $sysroot
2454    for var in xlibpth loclibpth locincpth glibpth; do
2455	eval xxx=\$$var
2456	eval $var=''
2457	for path in $xxx; do
2458	    eval $var=\"\$$var $sysroot$path\"
2459	done
2460    done
2461
2462fi
2463
2464: find out where common programs are
2465echo " "
2466echo "Locating common programs..." >&4
2467cat <<EOSC >loc
2468$startsh
2469case \$# in
24700) exit 1;;
2471esac
2472thing=\$1
2473shift
2474dflt=\$1
2475shift
2476for dir in \$*; do
2477	case "\$thing" in
2478	.)
2479	if test -d \$dir/\$thing; then
2480		echo \$dir
2481		exit 0
2482	fi
2483	;;
2484	*)
2485	for thisthing in \$dir/\$thing; do
2486		: just loop through to pick last item
2487	done
2488	if test -f \$thisthing; then
2489		echo \$thisthing
2490		exit 0
2491	elif test "X$_exe" != X -a -f \$thisthing$_exe; then
2492		echo \$thisthing
2493		exit 0
2494	elif test -f \$dir/\$thing.exe; then
2495		if test -n "$DJGPP"; then
2496			echo \$dir/\$thing.exe
2497		elif test "$eunicefix" != ":"; then
2498			: on Eunice apparently
2499			echo \$dir/\$thing
2500		fi
2501		exit 0
2502	fi
2503	;;
2504	esac
2505done
2506echo \$dflt
2507exit 1
2508EOSC
2509chmod +x loc
2510$eunicefix loc
2511loclist="
2512awk
2513cat
2514chmod
2515comm
2516cp
2517echo
2518expr
2519grep
2520ls
2521mkdir
2522rm
2523sed
2524sort
2525touch
2526tr
2527uniq
2528"
2529trylist="
2530ar
2531bison
2532byacc
2533cpp
2534csh
2535date
2536egrep
2537gmake
2538gzip
2539less
2540ln
2541make
2542more
2543nm
2544nroff
2545perl
2546pg
2547test
2548uname
2549zip
2550"
2551pth=`echo $PATH | sed -e "s/$p_/ /g"`
2552pth="$pth $sysroot/lib $sysroot/usr/lib"
2553for file in $loclist; do
2554	eval xxx=\$$file
2555	case "$xxx" in
2556	/*|?:[\\/]*)
2557		if test -f "$xxx"; then
2558			: ok
2559		else
2560			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2561			xxx=`./loc $file $file $pth`
2562		fi
2563		;;
2564	'') xxx=`./loc $file $file $pth`;;
2565	*) xxx=`./loc $xxx $xxx $pth`;;
2566	esac
2567	eval $file=$xxx$_exe
2568	eval _$file=$xxx
2569	case "$xxx" in
2570	/*)
2571		echo $file is in $xxx.
2572		;;
2573	?:[\\/]*)
2574		echo $file is in $xxx.
2575		;;
2576	*)
2577		echo "I don't know where '$file' is, and my life depends on it." >&4
2578		echo "Go find a public domain implementation or fix your PATH setting!" >&4
2579		exit 1
2580		;;
2581	esac
2582done
2583echo " "
2584echo "Don't worry if any of the following aren't found..."
2585say=offhand
2586for file in $trylist; do
2587	eval xxx=\$$file
2588	case "$xxx" in
2589	/*|?:[\\/]*)
2590		if test -f "$xxx"; then
2591			: ok
2592		else
2593			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2594			xxx=`./loc $file $file $pth`
2595		fi
2596		;;
2597	'') xxx=`./loc $file $file $pth`;;
2598	*) xxx=`./loc $xxx $xxx $pth`;;
2599	esac
2600	eval $file=$xxx$_exe
2601	eval _$file=$xxx
2602	case "$xxx" in
2603	/*)
2604		echo $file is in $xxx.
2605		;;
2606	?:[\\/]*)
2607		echo $file is in $xxx.
2608		;;
2609	*)
2610		echo "I don't see $file out there, $say."
2611		say=either
2612		;;
2613	esac
2614done
2615case "$egrep" in
2616egrep)
2617	echo "Substituting grep for egrep."
2618	egrep=$grep
2619	_egrep=$grep
2620	;;
2621esac
2622case "$less" in
2623'')	;;
2624*)	if $less -R </dev/null >/dev/null 2>&1; then
2625	       echo "Substituting less -R for less."
2626	       less="$less -R"
2627	       _less=$less
2628	fi
2629	;;
2630esac
2631case "$ln" in
2632ln)
2633	echo "Substituting cp for ln."
2634	ln=$cp
2635	_ln=$cp
2636	;;
2637esac
2638case "$make" in
2639make)
2640	case "$gmake" in
2641	gmake)
2642	echo "I can't find make or gmake, and my life depends on it." >&4
2643	echo "Go find a public domain implementation or fix your PATH setting!" >&4
2644	exit 1
2645	;;
2646	esac
2647	;;
2648esac
2649case "$gmake" in
2650gmake)	;;
2651*)	# We can't have osname yet.
2652	if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
2653		# Assume that gmake, if found, is definitely GNU make
2654		# and prefer it over the system make.
2655		echo "Substituting gmake for make."
2656		make=$gmake
2657		_make=$gmake
2658	fi
2659	;;
2660esac
2661case "$test" in
2662test)
2663	echo "Hopefully test is built into your sh."
2664	;;
2665*)
2666	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
2667		echo "Using the test built into your sh."
2668		test=test
2669		_test=test
2670	fi
2671	;;
2672esac
2673case "$echo" in
2674echo)
2675	echo "Hopefully echo is built into your sh."
2676	;;
2677'') ;;
2678*)
2679	echo " "
2680echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
2681	$echo $n "hi there$c" >foo1
2682	echo $n "hi there$c" >foo2
2683	if cmp foo1 foo2 >/dev/null 2>&1; then
2684		echo "They are compatible.  In fact, they may be identical."
2685	else
2686		case "$n" in
2687		'-n') n='' c='\c';;
2688		*) n='-n' c='';;
2689		esac
2690		cat <<FOO
2691They are not compatible!  You are probably running ksh on a non-USG system.
2692I'll have to use $echo instead of the builtin, since Bourne shell doesn't
2693have echo built in and we may have to run some Bourne shell scripts.  That
2694means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
2695
2696FOO
2697		$echo $n "The star should be here-->$c"
2698		$echo "*"
2699	fi
2700	$rm -f foo1 foo2
2701	;;
2702esac
2703
2704# This question was auctioned at YAPC::Europe-2007 in Vienna
2705# I never promised you could answer it. I only auctioned the question.
2706cat <<FOO
2707The following message is sponsored by
2708
2709  Dresden.pm<--The stars should be here.
2710
2711Dear Perl user, system administrator or package
2712maintainer, the Perl community sends greetings to
2713you. Do you (emblematical) greet back [Y/n]? n
2714
2715FOO
2716
2717: Check what type of C compiler we use
2718cat <<EOS >trygcc
2719$startsh
2720EOS
2721cat <<'EOSC' >>trygcc
2722case "$cc" in
2723'') ;;
2724*)  $rm -f try try.*
2725    $cat >try.c <<EOM
2726int main(int argc, char *argv[]) {
2727  return 0;
2728}
2729EOM
2730    if $cc -o try $ccflags $ldflags try.c; then
2731       :
2732    else
2733        echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2734        despair=yes
2735        trygcc=yes
2736        case "$cc" in
2737        *gcc*) trygcc=no ;;
2738        esac
2739	# Skip this test because it gives a false match on output like:
2740	#    ./trygcc: line 23: cc: command not found
2741        # case "`$cc -v -c try.c 2>&1`" in
2742        # *gcc*) trygcc=no ;;
2743        # esac
2744        if $test X"$trygcc" = Xyes; then
2745            if gcc -o try -c try.c; then
2746                echo " "
2747                echo "You seem to have a working gcc, though." >&4
2748		# Switching compilers may undo the work of hints files.
2749		# The most common problem is -D_REENTRANT for threads.
2750		# This heuristic catches that case, but gets false positives
2751		# if -Dusethreads was not actually specified.  Better to
2752		# bail out here with a useful message than fail
2753		# mysteriously later. Should we perhaps just try to
2754		# re-invoke Configure -Dcc=gcc config_args ?
2755		if $test -f usethreads.cbu; then
2756			$cat >&4 <<EOM
2757
2758*** However, any setting of the C compiler flags (e.g. for thread support)
2759*** will be lost.  It may be necessary for you to restart Configure and
2760*** add -Dcc=gcc to your Configure command line.
2761
2762EOM
2763			rp="Would you like to go ahead and try gcc anyway?"
2764			dflt=n
2765		else
2766			rp="Would you like to use it?"
2767			dflt=y
2768		fi
2769                if $test -f myread; then
2770                    . ./myread
2771                else
2772                    if $test -f UU/myread; then
2773                        . ./UU/myread
2774                    else
2775                        echo "Cannot find myread, sorry.  Aborting." >&2
2776                        exit 1
2777                    fi
2778                fi
2779                case "$ans" in
2780                [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
2781                esac
2782            fi
2783        fi
2784    fi
2785    $rm -f try try.*
2786    ;;
2787esac
2788EOSC
2789
2790cat <<EOS >checkcc
2791$startsh
2792EOS
2793cat <<'EOSC' >>checkcc
2794case "$cc" in
2795'') ;;
2796*)  $rm -f try try.*
2797    $cat >try.c <<EOM
2798int main(int argc, char *argv[]) {
2799  return 0;
2800}
2801EOM
2802    if $cc -o try $ccflags $ldflags try.c; then
2803       :
2804    else
2805        if $test X"$despair" = Xyes; then
2806           echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2807        fi
2808        $cat >&4 <<EOM
2809You need to find a working C compiler.
2810Either (purchase and) install the C compiler supplied by your OS vendor,
2811or for a free C compiler try http://gcc.gnu.org/
2812I cannot continue any further, aborting.
2813EOM
2814        exit 1
2815    fi
2816    $rm -f try try.*
2817    ;;
2818esac
2819EOSC
2820
2821: determine whether symbolic links are supported
2822echo " "
2823$touch blurfl
2824if $ln -s blurfl sym > /dev/null 2>&1 ; then
2825	echo "Symbolic links are supported." >&4
2826	lns="$ln -s"
2827else
2828	echo "Symbolic links are NOT supported." >&4
2829	lns="$ln"
2830fi
2831$rm -f blurfl sym
2832
2833: determine whether symbolic links are supported
2834echo " "
2835case "$lns" in
2836*"ln"*" -s")
2837	echo "Checking how to test for symbolic links..." >&4
2838	$lns blurfl sym
2839	if $test "X$issymlink" = X; then
2840		case "$newsh" in
2841		'') sh     -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2842		*)  $newsh -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2843		esac
2844		if test $? = 0; then
2845			issymlink="test -h"
2846		else
2847			echo "Your builtin 'test -h' may be broken." >&4
2848			case "$test" in
2849			/*)	;;
2850			*)	pth=`echo $PATH | sed -e "s/$p_/ /g"`
2851				for p in $pth
2852				do
2853					if test -f "$p/$test"; then
2854						test="$p/$test"
2855						break
2856					fi
2857				done
2858				;;
2859			esac
2860			case "$test" in
2861			/*)
2862				echo "Trying external '$test -h'." >&4
2863				issymlink="$test -h"
2864				if $test ! -h sym >/dev/null 2>&1; then
2865					echo "External '$test -h' is broken, too." >&4
2866					issymlink=''
2867				fi
2868				;;
2869			*)	issymlink='' ;;
2870			esac
2871		fi
2872	fi
2873	if $test "X$issymlink" = X; then
2874		if $test -L sym 2>/dev/null; then
2875			issymlink="$test -L"
2876			echo "The builtin '$test -L' worked." >&4
2877		fi
2878	fi
2879	if $test "X$issymlink" != X; then
2880		echo "You can test for symbolic links with '$issymlink'." >&4
2881	else
2882		echo "I do not know how you can test for symbolic links." >&4
2883	fi
2884	$rm -f blurfl sym
2885	;;
2886*)	echo "No symbolic links, so not testing for their testing..." >&4
2887	;;
2888esac
2889
2890: Make symlinks util
2891case "$mksymlinks" in
2892$define|true|[yY]*)
2893	case "$src" in
2894	''|'.')	echo "Cannot create symlinks in the original directory." >&4
2895		exit 1
2896		;;
2897	*)	case "$lns:$issymlink" in
2898		*"ln"*" -s:"*"test -"?)
2899			echo "Creating the symbolic links..." >&4
2900			cd ..
2901			awk '{print $1}' $src/MANIFEST | sed -e 's:/\([^/]*\)$: \1:' |
2902			awk 'NF == 1 {
2903				dir=".";
2904				file=$1 "";
2905			     }
2906			     NF == 2 {
2907				dir=$1 "";
2908				file=$2 "";
2909			     }
2910			     {
2911				 print "# dir = ", dir, "file = ", file
2912				 mf[dir] = mf[dir]" "source"/"dir"/"file;
2913			     } END {
2914				 for (d in mf) {
2915				     if (d != ".") { print("mkdir -p "d) }
2916				     print("ln -sf "mf[d]" "d);
2917				 }
2918			     }' source="$src" > UU/mksymlinks.$$
2919			sh UU/mksymlinks.$$
2920			rm UU/mksymlinks.$$
2921			# Sanity check 1.
2922			if test ! -d t/base; then
2923				echo "Failed to create the subdirectories.  Aborting." >&4
2924				exit 1
2925			fi
2926			# Sanity check 2.
2927			if test ! -f t/base/lex.t; then
2928				echo "Failed to create the symlinks (t/base/lex.t missing).  Aborting." >&4
2929				exit 1
2930			fi
2931			if test ! -f win32/win32.c; then
2932				echo "Failed to create the symlinks (win32/win32.c missing).  Aborting." >&4
2933				exit 1
2934			fi
2935			cd UU
2936			;;
2937		*)	echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
2938			;;
2939		esac
2940		;;
2941	esac
2942	;;
2943esac
2944
2945: Check for Cross-Compilation
2946if $test "X$targethost" = "X"; then
2947    targethost=""
2948fi
2949if $test "X$targetenv" = "X"; then
2950    targetenv=""
2951fi
2952case "$usecrosscompile" in
2953$define|true|[yY]*)
2954	$echo "Cross-compiling..."
2955	croak=''
2956	case "$cc" in
2957	*-gcc*|*-g++*) # A cross-compiling gcc, probably.
2958	    # arm-linux-androideabi-gcc  -> arm-linux-androideabi
2959	    # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
2960	    targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
2961	    ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
2962	    # leave out ld, choosing it is more complex
2963	    nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
2964	    ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
2965	    # We are in a weird spot. Just before us, some values
2966	    # were 'saved', to be restored after the hints are
2967	    # run.  This means that the changes we made to ar,
2968	    # nm and ranlib will get reverted.
2969	    # To avoid that, we hijack the saving mechanism and
2970	    # have it save our new values.
2971	    for file in ar nm ranlib; do
2972		eval xxx=\$$file
2973		eval $file=$xxx$_exe
2974		eval _$file=$xxx
2975	    done
2976	;;
2977	esac
2978	case "$targetarch" in
2979	'') echo "Targetarch not defined." >&4; croak=y ;;
2980	*)  echo "Using targetarch $targetarch." >&4 ;;
2981	esac
2982	case "$targethost" in
2983	'') echo "Targethost not defined." >&4; croak=n ;;
2984	*)  echo "Using targethost $targethost." >&4
2985	esac
2986	locincpth=' '
2987	loclibpth=' '
2988	case "$croak" in
2989	y) echo "Cannot continue, aborting." >&4; exit 1 ;;
2990	esac
2991    : compile a host miniperl and generate_uudmap, unless we got passed them
2992    if $test "X$hostperl" = X; then
2993      echo "Building host miniperl and generate_uudmap binaries" >&4
2994      before_host=`pwd`
2995      cd ..
2996      cd $src
2997      src=`pwd`
2998      rm -rf $src/host
2999      mkdir $src/host
3000      cd $src/host
3001      $src/Configure -des -Dusedevel -Dmksymlinks
3002      $make miniperl
3003      case "$hostgenerate" in
3004      '') $make generate_uudmap
3005          hostgenerate=$src/host/generate_uudmap
3006          ;;
3007       "$undef") hostgenerate=''
3008          ;;
3009      esac
3010      hostperl=$src/host/miniperl
3011      cd $before_host
3012    fi
3013    hostosname=`$hostperl -le 'print $^O'`
3014    ;;
3015*)
3016    usecrosscompile="$undef"
3017    ;;
3018esac
3019
3020: Define -Dtargethost=somecomputer to run compiled tests on another machine
3021case "$targethost" in
3022    '') echo "Checking for cross-compile" >&4
3023    case "$usecrosscompile$multiarch" in
3024       *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
3025         if [ -f Makefile ]; then
3026           echo " "
3027           echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
3028         else
3029           echo "Configure done."
3030         fi
3031       exit 0
3032       ;;
3033     *) echo "No targethost for running compiler tests against defined, running locally" >&4
3034        run=''
3035        to=:
3036        from=:
3037        ;;
3038    esac
3039    ;;
3040    *) echo "Using targethost $targethost." >&4
3041	case "$src" in
3042	/*) run=$src/Cross/run
3043	    targetmkdir=$src/Cross/mkdir
3044	    to=$src/Cross/to
3045	    from=$src/Cross/from
3046	    ;;
3047	*)  pwd=`$test -f ../Configure & cd ..; pwd`
3048	    run=$pwd/Cross/run
3049	    targetmkdir=$pwd/Cross/mkdir
3050	    to=$pwd/Cross/to
3051	    from=$pwd/Cross/from
3052	    ;;
3053	esac
3054	case "$targetrun" in
3055	'') targetrun=ssh ;;
3056	esac
3057	case "$targetto" in
3058	'') targetto=scp ;;
3059	esac
3060	case "$targetfrom" in
3061	'') targetfrom=scp ;;
3062	esac
3063	run=$run-$targetrun
3064	to=$to-$targetto
3065	from=$from-$targetfrom
3066	case "$targetdir" in
3067	'')  targetdir=/tmp
3068	     echo "Guessing targetdir $targetdir." >&4
3069	     ;;
3070	esac
3071	case "$targetuser" in
3072	'')  targetuser=root
3073	     echo "Guessing targetuser $targetuser." >&4
3074	     ;;
3075	esac
3076	case "$targetport" in
3077	'')  targetport=22
3078	     echo "Guessing targetport $targetport." >&4
3079	     ;;
3080	esac
3081	case "$targetfrom" in
3082	scp)	q=-q ;;
3083	*)	q='' ;;
3084	esac
3085	case "$targetrun" in
3086	ssh|rsh)
3087	    cat >$run <<EOF
3088#!/bin/sh
3089env=''
3090case "\$1" in
3091-cwd)
3092  shift
3093  cwd=\$1
3094  shift
3095  ;;
3096esac
3097case "\$1" in
3098-env)
3099  shift
3100  env=\$1
3101  shift
3102  ;;
3103esac
3104case "\$cwd" in
3105'') cwd=$targetdir ;;
3106esac
3107exe=\$1
3108shift
3109$to \$exe
3110$targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
3111EOF
3112	    ;;
3113	adb)
3114	    $touch $run
3115	    ;;
3116	*)  echo "Unknown targetrun '$targetrun'" >&4
3117	    exit 1
3118	    ;;
3119	esac
3120	case "$targetmkdir" in
3121	*/Cross/mkdir)
3122	    cat >$targetmkdir <<EOF
3123#!/bin/sh
3124$targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
3125EOF
3126	    $chmod a+rx $targetmkdir
3127	    ;;
3128	*)  echo "Unknown targetmkdir '$targetmkdir'" >&4
3129	    exit 1
3130	    ;;
3131	esac
3132	case "$targetto" in
3133	scp|rcp)
3134	    cat >$to <<EOF
3135#!/bin/sh
3136for f in \$@
3137do
3138  case "\$f" in
3139  /*)
3140    $targetmkdir \`dirname \$f\`
3141    $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f           2>/dev/null  || exit 1
3142    ;;
3143  *)
3144    $targetmkdir $targetdir/\`dirname \$f\`
3145    $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
3146    ;;
3147  esac
3148done
3149exit 0
3150EOF
3151	    ;;
3152	cp) cat >$to <<EOF
3153#!/bin/sh
3154for f in \$@
3155do
3156  case "\$f" in
3157  /*)
3158    $mkdir -p $targetdir/\`dirname \$f\`
3159    $cp \$f $targetdir/\$f || exit 1
3160    ;;
3161  *)
3162    $targetmkdir $targetdir/\`dirname \$f\`
3163    $cp \$f $targetdir/\$f || exit 1
3164    ;;
3165  esac
3166done
3167exit 0
3168EOF
3169	    ;;
3170	*)  echo "Unknown targetto '$targetto'" >&4
3171	    exit 1
3172	    ;;
3173	esac
3174	case "$targetfrom" in
3175	scp|rcp)
3176	  cat >$from <<EOF
3177#!/bin/sh
3178for f in \$@
3179do
3180  $rm -f \$f
3181  $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
3182done
3183exit 0
3184EOF
3185	    ;;
3186	cp) cat >$from <<EOF
3187#!/bin/sh
3188for f in \$@
3189do
3190  $rm -f \$f
3191  cp $targetdir/\$f . || exit 1
3192done
3193exit 0
3194EOF
3195	    ;;
3196	*)  echo "Unknown targetfrom '$targetfrom'" >&4
3197	    exit 1
3198	    ;;
3199	esac
3200	if $test ! -f $run; then
3201	    echo "Target 'run' script '$run' not found." >&4
3202	else
3203	    $chmod a+rx $run
3204	fi
3205	if $test ! -f $to; then
3206	    echo "Target 'to' script '$to' not found." >&4
3207	else
3208	    $chmod a+rx $to
3209	fi
3210	if $test ! -f $from; then
3211	    echo "Target 'from' script '$from' not found." >&4
3212	else
3213	    $chmod a+rx $from
3214	fi
3215	if $test ! -f $run -o ! -f $to -o ! -f $from; then
3216	    exit 1
3217	fi
3218	cat >&4 <<EOF
3219Using '$run' for remote execution,
3220and '$from' and '$to'
3221for remote file transfer.
3222EOF
3223	;;
3224*)	run=''
3225	to=:
3226	from=:
3227	usecrosscompile="$undef"
3228	targetarch=''
3229	;;
3230esac
3231
3232: see whether [:lower:] and [:upper:] are supported character classes
3233echo " "
3234case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | $tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
3235ABYZ-abyz)
3236	echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
3237	up='[:upper:]'
3238	low='[:lower:]'
3239	;;
3240*)	# There is a discontinuity in EBCDIC between 'R' and 'S'
3241	# (0xd9 and 0xe2), therefore that is a nice testing point.
3242	if test "X$up" = X -o "X$low" = X; then
3243	    case "`echo RS | $tr '[R-S]' '[r-s]' 2>/dev/null`" in
3244	    rs) up='[A-Z]'
3245		low='[a-z]'
3246		;;
3247	    esac
3248	fi
3249	if test "X$up" = X -o "X$low" = X; then
3250	    case "`echo RS | $tr R-S r-s 2>/dev/null`" in
3251	    rs) up='A-Z'
3252		low='a-z'
3253		;;
3254	    esac
3255	fi
3256	if test "X$up" = X -o "X$low" = X; then
3257	    case "`echo RS | od -x 2>/dev/null`" in
3258	    *D9E2*|*d9e2*)
3259		echo "Hey, this might be EBCDIC." >&4
3260		if test "X$up" = X -o "X$low" = X; then
3261		    case "`echo RS | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
3262		    rs) up='[A-IJ-RS-Z]'
3263			low='[a-ij-rs-z]'
3264			;;
3265		    esac
3266		fi
3267		if test "X$up" = X -o "X$low" = X; then
3268		    case "`echo RS | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
3269		    rs) up='A-IJ-RS-Z'
3270			low='a-ij-rs-z'
3271			;;
3272		    esac
3273		fi
3274		;;
3275	    esac
3276	fi
3277esac
3278case "`echo RS | $tr \"$up\" \"$low\" 2>/dev/null`" in
3279rs)
3280    echo "Using $up and $low to convert case." >&4
3281    ;;
3282*)
3283    echo "I don't know how to translate letters from upper to lower case." >&4
3284    echo "Your tr is not acting any way I know of." >&4
3285    exit 1
3286    ;;
3287esac
3288: set up the translation script tr, must be called with ./tr of course
3289cat >tr <<EOSC
3290$startsh
3291case "\$1\$2" in
3292'[A-Z][a-z]') exec $tr '$up' '$low';;
3293'[a-z][A-Z]') exec $tr '$low' '$up';;
3294esac
3295exec $tr "\$@"
3296EOSC
3297chmod +x tr
3298$eunicefix tr
3299
3300: Try to determine whether config.sh was made on this system
3301case "$config_sh" in
3302'')
3303myuname=`$uname -a 2>/dev/null`
3304$test -z "$myuname" && myuname=`hostname 2>/dev/null`
3305# Downcase everything to avoid ambiguity.
3306# Remove slashes and single quotes so we can use parts of this in
3307# directory and file names.
3308# Remove newlines so myuname is sane to use elsewhere.
3309# tr '[A-Z]' '[a-z]' would not work in EBCDIC
3310# because the A-Z/a-z are not consecutive.
3311myuname=`echo $myuname | $sed -e "s,['/],,g" | \
3312	./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
3313newmyuname="$myuname"
3314dflt=n
3315case "$knowitall" in
3316'')
3317	if test -f ../config.sh; then
3318		if $contains myuname= ../config.sh >/dev/null 2>&1; then
3319			eval "`grep myuname= ../config.sh`"
3320		fi
3321		if test "X$myuname" = "X$newmyuname"; then
3322			dflt=y
3323		fi
3324	fi
3325	;;
3326*) dflt=y;;
3327esac
3328
3329: Get old answers from old config file if Configure was run on the
3330: same system, otherwise use the hints.
3331hint=default
3332cd ..
3333if test -f config.sh; then
3334	echo " "
3335	rp="I see a config.sh file.  Shall I use it to set the defaults?"
3336	. UU/myread
3337	case "$ans" in
3338	n*|N*) echo "OK, I'll ignore it."
3339		mv config.sh config.sh.old
3340		myuname="$newmyuname"
3341		;;
3342	*)  echo "Fetching default answers from your old config.sh file..." >&4
3343		tmp_n="$n"
3344		tmp_c="$c"
3345		tmp_sh="$sh"
3346		. ./config.sh
3347		cp config.sh UU
3348		n="$tmp_n"
3349		c="$tmp_c"
3350		: Older versions did not always set $sh.  Catch re-use of such
3351		: an old config.sh.
3352		case "$sh" in
3353		'') sh="$tmp_sh" ;;
3354		esac
3355		hint=previous
3356		;;
3357	esac
3358fi
3359. ./UU/checkcc
3360if test ! -f config.sh; then
3361	$cat <<EOM
3362
3363First time through, eh?  I have some defaults handy for some systems
3364that need some extra help getting the Configure answers right:
3365
3366EOM
3367	(cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
3368	dflt=''
3369	: Half the following guesses are probably wrong... If you have better
3370	: tests or hints, please send them to https://github.com/Perl/perl5/issues
3371	: The metaconfig authors would also appreciate a copy...
3372	$test -f /irix && osname=irix
3373	$test -f /xenix && osname=sco_xenix
3374	$test -f /dynix && osname=dynix
3375	$test -f /dnix && osname=dnix
3376	$test -f /lynx.os && osname=lynxos
3377	$test -f /unicos && osname=unicos && osvers=`$uname -r`
3378	$test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
3379	$test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
3380	$test -f /bin/mips && /bin/mips && osname=mips
3381	$test -d /usr/apollo/bin && osname=apollo
3382	$test -f /etc/saf/_sactab && osname=svr4
3383	$test -d /usr/include/minix && osname=minix && osvers=`$uname -r`
3384	$test -f /system/gnu_library/bin/ar.pm && osname=vos
3385	$test -f /sys/utilities/MultiView && osname=amigaos
3386	if $test -d /MachTen -o -d /MachTen_Folder; then
3387		osname=machten
3388		if $test -x /sbin/version; then
3389			osvers=`/sbin/version | $awk '{print $2}' |
3390			$sed -e 's/[A-Za-z]$//'`
3391		elif $test -x /usr/etc/version; then
3392			osvers=`/usr/etc/version | $awk '{print $2}' |
3393			$sed -e 's/[A-Za-z]$//'`
3394		else
3395			osvers="$2.$3"
3396		fi
3397	fi
3398
3399	$test -f /sys/posix.dll &&
3400		$test -f /usr/bin/what &&
3401		set X `/usr/bin/what /sys/posix.dll` &&
3402		$test "$3" = UWIN &&
3403		osname=uwin &&
3404		osvers="$5"
3405
3406	if $test -f $uname; then
3407		set X $myuname
3408		shift
3409
3410		case "$5" in
3411		fps*) osname=fps ;;
3412		mips*)
3413			case "$4" in
3414			umips) osname=umips ;;
3415			*) osname=mips ;;
3416			esac;;
3417		[23]100) osname=mips ;;
3418		i386*)
3419			tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
3420			if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
3421				osname='sco'
3422				osvers=$tmp
3423			elif $test -f /etc/kconfig; then
3424				osname=isc
3425				if test "$lns" = "$ln -s"; then
3426					osvers=4
3427				elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
3428					osvers=3
3429				elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
3430					osvers=2
3431				fi
3432			fi
3433			tmp=''
3434			;;
3435		pc*)
3436			if test -n "$DJGPP"; then
3437				osname=dos
3438				osvers=djgpp
3439			fi
3440			;;
3441		esac
3442
3443		case "$1" in
3444		aix) osname=aix
3445			tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
3446			case "$tmp" in
3447			# oslevel can fail with:
3448			# oslevel: Unable to acquire lock.
3449			*not\ found) osvers="$4"."$3" ;;
3450			'<3240'|'<>3240') osvers=3.2.0 ;;
3451			'=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
3452			'=3250'|'>3250') osvers=3.2.5 ;;
3453			*) osvers=$tmp;;
3454			esac
3455			;;
3456		bitrig) osname=bitrig
3457			osvers="$3"
3458			;;
3459		bsd386) osname=bsd386
3460			osvers=`$uname -r`
3461			;;
3462		cygwin*) osname=cygwin
3463			osvers="$3"
3464			;;
3465		*dc.osx) osname=dcosx
3466			osvers="$3"
3467			;;
3468		dnix) osname=dnix
3469			osvers="$3"
3470			;;
3471		domainos) osname=apollo
3472			osvers="$3"
3473			;;
3474		dgux)	osname=dgux
3475			osvers="$3"
3476			;;
3477		dragonfly) osname=dragonfly
3478			osvers="$3"
3479			;;
3480		dynixptx*) osname=dynixptx
3481			osvers=`echo "$4"|sed 's/^v//'`
3482			;;
3483		freebsd) osname=freebsd
3484			osvers="$3" ;;
3485		genix)	osname=genix ;;
3486		gnu)	osname=gnu
3487			osvers="$3" ;;
3488		hp*)	osname=hpux
3489			osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
3490			;;
3491		irix*)	osname=irix
3492			case "$3" in
3493			4*) osvers=4 ;;
3494			5*) osvers=5 ;;
3495			*)	osvers="$3" ;;
3496			esac
3497			;;
3498		linux)	osname=linux
3499			case "$3" in
3500			*)	osvers="$3" ;;
3501			esac
3502			$test -f /system/lib/libandroid.so && osname=linux-android
3503			;;
3504		MiNT)	osname=mint
3505			;;
3506		minix)	osname=minix
3507			osvers=`$uname -r`
3508			;;
3509		netbsd*) osname=netbsd
3510			osvers="$3"
3511			;;
3512		news-os) osvers="$3"
3513			case "$3" in
3514			4*) osname=newsos4 ;;
3515			*) osname=newsos ;;
3516			esac
3517			;;
3518		nonstop-ux) osname=nonstopux ;;
3519		openbsd) osname=openbsd
3520			osvers="$3"
3521			;;
3522		os2)	osname=os2
3523			osvers="$4"
3524			;;
3525		POSIX-BC | posix-bc ) osname=posix-bc
3526			osvers="$3"
3527			;;
3528		powerux | power_ux | powermax_os | powermaxos | \
3529		powerunix | power_unix) osname=powerux
3530			osvers="$3"
3531			;;
3532		qnx) osname=qnx
3533			osvers="$4"
3534			;;
3535		solaris) osname=solaris
3536			case "$3" in
3537			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3538			*)	osvers="$3" ;;
3539			esac
3540			;;
3541		sunos) osname=sunos
3542			case "$3" in
3543			5*) osname=solaris
3544				osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3545			*)	osvers="$3" ;;
3546			esac
3547			;;
3548		titanos) osname=titanos
3549			case "$3" in
3550			1*) osvers=1 ;;
3551			2*) osvers=2 ;;
3552			3*) osvers=3 ;;
3553			4*) osvers=4 ;;
3554			*)	osvers="$3" ;;
3555			esac
3556			;;
3557		ultrix) osname=ultrix
3558			osvers="$3"
3559			;;
3560		osf1|mls+)	case "$5" in
3561				alpha)
3562					osname=dec_osf
3563					osvers=`sizer -v | awk -FUNIX '{print $2}' | awk '{print $1}' |  tr '[A-Z]' '[a-z]' | sed 's/^[xvt]//'`
3564					case "$osvers" in
3565					[1-9].[0-9]*) ;;
3566					*) osvers=`echo "$3" | sed 's/^[xvt]//'` ;;
3567					esac
3568					;;
3569			hp*)	osname=hp_osf1	;;
3570			mips)	osname=mips_osf1 ;;
3571			esac
3572			;;
3573		# UnixWare 7.1.2 is known as Open UNIX 8
3574		openunix|unixware) osname=svr5
3575			osvers="$4"
3576			;;
3577		uts)	osname=uts
3578			osvers="$3"
3579			;;
3580		vos) osvers="$3"
3581			;;
3582		$2) case "$osname" in
3583			*isc*) ;;
3584			*freebsd*) ;;
3585			svr*)
3586				: svr4.x or possibly later
3587				case "svr$3" in
3588				${osname}*)
3589					osname=svr$3
3590					osvers=$4
3591					;;
3592				esac
3593				case "$osname" in
3594				svr4.0)
3595					: Check for ESIX
3596					if test -f /stand/boot ; then
3597						eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
3598						if test -n "$INITPROG" -a -f "$INITPROG"; then
3599			isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
3600							if test -n "$isesix"; then
3601								osname=esix4
3602							fi
3603						fi
3604					fi
3605					;;
3606				esac
3607				;;
3608			*)	if test -f /etc/systemid; then
3609					osname=sco
3610					set `echo $3 | $sed 's/\./ /g'` $4
3611					if $test -f $src/hints/sco_$1_$2_$3.sh; then
3612						osvers=$1.$2.$3
3613					elif $test -f $src/hints/sco_$1_$2.sh; then
3614						osvers=$1.$2
3615					elif $test -f $src/hints/sco_$1.sh; then
3616						osvers=$1
3617					fi
3618				else
3619					case "$osname" in
3620					'') : Still unknown.  Probably a generic Sys V.
3621						osname="sysv"
3622						osvers="$3"
3623						;;
3624					esac
3625				fi
3626				;;
3627			esac
3628			;;
3629		*)	case "$osname" in
3630			'') : Still unknown.  Probably a generic BSD.
3631				osname="$1"
3632				osvers="$3"
3633				;;
3634			esac
3635			;;
3636		esac
3637	else
3638		if test -f /vmunix -a -f $src/hints/news_os.sh; then
3639			(what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
3640			if $contains news-os UU/kernel.what >/dev/null 2>&1; then
3641				osname=news_os
3642			fi
3643			$rm -f UU/kernel.what
3644		elif test -d c:/. -o -n "$is_os2" ; then
3645			set X $myuname
3646			osname=os2
3647			osvers="$5"
3648		fi
3649	fi
3650
3651        case "$targetarch" in
3652        '') ;;
3653        *)  hostarch=$osname
3654            case "$targetarch" in
3655                nto*|*-nto-*)
3656                    # Will load qnx.sh, which should change osname to nto
3657                    osname=qnx
3658                    osvers=''
3659                    ;;
3660                *linux-android*)
3661                    # Catch arm-linux-androideabi, mipsel-linux-android,
3662                    # and i686-linux-android
3663                    osname=linux-android
3664                    osvers=''
3665                    ;;
3666                *linux*)
3667                    # Something like arm-linux-gnueabihf is really just
3668                    # plain linux.
3669                    osname=linux
3670                    osvers=''
3671                    ;;
3672                *solaris*|*sunos*)
3673                    osname=solaris
3674                    # XXX perhaps we should just assume
3675                    # osvers to be 2, or maybe take the value
3676                    # from targetarch. Using $run before the
3677                    # hints are run is somewhat icky.
3678                    set X `$run $uname -a 2>/dev/null`
3679                    shift
3680                    case "$3" in
3681                        5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3682                        *)  osvers="$3" ;;
3683                    esac
3684                    ;;
3685                *)
3686		    osname=`echo $targetarch|sed 's,^[^-]*-,,'`
3687		    osvers=''
3688                ;;
3689            esac
3690            ;;
3691        esac
3692
3693	: Now look for a hint file osname_osvers, unless one has been
3694	: specified already.
3695	case "$hintfile" in
3696	''|' ')
3697		file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'`
3698		: Also try without trailing minor version numbers.
3699		xfile=`echo $file | $sed -e 's%_[^_]*$%%'`
3700		xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'`
3701		xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'`
3702		xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'`
3703		case "$file" in
3704		'') dflt=none ;;
3705		*)  case "$osvers" in
3706			'') dflt=$file
3707				;;
3708			*)  if $test -f $src/hints/$file.sh ; then
3709					dflt=$file
3710				elif $test -f $src/hints/$xfile.sh ; then
3711					dflt=$xfile
3712				elif $test -f $src/hints/$xxfile.sh ; then
3713					dflt=$xxfile
3714				elif $test -f $src/hints/$xxxfile.sh ; then
3715					dflt=$xxxfile
3716				elif $test -f $src/hints/$xxxxfile.sh ; then
3717					dflt=$xxxxfile
3718				elif $test -f "$src/hints/${osname}.sh" ; then
3719					dflt="${osname}"
3720				else
3721					dflt=none
3722				fi
3723				;;
3724			esac
3725			;;
3726		esac
3727		if $test -f Policy.sh ; then
3728			case "$dflt" in
3729			*Policy*) ;;
3730			none) dflt="Policy" ;;
3731			*) dflt="Policy $dflt" ;;
3732			esac
3733		fi
3734		;;
3735	*)
3736		dflt=`echo $hintfile | $sed 's/\.sh$//'`
3737		;;
3738	esac
3739
3740	if $test -f Policy.sh ; then
3741		$cat <<EOM
3742
3743There's also a Policy hint file available, which should make the
3744site-specific (policy) questions easier to answer.
3745EOM
3746
3747	fi
3748
3749	$cat <<EOM
3750
3751You may give one or more space-separated answers, or "none" if appropriate.
3752If you have a handcrafted Policy.sh file or a Policy.sh file generated by a
3753previous run of Configure, you may specify it as well as or instead of
3754OS-specific hints.  If hints are provided for your OS, you should use them:
3755although Perl can probably be built without hints on many platforms, using
3756hints often improve performance and may enable features that Configure can't
3757set up on its own. If there are no hints that match your OS, specify "none";
3758DO NOT give a wrong version or a wrong OS.
3759
3760EOM
3761
3762	rp="Which of these apply, if any?"
3763	. UU/myread
3764	tans=$ans
3765	for file in $tans; do
3766		if $test X$file = XPolicy -a -f Policy.sh; then
3767			. Policy.sh
3768			$cat Policy.sh >> UU/config.sh
3769		elif $test -f $src/hints/$file.sh; then
3770			. $src/hints/$file.sh
3771			$cat $src/hints/$file.sh >> UU/config.sh
3772		elif $test X"$tans" = X -o X"$tans" = Xnone ; then
3773			: nothing
3774		else
3775			: Give one chance to correct a possible typo.
3776			echo "$file.sh does not exist"
3777			dflt=$file
3778			rp="hint to use instead?"
3779			. UU/myread
3780			for file in $ans; do
3781				if $test -f "$src/hints/$file.sh"; then
3782					. $src/hints/$file.sh
3783					$cat $src/hints/$file.sh >> UU/config.sh
3784				elif $test X$ans = X -o X$ans = Xnone ; then
3785					: nothing
3786				else
3787					echo "$file.sh does not exist -- ignored."
3788				fi
3789			done
3790		fi
3791	done
3792
3793	hint=recommended
3794	: Remember our hint file for later.
3795	if $test -f "$src/hints/$file.sh" ; then
3796		hintfile="$file"
3797	else
3798		hintfile=''
3799	fi
3800fi
3801cd UU
3802;;
3803*)
3804	echo " "
3805	echo "Fetching default answers from $config_sh..." >&4
3806	tmp_n="$n"
3807	tmp_c="$c"
3808	cd ..
3809	cp $config_sh config.sh 2>/dev/null
3810	chmod +w config.sh
3811	. ./config.sh
3812	cd UU
3813	cp ../config.sh .
3814	n="$tmp_n"
3815	c="$tmp_c"
3816	hint=previous
3817	;;
3818esac
3819. ./optdef.sh
3820
3821: Restore computed paths
3822for file in $loclist $trylist; do
3823	eval $file="\$_$file"
3824done
3825
3826cat << EOM
3827
3828Configure uses the operating system name and version to set some defaults.
3829The default value is probably right if the name rings a bell. Otherwise,
3830since spelling matters for me, either accept the default or answer "none"
3831to leave it blank.
3832
3833EOM
3834case "$osname" in
3835	''|' ')
3836		case "$hintfile" in
3837		''|' '|none) dflt=none ;;
3838		*)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
3839		esac
3840		;;
3841	*) dflt="$osname" ;;
3842esac
3843rp="Operating system name?"
3844. ./myread
3845case "$ans" in
3846none)  osname='' ;;
3847*) osname=`echo "$ans" | $sed -e 's/[ 	][	]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
3848esac
3849echo " "
3850case "$osvers" in
3851	''|' ')
3852		case "$hintfile" in
3853		''|' '|none) dflt=none ;;
3854		*)	dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
3855			dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
3856			case "$dflt" in
3857			''|' ') dflt=none ;;
3858			esac
3859			;;
3860		esac
3861		;;
3862	*) dflt="$osvers" ;;
3863esac
3864rp="Operating system version?"
3865. ./myread
3866case "$ans" in
3867none)  osvers='' ;;
3868*) osvers="$ans" ;;
3869esac
3870
3871
3872. ./posthint.sh
3873
3874: who configured the system
3875cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
3876case "$cf_by" in
3877"")
3878	cf_by=`(logname) 2>/dev/null`
3879	case "$cf_by" in
3880	"")
3881		cf_by=`(whoami) 2>/dev/null`
3882		case "$cf_by" in
3883		"") cf_by=unknown ;;
3884		esac ;;
3885	esac ;;
3886esac
3887
3888: decide how portable to be.  Allow command line overrides.
3889case "$d_portable" in
3890"$undef") ;;
3891*)	d_portable="$define" ;;
3892esac
3893
3894: set up shell script to do ~ expansion
3895cat >filexp <<EOSS
3896$startsh
3897: expand filename
3898case "\$1" in
3899 \~/*|\~)
3900	echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
3901	;;
3902 \~*)
3903	if $test -f /bin/csh; then
3904		/bin/csh -f -c "glob \$1"
3905		failed=\$?
3906		echo ""
3907		exit \$failed
3908	else
3909		name=\`$expr x\$1 : '..\([^/]*\)'\`
3910		dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
3911		if $test ! -d "\$dir"; then
3912			me=\`basename \$0\`
3913			echo "\$me: can't locate home directory for: \$name" >&2
3914			exit 1
3915		fi
3916		case "\$1" in
3917		*/*)
3918			echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
3919			;;
3920		*)
3921			echo \$dir
3922			;;
3923		esac
3924	fi
3925	;;
3926*)
3927	echo \$1
3928	;;
3929esac
3930EOSS
3931chmod +x filexp
3932$eunicefix filexp
3933
3934: now set up to get a file name
3935cat <<EOS >getfile
3936$startsh
3937EOS
3938cat <<'EOSC' >>getfile
3939tilde=''
3940fullpath=''
3941already=''
3942skip=''
3943none_ok=''
3944exp_file=''
3945nopath_ok=''
3946orig_rp="$rp"
3947orig_dflt="$dflt"
3948case "$gfpth" in
3949'') gfpth='.' ;;
3950esac
3951
3952case "$fn" in
3953*\(*)
3954	: getfile will accept an answer from the comma-separated list
3955	: enclosed in parentheses even if it does not meet other criteria.
3956	expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
3957	fn=`echo $fn | sed 's/(.*)//'`
3958	;;
3959esac
3960
3961case "$fn" in
3962*:*)
3963	loc_file=`expr $fn : '.*:\(.*\)'`
3964	fn=`expr $fn : '\(.*\):.*'`
3965	;;
3966esac
3967
3968case "$fn" in
3969*~*) tilde=true;;
3970esac
3971case "$fn" in
3972*/*) fullpath=true;;
3973esac
3974case "$fn" in
3975*+*) skip=true;;
3976esac
3977case "$fn" in
3978*n*) none_ok=true;;
3979esac
3980case "$fn" in
3981*e*) exp_file=true;;
3982esac
3983case "$fn" in
3984*p*) nopath_ok=true;;
3985esac
3986
3987case "$fn" in
3988*f*) type='File';;
3989*d*) type='Directory';;
3990*l*) type='Locate';;
3991esac
3992
3993what="$type"
3994case "$what" in
3995Locate) what='File';;
3996esac
3997
3998case "$exp_file" in
3999'')
4000	case "$d_portable" in
4001	"$define") ;;
4002	*) exp_file=true;;
4003	esac
4004	;;
4005esac
4006
4007cd ..
4008while test "$type"; do
4009	redo=''
4010	rp="$orig_rp"
4011	dflt="$orig_dflt"
4012	case "$tilde" in
4013	true) rp="$rp (~name ok)";;
4014	esac
4015	. UU/myread
4016	if test -f UU/getfile.ok && \
4017		$contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
4018	then
4019		value="$ans"
4020		ansexp="$ans"
4021		break
4022	fi
4023	case "$ans" in
4024	none)
4025		value=''
4026		ansexp=''
4027		case "$none_ok" in
4028		true) type='';;
4029		esac
4030		;;
4031	*)
4032		case "$tilde" in
4033		'') value="$ans"
4034			ansexp="$ans";;
4035		*)
4036			value=`UU/filexp $ans`
4037			case $? in
4038			0)
4039				if test "$ans" != "$value"; then
4040					echo "(That expands to $value on this system.)"
4041				fi
4042				;;
4043			*) value="$ans";;
4044			esac
4045			ansexp="$value"
4046			case "$exp_file" in
4047			'') value="$ans";;
4048			esac
4049			;;
4050		esac
4051		case "$fullpath" in
4052		true)
4053			case "$ansexp" in
4054			/*) value="$ansexp" ;;
4055			[a-zA-Z]:/*) value="$ansexp" ;;
4056			*)
4057				redo=true
4058				case "$already" in
4059				true)
4060				echo "I shall only accept a full path name, as in /bin/ls." >&4
4061				echo "Use a ! shell escape if you wish to check pathnames." >&4
4062					;;
4063				*)
4064				echo "Please give a full path name, starting with slash." >&4
4065					case "$tilde" in
4066					true)
4067				echo "Note that using ~name is ok provided it expands well." >&4
4068						already=true
4069						;;
4070					esac
4071				esac
4072				;;
4073			esac
4074			;;
4075		esac
4076		case "$redo" in
4077		'')
4078			case "$type" in
4079			File)
4080				for fp in $gfpth; do
4081					if test "X$fp" = X.; then
4082					    pf="$ansexp"
4083					else
4084					    pf="$fp/$ansexp"
4085					fi
4086					if test -f "$pf"; then
4087						type=''
4088					elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
4089					then
4090						echo "($value is not a plain file, but that's ok.)"
4091						type=''
4092					fi
4093					if test X"$type" = X; then
4094					    value="$pf"
4095					    break
4096					fi
4097				done
4098				;;
4099			Directory)
4100				for fp in $gfpth; do
4101					if test "X$fp" = X.; then
4102					    dir="$ans"
4103					    direxp="$ansexp"
4104					else
4105					    dir="$fp/$ansexp"
4106					    direxp="$fp/$ansexp"
4107					fi
4108					if test -d "$direxp"; then
4109						type=''
4110						value="$dir"
4111						break
4112					fi
4113				done
4114				;;
4115			Locate)
4116				if test -d "$ansexp"; then
4117					echo "(Looking for $loc_file in directory $value.)"
4118					value="$value/$loc_file"
4119					ansexp="$ansexp/$loc_file"
4120				fi
4121				if test -f "$ansexp"; then
4122					type=''
4123				fi
4124				case "$nopath_ok" in
4125				true)	case "$value" in
4126					*/*) ;;
4127					*)	echo "Assuming $value will be in people's path."
4128						type=''
4129						;;
4130					esac
4131					;;
4132				esac
4133				;;
4134			esac
4135
4136			case "$skip" in
4137			true) type='';
4138			esac
4139
4140			case "$type" in
4141			'') ;;
4142			*)
4143				if test "$fastread" = yes; then
4144					dflt=y
4145				else
4146					dflt=n
4147				fi
4148				rp="$what $value doesn't exist.  Use that name anyway?"
4149				. UU/myread
4150				dflt=''
4151				case "$ans" in
4152				y*) type='';;
4153				*) echo " ";;
4154				esac
4155				;;
4156			esac
4157			;;
4158		esac
4159		;;
4160	esac
4161done
4162cd UU
4163ans="$value"
4164rp="$orig_rp"
4165dflt="$orig_dflt"
4166rm -f getfile.ok
4167test "X$gfpthkeep" != Xy && gfpth=""
4168EOSC
4169
4170: determine root of directory hierarchy where package will be installed.
4171case "$prefix" in
4172'')
4173	dflt=`./loc . /usr/local /usr/local /local /opt /usr`
4174	;;
4175*?/)
4176	dflt=`echo "$prefix" | sed 's/.$//'`
4177	;;
4178*)
4179	dflt="$prefix"
4180	;;
4181esac
4182$cat <<EOM
4183
4184By default, $package will be installed in $dflt/bin, manual pages
4185under $dflt/man, etc..., i.e. with $dflt as prefix for all
4186installation directories. Typically this is something like /usr/local.
4187If you wish to have binaries under /usr/bin but other parts of the
4188installation under /usr/local, that's ok: you will be prompted
4189separately for each of the installation directories, the prefix being
4190only used to set the defaults.
4191
4192EOM
4193fn=d~
4194rp='Installation prefix to use?'
4195. ./getfile
4196oldprefix=''
4197case "$prefix" in
4198'') ;;
4199*)
4200	case "$ans" in
4201	"$prefix") ;;
4202	*) oldprefix="$prefix";;
4203	esac
4204	;;
4205esac
4206prefix="$ans"
4207prefixexp="$ansexp"
4208
4209: allow them to override the AFS root
4210case "$afsroot" in
4211'')	afsroot=/afs ;;
4212*)	afsroot=$afsroot ;;
4213esac
4214
4215: is AFS running?
4216echo " "
4217case "$afs" in
4218$define|true)	afs=true ;;
4219$undef|false)	afs=false ;;
4220*)	if $test -d $afsroot; then
4221		afs=true
4222	else
4223		afs=false
4224	fi
4225	;;
4226esac
4227if $afs; then
4228	echo "AFS may be running... I'll be extra cautious then..." >&4
4229else
4230	echo "AFS does not seem to be running..." >&4
4231fi
4232
4233: determine installation prefix for where package is to be installed.
4234if $afs; then
4235$cat <<EOM
4236
4237Since you are running AFS, I need to distinguish the directory in which
4238files will reside from the directory in which they are installed (and from
4239which they are presumably copied to the former directory by occult means).
4240
4241EOM
4242	case "$installprefix" in
4243	'') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
4244	*) dflt="$installprefix";;
4245	esac
4246else
4247$cat <<EOM
4248
4249In some special cases, particularly when building $package for distribution,
4250it is convenient to distinguish the directory in which files should be
4251installed from the directory ($prefix) in which they will
4252eventually reside.  For most users, these two directories are the same.
4253
4254EOM
4255	case "$installprefix" in
4256	'') dflt=$prefix ;;
4257	*) dflt=$installprefix;;
4258	esac
4259fi
4260fn=d~
4261rp='What installation prefix should I use for installing files?'
4262. ./getfile
4263installprefix="$ans"
4264installprefixexp="$ansexp"
4265
4266: Perform the prefixexp/installprefixexp correction if necessary
4267cat <<EOS >installprefix
4268$startsh
4269EOS
4270cat <<'EOSC' >>installprefix
4271: Change installation prefix, if necessary.
4272if $test X"$prefix" != X"$installprefix"; then
4273    eval "install${prefixvar}=\`echo \$${prefixvar}exp | sed \"s#^\$prefixexp#\$installprefixexp#\"\`"
4274else
4275    eval "install${prefixvar}=\"\$${prefixvar}exp\""
4276fi
4277EOSC
4278chmod +x installprefix
4279$eunicefix installprefix
4280
4281: Set variables such as privlib and privlibexp from the output of ./getfile
4282: performing the prefixexp/installprefixexp correction if necessary.
4283cat <<EOS >setprefixvar
4284$startsh
4285EOS
4286cat <<'EOSC' >>setprefixvar
4287eval "${prefixvar}=\"\$ans\""
4288eval "${prefixvar}exp=\"\$ansexp\""
4289. ./installprefix
4290EOSC
4291chmod +x setprefixvar
4292$eunicefix setprefixvar
4293
4294: set up the script used to warn in case of inconsistency
4295cat <<EOS >whoa
4296$startsh
4297EOS
4298cat <<'EOSC' >>whoa
4299dflt=y
4300case "$hint" in
4301    recommended)
4302	case "$hintfile" in
4303	'')	echo "The $hint value for \$$var on this machine was \"$was\"!" >&4
4304		;;
4305	*)	echo "Hmm.  Based on the hints in hints/$hintfile.sh, " >&4
4306		echo "the $hint value for \$$var on this machine was \"$was\"!" >&4
4307		;;
4308	esac
4309	;;
4310    *)	echo " "
4311	echo "*** WHOA THERE!!! ***" >&4
4312	echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
4313	;;
4314esac
4315rp="    Keep the $hint value?"
4316. ./myread
4317case "$ans" in
4318y) td=$was; tu=$was;;
4319esac
4320EOSC
4321
4322: function used to set '$1' to '$val'
4323setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
4324case "$val$was" in
4325$define$undef) . ./whoa; eval "$var=\$td";;
4326$undef$define) . ./whoa; eval "$var=\$tu";;
4327*) eval "$var=$val";;
4328esac'
4329
4330: get the patchlevel
4331echo " "
4332echo "Getting the current patchlevel..." >&4
4333if $test -r $rsrc/patchlevel.h;then
4334	revision=`awk '/define[ 	]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
4335	patchlevel=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
4336	subversion=`awk '/define[ 	]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
4337	api_revision=`awk '/define[ 	]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
4338	api_version=`awk '/define[ 	]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
4339	api_subversion=`awk '/define[ 	]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
4340	perl_patchlevel=`egrep ',"(MAINT|SMOKE)[0-9][0-9]*"' $rsrc/patchlevel.h|tail -1|sed 's/[^0-9]//g'`
4341else
4342	revision=0
4343	patchlevel=0
4344	subversion=0
4345	api_revision=0
4346	api_version=0
4347	api_subversion=0
4348	perl_patchlevel=0
4349	$echo "(You do not have patchlevel.h.  Eek.)"
4350fi
4351: Define a handy string here to avoid duplication in myconfig.SH and configpm.
4352version_patchlevel_string="version $patchlevel subversion $subversion"
4353case "$perl_patchlevel" in
43540|'') ;;
4355*)  perl_patchlevel=`echo $perl_patchlevel | sed 's/.* //'`
4356    version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel"
4357    ;;
4358esac
4359
4360$echo "(You have $package $version_patchlevel_string.)"
4361
4362case "$osname" in
4363dos|vms)
4364	: XXX Should be a Configure test for double-dots in filenames.
4365	version=`echo $revision $patchlevel $subversion | \
4366		 $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
4367	api_versionstring=`echo $api_revision $api_version $api_subversion | \
4368		 $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
4369	;;
4370*)
4371	version=`echo $revision $patchlevel $subversion | \
4372		 $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
4373	api_versionstring=`echo $api_revision $api_version $api_subversion | \
4374		 $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
4375	;;
4376esac
4377: Special case the 5.005_xx maintenance series, which used 5.005
4378: without any subversion label as a subdirectory in $sitelib
4379if test "${api_revision}${api_version}${api_subversion}" = "550"; then
4380	api_versionstring='5.005'
4381fi
4382
4383: Do we want threads support and if so, what type
4384case "$usethreads" in
4385$define|true|[yY]*)     dflt='y';;
4386*)     # Catch case where user specified ithreads or 5005threads but
4387       # forgot -Dusethreads (A.D. 4/2002)
4388       case "$useithreads$use5005threads" in
4389       *$define*)	dflt='y';;
4390       *)		dflt='n';;
4391       esac
4392       ;;
4393esac
4394cat <<EOM
4395
4396Perl can be built to offer a form of threading support on some systems
4397To do so, Configure can be run with -Dusethreads.
4398
4399Note that Perl built with threading support runs slightly slower
4400and uses slightly more memory than plain Perl.
4401
4402If this doesn't make any sense to you, just accept the default '$dflt'.
4403EOM
4404rp='Build a threading Perl?'
4405. ./myread
4406case "$ans" in
4407y|Y)    val="$define" ;;
4408*)      val="$undef" ;;
4409esac
4410set usethreads
4411eval $setvar
4412
4413if $test $patchlevel -lt 9; then
4414    case "$usethreads" in
4415    $define)
4416	: Default to ithreads unless overridden on command line or with
4417	: old config.sh
4418	dflt='y'
4419	case "$use5005threads" in
4420		$define|true|[yY]*)
4421			echo "5.005 threads are no longer supported"
4422			exit 1
4423		;;
4424	esac
4425	case "$useithreads" in
4426		$undef|false|[nN]*) dflt='n';;
4427	esac
4428	rp='Use the newer interpreter-based ithreads?'
4429	. ./myread
4430	case "$ans" in
4431	y|Y)    val="$define" ;;
4432	*)      val="$undef" ;;
4433	esac
4434	set useithreads
4435	eval $setvar
4436	: Now set use5005threads to the opposite value.
4437	case "$useithreads" in
4438	$define) val="$undef" ;;
4439	*) val="$define" ;;
4440	esac
4441	set use5005threads
4442	eval $setvar
4443	;;
4444    *)
4445	useithreads="$undef"
4446	use5005threads="$undef"
4447	;;
4448    esac
4449
4450    case "$useithreads$use5005threads" in
4451    "$define$define")
4452	$cat >&4 <<EOM
4453
4454You cannot have both the ithreads and the 5.005 threads enabled
4455at the same time.  Disabling the 5.005 threads since they are
4456much less stable than the ithreads.
4457
4458EOM
4459	use5005threads="$undef"
4460	;;
4461    esac
4462
4463else
4464: perl-5.9.x and later
4465
4466    if test X"$usethreads" = "X$define"; then
4467	case "$use5005threads" in
4468	    $define|true|[yY]*)
4469		$cat >&4 <<EOM
4470
44715.005 threads has been removed for 5.10.  Perl will be built using ithreads.
4472
4473EOM
4474	    ;;
4475	esac
4476    fi
4477
4478    use5005threads="$undef"
4479    useithreads="$usethreads"
4480fi
4481
4482case "$d_oldpthreads" in
4483'')	: Configure tests would be welcome here.  For now, assume undef.
4484	val="$undef" ;;
4485*)	val="$d_oldpthreads" ;;
4486esac
4487set d_oldpthreads
4488eval $setvar
4489
4490
4491: Look for a hint-file generated 'call-back-unit'.  If the
4492: user has specified that a threading perl is to be built,
4493: we may need to set or change some other defaults.
4494if $test -f usethreads.cbu; then
4495    echo "Your platform has some specific hints regarding threaded builds, using them..."
4496    . ./usethreads.cbu
4497else
4498    case "$usethreads" in
4499	"$define"|true|[yY]*)
4500		$cat <<EOM
4501(Your platform does not have any specific hints for threaded builds.
4502 Assuming POSIX threads, then.)
4503EOM
4504	;;
4505    esac
4506fi
4507
4508: Check if multiplicity is required
4509cat <<EOM
4510
4511Perl can be built so that multiple Perl interpreters can coexist
4512within the same Perl executable.
4513EOM
4514
4515case "$useithreads" in
4516$define)
4517	cat <<EOM
4518This multiple interpreter support is required for interpreter-based threads.
4519EOM
4520	val="$define"
4521	;;
4522*)	case "$usemultiplicity" in
4523	$define|true|[yY]*)	dflt='y';;
4524	*) dflt='n';;
4525	esac
4526	echo " "
4527	echo "If this doesn't make any sense to you, just accept the default '$dflt'."
4528	rp='Build Perl for multiplicity?'
4529	. ./myread
4530	case "$ans" in
4531	y|Y)	val="$define" ;;
4532	*)      val="$undef" ;;
4533	esac
4534	;;
4535esac
4536set usemultiplicity
4537eval $setvar
4538
4539: Check if morebits is requested
4540case "$usemorebits" in
4541"$define"|true|[yY]*)
4542	use64bitint="$define"
4543	uselongdouble="$define"
4544	usemorebits="$define"
4545	;;
4546*)	usemorebits="$undef"
4547	;;
4548esac
4549
4550: Determine the C compiler to be used
4551echo " "
4552case "$cc" in
4553'') dflt=cc;;
4554*) dflt="$cc";;
4555esac
4556rp="Use which C compiler?"
4557. ./myread
4558cc="$ans"
4559
4560: See whether they have no cc but they do have gcc
4561. ./trygcc
4562if $test -f cc.cbu; then
4563    . ./cc.cbu
4564fi
4565. ./checkcc
4566
4567: make some quick guesses about what we are up against
4568echo " "
4569$echo $n "Hmm...  $c"
4570echo exit 1 >bsd
4571echo exit 1 >usg
4572echo exit 1 >v7
4573echo exit 1 >osf1
4574echo exit 1 >eunice
4575echo exit 1 >xenix
4576echo exit 1 >venix
4577echo exit 1 >os2
4578d_bsd="$undef"
4579$cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null
4580if test -f /osf_boot || $contains 'OSF/1' $sysroot/usr/include/ctype.h >/dev/null 2>&1
4581then
4582	echo "Looks kind of like an OSF/1 system, but we'll see..."
4583	echo exit 0 >osf1
4584elif test `echo abc | $tr a-z A-Z` = Abc ; then
4585	xxx=`./loc addbib blurfl $pth`
4586	if $test -f $xxx; then
4587	echo "Looks kind of like a USG system with BSD features, but we'll see..."
4588		echo exit 0 >bsd
4589		echo exit 0 >usg
4590	else
4591		if $contains SIGTSTP foo >/dev/null 2>&1 ; then
4592			echo "Looks kind of like an extended USG system, but we'll see..."
4593		else
4594			echo "Looks kind of like a USG system, but we'll see..."
4595		fi
4596		echo exit 0 >usg
4597	fi
4598elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
4599	echo "Looks kind of like a BSD system, but we'll see..."
4600	d_bsd="$define"
4601	echo exit 0 >bsd
4602else
4603	echo "Looks kind of like a Version 7 system, but we'll see..."
4604	echo exit 0 >v7
4605fi
4606case "$eunicefix" in
4607*unixtovms*)
4608	$cat <<'EOI'
4609There is, however, a strange, musty smell in the air that reminds me of
4610something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
4611EOI
4612	echo exit 0 >eunice
4613	d_eunice="$define"
4614: it so happens the Eunice I know will not run shell scripts in Unix format
4615	;;
4616*)
4617	echo " "
4618	echo "Congratulations.  You aren't running Eunice."
4619	d_eunice="$undef"
4620	;;
4621esac
4622: Detect OS2.  The p_ variable is set above in the Head.U unit.
4623: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
4624: semicolon as a patch separator
4625case "$p_" in
4626:) ;;
4627*)
4628	$cat <<'EOI'
4629I have the feeling something is not exactly right, however...don't tell me...
4630lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
4631(Or you may be running DOS with DJGPP.)
4632EOI
4633	echo exit 0 >os2
4634	;;
4635esac
4636if test -f /xenix; then
4637	echo "Actually, this looks more like a XENIX system..."
4638	echo exit 0 >xenix
4639	d_xenix="$define"
4640else
4641	echo " "
4642	echo "It's not Xenix..."
4643	d_xenix="$undef"
4644fi
4645chmod +x xenix
4646$eunicefix xenix
4647if test -f /venix; then
4648	echo "Actually, this looks more like a VENIX system..."
4649	echo exit 0 >venix
4650else
4651	echo " "
4652	if ./xenix; then
4653		: null
4654	else
4655		echo "Nor is it Venix..."
4656	fi
4657fi
4658chmod +x bsd usg v7 osf1 eunice xenix venix os2
4659$eunicefix bsd usg v7 osf1 eunice xenix venix os2
4660$rm -f foo
4661
4662: Check if we are using GNU gcc and what its version is
4663echo " "
4664echo "Checking for GNU cc in disguise and/or its version number..." >&4
4665$cat >try.c <<EOM
4666#include <stdio.h>
4667int main() {
4668#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
4669#ifdef __VERSION__
4670	printf("%s\n", __VERSION__);
4671#else
4672	printf("%s\n", "1");
4673#endif
4674#endif
4675	return(0);
4676}
4677EOM
4678if $cc -o try $ccflags $ldflags try.c; then
4679	gccversion=`$run ./try`
4680	case "$gccversion" in
4681	'') echo "You are not using GNU cc." ;;
4682	*)  echo "You are using GNU cc $gccversion."
4683	    ccname=gcc
4684	    ;;
4685	esac
4686else
4687	echo " "
4688	echo "*** WHOA THERE!!! ***" >&4
4689	echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
4690	case "$knowitall" in
4691	'')
4692	echo "    You'd better start hunting for one and let me know about it." >&4
4693		exit 1
4694		;;
4695	esac
4696fi
4697$rm -f try try.*
4698case "$gccversion" in
46991.*) cpp=`./loc gcc-cpp $cpp $pth` ;;
4700esac
4701case "$gccversion" in
4702'') gccosandvers='' ;;
4703*) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
4704   gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
4705   gccshortvers=''
4706   case "$gccosandvers" in
4707   $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
4708   $osname$osvers) ;; # looking good
4709   $osname*) cat <<EOM >&4
4710
4711*** WHOA THERE!!! ***
4712
4713    Your gcc has not been compiled for the exact release of
4714    your operating system ($gccosandvers versus $osname$osvers).
4715
4716    In general it is a good idea to keep gcc synchronized with
4717    the operating system because otherwise serious problems
4718    may ensue when trying to compile software, like Perl.
4719
4720    I'm trying to be optimistic here, though, and will continue.
4721    If later during the configuration and build icky compilation
4722    problems appear (headerfile conflicts being the most common
4723    manifestation), I suggest reinstalling the gcc to match
4724    your operating system release.
4725
4726EOM
4727      ;;
4728   *) gccosandvers='' ;; # failed to parse, better be silent
4729   esac
4730   ;;
4731esac
4732case "$ccname" in
4733'') ccname="$cc" ;;
4734esac
4735
4736# gcc 3.* complain about adding -Idirectories that they already know about,
4737# so we will take those off from locincpth.
4738case "$gccversion" in
47393.*)
4740    echo "main(){}">try.c
4741    for incdir in $locincpth; do
4742       warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
4743	     grep '^c[cp]p*[01]: warning: changing search order '`
4744       if test "X$warn" != X; then
4745	   locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
4746       fi
4747    done
4748    $rm -f try try.*
4749esac
4750
4751# gcc 4.9 by default does some optimizations that break perl.
4752# see ticket 121505.
4753#
4754# The -fwrapv disables those optimizations (and probably others,) so
4755# for gcc 4.9 (and later, since the optimizations probably won't go
4756# away), add -fwrapv unless the user requests -fno-wrapv, which
4757# disables -fwrapv, or if the user requests -fsanitize=undefined,
4758# which turns the overflows -fwrapv ignores into runtime errors.
4759case "$gccversion" in
47604.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*)
4761    case "$ccflags" in
4762    *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
4763    *) ccflags="$ccflags -fwrapv" ;;
4764    esac
4765esac
4766
4767: What should the include directory be ?
4768: Use sysroot if set, so findhdr looks in the right place.
4769echo " "
4770$echo $n "Hmm...  $c"
4771dflt="$sysroot/usr/include"
4772incpath=''
4773mips_type=''
4774if $test -f /bin/mips && /bin/mips; then
4775	echo "Looks like a MIPS system..."
4776	$cat >usr.c <<'EOCP'
4777#ifdef SYSTYPE_BSD43
4778/bsd43
4779#endif
4780EOCP
4781	if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
4782		dflt='/bsd43/usr/include'
4783		incpath='/bsd43'
4784		mips_type='BSD 4.3'
4785	else
4786		mips_type='System V'
4787	fi
4788	$rm -f usr.c usr.out
4789	echo "and you're compiling with the $mips_type compiler and libraries."
4790	xxx_prompt=y
4791	echo "exit 0" >mips
4792else
4793	echo "Doesn't look like a MIPS system."
4794	xxx_prompt=n
4795	echo "exit 1" >mips
4796fi
4797chmod +x mips
4798$eunicefix mips
4799case "$usrinc" in
4800'') ;;
4801*) dflt="$usrinc";;
4802esac
4803case "$xxx_prompt" in
4804y)	fn=d/
4805	echo " "
4806	rp='Where are the include files you want to use?'
4807	. ./getfile
4808	usrinc="$ans"
4809	;;
4810*)	usrinc="$dflt"
4811	;;
4812esac
4813
4814: see how we invoke the C preprocessor
4815echo " "
4816echo "Now, how can we feed standard input to your C preprocessor..." >&4
4817cat <<'EOT' >testcpp.c
4818#define ABC abc
4819#define XYZ xyz
4820ABC.XYZ
4821EOT
4822cd ..
4823if test ! -f cppstdin; then
4824	if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
4825		# AIX cc -E doesn't show the absolute headerfile
4826		# locations but we'll cheat by using the -M flag.
4827		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
4828	else
4829		echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
4830	fi
4831else
4832	echo "Keeping your $hint cppstdin wrapper."
4833fi
4834chmod 755 cppstdin
4835wrapper=`pwd`/cppstdin
4836ok='false'
4837cd UU
4838
4839if $test "X$cppstdin" != "X" && \
4840	$cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
4841	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4842then
4843	echo "You used to use $cppstdin $cppminus so we'll use that again."
4844	case "$cpprun" in
4845	'') echo "But let's see if we can live without a wrapper..." ;;
4846	*)
4847		if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
4848			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4849		then
4850			echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
4851			ok='true'
4852		else
4853			echo "(However, $cpprun $cpplast does not work, let's see...)"
4854		fi
4855		;;
4856	esac
4857else
4858	case "$cppstdin" in
4859	'') ;;
4860	*)
4861		echo "Good old $cppstdin $cppminus does not seem to be of any help..."
4862		;;
4863	esac
4864fi
4865
4866if $ok; then
4867	: nothing
4868elif echo 'Maybe "'"$cc"' -E" will work...'; \
4869	$cc -E <testcpp.c >testcpp.out 2>&1; \
4870	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4871	echo "Yup, it does."
4872	x_cpp="$cc $cppflags -E"
4873	x_minus='';
4874elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
4875	$cc -E - <testcpp.c >testcpp.out 2>&1; \
4876	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4877	echo "Yup, it does."
4878	x_cpp="$cc $cppflags -E"
4879	x_minus='-';
4880elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
4881	$cc -P <testcpp.c >testcpp.out 2>&1; \
4882	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4883	echo "Yipee, that works!"
4884	x_cpp="$cc $cppflags -P"
4885	x_minus='';
4886elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
4887	$cc -P - <testcpp.c >testcpp.out 2>&1; \
4888	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4889	echo "At long last!"
4890	x_cpp="$cc $cppflags -P"
4891	x_minus='-';
4892elif echo 'No such luck, maybe "'$cpp'" will work...'; \
4893	$cpp <testcpp.c >testcpp.out 2>&1; \
4894	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4895	echo "It works!"
4896	x_cpp="$cpp $cppflags"
4897	x_minus='';
4898elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
4899	$cpp - <testcpp.c >testcpp.out 2>&1; \
4900	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4901	echo "Hooray, it works!  I was beginning to wonder."
4902	x_cpp="$cpp $cppflags"
4903	x_minus='-';
4904elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
4905	$wrapper <testcpp.c >testcpp.out 2>&1; \
4906	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4907	x_cpp="$wrapper"
4908	x_minus=''
4909	echo "Eureka!"
4910else
4911	dflt=''
4912	rp="No dice.  I can't find a C preprocessor.  Name one:"
4913	. ./myread
4914	x_cpp="$ans"
4915	x_minus=''
4916	$x_cpp <testcpp.c >testcpp.out 2>&1
4917	if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4918		echo "OK, that will do." >&4
4919	else
4920echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
4921		exit 1
4922	fi
4923fi
4924
4925case "$ok" in
4926false)
4927	cppstdin="$x_cpp"
4928	cppminus="$x_minus"
4929	cpprun="$x_cpp"
4930	cpplast="$x_minus"
4931	set X $x_cpp
4932	shift
4933	case "$1" in
4934	"$cpp")
4935		echo "Perhaps can we force $cc -E using a wrapper..."
4936		if $wrapper <testcpp.c >testcpp.out 2>&1; \
4937			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4938		then
4939			echo "Yup, we can."
4940			cppstdin="$wrapper"
4941			cppminus='';
4942		else
4943			echo "Nope, we'll have to live without it..."
4944		fi
4945		;;
4946	esac
4947	case "$cpprun" in
4948	"$wrapper")
4949		cpprun=''
4950		cpplast=''
4951		;;
4952	esac
4953	;;
4954esac
4955
4956case "$cppstdin" in
4957"$wrapper"|'cppstdin') ;;
4958*) $rm -f $wrapper;;
4959esac
4960$rm -f testcpp.c testcpp.out
4961
4962: Adjust cppfilter for path component separator
4963case "$osname" in
4964vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
4965os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
4966*)   cppfilter='' ;;
4967esac
4968
4969: Use gcc to determine libpth and incpth
4970# If using gcc or clang, we can get better values for libpth, incpth
4971# and usrinc directly from the compiler.
4972# Note that ccname for clang is also gcc.
4973case "$ccname" in
4974    gcc)
4975	$echo 'extern int foo;' > try.c
4976	set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
4977	shift
4978	if $test $# -gt 0; then
4979	    incpth="$incpth $*"
4980	    incpth="`$echo $incpth|$sed 's/^ //'`"
4981	    for i in $*; do
4982		j="`$echo $i|$sed 's,/include$,/lib,'`"
4983		if $test -d $j; then
4984		    libpth="$libpth $j"
4985		fi
4986	    done
4987	    libpth="`$echo $libpth|$sed 's/^ //'`"
4988	    for xxx in $libpth $loclibpth $plibpth $glibpth; do
4989		if $test -d $xxx; then
4990		    case " $libpth " in
4991		    *" $xxx "*) ;;
4992		    *) libpth="$libpth $xxx";;
4993		    esac
4994		fi
4995	    done
4996	fi
4997	$rm -f try.c
4998	case "$usrinc" in
4999	'') for i in $incpth; do
5000		if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
5001		    usrinc="$i"
5002		    break
5003		fi
5004	    done
5005	    ;;
5006	esac
5007
5008	case "$usecrosscompile" in
5009	$define|true|[yY]*)
5010	    case "$incpth" in
5011		'') echo "Incpth not defined." >&4; croak=y ;;
5012		*)  echo "Using incpth '$incpth'." >&4 ;;
5013	    esac
5014	    case "$libpth" in
5015		'') echo "Libpth not defined." >&4; croak=y ;;
5016		*)  echo "Using libpth '$libpth'." >&4 ;;
5017	    esac
5018	    case "$usrinc" in
5019		'') echo "Usrinc not defined." >&4; croak=y ;;
5020		*)  echo "Using usrinc $usrinc." >&4 ;;
5021	    esac
5022	    case "$croak" in
5023		y)
5024		if test "X$sysroot" = X; then
5025		    echo "Cannot continue, aborting." >&4; exit 1
5026		else
5027		    echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
5028		fi
5029		;;
5030	    esac
5031	    ;;
5032	esac
5033    ;;
5034esac
5035
5036: Default value for incpth is just usrinc
5037case "$incpth" in
5038'') incpth="$usrinc";;
5039esac
5040
5041: Set private lib path
5042case "$plibpth" in
5043'') if ./mips; then
5044	plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
5045    fi;;
5046esac
5047case "$libpth" in
5048' ') dlist='';;
5049'') dlist="$loclibpth $plibpth $glibpth";;
5050*) dlist="$libpth";;
5051esac
5052
5053: Now check and see which directories actually exist, avoiding duplicates
5054for xxx in $dlist
5055do
5056    if $test -d $xxx; then
5057		case " $libpth " in
5058		*" $xxx "*) ;;
5059		*) libpth="$libpth $xxx";;
5060		esac
5061    fi
5062done
5063$cat <<'EOM'
5064
5065Some systems have incompatible or broken versions of libraries.  Among
5066the directories listed in the question below, please remove any you
5067know not to be holding relevant libraries, and add any that are needed.
5068Say "none" for none.
5069
5070EOM
5071
5072if test "X$sysroot" != X; then
5073    $cat <<EOM
5074You have set sysroot to $sysroot, please supply the directories excluding sysroot
5075
5076EOM
5077fi
5078
5079case "$libpth" in
5080'') dflt='none';;
5081*)
5082	set X $libpth
5083	shift
5084	dflt=${1+"$@"}
5085	;;
5086esac
5087rp="Directories to use for library searches?"
5088. ./myread
5089case "$ans" in
5090none) libpth=' ';;
5091*) libpth="$ans";;
5092esac
5093
5094: compute shared library extension
5095case "$so" in
5096'')
5097	if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
5098		dflt='sl'
5099	else
5100		dflt='so'
5101	fi
5102	;;
5103*) dflt="$so";;
5104esac
5105$cat <<EOM
5106
5107On some systems, shared libraries may be available.  Answer 'none' if
5108you want to suppress searching of shared libraries for the remainder
5109of this configuration.
5110
5111EOM
5112rp='What is the file extension used for shared libraries?'
5113. ./myread
5114so="$ans"
5115
5116: Does target system insist that shared library basenames are unique
5117$cat << EOM
5118
5119Some dynamic loaders assume that the *basename* of shared library filenames
5120are globally unique.  We'll default this to undef as we assume your system
5121is not this weird. Set to defined if you're on one of them.
5122
5123EOM
5124
5125dflt='n'
5126rp='Make shared library basenames unique?'
5127. ./myread
5128case "$ans" in
5129y|Y) val="$define" ;;
5130*)   val="$undef"  ;;
5131esac
5132set d_libname_unique
5133eval $setvar
5134
5135: Define several unixisms.
5136: Hints files or command line option can be used to override them.
5137: The convoluted testing is in case hints files set either the old
5138: or the new name.
5139case "$_exe" in
5140'')	case "$exe_ext" in
5141	'')	;;
5142	*)	_exe="$exe_ext" ;;
5143	esac
5144	;;
5145esac
5146case "$_a" in
5147'')	case "$lib_ext" in
5148    '')	_a='.a';;
5149	*)	_a="$lib_ext" ;;
5150	esac
5151	;;
5152esac
5153case "$_o" in
5154'') case "$obj_ext" in
5155	'')	_o='.o';;
5156	*)	_o="$obj_ext";;
5157	esac
5158	;;
5159esac
5160case "$p_" in
5161'') case "$path_sep" in
5162	'')	p_=':';;
5163	*)	p_="$path_sep";;
5164	esac
5165	;;
5166esac
5167exe_ext=$_exe
5168lib_ext=$_a
5169obj_ext=$_o
5170path_sep=$p_
5171
5172rm_try="$rm -f try try$_exe a.out .out try.[cho] try.$_o core core.try* try.core*"
5173
5174: Which makefile gets called first.  This is used by make depend.
5175case "$firstmakefile" in
5176'') firstmakefile='makefile';;
5177esac
5178
5179: Check is we will use socks
5180case "$usesocks" in
5181$define|true|[yY]*)	dflt='y';;
5182*) dflt='n';;
5183esac
5184cat <<EOM
5185
5186Perl can be built to use the SOCKS proxy protocol library.  To do so,
5187Configure must be run with -Dusesocks.  If you use SOCKS you also need
5188to use the PerlIO abstraction layer, this will be implicitly selected.
5189
5190If this doesn't make any sense to you, just accept the default '$dflt'.
5191EOM
5192rp='Build Perl for SOCKS?'
5193. ./myread
5194case "$ans" in
5195y|Y)	val="$define" ;;
5196*)      val="$undef" ;;
5197esac
5198set usesocks
5199eval $setvar
5200
5201: Check for uselongdouble support
5202case "$ccflags" in
5203*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
5204esac
5205
5206case "$uselongdouble" in
5207$define|true|[yY]*)	dflt='y';;
5208*) dflt='n';;
5209esac
5210cat <<EOM
5211
5212Perl can be built to take advantage of long doubles which
5213(if available) may give more accuracy and range for floating point numbers.
5214
5215If this doesn't make any sense to you, just accept the default '$dflt'.
5216EOM
5217rp='Try to use long doubles if available?'
5218. ./myread
5219case "$ans" in
5220y|Y)	val="$define"	;;
5221*)      val="$undef"	;;
5222esac
5223set uselongdouble
5224eval $setvar
5225
5226case "$uselongdouble" in
5227true|[yY]*) uselongdouble="$define" ;;
5228esac
5229
5230: Look for a hint-file generated 'call-back-unit'.  If the
5231: user has specified that long doubles should be used,
5232: we may need to set or change some other defaults.
5233if $test -f uselongdouble.cbu; then
5234    echo "Your platform has some specific hints regarding long doubles, using them..."
5235    . ./uselongdouble.cbu
5236else
5237    case "$uselongdouble" in
5238	$define)
5239		$cat <<EOM
5240(Your platform does not have any specific hints for long doubles.)
5241EOM
5242	;;
5243    esac
5244fi
5245
5246: Check if quadmath is requested
5247case "$usequadmath" in
5248"$define"|true|[yY]*) usequadmath="$define" ;;
5249*)                    usequadmath="$undef"  ;;
5250esac
5251
5252: Fail if both uselongdouble and usequadmath are requested
5253case "$usequadmath:$uselongdouble" in
5254define:define)
5255	$cat <<EOM >&4
5256
5257*** You requested the use of the quadmath library and use
5258*** of long doubles.
5259***
5260*** Please select one or the other.
5261EOM
5262	exit 1
5263	;;
5264esac
5265
5266: Looking for optional libraries
5267echo " "
5268echo "Checking for optional libraries..." >&4
5269case "$libs" in
5270' '|'') dflt='';;
5271*) dflt="$libs";;
5272esac
5273case "$libswanted" in
5274'') libswanted='c_s';;
5275esac
5276case "$usesocks" in
5277"$define") libswanted="$libswanted socks5 socks5_sh" ;;
5278esac
5279case "$usecbacktrace" in
5280"$define") libswanted="$libswanted bfd" ;;
5281esac
5282case "$usequadmath" in
5283"$define") libswanted="$libswanted quadmath" ;;
5284esac
5285libsfound=''
5286libsfiles=''
5287libsdirs=''
5288libspath=''
5289for thisdir in $libpth $xlibpth; do
5290  test -d $thisdir && libspath="$libspath $thisdir"
5291done
5292for thislib in $libswanted; do
5293	for thisdir in $libspath; do
5294	    xxx=''
5295	    if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
5296		xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|sed -n '$p'`
5297	        $test -f "$xxx" && eval $libscheck
5298		$test -f "$xxx" && libstyle=shared
5299		xxx=`ls $thisdir/lib$thislib.[0-9].$so 2>/dev/null|sed -n '$p'`
5300	        $test -f "$xxx" && eval $libscheck
5301		$test -f "$xxx" && libstyle=shared
5302	    fi
5303	    if test ! -f "$xxx"; then
5304		xxx=$thisdir/lib$thislib.$so
5305	        $test -f "$xxx" && eval $libscheck
5306		$test -f "$xxx" && libstyle=shared
5307	    fi
5308	    if test ! -f "$xxx"; then
5309		xxx=$thisdir/lib$thislib$_a
5310	        $test -f "$xxx" && eval $libscheck
5311		$test -f "$xxx" && libstyle=static
5312	    fi
5313	    if test ! -f "$xxx"; then
5314		xxx=$thisdir/$thislib$_a
5315	        $test -f "$xxx" && eval $libscheck
5316		$test -f "$xxx" && libstyle=static
5317	    fi
5318	    if test ! -f "$xxx"; then
5319		xxx=$thisdir/lib${thislib}_s$_a
5320	        $test -f "$xxx" && eval $libscheck
5321		$test -f "$xxx" && libstyle=static
5322		$test -f "$xxx" && thislib=${thislib}_s
5323	    fi
5324	    if test ! -f "$xxx"; then
5325		xxx=$thisdir/Slib$thislib$_a
5326	        $test -f "$xxx" && eval $libscheck
5327		$test -f "$xxx" && libstyle=static
5328	    fi
5329	    if $test -f "$xxx"; then
5330		case "$libstyle" in
5331		shared) echo "Found -l$thislib (shared)." ;;
5332		static) echo "Found -l$thislib." ;;
5333		*)      echo "Found -l$thislib ($libstyle)." ;;
5334		esac
5335		case " $dflt " in
5336		*"-l$thislib "*);;
5337		*) dflt="$dflt -l$thislib"
5338                   libsfound="$libsfound $xxx"
5339                   yyy=`basename $xxx`
5340                   libsfiles="$libsfiles $yyy"
5341                   yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"`
5342                   case " $libsdirs " in
5343                   *" $yyy "*) ;;
5344                   *) libsdirs="$libsdirs $yyy" ;;
5345                   esac
5346		   ;;
5347		esac
5348		break
5349	    fi
5350	done
5351	if $test ! -f "$xxx"; then
5352	    echo "No -l$thislib."
5353	fi
5354done
5355set X $dflt
5356shift
5357dflt="$*"
5358case "$libs" in
5359'') dflt="$dflt";;
5360*) dflt="$libs";;
5361esac
5362case "$dflt" in
5363' '|'') dflt='none';;
5364esac
5365
5366$cat <<EOM
5367
5368In order to compile $package on your machine, a number of libraries
5369are usually needed.  Include any other special libraries here as well.
5370Say "none" for none.  The default list is almost always right.
5371EOM
5372
5373echo " "
5374rp="What libraries to use?"
5375. ./myread
5376case "$ans" in
5377none) libs=' ';;
5378*) libs="$ans";;
5379esac
5380
5381: determine optimization, if desired, or use for debug flag also
5382case "$optimize" in
5383' '|$undef) dflt='none';;
5384'') dflt='-O';;
5385*) dflt="$optimize";;
5386esac
5387$cat <<EOH
5388
5389By default, $package compiles with the -O flag to use the optimizer.
5390Alternately, you might want to use the symbolic debugger, which uses
5391the -g flag (on traditional Unix systems).  Either flag can be
5392specified here.  To use neither flag, specify the word "none".
5393
5394EOH
5395rp="What optimizer/debugger flag should be used?"
5396. ./myread
5397optimize="$ans"
5398case "$optimize" in
5399'none') optimize=" ";;
5400esac
5401
5402: Check what DEBUGGING is required from the command line
5403: -DEBUGGING      or -DDEBUGGING or
5404: -DEBUGGING=both			= -g + -DDEBUGGING
5405: -DEBUGGING=-g   or -Doptimize=-g	= -g
5406: -DEBUGGING=none or -UDEBUGGING	=
5407: -DEBUGGING=old  or -DEBUGGING=default	= ? $optimize
5408case "$EBUGGING" in
5409'')	;;
5410*)	DEBUGGING=$EBUGGING ;;
5411esac
5412
5413case "$DEBUGGING" in
5414-g|both|$define)
5415    case "$optimize" in
5416	*-g*) ;;
5417	*)    optimize="$optimize -g" ;;
5418    esac ;;
5419none|$undef)
5420    case "$optimize" in
5421	*-g*)	set `echo "X $optimize " | sed 's/ -g / /'`
5422		shift
5423		optimize="$*"
5424		;;
5425    esac ;;
5426esac
5427
5428dflt=''
5429case "$DEBUGGING" in
5430both|$define) dflt='-DDEBUGGING'
5431esac
5432
5433: argument order is deliberate, as the flag will start with - which set could
5434: think is an option
5435checkccflag='check=$1; flag=$2; callback=$3;
5436echo " ";
5437echo "Checking if your compiler accepts $flag" 2>&1;
5438[ "X$sysroot" != "X" ] && echo "For sysroot = $sysroot";
5439echo "int main(void) { return 0; }" > gcctest.c;
5440if $cc $_sysroot -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
5441    echo "Yes, it does." 2>&1;
5442    if $test -s gcctest.out ; then
5443        echo "But your platform does not like it:";
5444        cat gcctest.out;
5445    else
5446	case "$ccflags" in
5447	*$check*)
5448	    echo "Leaving current flags $ccflags alone." 2>&1
5449	    ;;
5450	*) dflt="$dflt $flag";
5451	    eval $callback
5452	    ;;
5453	esac
5454    fi
5455else
5456    echo "Nope, it does not, but that is ok." 2>&1;
5457fi
5458'
5459
5460: We will not override a previous value, but we might want to
5461: augment a hint file
5462case "$hint" in
5463default|recommended)
5464	case "$gccversion" in
5465	1.*) dflt="$dflt -fpcc-struct-return" ;;
5466	esac
5467	case "$optimize:$DEBUGGING" in
5468	*-g*:old) dflt="$dflt -DDEBUGGING";;
5469	esac
5470	case "$gccversion" in
5471	2.*) if $test -d /etc/conf/kconfig.d &&
5472			$contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
5473		then
5474			# Interactive Systems (ISC) POSIX mode.
5475			dflt="$dflt -posix"
5476		fi
5477		;;
5478	esac
5479	case "$gccversion" in
5480	1.*) ;;
5481	2.[0-8]*) ;;
5482	?*)	set strict-aliasing -fno-strict-aliasing
5483		eval $checkccflag
5484		;;
5485	esac
5486	case "$gccversion" in
5487	1*) ;;
5488	2*) ;;
5489	?*) 	echo " "
5490		echo "Checking if your compiler accepts -fno-delete-null-pointer-checks" 2>&1
5491		echo 'int main(void) { return 0; }' > gcctest.c
5492		if $cc -O2 -fno-delete-null-pointer-checks -o gcctest gcctest.c; then
5493			echo "Yes, it does." 2>&1
5494			case "$ccflags" in
5495			*delete-null-pointer-checks*)
5496				echo "Leaving current flags $ccflags alone." 2>&1
5497				;;
5498			*) dflt="$dflt -fno-delete-null-pointer-checks" ;;
5499			esac
5500		else
5501			echo "Nope, it doesn't, but that's ok." 2>&1
5502		fi
5503		;;
5504	esac
5505	# For gcc, adding -pipe speeds up compilations for some, but apparently
5506	# some assemblers can't read from stdin.  (It also slows down compilations
5507	# in other cases, but those are apparently rarer these days.)  AD 5/2004.
5508	case "$gccversion" in
5509	?*)	set pipe -pipe
5510		eval $checkccflag
5511		;;
5512	esac
5513
5514	# on x86_64 (at least) we require an extra library (libssp) in the
5515	# link command line. This library is not named, so I infer that it is
5516	# an implementation detail that may change. Hence the safest approach
5517	# is to add the flag to the flags passed to the compiler at link time,
5518	# as that way the compiler can do the right implementation dependant
5519	# thing. (NWC)
5520	case "$osname" in
5521	amigaos) ;; # -fstack-protector builds but doesn't work
5522	*)	case "$gccversion" in
5523		?*)	set stack-protector-strong -fstack-protector-strong
5524			eval $checkccflag
5525			case "$dflt" in
5526			*-fstack-protector-strong*) ;; # It got added.
5527			*) # Try the plain/older -fstack-protector.
5528			   set stack-protector -fstack-protector
5529			   eval $checkccflag
5530			   ;;
5531			esac
5532			;;
5533		esac
5534		;;
5535	esac
5536	;;
5537esac
5538
5539case "$mips_type" in
5540*BSD*|'') inclwanted="$locincpth $usrinc";;
5541*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
5542esac
5543for thisincl in $inclwanted; do
5544	if $test -d $thisincl; then
5545		if $test x$thisincl != x$usrinc; then
5546			case "$dflt" in
5547			*" -I$thisincl "*);;
5548			*) dflt="$dflt -I$thisincl ";;
5549			esac
5550		fi
5551	fi
5552done
5553
5554inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
5555	xxx=true;
5556elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
5557	xxx=true;
5558else
5559	xxx=false;
5560fi;
5561if $xxx; then
5562	case "$dflt" in
5563	*$2*);;
5564	*) dflt="$dflt -D$2";;
5565	esac;
5566fi'
5567
5568set signal.h LANGUAGE_C; eval $inctest
5569
5570case "$usesocks" in
5571$define)
5572	ccflags="$ccflags -DSOCKS"
5573	;;
5574esac
5575
5576case "$hint" in
5577default|recommended) dflt="$ccflags $dflt" ;;
5578*) dflt="$ccflags";;
5579esac
5580
5581case "$dflt" in
5582''|' ') dflt=none;;
5583esac
5584
5585$cat <<EOH
5586
5587Your C compiler may want other flags.  For this question you should include
5588-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
5589but you should NOT include libraries or ld flags like -lwhatever.  If you
5590want $package to honor its debug switch, you should include -DDEBUGGING here.
5591Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
5592
5593To use no flags, specify the word "none".
5594
5595EOH
5596set X $dflt
5597shift
5598dflt=${1+"$@"}
5599rp="Any additional cc flags?"
5600. ./myread
5601case "$ans" in
5602none) ccflags='';;
5603*) ccflags="$ans";;
5604esac
5605
5606: the following weeds options from ccflags that are of no interest to cpp
5607case "$cppflags" in
5608'') cppflags="$ccflags" ;;
5609*)  set X $ccflags; shift
5610    case " $cppflags " in
5611    *" $1 "*) ;;  # Try to avoid doubling the cppflags.
5612    *) cppflags="$cppflags $ccflags" ;;
5613    esac
5614    ;;
5615esac
5616case "$gccversion" in
56171.*) cppflags="$cppflags -D__GNUC__"
5618esac
5619case "$mips_type" in
5620'');;
5621*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
5622esac
5623case "$cppflags" in
5624'');;
5625*)
5626	echo " "
5627	echo "Let me guess what the preprocessor flags are..." >&4
5628	set X $cppflags
5629	shift
5630	cppflags=''
5631	$cat >cpp.c <<'EOM'
5632#define BLURFL foo
5633
5634BLURFL xx LFRULB
5635EOM
5636	previous=''
5637	for flag in $*
5638	do
5639		case "$flag" in
5640		-*) ftry="$flag";;
5641		*) ftry="$previous $flag";;
5642		esac
5643		if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
5644			>cpp1.out 2>/dev/null && \
5645			$cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
5646			>cpp2.out 2>/dev/null && \
5647			$contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
5648			$contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
5649		then
5650			cppflags="$cppflags $ftry"
5651			previous=''
5652		else
5653			previous="$flag"
5654		fi
5655	done
5656	set X $cppflags
5657	shift
5658	cppflags=${1+"$@"}
5659	case "$cppflags" in
5660	*-*)  echo "They appear to be: $cppflags";;
5661	esac
5662	$rm -f cpp.c cpp?.out
5663	;;
5664esac
5665
5666: flags used in final linking phase
5667case "$ldflags" in
5668'') if ./venix; then
5669		dflt='-i -z'
5670	else
5671		dflt=''
5672	fi
5673	case "$ccflags" in
5674	*-posix*) dflt="$dflt -posix" ;;
5675	esac
5676	;;
5677*) dflt="$ldflags";;
5678esac
5679# See note above about -fstack-protector
5680case "$ccflags" in
5681*-fstack-protector-strong*)
5682	case "$dflt" in
5683	*-fstack-protector-strong*) ;; # Don't add it again
5684	*) dflt="$dflt -fstack-protector-strong" ;;
5685	esac
5686	;;
5687*-fstack-protector*)
5688	case "$dflt" in
5689	*-fstack-protector*) ;; # Don't add it again
5690	*) dflt="$dflt -fstack-protector" ;;
5691	esac
5692	;;
5693esac
5694
5695: Try to guess additional flags to pick up local libraries.
5696for thislibdir in $libpth; do
5697	case " $loclibpth " in
5698	*" $thislibdir "*)
5699		case "$dflt " in
5700		*"-L$thislibdir "*) ;;
5701		*)  dflt="$dflt -L$thislibdir" ;;
5702		esac
5703		;;
5704	esac
5705done
5706
5707case "$dflt" in
5708'') dflt='none' ;;
5709esac
5710
5711$cat <<EOH
5712
5713Your C linker may need flags.  For this question you should
5714include -L/whatever and any other flags used by the C linker, but you
5715should NOT include libraries like -lwhatever.
5716
5717Make sure you include the appropriate -L/path flags if your C linker
5718does not normally search all of the directories you specified above,
5719namely
5720	$libpth
5721To use no flags, specify the word "none".
5722
5723EOH
5724
5725rp="Any additional ld flags (NOT including libraries)?"
5726. ./myread
5727case "$ans" in
5728none) ldflags='';;
5729*) ldflags="$ans";;
5730esac
5731rmlist="$rmlist pdp11"
5732
5733: coherency check
5734echo " "
5735echo "Checking your choice of C compiler and flags for coherency..." >&4
5736$cat > try.c <<'EOF'
5737#include <stdio.h>
5738int main() { printf("Ok\n"); return(0); }
5739EOF
5740set X $cc -o try $optimize $ccflags $ldflags try.c $libs
5741shift
5742$cat >try.msg <<'EOM'
5743I've tried to compile and run the following simple program:
5744
5745EOM
5746$cat try.c >> try.msg
5747
5748$cat >> try.msg <<EOM
5749
5750I used the command:
5751
5752	$*
5753	$run ./try
5754
5755and I got the following output:
5756
5757EOM
5758dflt=y
5759if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; then
5760	if $sh -c "$run ./try " >>try.msg 2>&1; then
5761		xxx=`$run ./try`
5762		case "$xxx" in
5763		"Ok") dflt=n ;;
5764		*)    echo 'The program compiled OK, but produced no output.' >> try.msg ;;
5765		esac
5766	else
5767		echo "The program compiled OK, but exited with status $?." >>try.msg
5768		rp="You have a problem.  Shall I abort Configure"
5769		dflt=y
5770	fi
5771else
5772	echo "I can't compile the test program." >>try.msg
5773	rp="You have a BIG problem.  Shall I abort Configure"
5774	dflt=y
5775fi
5776case "$dflt" in
5777y)
5778	$cat try.msg >&4
5779	case "$knowitall" in
5780	'')
5781		echo "(The supplied flags or libraries might be incorrect.)"
5782		;;
5783	*) dflt=n;;
5784	esac
5785	echo " "
5786	. ./myread
5787	case "$ans" in
5788	n*|N*) ;;
5789	*)	echo "Ok.  Stopping Configure." >&4
5790		exit 1
5791		;;
5792	esac
5793	;;
5794n) echo "OK, that should do.";;
5795esac
5796$rm_try gcctest gcctest.out
5797
5798: define a shorthand compile call
5799compile='
5800mc_file=$1;
5801shift;
5802case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
5803echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to https://github.com/Perl/perl5/issues" >&4;
5804exit 1;
5805fi;
5806esac;
5807$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5808: define a shorthand compile call for compilations that should be ok.
5809compile_ok='
5810mc_file=$1;
5811shift;
5812$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5813
5814: stub, used only to satisfy other units
5815i_stdlib='define'
5816
5817: check for lengths of integral types
5818echo " "
5819case "$intsize" in
5820'')
5821	echo "Checking to see how big your integers are..." >&4
5822	$cat >try.c <<EOCP
5823#include <stdio.h>
5824#$i_stdlib I_STDLIB
5825#ifdef I_STDLIB
5826#include <stdlib.h>
5827#endif
5828int main()
5829{
5830	printf("intsize=%d;\n", (int)sizeof(int));
5831	printf("longsize=%d;\n", (int)sizeof(long));
5832	printf("shortsize=%d;\n", (int)sizeof(short));
5833	exit(0);
5834}
5835EOCP
5836	set try
5837	if eval $compile_ok && $run ./try > /dev/null; then
5838		eval `$run ./try`
5839		echo "Your integers are $intsize bytes long."
5840		echo "Your long integers are $longsize bytes long."
5841		echo "Your short integers are $shortsize bytes long."
5842	else
5843		$cat >&4 <<EOM
5844!
5845Help! I can't compile and run the intsize test program: please enlighten me!
5846(This is probably a misconfiguration in your system or libraries, and
5847you really ought to fix it.  Still, I'll try anyway.)
5848!
5849EOM
5850		dflt=4
5851		rp="What is the size of an integer (in bytes)?"
5852		. ./myread
5853		intsize="$ans"
5854		dflt=$intsize
5855		rp="What is the size of a long integer (in bytes)?"
5856		. ./myread
5857		longsize="$ans"
5858		dflt=2
5859		rp="What is the size of a short integer (in bytes)?"
5860		. ./myread
5861		shortsize="$ans"
5862	fi
5863	;;
5864esac
5865$rm_try
5866
5867: check for long long
5868echo " "
5869echo "Checking to see if you have long long..." >&4
5870echo 'int main() { long long x = 7; return 0; }' > try.c
5871set try
5872if eval $compile; then
5873	val="$define"
5874	echo "You have long long."
5875else
5876	val="$undef"
5877	echo "You do not have long long."
5878fi
5879$rm_try
5880set d_longlong
5881eval $setvar
5882
5883: check for length of long long
5884case "${d_longlong}${longlongsize}" in
5885$define)
5886	echo " "
5887	echo "Checking to see how big your long longs are..." >&4
5888	$cat >try.c <<'EOCP'
5889#include <stdio.h>
5890int main()
5891{
5892    printf("%d\n", (int)sizeof(long long));
5893    return(0);
5894}
5895EOCP
5896	set try
5897	if eval $compile_ok; then
5898		longlongsize=`$run ./try`
5899		echo "Your long longs are $longlongsize bytes long."
5900	else
5901		dflt='8'
5902		echo " "
5903		echo "(I can't seem to compile the test program.  Guessing...)"
5904		rp="What is the size of a long long (in bytes)?"
5905		. ./myread
5906		longlongsize="$ans"
5907	fi
5908	if $test "X$longsize" = "X$longlongsize"; then
5909		echo "(That isn't any different from an ordinary long.)"
5910	fi
5911	;;
5912esac
5913$rm_try
5914
5915: determine filename position in cpp output
5916echo " "
5917echo "Computing filename position in cpp output for #include directives..." >&4
5918case "$osname" in
5919amigaos) fieldn=3 ;;  # Workaround for a bug in abc (pdksh).
5920esac
5921case "$fieldn" in
5922'')
5923case "$osname" in
5924vos) testaccess=-e ;;
5925*)   testaccess=-r ;;
5926esac
5927echo '#include <stdio.h>' > foo.c
5928$cat >fieldn <<EOF
5929$startsh
5930$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
5931$grep '^[ 	]*#.*stdio\.h' | \
5932while read cline; do
5933	pos=1
5934	set \$cline
5935	while $test \$# -gt 0; do
5936		if $test $testaccess \`echo \$1 | $tr -d '"'\`; then
5937			echo "\$pos"
5938			exit 0
5939		fi
5940		shift
5941		pos=\`expr \$pos + 1\`
5942	done
5943done
5944EOF
5945chmod +x fieldn
5946fieldn=`./fieldn`
5947$rm -f foo.c fieldn
5948;;
5949esac
5950case $fieldn in
5951'') pos='???';;
59521) pos=first;;
59532) pos=second;;
59543) pos=third;;
5955*) pos="${fieldn}th";;
5956esac
5957echo "Your cpp writes the filename in the $pos field of the line."
5958
5959: locate header file
5960$cat >findhdr <<EOF
5961$startsh
5962wanted=\$1
5963name=''
5964for usrincdir in $incpth
5965do
5966	if test -f \$usrincdir/\$wanted; then
5967		echo "\$usrincdir/\$wanted"
5968		exit 0
5969	fi
5970done
5971awkprg='{ print \$$fieldn }'
5972echo "#include <\$wanted>" > foo\$\$.c
5973$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
5974$cppfilter $grep "^[ 	]*#.*\$wanted" | \
5975while read cline; do
5976	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
5977	case "\$name" in
5978	*[/\\\\]\$wanted) echo "\$name"; exit 1;;
5979	*[\\\\/]\$wanted) echo "\$name"; exit 1;;
5980	*) exit 2;;
5981	esac;
5982done;
5983#
5984# status = 0: grep returned 0 lines, case statement not executed
5985# status = 1: headerfile found
5986# status = 2: while loop executed, no headerfile found
5987#
5988status=\$?
5989$rm -f foo\$\$.c;
5990if test \$status -eq 1; then
5991	exit 0;
5992fi
5993exit 1
5994EOF
5995chmod +x findhdr
5996
5997: define an alternate in-header-list? function
5998inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
5999cont=true; xxf="echo \"<\$1> found.\" >&4";
6000case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
6001*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
6002esac;
6003case $# in 4) instead=instead;; *) instead="at last";; esac;
6004while $test "$cont"; do
6005	xxx=`./findhdr $1`
6006	var=$2; eval "was=\$$2";
6007	if $test "$xxx" && $test -r "$xxx";
6008	then eval $xxf;
6009	eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
6010		cont="";
6011	else eval $xxnf;
6012	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
6013	set $yyy; shift; shift; yyy=$@;
6014	case $# in 0) cont="";;
6015	2) xxf="echo \"but I found <\$1> $instead.\" >&4";
6016		xxnf="echo \"and I did not find <\$1> either.\" >&4";;
6017	*) xxf="echo \"but I found <\$1\> instead.\" >&4";
6018		xxnf="echo \"there is no <\$1>, ...\" >&4";;
6019	esac;
6020done;
6021while $test "$yyy";
6022do set $yyy; var=$2; eval "was=\$$2";
6023	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
6024	set $yyy; shift; shift; yyy=$@;
6025done'
6026
6027: see if inttypes.h is available
6028: we want a real compile instead of Inhdr because some systems
6029: have an inttypes.h which includes non-existent headers
6030echo " "
6031$cat >try.c <<EOCP
6032#include <inttypes.h>
6033int main() {
6034	static int32_t foo32 = 0x12345678;
6035}
6036EOCP
6037set try
6038if eval $compile; then
6039	echo "<inttypes.h> found." >&4
6040	val="$define"
6041else
6042	echo "<inttypes.h> NOT found." >&4
6043	val="$undef"
6044fi
6045$rm_try
6046set i_inttypes
6047eval $setvar
6048
6049: check for int64_t
6050echo " "
6051echo "Checking to see if you have int64_t..." >&4
6052$cat >try.c <<EOCP
6053#include <sys/types.h>
6054#$i_inttypes I_INTTYPES
6055#ifdef I_INTTYPES
6056#include <inttypes.h>
6057#endif
6058int main() { int64_t x = 7; }
6059EOCP
6060set try
6061if eval $compile; then
6062	val="$define"
6063	echo "You have int64_t."
6064else
6065	val="$undef"
6066	echo "You do not have int64_t."
6067fi
6068$rm_try
6069set d_int64_t
6070eval $setvar
6071
6072: Check if 64bit ints have a quad type
6073echo " "
6074echo "Checking which 64-bit integer type we could use..." >&4
6075
6076case "$intsize" in
60778) val=int
6078   set quadtype
6079   eval $setvar
6080   val='"unsigned int"'
6081   set uquadtype
6082   eval $setvar
6083   quadkind=1
6084   ;;
6085*) case "$longsize" in
6086   8) val=long
6087      set quadtype
6088      eval $setvar
6089      val='"unsigned long"'
6090      set uquadtype
6091      eval $setvar
6092      quadkind=2
6093      ;;
6094   *) case "$d_longlong:$longlongsize" in
6095      define:8)
6096        val='"long long"'
6097        set quadtype
6098        eval $setvar
6099        val='"unsigned long long"'
6100        set uquadtype
6101        eval $setvar
6102        quadkind=3
6103        ;;
6104      *) case "$d_int64_t" in
6105         define)
6106           val=int64_t
6107           set quadtype
6108           eval $setvar
6109           val=uint64_t
6110           set uquadtype
6111           eval $setvar
6112           quadkind=4
6113           ;;
6114         esac
6115         ;;
6116      esac
6117      ;;
6118   esac
6119   ;;
6120esac
6121
6122case "$quadtype" in
6123'')	echo "Alas, no 64-bit integer types in sight." >&4
6124	d_quad="$undef"
6125	;;
6126*)	echo "We could use '$quadtype' for 64-bit integers." >&4
6127	d_quad="$define"
6128	;;
6129esac
6130
6131: Do we want 64bit support
6132case "$uselonglong" in
6133"$define"|true|[yY]*)
6134	cat <<EOM >&4
6135
6136*** Configure -Duselonglong is deprecated, using -Duse64bitint instead.
6137EOM
6138	use64bitint="$define"
6139	;;
6140esac
6141case "$use64bits" in
6142"$define"|true|[yY]*)
6143	cat <<EOM >&4
6144
6145*** Configure -Duse64bits is deprecated, using -Duse64bitint instead.
6146EOM
6147	use64bitint="$define"
6148	;;
6149esac
6150case "$use64bitints" in
6151"$define"|true|[yY]*)
6152	cat <<EOM >&4
6153
6154*** There is no Configure -Duse64bitints, using -Duse64bitint instead.
6155EOM
6156	use64bitint="$define"
6157	;;
6158esac
6159case "$use64bitsint" in
6160"$define"|true|[yY]*)
6161	cat <<EOM >&4
6162
6163*** There is no Configure -Duse64bitsint, using -Duse64bitint instead.
6164EOM
6165	use64bitint="$define"
6166	;;
6167esac
6168case "$uselonglongs" in
6169"$define"|true|[yY]*)
6170	cat <<EOM >&4
6171
6172*** There is no Configure -Duselonglongs, using -Duse64bitint instead.
6173EOM
6174	use64bitint="$define"
6175	;;
6176esac
6177case "$use64bitsall" in
6178"$define"|true|[yY]*)
6179	cat <<EOM >&4
6180
6181*** There is no Configure -Duse64bitsall, using -Duse64bitall instead.
6182EOM
6183	use64bitall="$define"
6184	;;
6185esac
6186
6187case "$ccflags" in
6188*-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
6189esac
6190case "$use64bitall" in
6191"$define"|true|[yY]*) use64bitint="$define" ;;
6192esac
6193
6194case "$longsize" in
61958) cat <<EOM
6196
6197You have natively 64-bit long integers.
6198EOM
6199   val="$define"
6200   ;;
6201*) case "$use64bitint" in
6202   "$define"|true|[yY]*) dflt='y';;
6203   *) dflt='n';;
6204   esac
6205   case "$d_quad" in
6206   "$define") ;;
6207   *) dflt='n' ;;
6208   esac
6209   cat <<EOM
6210
6211Perl can be built to take advantage of 64-bit integer types
6212on some systems.  To do so, Configure can be run with -Duse64bitint.
6213Choosing this option will most probably introduce binary incompatibilities.
6214
6215If this doesn't make any sense to you, just accept the default '$dflt'.
6216(The default has been chosen based on your configuration.)
6217EOM
6218   rp='Try to use 64-bit integers, if available?'
6219   . ./myread
6220   case "$ans" in
6221   [yY]*) val="$define" ;;
6222   *)     val="$undef"  ;;
6223   esac
6224   ;;
6225esac
6226set use64bitint
6227eval $setvar
6228
6229case "$use64bitall" in
6230"$define"|true|[yY]*) dflt='y' ;;
6231*) case "$longsize" in
6232   8) dflt='y' ;;
6233   *) dflt='n' ;;
6234   esac
6235   ;;
6236esac
6237cat <<EOM
6238
6239You may also choose to try maximal 64-bitness.  It means using as much
624064-bitness as possible on the platform.  This in turn means even more
6241binary incompatibilities.  On the other hand, your platform may not
6242have any more 64-bitness available than what you already have chosen.
6243
6244If this doesn't make any sense to you, just accept the default '$dflt'.
6245(The default has been chosen based on your configuration.)
6246EOM
6247rp='Try to use maximal 64-bit support, if available?'
6248. ./myread
6249case "$ans" in
6250[yY]*) val="$define" ;;
6251*)     val="$undef"  ;;
6252esac
6253set use64bitall
6254eval $setvar
6255case "$use64bitall" in
6256"$define")
6257	case "$use64bitint" in
6258	"$undef")
6259		cat <<EOM
6260
6261Since you have chosen a maximally 64-bit build, I'm also turning on
6262the use of 64-bit integers.
6263EOM
6264		use64bitint="$define" ;;
6265	esac
6266	;;
6267esac
6268
6269: Look for a hint-file generated 'call-back-unit'.  If the
6270: user has specified that a 64-bit perl is to be built,
6271: we may need to set or change some other defaults.
6272if $test -f use64bitint.cbu; then
6273	echo "Your platform has some specific hints regarding 64-bit integers, using them..."
6274	. ./use64bitint.cbu
6275fi
6276case "$use64bitint" in
6277"$define"|true|[yY]*)
6278	: This test was common to all the OpenBSD forks, and seems harmless for
6279	: other platforms:
6280	echo " "
6281	echo "Checking if your C library has broken 64-bit functions..." >&4
6282	cat >try.c <<EOCP
6283#include <stdio.h>
6284typedef $uquadtype myULL;
6285int main (void)
6286{
6287    struct {
6288	double d;
6289	myULL  u;
6290    } *p, test[] = {
6291	{4294967303.15, 4294967303ULL},
6292	{4294967294.2,  4294967294ULL},
6293	{4294967295.7,  4294967295ULL},
6294	{0.0, 0ULL}
6295    };
6296    for (p = test; p->u; p++) {
6297	myULL x = (myULL)p->d;
6298	if (x != p->u) {
6299	    printf("buggy\n");
6300	    return 0;
6301	}
6302    }
6303    printf("ok\n");
6304    return 0;
6305}
6306EOCP
6307	set try
6308	if eval $compile_ok; then
6309	    libcquad=`$run ./try`
6310	    echo "Your C library's 64-bit functions are $libcquad."
6311	else
6312	    echo "(I can't seem to compile the test program.)"
6313	    echo "Assuming that your C library's 64-bit functions are ok."
6314	    libcquad="ok"
6315	fi
6316	$rm_try
6317
6318	case "$libcquad" in
6319	    buggy*)
6320		cat >&4 <<EOM
6321
6322*** You have a C library with broken 64-bit functions.
6323*** 64-bit support does not work reliably in this configuration.
6324*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6325*** Cannot continue, aborting.
6326
6327EOM
6328		exit 1
6329		;;
6330	esac
6331	case "$longsize" in
6332	4) case "$archname64" in
6333	   '') archname64=64int ;;
6334	   esac
6335	   ;;
6336	esac
6337	;;
6338esac
6339
6340: Look for a hint-file generated 'call-back-unit'.  If the
6341: user has specified that a maximally 64-bit perl is to be built,
6342: we may need to set or change some other defaults.
6343if $test -f use64bitall.cbu; then
6344	echo "Your platform has some specific hints regarding 64-bit builds, using them..."
6345	. ./use64bitall.cbu
6346fi
6347case "$use64bitall" in
6348"$define"|true|[yY]*)
6349	case "$longsize" in
6350	4) case "$archname64" in
6351	   ''|64int) archname64=64all ;;
6352	   esac
6353	   ;;
6354	esac
6355	;;
6356esac
6357
6358case "$d_quad:$use64bitint" in
6359$undef:$define)
6360	cat >&4 <<EOF
6361
6362*** You have chosen to use 64-bit integers,
6363*** but none can be found.
6364*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6365*** Cannot continue, aborting.
6366
6367EOF
6368	exit 1
6369	;;
6370esac
6371
6372: Check if we are using the GNU C library
6373echo " "
6374echo "Checking for GNU C Library..." >&4
6375cat >try.c <<'EOCP'
6376/* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
6377   alone are insufficient to distinguish different versions, such as
6378   2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
6379   libc version 2.1.0.      A. Dougherty,  June 3, 2002.
6380*/
6381#include <stdio.h>
6382int main(void)
6383{
6384#ifdef __GLIBC__
6385#   ifdef __GLIBC_MINOR__
6386#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
6387#           include <gnu/libc-version.h>
6388	    printf("%s\n",  gnu_get_libc_version());
6389#       else
6390	    printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
6391#       endif
6392#   else
6393	printf("%d\n",  __GLIBC__);
6394#   endif
6395    return 0;
6396#else
6397    return 1;
6398#endif
6399}
6400EOCP
6401set try
6402if eval $compile_ok && $run ./try > glibc.ver; then
6403	val="$define"
6404	gnulibc_version=`$cat glibc.ver`
6405	echo "You are using the GNU C Library version $gnulibc_version"
6406else
6407	val="$undef"
6408	gnulibc_version=''
6409	echo "You are not using the GNU C Library"
6410fi
6411$rm_try glibc.ver
6412set d_gnulibc
6413eval $setvar
6414
6415: see if nm is to be used to determine whether a symbol is defined or not
6416case "$usenm" in
6417'')
6418	dflt=''
6419	case "$d_gnulibc" in
6420	"$define")
6421		echo " "
6422		echo "nm probably won't work on the GNU C Library." >&4
6423		dflt=n
6424		;;
6425	esac
6426	case "$dflt" in
6427	'')
6428		if $test "$osname" = aix -a "X$PASE" != "Xdefine" -a ! -f /lib/syscalls.exp; then
6429			echo " "
6430			echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
6431			echo "'nm' won't be sufficient on this system." >&4
6432			dflt=n
6433		fi
6434		;;
6435	esac
6436	case "$dflt" in
6437	'') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
6438		if $test $dflt -gt 20; then
6439			dflt=y
6440		else
6441			dflt=n
6442		fi
6443		;;
6444	esac
6445	;;
6446*)
6447	case "$usenm" in
6448	true|$define) dflt=y;;
6449	*) dflt=n;;
6450	esac
6451	;;
6452esac
6453$cat <<EOM
6454
6455I can use $nm to extract the symbols from your C libraries. This
6456is a time consuming task which may generate huge output on the disk (up
6457to 3 megabytes) but that should make the symbols extraction faster. The
6458alternative is to skip the 'nm' extraction part and to compile a small
6459test program instead to determine whether each symbol is present. If
6460you have a fast C compiler and/or if your 'nm' output cannot be parsed,
6461this may be the best solution.
6462
6463You probably shouldn't let me use 'nm' if you are using the GNU C Library.
6464
6465EOM
6466rp="Shall I use $nm to extract C symbols from the libraries?"
6467. ./myread
6468case "$ans" in
6469[Nn]*) usenm=false;;
6470*) usenm=true;;
6471esac
6472
6473runnm=$usenm
6474case "$reuseval" in
6475true) runnm=false;;
6476esac
6477
6478: nm options which may be necessary
6479case "$nm_opt" in
6480'') if $test -f /mach_boot; then
6481		nm_opt=''	# Mach
6482	elif $test -d /usr/ccs/lib; then
6483		nm_opt='-p'	# Solaris (and SunOS?)
6484	elif $test -f /dgux; then
6485		nm_opt='-p'	# DG-UX
6486	elif $test -f /lib64/rld; then
6487		nm_opt='-p'	# 64-bit Irix
6488	else
6489		nm_opt=''
6490	fi;;
6491esac
6492
6493: nm options which may be necessary for shared libraries but illegal
6494: for archive libraries.  Thank you, Linux.
6495case "$nm_so_opt" in
6496'')	case "$myuname" in
6497	*linux*|gnu*)
6498		if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
6499			nm_so_opt='--dynamic'
6500		fi
6501		;;
6502	esac
6503	;;
6504esac
6505
6506: Figure out where the libc is located
6507case "$runnm" in
6508true)
6509: get list of predefined functions in a handy place
6510echo " "
6511case "$libc" in
6512'') libc=unknown
6513	case "$libs" in
6514	*-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
6515	esac
6516	;;
6517esac
6518case "$libs" in
6519'') ;;
6520*)  for thislib in $libs; do
6521	case "$thislib" in
6522	-lc|-lc_s)
6523		: Handle C library specially below.
6524		;;
6525	-l*)
6526		thislib=`echo $thislib | $sed -e 's/^-l//'`
6527		if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
6528			:
6529		elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
6530			:
6531		elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
6532			:
6533		elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
6534			:
6535		elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
6536			:
6537		elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
6538			:
6539		elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
6540			:
6541		else
6542			try=''
6543		fi
6544		libnames="$libnames $try"
6545		;;
6546	*) libnames="$libnames $thislib" ;;
6547	esac
6548	done
6549	;;
6550esac
6551xxx=normal
6552case "$libc" in
6553unknown)
6554	set /lib/libc.$so
6555	for xxx in $libpth; do
6556		$test -r $1 || set $xxx/libc.$so
6557		: The messy sed command sorts on library version numbers.
6558		$test -r $1 || \
6559			set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
6560			tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
6561				h
6562				s/[0-9][0-9]*/0000&/g
6563				s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
6564				G
6565				s/\n/ /' | \
6566			 $sort | $sed -e 's/^.* //'`
6567		eval set \$$#
6568	done
6569	$test -r $1 || set $sysroot/usr/ccs/lib/libc.$so
6570	$test -r $1 || set $sysroot/lib/libsys_s$_a
6571	;;
6572*)
6573	set blurfl
6574	;;
6575esac
6576if $test -r "$1"; then
6577	echo "Your (shared) C library seems to be in $1."
6578	libc="$1"
6579elif $test -r /lib/libc && $test -r /lib/clib; then
6580	echo "Your C library seems to be in both /lib/clib and /lib/libc."
6581	xxx=apollo
6582	libc='/lib/clib /lib/libc'
6583	if $test -r /lib/syslib; then
6584		echo "(Your math library is in /lib/syslib.)"
6585		libc="$libc /lib/syslib"
6586	fi
6587elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
6588	echo "Your C library seems to be in $libc, as you said before."
6589elif $test -r $incpath/usr/lib/libc$_a; then
6590	libc=$incpath/usr/lib/libc$_a;
6591	echo "Your C library seems to be in $libc.  That's fine."
6592elif $test -r /lib/libc$_a; then
6593	libc=/lib/libc$_a;
6594	echo "Your C library seems to be in $libc.  You're normal."
6595else
6596	if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
6597		:
6598	elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
6599		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
6600	elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
6601		:
6602	elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
6603		:
6604	elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
6605		:
6606	else
6607		tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
6608	fi
6609	if $test -r "$tans"; then
6610		echo "Your C library seems to be in $tans, of all places."
6611		libc=$tans
6612	else
6613		libc='blurfl'
6614	fi
6615fi
6616if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
6617	dflt="$libc"
6618	cat <<EOM
6619
6620If the guess above is wrong (which it might be if you're using a strange
6621compiler, or your machine supports multiple models), you can override it here.
6622
6623EOM
6624else
6625	dflt=''
6626	echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
6627	cat >&4 <<EOM
6628I can't seem to find your C library.  I've looked in the following places:
6629
6630EOM
6631	$sed 's/^/	/' libpath
6632	cat <<EOM
6633
6634None of these seems to contain your C library. I need to get its name...
6635
6636EOM
6637fi
6638fn=f
6639rp='Where is your C library?'
6640. ./getfile
6641libc="$ans"
6642
6643echo " "
6644echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
6645set X `cat libnames`
6646shift
6647xxx=files
6648case $# in 1) xxx=file; esac
6649echo "Extracting names from the following $xxx for later perusal:" >&4
6650echo " "
6651$sed 's/^/	/' libnames >&4
6652echo " "
6653$echo $n "This may take a while...$c" >&4
6654
6655for file in $*; do
6656	case $file in
6657	*$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
6658	*) $nm $nm_opt $file 2>/dev/null;;
6659	esac
6660done >libc.tmp
6661
6662$echo $n ".$c"
6663$grep fprintf libc.tmp > libc.ptf
6664xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
6665xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
6666xxx='[ADTSIWi]'
6667if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
6668	eval $xscan;\
6669	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6670		eval $xrun
6671elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
6672	eval $xscan;\
6673	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6674		eval $xrun
6675elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
6676	eval $xscan;\
6677	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6678		eval $xrun
6679elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
6680	eval $xscan;\
6681	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6682		eval $xrun
6683elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
6684	eval $xscan;\
6685	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6686		eval $xrun
6687elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
6688	eval $xscan;\
6689	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6690		eval $xrun
6691elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
6692				-e '/ file/d' -e 's/^\([^ 	]*\).*/\1/p'";\
6693	eval $xscan;\
6694	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6695		eval $xrun
6696elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
6697	eval $xscan;\
6698	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6699		eval $xrun
6700elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
6701	eval $xscan;\
6702	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6703		eval $xrun
6704elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
6705	eval $xscan;\
6706	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6707		eval $xrun
6708elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
6709	eval $xscan;\
6710	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6711		eval $xrun
6712elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
6713	eval $xscan;\
6714	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6715		eval $xrun
6716elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
6717	eval $xscan;\
6718	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6719		eval $xrun
6720elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
6721	eval $xscan;\
6722	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6723		eval $xrun
6724else
6725	$nm -p $* 2>/dev/null >libc.tmp
6726	$grep fprintf libc.tmp > libc.ptf
6727	if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
6728		eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
6729	then
6730		nm_opt='-p'
6731		eval $xrun
6732	else
6733		echo " "
6734		echo "$nm didn't seem to work right. Trying $ar instead..." >&4
6735		com=''
6736		if $ar t $libc > libc.tmp && \
6737			$contains '^fprintf$' libc.tmp >/dev/null 2>&1
6738		then
6739			for thisname in $libnames $libc; do
6740				$ar t $thisname >>libc.tmp
6741			done
6742			$sed -e "s/\\$_o\$//" < libc.tmp > libc.list
6743			echo "Ok." >&4
6744		elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
6745			for thisname in $libnames $libc; do
6746				$ar tv $thisname >>libc.tmp
6747				emximp -o tmp.imp $thisname \
6748				    2>/dev/null && \
6749				    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
6750				    < tmp.imp >>libc.tmp
6751				$rm -f tmp.imp
6752			done
6753			$sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
6754			echo "Ok." >&4
6755		else
6756			echo "$ar didn't seem to work right." >&4
6757			echo "Maybe this is a Cray...trying bld instead..." >&4
6758			if  bld t $libc | \
6759				$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list &&
6760				$test -s libc.list
6761			then
6762				for thisname in $libnames; do
6763					bld t $libnames | \
6764					$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
6765					$ar t $thisname >>libc.tmp
6766				done
6767				echo "Ok." >&4
6768			else
6769				echo "That didn't work either.  Giving up." >&4
6770				exit 1
6771			fi
6772		fi
6773	fi
6774fi
6775nm_extract="$com"
6776case "$PASE" in
6777define)
6778    echo " "
6779    echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
6780    dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
6781    ;;
6782*)  if $test -f /lib/syscalls.exp; then
6783	echo " "
6784	echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
6785	$sed -n 's/^\([^ 	]*\)[ 	]*syscall[0-9]*[ 	]*$/\1/p' \
6786		/lib/syscalls.exp >>libc.list
6787    fi
6788    ;;
6789esac
6790;;
6791esac
6792$rm -f libnames libpath
6793
6794: Check if we are using C++
6795echo " "
6796echo "Checking for C++..." >&4
6797$cat >try.c <<'EOCP'
6798#include <stdio.h>
6799int main(void)
6800{
6801#ifdef __cplusplus
6802    return 0;
6803#else
6804    return 1;
6805#endif
6806}
6807EOCP
6808set try
6809if eval $compile_ok && $run ./try; then
6810	val="$define"
6811	echo "You are using a C++ compiler."
6812else
6813	val="$undef"
6814	echo "You are not using a C++ compiler."
6815fi
6816$rm_try cplusplus$$
6817set d_cplusplus
6818eval $setvar
6819
6820: is a C symbol defined?
6821csym='tlook=$1;
6822case "$3" in
6823-v) tf=libc.tmp; tdc="";;
6824-a) tf=libc.tmp; tdc="[]";;
6825*) tlook="^$1\$"; tf=libc.list; tdc="()";;
6826esac;
6827case "$d_cplusplus" in
6828    $define)	extern_C="extern \"C\""	;;
6829    *)		extern_C="extern"	;;
6830esac;
6831tx=yes;
6832case "$reuseval-$4" in
6833true-) ;;
6834true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
6835esac;
6836case "$tx" in
6837yes)
6838	tval=false;
6839	if $test "$runnm" = true; then
6840		if $contains $tlook $tf >/dev/null 2>&1; then
6841			tval=true;
6842		elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
6843			echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main(int argc, char **argv) { if(p() && p() != (void *)argv[0]) return(0); else return(1); }"> try.c;
6844			$cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
6845			$test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
6846			$rm_try;
6847		fi;
6848	else
6849		echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main(int argc, char **argv) { if(p() && p() != (void *)argv[0]) return(0); else return(1); }"> try.c;
6850		$cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
6851		$rm_try;
6852	fi;
6853	;;
6854*)
6855	case "$tval" in
6856	$define) tval=true;;
6857	*) tval=false;;
6858	esac;
6859	;;
6860esac;
6861eval "$2=$tval"'
6862
6863: define an is-in-libc? function
6864inlibc='echo " "; td=$define; tu=$undef;
6865sym=$1; var=$2; eval "was=\$$2";
6866tx=yes;
6867case "$reuseval$was" in
6868true) ;;
6869true*) tx=no;;
6870esac;
6871case "$tx" in
6872yes)
6873	set $sym tres -f;
6874	eval $csym;
6875	case "$tres" in
6876	true)
6877		echo "$sym() found." >&4;
6878		case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
6879	*)
6880		echo "$sym() NOT found." >&4;
6881		case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
6882	esac;;
6883*)
6884	case "$was" in
6885	$define) echo "$sym() found." >&4;;
6886	*) echo "$sym() NOT found." >&4;;
6887	esac;;
6888esac'
6889
6890: check for length of double
6891echo " "
6892case "$doublesize" in
6893'')
6894	echo "Checking to see how big your double precision numbers are..." >&4
6895	$cat >try.c <<EOCP
6896#include <stdio.h>
6897#$i_stdlib I_STDLIB
6898#ifdef I_STDLIB
6899#include <stdlib.h>
6900#endif
6901int main()
6902{
6903    printf("%d\n", (int)sizeof(double));
6904    exit(0);
6905}
6906EOCP
6907	set try
6908	if eval $compile_ok; then
6909		doublesize=`$run ./try`
6910		echo "Your double is $doublesize bytes long."
6911	else
6912		dflt='8'
6913		echo "(I can't seem to compile the test program.  Guessing...)"
6914		rp="What is the size of a double precision number (in bytes)?"
6915		. ./myread
6916		doublesize="$ans"
6917	fi
6918	;;
6919esac
6920$rm_try
6921
6922: check for long doubles
6923echo " "
6924echo "Checking to see if you have long double..." >&4
6925echo 'int main() { long double x = 7.0; }' > try.c
6926set try
6927if eval $compile; then
6928	val="$define"
6929	echo "You have long double."
6930else
6931	val="$undef"
6932	echo "You do not have long double."
6933fi
6934$rm_try
6935set d_longdbl
6936eval $setvar
6937
6938: see if ldexpl exists
6939set ldexpl d_ldexpl
6940eval $inlibc
6941
6942: check for length of long double
6943case "${d_longdbl}${longdblsize}" in
6944$define)
6945	echo " "
6946	echo "Checking to see how big your long doubles are..." >&4
6947	$cat >try.c <<'EOCP'
6948#include <stdio.h>
6949int main()
6950{
6951	printf("%d\n", sizeof(long double));
6952}
6953EOCP
6954	set try
6955	set try
6956	if eval $compile; then
6957		longdblsize=`$run ./try`
6958		echo "Your long doubles are $longdblsize bytes long."
6959	else
6960		dflt='8'
6961		echo " "
6962		echo "(I can't seem to compile the test program.  Guessing...)" >&4
6963		rp="What is the size of a long double (in bytes)?"
6964		. ./myread
6965		longdblsize="$ans"
6966	fi
6967	if $test "X$doublesize" = "X$longdblsize"; then
6968		echo "That isn't any different from an ordinary double."
6969		echo "I'll keep your setting anyway, but you may see some"
6970		echo "harmless compilation warnings."
6971	fi
6972	;;
6973esac
6974$rm_try
6975
6976$echo "Checking the kind of long doubles you have..." >&4
6977case "$d_longdbl" in
6978define)
6979$cat <<EOP >try.c
6980#$i_stdlib I_STDLIB
6981#define LONGDBLSIZE $longdblsize
6982#define DOUBLESIZE $doublesize
6983#include <float.h>
6984#ifdef I_STDLIB
6985#include <stdlib.h>
6986#endif
6987#include <stdio.h>
6988static const long double d = -0.1L;
6989int main() {
6990  unsigned const char* b = (unsigned const char*)(&d);
6991#if DOUBLESIZE == LONGDBLSIZE
6992  printf("0\n"); /* if it floats like double */
6993  exit(0);
6994#endif
6995#if (LDBL_MANT_DIG == 113 || FLT128_MANT_DIG == 113) && LONGDBLSIZE == 16
6996  if (b[0] == 0x9A && b[1] == 0x99 && b[15] == 0xBF) {
6997    /* IEEE 754 128-bit little-endian */
6998    printf("1\n");
6999    exit(0);
7000  }
7001  if (b[0] == 0xBF && b[14] == 0x99 && b[15] == 0x9A) {
7002    /* IEEE 128-bit big-endian, e.g. solaris sparc */
7003    printf("2\n");
7004    exit(0);
7005  }
7006#endif
7007/* For alignment 32-bit platforms have the 80 bits in 12 bytes,
7008 * while 64-bits platforms have it in 16 bytes.  The trailing bytes
7009 * cannot be trusted. */
7010#if LDBL_MANT_DIG == 64 && (LONGDBLSIZE == 16 || LONGDBLSIZE == 12)
7011  if (b[0] == 0xCD && b[9] == 0xBF) {
7012    /* x86 80-bit little-endian, sizeof 12 (ILP32, Solaris x86)
7013     * or 16 (LP64, Linux and OS X), 4 or 6 bytes of padding.
7014     * Also known as "extended precision". */
7015    printf("3\n");
7016    exit(0);
7017  }
7018  if (b[0] == 0xBF && b[9] == 0xCD) {
7019    /* Is there ever big-endian 80-bit, really?
7020     *
7021     * The Motorola 68881 had another "extended precision" format:
7022     * sign:1 exp:15 zero:16 integer:1 mantissa:63
7023     * for total of 96 bits of bytes.  The zero bits were unused.
7024     * See "M68000 FAMILY PROGRAMMER’S REFERENCE MANUAL" for more details.
7025     * If it ever becomes relevant, this format should be allocated
7026     * a new doublekind code since it's quite different from the Intel x87.
7027     */
7028    printf("4\n");
7029    exit(0);
7030  }
7031#endif
7032#if (LDBL_MANT_DIG == 106 || LDBL_MANT_DIG == 107) && LONGDBLSIZE == 16
7033  /* software "double double", the 106 is 53+53.
7034   * but irix thinks it is 107. */
7035  if (b[0] == 0x9A && b[7] == 0x3C && b[8] == 0x9A && b[15] == 0xBF) {
7036    /* double double 128-bit fully little-endian,
7037     * little-endian doubles in little-endian order,
7038     * 9a 99 99 99 99 99 59 3c 9a 99 99 99 99 99 b9 bf */
7039    printf("5\n");
7040    exit(0);
7041  }
7042  if (b[0] == 0xBF && b[7] == 0x9A && b[8] == 0x3C && b[15] == 0x9A) {
7043    /* double double 128-bit fully big-endian,
7044     * big-endian doubles in big-endian order,
7045     * e.g. PPC/Power and MIPS:
7046     * bf b9 99 99 99 99 99 9a 3c 59 99 99 99 99 99 9a */
7047    printf("6\n");
7048    exit(0);
7049  }
7050  if (b[0] == 0x9A && b[7] == 0xBF && b[8] == 0x9A && b[15] == 0x3C) {
7051    /* double double 128-bit mixed endian.
7052     * little-endian doubles in big-endian order,
7053     * e.g. ppc64el,
7054     * 9a 99 99 99 99 99 b9 bf 9a 99 99 99 99 99 59 3c */
7055    printf("7\n");
7056    exit(0);
7057  }
7058  if (b[0] == 0x3C && b[7] == 0x9A && b[8] == 0xBF && b[15] == 0x9A) {
7059    /* double double 128-bit mixed endian,
7060     * big-endian doubles in little-endian order,
7061     * 3c 59 99 99 99 99 99 9a bf b9 99 99 99 99 99 9a */
7062    printf("8\n");
7063    exit(0);
7064  }
7065#endif
7066/* We are largely making this up because it may well be
7067 * that the VAX format H was never made available to C,
7068 * only to Fortran. */
7069#if LONGDBLSIZE == 16 && defined(__vax__)
7070  if (b[0] == 0xFD && b[15] == 0x99) {
7071    /* VAX format H, PDP-11 mixed endian. */
7072    printf("9\n");
7073    exit(0);
7074  }
7075#endif
7076  printf("-1\n"); /* unknown */
7077  exit(0);
7078}
7079EOP
7080set try
7081if eval $compile; then
7082    longdblkind=`$run ./try`
7083else
7084    longdblkind=-1
7085fi
7086;;
7087*) longdblkind=0 ;;
7088esac
7089case "$longdblkind" in
70900) echo "Your long doubles are doubles." >&4 ;;
70911) echo "You have IEEE 754 128-bit little endian long doubles." >&4 ;;
70922) echo "You have IEEE 754 128-bit big endian long doubles." >&4 ;;
70933) echo "You have x86 80-bit little endian long doubles." >& 4 ;;
70944) echo "You have x86 80-bit big endian long doubles." >& 4 ;;
70955) echo "You have 128-bit fully little-endian double-double long doubles (64-bit LEs in LE)." >& 4 ;;
70966) echo "You have 128-bit fully big-endian double-double long doubles (64-bit BEs in BE)." >& 4 ;;
70977) echo "You have 128-bit mixed-endian double-double long doubles (64-bit LEs in BE)." >& 4 ;;
70988) echo "You have 128-bit mixed-endian double-double long doubles (64-bit BEs in LE)." >& 4 ;;
70999) echo "You have 128-bit PDP-style mixed-endian long doubles (VAX format H)." >& 4 ;;
7100*) echo "Cannot figure out your long double." >&4 ;;
7101esac
7102d_long_double_style_ieee=$undef
7103d_long_double_style_ieee_std=$undef
7104d_long_double_style_ieee_extended=$undef
7105d_long_double_style_ieee_doubledouble=$undef
7106d_long_double_style_vax=$undef
7107case "$longdblkind" in
71081|2|3|4|5|6|7|8) d_long_double_style_ieee=$define ;;
7109esac
7110case "$longdblkind" in
71111|2) d_long_double_style_ieee_std=$define ;;
7112esac
7113case "$longdblkind" in
71143|4) d_long_double_style_ieee_extended=$define ;;
7115esac
7116case "$longdblkind" in
71175|6|7|8) d_long_double_style_ieee_doubledouble=$define ;;
7118esac
7119case "$longdblkind" in
71209) d_long_double_style_vax=$define ;;
7121esac
7122$rm_try
7123
7124: determine the architecture name
7125echo " "
7126if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
7127	tarch=`arch`"-$osname"
7128elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
7129	if uname -m > tmparch 2>&1 ; then
7130		tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
7131			-e 's/$/'"-$osname/" tmparch`
7132	else
7133		tarch="$osname"
7134	fi
7135	$rm -f tmparch
7136else
7137	tarch="$osname"
7138fi
7139case "$myarchname" in
7140''|"$tarch") ;;
7141*)
7142	echo "(Your architecture name used to be $myarchname.)"
7143	archname=''
7144	;;
7145esac
7146case "$targetarch" in
7147'') ;;
7148*)  archname=`echo $targetarch|sed 's,^[^-]*-,,'` ;;
7149esac
7150myarchname="$tarch"
7151case "$archname" in
7152'') dflt="$tarch";;
7153*) dflt="$archname";;
7154esac
7155rp='What is your architecture name'
7156. ./myread
7157archname="$ans"
7158
7159: optionally add API version to the architecture for versioned archlibs
7160case "$useversionedarchname" in
7161$define|true|[yY]*) dflt='y';;
7162*)                  dflt='n';;
7163esac
7164rp='Add the Perl API version to your archname?'
7165. ./myread
7166case "$ans" in
7167y|Y)	useversionedarchname="$define" ;;
7168*)      useversionedarchname="$undef" ;;
7169esac
7170case "$useversionedarchname" in
7171$define)
7172	case "$archname" in
7173	*-$api_versionstring)
7174		echo "...and architecture name already has -$api_versionstring" >&4
7175		;;
7176	*)
7177		archname="$archname-$api_versionstring"
7178		echo "...setting architecture name to $archname." >&4
7179		;;
7180	esac
7181	;;
7182esac
7183
7184case "$usethreads" in
7185$define)
7186	echo "Threads selected." >&4
7187	case "$archname" in
7188	*-thread*) echo "...and architecture name already has -thread." >&4
7189		;;
7190	*)      archname="$archname-thread"
7191		echo "...setting architecture name to $archname." >&4
7192		;;
7193	esac
7194	;;
7195esac
7196case "$usemultiplicity" in
7197$define)
7198	echo "Multiplicity selected." >&4
7199	case "$archname" in
7200	*-multi*) echo "...and architecture name already has -multi." >&4
7201		;;
7202	*)      archname="$archname-multi"
7203		echo "...setting architecture name to $archname." >&4
7204		;;
7205	esac
7206	;;
7207esac
7208case "$use64bitint$use64bitall" in
7209*"$define"*)
7210	case "$archname64" in
7211	'')
7212		echo "This architecture is naturally 64-bit, not changing architecture name." >&4
7213		;;
7214	*)
7215		case "$use64bitint" in
7216		"$define") echo "64 bit integers selected." >&4 ;;
7217		esac
7218		case "$use64bitall" in
7219		"$define") echo "Maximal 64 bitness selected." >&4 ;;
7220		esac
7221		case "$archname" in
7222		*-$archname64*) echo "...and architecture name already has $archname64." >&4
7223			;;
7224		*)      archname="$archname-$archname64"
7225			echo "...setting architecture name to $archname." >&4
7226			;;
7227		esac
7228		;;
7229	esac
7230esac
7231case "$uselongdouble" in
7232$define)
7233	echo "Long doubles selected." >&4
7234	case "$longdblsize" in
7235	$doublesize)
7236		echo "...but long doubles are equal to doubles, not changing architecture name." >&4
7237		;;
7238	*)
7239		case "$archname" in
7240		*-ld*) echo "...and architecture name already has -ld." >&4
7241			;;
7242		*)      archname="$archname-ld"
7243			echo "...setting architecture name to $archname." >&4
7244			;;
7245		esac
7246		;;
7247	esac
7248	;;
7249esac
7250case "$usequadmath" in
7251$define)
7252	echo "quadmath selected." >&4
7253	case "$archname" in
7254	*-quadmath*) echo "...and architecture name already has -quadmath." >&4
7255		;;
7256	*)      archname="$archname-quadmath"
7257		echo "...setting architecture name to $archname." >&4
7258		;;
7259	esac
7260	;;
7261esac
7262if $test -f archname.cbu; then
7263	echo "Your platform has some specific hints for architecture name, using them..."
7264	. ./archname.cbu
7265fi
7266
7267: set the prefixit variable, to compute a suitable default value
7268prefixit='case "$3" in
7269""|none)
7270	case "$oldprefix" in
7271	"") eval "$1=\"\$$2\"";;
7272	*)
7273		case "$3" in
7274		"") eval "$1=";;
7275		none)
7276			eval "tp=\"\$$2\"";
7277			case "$tp" in
7278			""|" ") eval "$1=\"\$$2\"";;
7279			*) eval "$1=";;
7280			esac;;
7281		esac;;
7282	esac;;
7283*)
7284	eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
7285	case "$tp" in
7286	--|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
7287	/*-$oldprefix/*|\~*-$oldprefix/*)
7288		eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
7289	*) eval "$1=\"\$$2\"";;
7290	esac;;
7291esac'
7292
7293: determine installation style
7294: For now, try to deduce it from prefix unless it is already set.
7295: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
7296case "$installstyle" in
7297'')	case "$prefix" in
7298		*perl*) dflt='lib';;
7299		*) dflt='lib/perl5' ;;
7300	esac
7301	;;
7302*)	dflt="$installstyle" ;;
7303esac
7304: Probably not worth prompting for this since we prompt for all
7305: the directories individually, and the prompt would be too long and
7306: confusing anyway.
7307installstyle=$dflt
7308
7309: determine where public executables go
7310echo " "
7311set dflt bin bin
7312eval $prefixit
7313fn=d~
7314rp='Pathname where the public executables will reside?'
7315. ./getfile
7316if $test "X$ansexp" != "X$binexp"; then
7317	installbin=''
7318fi
7319prefixvar=bin
7320: XXX Bug? -- ignores Configure -Dinstallprefix setting.
7321: XXX If this is fixed, also fix the "start perl" hunk below, which relies on
7322:     this via initialinstalllocation
7323. ./setprefixvar
7324
7325case "$userelocatableinc" in
7326$define|true|[yY]*)	dflt='y' ;;
7327*)			dflt='n' ;;
7328esac
7329cat <<EOM
7330
7331Would you like to build Perl so that the installation is relocatable, so that
7332library paths in @INC are determined relative to the path of the perl binary?
7333This is not advised for system Perl installs, or if you need to run setid
7334scripts or scripts under taint mode.
7335
7336If this doesn't make any sense to you, just accept the default '$dflt'.
7337EOM
7338rp='Use relocatable @INC?'
7339. ./myread
7340case "$ans" in
7341y|Y)	val="$define" ;;
7342*)	val="$undef"  ;;
7343esac
7344set userelocatableinc
7345eval $setvar
7346
7347initialinstalllocation="$binexp"
7348: Default prefix is now "up one level from where the binaries are"
7349case "$userelocatableinc" in
7350$define|true|[yY]*)
7351    bin=".../"
7352    binexp=".../"
7353    prefix=".../.."
7354    prefixexp=".../.."
7355    installprefixexp=".../.."
7356    ;;
7357esac
7358
7359: determine where private library files go
7360: Usual default is /usr/local/lib/perl5/$version.
7361: Also allow things like /opt/perl/lib/$version, since
7362: /opt/perl/lib/perl5... would be redundant.
7363: The default "style" setting is made in installstyle.U
7364case "$installstyle" in
7365*lib/perl5*) set dflt privlib lib/$package/$version ;;
7366*)	 set dflt privlib lib/$version ;;
7367esac
7368eval $prefixit
7369$cat <<EOM
7370
7371There are some auxiliary files for $package that need to be put into a
7372private library directory that is accessible by everyone.
7373
7374EOM
7375fn=$binexp
7376fn=d~+
7377rp='Pathname where the private library files will reside?'
7378. ./getfile
7379prefixvar=privlib
7380. ./setprefixvar
7381
7382: set the prefixup variable, to restore leading tilda escape
7383prefixup='case "$prefixexp" in
7384"$prefix") ;;
7385*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
7386esac'
7387
7388: determine where public architecture dependent libraries go
7389set archlib archlib
7390eval $prefixit
7391: privlib default is /usr/local/lib/$package/$version
7392: archlib default is /usr/local/lib/$package/$version/$archname
7393: privlib may have an optional trailing /share.
7394tdflt=`echo $privlib | $sed 's,/share$,,'`
7395tdflt=$tdflt/$archname
7396case "$archlib" in
7397'')	dflt=$tdflt
7398	;;
7399*)	dflt="$archlib"
7400    ;;
7401esac
7402$cat <<EOM
7403
7404$spackage contains architecture-dependent library files.  If you are
7405sharing libraries in a heterogeneous environment, you might store
7406these files in a separate location.  Otherwise, you can just include
7407them with the rest of the public library files.
7408
7409EOM
7410fn=$binexp
7411fn=d+~
7412rp='Where do you want to put the public architecture-dependent libraries?'
7413. ./getfile
7414prefixvar=archlib
7415. ./setprefixvar
7416if $test X"$archlib" = X"$privlib"; then
7417	d_archlib="$undef"
7418else
7419	d_archlib="$define"
7420fi
7421
7422: see if setuid scripts can be secure
7423$cat <<EOM
7424
7425Some kernels have a bug that prevents setuid #! scripts from being
7426secure.  Some sites have disabled setuid #! scripts because of this.
7427
7428First let's decide if your kernel supports secure setuid #! scripts.
7429(If setuid #! scripts would be secure but have been disabled anyway,
7430don't say that they are secure if asked.)
7431
7432EOM
7433
7434val="$undef"
7435if $test -d /dev/fd; then
7436	echo "#!$ls" >reflect
7437	chmod +x,u+s reflect
7438	./reflect >flect 2>&1
7439	if $contains "/dev/fd" flect >/dev/null; then
7440		echo "Congratulations, your kernel has secure setuid scripts!" >&4
7441		val="$define"
7442	else
7443		$cat <<EOM
7444If you are not sure if they are secure, I can check but I'll need a
7445username and password different from the one you are using right now.
7446If you don't have such a username or don't want me to test, simply
7447enter 'none'.
7448
7449EOM
7450		rp='Other username to test security of setuid scripts with?'
7451		dflt='none'
7452		. ./myread
7453		case "$ans" in
7454		n|none)
7455			case "$d_suidsafe" in
7456			'')	echo "I'll assume setuid scripts are *not* secure." >&4
7457				dflt=n;;
7458			"$undef")
7459				echo "Well, the $hint value is *not* secure." >&4
7460				dflt=n;;
7461			*)	echo "Well, the $hint value *is* secure." >&4
7462				dflt=y;;
7463			esac
7464			;;
7465		*)
7466			$rm -f reflect flect
7467			echo "#!$ls" >reflect
7468			chmod +x,u+s reflect
7469			echo >flect
7470			chmod a+w flect
7471			echo '"su" will (probably) prompt you for '"$ans's password."
7472			su $ans -c './reflect >flect'
7473			if $contains "/dev/fd" flect >/dev/null; then
7474				echo "Okay, it looks like setuid scripts are secure." >&4
7475				dflt=y
7476			else
7477				echo "I don't think setuid scripts are secure." >&4
7478				dflt=n
7479			fi
7480			;;
7481		esac
7482		rp='Does your kernel have *secure* setuid scripts?'
7483		. ./myread
7484		case "$ans" in
7485		[yY]*)	val="$define";;
7486		*)	val="$undef";;
7487		esac
7488	fi
7489else
7490	echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
7491	echo "(That's for file descriptors, not floppy disks.)"
7492	val="$undef"
7493fi
7494set d_suidsafe
7495eval $setvar
7496
7497$rm -f reflect flect
7498
7499: now see if they want to do setuid emulation
7500if $test $patchlevel -lt 11; then
7501echo " "
7502val="$undef"
7503case "$d_suidsafe" in
7504"$define")
7505	val="$undef"
7506	echo "No need to emulate SUID scripts since they are secure here." >&4
7507	;;
7508*)
7509	$cat <<EOM
7510Some systems have disabled setuid scripts, especially systems where
7511setuid scripts cannot be secure.  On systems where setuid scripts have
7512been disabled, the setuid/setgid bits on scripts are currently
7513useless.  It is possible for $package to detect those bits and emulate
7514setuid/setgid in a secure fashion.  This emulation will only work if
7515setuid scripts have been disabled in your kernel.
7516
7517EOM
7518	case "$d_dosuid" in
7519	"$define") dflt=y ;;
7520	*) dflt=n ;;
7521	esac
7522	rp="Do you want to do setuid/setgid emulation?"
7523	. ./myread
7524	case "$ans" in
7525	[yY]*)	val="$define";;
7526	*)	val="$undef";;
7527	esac
7528	;;
7529esac
7530set d_dosuid
7531eval $setvar
7532else
7533    case "$d_dosuid" in
7534	"$define")
7535	cat >&4 <<EOH
7536
7537SUID emulation has been removed for 5.12
7538Please re-run Configure without -Dd_dosuid
7539
7540EOH
7541	exit 1;
7542	;;
7543    esac
7544    d_dosuid=undef
7545fi
7546
7547: Find perl5.005 or later.
7548echo "Looking for a previously installed perl5.005 or later... "
7549case "$perl5" in
7550'')	for tdir in `echo "$binexp$path_sep$PATH" | $sed "s/$path_sep/ /g"`; do
7551		: Check if this perl is recent and can load a simple module
7552		if $test -x $tdir/perl$exe_ext && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
7553			perl5=$tdir/perl
7554			break;
7555		elif $test -x $tdir/perl5$exe_ext && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
7556			perl5=$tdir/perl5
7557			break;
7558		fi
7559	done
7560	;;
7561*)	perl5="$perl5"
7562	;;
7563esac
7564case "$perl5" in
7565'')	echo "None found.  That's ok.";;
7566*)	echo "Using $perl5." ;;
7567esac
7568
7569: Set the siteprefix variables
7570$cat <<EOM
7571
7572After $package is installed, you may wish to install various
7573add-on modules and utilities.  Typically, these add-ons will
7574be installed under $prefix with the rest
7575of this package.  However, you may wish to install such add-ons
7576elsewhere under a different prefix.
7577
7578If you do not wish to put everything under a single prefix, that's
7579ok.  You will be prompted for the individual locations; this siteprefix
7580is only used to suggest the defaults.
7581
7582The default should be fine for most people.
7583
7584EOM
7585fn=d~+
7586rp='Installation prefix to use for add-on modules and utilities?'
7587: XXX Here might be another good place for an installstyle setting.
7588case "$siteprefix" in
7589'') dflt=$prefix ;;
7590*)  dflt=$siteprefix ;;
7591esac
7592. ./getfile
7593: XXX Prefixit unit does not yet support siteprefix and vendorprefix
7594oldsiteprefix=''
7595case "$siteprefix" in
7596'') ;;
7597*)	case "$ans" in
7598	"$prefix") ;;
7599	*) oldsiteprefix="$prefix";;
7600	esac
7601	;;
7602esac
7603siteprefix="$ans"
7604siteprefixexp="$ansexp"
7605
7606: determine where site specific libraries go.
7607: Usual default is /usr/local/lib/perl5/site_perl/$version
7608: The default "style" setting is made in installstyle.U
7609: XXX No longer works with Prefixit stuff.
7610prog=`echo $package | $sed 's/-*[0-9.]*$//'`
7611case "$sitelib" in
7612'') case "$installstyle" in
7613	*lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
7614	*)	 dflt=$siteprefix/lib/site_$prog/$version ;;
7615	esac
7616	;;
7617*)	dflt="$sitelib"
7618	;;
7619esac
7620$cat <<EOM
7621
7622The installation process will create a directory for
7623site-specific extensions and modules.  Most users find it convenient
7624to place all site-specific files in this directory rather than in the
7625main distribution directory.
7626
7627EOM
7628fn=d~+
7629rp='Pathname for the site-specific library files?'
7630. ./getfile
7631prefixvar=sitelib
7632. ./setprefixvar
7633sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
7634
7635: Determine list of previous versions to include in @INC
7636$cat > getverlist <<EOPL
7637#!$perl5 -w
7638use File::Basename;
7639\$api_versionstring = "$api_versionstring";
7640\$version = "$version";
7641\$stem = "$sitelib_stem";
7642\$archname = "$archname";
7643EOPL
7644	$cat >> getverlist <<'EOPL'
7645# The list found is store twice for each entry: the original name, and
7646# the binary broken down version as pack "sss", so sorting is easy and
7647# unambiguous. This will work for all versions that have a maximum of
7648# three digit groups, separate by '.'s or '_'s. Names are extended with
7649# ".0.0" to ensure at least three elements for the pack.
7650#					-- H.Merijn Brand (m)'06 23-10-2006
7651
7652# Can't have leading @ because metaconfig interprets it as a command!
7653;@inc_version_list=();
7654# XXX Redo to do opendir/readdir?
7655if (-d $stem) {
7656    chdir($stem);
7657    ;@candidates = map {
7658	[ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*");
7659    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
7660}
7661else {
7662    ;@candidates = ();
7663}
7664
7665($pversion, $aversion, $vsn5005) = map {
7666    pack "sss", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005";
7667foreach $d (@candidates) {
7668    if ($d->[1] lt $pversion) {
7669	if ($d->[1] ge $aversion) {
7670	    unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);
7671	}
7672	elsif ($d->[1] ge $vsn5005) {
7673	    unshift(@inc_version_list, grep { -d } $d->[0]);
7674	}
7675    }
7676    else {
7677	# Skip newer version.  I.e. don't look in
7678	# 5.7.0 if we're installing 5.6.1.
7679    }
7680}
7681
7682if (@inc_version_list) {
7683    print join(' ', @inc_version_list);
7684}
7685else {
7686    # Blank space to preserve value for next Configure run.
7687    print " ";
7688}
7689EOPL
7690chmod +x getverlist
7691case "$inc_version_list" in
7692'')	if test -x "$perl5$exe_ext"; then
7693		dflt=`$perl5 getverlist`
7694	else
7695		dflt='none'
7696	fi
7697	;;
7698$undef) dflt='none' ;;
7699*)  eval dflt=\"$inc_version_list\" ;;
7700esac
7701case "$dflt" in
7702''|' ') dflt=none ;;
7703esac
7704case "$dflt" in
77055.005) dflt=none ;;
7706esac
7707$cat <<EOM
7708
7709In order to ease the process of upgrading, this version of perl
7710can be configured to use modules built and installed with earlier
7711versions of perl that were installed under $prefix.  Specify here
7712the list of earlier versions that this version of perl should check.
7713If Configure detected no earlier versions of perl installed under
7714$prefix, then the list will be empty.  Answer 'none' to tell perl
7715to not search earlier versions.
7716
7717The default should almost always be sensible, so if you're not sure,
7718just accept the default.
7719EOM
7720
7721rp='List of earlier versions to include in @INC?'
7722. ./myread
7723case "$ans" in
7724[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
7725*) inc_version_list="$ans" ;;
7726esac
7727case "$inc_version_list" in
7728''|' ')
7729	inc_version_list_init='0'
7730	d_inc_version_list="$undef"
7731	;;
7732*)	inc_version_list_init=`echo $inc_version_list |
7733		$sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
7734	d_inc_version_list="$define"
7735	;;
7736esac
7737$rm -f getverlist
7738
7739: see if malloc/malloc.h has to be included
7740set malloc/malloc.h i_mallocmalloc
7741eval $inhdr
7742
7743: see if this is a malloc.h system
7744: we want a real compile instead of Inhdr because some systems have a
7745: malloc.h that just gives a compile error saying to use stdlib.h instead
7746echo " "
7747$cat >try.c <<EOCP
7748#include <stdlib.h>
7749#include <malloc.h>
7750#$i_mallocmalloc I_MALLOCMALLOC
7751#ifdef I_MALLOCMALLOC
7752# include <malloc/malloc.h>
7753#endif
7754
7755int main () { return 0; }
7756EOCP
7757set try
7758if eval $compile; then
7759    echo "<malloc.h> found." >&4
7760    val="$define"
7761else
7762    echo "<malloc.h> NOT found." >&4
7763    val="$undef"
7764fi
7765$rm_try
7766set i_malloc
7767eval $setvar
7768
7769: check for length of pointer
7770echo " "
7771case "$ptrsize" in
7772'')
7773	echo "Checking to see how big your pointers are..." >&4
7774	$cat >try.c <<EOCP
7775#include <stdio.h>
7776#$i_stdlib I_STDLIB
7777#ifdef I_STDLIB
7778#include <stdlib.h>
7779#endif
7780int main()
7781{
7782    printf("%d\n", (int)sizeof(void *));
7783    exit(0);
7784}
7785EOCP
7786	set try
7787	if eval $compile_ok; then
7788		ptrsize=`$run ./try`
7789		echo "Your pointers are $ptrsize bytes long."
7790	else
7791		dflt='4'
7792		echo "(I can't seem to compile the test program.  Guessing...)" >&4
7793		rp="What is the size of a pointer (in bytes)?"
7794		. ./myread
7795		ptrsize="$ans"
7796	fi
7797	;;
7798esac
7799$rm_try
7800case "$use64bitall" in
7801"$define"|true|[yY]*)
7802	case "$ptrsize" in
7803	4)	cat <<EOM >&4
7804
7805*** You have chosen a maximally 64-bit build,
7806*** but your pointers are only 4 bytes wide.
7807*** Please rerun Configure without -Duse64bitall.
7808EOM
7809		case "$d_quad" in
7810		define)
7811			cat <<EOM >&4
7812*** Since you have quads, you could possibly try with -Duse64bitint.
7813EOM
7814			;;
7815		esac
7816		cat <<EOM >&4
7817*** Cannot continue, aborting.
7818
7819EOM
7820
7821		exit 1
7822		;;
7823	esac
7824	;;
7825esac
7826
7827: determine whether to use malloc wrapping
7828echo " "
7829case "$usemallocwrap" in
7830[yY]*|true|$define)	dflt='y' ;;
7831[nN]*|false|$undef)	dflt='n' ;;
7832*)	case "$usedevel" in
7833	[yY]*|true|$define)	dflt='y' ;;
7834	*) dflt='n' ;;
7835	esac
7836	;;
7837esac
7838rp="Do you wish to wrap malloc calls to protect against potential overflows?"
7839. ./myread
7840usemallocwrap="$ans"
7841case "$ans" in
7842y*|true)
7843	usemallocwrap="$define" ;;
7844*)
7845	usemallocwrap="$undef" ;;
7846esac
7847
7848: determine which malloc to compile in
7849echo " "
7850case "$usemymalloc" in
7851[yY]*|true|$define)	dflt='y' ;;
7852[nN]*|false|$undef)	dflt='n' ;;
7853*)	case "$ptrsize" in
7854	4) dflt='y' ;;
7855	*) dflt='n' ;;
7856	esac
7857	if test "$useithreads" = "$define"; then dflt='n'; fi
7858	;;
7859esac
7860rp="Do you wish to attempt to use the malloc that comes with $package?"
7861. ./myread
7862usemymalloc="$ans"
7863case "$ans" in
7864y*|true)
7865	usemymalloc='y'
7866	mallocsrc='malloc.c'
7867	mallocobj="malloc$_o"
7868	d_mymalloc="$define"
7869	case "$libs" in
7870	*-lmalloc*)
7871		: Remove malloc from list of libraries to use
7872		echo "Removing unneeded -lmalloc from library list" >&4
7873		set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
7874		shift
7875		libs="$*"
7876		echo "libs = $libs" >&4
7877		;;
7878	esac
7879	;;
7880*)
7881	usemymalloc='n'
7882	mallocsrc=''
7883	mallocobj=''
7884	d_mymalloc="$undef"
7885	;;
7886esac
7887
7888: compute the return types of malloc and free
7889echo " "
7890$cat >malloc.c <<END
7891#$i_malloc I_MALLOC
7892#$i_stdlib I_STDLIB
7893#include <stdio.h>
7894#include <sys/types.h>
7895#ifdef I_MALLOC
7896#include <malloc.h>
7897#endif
7898#ifdef I_STDLIB
7899#include <stdlib.h>
7900#endif
7901#ifdef TRY_MALLOC
7902void *malloc();
7903#endif
7904#ifdef TRY_FREE
7905void free();
7906#endif
7907END
7908case "$malloctype" in
7909'')
7910	if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
7911		malloctype='void *'
7912	else
7913		malloctype='char *'
7914	fi
7915	;;
7916esac
7917echo "Your system wants malloc to return '$malloctype', it would seem." >&4
7918
7919case "$freetype" in
7920'')
7921	if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
7922		freetype='void'
7923	else
7924		freetype='int'
7925	fi
7926	;;
7927esac
7928echo "Your system uses $freetype free(), it would seem." >&4
7929$rm -f malloc.[co]
7930: determine where site specific architecture-dependent libraries go.
7931: sitelib  default is /usr/local/lib/perl5/site_perl/$version
7932: sitearch default is /usr/local/lib/perl5/site_perl/$version/$archname
7933: sitelib may have an optional trailing /share.
7934case "$sitearch" in
7935'')	dflt=`echo $sitelib | $sed 's,/share$,,'`
7936	dflt="$dflt/$archname"
7937	;;
7938*)	dflt="$sitearch"
7939	;;
7940esac
7941set sitearch sitearch none
7942eval $prefixit
7943$cat <<EOM
7944
7945The installation process will also create a directory for
7946architecture-dependent site-specific extensions and modules.
7947
7948EOM
7949fn=d~+
7950rp='Pathname for the site-specific architecture-dependent library files?'
7951. ./getfile
7952prefixvar=sitearch
7953. ./setprefixvar
7954if $test X"$sitearch" = X"$sitelib"; then
7955	d_sitearch="$undef"
7956else
7957	d_sitearch="$define"
7958fi
7959
7960: Set the vendorprefix variables
7961$cat <<EOM
7962
7963The installation process will also create a directory for
7964vendor-supplied add-ons.  Vendors who supply perl with their system
7965may find it convenient to place all vendor-supplied files in this
7966directory rather than in the main distribution directory.  This will
7967ease upgrades between binary-compatible maintenance versions of perl.
7968
7969Of course you may also use these directories in whatever way you see
7970fit.  For example, you might use them to access modules shared over a
7971company-wide network.
7972
7973The default answer should be fine for most people.
7974This causes further questions about vendor add-ons to be skipped
7975and no vendor-specific directories will be configured for perl.
7976
7977EOM
7978rp='Do you want to configure vendor-specific add-on directories?'
7979case "$usevendorprefix" in
7980define|true|[yY]*) dflt=y ;;
7981*)	: User may have set vendorprefix directly on Configure command line.
7982	case "$vendorprefix" in
7983	''|' ') dflt=n ;;
7984	*)	dflt=y ;;
7985	esac
7986	;;
7987esac
7988. ./myread
7989case "$ans" in
7990[yY]*)	fn=d~+
7991	rp='Installation prefix to use for vendor-supplied add-ons?'
7992	case "$vendorprefix" in
7993	'') dflt="$prefix" ;;
7994	*)  dflt=$vendorprefix ;;
7995	esac
7996	. ./getfile
7997	: XXX Prefixit unit does not yet support siteprefix and vendorprefix
7998	oldvendorprefix=''
7999	case "$vendorprefix" in
8000	'') ;;
8001	*)	case "$ans" in
8002		"$prefix") ;;
8003		*) oldvendorprefix="$prefix";;
8004		esac
8005		;;
8006	esac
8007	usevendorprefix="$define"
8008	vendorprefix="$ans"
8009	vendorprefixexp="$ansexp"
8010	;;
8011*)	usevendorprefix="$undef"
8012	vendorprefix=''
8013	vendorprefixexp=''
8014	;;
8015esac
8016
8017: Set the vendorlib variables
8018case "$vendorprefix" in
8019'')	d_vendorlib="$undef"
8020	vendorlib=''
8021	vendorlibexp=''
8022	;;
8023*)	d_vendorlib="$define"
8024	: determine where vendor-supplied modules go.
8025	: Usual default is /usr/local/lib/perl5/vendor_perl/$version
8026	case "$vendorlib" in
8027	'')
8028		prog=`echo $package | $sed 's/-*[0-9.]*$//'`
8029		case "$installstyle" in
8030		*lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
8031		*)	     dflt=$vendorprefix/lib/vendor_$prog/$version ;;
8032		esac
8033		;;
8034	*)	dflt="$vendorlib"
8035		;;
8036	esac
8037	fn=d~+
8038	rp='Pathname for the vendor-supplied library files?'
8039	. ./getfile
8040	vendorlib="$ans"
8041	vendorlibexp="$ansexp"
8042	;;
8043esac
8044vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
8045prefixvar=vendorlib
8046. ./installprefix
8047
8048: Set the vendorarch variables
8049case "$vendorprefix" in
8050'')	d_vendorarch="$undef"
8051	vendorarch=''
8052	vendorarchexp=''
8053	;;
8054*)	d_vendorarch="$define"
8055	: determine where vendor-supplied architecture-dependent libraries go.
8056	: vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
8057	: vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
8058	: vendorlib may have an optional trailing /share.
8059	case "$vendorarch" in
8060	'')	dflt=`echo $vendorlib | $sed 's,/share$,,'`
8061		dflt="$dflt/$archname"
8062		;;
8063	*)	dflt="$vendorarch" ;;
8064	esac
8065	fn=d~+
8066	rp='Pathname for vendor-supplied architecture-dependent files?'
8067	. ./getfile
8068	vendorarch="$ans"
8069	vendorarchexp="$ansexp"
8070	;;
8071esac
8072prefixvar=vendorarch
8073. ./installprefix
8074if $test X"$vendorarch" = X"$vendorlib"; then
8075	d_vendorarch="$undef"
8076else
8077	d_vendorarch="$define"
8078fi
8079
8080: Final catch-all directories to search
8081$cat <<EOM
8082
8083Lastly, you can have perl look in other directories for extensions and
8084modules in addition to those already specified.
8085These directories will be searched after
8086	$sitearch
8087	$sitelib
8088EOM
8089test X"$vendorlib" != "X" && echo '	' $vendorlib
8090test X"$vendorarch" != "X" && echo '	' $vendorarch
8091echo ' '
8092case "$otherlibdirs" in
8093''|' ') dflt='none' ;;
8094*)	dflt="$otherlibdirs" ;;
8095esac
8096$cat <<EOM
8097Enter a colon-separated set of extra paths to include in perl's @INC
8098search path, or enter 'none' for no extra paths.
8099
8100EOM
8101
8102rp='Colon-separated list of additional directories for perl to search?'
8103. ./myread
8104case "$ans" in
8105' '|''|none)	otherlibdirs=' ' ;;
8106*)	otherlibdirs="$ans" ;;
8107esac
8108case "$otherlibdirs" in
8109' ') val=$undef ;;
8110*)	val=$define ;;
8111esac
8112set d_perl_otherlibdirs
8113eval $setvar
8114
8115: DTrace support
8116dflt_dtrace='/usr/sbin/dtrace'
8117$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/dtrace'
8118
8119cat <<EOM
8120
8121Perl can be built to support DTrace on platforms that support it.
8122DTrace is a diagnosis and performance analysis tool from Sun.
8123
8124If this doesn't make any sense to you, just accept the default.
8125EOM
8126
8127while $test 1 ; do
8128	case "$usedtrace" in
8129	$define|true|[yY]*)
8130		dflt='y'
8131		;;
8132	?*)
8133		dflt='y'
8134		dflt_dtrace=$usedtrace
8135		;;
8136	*)
8137		dflt='n'
8138		;;
8139	esac
8140
8141	rp='Support DTrace if available?'
8142	. ./myread
8143	case "$ans" in
8144	y|Y)	val="$define" ;;
8145	*)      val="$undef" ;;
8146	esac
8147	set usedtrace
8148	eval $setvar
8149
8150	test "X$usedtrace" != "X$define" && break
8151
8152	echo " "
8153	rp='Where is the dtrace executable?'
8154	dflt=$dflt_dtrace
8155	. ./getfile
8156	val="$ans"
8157	set dtrace
8158	eval $setvar
8159
8160	if $test -f $dtrace
8161	then
8162		if $dtrace -h -s ../perldtrace.d \
8163			-o perldtrace.tmp >/dev/null 2>&1 \
8164			&& rm -f perldtrace.tmp
8165		then
8166			echo " "
8167			echo "Good: your $dtrace knows about the -h flag."
8168		else
8169			cat >&2 <<EOM
8170
8171*** $me:  Fatal Error:  $dtrace doesn't support -h flag
8172***
8173*** Your installed dtrace doesn't support the -h switch to compile a D
8174*** program into a C header. Can't continue.
8175
8176EOM
8177			exit 1
8178		fi
8179		break;
8180	fi
8181
8182	case "$fastread" in
8183	yes)
8184		cat >&2 <<EOM
8185
8186*** $me:  Fatal Error:  $dtrace not found.
8187*** Can't continue.
8188
8189EOM
8190		exit 1
8191		;;
8192	*)
8193		echo "*** $dtrace was not found."
8194		echo " "
8195		;;
8196	esac
8197done
8198
8199: See if we want extra modules installed
8200echo " "
8201case "$extras" in
8202'') dflt='n';;
8203*) dflt='y';;
8204esac
8205cat <<EOM
8206Perl can be built with extra modules or bundles of modules which
8207will be fetched from the CPAN and installed alongside Perl.
8208
8209Notice that you will need access to the CPAN; either via the Internet,
8210or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
8211be asked later to configure the CPAN.pm module which will in turn do
8212the installation of the rest of the extra modules or bundles.)
8213
8214Notice also that if the modules require any external software such as
8215libraries and headers (the libz library and the zlib.h header for the
8216Compress::Zlib module, for example) you MUST have any such software
8217already installed, this configuration process will NOT install such
8218things for you.
8219
8220If this doesn't make any sense to you, just accept the default '$dflt'.
8221EOM
8222rp='Install any extra modules (y or n)?'
8223. ./myread
8224case "$ans" in
8225y|Y)
8226	cat <<EOM
8227
8228Please list any extra modules or bundles to be installed from CPAN,
8229with spaces between the names.  The names can be in any format the
8230'install' command of CPAN.pm will understand.  (Answer 'none',
8231without the quotes, to install no extra modules or bundles.)
8232EOM
8233	rp='Extras?'
8234	dflt="$extras"
8235	. ./myread
8236	extras="$ans"
8237esac
8238case "$extras" in
8239''|'none')
8240	val=''
8241	$rm -f ../extras.lst
8242	;;
8243*)	echo "(Saving the list of extras for later...)"
8244	echo "$extras" > ../extras.lst
8245	val="'$extras'"
8246	;;
8247esac
8248set extras
8249eval $setvar
8250echo " "
8251
8252: determine where html pages for programs go
8253set html1dir html1dir none
8254eval $prefixit
8255$cat <<EOM
8256
8257If you wish to install html files for programs in $spackage, indicate
8258the appropriate directory here.  To skip installing html files,
8259answer "none".
8260EOM
8261case "$html1dir" in
8262''|none|$undef|' ') dflt=none ;;
8263*) dflt=$html1dir ;;
8264esac
8265fn=dn+~
8266rp="Directory for the main $spackage html pages?"
8267. ./getfile
8268prefixvar=html1dir
8269. ./setprefixvar
8270: Use ' ' for none so value is preserved next time through Configure
8271$test X"$html1dir" = "X" && html1dir=' '
8272
8273: determine where html pages for libraries and modules go
8274set html3dir html3dir none
8275eval $prefixit
8276$cat <<EOM
8277
8278If you wish to install html files for modules associated with $spackage,
8279indicate the appropriate directory here.  To skip installing html files,
8280answer "none".
8281EOM
8282: There is no obvious default.  If they have specified html1dir, then
8283: try to key off that, possibly changing .../html1 into .../html3.
8284case "$html3dir" in
8285'') html3dir=`echo "$html1dir" | $sed 's/1$/3$/'` ;;
8286*) dflt=$html3dir ;;
8287esac
8288fn=dn+~
8289rp="Directory for the $spackage module html pages?"
8290. ./getfile
8291prefixvar=html3dir
8292. ./setprefixvar
8293: Use ' ' for none so value is preserved next time through Configure
8294$test X"$html3dir" = "X" && html3dir=' '
8295
8296: determine whether to install perl also as /usr/bin/perl
8297
8298echo " "
8299if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
8300	$cat <<EOM
8301Many scripts expect perl to be installed as /usr/bin/perl.
8302
8303If you want to, I can install the perl you are about to compile
8304as /usr/bin/perl (in addition to $bin/perl).
8305EOM
8306	if test -f /usr/bin/perl; then
8307	    $cat <<EOM
8308
8309However, please note that because you already have a /usr/bin/perl,
8310overwriting that with a new Perl would very probably cause problems.
8311Therefore I'm assuming you don't want to do that (unless you insist).
8312
8313EOM
8314	    case "$installusrbinperl" in
8315	    "$define"|[yY]*)	dflt='y';;
8316	    *)			dflt='n';;
8317	    esac
8318	else
8319	    $cat <<EOM
8320
8321Since you don't have a /usr/bin/perl I'm assuming creating one is okay.
8322
8323EOM
8324	    case "$installusrbinperl" in
8325	    "$undef"|[nN]*)	dflt='n';;
8326	    *)			dflt='y';;
8327	    esac
8328	fi
8329	rp="Do you want to install perl as /usr/bin/perl?"
8330	. ./myread
8331	case "$ans" in
8332	[yY]*)	val="$define";;
8333	*)	val="$undef" ;;
8334	esac
8335else
8336	val="$undef"
8337fi
8338set installusrbinperl
8339eval $setvar
8340
8341: see if dlopen exists
8342xxx_runnm="$runnm"
8343xxx_ccflags="$ccflags"
8344runnm=false
8345: with g++ one needs -shared to get is-in-libc to work for dlopen
8346case "$gccversion" in
8347'')	;;
8348*Clang*)	;;
8349*)	case "$d_cplusplus" in
8350	"$define") ccflags="$ccflags -shared" ;;
8351	esac
8352	;;
8353esac
8354set dlopen d_dlopen
8355eval $inlibc
8356runnm="$xxx_runnm"
8357ccflags="$xxx_ccflags"
8358
8359: see if this is a unistd.h system
8360set unistd.h i_unistd
8361eval $inhdr
8362
8363: determine which dynamic loading, if any, to compile in
8364echo " "
8365dldir="ext/DynaLoader"
8366case "$usedl" in
8367    $define|y|true)
8368	dflt='y'
8369	usedl="$define"
8370	;;
8371    $undef|n|false)
8372	dflt='n'
8373	usedl="$undef"
8374	;;
8375    *)
8376	dflt='n'
8377	case "$d_dlopen" in
8378	    $define) dflt='y' ;;
8379	esac
8380	: Does a dl_xxx.xs file exist for this operating system
8381	$test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
8382	;;
8383esac
8384rp="Do you wish to use dynamic loading?"
8385. ./myread
8386usedl="$ans"
8387bin_ELF="$undef"
8388case "$ans" in
8389    y*) usedl="$define"
8390	case "$dlsrc" in
8391	    '') if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
8392		    dflt="$dldir/dl_${osname}.xs"
8393		elif $test "$d_dlopen" = "$define" ; then
8394		    dflt="$dldir/dl_dlopen.xs"
8395		else
8396		    dflt=''
8397		fi
8398		;;
8399	    *)  dflt="$dldir/$dlsrc"
8400		;;
8401	esac
8402	echo "The following dynamic loading files are available:"
8403	: Can not go over to $dldir because getfile has path hard-coded in.
8404	tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir"
8405	rp="Source file to use for dynamic loading"
8406	fn="fne"
8407	gfpth="$src"
8408	. ./getfile
8409	usedl="$define"
8410	: emulate basename
8411	dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'`
8412
8413	$cat << EOM
8414
8415Some systems may require passing special flags to $cc -c to
8416compile modules that will be used to create a shared library.
8417To use no flags, say "none".
8418
8419EOM
8420	case "$cccdlflags" in
8421	    '') case "$gccversion" in
8422		'') case "$osname" in
8423			hpux)	dflt='+z' ;;
8424			irix*)	dflt='-KPIC' ;;
8425			svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
8426			sunos)	dflt='-pic' ;;
8427			*)	dflt='none' ;;
8428		    esac
8429		    ;;
8430		*)  case "$osname" in
8431			darwin) dflt='none' ;;
8432			*linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
8433			*)	dflt='-fpic' ;;
8434		    esac ;;
8435		esac ;;
8436	    ' ') dflt='none' ;;
8437	    *)   dflt="$cccdlflags" ;;
8438	esac
8439
8440	case "$dflt" in
8441	    none) dflt='' ;;
8442	esac
8443
8444	# If -Dsysroot was specified, now's the time to add it
8445	# to cccdlflags
8446	if test "X$sysroot" != X; then
8447	    case "$gccversion" in
8448		'') ;;
8449		*)  case "$dflt" in
8450			*sysroot*) ;;
8451			'undef'|*)
8452			    dflt="$dflt --sysroot=$sysroot" ;;
8453		    esac
8454		    ;;
8455	    esac
8456	fi
8457
8458	case "$dflt" in
8459	    '') dflt='none';;
8460	esac
8461
8462	rp="Any special flags to pass to $cc -c to compile shared library modules?"
8463	. ./myread
8464	case "$ans" in
8465	    none) cccdlflags=' ' ;;
8466	    *)    cccdlflags="$ans" ;;
8467	esac
8468
8469	cat << EOM
8470
8471Some systems use ld to create libraries that can be dynamically loaded,
8472while other systems (such as those using ELF) use $cc.
8473
8474EOM
8475
8476: Determine if this is ELF
8477	$cat >try.c <<EOM
8478/* Test for whether ELF binaries are produced */
8479#include <fcntl.h>
8480#$i_stdlib I_STDLIB
8481#ifdef I_STDLIB
8482#include <stdlib.h>
8483#endif
8484#$i_unistd I_UNISTD
8485#ifdef I_UNISTD
8486#include <unistd.h>
8487#endif
8488int main() {
8489    char b[4];
8490    int i = open("a.out",O_RDONLY);
8491    if(i == -1)
8492	exit(1); /* fail */
8493    if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
8494	exit(0); /* succeed (yes, it is ELF) */
8495    exit(1); /* fail */
8496}
8497EOM
8498	if $cc $ccflags $ldflags -o a.out try.c >/dev/null 2>&1 && $run ./a.out; then
8499	    bin_ELF="$define"
8500	fi
8501	$rm_try
8502
8503	case "$ld" in
8504	    '') if $test $bin_ELF = "$define"; then
8505		    cat <<EOM
8506You appear to have ELF support.  I'll use $cc to build dynamic libraries.
8507EOM
8508		    dflt="$cc"
8509		else
8510		    echo "I'll use ld to build dynamic libraries."
8511		    dflt='ld'
8512		fi
8513		;;
8514	    *)  dflt="$ld"
8515		;;
8516	esac
8517
8518	rp="What command should be used to create dynamic libraries?"
8519	. ./myread
8520	ld="$ans"
8521
8522	cat << EOM
8523
8524Some systems may require passing special flags to $ld to create a
8525library that can be dynamically loaded.  If your ld flags include
8526-L/other/path options to locate libraries outside your loader's normal
8527search path, you may need to specify those -L options here as well.  To
8528use no flags, say "none".
8529
8530EOM
8531	case "$lddlflags" in
8532	    '') case "$osname" in
8533		    haiku) dflt='-shared' ;;
8534		    hpux) dflt='-b';
8535			  case "$gccversion" in
8536			      '') dflt="$dflt +vnocompatwarnings" ;;
8537			  esac
8538			  ;;
8539		    *linux*|irix*|gnu*)  dflt="-shared $optimize" ;;
8540		    solaris) # See [perl #66604].
8541			    # On Solaris 11, gcc -m64 on amd64
8542			    # appears not to understand -G.  gcc versions at
8543			    # least as old as 3.4.3 support -shared, so just
8544			    # use that with Solaris 11 and later, but keep
8545			    # the old behavior for older Solaris versions.
8546			    case "$gccversion" in
8547				'') dflt='-G' ;;
8548				*)  case "$osvers" in
8549					2.?|2.10) dflt='-G' ;;
8550					*) dflt='-shared' ;;
8551				    esac
8552				    ;;
8553			    esac
8554			    ;;
8555		    sunos) dflt='-assert nodefinitions' ;;
8556		    svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
8557		    *)     dflt='none' ;;
8558		esac
8559		;;
8560	    *) dflt="$lddlflags" ;;
8561	esac
8562
8563	: Only do this for gcc, since, for example, qcc has no concept
8564	: of --sysroot.
8565	if $test "X$sysroot" != X; then
8566	    case "$gccversion" in
8567		'') ;;
8568		*)  dflt="$dflt --sysroot $sysroot" ;;
8569	    esac
8570	fi
8571
8572	: Try to guess additional flags to pick up local libraries.
8573	: Be careful not to append to a plain 'none'
8574	case "$dflt" in
8575	    none) dflt='' ;;
8576	esac
8577	for thisflag in $ldflags; do
8578	    case "$thisflag" in
8579		-L*|-R*|-Wl,-R*)
8580		    case " $dflt " in
8581			*" $thisflag "*) ;;
8582			*) dflt="$dflt $thisflag" ;;
8583		    esac
8584		    ;;
8585	    esac
8586	done
8587
8588	case "$dflt" in
8589	    ''|' ') dflt='none' ;;
8590	esac
8591
8592	case "$ldflags" in
8593	    *-fstack-protector-strong*)
8594		case "$dflt" in
8595		    *-fstack-protector-strong*) ;; # Don't add it again
8596		    *) dflt="$dflt -fstack-protector-strong" ;;
8597		esac
8598		;;
8599	    *-fstack-protector*)
8600		case "$dflt" in
8601		    *-fstack-protector*) ;; # Don't add it again
8602		    *) dflt="$dflt -fstack-protector" ;;
8603		esac
8604		;;
8605	esac
8606
8607	rp="Any special flags to pass to $ld to create a dynamically loaded library?"
8608	. ./myread
8609	case "$ans" in
8610	    none) lddlflags=' ' ;;
8611	    *) lddlflags="$ans" ;;
8612	esac
8613
8614	cat <<EOM
8615
8616Some systems may require passing special flags to $cc to indicate that
8617the resulting executable will use dynamic linking.  To use no flags,
8618say "none".
8619
8620EOM
8621	case "$ccdlflags" in
8622	    '') case "$osname" in
8623		    *linux*|hpux|gnu*) dflt='-Wl,-E' ;;
8624		    sunos)             dflt='none'   ;;
8625		    *)                 dflt='none'   ;;
8626		esac ;;
8627	    ' ') dflt='none' ;;
8628	    *)   dflt="$ccdlflags" ;;
8629	esac
8630	rp="Any special flags to pass to $cc to use dynamic linking?"
8631	. ./myread
8632	case "$ans" in
8633	    none) ccdlflags=' ' ;;
8634	    *)    ccdlflags="$ans" ;;
8635	esac
8636	;;
8637
8638    *)  usedl="$undef"
8639	ld='ld'
8640	dlsrc='dl_none.xs'
8641	lddlflags=''
8642	ccdlflags=''
8643	;;
8644esac
8645
8646ld_can_script="$undef"
8647case "$bin_ELF$usedl" in
8648    $define$define)
8649	# Abuse try.h and a.out names for neat cleanup
8650	$cat >try.c <<EOM
8651void foo() {}
8652void bar() {}
8653EOM
8654	$cat >try.h <<EOM
8655LIBTEST_42 {
8656 global:
8657  foo;
8658 local: *;
8659 };
8660EOM
8661	if $cc $cccdlflags $ccdlflags $ccflags \
8662	       $ldflags $lddlflags -o a.out try.c \
8663	       -Wl,--version-script=try.h >/dev/null 2>&1 \
8664	   &&  $test -s a.out ; then
8665	    echo "ld supports scripting" >&4
8666	    ld_can_script="$define"
8667	else
8668	    echo "ld does not support scripting" >&4
8669	fi
8670	$rm_try
8671	;;
8672esac
8673
8674: Do we want a shared libperl?
8675also=''
8676case "$usedl" in
8677$undef)
8678	# No dynamic loading being used, so don't bother even to prompt.
8679	useshrplib='false'
8680	;;
8681*)	case "$useshrplib" in
8682	'')	case "$osname" in
8683		svr4*|nonstopux|dgux|dynixptx|esix|powerux|haiku|cygwin*)
8684			dflt=y
8685			also='Building a shared libperl is required for dynamic loading to work on your system.'
8686			;;
8687		*)	dflt=n
8688			;;
8689		esac
8690		;;
8691	$define|true|[Yy]*)
8692		dflt=y
8693		;;
8694	*)	dflt=n
8695		;;
8696	esac
8697	$cat << EOM
8698
8699The perl executable is normally obtained by linking perlmain.c with
8700libperl${_a}, any static extensions (usually just DynaLoader), and
8701any other libraries needed on this system (such as -lm, etc.).  Since
8702your system supports dynamic loading, it is probably possible to build
8703a shared libperl.$so.  If you will have more than one executable linked
8704to libperl.$so, this will significantly reduce the size of each
8705executable, but it may have a noticeable effect on performance.  The
8706default is probably sensible for your system.
8707$also
8708
8709EOM
8710	rp="Build a shared libperl.$so (y/n)"
8711	. ./myread
8712	case "$ans" in
8713	true|$define|[Yy]*)
8714		useshrplib='true'  ;;
8715	*)	useshrplib='false' ;;
8716	esac
8717	;;
8718esac
8719
8720case "$useshrplib" in
8721true)
8722	case "$userelocatableinc" in
8723	true|define)
8724		echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
8725		echo "See INSTALL for an explanation why that won't work." >&4
8726		exit 4
8727		;;
8728	esac
8729	case "$libperl" in
8730	'')
8731		# Figure out a good name for libperl.so.  Since it gets stored in
8732		# a version-specific architecture-dependent library, the version
8733		# number isn't really that important, except for making cc/ld happy.
8734		#
8735		# A name such as libperl.so.10.1
8736		majmin="libperl.$so.$patchlevel.$subversion"
8737		# A name such as libperl.so.100
8738		majonly=`echo $patchlevel $subversion |
8739			$awk '{printf "%d%02d", $1, $2}'`
8740		majonly=libperl.$so.$majonly
8741		# I'd prefer to keep the os-specific stuff here to a minimum, and
8742		# rely on figuring it out from the naming of libc.
8743		case "${osname}${osvers}" in
8744		*linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
8745			dflt=libperl.$so
8746			;;
8747		cygwin*) # ld links now against the dll directly
8748			majmin="cygperl5_${patchlevel}_${subversion}.${so}"
8749			majonly=`echo $patchlevel $subversion |
8750				$awk '{printf "%03d%03d", $1, $2}'`
8751			majonly=cygperl5.$majonly.$so
8752			dflt=$majmin
8753			;;
8754		*)	# Try to guess based on whether libc has major.minor.
8755			case "$libc" in
8756			*libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
8757			*libc.$so.[0-9]*) dflt=$majonly ;;
8758			*)	dflt=libperl.$so ;;
8759			esac
8760			;;
8761		esac
8762		;;
8763	*)	dflt=$libperl
8764		;;
8765	esac
8766	cat << EOM
8767
8768I need to select a good name for the shared libperl.  If your system uses
8769library names with major and minor numbers, then you might want something
8770like $majmin.  Alternatively, if your system uses a single version
8771number for shared libraries, then you might want to use $majonly.
8772Or, your system might be quite happy with a simple libperl.$so.
8773
8774Since the shared libperl will get installed into a version-specific
8775architecture-dependent directory, the version number of the shared perl
8776library probably isn't important, so the default should be o.k.
8777
8778EOM
8779	rp='What name do you want to give to the shared libperl?'
8780	. ./myread
8781	libperl=$ans
8782	echo "Ok, I'll use $libperl"
8783	;;
8784*)
8785	libperl="libperl${_a}"
8786	;;
8787esac
8788
8789# Detect old use of shrpdir via undocumented Configure -Dshrpdir
8790case "$shrpdir" in
8791'') ;;
8792*)	$cat >&4 <<EOM
8793WARNING:  Use of the shrpdir variable for the installation location of
8794the shared $libperl is not supported.  It was never documented and
8795will not work in this version.  Let me (https://github.com/Perl/perl5/issues)
8796know of any problems this may cause.
8797
8798EOM
8799	case "$shrpdir" in
8800	"$archlibexp/CORE")
8801		$cat >&4 <<EOM
8802But your current setting of $shrpdir is
8803the default anyway, so it's harmless.
8804EOM
8805		;;
8806	*)
8807		$cat >&4 <<EOM
8808Further, your current attempted setting of $shrpdir
8809conflicts with the value of $archlibexp/CORE
8810that installperl will use.
8811EOM
8812		;;
8813	esac
8814	;;
8815esac
8816
8817# How will the perl executable find the installed shared $libperl?
8818# Add $xxx to ccdlflags.
8819# If we can't figure out a command-line option, use $shrpenv to
8820# set env LD_RUN_PATH.  The main perl makefile uses this.
8821shrpdir=$archlibexp/CORE
8822xxx=''
8823tmp_shrpenv=''
8824if "$useshrplib"; then
8825    case "$osname" in
8826	aix)
8827		# We'll set it in Makefile.SH...
8828		;;
8829	solaris)
8830		xxx="-R $shrpdir"
8831		;;
8832	freebsd|minix|mirbsd|netbsd|openbsd|interix|dragonfly|bitrig)
8833		xxx="-Wl,-R$shrpdir"
8834		;;
8835	bsdos|linux|irix*|dec_osf|gnu*|haiku)
8836		xxx="-Wl,-rpath,$shrpdir"
8837		;;
8838	hpux*)
8839		# hpux doesn't like the default, either.
8840		tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
8841		;;
8842	cygwin)
8843		# cygwin needs only ldlibpth
8844		;;
8845	*)
8846		tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
8847		;;
8848	esac
8849	case "$xxx" in
8850	'') ;;
8851	*)
8852		# Only add $xxx if it isn't already in ccdlflags.
8853		case " $ccdlflags " in
8854		*" $xxx "*)	;;
8855		*)	ccdlflags="$ccdlflags $xxx"
8856			cat <<EOM >&4
8857
8858Adding $xxx to the flags
8859passed to $ld so that the perl executable will find the
8860installed shared $libperl.
8861
8862EOM
8863			;;
8864		esac
8865		;;
8866	esac
8867fi
8868# Fix ccdlflags in AIX for building external extensions.
8869# (For building Perl itself bare -bE:perl.exp is needed,
8870#  Makefile.SH takes care of this.)
8871case "$osname" in
8872aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
8873esac
8874# Respect a hint or command-line value.
8875case "$shrpenv" in
8876'') shrpenv="$tmp_shrpenv" ;;
8877esac
8878case "$ldlibpthname" in
8879'')	ldlibpthname=LD_LIBRARY_PATH ;;
8880none)	ldlibpthname='' ;;
8881esac
8882
8883: determine where manual pages are on this system
8884echo " "
8885case "$sysman" in
8886'')
8887	syspath='/usr/share/man/man1 /usr/man/man1'
8888	syspath="$syspath /usr/man/mann /usr/man/manl /usr/man/local/man1"
8889	syspath="$syspath /usr/man/u_man/man1"
8890	syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
8891	syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
8892	syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
8893	sysman=`./loc . /usr/man/man1 $syspath`
8894	;;
8895esac
8896if $test -d "$sysman"; then
8897	echo "System manual is in $sysman." >&4
8898else
8899	echo "Could not find manual pages in source form." >&4
8900fi
8901
8902: determine where manual pages go
8903set man1dir man1dir none
8904eval $prefixit
8905$cat <<EOM
8906
8907$spackage has manual pages available in source form.
8908EOM
8909case "$nroff" in
8910nroff)
8911	echo "However, you don't have nroff, so they're probably useless to you."
8912	case "$man1dir" in
8913	'') man1dir="none";;
8914	esac;;
8915esac
8916echo "If you don't want the manual sources installed, answer 'none'."
8917case "$man1dir" in
8918' ') dflt=none
8919	;;
8920'')
8921	lookpath="$prefixexp/share/man/man1"
8922	lookpath="$lookpath $prefixexp/man/man1 $prefixexp/man/l_man/man1"
8923	lookpath="$lookpath $prefixexp/man/p_man/man1"
8924	lookpath="$lookpath $prefixexp/man/u_man/man1"
8925	lookpath="$lookpath $prefixexp/man/man.1"
8926	case "$sysman" in
8927	*/?_man*)	dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
8928	*)	dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
8929	esac
8930	set dflt
8931	eval $prefixup
8932	;;
8933*)  dflt="$man1dir"
8934	;;
8935esac
8936echo " "
8937fn=dn+~
8938rp="Where do the main $spackage manual pages (source) go?"
8939. ./getfile
8940if $test "X$man1direxp" != "X$ansexp"; then
8941	installman1dir=''
8942fi
8943prefixvar=man1dir
8944. ./setprefixvar
8945
8946case "$man1dir" in
8947'')	man1dir=' '
8948	installman1dir='';;
8949esac
8950
8951: What suffix to use on installed man pages
8952
8953case "$man1dir" in
8954' ')
8955	man1ext='0'
8956	;;
8957*)
8958	rp="What suffix should be used for the main $spackage man pages?"
8959	case "$man1ext" in
8960	'')	case "$man1dir" in
8961		*1)  dflt=1 ;;
8962		*1p) dflt=1p ;;
8963		*1pm) dflt=1pm ;;
8964		*l) dflt=l;;
8965		*n) dflt=n;;
8966		*o) dflt=o;;
8967		*p) dflt=p;;
8968		*C) dflt=C;;
8969		*L) dflt=L;;
8970		*L1) dflt=L1;;
8971		*) dflt=1;;
8972		esac
8973		;;
8974	*)	dflt="$man1ext";;
8975	esac
8976	. ./myread
8977	man1ext="$ans"
8978	;;
8979esac
8980
8981: see if we can have long filenames
8982echo " "
8983first=123456789abcdef
8984$rm -f $first
8985if (echo hi >$first) 2>/dev/null; then
8986	if $test -f 123456789abcde; then
8987		echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
8988		val="$undef"
8989	else
8990		echo 'You can have filenames longer than 14 characters.'>&4
8991		val="$define"
8992	fi
8993else
8994	$cat <<'EOM'
8995You can't have filenames longer than 14 chars.
8996You can't even think about them!
8997EOM
8998	val="$undef"
8999fi
9000set d_flexfnam
9001eval $setvar
9002$rm -rf 123456789abcde*
9003
9004: determine where library module manual pages go
9005set man3dir man3dir none
9006eval $prefixit
9007$cat <<EOM
9008
9009$spackage has manual pages for many of the library modules.
9010EOM
9011
9012case "$nroff" in
9013nroff)
9014	$cat <<'EOM'
9015However, you don't have nroff, so they're probably useless to you.
9016EOM
9017	case "$man3dir" in
9018	'') man3dir="none";;
9019	esac;;
9020esac
9021
9022case "$d_flexfnam" in
9023undef)
9024	$cat <<'EOM'
9025However, your system can't handle the long file names like File::Basename.3.
9026EOM
9027	case "$man3dir" in
9028	'') man3dir="none";;
9029	esac;;
9030esac
9031
9032echo "If you don't want the manual sources installed, answer 'none'."
9033prog=`echo $package | $sed 's/-*[0-9.]*$//'`
9034case "$man3dir" in
9035'')	dflt=`echo "$man1dir" | $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'`
9036	if $test -d "$privlib/man/man3"; then
9037		cat <<EOM >&4
9038
9039WARNING:  Previous versions of perl installed man3 pages into
9040$privlib/man/man3.  This version will suggest a
9041new default of $dflt.
9042EOM
9043		tdflt=$dflt
9044		dflt='n'
9045		rp='Do you wish to preserve the old behavior?(y/n)'
9046		. ./myread
9047		case "$ans" in
9048		y*) dflt="$privlib/man/man3" ;;
9049		*)  dflt=$tdflt ;;
9050		esac
9051    fi
9052	;;
9053*)	dflt="$man3dir" ;;
9054esac
9055case "$dflt" in
9056' ') dflt=none ;;
9057esac
9058echo " "
9059fn=dn+~
9060rp="Where do the $package library man pages (source) go?"
9061. ./getfile
9062prefixvar=man3dir
9063. ./setprefixvar
9064
9065case "$man3dir" in
9066'')	man3dir=' '
9067	installman3dir='';;
9068esac
9069
9070: What suffix to use on installed man pages
9071case "$man3dir" in
9072' ')
9073	man3ext='0'
9074	;;
9075*)
9076	rp="What suffix should be used for the $package library man pages?"
9077	case "$man3ext" in
9078	'')	case "$man3dir" in
9079		*3)  dflt=3 ;;
9080		*3p) dflt=3p ;;
9081		*3pm) dflt=3pm ;;
9082		*l) dflt=l;;
9083		*n) dflt=n;;
9084		*o) dflt=o;;
9085		*p) dflt=p;;
9086		*C) dflt=C;;
9087		*L) dflt=L;;
9088		*L3) dflt=L3;;
9089		*) dflt=3;;
9090		esac
9091		;;
9092	*)	dflt="$man3ext";;
9093	esac
9094	. ./myread
9095	man3ext="$ans"
9096	;;
9097esac
9098
9099: see if we have to deal with yellow pages, now NIS.
9100if $test -d /usr/etc/yp || $test -d /etc/yp || $test -d /usr/lib/yp; then
9101	case "$hostcat" in
9102	nidump*) ;;
9103	*)
9104		case "$hostcat" in
9105		*ypcat*) dflt=y;;
9106		'') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
9107				dflt=y
9108			else
9109				dflt=n
9110			fi;;
9111		*) dflt=n;;
9112		esac
9113		echo " "
9114		rp='Are you getting the hosts file via yellow pages?'
9115		. ./myread
9116		case "$ans" in
9117		y*) hostcat='ypcat hosts';;
9118		*) hostcat='cat /etc/hosts';;
9119		esac
9120		;;
9121	esac
9122fi
9123case "$hostcat" in
9124'') test -f /etc/hosts && hostcat='cat /etc/hosts';;
9125esac
9126case "$groupcat" in
9127'') test -f /etc/group && groupcat='cat /etc/group';;
9128esac
9129case "$passcat" in
9130'') test -f /etc/passwd && passcat='cat /etc/passwd';;
9131esac
9132
9133: now get the host name
9134echo " "
9135echo "Figuring out host name..." >&4
9136case "$myhostname" in
9137'') cont=true
9138	echo 'Maybe "hostname" will work...'
9139	if tans=`sh -c hostname 2>&1` ; then
9140		myhostname=$tans
9141		phostname=hostname
9142		cont=''
9143	fi
9144	;;
9145*) cont='';;
9146esac
9147if $test "$cont"; then
9148	if ./xenix; then
9149		echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
9150		if tans=`cat /etc/systemid 2>&1` ; then
9151			myhostname=$tans
9152			phostname='cat /etc/systemid'
9153			echo "Whadyaknow.  Xenix always was a bit strange..."
9154			cont=''
9155		fi
9156	elif $test -r /etc/systemid; then
9157		echo "(What is a non-Xenix system doing with /etc/systemid?)"
9158	fi
9159fi
9160if $test "$cont"; then
9161	echo 'No, maybe "uuname -l" will work...'
9162	if tans=`sh -c 'uuname -l' 2>&1` ; then
9163		myhostname=$tans
9164		phostname='uuname -l'
9165	else
9166		echo 'Strange.  Maybe "uname -n" will work...'
9167		if tans=`sh -c 'uname -n' 2>&1` ; then
9168			myhostname=$tans
9169			phostname='uname -n'
9170		else
9171			echo 'Oh well, maybe I can mine it out of whoami.h...'
9172			if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
9173				myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
9174				phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
9175			else
9176				case "$myhostname" in
9177				'') echo "Does this machine have an identity crisis or something?"
9178					phostname='';;
9179				*)
9180					echo "Well, you said $myhostname before..."
9181					phostname='echo $myhostname';;
9182				esac
9183			fi
9184		fi
9185	fi
9186fi
9187case "$myhostname" in
9188'') myhostname=noname ;;
9189esac
9190: you do not want to know about this
9191set $myhostname
9192myhostname=$1
9193
9194: verify guess
9195if $test "$myhostname" ; then
9196	dflt=y
9197	rp='Your host name appears to be "'$myhostname'".'" Right?"
9198	. ./myread
9199	case "$ans" in
9200	y*) ;;
9201	*) myhostname='';;
9202	esac
9203fi
9204
9205: bad guess or no guess
9206while $test "X$myhostname" = X ; do
9207	dflt=''
9208	rp="Please type the (one word) name of your host:"
9209	. ./myread
9210	myhostname="$ans"
9211done
9212
9213: translate upper to lower if necessary
9214case "$myhostname" in
9215*[A-Z]*)
9216	echo "(Normalizing case in your host name)"
9217	myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
9218	;;
9219esac
9220
9221case "$myhostname" in
9222*.*)
9223	dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
9224	myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
9225	echo "(Trimming domain name from host name--host name is now $myhostname)"
9226	;;
9227*) case "$mydomain" in
9228	'')
9229		{
9230			test "X$hostcat" = "Xypcat hosts" &&
9231			ypmatch "$myhostname" hosts 2>/dev/null |\
9232				$sed -e 's/[	 ]*#.*//; s/$/ /' > hosts && \
9233			$test -s hosts
9234		} || {
9235			test "X$hostcat" != "X" &&
9236			$hostcat | $sed -n -e "s/[	 ]*#.*//; s/\$/ /
9237					/[	 ]$myhostname[	. ]/p" > hosts
9238		}
9239		tmp_re="[	. ]"
9240		if $test -f hosts; then
9241			$test x`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ { sum++ }
9242			     END { print sum }" hosts` = x1 || tmp_re="[	 ]"
9243			dflt=.`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
9244				hosts | $sort | $uniq | \
9245				$sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
9246			case `$echo X$dflt` in
9247			X*\ *)	echo "(Several hosts in the database matched hostname)"
9248				dflt=.
9249				;;
9250			X.) echo "(You do not have fully-qualified names in the hosts database)"
9251				;;
9252			esac
9253		else
9254			echo "(I cannot locate a hosts database anywhere)"
9255			dflt=.
9256		fi
9257		case "$dflt" in
9258		.)
9259			tans=`./loc resolv.conf X /etc /usr/etc`
9260			if $test -f "$tans"; then
9261				echo "(Attempting domain name extraction from $tans)"
9262				dflt=.`$sed -n -e 's/	/ /g' \
9263				  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
9264				  -e 1q 2>/dev/null`
9265				case "$dflt" in
9266				.) dflt=.`$sed -n -e 's/	/ /g' \
9267				     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
9268				     -e 1q 2>/dev/null`
9269					;;
9270				esac
9271			fi
9272			;;
9273		esac
9274		case "$dflt" in
9275		.) echo "(No help from resolv.conf either -- attempting clever guess)"
9276			dflt=.`sh -c domainname 2>/dev/null`
9277			case "$dflt" in
9278			'') dflt='.';;
9279			.nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
9280			esac
9281			;;
9282		esac
9283		case "$dflt$osname" in
9284		.os390) echo "(Attempting domain name extraction from //'SYS1.TCPPARMS(TCPDATA)')"
9285			dflt=.`awk '/^DOMAINORIGIN/ {print $2}' "//'SYS1.TCPPARMS(TCPDATA)'" 2>/dev/null`
9286			;;
9287		esac
9288		case "$dflt" in
9289		.) echo "(Lost all hope -- silly guess then)"
9290			dflt='.nonet'
9291			;;
9292		esac
9293		$rm -f hosts
9294		;;
9295	*) dflt="$mydomain";;
9296	esac;;
9297esac
9298echo " "
9299rp="What is your domain name?"
9300. ./myread
9301tans="$ans"
9302case "$ans" in
9303'') ;;
9304.*) ;;
9305*) tans=".$tans";;
9306esac
9307mydomain="$tans"
9308
9309: translate upper to lower if necessary
9310case "$mydomain" in
9311*[A-Z]*)
9312	echo "(Normalizing case in your domain name)"
9313	mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
9314	;;
9315esac
9316
9317: a little sanity check here
9318case "$phostname" in
9319'') ;;
9320*)
9321	case `$phostname | ./tr '[A-Z]' '[a-z]'` in
9322	$myhostname$mydomain|$myhostname) ;;
9323	*)
9324		case "$phostname" in
9325		sed*)
9326			echo "(That doesn't agree with your whoami.h file, by the way.)"
9327			;;
9328		*)
9329			echo "(That doesn't agree with your $phostname command, by the way.)"
9330			;;
9331		esac
9332	;;
9333	esac
9334	;;
9335esac
9336
9337: determine the e-mail address of the user who is running us
9338$cat <<EOM
9339
9340I need to get your e-mail address in Internet format if possible, i.e.
9341something like user@host.domain. Please answer accurately since I have
9342no easy means to double check it. The default value provided below
9343is most probably close to reality but may not be valid from outside
9344your organization...
9345
9346EOM
9347cont=x
9348while test "$cont"; do
9349	case "$MAILDOMAIN" in
9350	'')
9351		if $test -s /etc/mailname; then
9352			maildomain=`$cat /etc/mailname`
9353		else
9354			maildomain="$myhostname$mydomain"
9355		fi
9356		;;
9357	*)  maildomain="$MAILDOMAIN";;
9358	esac
9359	case "$cf_email" in
9360	'') dflt="$cf_by@$maildomain";;
9361	*)  dflt="$cf_email";;
9362	esac
9363	rp='What is your e-mail address?'
9364	. ./myread
9365	cf_email="$ans"
9366	case "$cf_email" in
9367	*@*.*) cont='' ;;
9368	*)
9369		rp='Address does not look like an Internet one.  Use it anyway?'
9370		case "$fastread" in
9371		yes) dflt=y ;;
9372		*) dflt=n ;;
9373		esac
9374		. ./myread
9375		case "$ans" in
9376		y*) cont='' ;;
9377		*) echo " " ;;
9378		esac
9379		;;
9380	esac
9381done
9382
9383: Ask e-mail of administrator
9384$cat <<EOM
9385
9386If you or somebody else will be maintaining perl at your site, please
9387fill in the correct e-mail address here so that they may be contacted
9388if necessary. Currently, the "perlbug" program included with perl
9389will send mail to this address in addition to perlbug@perl.org. You may
9390enter "none" for no administrator.
9391
9392EOM
9393case "$perladmin" in
9394'') dflt="$cf_email";;
9395*) dflt="$perladmin";;
9396esac
9397rp='Perl administrator e-mail address'
9398. ./myread
9399perladmin="$ans"
9400
9401: determine whether to use a version number suffix for installed binaries
9402echo " "
9403$cat <<EOM
9404Do you want to use a version number suffix for installed binaries? This
9405will install 'perl$version' instead of 'perl', and likewise for other
9406binaries like 'perldoc' and 'cpan'. This allows many versions of perl
9407to be installed side-by-side. Unless you are a developer, you probably
9408do *not* want to do this.
9409EOM
9410case "$versiononly" in
9411"$define"|[Yy]*|true) dflt='y' ;;
9412*) dflt='n';
9413esac
9414rp="Do you want to use a version number suffix for installed binaries?"
9415. ./myread
9416case "$ans" in
9417[yY]*)	val="$define";;
9418*)	val="$undef" ;;
9419esac
9420set versiononly
9421eval $setvar
9422
9423case "$versiononly" in
9424"$define") inc_version_list=''
9425           inc_version_list_init=0
9426           ;;
9427esac
9428
9429: figure out how to guarantee perl startup
9430: XXX Note that this currently takes advantage of the bug that binexp ignores
9431:     the Configure -Dinstallprefix setting, which in turn means that under
9432:     relocatable @INC, initialinstalllocation is what binexp started as.
9433case "$startperl" in
9434'')
9435	case "$sharpbang" in
9436	*!)
9437		$cat <<EOH
9438
9439I can use the #! construct to start perl on your system. This will
9440make startup of perl scripts faster, but may cause problems if you
9441want to share those scripts and perl is not in a standard place
9442($initialinstalllocation/perl) on all your platforms. The alternative
9443is to force a shell by starting the script with a single ':' character.
9444
9445EOH
9446		case "$versiononly" in
9447		"$define")      dflt="$initialinstalllocation/perl$version";;
9448		*)              dflt="$initialinstalllocation/perl";;
9449		esac
9450		rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
9451		. ./myread
9452		case "$ans" in
9453		none)	startperl=": # use perl";;
9454		*)	startperl="#!$ans"
9455			if $test 30 -lt `echo "$ans" | wc -c`; then
9456				$cat >&4 <<EOM
9457
9458WARNING:  Some systems limit the #! command to 32 characters.
9459If you experience difficulty running Perl scripts with #!, try
9460installing Perl in a directory with a shorter pathname.
9461
9462EOM
9463			fi ;;
9464		esac
9465		;;
9466	*) startperl=": # use perl"
9467		;;
9468	esac
9469	;;
9470esac
9471echo "I'll use $startperl to start perl scripts."
9472
9473: figure best path for perl in scripts
9474case "$perlpath" in
9475'')
9476	case "$versiononly" in
9477	"$define")	perlpath="$initialinstalllocation/perl$version";;
9478	*)		perlpath="$initialinstalllocation/perl";;
9479	esac
9480	case "$startperl" in
9481	*!*) ;;
9482	*)
9483		$cat <<EOH
9484
9485I will use the "eval 'exec'" idiom to start Perl on your system.
9486I can use the full path of your Perl binary for this purpose, but
9487doing so may cause problems if you want to share those scripts and
9488Perl is not always in a standard place ($initialinstalllocation/perl).
9489
9490EOH
9491		dflt="$initialinstalllocation/perl"
9492		rp="What path shall I use in \"eval 'exec'\"?"
9493		. ./myread
9494		perlpath="$ans"
9495		;;
9496	esac
9497	;;
9498esac
9499case "$startperl" in
9500*!*)	;;
9501*)	echo "I'll use $perlpath in \"eval 'exec'\"" ;;
9502esac
9503
9504: determine where public executable scripts go
9505set scriptdir scriptdir
9506eval $prefixit
9507case "$scriptdir" in
9508'')
9509	dflt="$bin"
9510	: guess some guesses
9511	$test -d /usr/share/scripts && dflt=/usr/share/scripts
9512	$test -d /usr/share/bin     && dflt=/usr/share/bin
9513	$test -d /usr/local/script  && dflt=/usr/local/script
9514	$test -d /usr/local/scripts && dflt=/usr/local/scripts
9515	$test -d $prefixexp/script  && dflt=$prefixexp/script
9516	set dflt
9517	eval $prefixup
9518	;;
9519*)  dflt="$scriptdir"
9520	;;
9521esac
9522$cat <<EOM
9523
9524Some installations have a separate directory just for executable scripts so
9525that they can mount it across multiple architectures but keep the scripts in
9526one spot.  You might, for example, have a subdirectory of /usr/share for this.
9527Or you might just lump your scripts in with all your other executables.
9528
9529EOM
9530fn=d~
9531rp='Where do you keep publicly executable scripts?'
9532. ./getfile
9533if $test "X$ansexp" != "X$scriptdirexp"; then
9534	installscript=''
9535fi
9536installscriptdir=''
9537prefixvar=scriptdir
9538. ./setprefixvar
9539: A little fix up for an irregularly named variable.
9540installscript="$installscriptdir"
9541
9542: determine where add-on public executables go
9543case "$sitebin" in
9544'')	dflt=$siteprefix/bin ;;
9545*)	dflt=$sitebin ;;
9546esac
9547fn=d~
9548rp='Pathname where the add-on public executables should be installed?'
9549. ./getfile
9550prefixvar=sitebin
9551. ./setprefixvar
9552
9553: determine where add-on html pages go
9554: There is no standard location, so try to copy the previously-selected
9555: directory structure for the core html pages.
9556case "$sitehtml1dir" in
9557'')    dflt=`echo "$html1dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9558*)     dflt=$sitehtml1dir ;;
9559esac
9560case "$dflt" in
9561''|' ') dflt=none ;;
9562esac
9563fn=dn+~
9564rp='Pathname where the site-specific html pages should be installed?'
9565. ./getfile
9566prefixvar=sitehtml1dir
9567. ./setprefixvar
9568
9569: determine where add-on library html pages go
9570: There is no standard location, so try to copy the previously-selected
9571: directory structure for the core html pages.
9572case "$sitehtml3dir" in
9573'')    dflt=`echo "$html3dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9574*)     dflt=$sitehtml3dir ;;
9575esac
9576case "$dflt" in
9577''|' ') dflt=none ;;
9578esac
9579fn=dn+~
9580rp='Pathname where the site-specific library html pages should be installed?'
9581. ./getfile
9582prefixvar=sitehtml3dir
9583. ./setprefixvar
9584
9585: determine where add-on manual pages go
9586case "$siteman1dir" in
9587'')	dflt=`echo $man1dir | $sed "s#^$prefix#$siteprefix#"` ;;
9588*)	dflt=$siteman1dir ;;
9589esac
9590case "$dflt" in
9591''|' ') dflt=none ;;
9592esac
9593fn=dn+~
9594rp='Pathname where the site-specific manual pages should be installed?'
9595. ./getfile
9596prefixvar=siteman1dir
9597. ./setprefixvar
9598
9599: determine where add-on library man pages go
9600case "$siteman3dir" in
9601'')	dflt=`echo $man3dir | $sed "s#^$prefix#$siteprefix#"` ;;
9602*)	dflt=$siteman3dir ;;
9603esac
9604case "$dflt" in
9605''|' ') dflt=none ;;
9606esac
9607fn=dn+~
9608rp='Pathname where the site-specific library manual pages should be installed?'
9609. ./getfile
9610prefixvar=siteman3dir
9611. ./setprefixvar
9612
9613: determine where add-on public executable scripts go
9614case "$sitescript" in
9615'')	dflt=$siteprefix/script
9616	$test -d $dflt || dflt=$sitebin ;;
9617*)  dflt="$sitescript" ;;
9618esac
9619fn=d~+
9620rp='Pathname where add-on public executable scripts should be installed?'
9621. ./getfile
9622prefixvar=sitescript
9623. ./setprefixvar
9624
9625: see if backtrace exists
9626set backtrace d_backtrace
9627eval $inlibc
9628
9629: add flags if using c backtrace
9630case "$usecbacktrace" in
9631  "") usecbacktrace=$undef ;;
9632  [yY]*|true|$define)
9633    case "$d_backtrace" in
9634      [yY]*|true|$define)
9635        case " $ccflags " in
9636	  *" -DUSE_C_BACKTRACE "*) ;; # Already there.
9637	  *) ccflags="$ccflags -DUSE_C_BACKTRACE -g" ;;
9638	  esac
9639        ;;
9640      *)
9641        echo "This system does not support backtrace" >&4
9642        usecbacktrace=$undef
9643        ;;
9644      esac
9645    ;;
9646  esac
9647
9648: Check if faststdio is requested and available
9649case "$usefaststdio" in
9650$define|true|[yY]*|'')
9651	xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
9652	case "$xversion" in
9653	[68])	dflt='y' ;;
9654	*)	dflt='n' ;;
9655	esac
9656	;;
9657*) dflt='n';;
9658esac
9659cat <<EOM
9660
9661Perl can be built to use 'fast stdio', which means using the stdio
9662library but also directly manipulating the stdio buffers to enable
9663faster I/O.  Using stdio is better for backward compatibility (especially
9664for Perl extensions), but on the other hand since Perl 5.8 the 'perlio'
9665interface has been preferred instead of stdio.
9666
9667If this doesn't make any sense to you, just accept the default '$dflt'.
9668EOM
9669rp='Use the "fast stdio" if available?'
9670. ./myread
9671case "$ans" in
9672y|Y)	val="$define" ;;
9673*)      val="$undef" ;;
9674esac
9675set usefaststdio
9676eval $setvar
9677
9678: define an is-a-typedef? function
9679typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9680case "$inclist" in
9681"") inclist="sys/types.h";;
9682esac;
9683eval "varval=\$$var";
9684case "$varval" in
9685"")
9686	$rm -f temp.c;
9687	for inc in $inclist; do
9688		echo "#include <$inc>" >>temp.c;
9689	done;
9690	echo "#ifdef $type" >> temp.c;
9691	echo "printf(\"We have $type\");" >> temp.c;
9692	echo "#endif" >> temp.c;
9693	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9694	if $contains $type temp.E >/dev/null 2>&1; then
9695		eval "$var=\$type";
9696	else
9697		eval "$var=\$def";
9698	fi;
9699	$rm -f temp.?;;
9700*) eval "$var=\$varval";;
9701esac'
9702
9703: define an is-a-typedef? function that prompts if the type is not available.
9704typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9705case "$inclist" in
9706"") inclist="sys/types.h";;
9707esac;
9708eval "varval=\$$var";
9709case "$varval" in
9710"")
9711	$rm -f temp.c;
9712	for inc in $inclist; do
9713		echo "#include <$inc>" >>temp.c;
9714	done;
9715	echo "#ifdef $type" >> temp.c;
9716	echo "printf(\"We have $type\");" >> temp.c;
9717	echo "#endif" >> temp.c;
9718	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9719	echo " " ;
9720	echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
9721	if $contains $type temp.E >/dev/null 2>&1; then
9722		echo "$type found." >&4;
9723		eval "$var=\$type";
9724	else
9725		echo "$type NOT found." >&4;
9726		dflt="$def";
9727		. ./myread ;
9728		eval "$var=\$ans";
9729	fi;
9730	$rm -f temp.?;;
9731*) eval "$var=\$varval";;
9732esac'
9733
9734: see what type lseek is declared as in the kernel
9735rp="What is the type used for lseek's offset on this system?"
9736set off_t lseektype long stdio.h sys/types.h
9737eval $typedef_ask
9738
9739echo " "
9740echo "Checking to see how big your file offsets are..." >&4
9741$cat >try.c <<EOCP
9742#include <sys/types.h>
9743#include <stdio.h>
9744int main()
9745{
9746    printf("%d\n", (int)sizeof($lseektype));
9747    return(0);
9748}
9749EOCP
9750set try
9751if eval $compile_ok; then
9752	lseeksize=`$run ./try`
9753	echo "Your file offsets are $lseeksize bytes long."
9754else
9755	dflt=$longsize
9756	echo " "
9757	echo "(I can't seem to compile the test program.  Guessing...)"
9758	rp="What is the size of your file offsets (in bytes)?"
9759	. ./myread
9760	lseeksize="$ans"
9761fi
9762$rm_try
9763
9764: see what type file positions are declared as in the library
9765rp="What is the type for file position used by fsetpos()?"
9766set fpos_t fpostype long stdio.h sys/types.h
9767eval $typedef_ask
9768
9769: Check size for Fpos_t
9770echo " "
9771case "$fpostype" in
9772*_t) zzz="$fpostype"	;;
9773*)   zzz="fpos_t"	;;
9774esac
9775echo "Checking the size of $zzz..." >&4
9776cat > try.c <<EOCP
9777#include <sys/types.h>
9778#include <stdio.h>
9779#$i_stdlib I_STDLIB
9780#ifdef I_STDLIB
9781#include <stdlib.h>
9782#endif
9783int main() {
9784    printf("%d\n", (int)sizeof($fpostype));
9785    exit(0);
9786}
9787EOCP
9788set try
9789if eval $compile_ok; then
9790	yyy=`$run ./try`
9791	case "$yyy" in
9792	'')	fpossize=4
9793		echo "(I can't execute the test program--guessing $fpossize.)" >&4
9794		;;
9795	*)	fpossize=$yyy
9796		echo "Your $zzz is $fpossize bytes long."
9797		;;
9798	esac
9799else
9800	dflt="$longsize"
9801	echo " " >&4
9802	echo "(I can't compile the test program.  Guessing...)" >&4
9803	rp="What is the size of your file positions (in bytes)?"
9804	. ./myread
9805	fpossize="$ans"
9806fi
9807
9808: Check for large file support
9809# Backward compatibility (uselfs is deprecated).
9810case "$uselfs" in
9811"$define"|true|[yY]*)
9812	cat <<EOM >&4
9813
9814*** Configure -Duselfs is deprecated, using -Duselargefiles instead.
9815EOM
9816	uselargefiles="$define"
9817	;;
9818esac
9819
9820case "$lseeksize:$fpossize" in
98218:8) cat <<EOM
9822
9823You can have files larger than 2 gigabytes.
9824EOM
9825   val="$define" ;;
9826*)    case "$uselargefiles" in
9827   "$undef"|false|[nN]*) dflt='n' ;;
9828   *)	dflt='y' ;;
9829   esac
9830   cat <<EOM
9831
9832Perl can be built to understand large files (files larger than 2 gigabytes)
9833on some systems.  To do so, Configure can be run with -Duselargefiles.
9834
9835If this doesn't make any sense to you, just accept the default '$dflt'.
9836EOM
9837   rp='Try to understand large files, if available?'
9838   . ./myread
9839   case "$ans" in
9840   y|Y)	val="$define" ;;
9841   *)	val="$undef"  ;;
9842   esac
9843   ;;
9844esac
9845set uselargefiles
9846eval $setvar
9847: Look for a hint-file generated 'call-back-unit'.  If the
9848: user has specified that a large files perl is to be built,
9849: we may need to set or change some other defaults.
9850if $test -f uselargefiles.cbu; then
9851	echo "Your platform has some specific hints regarding large file builds, using them..."
9852	. ./uselargefiles.cbu
9853fi
9854case "$uselargefiles" in
9855"$define")
9856	if $test -f uselargefiles.cbu; then
9857		echo " "
9858		echo "Rechecking to see how big your file offsets are..." >&4
9859		$cat >try.c <<EOCP
9860#include <sys/types.h>
9861#include <stdio.h>
9862int main()
9863{
9864    printf("%d\n", (int)sizeof($lseektype));
9865    return(0);
9866}
9867EOCP
9868		set try
9869		if eval $compile_ok; then
9870			lseeksize=`$run ./try`
9871			$echo "Your file offsets are now $lseeksize bytes long."
9872		else
9873			dflt="$lseeksize"
9874			echo " "
9875			echo "(I can't seem to compile the test program.  Guessing...)"
9876			rp="What is the size of your file offsets (in bytes)?"
9877			. ./myread
9878			lseeksize="$ans"
9879		fi
9880		case "$fpostype" in
9881		*_t) zzz="$fpostype"	;;
9882		*)   zzz="fpos_t"	;;
9883		esac
9884		$echo $n "Rechecking the size of $zzz...$c" >&4
9885		$cat > try.c <<EOCP
9886#include <sys/types.h>
9887#include <stdio.h>
9888#$i_stdlib I_STDLIB
9889#ifdef I_STDLIB
9890#include <stdlib.h>
9891#endif
9892int main() {
9893    printf("%d\n", (int)sizeof($fpostype));
9894    return(0);
9895}
9896EOCP
9897		set try
9898		if eval $compile_ok; then
9899			yyy=`$run ./try`
9900			dflt="$lseeksize"
9901			case "$yyy" in
9902			'')	echo " "
9903				echo "(I can't execute the test program--guessing $fpossize.)" >&4
9904				;;
9905			*)	fpossize=$yyy
9906				echo " $fpossize bytes." >&4
9907				;;
9908			esac
9909		else
9910			dflt="$fpossize"
9911			echo " "
9912			echo "(I can't compile the test program.  Guessing...)" >&4
9913			rp="What is the size of your file positions (in bytes)?"
9914			. ./myread
9915			fpossize="$ans"
9916		fi
9917		$rm_try
9918	fi
9919	;;
9920esac
9921
9922: Check if we want perlio
9923useperlio="$define"
9924
9925: Set the vendorbin variables
9926case "$vendorprefix" in
9927'')	d_vendorbin="$undef"
9928	vendorbin=''
9929	vendorbinexp=''
9930	;;
9931*)	d_vendorbin="$define"
9932	: determine where vendor-supplied executables go.
9933	case "$vendorbin" in
9934	'') dflt=$vendorprefix/bin ;;
9935	*)	dflt="$vendorbin" ;;
9936	esac
9937	fn=d~+
9938	rp='Pathname for the vendor-supplied executables directory?'
9939	. ./getfile
9940	vendorbin="$ans"
9941	vendorbinexp="$ansexp"
9942	;;
9943esac
9944prefixvar=vendorbin
9945. ./installprefix
9946
9947: Set the vendorhtml1dir variables
9948case "$vendorprefix" in
9949'')	vendorhtml1dir=''
9950	vendorhtml1direxp=''
9951	;;
9952*)	: determine where vendor-supplied html pages go.
9953	: There is no standard location, so try to copy the previously-selected
9954	: directory structure for the core html pages.
9955	: XXX Better default suggestions would be welcome.
9956	case "$vendorhtml1dir" in
9957	'')	dflt=`echo "$html1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9958	*)	dflt=$vendorhtml1dir ;;
9959	esac
9960	case "$dflt" in
9961	''|' ') dflt=none ;;
9962	esac
9963	fn=dn+~
9964	rp='Pathname for the vendor-supplied html pages?'
9965	. ./getfile
9966	vendorhtml1dir="$ans"
9967	vendorhtml1direxp="$ansexp"
9968	;;
9969esac
9970: Use ' ' for none so value is preserved next time through Configure
9971$test X"$vendorhtml1dir" = "X" && vendorhtml1dir=' '
9972prefixvar=vendorhtml1dir
9973. ./installprefix
9974
9975: Set the vendorhtml3dir variables
9976case "$vendorprefix" in
9977'')	vendorhtml3dir=''
9978	vendorhtml3direxp=''
9979	;;
9980*)	: determine where vendor-supplied module html pages go.
9981	: There is no standard location, so try to copy the previously-selected
9982	: directory structure for the core html pages.
9983	: XXX Better default suggestions would be welcome.
9984	case "$vendorhtml3dir" in
9985	'')	dflt=`echo "$html3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9986	*)	dflt=$vendorhtml3dir ;;
9987	esac
9988	case "$dflt" in
9989	''|' ') dflt=none ;;
9990	esac
9991	fn=dn+~
9992	rp='Pathname for the vendor-supplied html pages?'
9993	. ./getfile
9994	vendorhtml3dir="$ans"
9995	vendorhtml3direxp="$ansexp"
9996	;;
9997esac
9998: Use ' ' for none so value is preserved next time through Configure
9999$test X"$vendorhtml3dir" = "X" && vendorhtml3dir=' '
10000prefixvar=vendorhtml3dir
10001. ./installprefix
10002
10003: Set the vendorman1dir variables
10004case "$vendorprefix" in
10005'')	vendorman1dir=''
10006	vendorman1direxp=''
10007	;;
10008*)	: determine where vendor-supplied manual pages go.
10009	case "$vendorman1dir" in
10010	'') dflt=`echo "$man1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10011	*)	dflt=$vendorman1dir ;;
10012	esac
10013	case "$dflt" in
10014	''|' ') dflt=none ;;
10015	esac
10016	fn=nd~+
10017	rp='Pathname for the vendor-supplied manual section 1 pages?'
10018	. ./getfile
10019	vendorman1dir="$ans"
10020	vendorman1direxp="$ansexp"
10021	;;
10022esac
10023: Use ' ' for none so value is preserved next time through Configure
10024$test X"$vendorman1dir" = "X" && vendorman1dir=' '
10025prefixvar=vendorman1dir
10026. ./installprefix
10027
10028: Set the vendorman3dir variables
10029case "$vendorprefix" in
10030'')	vendorman3dir=''
10031	vendorman3direxp=''
10032	;;
10033*)	: determine where vendor-supplied module manual pages go.
10034	case "$vendorman3dir" in
10035	'') dflt=`echo "$man3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10036	*)	dflt=$vendorman3dir ;;
10037	esac
10038	case "$dflt" in
10039	''|' ') dflt=none ;;
10040	esac
10041	fn=nd~+
10042	rp='Pathname for the vendor-supplied manual section 3 pages?'
10043	. ./getfile
10044	vendorman3dir="$ans"
10045	vendorman3direxp="$ansexp"
10046	;;
10047esac
10048: Use ' ' for none so value is preserved next time through Configure
10049$test X"$vendorman3dir" = "X" && vendorman3dir=' '
10050prefixvar=vendorman3dir
10051. ./installprefix
10052
10053: Set the vendorscript variables
10054case "$vendorprefix" in
10055'')	d_vendorscript="$undef"
10056	vendorscript=''
10057	vendorscriptexp=''
10058	;;
10059*)	d_vendorscript="$define"
10060	: determine where vendor-supplied scripts go.
10061	case "$vendorscript" in
10062	'')	dflt=$vendorprefix/script
10063		$test -d $dflt || dflt=$vendorbin ;;
10064	*)  dflt="$vendorscript" ;;
10065	esac
10066	$cat <<EOM
10067
10068The installation process will create a directory for
10069vendor-supplied scripts.
10070
10071EOM
10072	fn=d~+
10073	rp='Pathname for the vendor-supplied scripts directory?'
10074	. ./getfile
10075	vendorscript="$ans"
10076	vendorscriptexp="$ansexp"
10077	;;
10078esac
10079prefixvar=vendorscript
10080. ./installprefix
10081
10082: see if qgcvt exists
10083set qgcvt d_qgcvt
10084eval $inlibc
10085
10086: Check what kind of doubles your system has
10087$echo "Checking the kind of doubles you have..." >&4
10088$cat >try.c <<EOP
10089#$i_stdlib I_STDLIB
10090#define DOUBLESIZE $doublesize
10091#ifdef I_STDLIB
10092#include <stdlib.h>
10093#endif
10094#include <stdio.h>
10095static const double d = -0.1;
10096int main() {
10097  unsigned const char* b = (unsigned const char*)(&d);
10098#if DOUBLESIZE == 4
10099  if (b[0] == 0xCD && b[3] == 0xBD) {
10100    /* IEEE 754 32-bit little-endian */
10101    printf("1\n");
10102    exit(0);
10103  }
10104  if (b[0] == 0xBD && b[3] == 0xCD) {
10105    /* IEEE 754 32-bit big-endian */
10106    printf("2\n");
10107    exit(0);
10108  }
10109  if (b[0] == 0xCC && b[3] == 0xCC) {
10110    /* VAX format F, 32-bit PDP-style mixed endian. */
10111    printf("9\n");
10112    exit(0);
10113  }
10114  if (b[0] == 0xC0 && b[3] == 0x9A) {
10115    /* IBM single 32-bit */
10116    printf("12\n");
10117    exit(0);
10118  }
10119#endif
10120#if DOUBLESIZE == 8
10121  if (b[0] == 0x9A && b[7] == 0xBF) {
10122    /* IEEE 754 64-bit little-endian */
10123    printf("3\n");
10124    exit(0);
10125  }
10126  if (b[0] == 0xBF && b[7] == 0x9A) {
10127    /* IEEE 754 64-bit big-endian */
10128    printf("4\n");
10129    exit(0);
10130  }
10131  if (b[0] == 0x99 && b[3] == 0xBF && b[4] == 0x9A && b[7] == 0x99) {
10132   /* ARM mixed endian: two little-endian 32-bit floats, in big endian order:
10133    * 4 5 6 7 0 1 2 3 (MSB = 7, LSB = 0)
10134    * 99 99 b9 bf 9a 99 99 99 */
10135    printf("7\n");
10136    exit(0);
10137  }
10138  if (b[0] == 0x99 && b[3] == 0x9A && b[4] == 0xBF && b[7] == 0x99) {
10139   /* The opposite of case 7, mixed endian: two big-endian 32-bit floats,
10140    * in little endian order: 3 2 1 0 7 6 5 4 (MSB = 7, LSB = 0)
10141    * 99 99 99 9a bf b9 99 99 */
10142    printf("8\n");
10143    exit(0);
10144  }
10145  if (b[0] == 0xCC && b[7] == 0xCC) {
10146   /* VAX format D, 64-bit PDP-style mixed endian. */
10147    printf("10\n");
10148    exit(0);
10149  }
10150  if (b[0] == 0xD9 && b[7] == 0x99) {
10151   /* VAX format G, 64-bit PDP-style mixed endian. */
10152    printf("11\n");
10153    exit(0);
10154  }
10155  if (b[0] == 0xC0 && b[7] == 0x9A) {
10156    /* IBM double 64-bit */
10157    printf("13\n");
10158    exit(0);
10159  }
10160  if (b[0] == 0xBF && b[7] == 0xCD) {
10161    /* CRAY single 64-bit */
10162    printf("14\n");
10163    exit(0);
10164  }
10165#endif
10166#if DOUBLESIZE == 16
10167  if (b[0] == 0x9A && b[15] == 0xBF) {
10168    /* IEEE 754 128-bit little-endian */
10169    printf("5\n");
10170    exit(0);
10171  }
10172  if (b[0] == 0xBF && b[15] == 0x9A) {
10173    /* IEEE 754 128-bit big-endian */
10174    printf("6\n");
10175    exit(0);
10176  }
10177#endif
10178  /* Then there are old mainframe/miniframe formats like IBM and CRAY.
10179   * Whether those environments can still build Perl is debatable. */
10180  printf("-1\n"); /* unknown */
10181  exit(0);
10182}
10183EOP
10184set try
10185if eval $compile; then
10186    doublekind=`$run ./try`
10187else
10188    doublekind=-1
10189fi
10190case "$doublekind" in
101911) echo "You have IEEE 754 32-bit little endian doubles." >&4 ;;
101922) echo "You have IEEE 754 32-bit big endian doubles." >&4 ;;
101933) echo "You have IEEE 754 64-bit little endian doubles." >&4 ;;
101944) echo "You have IEEE 754 64-bit big endian doubles." >&4 ;;
101955) echo "You have IEEE 754 128-bit little endian doubles." >&4 ;;
101966) echo "You have IEEE 754 128-bit big endian doubles." >&4 ;;
101977) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit LEs in BE)." >&4 ;;
101988) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit BEs in LE)." >&4 ;;
101999) echo "You have VAX format F 32-bit PDP-style mixed endian doubles." >&4 ;;
1020010) echo "You have VAX format D 64-bit PDP-style mixed endian doubles." >&4 ;;
1020111) echo "You have VAX format G 64-bit PDP-style mixed endian doubles." >&4 ;;
1020212) echo "You have IBM short 32-bit doubles." >&4 ;;
1020313) echo "You have IBM long 64-bit doubles." >&4 ;;
1020414) echo "You have Cray single 64-bit doubles." >&4 ;;
10205*) echo "Cannot figure out your double.  You Cyber, or something?" >&4 ;;
10206esac
10207d_double_style_ieee=$undef
10208d_double_style_vax=$undef
10209d_double_style_ibm=$undef
10210d_double_style_cray=$undef
10211case "$doublekind" in
102121|2|3|4|5|6|7|8) d_double_style_ieee=$define ;;
102139|10|11) d_double_style_vax=$define ;;
1021412|13) d_double_style_ibm=$define ;;
1021514) d_double_style_cray=$define ;;
10216esac
10217case "$d_double_style_ieee" in
10218$define)
10219    d_double_has_inf=$define
10220    d_double_has_nan=$define
10221    d_double_has_negative_zero=$define
10222    d_double_has_subnormals=$define
10223    ;;
10224*)
10225    d_double_has_inf=$undef
10226    d_double_has_nan=$undef
10227    d_double_has_negative_zero=$undef
10228    d_double_has_subnormals=$undef
10229    ;;
10230esac
10231$rm_try
10232
10233: Check print/scan long double stuff
10234echo " "
10235
10236if $test X"$d_longdbl" = X"$define"; then
10237
10238echo "Checking how to print long doubles..." >&4
10239
10240if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
10241	$cat >try.c <<'EOCP'
10242#include <sys/types.h>
10243#include <stdio.h>
10244int main() {
10245  double d = 123.456;
10246  printf("%.3f\n", d);
10247}
10248EOCP
10249	set try
10250	if eval $compile; then
10251		yyy=`$run ./try`
10252		case "$yyy" in
10253		123.456)
10254			sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
10255			sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
10256			echo "We will use %f."
10257			;;
10258		esac
10259	fi
10260fi
10261
10262if $test X"$sPRIfldbl" = X; then
10263	$cat >try.c <<'EOCP'
10264#include <sys/types.h>
10265#include <stdio.h>
10266int main() {
10267  long double d = 123.456;
10268  printf("%.3Lf\n", d);
10269}
10270EOCP
10271	set try
10272	if eval $compile; then
10273		yyy=`$run ./try`
10274		case "$yyy" in
10275		123.456)
10276			sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
10277			sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
10278			echo "We will use %Lf."
10279			;;
10280		esac
10281	fi
10282fi
10283
10284if $test X"$sPRIfldbl" = X; then
10285	$cat >try.c <<'EOCP'
10286#include <sys/types.h>
10287#include <stdio.h>
10288int main() {
10289  long double d = 123.456;
10290  printf("%.3llf\n", d);
10291}
10292EOCP
10293	set try
10294	if eval $compile; then
10295		yyy=`$run ./try`
10296		case "$yyy" in
10297		123.456)
10298			sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
10299			sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
10300			echo "We will use %llf."
10301			;;
10302		esac
10303	fi
10304fi
10305
10306if $test X"$sPRIfldbl" = X; then
10307	$cat >try.c <<'EOCP'
10308#include <sys/types.h>
10309#include <stdio.h>
10310int main() {
10311  long double d = 123.456;
10312  printf("%.3lf\n", d);
10313}
10314EOCP
10315	set try
10316	if eval $compile; then
10317		yyy=`$run ./try`
10318		case "$yyy" in
10319		123.456)
10320			sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
10321			sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
10322			echo "We will use %lf."
10323			;;
10324		esac
10325	fi
10326fi
10327
10328if $test X"$sPRIfldbl" = X; then
10329	echo "Cannot figure out how to print long doubles." >&4
10330else
10331	sSCNfldbl=$sPRIfldbl	# expect consistency
10332fi
10333
10334$rm_try
10335
10336fi # d_longdbl
10337
10338case "$sPRIfldbl" in
10339'')	d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
10340	d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
10341	d_SCNfldbl="$undef";
10342	;;
10343*)	d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
10344	d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
10345	d_SCNfldbl="$define";
10346	;;
10347esac
10348
10349: Before committing on uselongdouble, see whether that looks sane.
10350if $test "$uselongdouble" = "$define"; then
10351    message=""
10352    echo " "
10353    echo "Checking if your long double math functions work right..." >&4
10354    $cat > try.c <<EOF
10355#include <math.h>
10356#include <stdio.h>
10357int main() {
10358  printf("%"$sPRIgldbl"\n", sqrtl(logl(expl(cosl(sinl(0.0L))))+powl(2.0L, 3.0L)));
10359}
10360EOF
10361    case "$osname:$gccversion" in
10362    aix:)	saveccflags="$ccflags"
10363		ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
10364    esac
10365    set try
10366    if eval $compile_ok; then
10367      yyy=`$run ./try`
10368    fi
10369    case "$yyy" in
10370    3) echo "Your long double math functions are working correctly." >&4 ;;
10371    *) echo "Your long double math functions are broken, not using long doubles." >&4
10372       uselongdouble=$undef
10373       ;;
10374    esac
10375    $rm_try
10376    case "$osname:$gccversion" in
10377    aix:)	ccflags="$saveccflags" ;; # restore
10378    esac
10379fi
10380
10381: Check how to convert floats to strings.
10382
10383if test "X$d_Gconvert" = X; then
10384
10385echo " "
10386echo "Checking for an efficient way to convert floats to strings."
10387echo " " > try.c
10388case "$uselongdouble" in
10389"$define") echo "#define USE_LONG_DOUBLE" >>try.c ;;
10390esac
10391case "$d_longdbl" in
10392"$define") echo "#define HAS_LONG_DOUBLE" >>try.c ;;
10393esac
10394case "$d_PRIgldbl" in
10395"$define") echo "#define HAS_PRIgldbl"    >>try.c ;;
10396esac
10397$cat >>try.c <<EOP
10398#ifdef TRY_gconvert
10399#define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
10400char *myname = "gconvert";
10401#endif
10402#ifdef TRY_gcvt
10403#define Gconvert(x,n,t,b) gcvt((x),(n),(b))
10404char *myname = "gcvt";
10405#endif
10406#ifdef TRY_qgcvt
10407#define Gconvert(x,n,t,b) qgcvt((x),(n),(b))
10408char *myname = "qgcvt";
10409#define DOUBLETYPE long double
10410#endif
10411#ifdef TRY_sprintf
10412#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10413#ifdef HAS_PRIgldbl
10414#define Gconvert(x,n,t,b) sprintf((b),"%.*"$sPRIgldbl,(n),(x))
10415#else
10416#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(double)(x))
10417#endif
10418#else
10419#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
10420#endif
10421char *myname = "sprintf";
10422#endif
10423
10424#ifndef DOUBLETYPE
10425#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10426#define DOUBLETYPE long double
10427#else
10428#define DOUBLETYPE double
10429#endif
10430#endif
10431
10432#include <stdio.h>
10433
10434#$i_stdlib I_STDLIB
10435#ifdef I_STDLIB
10436#include <stdlib.h>
10437#endif
10438#include <string.h>
10439
10440int checkit(char *expect, char *got)
10441{
10442    if (strcmp(expect, got)) {
10443		printf("%s oddity:  Expected %s, got %s\n",
10444			myname, expect, got);
10445		exit(1);
10446	}
10447}
10448
10449int main()
10450{
10451	char buf[64];
10452	buf[63] = '\0';
10453
10454	/* This must be 1st test on (which?) platform */
10455	/* Alan Burlison <AlanBurlsin@unn.unisys.com> */
10456	Gconvert((DOUBLETYPE)0.1, 8, 0, buf);
10457	checkit("0.1", buf);
10458
10459	Gconvert((DOUBLETYPE)0.01, 8, 0, buf);
10460	checkit("0.01", buf);
10461
10462	Gconvert((DOUBLETYPE)0.001, 8, 0, buf);
10463	checkit("0.001", buf);
10464
10465	Gconvert((DOUBLETYPE)0.0001, 8, 0, buf);
10466	checkit("0.0001", buf);
10467
10468	Gconvert((DOUBLETYPE)0.00009, 8, 0, buf);
10469	if (strlen(buf) > 5)
10470	    checkit("9e-005", buf); /* for Microsoft ?? */
10471	else
10472	    checkit("9e-05", buf);
10473
10474	Gconvert((DOUBLETYPE)1.0, 8, 0, buf);
10475	checkit("1", buf);
10476
10477	Gconvert((DOUBLETYPE)1.1, 8, 0, buf);
10478	checkit("1.1", buf);
10479
10480	Gconvert((DOUBLETYPE)1.01, 8, 0, buf);
10481	checkit("1.01", buf);
10482
10483	Gconvert((DOUBLETYPE)1.001, 8, 0, buf);
10484	checkit("1.001", buf);
10485
10486	Gconvert((DOUBLETYPE)1.0001, 8, 0, buf);
10487	checkit("1.0001", buf);
10488
10489	Gconvert((DOUBLETYPE)1.00001, 8, 0, buf);
10490	checkit("1.00001", buf);
10491
10492	Gconvert((DOUBLETYPE)1.000001, 8, 0, buf);
10493	checkit("1.000001", buf);
10494
10495	Gconvert((DOUBLETYPE)0.0, 8, 0, buf);
10496	checkit("0", buf);
10497
10498	Gconvert((DOUBLETYPE)-1.0, 8, 0, buf);
10499	checkit("-1", buf);
10500
10501	/* Some Linux gcvt's give 1.e+5 here. */
10502	Gconvert((DOUBLETYPE)100000.0, 8, 0, buf);
10503	checkit("100000", buf);
10504
10505	/* Some Linux gcvt's give -1.e+5 here. */
10506	Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf);
10507	checkit("-100000", buf);
10508
10509	Gconvert((DOUBLETYPE)123.456, 8, 0, buf);
10510	checkit("123.456", buf);
10511
10512	/* Testing of 1e+129 in bigintpm.t must not get extra '.' here. */
10513	Gconvert((DOUBLETYPE)1e34, 8, 0, buf);
10514	/* 34 should be enough to scare even long double
10515	 * places into using the e notation. */
10516	if (strlen(buf) > 5)
10517	    checkit("1e+034", buf); /* for Microsoft */
10518	else
10519	    checkit("1e+34", buf);
10520
10521	/* For Perl, if you add additional tests here, also add them to
10522	 * t/base/num.t for benefit of platforms not using Configure or
10523	 * overriding d_Gconvert */
10524
10525	exit(0);
10526}
10527EOP
10528: first add preferred functions to our list
10529xxx_list=""
10530for xxx_convert in $gconvert_preference; do
10531    case $xxx_convert in
10532    gcvt|gconvert|sprintf) xxx_list="$xxx_list $xxx_convert" ;;
10533    *) echo "Discarding unrecognized gconvert_preference $xxx_convert" >&4 ;;
10534    esac
10535done
10536: then add any others
10537for xxx_convert in gconvert gcvt sprintf; do
10538    case "$xxx_list" in
10539    *$xxx_convert*) ;;
10540    *) xxx_list="$xxx_list $xxx_convert" ;;
10541    esac
10542done
10543
10544case "$d_longdbl$uselongdouble" in
10545"$define$define")
10546    : again, add preferred functions to our list first
10547    xxx_ld_list=""
10548    for xxx_convert in $gconvert_ld_preference; do
10549        case $xxx_convert in
10550        qgcvt|gcvt|gconvert|sprintf) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10551        *) echo "Discarding unrecognized gconvert_ld_preference $xxx_convert" ;;
10552        esac
10553    done
10554    : then add qgcvt, sprintf--then, in xxx_list order, gconvert and gcvt
10555    for xxx_convert in qgcvt sprintf $xxx_list; do
10556        case "$xxx_ld_list" in
10557        $xxx_convert*|*" $xxx_convert"*) ;;
10558        *) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10559        esac
10560    done
10561    : if sprintf cannot do long doubles, move it to the end
10562    if test "$d_PRIgldbl" != "$define"; then
10563        xxx_ld_list="`echo $xxx_ld_list|sed s/sprintf//` sprintf"
10564    fi
10565    : if no qgcvt, remove it
10566    if test "$d_qgcvt" != "$define"; then
10567        xxx_ld_list="`echo $xxx_ld_list|sed s/qgcvt//`"
10568    fi
10569    : use the ld_list
10570    xxx_list="$xxx_ld_list"
10571    ;;
10572esac
10573
10574for xxx_convert in $xxx_list; do
10575	echo "Trying $xxx_convert..."
10576	$rm -f try try$_o core
10577	set try -DTRY_$xxx_convert
10578	if eval $compile; then
10579		echo "$xxx_convert() found." >&4
10580		if $run ./try; then
10581			echo "I'll use $xxx_convert to convert floats into a string." >&4
10582			break;
10583		else
10584			echo "...But $xxx_convert didn't work as I expected."
10585			xxx_convert=''
10586		fi
10587	else
10588		echo "$xxx_convert NOT found." >&4
10589	fi
10590done
10591
10592if test X$xxx_convert = X; then
10593    echo "*** WHOA THERE!!! ***" >&4
10594    echo "None of ($xxx_list)  seemed to work properly.  I'll use sprintf." >&4
10595    xxx_convert=sprintf
10596fi
10597
10598case "$xxx_convert" in
10599gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
10600gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
10601qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;;
10602*) case "$uselongdouble$d_longdbl$d_PRIgldbl" in
10603   "$define$define$define")
10604      d_Gconvert="sprintf((b),\"%.*\"$sPRIgldbl,(n),(x))" ;;
10605   "$define$define$undef")
10606      d_Gconvert='sprintf((b),"%.*g",(n),(double)(x))' ;;
10607   *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
10608   esac
10609   ;;
10610esac
10611
10612fi
10613$rm_try
10614
10615: see if _fwalk exists
10616set fwalk d__fwalk
10617eval $inlibc
10618
10619: see if accept4 exists
10620set accept4 d_accept4
10621eval $inlibc
10622
10623: Initialize h_fcntl
10624h_fcntl=false
10625
10626: Initialize h_sysfile
10627h_sysfile=false
10628
10629: access call always available on UNIX
10630set access d_access
10631eval $inlibc
10632
10633: locate the flags for 'access()'
10634case "$d_access" in
10635"$define")
10636	echo " "
10637	$cat >access.c <<EOCP
10638#include <sys/types.h>
10639#ifdef I_FCNTL
10640#include <fcntl.h>
10641#endif
10642#ifdef I_SYS_FILE
10643#include <sys/file.h>
10644#endif
10645#ifdef I_UNISTD
10646#include <unistd.h>
10647#endif
10648#$i_stdlib I_STDLIB
10649#ifdef I_STDLIB
10650#include <stdlib.h>
10651#endif
10652int main() {
10653	exit(R_OK);
10654}
10655EOCP
10656	: check sys/file.h first, no particular reason here
10657	if $test `./findhdr sys/file.h` && \
10658		$cc -o access $cppflags -DI_SYS_FILE access.c >/dev/null 2>&1 ; then
10659		h_sysfile=true;
10660		echo "<sys/file.h> defines the *_OK access constants." >&4
10661	elif $test `./findhdr fcntl.h` && \
10662		$cc -o access $cppflags -DI_FCNTL access.c >/dev/null 2>&1 ; then
10663		h_fcntl=true;
10664		echo "<fcntl.h> defines the *_OK access constants." >&4
10665	elif $test `./findhdr unistd.h` && \
10666		$cc -o access $cppflags -DI_UNISTD access.c >/dev/null 2>&1 ; then
10667		echo "<unistd.h> defines the *_OK access constants." >&4
10668	else
10669		echo "I can't find the four *_OK access constants--I'll use mine." >&4
10670	fi
10671	;;
10672esac
10673$rm -f access*
10674
10675: see if accessx exists
10676set accessx d_accessx
10677eval $inlibc
10678
10679: see if acosh exists
10680set acosh d_acosh
10681eval $inlibc
10682
10683: see if aintl exists
10684set aintl d_aintl
10685eval $inlibc
10686
10687: see if alarm exists
10688set alarm d_alarm
10689eval $inlibc
10690
10691: see if 64bit time functions exists
10692
10693set ctime64 d_ctime64
10694eval $inlibc
10695
10696set localtime64 d_localtime64
10697eval $inlibc
10698
10699set gmtime64 d_gmtime64
10700eval $inlibc
10701
10702set mktime64 d_mktime64
10703eval $inlibc
10704
10705set difftime64 d_difftime64
10706eval $inlibc
10707
10708set asctime64 d_asctime64
10709eval $inlibc
10710
10711: see if POSIX threads are available
10712set pthread.h i_pthread
10713eval $inhdr
10714
10715: define a function to check prototypes
10716$cat > protochk <<EOSH
10717$startsh
10718cc="$cc"
10719optimize="$optimize"
10720ccflags="$ccflags"
10721define="$define"
10722rm_try="$rm_try"
10723usethreads=$usethreads
10724i_pthread=$i_pthread
10725pthread_h_first=$pthread_h_first
10726EOSH
10727
10728$cat >> protochk <<'EOSH'
10729
10730$rm_try
10731foo="$1"
10732shift
10733while test $# -ge 2; do
10734	case "$1" in
10735		$define) echo "#include <$2>" >> try.c ;;
10736		literal) echo "$2" >> try.c ;;
10737	esac
10738    # Extra magic for the benefit of systems that need pthread.h
10739    # to be included early to correctly detect threadsafe functions.
10740    # Such functions must guarantee themselves, though, that the usethreads
10741    # and i_pthread have been defined, before calling protochk.
10742    if test "$usethreads" = "$define" -a "$i_pthread" = "$define" -a "$pthread_h_first" = "$define" -a "$pthread_h_done" = ""; then
10743	echo "#include <pthread.h>" >> try.c
10744	pthread_h_done=yes
10745    fi
10746    shift 2
10747done
10748cat >> try.c <<'EOCP'
10749#define	_(args) args
10750EOCP
10751echo "$foo" >> try.c
10752echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
10753$cc $optimize $ccflags -c try.c > /dev/null 2>&1
10754status=$?
10755$rm_try
10756exit $status
10757EOSH
10758chmod +x protochk
10759$eunicefix protochk
10760
10761: Define hasproto macro for Configure internal use
10762hasproto='varname=$1; func=$2; shift; shift;
10763while $test $# -ge 2; do
10764	case "$1" in
10765	$define) echo "#include <$2>";;
10766	literal) echo "$2" ;;
10767	esac ;
10768    shift 2;
10769done > try.c;
10770$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
10771if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
10772	echo "$func() prototype found.";
10773	val="$define";
10774else
10775	echo "$func() prototype NOT found.";
10776	val="$undef";
10777fi;
10778set $varname;
10779eval $setvar;
10780$rm_try tryout.c'
10781
10782: see if sys/types.h has to be included
10783set sys/types.h i_systypes
10784eval $inhdr
10785
10786: see if sys/select.h has to be included
10787set sys/select.h i_sysselct
10788eval $inhdr
10789
10790: Define hasfield macro for Configure internal use
10791hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
10792while $test $# -ge 2; do
10793	case "$1" in
10794	$define) echo "#include <$2>";;
10795	esac ;
10796    shift 2;
10797done > try.c;
10798echo "int main () { struct $struct foo; char* bar; bar = (char*)foo.$field; }" >> try.c;
10799set try;
10800if eval $compile; then
10801	val="$define";
10802else
10803	val="$undef";
10804fi;
10805set $varname;
10806eval $setvar;
10807$rm_try'
10808
10809: see if we should include sys/time.h
10810echo " "
10811i_time='define'
10812if test "X$timeincl" = X; then
10813	echo "Testing to see if we should include <sys/time.h>." >&4
10814	$echo $n "I'm now running the test program...$c"
10815	$cat >try.c <<EOCP
10816#include <sys/types.h>
10817#include <time.h>
10818#ifdef I_SYSTIME
10819#ifdef SYSTIMEKERNEL
10820#define KERNEL
10821#endif
10822#include <sys/time.h>
10823#endif
10824#ifdef I_SYSSELECT
10825#include <sys/select.h>
10826#endif
10827#$i_stdlib I_STDLIB
10828#ifdef I_STDLIB
10829#include <stdlib.h>
10830#endif
10831int main()
10832{
10833	struct tm foo;
10834#ifdef S_TIMEVAL
10835	struct timeval bar;
10836#endif
10837#ifdef S_TIMEZONE
10838	struct timezone tzp;
10839#endif
10840	if (foo.tm_sec == foo.tm_sec)
10841		exit(0);
10842#ifdef S_TIMEVAL
10843	if (bar.tv_sec == bar.tv_sec)
10844		exit(0);
10845#endif
10846	exit(1);
10847}
10848EOCP
10849	flags=''
10850	for s_timezone in '-DS_TIMEZONE' ''; do
10851	sysselect=''
10852	for s_timeval in '-DS_TIMEVAL' ''; do
10853	for i_systimek in '' '-DSYSTIMEKERNEL'; do
10854	for i_systime in '-DI_SYSTIME' ''; do
10855		case "$flags" in
10856		'') $echo $n ".$c"
10857			set try $i_systime $i_systimek $sysselect $s_timeval $s_timezone
10858			if eval $compile; then
10859				set X $i_systime $i_systimek $sysselect $s_timeval
10860				shift
10861				flags="$*"
10862				echo " "
10863				$echo $n "Succeeded with $flags$c"
10864			fi
10865			;;
10866		esac
10867	done
10868	done
10869	done
10870	done
10871	timeincl=''
10872	echo " "
10873	case "$flags" in
10874	*SYSTIMEKERNEL*) i_systimek="$define"
10875		timeincl=`./findhdr sys/time.h`
10876		echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
10877	*) i_systimek="$undef";;
10878	esac
10879	case "$flags" in
10880	*I_SYSTIME*) i_systime="$define"
10881		timeincl=`./findhdr sys/time.h`" $timeincl"
10882		echo "We'll include <sys/time.h>." >&4;;
10883	*) i_systime="$undef";;
10884	esac
10885	$rm_try
10886fi
10887: see if struct tm knows about tm_zone
10888case "$i_systime$i_time" in
10889*$define*)
10890        echo " "
10891        echo "Checking to see if your struct tm has tm_zone field..." >&4
10892        set d_tm_tm_zone tm tm_zone $i_systime sys/time.h $i_time time.h
10893        eval $hasfield
10894        ;;
10895*)      val="$undef"
10896        set d_tm_tm_zone
10897        eval $setvar
10898        ;;
10899esac
10900case "$d_tm_tm_zone" in
10901"$define")      echo "Yes, it does."   ;;
10902*)              echo "No, it doesn't." ;;
10903esac
10904: see if struct tm knows about tm_gmtoff
10905case "$i_systime$i_time" in
10906*$define*)
10907        echo " "
10908        echo "Checking to see if your struct tm has tm_gmtoff field..." >&4
10909        set d_tm_tm_gmtoff tm tm_gmtoff $i_systime sys/time.h $i_time time.h
10910        eval $hasfield
10911        ;;
10912*)      val="$undef"
10913        set d_tm_tm_gmtoff
10914        eval $setvar
10915        ;;
10916esac
10917case "$d_tm_tm_gmtoff" in
10918"$define")      echo "Yes, it does."   ;;
10919*)              echo "No, it doesn't." ;;
10920esac
10921
10922: see if asctime_r exists
10923set asctime_r d_asctime_r
10924eval $inlibc
10925case "$d_asctime_r" in
10926"$define")
10927	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
10928	case "$d_asctime_r_proto:$usethreads" in
10929	":define")	d_asctime_r_proto=define
10930		set d_asctime_r_proto asctime_r $hdrs
10931		eval $hasproto ;;
10932	*)	;;
10933	esac
10934	case "$d_asctime_r_proto" in
10935	define)
10936	case "$asctime_r_proto" in
10937	''|0) try='char* asctime_r(const struct tm*, char*);'
10938	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SB ;;
10939	esac
10940	case "$asctime_r_proto" in
10941	''|0) try='char* asctime_r(const struct tm*, char*, int);'
10942	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SBI ;;
10943	esac
10944	case "$asctime_r_proto" in
10945	''|0) try='int asctime_r(const struct tm*, char*);'
10946	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SB ;;
10947	esac
10948	case "$asctime_r_proto" in
10949	''|0) try='int asctime_r(const struct tm*, char*, int);'
10950	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SBI ;;
10951	esac
10952	case "$asctime_r_proto" in
10953	''|0)	d_asctime_r=undef
10954		asctime_r_proto=0
10955		echo "Disabling asctime_r, cannot determine prototype." >&4 ;;
10956	* )	case "$asctime_r_proto" in
10957		REENTRANT_PROTO*) ;;
10958		*) asctime_r_proto="REENTRANT_PROTO_$asctime_r_proto" ;;
10959		esac
10960		echo "Prototype: $try" ;;
10961	esac
10962	;;
10963	*)	case "$usethreads" in
10964		define) echo "asctime_r has no prototype, not using it." >&4 ;;
10965		esac
10966		d_asctime_r=undef
10967		asctime_r_proto=0
10968		;;
10969	esac
10970	;;
10971*)	asctime_r_proto=0
10972	;;
10973esac
10974
10975: see if asinh exists
10976set asinh d_asinh
10977eval $inlibc
10978
10979: see if atanh exists
10980set atanh d_atanh
10981eval $inlibc
10982
10983: see if atolf exists
10984set atolf d_atolf
10985eval $inlibc
10986
10987: see if atoll exists
10988set atoll d_atoll
10989eval $inlibc
10990
10991: Look for GCC-style attribute format
10992case "$d_attribute_format" in
10993'')
10994echo " "
10995echo "Checking whether your compiler can handle __attribute__((format)) ..." >&4
10996$cat >attrib.c <<'EOCP'
10997#include <stdio.h>
10998void my_special_printf(char* pat,...) __attribute__((__format__(__printf__,1,2)));
10999EOCP
11000if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11001	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11002		echo "Your C compiler doesn't support __attribute__((format))."
11003		val="$undef"
11004	else
11005		echo "Your C compiler supports __attribute__((format))."
11006		val="$define"
11007	fi
11008else
11009	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11010	val="$undef"
11011fi
11012;;
11013*) val="$d_attribute_format" ;;
11014esac
11015set d_attribute_format
11016eval $setvar
11017$rm -f attrib*
11018
11019: Look for GCC-style attribute format with null format allowed
11020case "$d_printf_format_null" in
11021'') case "$d_attribute_format" in
11022    $define)
11023	echo " "
11024	echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
11025$cat >attrib.c <<EOCP
11026#include <stdio.h>
11027#$i_stdlib I_STDLIB
11028#ifdef I_STDLIB
11029#include <stdlib.h>
11030#endif
11031#$i_inttypes I_INTTYPES
11032#ifdef I_INTTYPES
11033#include <inttypes.h>
11034#endif
11035#ifndef INTPTR_MAX
11036#define intptr_t int
11037#endif
11038int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
11039int null_printf (char* pat,...) { return (int)(intptr_t)pat; }
11040int main () { exit(null_printf(NULL)); }
11041EOCP
11042	if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
11043	    : run the executable in case it produces a run-time warning
11044	    if $run ./attrib >>attrib.out 2>&1; then
11045		if $contains 'warning' attrib.out >/dev/null 2>&1; then
11046		    echo "Your C compiler doesn't allow __printf__ format to be null."
11047		    val="$undef"
11048		else
11049		    echo "Your C compiler allows __printf__ format to be null."
11050		    val="$define"
11051		fi
11052	    else
11053	    echo "Your C compiler executable failed with __printf__ format null."
11054	    val="$undef"
11055	fi
11056    else
11057	echo "Your C compiler fails with __printf__ format null."
11058	val="$undef"
11059    fi
11060    ;;
11061    *)  val="$undef" ;;
11062    esac
11063;;
11064*)  val="$d_printf_format_null" ;;
11065esac
11066set d_printf_format_null
11067eval $setvar
11068$rm -f attrib*
11069
11070: Look for GCC-style attribute malloc
11071case "$d_attribute_malloc" in
11072'')
11073echo " "
11074echo "Checking whether your compiler can handle __attribute__((malloc)) ..." >&4
11075$cat >attrib.c <<'EOCP'
11076#include <stdio.h>
11077char *go_get_some_memory( int how_many_bytes ) __attribute__((malloc));
11078EOCP
11079if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11080	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11081		echo "Your C compiler doesn't support __attribute__((malloc))."
11082		val="$undef"
11083	else
11084		echo "Your C compiler supports __attribute__((malloc))."
11085		val="$define"
11086	fi
11087else
11088	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11089	val="$undef"
11090fi
11091;;
11092*) val="$d_attribute_malloc" ;;
11093esac
11094set d_attribute_malloc
11095eval $setvar
11096$rm -f attrib*
11097
11098: Look for GCC-style attribute nonnull
11099case "$d_attribute_nonnull" in
11100'')
11101echo " "
11102echo "Checking whether your compiler can handle __attribute__((nonnull(1))) ..." >&4
11103$cat >attrib.c <<'EOCP'
11104#include <stdio.h>
11105void do_something (char *some_pointer,...) __attribute__((nonnull(1)));
11106EOCP
11107if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11108	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11109		echo "Your C compiler doesn't support __attribute__((nonnull))."
11110		val="$undef"
11111	else
11112		echo "Your C compiler supports __attribute__((nonnull))."
11113		val="$define"
11114	fi
11115else
11116	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11117	val="$undef"
11118fi
11119;;
11120*) val="$d_attribute_nonnull" ;;
11121esac
11122set d_attribute_nonnull
11123eval $setvar
11124$rm -f attrib*
11125
11126: Look for GCC-style attribute noreturn
11127case "$d_attribute_noreturn" in
11128'')
11129echo " "
11130echo "Checking whether your compiler can handle __attribute__((noreturn)) ..." >&4
11131$cat >attrib.c <<'EOCP'
11132#include <stdio.h>
11133void fall_over_dead( void ) __attribute__((noreturn));
11134EOCP
11135if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11136	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11137		echo "Your C compiler doesn't support __attribute__((noreturn))."
11138		val="$undef"
11139	else
11140		echo "Your C compiler supports __attribute__((noreturn))."
11141		val="$define"
11142	fi
11143else
11144	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11145	val="$undef"
11146fi
11147;;
11148*) val="$d_attribute_noreturn" ;;
11149esac
11150set d_attribute_noreturn
11151eval $setvar
11152$rm -f attrib*
11153
11154: Look for GCC-style attribute pure
11155case "$d_attribute_pure" in
11156'')
11157echo " "
11158echo "Checking whether your compiler can handle __attribute__((pure)) ..." >&4
11159$cat >attrib.c <<'EOCP'
11160#include <stdio.h>
11161int square( int n ) __attribute__((pure));
11162EOCP
11163if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11164	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11165		echo "Your C compiler doesn't support __attribute__((pure))."
11166		val="$undef"
11167	else
11168		echo "Your C compiler supports __attribute__((pure))."
11169		val="$define"
11170	fi
11171else
11172	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11173	val="$undef"
11174fi
11175;;
11176*) val="$d_attribute_pure" ;;
11177esac
11178set d_attribute_pure
11179eval $setvar
11180$rm -f attrib*
11181
11182: Look for GCC-style attribute unused
11183case "$d_attribute_unused" in
11184'')
11185echo " "
11186echo "Checking whether your compiler can handle __attribute__((unused)) ..." >&4
11187$cat >attrib.c <<'EOCP'
11188#include <stdio.h>
11189int do_something( int dummy __attribute__((unused)), int n );
11190EOCP
11191if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11192	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11193		echo "Your C compiler doesn't support __attribute__((unused))."
11194		val="$undef"
11195	else
11196		echo "Your C compiler supports __attribute__((unused))."
11197		val="$define"
11198	fi
11199else
11200	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11201	val="$undef"
11202fi
11203;;
11204*) val="$d_attribute_unused" ;;
11205esac
11206set d_attribute_unused
11207eval $setvar
11208$rm -f attrib*
11209
11210: Look for GCC-style attribute deprecated
11211case "$d_attribute_deprecated" in
11212'')
11213echo " "
11214echo "Checking whether your compiler can handle __attribute__((deprecated)) ..." >&4
11215$cat >attrib.c <<'EOCP'
11216#include <stdio.h>
11217int I_am_deprecated(void) __attribute__((deprecated));
11218EOCP
11219if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11220	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11221		echo "Your C compiler doesn't support __attribute__((deprecated))."
11222		val="$undef"
11223	else
11224		echo "Your C compiler supports __attribute__((deprecated))."
11225		val="$define"
11226	fi
11227else
11228	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11229	val="$undef"
11230fi
11231;;
11232*) val="$d_attribute_deprecated" ;;
11233esac
11234set d_attribute_deprecated
11235eval $setvar
11236$rm -f attrib*
11237
11238: Look for GCC-style attribute warn_unused_result
11239case "$d_attribute_warn_unused_result" in
11240'')
11241echo " "
11242echo "Checking whether your compiler can handle __attribute__((warn_unused_result)) ..." >&4
11243$cat >attrib.c <<'EOCP'
11244#include <stdio.h>
11245int I_will_not_be_ignored(void) __attribute__((warn_unused_result));
11246EOCP
11247if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11248	if $contains 'warning' attrib.out >/dev/null 2>&1; then
11249		echo "Your C compiler doesn't support __attribute__((warn_unused_result))."
11250		val="$undef"
11251	else
11252		echo "Your C compiler supports __attribute__((warn_unused_result))."
11253		val="$define"
11254	fi
11255else
11256	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11257	val="$undef"
11258fi
11259;;
11260*) val="$d_attribute_warn_unused_result" ;;
11261esac
11262set d_attribute_warn_unused_result
11263eval $setvar
11264$rm -f attrib*
11265
11266: see if getpgrp exists
11267set getpgrp d_getpgrp
11268eval $inlibc
11269
11270case "$d_getpgrp" in
11271"$define")
11272	echo " "
11273	echo "Checking to see which flavor of getpgrp is in use..."
11274	$cat >try.c <<EOP
11275#$i_unistd I_UNISTD
11276#include <sys/types.h>
11277#ifdef I_UNISTD
11278#  include <unistd.h>
11279#endif
11280#$i_stdlib I_STDLIB
11281#ifdef I_STDLIB
11282#include <stdlib.h>
11283#endif
11284int main()
11285{
11286	if (getuid() == 0) {
11287		printf("(I see you are running Configure as super-user...)\n");
11288		setuid(1);
11289	}
11290#ifdef TRY_BSD_PGRP
11291	if (getpgrp(1) == 0)
11292		exit(0);
11293#else
11294	if (getpgrp() > 0)
11295		exit(0);
11296#endif
11297	exit(1);
11298}
11299EOP
11300	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11301		echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
11302		val="$define"
11303	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11304		echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
11305		val="$undef"
11306	else
11307		echo "I can't seem to compile and run the test program."
11308		if ./usg; then
11309			xxx="a USG one, i.e. you use getpgrp()."
11310		else
11311			# SVR4 systems can appear rather BSD-ish.
11312			case "$i_unistd" in
11313			$undef)
11314				xxx="a BSD one, i.e. you use getpgrp(pid)."
11315				val="$define"
11316				;;
11317			$define)
11318				xxx="probably a USG one, i.e. you use getpgrp()."
11319				val="$undef"
11320				;;
11321			esac
11322		fi
11323		echo "Assuming your getpgrp is $xxx" >&4
11324	fi
11325	;;
11326*) val="$undef";;
11327esac
11328set d_bsdgetpgrp
11329eval $setvar
11330$rm_try
11331
11332: see if setpgrp exists
11333set setpgrp d_setpgrp
11334eval $inlibc
11335
11336case "$d_setpgrp" in
11337"$define")
11338	echo " "
11339	echo "Checking to see which flavor of setpgrp is in use..."
11340	$cat >try.c <<EOP
11341#$i_unistd I_UNISTD
11342#include <sys/types.h>
11343#ifdef I_UNISTD
11344#  include <unistd.h>
11345#endif
11346#$i_stdlib I_STDLIB
11347#ifdef I_STDLIB
11348#include <stdlib.h>
11349#endif
11350int main()
11351{
11352	if (getuid() == 0) {
11353		printf("(I see you are running Configure as super-user...)\n");
11354		setuid(1);
11355	}
11356#ifdef TRY_BSD_PGRP
11357	if (-1 == setpgrp(1, 1))
11358		exit(0);
11359#else
11360	if (setpgrp() != -1)
11361		exit(0);
11362#endif
11363	exit(1);
11364}
11365EOP
11366	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11367		echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
11368		val="$define"
11369	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11370		echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
11371		val="$undef"
11372	else
11373		echo "(I can't seem to compile and run the test program.)"
11374		if ./usg; then
11375			xxx="a USG one, i.e. you use setpgrp()."
11376		else
11377			# SVR4 systems can appear rather BSD-ish.
11378			case "$i_unistd" in
11379			$undef)
11380				xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
11381				val="$define"
11382				;;
11383			$define)
11384				xxx="probably a USG one, i.e. you use setpgrp()."
11385				val="$undef"
11386				;;
11387			esac
11388		fi
11389		echo "Assuming your setpgrp is $xxx" >&4
11390	fi
11391	;;
11392*) val="$undef";;
11393esac
11394set d_bsdsetpgrp
11395eval $setvar
11396$rm_try
11397
11398: Look for GCC-style __builtin_add_overflow
11399case "$d_builtin_add_overflow" in
11400'')
11401    echo " "
11402    echo "Checking whether your compiler can handle __builtin_add_overflow ..." >&4
11403    $cat >try.c <<'EOCP'
11404int main(void) {
11405    const unsigned int uint_max = ~0u;
11406    int target_int = 0;
11407    if (__builtin_add_overflow(1, 2, &target_int) || target_int != 3) {
11408        return 1;
11409    }
11410    if (!__builtin_add_overflow((int)(uint_max >> 1), 1, &target_int)) {
11411        return 1;
11412    }
11413    if (!__builtin_add_overflow(uint_max, -1, &target_int)) {
11414        return 1;
11415    }
11416    return 0;
11417}
11418EOCP
11419    set try
11420    if eval $compile && $run ./try; then
11421        echo "Your C compiler supports __builtin_add_overflow."
11422        val="$define"
11423    else
11424        echo "Your C compiler doesn't seem to understand __builtin_add_overflow."
11425        val="$undef"
11426    fi
11427    ;;
11428*) val="$d_builtin_add_overflow" ;;
11429esac
11430
11431set d_builtin_add_overflow
11432eval $setvar
11433$rm_try
11434
11435: Look for GCC-style __builtin_sub_overflow
11436case "$d_builtin_sub_overflow" in
11437'')
11438    echo " "
11439    echo "Checking whether your compiler can handle __builtin_sub_overflow ..." >&4
11440    $cat >try.c <<'EOCP'
11441int main(void) {
11442    const unsigned int uint_max = ~0u;
11443    int target_int = 0;
11444    if (__builtin_sub_overflow(1, -2, &target_int) || target_int != 3) {
11445        return 1;
11446    }
11447    if (!__builtin_sub_overflow(-(int)(uint_max >> 1), 2, &target_int)) {
11448        return 1;
11449    }
11450    if (!__builtin_sub_overflow(uint_max, 1, &target_int)) {
11451        return 1;
11452    }
11453    return 0;
11454}
11455EOCP
11456    set try
11457    if eval $compile && $run ./try; then
11458        echo "Your C compiler supports __builtin_sub_overflow."
11459        val="$define"
11460    else
11461        echo "Your C compiler doesn't seem to understand __builtin_sub_overflow."
11462        val="$undef"
11463    fi
11464    ;;
11465*) val="$d_builtin_sub_overflow" ;;
11466esac
11467
11468set d_builtin_sub_overflow
11469eval $setvar
11470$rm_try
11471
11472: Look for GCC-style __builtin_mul_overflow
11473case "$d_builtin_mul_overflow" in
11474'')
11475    echo " "
11476    echo "Checking whether your compiler can handle __builtin_mul_overflow ..." >&4
11477    $cat >try.c <<'EOCP'
11478int main(void) {
11479    const unsigned int uint_max = ~0u;
11480    int target_int = 0;
11481    if (__builtin_mul_overflow(2, 3, &target_int) || target_int != 6) {
11482        return 1;
11483    }
11484    if (!__builtin_mul_overflow((int)(uint_max >> 1), 2, &target_int)) {
11485        return 1;
11486    }
11487    if (!__builtin_mul_overflow(uint_max, 1, &target_int)) {
11488        return 1;
11489    }
11490    return 0;
11491}
11492EOCP
11493    set try
11494    if eval $compile && $run ./try; then
11495        echo "Your C compiler supports __builtin_mul_overflow."
11496        val="$define"
11497    else
11498        echo "Your C compiler doesn't seem to understand __builtin_mul_overflow."
11499        val="$undef"
11500    fi
11501    ;;
11502*) val="$d_builtin_mul_overflow" ;;
11503esac
11504
11505set d_builtin_mul_overflow
11506eval $setvar
11507$rm_try
11508
11509: Look for GCC-style __builtin_choose_expr
11510case "$d_builtin_choose_expr" in
11511'')
11512    echo " "
11513    echo "Checking whether your compiler can handle __builtin_choose_expr ..." >&4
11514    $cat >try.c <<'EOCP'
11515#include <assert.h>
11516#include <stdlib.h>
11517#include <stdio.h>
11518
11519#define SYRINX(x) __builtin_choose_expr( x, (1056*2), (103*50) )
11520
11521int main(void) {
11522    assert( SYRINX(1) == 2112 );
11523    assert( SYRINX(1) != 5150 );
11524    assert( SYRINX(0) == 5150 );
11525    assert( SYRINX(0) != 2112 );
11526    puts( "All good!" );
11527    exit(0);
11528}
11529
11530EOCP
11531    set try
11532    if eval $compile && $run ./try; then
11533	echo "Your C compiler supports __builtin_choose_expr."
11534	val="$define"
11535    else
11536	echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
11537	val="$undef"
11538    fi
11539;;
11540*) val="$d_builtin_choose_expr" ;;
11541esac
11542
11543set d_builtin_choose_expr
11544eval $setvar
11545$rm_try
11546
11547: Look for GCC-style __builtin_expect
11548case "$d_builtin_expect" in
11549'')
11550    echo " "
11551    echo "Checking whether your compiler can handle __builtin_expect ..." >&4
11552    $cat >try.c <<'EOCP'
11553int main(void) {
11554    int n = 50;
11555    if ( __builtin_expect(n, 0) ) n = 1;
11556    /* Remember shell exit code truth is 0, C truth is non-zero */
11557    return !(n == 1);
11558}
11559EOCP
11560    set try
11561    if eval $compile && $run ./try; then
11562	echo "Your C compiler supports __builtin_expect."
11563	val="$define"
11564    else
11565	echo "Your C compiler doesn't seem to understand __builtin_expect."
11566	val="$undef"
11567    fi
11568    ;;
11569*) val="$d_builtin_expect" ;;
11570esac
11571
11572set d_builtin_expect
11573eval $setvar
11574$rm_try
11575
11576: see if the Compiler supports C99 variadic macros
11577echo "Checking for C99 variadic macros." >&4
11578$cat >try.c <<EOCP
11579#include <stdio.h>
11580#include <stdarg.h>
11581
11582#define foo(buffer, format, ...) sprintf(buffer, format, __VA_ARGS__)
11583
11584int main() {
11585  char buf[20];
11586  foo(buf, "%d %g %.*s", 123, 456.0, (int)3, "789fail");
11587  puts(buf);
11588  return 0;
11589}
11590EOCP
11591set try
11592if eval $compile && $run ./try 2>&1 >/dev/null; then
11593    case "`$run ./try`" in
11594	"123 456 789")
11595	echo "You have C99 variadic macros." >&4
11596	d_c99_variadic_macros="$define"
11597	;;
11598	*)
11599	echo "You don't have functional C99 variadic macros." >&4
11600	d_c99_variadic_macros="$undef"
11601	;;
11602    esac
11603else
11604    echo "I couldn't compile and run the test program, so I assume that you don't have functional C99 variadic macros." >&4
11605    d_c99_variadic_macros="$undef"
11606fi
11607$rm_try
11608
11609: see if signal is declared as pointer to function returning int or void
11610echo " "
11611xxx=`./findhdr signal.h`
11612$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
11613if $contains 'int.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11614	echo "You have int (*signal())() instead of void." >&4
11615	val="$undef"
11616elif $contains 'void.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11617	echo "You have void (*signal())()." >&4
11618	val="$define"
11619elif $contains 'extern[ 	]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
11620	echo "You have int (*signal())() instead of void." >&4
11621	val="$undef"
11622elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
11623	echo "You have void (*signal())()." >&4
11624	val="$define"
11625else
11626	case "$d_voidsig" in
11627	'')
11628	echo "I can't determine whether signal handler returns void or int..." >&4
11629		dflt=void
11630		rp="What type does your signal handler return?"
11631		. ./myread
11632		case "$ans" in
11633		v*) val="$define";;
11634		*) val="$undef";;
11635		esac;;
11636	"$define")
11637		echo "As you already told me, signal handler returns void." >&4
11638		val="$define"
11639		;;
11640	*)	echo "As you already told me, signal handler returns int." >&4
11641		val="$undef"
11642		;;
11643	esac
11644fi
11645set d_voidsig
11646eval $setvar
11647case "$d_voidsig" in
11648"$define") signal_t="void";;
11649*) signal_t="int";;
11650esac
11651$rm -f $$.tmp
11652
11653: check for ability to cast large floats to 32-bit ints.
11654echo " "
11655echo 'Checking whether your C compiler can cast large floats to int32.' >&4
11656if $test "$intsize" -ge 4; then
11657	xxx=int
11658else
11659	xxx=long
11660fi
11661$cat >try.c <<EOCP
11662#include <stdio.h>
11663#$i_stdlib I_STDLIB
11664#ifdef I_STDLIB
11665#include <stdlib.h>
11666#endif
11667#include <sys/types.h>
11668#include <signal.h>
11669$signal_t blech(int s) { exit(3); }
11670int main()
11671{
11672	$xxx i32;
11673	double f, g;
11674	int result = 0;
11675	char str[16];
11676	signal(SIGFPE, blech);
11677
11678	/* Don't let compiler optimize the test away.  Store the number
11679	   in a writable string for gcc to pass to sscanf under HP-UX.
11680	*/
11681	sprintf(str, "2147483647");
11682	sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
11683	g = 10 * f;
11684	i32  = ($xxx) g;
11685
11686	/* x86 processors will probably give 0x8000 0000, which is a
11687	   sign change.  We don't want that.  We want to mimic SPARC
11688	   behavior here, which is to preserve the sign and give
11689	   back 0x7fff ffff.
11690	*/
11691	if (i32 != ($xxx) f)
11692		result |= 1;
11693	exit(result);
11694}
11695EOCP
11696set try
11697if eval $compile_ok; then
11698	$run ./try 2>/dev/null
11699	yyy=$?
11700else
11701	echo "(I can't seem to compile the test program--assuming it can't)"
11702	yyy=1
11703fi
11704case "$yyy" in
117050)	val="$define"
11706	echo "Yup, it can."
11707	;;
11708*)	val="$undef"
11709	echo "Nope, it can't."
11710	;;
11711esac
11712set d_casti32
11713eval $setvar
11714$rm_try
11715
11716: check for ability to cast negative floats to unsigned
11717echo " "
11718echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
11719$cat >try.c <<EOCP
11720#include <stdio.h>
11721#$i_stdlib I_STDLIB
11722#ifdef I_STDLIB
11723#include <stdlib.h>
11724#endif
11725#include <sys/types.h>
11726#include <signal.h>
11727$signal_t blech(int s) { exit(7); }
11728$signal_t blech_in_list(int s) { exit(4); }
11729unsigned long dummy_long(unsigned long p) { return p; }
11730unsigned int dummy_int(unsigned int p) { return p; }
11731unsigned short dummy_short(unsigned short p) { return p; }
11732int main()
11733{
11734	double f;
11735	unsigned long along;
11736	unsigned int aint;
11737	unsigned short ashort;
11738	int result = 0;
11739	char str[16];
11740
11741	/* Frustrate gcc-2.7.2's optimizer which failed this test with
11742	   a direct f = -123. assignment.  gcc-2.8.0 reportedly
11743	   optimized the whole file away
11744	*/
11745	/* Store the number in a writable string for gcc to pass to
11746	   sscanf under HP-UX.
11747	*/
11748	sprintf(str, "-123");
11749	sscanf(str, "%lf", &f);  /* f = -123.; */
11750
11751	signal(SIGFPE, blech);
11752	along = (unsigned long)f;
11753	aint = (unsigned int)f;
11754	ashort = (unsigned short)f;
11755	if (along != (unsigned long)-123)
11756		result |= 1;
11757	if (aint != (unsigned int)-123)
11758		result |= 1;
11759	if (ashort != (unsigned short)-123)
11760		result |= 1;
11761	sprintf(str, "1073741824.");
11762	sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
11763	f = f + f;
11764	along = 0;
11765	along = (unsigned long)f;
11766	if (along != 0x80000000)
11767		result |= 2;
11768	f -= 1.;
11769	along = 0;
11770	along = (unsigned long)f;
11771	if (along != 0x7fffffff)
11772		result |= 1;
11773	f += 2.;
11774	along = 0;
11775	along = (unsigned long)f;
11776	if (along != 0x80000001)
11777		result |= 2;
11778	if (result)
11779		exit(result);
11780	signal(SIGFPE, blech_in_list);
11781	sprintf(str, "123.");
11782	sscanf(str, "%lf", &f);  /* f = 123.; */
11783	along = dummy_long((unsigned long)f);
11784	aint = dummy_int((unsigned int)f);
11785	ashort = dummy_short((unsigned short)f);
11786	if (along != (unsigned long)123)
11787		result |= 4;
11788	if (aint != (unsigned int)123)
11789		result |= 4;
11790	if (ashort != (unsigned short)123)
11791		result |= 4;
11792	exit(result);
11793
11794}
11795EOCP
11796set try
11797if eval $compile_ok; then
11798	$run ./try 2>/dev/null
11799	castflags=$?
11800else
11801	echo "(I can't seem to compile the test program--assuming it can't)"
11802	castflags=7
11803fi
11804case "$castflags" in
118050)	val="$define"
11806	echo "Yup, it can."
11807	;;
11808*)	val="$undef"
11809	echo "Nope, it can't."
11810	;;
11811esac
11812set d_castneg
11813eval $setvar
11814$rm_try
11815
11816: see if cbrt exists
11817set cbrt d_cbrt
11818eval $inlibc
11819
11820: see if chown exists
11821set chown d_chown
11822eval $inlibc
11823
11824: see if chroot exists
11825set chroot d_chroot
11826eval $inlibc
11827
11828: see if chsize exists
11829set chsize d_chsize
11830eval $inlibc
11831
11832: see if class exists
11833set class d_class
11834eval $inlibc
11835
11836: see if clearenv exists
11837set clearenv d_clearenv
11838eval $inlibc
11839
11840: Define hasstruct macro for Configure internal use
11841hasstruct='varname=$1; struct=$2; shift; shift;
11842while $test $# -ge 2; do
11843	case "$1" in
11844	$define) echo "#include <$2>";;
11845	esac ;
11846    shift 2;
11847done > try.c;
11848echo "int main () { struct $struct foo; }" >> try.c;
11849set try;
11850if eval $compile; then
11851	val="$define";
11852else
11853	val="$undef";
11854fi;
11855set $varname;
11856eval $setvar;
11857$rm_try'
11858
11859: see whether socket exists
11860socketlib=''
11861sockethdr=''
11862echo " "
11863$echo $n "Hmm... $c" >&4
11864if set socket val -f d_socket; eval $csym; $val; then
11865    echo "Looks like you have Berkeley networking support." >&4
11866    d_socket="$define"
11867    if set setsockopt val -f; eval $csym; $val; then
11868	d_oldsock="$undef"
11869    else
11870	echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
11871	d_oldsock="$define"
11872    fi
11873else
11874    if $contains socklib libc.list >/dev/null 2>&1; then
11875	echo "Looks like you have Berkeley networking support." >&4
11876	d_socket="$define"
11877	: we will have to assume that it supports the 4.2 BSD interface
11878	d_oldsock="$undef"
11879    else
11880	echo "You don't have Berkeley networking in libc$_a..." >&4
11881	if test "X$d_socket" = "X$define"; then
11882	    echo "...but you seem to believe that you have sockets." >&4
11883	else
11884	    for net in net socket
11885	    do
11886		if test -f $sysroot/usr/lib/lib$net$_a; then
11887		    ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) ||  \
11888		    $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list
11889		    if $contains socket libc.list >/dev/null 2>&1; then
11890			d_socket="$define"
11891			socketlib="-l$net"
11892			case "$net" in
11893			net)
11894			    echo "...but the Wollongong group seems to have hacked it in." >&4
11895			    sockethdr="-I$sysroot/usr/netinclude"
11896			    ;;
11897			esac
11898			echo "Found Berkeley sockets interface in lib$net." >&4
11899			if $contains setsockopt libc.list >/dev/null 2>&1; then
11900			    d_oldsock="$undef"
11901			else
11902			    echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
11903			    d_oldsock="$define"
11904			fi
11905			break
11906		    fi
11907		fi
11908	    done
11909	    if test "X$d_socket" != "X$define"; then
11910	       echo "or anywhere else I see." >&4
11911	       d_socket="$undef"
11912	       d_oldsock="$undef"
11913	    fi
11914	fi
11915    fi
11916fi
11917
11918: see if socketpair exists
11919set socketpair d_sockpair
11920eval $inlibc
11921
11922
11923echo " "
11924echo "Checking the availability sa_len in the sock struct ..." >&4
11925$cat >try.c <<EOF
11926#include <sys/types.h>
11927#include <sys/socket.h>
11928int main() {
11929struct sockaddr sa;
11930return (sa.sa_len);
11931}
11932EOF
11933val="$undef"
11934set try; if eval $compile; then
11935    val="$define"
11936fi
11937set d_sockaddr_sa_len; eval $setvar
11938$rm_try
11939
11940echo " "
11941echo "Checking the availability struct sockaddr_in6 ..." >&4
11942$cat >try.c <<EOF
11943#include <sys/types.h>
11944#include <sys/socket.h>
11945#include <netinet/in.h>
11946int main() {
11947struct sockaddr_in6 sin6;
11948return (sin6.sin6_family);
11949}
11950EOF
11951val="$undef"
11952set try; if eval $compile; then
11953    val="$define"
11954fi
11955set d_sockaddr_in6; eval $setvar
11956$rm_try
11957
11958echo " "
11959echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
11960$cat >try.c <<EOF
11961#include <sys/types.h>
11962#include <sys/socket.h>
11963#include <netinet/in.h>
11964int main() {
11965struct sockaddr_in6 sin6;
11966return (sin6.sin6_scope_id);
11967}
11968EOF
11969val="$undef"
11970set try; if eval $compile; then
11971    val="$define"
11972fi
11973set d_sin6_scope_id; eval $setvar
11974$rm_try
11975
11976echo " "
11977echo "Checking the availability struct ip_mreq ..." >&4
11978$cat >try.c <<EOF
11979#include <sys/types.h>
11980#include <sys/socket.h>
11981#include <netinet/in.h>
11982int main() {
11983struct ip_mreq mreq;
11984return (mreq.imr_multiaddr.s_addr);
11985}
11986EOF
11987val="$undef"
11988set try; if eval $compile; then
11989       val="$define"
11990fi
11991set d_ip_mreq; eval $setvar
11992$rm_try
11993
11994echo " "
11995echo "Checking the availability struct ip_mreq_source ..." >&4
11996$cat >try.c <<EOF
11997#include <sys/types.h>
11998#include <sys/socket.h>
11999#include <netinet/in.h>
12000int main() {
12001struct ip_mreq_source mreq;
12002return (mreq.imr_multiaddr.s_addr);
12003}
12004EOF
12005val="$undef"
12006set try; if eval $compile; then
12007       val="$define"
12008fi
12009set d_ip_mreq_source; eval $setvar
12010$rm_try
12011
12012echo " "
12013echo "Checking the availability struct ipv6_mreq ..." >&4
12014$cat >try.c <<EOF
12015#include <sys/types.h>
12016#include <sys/socket.h>
12017#include <netinet/in.h>
12018int main() {
12019struct ipv6_mreq mreq;
12020return (mreq.ipv6mr_interface);
12021}
12022EOF
12023val="$undef"
12024set try; if eval $compile; then
12025    val="$define"
12026fi
12027set d_ipv6_mreq; eval $setvar
12028$rm_try
12029
12030echo " "
12031echo "Checking the availability struct ipv6_mreq_source ..." >&4
12032$cat >try.c <<EOF
12033#include <sys/types.h>
12034#include <sys/socket.h>
12035#include <netinet/in.h>
12036int main() {
12037struct ipv6_mreq_source mreq;
12038return (mreq.imr_multiaddr.s_addr);
12039}
12040EOF
12041val="$undef"
12042set try; if eval $compile; then
12043       val="$define"
12044fi
12045set d_ipv6_mreq_source; eval $setvar
12046$rm_try
12047
12048echo " "
12049echo "Checking the availability of certain socket constants..." >&4
12050for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
12051    enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
12052    $cat >try.c <<EOF
12053#include <sys/types.h>
12054#include <sys/socket.h>
12055int main() {
12056    int i = $ENUM;
12057}
12058EOF
12059    val="$undef"
12060    set try; if eval $compile; then
12061	val="$define"
12062    fi
12063    set d_${enum}; eval $setvar
12064    $rm_try
12065done
12066
12067: see if this is a sys/uio.h system
12068set sys/uio.h i_sysuio
12069eval $inhdr
12070
12071: Check for cmsghdr support
12072echo " "
12073echo "Checking to see if your system supports struct cmsghdr..." >&4
12074set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
12075eval $hasstruct
12076case "$d_cmsghdr_s" in
12077"$define")      echo "Yes, it does."   ;;
12078*)              echo "No, it doesn't." ;;
12079esac
12080
12081: see if copysign exists
12082set copysign d_copysign
12083eval $inlibc
12084
12085: see if copysignl exists
12086set copysignl d_copysignl
12087eval $inlibc
12088
12089: see if crypt exists
12090echo " "
12091set crypt d_crypt
12092eval $inlibc
12093case "$d_crypt" in
12094$define) cryptlib='' ;;
12095*)	if set crypt val -f d_crypt; eval $csym; $val; then
12096		echo 'crypt() found.' >&4
12097		val="$define"
12098		cryptlib=''
12099	else
12100		cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
12101		if $test -z "$cryptlib"; then
12102			cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
12103		else
12104			cryptlib=-lcrypt
12105		fi
12106		if $test -z "$cryptlib"; then
12107			cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
12108		else
12109			cryptlib=-lcrypt
12110		fi
12111		if $test -z "$cryptlib"; then
12112			cryptlib=`./loc libcrypt$_a "" $libpth`
12113		else
12114			cryptlib=-lcrypt
12115		fi
12116		if $test -z "$cryptlib"; then
12117			echo 'crypt() NOT found.' >&4
12118			val="$undef"
12119		else
12120			val="$define"
12121		fi
12122	fi
12123	set d_crypt
12124	eval $setvar
12125	;;
12126esac
12127
12128: see if this is a crypt.h system
12129set crypt.h i_crypt
12130eval $inhdr
12131
12132: see if crypt_r exists
12133set crypt_r d_crypt_r
12134eval $inlibc
12135case "$d_crypt_r" in
12136"$define")
12137	hdrs="$i_systypes sys/types.h define stdio.h $i_crypt crypt.h"
12138	case "$d_crypt_r_proto:$usethreads" in
12139	":define")	d_crypt_r_proto=define
12140		set d_crypt_r_proto crypt_r $hdrs
12141		eval $hasproto ;;
12142	*)	;;
12143	esac
12144	case "$d_crypt_r_proto" in
12145	define)
12146	case "$crypt_r_proto" in
12147	''|0) try='char* crypt_r(const char*, const char*, struct crypt_data*);'
12148	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCS ;;
12149	esac
12150	case "$crypt_r_proto" in
12151	''|0) try='char* crypt_r(const char*, const char*, CRYPTD*);'
12152	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCD ;;
12153	esac
12154	case "$crypt_r_proto" in
12155	''|0)	d_crypt_r=undef
12156		crypt_r_proto=0
12157		echo "Disabling crypt_r, cannot determine prototype." >&4 ;;
12158	* )	case "$crypt_r_proto" in
12159		REENTRANT_PROTO*) ;;
12160		*) crypt_r_proto="REENTRANT_PROTO_$crypt_r_proto" ;;
12161		esac
12162		echo "Prototype: $try" ;;
12163	esac
12164	;;
12165	*)	case "$usethreads" in
12166		define) echo "crypt_r has no prototype, not using it." >&4 ;;
12167		esac
12168		d_crypt_r=undef
12169		crypt_r_proto=0
12170		;;
12171	esac
12172	;;
12173*)	crypt_r_proto=0
12174	;;
12175esac
12176
12177: get csh whereabouts
12178case "$csh" in
12179'csh') val="$undef" ;;
12180*) val="$define" ;;
12181esac
12182set d_csh
12183eval $setvar
12184: Respect a hint or command line value for full_csh.
12185case "$full_csh" in
12186'') full_csh=$csh ;;
12187esac
12188
12189: see if ctermid exists
12190set ctermid d_ctermid
12191eval $inlibc
12192
12193: see if ctermid_r exists
12194set ctermid_r d_ctermid_r
12195eval $inlibc
12196case "$d_ctermid_r" in
12197"$define")
12198	hdrs="$i_systypes sys/types.h define stdio.h "
12199	case "$d_ctermid_r_proto:$usethreads" in
12200	":define")	d_ctermid_r_proto=define
12201		set d_ctermid_r_proto ctermid_r $hdrs
12202		eval $hasproto ;;
12203	*)	;;
12204	esac
12205	case "$d_ctermid_r_proto" in
12206	define)
12207	case "$ctermid_r_proto" in
12208	''|0) try='char* ctermid_r(char*);'
12209	./protochk "$extern_C $try" $hdrs && ctermid_r_proto=B_B ;;
12210	esac
12211	case "$ctermid_r_proto" in
12212	''|0)	d_ctermid_r=undef
12213		ctermid_r_proto=0
12214		echo "Disabling ctermid_r, cannot determine prototype." >&4 ;;
12215	* )	case "$ctermid_r_proto" in
12216		REENTRANT_PROTO*) ;;
12217		*) ctermid_r_proto="REENTRANT_PROTO_$ctermid_r_proto" ;;
12218		esac
12219		echo "Prototype: $try" ;;
12220	esac
12221	;;
12222	*)	case "$usethreads" in
12223		define) echo "ctermid_r has no prototype, not using it." >&4 ;;
12224		esac
12225		d_ctermid_r=undef
12226		ctermid_r_proto=0
12227		;;
12228	esac
12229	;;
12230*)	ctermid_r_proto=0
12231	;;
12232esac
12233
12234: see if ctime_r exists
12235set ctime_r d_ctime_r
12236eval $inlibc
12237case "$d_ctime_r" in
12238"$define")
12239	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
12240	case "$d_ctime_r_proto:$usethreads" in
12241	":define")	d_ctime_r_proto=define
12242		set d_ctime_r_proto ctime_r $hdrs
12243		eval $hasproto ;;
12244	*)	;;
12245	esac
12246	case "$d_ctime_r_proto" in
12247	define)
12248	case "$ctime_r_proto" in
12249	''|0) try='char* ctime_r(const time_t*, char*);'
12250	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SB ;;
12251	esac
12252	case "$ctime_r_proto" in
12253	''|0) try='char* ctime_r(const time_t*, char*, int);'
12254	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SBI ;;
12255	esac
12256	case "$ctime_r_proto" in
12257	''|0) try='int ctime_r(const time_t*, char*);'
12258	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SB ;;
12259	esac
12260	case "$ctime_r_proto" in
12261	''|0) try='int ctime_r(const time_t*, char*, int);'
12262	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SBI ;;
12263	esac
12264	case "$ctime_r_proto" in
12265	''|0)	d_ctime_r=undef
12266		ctime_r_proto=0
12267		echo "Disabling ctime_r, cannot determine prototype." >&4 ;;
12268	* )	case "$ctime_r_proto" in
12269		REENTRANT_PROTO*) ;;
12270		*) ctime_r_proto="REENTRANT_PROTO_$ctime_r_proto" ;;
12271		esac
12272		echo "Prototype: $try" ;;
12273	esac
12274	;;
12275	*)	case "$usethreads" in
12276		define) echo "ctime_r has no prototype, not using it." >&4 ;;
12277		esac
12278		d_ctime_r=undef
12279		ctime_r_proto=0
12280		;;
12281	esac
12282	;;
12283*)	ctime_r_proto=0
12284	;;
12285esac
12286
12287: see if cuserid exists
12288set cuserid d_cuserid
12289eval $inlibc
12290
12291: see if dbm.h is available
12292: see if dbmclose exists
12293set dbmclose d_dbmclose
12294eval $inlibc
12295
12296case "$d_dbmclose" in
12297$define)
12298	set dbm.h i_dbm
12299	eval $inhdr
12300	case "$i_dbm" in
12301	$define)
12302		val="$undef"
12303		set i_rpcsvcdbm
12304		eval $setvar
12305		;;
12306	*)	set rpcsvc/dbm.h i_rpcsvcdbm
12307		eval $inhdr
12308		;;
12309	esac
12310	;;
12311*)	echo "We won't be including <dbm.h>"
12312	val="$undef"
12313	set i_dbm
12314	eval $setvar
12315	val="$undef"
12316	set i_rpcsvcdbm
12317	eval $setvar
12318	;;
12319esac
12320
12321: see if prototype for dbminit is available
12322echo " "
12323set d_dbminitproto dbminit $i_dbm dbm.h
12324eval $hasproto
12325
12326: see if difftime exists
12327set difftime d_difftime
12328eval $inlibc
12329
12330: see if this is a dirent system
12331echo " "
12332if xinc=`./findhdr dirent.h`; $test "$xinc"; then
12333	val="$define"
12334	echo "<dirent.h> found." >&4
12335else
12336	val="$undef"
12337	if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
12338		echo "<sys/dir.h> found." >&4
12339		echo " "
12340	else
12341		xinc=`./findhdr sys/ndir.h`
12342	fi
12343	echo "<dirent.h> NOT found." >&4
12344fi
12345set i_dirent
12346eval $setvar
12347
12348: Look for type of directory structure.
12349echo " "
12350$cppstdin $cppflags $cppminus < "$xinc" > try.c
12351
12352case "$direntrytype" in
12353''|' ')
12354	case "$i_dirent" in
12355	$define) guess1='struct dirent' ;;
12356	*) guess1='struct direct'  ;;
12357	esac
12358	;;
12359*)	guess1="$direntrytype"
12360	;;
12361esac
12362
12363case "$guess1" in
12364'struct dirent') guess2='struct direct' ;;
12365*) guess2='struct dirent' ;;
12366esac
12367
12368if $contains "$guess1" try.c >/dev/null 2>&1; then
12369	direntrytype="$guess1"
12370	echo "Your directory entries are $direntrytype." >&4
12371elif $contains "$guess2" try.c >/dev/null 2>&1; then
12372	direntrytype="$guess2"
12373	echo "Your directory entries seem to be $direntrytype." >&4
12374else
12375	echo "I don't recognize your system's directory entries." >&4
12376	rp="What type is used for directory entries on this system?"
12377	dflt="$guess1"
12378	. ./myread
12379	direntrytype="$ans"
12380fi
12381$rm_try
12382
12383: see if the directory entry stores field length
12384echo " "
12385$cppstdin $cppflags $cppminus < "$xinc" > try.c
12386if $contains 'd_namlen' try.c >/dev/null 2>&1; then
12387	echo "Good, your directory entry keeps length information in d_namlen." >&4
12388	val="$define"
12389else
12390	echo "Your directory entry does not know about the d_namlen field." >&4
12391	val="$undef"
12392fi
12393set d_dirnamlen
12394eval $setvar
12395$rm_try
12396
12397: Look for DIR.dd_fd
12398case "$i_dirent" in
12399"$define")
12400    echo "Checking to see if DIR has a dd_fd member variable" >&4
12401    $cat >try.c <<EOCP
12402#$i_stdlib I_STDLIB
12403#ifdef I_STDLIB
12404#include <stdlib.h>
12405#endif
12406#include <dirent.h>
12407
12408int main() {
12409    DIR dir;
12410    dir.dd_fd = 1;
12411    return 0;
12412}
12413EOCP
12414    val=$undef
12415    set try
12416    if eval $compile; then
12417        echo "Yes, it does."
12418        val="$define"
12419    else
12420        echo "No, it does not."
12421        val="$undef"
12422    fi
12423    ;;
12424*)
12425    echo "You don't have a <dirent.h>, so not checking for dd_fd." >&4
12426    val="$undef"
12427    ;;
12428esac
12429set d_dir_dd_fd
12430eval $setvar
12431$rm_try
12432
12433: see if this is an sysdir system
12434set sys/dir.h i_sysdir
12435eval $inhdr
12436
12437: see if this is an sysndir system
12438set sys/ndir.h i_sysndir
12439eval $inhdr
12440
12441: Look for dirfd
12442echo " "
12443$cat >dirfd.c <<EOM
12444#include <stdio.h>
12445#$i_stdlib I_STDLIB
12446#ifdef I_STDLIB
12447#include <stdlib.h>
12448#endif
12449#$i_dirent I_DIRENT		/**/
12450#$i_sysdir I_SYS_DIR		/**/
12451#$i_sysndir I_SYS_NDIR		/**/
12452#$i_systypes I_SYS_TYPES	/**/
12453#if defined(I_SYS_TYPES)
12454#include <sys/types.h>
12455#endif
12456#if defined(I_DIRENT)
12457#include <dirent.h>
12458#else
12459#ifdef I_SYS_NDIR
12460#include <sys/ndir.h>
12461#else
12462#ifdef I_SYS_DIR
12463#include <sys/dir.h>
12464#endif
12465#endif
12466#endif
12467int main() {
12468	DIR *dirp = opendir(".");
12469	if (dirfd(dirp) >= 0)
12470		exit(0);
12471	else
12472		exit(1);
12473}
12474EOM
12475val=$undef
12476set dirfd
12477if eval $compile; then
12478	val="$define"
12479fi
12480case "$val" in
12481$define)	echo "dirfd() found." >&4	;;
12482*)		echo "dirfd() NOT found." >&4	;;
12483esac
12484set d_dirfd
12485eval $setvar
12486$rm -f dirfd*
12487
12488: see if dladdr exists
12489set dladdr d_dladdr
12490eval $inlibc
12491
12492: see if dlerror exists
12493xxx_runnm="$runnm"
12494runnm=false
12495set dlerror d_dlerror
12496eval $inlibc
12497runnm="$xxx_runnm"
12498
12499: see if dlfcn is available
12500set dlfcn.h i_dlfcn
12501eval $inhdr
12502
12503: Check what extension to use for shared libs
12504case "$usedl" in
12505$define|y|true)
12506	$cat << EOM
12507
12508On a few systems, the dynamically loaded modules that perl generates and uses
12509will need a different extension than shared libs. The default will probably
12510be appropriate.
12511
12512EOM
12513	case "$dlext" in
12514	'')	dflt="$so" ;;
12515	*)	dflt="$dlext" ;;
12516	esac
12517	rp='What is the extension of dynamically loaded modules'
12518	. ./myread
12519	dlext="$ans"
12520	;;
12521*)
12522	dlext="none"
12523	;;
12524esac
12525
12526: Check if dlsym need a leading underscore
12527echo " "
12528val="$undef"
12529
12530case "$dlsrc" in
12531dl_dlopen.xs)
12532	echo "Checking whether your dlsym() needs a leading underscore ..." >&4
12533	$cat >dyna.c <<'EOM'
12534fred () { }
12535EOM
12536
12537$cat >fred.c<<EOM
12538
12539#include <stdio.h>
12540#$i_stdlib I_STDLIB
12541#ifdef I_STDLIB
12542#include <stdlib.h>
12543#endif
12544#$i_dlfcn I_DLFCN
12545#ifdef I_DLFCN
12546#include <dlfcn.h>      /* the dynamic linker include file for SunOS/Solaris */
12547#else
12548#include <sys/types.h>
12549#include <nlist.h>
12550#include <link.h>
12551#endif
12552
12553extern int fred() ;
12554
12555int main()
12556{
12557    void * handle ;
12558    void * symbol ;
12559#ifndef RTLD_LAZY
12560    int mode = 1 ;
12561#else
12562    int mode = RTLD_LAZY ;
12563#endif
12564    handle = dlopen("./dyna.$dlext", mode) ;
12565    if (handle == NULL) {
12566	printf ("1\n") ;
12567	fflush (stdout) ;
12568	exit(0);
12569    }
12570    symbol = dlsym(handle, "fred") ;
12571    if (symbol == NULL) {
12572	/* try putting a leading underscore */
12573	symbol = dlsym(handle, "_fred") ;
12574	if (symbol == NULL) {
12575	    printf ("2\n") ;
12576	    fflush (stdout) ;
12577	    exit(0);
12578	}
12579	printf ("3\n") ;
12580    }
12581    else
12582	printf ("4\n") ;
12583    fflush (stdout) ;
12584    exit(0);
12585}
12586EOM
12587	: Call the object file tmp-dyna.o in case dlext=o.
12588	if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 &&
12589		mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 &&
12590		$ld -o dyna.$dlext $ldflags $lddlflags tmp-dyna${_o} > /dev/null 2>&1 &&
12591		$cc -o fred $ccflags $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1 && $to dyna.$dlext; then
12592		xxx=`$run ./fred`
12593		case $xxx in
12594		1)	echo "Test program failed using dlopen." >&4
12595			echo "Perhaps you should not use dynamic loading." >&4;;
12596		2)	echo "Test program failed using dlsym." >&4
12597			echo "Perhaps you should not use dynamic loading." >&4;;
12598		3)	echo "dlsym needs a leading underscore" >&4
12599			val="$define" ;;
12600		4)	echo "dlsym doesn't need a leading underscore." >&4;;
12601		esac
12602	else
12603		echo "I can't compile and run the test program." >&4
12604                echo "I'm guessing that dlsym doesn't need a leading underscore." >&4
12605	fi
12606	;;
12607esac
12608
12609$rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.*
12610
12611set d_dlsymun
12612eval $setvar
12613
12614: see if drand48_r exists
12615set drand48_r d_drand48_r
12616eval $inlibc
12617case "$d_drand48_r" in
12618"$define")
12619	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
12620	case "$d_drand48_r_proto:$usethreads" in
12621	":define")	d_drand48_r_proto=define
12622		set d_drand48_r_proto drand48_r $hdrs
12623		eval $hasproto ;;
12624	*)	;;
12625	esac
12626	case "$d_drand48_r_proto" in
12627	define)
12628	case "$drand48_r_proto" in
12629	''|0) try='int drand48_r(struct drand48_data*, double*);'
12630	./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;;
12631	esac
12632	case "$drand48_r_proto" in
12633	''|0)	d_drand48_r=undef
12634		drand48_r_proto=0
12635		echo "Disabling drand48_r, cannot determine prototype." >&4 ;;
12636	* )	case "$drand48_r_proto" in
12637		REENTRANT_PROTO*) ;;
12638		*) drand48_r_proto="REENTRANT_PROTO_$drand48_r_proto" ;;
12639		esac
12640		echo "Prototype: $try" ;;
12641	esac
12642	;;
12643	*)	case "$usethreads" in
12644		define) echo "drand48_r has no prototype, not using it." >&4 ;;
12645		esac
12646		d_drand48_r=undef
12647		drand48_r_proto=0
12648		;;
12649	esac
12650	;;
12651*)	drand48_r_proto=0
12652	;;
12653esac
12654
12655: see if prototype for drand48 is available
12656echo " "
12657set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
12658eval $hasproto
12659
12660: see if dup2 exists
12661set dup2 d_dup2
12662eval $inlibc
12663
12664: see if dup3 exists
12665set dup3 d_dup3
12666eval $inlibc
12667
12668: see if this is an xlocale.h system
12669set xlocale.h i_xlocale
12670eval $inhdr
12671
12672: see if newlocale exists
12673set newlocale d_newlocale
12674eval $inlibc
12675
12676: see if freelocale exists
12677set freelocale d_freelocale
12678eval $inlibc
12679
12680: see if uselocale exists
12681set uselocale d_uselocale
12682eval $inlibc
12683
12684: see if duplocale exists
12685set duplocale d_duplocale
12686eval $inlibc
12687
12688: see if querylocale exists
12689set querylocale d_querylocale
12690eval $inlibc
12691
12692: see if eaccess exists
12693set eaccess d_eaccess
12694eval $inlibc
12695
12696: see if endgrent exists
12697set endgrent d_endgrent
12698eval $inlibc
12699
12700: see if this is an grp system
12701set grp.h i_grp
12702eval $inhdr
12703
12704case "$i_grp" in
12705$define)
12706	xxx=`./findhdr grp.h`
12707	$cppstdin $cppflags $cppminus < $xxx >$$.h
12708
12709	if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
12710		val="$define"
12711	else
12712		val="$undef"
12713	fi
12714	set d_grpasswd
12715	eval $setvar
12716
12717	$rm -f $$.h
12718	;;
12719*)
12720	val="$undef";
12721	set d_grpasswd; eval $setvar
12722	;;
12723esac
12724
12725: see if endgrent_r exists
12726set endgrent_r d_endgrent_r
12727eval $inlibc
12728case "$d_endgrent_r" in
12729"$define")
12730	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
12731	case "$d_endgrent_r_proto:$usethreads" in
12732	":define")	d_endgrent_r_proto=define
12733		set d_endgrent_r_proto endgrent_r $hdrs
12734		eval $hasproto ;;
12735	*)	;;
12736	esac
12737	case "$d_endgrent_r_proto" in
12738	define)
12739	case "$endgrent_r_proto" in
12740	''|0) try='int endgrent_r(FILE**);'
12741	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=I_H ;;
12742	esac
12743	case "$endgrent_r_proto" in
12744	''|0) try='void endgrent_r(FILE**);'
12745	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=V_H ;;
12746	esac
12747	case "$endgrent_r_proto" in
12748	''|0)	d_endgrent_r=undef
12749		endgrent_r_proto=0
12750		echo "Disabling endgrent_r, cannot determine prototype." >&4 ;;
12751	* )	case "$endgrent_r_proto" in
12752		REENTRANT_PROTO*) ;;
12753		*) endgrent_r_proto="REENTRANT_PROTO_$endgrent_r_proto" ;;
12754		esac
12755		echo "Prototype: $try" ;;
12756	esac
12757	;;
12758	*)	case "$usethreads" in
12759		define) echo "endgrent_r has no prototype, not using it." >&4 ;;
12760		esac
12761		d_endgrent_r=undef
12762		endgrent_r_proto=0
12763		;;
12764	esac
12765	;;
12766*)	endgrent_r_proto=0
12767	;;
12768esac
12769
12770: see if endhostent exists
12771set endhostent d_endhent
12772eval $inlibc
12773
12774: see if this is a netdb.h system
12775set netdb.h i_netdb
12776eval $inhdr
12777
12778: see if endhostent_r exists
12779set endhostent_r d_endhostent_r
12780eval $inlibc
12781case "$d_endhostent_r" in
12782"$define")
12783	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12784	case "$d_endhostent_r_proto:$usethreads" in
12785	":define")	d_endhostent_r_proto=define
12786		set d_endhostent_r_proto endhostent_r $hdrs
12787		eval $hasproto ;;
12788	*)	;;
12789	esac
12790	case "$d_endhostent_r_proto" in
12791	define)
12792	case "$endhostent_r_proto" in
12793	''|0) try='int endhostent_r(struct hostent_data*);'
12794	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=I_D ;;
12795	esac
12796	case "$endhostent_r_proto" in
12797	''|0) try='void endhostent_r(struct hostent_data*);'
12798	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=V_D ;;
12799	esac
12800	case "$endhostent_r_proto" in
12801	''|0)	d_endhostent_r=undef
12802		endhostent_r_proto=0
12803		echo "Disabling endhostent_r, cannot determine prototype." >&4 ;;
12804	* )	case "$endhostent_r_proto" in
12805		REENTRANT_PROTO*) ;;
12806		*) endhostent_r_proto="REENTRANT_PROTO_$endhostent_r_proto" ;;
12807		esac
12808		echo "Prototype: $try" ;;
12809	esac
12810	;;
12811	*)	case "$usethreads" in
12812		define) echo "endhostent_r has no prototype, not using it." >&4 ;;
12813		esac
12814		d_endhostent_r=undef
12815		endhostent_r_proto=0
12816		;;
12817	esac
12818	;;
12819*)	endhostent_r_proto=0
12820	;;
12821esac
12822
12823: see if endnetent exists
12824set endnetent d_endnent
12825eval $inlibc
12826
12827: see if endnetent_r exists
12828set endnetent_r d_endnetent_r
12829eval $inlibc
12830case "$d_endnetent_r" in
12831"$define")
12832	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12833	case "$d_endnetent_r_proto:$usethreads" in
12834	":define")	d_endnetent_r_proto=define
12835		set d_endnetent_r_proto endnetent_r $hdrs
12836		eval $hasproto ;;
12837	*)	;;
12838	esac
12839	case "$d_endnetent_r_proto" in
12840	define)
12841	case "$endnetent_r_proto" in
12842	''|0) try='int endnetent_r(struct netent_data*);'
12843	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=I_D ;;
12844	esac
12845	case "$endnetent_r_proto" in
12846	''|0) try='void endnetent_r(struct netent_data*);'
12847	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=V_D ;;
12848	esac
12849	case "$endnetent_r_proto" in
12850	''|0)	d_endnetent_r=undef
12851		endnetent_r_proto=0
12852		echo "Disabling endnetent_r, cannot determine prototype." >&4 ;;
12853	* )	case "$endnetent_r_proto" in
12854		REENTRANT_PROTO*) ;;
12855		*) endnetent_r_proto="REENTRANT_PROTO_$endnetent_r_proto" ;;
12856		esac
12857		echo "Prototype: $try" ;;
12858	esac
12859	;;
12860	*)	case "$usethreads" in
12861		define) echo "endnetent_r has no prototype, not using it." >&4 ;;
12862		esac
12863		d_endnetent_r=undef
12864		endnetent_r_proto=0
12865		;;
12866	esac
12867	;;
12868*)	endnetent_r_proto=0
12869	;;
12870esac
12871
12872: see if endprotoent exists
12873set endprotoent d_endpent
12874eval $inlibc
12875
12876: see if endprotoent_r exists
12877set endprotoent_r d_endprotoent_r
12878eval $inlibc
12879case "$d_endprotoent_r" in
12880"$define")
12881	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12882	case "$d_endprotoent_r_proto:$usethreads" in
12883	":define")	d_endprotoent_r_proto=define
12884		set d_endprotoent_r_proto endprotoent_r $hdrs
12885		eval $hasproto ;;
12886	*)	;;
12887	esac
12888	case "$d_endprotoent_r_proto" in
12889	define)
12890	case "$endprotoent_r_proto" in
12891	''|0) try='int endprotoent_r(struct protoent_data*);'
12892	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=I_D ;;
12893	esac
12894	case "$endprotoent_r_proto" in
12895	''|0) try='void endprotoent_r(struct protoent_data*);'
12896	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=V_D ;;
12897	esac
12898	case "$endprotoent_r_proto" in
12899	''|0)	d_endprotoent_r=undef
12900		endprotoent_r_proto=0
12901		echo "Disabling endprotoent_r, cannot determine prototype." >&4 ;;
12902	* )	case "$endprotoent_r_proto" in
12903		REENTRANT_PROTO*) ;;
12904		*) endprotoent_r_proto="REENTRANT_PROTO_$endprotoent_r_proto" ;;
12905		esac
12906		echo "Prototype: $try" ;;
12907	esac
12908	;;
12909	*)	case "$usethreads" in
12910		define) echo "endprotoent_r has no prototype, not using it." >&4 ;;
12911		esac
12912		d_endprotoent_r=undef
12913		endprotoent_r_proto=0
12914		;;
12915	esac
12916	;;
12917*)	endprotoent_r_proto=0
12918	;;
12919esac
12920
12921: see if endpwent exists
12922set endpwent d_endpwent
12923eval $inlibc
12924
12925: see if this is a pwd.h system
12926set pwd.h i_pwd
12927eval $inhdr
12928
12929case "$i_pwd" in
12930$define)
12931	xxx=`./findhdr pwd.h`
12932	$cppstdin $cppflags $cppminus < $xxx >$$.h
12933
12934	if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
12935		val="$define"
12936	else
12937		val="$undef"
12938	fi
12939	set d_pwquota
12940	eval $setvar
12941
12942	if $contains 'pw_age' $$.h >/dev/null 2>&1; then
12943		val="$define"
12944	else
12945		val="$undef"
12946	fi
12947	set d_pwage
12948	eval $setvar
12949
12950	if $contains 'pw_change' $$.h >/dev/null 2>&1; then
12951		val="$define"
12952	else
12953		val="$undef"
12954	fi
12955	set d_pwchange
12956	eval $setvar
12957
12958	if $contains 'pw_class' $$.h >/dev/null 2>&1; then
12959		val="$define"
12960	else
12961		val="$undef"
12962	fi
12963	set d_pwclass
12964	eval $setvar
12965
12966	if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
12967		val="$define"
12968	else
12969		val="$undef"
12970	fi
12971	set d_pwexpire
12972	eval $setvar
12973
12974	if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
12975		val="$define"
12976	else
12977		val="$undef"
12978	fi
12979	set d_pwcomment
12980	eval $setvar
12981
12982	if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
12983		val="$define"
12984	else
12985		val="$undef"
12986	fi
12987	set d_pwgecos
12988	eval $setvar
12989
12990	if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
12991		val="$define"
12992	else
12993		val="$undef"
12994	fi
12995	set d_pwpasswd
12996	eval $setvar
12997
12998	$rm -f $$.h
12999	;;
13000*)
13001	val="$undef";
13002	set d_pwquota; eval $setvar
13003	set d_pwage; eval $setvar
13004	set d_pwchange; eval $setvar
13005	set d_pwclass; eval $setvar
13006	set d_pwexpire; eval $setvar
13007	set d_pwcomment; eval $setvar
13008	set d_pwgecos; eval $setvar
13009	set d_pwpasswd; eval $setvar
13010	;;
13011esac
13012
13013: see if endpwent_r exists
13014set endpwent_r d_endpwent_r
13015eval $inlibc
13016case "$d_endpwent_r" in
13017"$define")
13018	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
13019	case "$d_endpwent_r_proto:$usethreads" in
13020	":define")	d_endpwent_r_proto=define
13021		set d_endpwent_r_proto endpwent_r $hdrs
13022		eval $hasproto ;;
13023	*)	;;
13024	esac
13025	case "$d_endpwent_r_proto" in
13026	define)
13027	case "$endpwent_r_proto" in
13028	''|0) try='int endpwent_r(FILE**);'
13029	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=I_H ;;
13030	esac
13031	case "$endpwent_r_proto" in
13032	''|0) try='void endpwent_r(FILE**);'
13033	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=V_H ;;
13034	esac
13035	case "$endpwent_r_proto" in
13036	''|0)	d_endpwent_r=undef
13037		endpwent_r_proto=0
13038		echo "Disabling endpwent_r, cannot determine prototype." >&4 ;;
13039	* )	case "$endpwent_r_proto" in
13040		REENTRANT_PROTO*) ;;
13041		*) endpwent_r_proto="REENTRANT_PROTO_$endpwent_r_proto" ;;
13042		esac
13043		echo "Prototype: $try" ;;
13044	esac
13045	;;
13046	*)	case "$usethreads" in
13047		define) echo "endpwent_r has no prototype, not using it." >&4 ;;
13048		esac
13049		d_endpwent_r=undef
13050		endpwent_r_proto=0
13051		;;
13052	esac
13053	;;
13054*)	endpwent_r_proto=0
13055	;;
13056esac
13057
13058: see if endservent exists
13059set endservent d_endsent
13060eval $inlibc
13061
13062: see if endservent_r exists
13063set endservent_r d_endservent_r
13064eval $inlibc
13065case "$d_endservent_r" in
13066"$define")
13067	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
13068	case "$d_endservent_r_proto:$usethreads" in
13069	":define")	d_endservent_r_proto=define
13070		set d_endservent_r_proto endservent_r $hdrs
13071		eval $hasproto ;;
13072	*)	;;
13073	esac
13074	case "$d_endservent_r_proto" in
13075	define)
13076	case "$endservent_r_proto" in
13077	''|0) try='int endservent_r(struct servent_data*);'
13078	./protochk "$extern_C $try" $hdrs && endservent_r_proto=I_D ;;
13079	esac
13080	case "$endservent_r_proto" in
13081	''|0) try='void endservent_r(struct servent_data*);'
13082	./protochk "$extern_C $try" $hdrs && endservent_r_proto=V_D ;;
13083	esac
13084	case "$endservent_r_proto" in
13085	''|0)	d_endservent_r=undef
13086		endservent_r_proto=0
13087		echo "Disabling endservent_r, cannot determine prototype." >&4 ;;
13088	* )	case "$endservent_r_proto" in
13089		REENTRANT_PROTO*) ;;
13090		*) endservent_r_proto="REENTRANT_PROTO_$endservent_r_proto" ;;
13091		esac
13092		echo "Prototype: $try" ;;
13093	esac
13094	;;
13095	*)	case "$usethreads" in
13096		define) echo "endservent_r has no prototype, not using it." >&4 ;;
13097		esac
13098		d_endservent_r=undef
13099		endservent_r_proto=0
13100		;;
13101	esac
13102	;;
13103*)	endservent_r_proto=0
13104	;;
13105esac
13106
13107: Locate the flags for 'open()'
13108echo " "
13109$cat >try.c <<EOCP
13110#include <sys/types.h>
13111#ifdef I_FCNTL
13112#include <fcntl.h>
13113#endif
13114#ifdef I_SYS_FILE
13115#include <sys/file.h>
13116#endif
13117#$i_stdlib I_STDLIB
13118#ifdef I_STDLIB
13119#include <stdlib.h>
13120#endif
13121int main() {
13122	if(O_RDONLY);
13123#ifdef O_TRUNC
13124	exit(0);
13125#else
13126	exit(1);
13127#endif
13128}
13129EOCP
13130: check sys/file.h first to get FREAD on Sun
13131if $test `./findhdr sys/file.h` && \
13132		set try -DI_SYS_FILE && eval $compile; then
13133	h_sysfile=true;
13134	echo "<sys/file.h> defines the O_* constants..." >&4
13135	if $run ./try; then
13136		echo "and you have the 3 argument form of open()." >&4
13137		val="$define"
13138	else
13139		echo "but not the 3 argument form of open().  Oh, well." >&4
13140		val="$undef"
13141	fi
13142elif $test `./findhdr fcntl.h` && \
13143		set try -DI_FCNTL && eval $compile; then
13144	h_fcntl=true;
13145	echo "<fcntl.h> defines the O_* constants..." >&4
13146	if $run ./try; then
13147		echo "and you have the 3 argument form of open()." >&4
13148		val="$define"
13149	else
13150		echo "but not the 3 argument form of open().  Oh, well." >&4
13151		val="$undef"
13152	fi
13153else
13154	val="$undef"
13155	echo "I can't find the O_* constant definitions!  You got problems." >&4
13156fi
13157set d_open3
13158eval $setvar
13159$rm_try
13160
13161: see if this is a sys/file.h system
13162val=''
13163set sys/file.h val
13164eval $inhdr
13165
13166: do we need to include sys/file.h ?
13167case "$val" in
13168"$define")
13169	echo " "
13170	if $h_sysfile; then
13171		val="$define"
13172		echo "We'll be including <sys/file.h>." >&4
13173	else
13174		val="$undef"
13175		echo "We won't be including <sys/file.h>." >&4
13176	fi
13177	;;
13178*)
13179	h_sysfile=false
13180	;;
13181esac
13182set i_sysfile
13183eval $setvar
13184
13185: see if fcntl.h is there
13186val=''
13187set fcntl.h val
13188eval $inhdr
13189
13190: see if we can include fcntl.h
13191case "$val" in
13192"$define")
13193	echo " "
13194	if $h_fcntl; then
13195		val="$define"
13196		echo "We'll be including <fcntl.h>." >&4
13197	else
13198		val="$undef"
13199		if $h_sysfile; then
13200	echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
13201		else
13202			echo "We won't be including <fcntl.h>." >&4
13203		fi
13204	fi
13205	;;
13206*)
13207	h_fcntl=false
13208	val="$undef"
13209	;;
13210esac
13211set i_fcntl
13212eval $setvar
13213
13214: see if fork exists
13215set fork d_fork
13216eval $inlibc
13217
13218: see if pipe exists
13219set pipe d_pipe
13220eval $inlibc
13221
13222: check for non-blocking I/O stuff
13223case "$h_sysfile" in
13224true) echo "#include <sys/file.h>" > head.c;;
13225*)
13226       case "$h_fcntl" in
13227       true) echo "#include <fcntl.h>" > head.c;;
13228       *) echo "#include <sys/fcntl.h>" > head.c;;
13229       esac
13230       ;;
13231esac
13232echo " "
13233echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
13234case "$o_nonblock" in
13235'')
13236	$cat head.c > try.c
13237	$cat >>try.c <<EOCP
13238#include <stdio.h>
13239#$i_stdlib I_STDLIB
13240#ifdef I_STDLIB
13241#include <stdlib.h>
13242#endif
13243#$i_fcntl I_FCNTL
13244#ifdef I_FCNTL
13245#include <fcntl.h>
13246#endif
13247int main() {
13248#ifdef O_NONBLOCK
13249	printf("O_NONBLOCK\n");
13250	exit(0);
13251#endif
13252#ifdef O_NDELAY
13253	printf("O_NDELAY\n");
13254	exit(0);
13255#endif
13256#ifdef FNDELAY
13257	printf("FNDELAY\n");
13258	exit(0);
13259#endif
13260	exit(0);
13261}
13262EOCP
13263	set try
13264	if eval $compile_ok; then
13265		o_nonblock=`$run ./try`
13266		case "$o_nonblock" in
13267		'') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
13268		*) echo "Seems like we can use $o_nonblock.";;
13269		esac
13270	else
13271		echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
13272	fi
13273	;;
13274*) echo "Using $hint value $o_nonblock.";;
13275esac
13276$rm_try
13277
13278echo " "
13279echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
13280case "$eagain" in
13281'')
13282	case "$d_fork:$d_pipe:$d_alarm" in
13283	define:define:define)
13284	$cat head.c > try.c
13285	$cat >>try.c <<EOCP
13286#include <errno.h>
13287#include <sys/types.h>
13288#include <signal.h>
13289#include <stdio.h>
13290#$i_stdlib I_STDLIB
13291#ifdef I_STDLIB
13292#include <stdlib.h>
13293#endif
13294#$i_fcntl I_FCNTL
13295#ifdef I_FCNTL
13296#include <fcntl.h>
13297#endif
13298#define MY_O_NONBLOCK $o_nonblock
13299#ifndef errno  /* XXX need better Configure test */
13300extern int errno;
13301#endif
13302#$i_unistd I_UNISTD
13303#ifdef I_UNISTD
13304#include <unistd.h>
13305#endif
13306#include <string.h>
13307$signal_t blech(int x) { exit(3); }
13308EOCP
13309	$cat >> try.c <<'EOCP'
13310int main()
13311{
13312	int pd[2];
13313	int pu[2];
13314	char buf[1];
13315	char string[100];
13316	int ret;
13317
13318	ret = pipe(pd);	/* Down: child -> parent */
13319	if (ret != 0)
13320		exit(3);
13321	ret = pipe(pu);	/* Up: parent -> child */
13322	if (ret != 0)
13323		exit(3);
13324	if (0 != fork()) {
13325		close(pd[1]);	/* Parent reads from pd[0] */
13326		close(pu[0]);	/* Parent writes (blocking) to pu[1] */
13327#ifdef F_SETFL
13328		if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
13329			exit(1);
13330#else
13331		exit(4);
13332#endif
13333		signal(SIGALRM, blech);
13334		alarm(5);
13335		if ((ret = read(pd[0], buf, 1)) > 0)	/* Nothing to read! */
13336			exit(2);
13337		sprintf(string, "%d\n", ret);
13338		ret = write(2, string, strlen(string));
13339		if (ret != strlen(string))
13340			exit(3);
13341		alarm(0);
13342#ifdef EAGAIN
13343		if (errno == EAGAIN) {
13344			printf("EAGAIN\n");
13345			goto ok;
13346		}
13347#endif
13348#ifdef EWOULDBLOCK
13349		if (errno == EWOULDBLOCK)
13350			printf("EWOULDBLOCK\n");
13351#endif
13352	ok:
13353		ret = write(pu[1], buf, 1);	/* Unblocks child, tell it to close our pipe */
13354		if (ret != 1)
13355			exit(3);
13356		sleep(2);				/* Give it time to close our pipe */
13357		alarm(5);
13358		ret = read(pd[0], buf, 1);	/* Should read EOF */
13359		alarm(0);
13360		sprintf(string, "%d\n", ret);
13361		ret = write(4, string, strlen(string));
13362		if (ret != strlen(string))
13363			exit(3);
13364		exit(0);
13365	}
13366
13367	close(pd[0]);			/* We write to pd[1] */
13368	close(pu[1]);			/* We read from pu[0] */
13369	ret = read(pu[0], buf, 1);	/* Wait for parent to signal us we may continue */
13370	if (ret != 1)
13371		exit(3);
13372	close(pd[1]);			/* Pipe pd is now fully closed! */
13373	exit(0);				/* Bye bye, thank you for playing! */
13374}
13375EOCP
13376	set try
13377	if eval $compile_ok; then
13378		echo "$startsh" >mtry
13379		echo "$run ./try >try.out 2>try.ret 4>try.err || exit 4" >>mtry
13380		chmod +x mtry
13381		$run ./mtry >/dev/null 2>&1
13382		case $? in
13383		0) eagain=`$cat try.out`;;
13384		1) echo "Could not perform non-blocking setting!";;
13385		2) echo "I did a successful read() for something that was not there!";;
13386		3) echo "Hmm... non-blocking I/O does not seem to be working!";;
13387		4) echo "Could not find F_SETFL!";;
13388		*) echo "Something terribly wrong happened during testing.";;
13389		esac
13390		rd_nodata=`$cat try.ret`
13391		echo "A read() system call with no data present returns $rd_nodata."
13392		case "$rd_nodata" in
13393		0|-1) ;;
13394		*)
13395			echo "(That's peculiar, fixing that to be -1.)"
13396			rd_nodata=-1
13397			;;
13398		esac
13399		case "$eagain" in
13400		'')
13401			echo "Forcing errno EAGAIN on read() with no data available."
13402			eagain=EAGAIN
13403			;;
13404		*)
13405			echo "Your read() sets errno to $eagain when no data is available."
13406			;;
13407		esac
13408		status=`$cat try.err`
13409		case "$status" in
13410		0) echo "And it correctly returns 0 to signal EOF.";;
13411		-1) echo "But it also returns -1 to signal EOF, so be careful!";;
13412		*) echo "However, your read() returns '$status' on EOF??";;
13413		esac
13414		val="$define"
13415		if test "$status" = "$rd_nodata"; then
13416			echo "WARNING: you can't distinguish between EOF and no data!"
13417			val="$undef"
13418		fi
13419	else
13420		echo "I can't compile the test program--assuming errno EAGAIN will do."
13421		eagain=EAGAIN
13422	fi
13423	;;
13424	*)	echo "Can't figure out how to test this--assuming errno EAGAIN will do."
13425		eagain=EAGAIN
13426		val="$define"
13427		;;
13428	esac
13429	set d_eofnblk
13430	eval $setvar
13431	;;
13432*)
13433	echo "Using $hint value $eagain."
13434	echo "Your read() returns $rd_nodata when no data is present."
13435	case "$d_eofnblk" in
13436	"$define") echo "And you can see EOF because read() returns 0.";;
13437	"$undef") echo "But you can't see EOF status from read() returned value.";;
13438	*)
13439		echo "(Assuming you can't see EOF status from read anyway.)"
13440		d_eofnblk=$undef
13441		;;
13442	esac
13443	;;
13444esac
13445$rm_try head.c mtry
13446
13447: see if erf exists
13448set erf d_erf
13449eval $inlibc
13450
13451: see if erfc exists
13452set erfc d_erfc
13453eval $inlibc
13454
13455: see if exp2 exists
13456set exp2 d_exp2
13457eval $inlibc
13458
13459: see if expm1 exists
13460set expm1 d_expm1
13461eval $inlibc
13462
13463: see if _ptr and _cnt from stdio act std
13464echo " "
13465
13466if $contains '_lbfsize' `./findhdr stdio.h` >/dev/null 2>&1 ; then
13467	echo "(Looks like you have stdio.h from BSD.)"
13468	case "$stdio_ptr" in
13469	'') stdio_ptr='((fp)->_p)'
13470		ptr_lval=$define
13471		;;
13472	*)	ptr_lval=$d_stdio_ptr_lval;;
13473	esac
13474	case "$stdio_cnt" in
13475	'') stdio_cnt='((fp)->_r)'
13476		cnt_lval=$define
13477		;;
13478	*)	cnt_lval=$d_stdio_cnt_lval;;
13479	esac
13480	case "$stdio_base" in
13481	'') stdio_base='((fp)->_ub._base ? (fp)->_ub._base : (fp)->_bf._base)';;
13482	esac
13483	case "$stdio_bufsiz" in
13484	'') stdio_bufsiz='((fp)->_ub._base ? (fp)->_ub._size : (fp)->_bf._size)';;
13485	esac
13486elif $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
13487	echo "(Looks like you have stdio.h from Linux.)"
13488	case "$stdio_ptr" in
13489	'') stdio_ptr='((fp)->_IO_read_ptr)'
13490		ptr_lval=$define
13491		;;
13492	*)	ptr_lval=$d_stdio_ptr_lval;;
13493	esac
13494	case "$stdio_cnt" in
13495	'') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
13496		cnt_lval=$undef
13497		;;
13498	*)	cnt_lval=$d_stdio_cnt_lval;;
13499	esac
13500	case "$stdio_base" in
13501	'') stdio_base='((fp)->_IO_read_base)';;
13502	esac
13503	case "$stdio_bufsiz" in
13504	'') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
13505	esac
13506else
13507	case "$stdio_ptr" in
13508	'') stdio_ptr='((fp)->_ptr)'
13509		ptr_lval=$define
13510		;;
13511	*)	ptr_lval=$d_stdio_ptr_lval;;
13512	esac
13513	case "$stdio_cnt" in
13514	'') stdio_cnt='((fp)->_cnt)'
13515		cnt_lval=$define
13516		;;
13517	*)	cnt_lval=$d_stdio_cnt_lval;;
13518	esac
13519	case "$stdio_base" in
13520	'') stdio_base='((fp)->_base)';;
13521	esac
13522	case "$stdio_bufsiz" in
13523	'') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
13524	esac
13525fi
13526
13527: test whether _ptr and _cnt really work
13528echo "Checking how std your stdio is..." >&4
13529$cat >try.c <<EOP
13530#include <stdio.h>
13531#$i_stdlib I_STDLIB
13532#ifdef I_STDLIB
13533#include <stdlib.h>
13534#endif
13535#define FILE_ptr(fp)	$stdio_ptr
13536#define FILE_cnt(fp)	$stdio_cnt
13537int main() {
13538	FILE *fp = fopen("try.c", "r");
13539	char c = getc(fp);
13540	if (
13541		18 <= FILE_cnt(fp) &&
13542		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
13543	)
13544		exit(0);
13545	exit(1);
13546}
13547EOP
13548val="$undef"
13549set try
13550if eval $compile && $to try.c; then
13551	if $run ./try; then
13552		echo "Your stdio acts pretty std."
13553		val="$define"
13554	else
13555		echo "Your stdio isn't very std."
13556	fi
13557else
13558	echo "Your stdio doesn't appear very std."
13559fi
13560$rm_try
13561
13562# glibc 2.2.90 and above apparently change stdio streams so Perl's
13563# direct buffer manipulation no longer works.  The Configure tests
13564# should be changed to correctly detect this, but until then,
13565# the following check should at least let perl compile and run.
13566# (This quick fix should be updated before 5.8.1.)
13567# To be defensive, reject all unknown versions, and all versions  > 2.2.9.
13568# A. Dougherty, June 3, 2002.
13569case "$d_gnulibc" in
13570$define)
13571	case "$gnulibc_version" in
13572	2.[01]*)  ;;
13573	2.2) ;;
13574	2.2.[0-9]) ;;
13575	*)  echo "But I will not snoop inside glibc $gnulibc_version stdio buffers."
13576		val="$undef"
13577		;;
13578	esac
13579	;;
13580esac
13581set d_stdstdio
13582eval $setvar
13583
13584: Can _ptr be used as an lvalue?
13585case "$d_stdstdio$ptr_lval" in
13586$define$define) val=$define ;;
13587*) val=$undef ;;
13588esac
13589set d_stdio_ptr_lval
13590eval $setvar
13591
13592: Can _cnt be used as an lvalue?
13593case "$d_stdstdio$cnt_lval" in
13594$define$define) val=$define ;;
13595*) val=$undef ;;
13596esac
13597set d_stdio_cnt_lval
13598eval $setvar
13599
13600
13601: test whether setting _ptr sets _cnt as a side effect
13602d_stdio_ptr_lval_sets_cnt="$undef"
13603d_stdio_ptr_lval_nochange_cnt="$undef"
13604case "$d_stdio_ptr_lval$d_stdstdio" in
13605$define$define)
13606	echo "Checking to see what happens if we set the stdio ptr..." >&4
13607$cat >try.c <<EOP
13608#include <stdio.h>
13609/* Can we scream? */
13610/* Eat dust sed :-) */
13611/* In the buffer space, no one can hear you scream. */
13612#$i_stdlib I_STDLIB
13613#ifdef I_STDLIB
13614#include <stdlib.h>
13615#endif
13616#define FILE_ptr(fp)	$stdio_ptr
13617#define FILE_cnt(fp)	$stdio_cnt
13618#include <sys/types.h>
13619int main() {
13620	FILE *fp = fopen("try.c", "r");
13621	int c;
13622	char *ptr;
13623	size_t cnt;
13624	if (!fp) {
13625	    puts("Fail even to read");
13626	    exit(1);
13627	}
13628	c = getc(fp); /* Read away the first # */
13629	if (c == EOF) {
13630	    puts("Fail even to read");
13631	    exit(1);
13632	}
13633	if (!(
13634		18 <= FILE_cnt(fp) &&
13635		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
13636	)) {
13637		puts("Fail even to read");
13638		exit (1);
13639	}
13640	ptr = (char*) FILE_ptr(fp);
13641	cnt = (size_t)FILE_cnt(fp);
13642
13643	FILE_ptr(fp) += 42;
13644
13645	if ((char*)FILE_ptr(fp) != (ptr + 42)) {
13646		printf("Fail ptr check %p != %p", FILE_ptr(fp), (ptr + 42));
13647		exit (1);
13648	}
13649	if (FILE_cnt(fp) <= 20) {
13650		printf ("Fail (<20 chars to test)");
13651		exit (1);
13652	}
13653	if (strncmp(FILE_ptr(fp), "Eat dust sed :-) */\n", 20) != 0) {
13654		puts("Fail compare");
13655		exit (1);
13656	}
13657	if (cnt == FILE_cnt(fp)) {
13658		puts("Pass_unchanged");
13659		exit (0);
13660	}
13661	if (FILE_cnt(fp) == (cnt - 42)) {
13662		puts("Pass_changed");
13663		exit (0);
13664	}
13665	printf("Fail count was %d now %d\n", cnt, FILE_cnt(fp));
13666	return 1;
13667
13668}
13669EOP
13670	set try
13671	if eval $compile && $to try.c; then
13672		case `$run ./try` in
13673		Pass_changed)
13674			echo "Increasing ptr in your stdio decreases cnt by the same amount.  Good." >&4
13675			d_stdio_ptr_lval_sets_cnt="$define" ;;
13676		Pass_unchanged)
13677			echo "Increasing ptr in your stdio leaves cnt unchanged.  Good." >&4
13678			d_stdio_ptr_lval_nochange_cnt="$define" ;;
13679		Fail*)
13680			echo "Increasing ptr in your stdio didn't do exactly what I expected.  We'll not be doing that then." >&4 ;;
13681		*)
13682			echo "It appears attempting to set ptr in your stdio is a bad plan." >&4 ;;
13683	esac
13684	else
13685		echo "It seems we can't set ptr in your stdio.  Nevermind." >&4
13686	fi
13687	$rm_try
13688	;;
13689esac
13690
13691: see if _base is also standard
13692val="$undef"
13693case "$d_stdstdio" in
13694$define)
13695	$cat >try.c <<EOP
13696#include <stdio.h>
13697#$i_stdlib I_STDLIB
13698#ifdef I_STDLIB
13699#include <stdlib.h>
13700#endif
13701#define FILE_base(fp)	$stdio_base
13702#define FILE_bufsiz(fp)	$stdio_bufsiz
13703int main() {
13704	FILE *fp = fopen("try.c", "r");
13705	char c = getc(fp);
13706	if (
13707		19 <= FILE_bufsiz(fp) &&
13708		strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
13709	)
13710		exit(0);
13711	exit(1);
13712}
13713EOP
13714	set try
13715	if eval $compile && $to try.c; then
13716		if $run ./try; then
13717			echo "And its _base field acts std."
13718			val="$define"
13719		else
13720			echo "But its _base field isn't std."
13721		fi
13722	else
13723		echo "However, it seems to be lacking the _base field."
13724	fi
13725	$rm_try
13726	;;
13727esac
13728set d_stdiobase
13729eval $setvar
13730
13731: see if fast_stdio exists
13732val="$undef"
13733case "$d_stdstdio:$d_stdio_ptr_lval" in
13734"$define:$define")
13735	case "$d_stdio_cnt_lval$d_stdio_ptr_lval_sets_cnt" in
13736	*$define*)
13737		echo "You seem to have 'fast stdio' to directly manipulate the stdio buffers." >& 4
13738		val="$define"
13739		;;
13740	esac
13741	;;
13742esac
13743set d_faststdio
13744eval $setvar
13745
13746: see if fchdir exists
13747set fchdir d_fchdir
13748eval $inlibc
13749
13750: see if fchmod exists
13751set fchmod d_fchmod
13752eval $inlibc
13753
13754: check for openat, unlinkat, renameat, linkat, fchmodat
13755set openat d_openat
13756eval $inlibc
13757
13758set unlinkat d_unlinkat
13759eval $inlibc
13760
13761set renameat d_renameat
13762eval $inlibc
13763
13764set linkat d_linkat
13765eval $inlibc
13766
13767set fchmodat d_fchmodat
13768eval $inlibc
13769
13770: see if fchown exists
13771set fchown d_fchown
13772eval $inlibc
13773
13774: see if this is an fcntl system
13775set fcntl d_fcntl
13776eval $inlibc
13777
13778: See if fcntl-based locking works.
13779echo " "
13780$cat >try.c <<EOCP
13781#$i_stdlib I_STDLIB
13782#ifdef I_STDLIB
13783#include <stdlib.h>
13784#endif
13785#include <unistd.h>
13786#include <fcntl.h>
13787#include <signal.h>
13788$signal_t blech(int x) { exit(3); }
13789int main() {
13790#if defined(F_SETLK) && defined(F_SETLKW)
13791     struct flock flock;
13792     int retval, fd;
13793     fd = open("try.c", O_RDONLY);
13794     flock.l_type = F_RDLCK;
13795     flock.l_whence = SEEK_SET;
13796     flock.l_start = flock.l_len = 0;
13797     signal(SIGALRM, blech);
13798     alarm(10);
13799     retval = fcntl(fd, F_SETLK, &flock);
13800     close(fd);
13801     (retval < 0 ? exit(2) : exit(0));
13802#else
13803     exit(2);
13804#endif
13805}
13806EOCP
13807echo "Checking if fcntl-based file locking works... "
13808case "$d_fcntl" in
13809"$define")
13810	set try
13811	if eval $compile_ok; then
13812		if $run ./try; then
13813			echo "Yes, it seems to work."
13814			val="$define"
13815		else
13816			echo "Nope, it didn't work."
13817			val="$undef"
13818			case "$?" in
13819			3) $cat >&4 <<EOM
13820***
13821*** I had to forcibly timeout from fcntl(..., F_SETLK, ...).
13822*** This is (almost) impossible.
13823*** If your NFS lock daemons are not feeling well, something like
13824*** this may happen, please investigate.  Cannot continue, aborting.
13825***
13826EOM
13827				exit 1
13828				;;
13829			esac
13830		fi
13831	else
13832		echo "I'm unable to compile the test program, so I'll assume not."
13833		val="$undef"
13834	fi
13835	;;
13836*) val="$undef";
13837	echo "Nope, since you don't even have fcntl()."
13838	;;
13839esac
13840set d_fcntl_can_lock
13841eval $setvar
13842$rm_try
13843
13844: check for fd_set items
13845$cat <<EOM
13846
13847Checking to see how well your C compiler handles fd_set and friends ...
13848EOM
13849$cat >try.c <<EOCP
13850#$i_stdlib I_STDLIB
13851#ifdef I_STDLIB
13852#include <stdlib.h>
13853#endif
13854#$i_systime I_SYS_TIME
13855#$i_sysselct I_SYS_SELECT
13856#$d_socket HAS_SOCKET
13857#include <sys/types.h>
13858#ifdef HAS_SOCKET
13859#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
13860#endif
13861#ifdef I_SYS_TIME
13862#include <sys/time.h>
13863#endif
13864#ifdef I_SYS_SELECT
13865#include <sys/select.h>
13866#endif
13867int main() {
13868	fd_set fds;
13869
13870#ifdef TRYBITS
13871	if(fds.fds_bits);
13872#endif
13873
13874#if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
13875	exit(0);
13876#else
13877	exit(1);
13878#endif
13879}
13880EOCP
13881set try -DTRYBITS
13882if eval $compile; then
13883	d_fds_bits="$define"
13884	d_fd_set="$define"
13885	echo "Well, your system knows about the normal fd_set typedef..." >&4
13886	if $run ./try; then
13887		echo "and you have the normal fd_set macros (just as I'd expect)." >&4
13888		d_fd_macros="$define"
13889	else
13890		$cat >&4 <<'EOM'
13891but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
13892EOM
13893		d_fd_macros="$undef"
13894	fi
13895else
13896	$cat <<'EOM'
13897Hmm, your compiler has some difficulty with fd_set.  Checking further...
13898EOM
13899	set try
13900	if eval $compile; then
13901		d_fds_bits="$undef"
13902		d_fd_set="$define"
13903		echo "Well, your system has some sort of fd_set available..." >&4
13904		if $run ./try; then
13905			echo "and you have the normal fd_set macros." >&4
13906			d_fd_macros="$define"
13907		else
13908			$cat <<'EOM'
13909but not the normal fd_set macros!  Gross!  More work for me...
13910EOM
13911			d_fd_macros="$undef"
13912		fi
13913	else
13914	echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
13915		d_fd_set="$undef"
13916		d_fds_bits="$undef"
13917		d_fd_macros="$undef"
13918	fi
13919fi
13920$rm_try
13921
13922: see if fdclose exists
13923set fdclose d_fdclose
13924eval $inlibc
13925
13926: see if fdim exists
13927set fdim d_fdim
13928eval $inlibc
13929
13930: see if fegetround exists
13931set fegetround d_fegetround
13932eval $inlibc
13933
13934: see if fgetpos exists
13935set fgetpos d_fgetpos
13936eval $inlibc
13937
13938: see if finite exists
13939set finite d_finite
13940eval $inlibc
13941
13942: see if finitel exists
13943set finitel d_finitel
13944eval $inlibc
13945
13946: see if flock exists
13947set flock d_flock
13948eval $inlibc
13949
13950: see if prototype for flock is available
13951echo " "
13952set d_flockproto flock $i_sysfile sys/file.h
13953eval $hasproto
13954
13955: see if fma exists
13956set fma d_fma
13957eval $inlibc
13958
13959: see if fmax exists
13960set fmax d_fmax
13961eval $inlibc
13962
13963: see if fmin exists
13964set fmin d_fmin
13965eval $inlibc
13966
13967: see if fp_class exists
13968set fp_class d_fp_class
13969eval $inlibc
13970
13971: check for fpclassify
13972echo "Checking to see if you have fpclassify..." >&4
13973$cat >try.c <<EOCP
13974#include <math.h>
13975int main() { return fpclassify(1.0) == FP_NORMAL ? 0 : 1; }
13976EOCP
13977set try
13978if eval $compile; then
13979	val="$define"
13980	echo "You have fpclassify."
13981else
13982	val="$undef"
13983	echo "You do not have fpclassify."
13984fi
13985$rm_try
13986set d_fpclassify
13987eval $setvar
13988
13989: see if fp_classify exists
13990set fp_classify d_fp_classify
13991eval $inlibc
13992
13993: see if fp_classl exists
13994set fp_classl d_fp_classl
13995eval $inlibc
13996
13997: see if pathconf exists
13998set pathconf d_pathconf
13999eval $inlibc
14000
14001: see if fpathconf exists
14002set fpathconf d_fpathconf
14003eval $inlibc
14004
14005: see if fpclass exists
14006set fpclass d_fpclass
14007eval $inlibc
14008
14009: see if fpclassl exists
14010set fpclassl d_fpclassl
14011eval $inlibc
14012
14013: see if fpgetround exists
14014set fpgetround d_fpgetround
14015eval $inlibc
14016
14017: check for fpos64_t
14018echo " "
14019echo "Checking to see if you have fpos64_t..." >&4
14020$cat >try.c <<EOCP
14021#include <stdio.h>
14022int main() { fpos64_t x = 7; }
14023EOCP
14024set try
14025if eval $compile; then
14026	val="$define"
14027	echo "You have fpos64_t."
14028else
14029	val="$undef"
14030	echo "You do not have fpos64_t."
14031	case "$fpossize" in
14032	8) echo "(Your fpos_t is 64 bits, so you could use that.)" ;;
14033	esac
14034fi
14035$rm_try
14036set d_fpos64_t
14037eval $setvar
14038
14039: see if frexpl exists
14040set frexpl d_frexpl
14041eval $inlibc
14042
14043: see if this is a sys/param system
14044set sys/param.h i_sysparam
14045eval $inhdr
14046
14047: see if this is a sys/mount.h system
14048set sys/mount.h i_sysmount
14049eval $inhdr
14050
14051: Check for fs_data_s
14052echo " "
14053echo "Checking to see if your system supports struct fs_data..." >&4
14054set d_fs_data_s fs_data $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h
14055eval $hasstruct
14056case "$d_fs_data_s" in
14057"$define")      echo "Yes, it does."   ;;
14058*)              echo "No, it doesn't." ;;
14059esac
14060
14061: see if fseeko exists
14062set fseeko d_fseeko
14063eval $inlibc
14064case "$longsize" in
140658) echo "(Your long is 64 bits, so you could use fseek.)" ;;
14066esac
14067
14068: see if fsetpos exists
14069set fsetpos d_fsetpos
14070eval $inlibc
14071
14072: see if fstatfs exists
14073set fstatfs d_fstatfs
14074eval $inlibc
14075
14076: see if statvfs exists
14077set statvfs d_statvfs
14078eval $inlibc
14079
14080: see if fstatvfs exists
14081set fstatvfs d_fstatvfs
14082eval $inlibc
14083
14084: see if fsync exists
14085set fsync d_fsync
14086eval $inlibc
14087
14088: see if ftello exists
14089set ftello d_ftello
14090eval $inlibc
14091case "$longsize" in
140928) echo "(Your long is 64 bits, so you could use ftell.)" ;;
14093esac
14094
14095: check for a working futimes
14096d_futimes="$undef"
14097echo " "
14098echo "Checking if you have a working futimes()" >&4
14099$cat >try.c <<EOCP
14100#include <stdio.h>
14101#include <sys/time.h>
14102#include <errno.h>
14103#include <fcntl.h>
14104
14105int main ()
14106{
14107    int fd, rv;
14108    fd = open ("try.c", O_RDWR);
14109    if (-1 == fd) exit (1);
14110    rv = futimes (fd, NULL);
14111    exit (rv == -1 ? errno : 0);
14112}
14113EOCP
14114set try
14115if eval $compile; then
14116    `$run ./try`
14117    rc=$?
14118    case "$rc" in
14119	0)  echo "Yes, you have" >&4
14120	    d_futimes="$define"
14121	    ;;
14122	*)  echo "No, you have futimes, but it isn't working ($rc) (probably harmless)" >&4
14123	    ;;
14124    esac
14125else
14126    echo "No, it does not (probably harmless)" >&4
14127fi
14128$rm_try
14129
14130: look for gai_strerror
14131echo " "
14132$cat >try.c <<'EOCP'
14133#include <sys/types.h>
14134#include <sys/socket.h>
14135#include <netdb.h>
14136int main ()
14137{
14138    return (gai_strerror (0) ? 0 : 1);
14139    }
14140EOCP
14141set try
14142val="$undef"
14143if eval $compile; then
14144    `$run ./try`
14145    case "$?" in
14146	0)  echo "A working gai_strerror() found." >&4
14147	    val="$define" ;;
14148	*)  echo "gai_strerror() found, but it doesn't work" >&4
14149	    ;;
14150	esac
14151else
14152    echo "gai_strerror() NOT found." >&4
14153    fi
14154set d_gai_strerror
14155eval $setvar
14156$rm_try
14157
14158: see if ndbm.h is available
14159set ndbm.h i_ndbm
14160eval $inhdr
14161: Compatibility location for RedHat 7.1
14162set gdbm/ndbm.h i_gdbmndbm
14163eval $inhdr
14164: Compatibility location for Debian 4.0
14165set gdbm-ndbm.h i_gdbm_ndbm
14166eval $inhdr
14167
14168val="$undef"
14169if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then
14170	: see if dbm_open exists
14171	set dbm_open d_dbm_open
14172	eval $inlibc
14173	case "$d_dbm_open" in
14174	$undef)
14175		i_ndbm="$undef"
14176		i_gdbmndbm="$undef"
14177		i_gdbm_ndbm="$undef"
14178		echo "We won't be including <ndbm.h>"
14179		val="$undef"
14180		;;
14181	*) val="$define"
14182	   ;;
14183	esac
14184fi
14185set d_ndbm
14186eval $setvar
14187
14188ndbm_hdr_protochk='name=$1; hdr=$2;
14189eval "ihdr=\$""i_$name";
14190val="$undef";
14191if $test "$ihdr" = "$define"; then
14192	$echo "Checking if your <$hdr> uses prototypes..." >&4;
14193	case "$d_cplusplus" in
14194	$define) ./protochk "$extern_C void dbm_close(DBM *);" literal "extern \"C\" {" $ihdr $hdr literal "}" && val="$define" ;;
14195	*) ./protochk "$extern_C void dbm_close(int, int);" $ihdr $hdr || val="$define" ;;
14196	esac;
14197	case "$val" in
14198	$define) $echo "Your <$hdr> seems to have prototypes";;
14199	*) $echo "Your <$hdr> does not seem to have prototypes";;
14200	esac;
14201fi;
14202set "d_${name}_h_uses_prototypes";
14203eval $setvar'
14204
14205set ndbm ndbm.h
14206eval $ndbm_hdr_protochk
14207set gdbmndbm gdbm/ndbm.h
14208eval $ndbm_hdr_protochk
14209set gdbm_ndbm gdbm-ndbm.h
14210eval $ndbm_hdr_protochk
14211
14212: see if getaddrinfo exists
14213set getaddrinfo d_getaddrinfo
14214eval $inlibc
14215
14216: see if getcwd exists
14217set getcwd d_getcwd
14218eval $inlibc
14219
14220: see if getespwnam exists
14221set getespwnam d_getespwnam
14222eval $inlibc
14223
14224: see if getfsstat exists
14225set getfsstat d_getfsstat
14226eval $inlibc
14227
14228: see if getgrent exists
14229set getgrent d_getgrent
14230eval $inlibc
14231
14232: see if getgrent_r exists
14233set getgrent_r d_getgrent_r
14234eval $inlibc
14235case "$d_getgrent_r" in
14236"$define")
14237	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
14238	case "$d_getgrent_r_proto:$usethreads" in
14239	":define")	d_getgrent_r_proto=define
14240		set d_getgrent_r_proto getgrent_r $hdrs
14241		eval $hasproto ;;
14242	*)	;;
14243	esac
14244	case "$d_getgrent_r_proto" in
14245	define)
14246	case "$getgrent_r_proto" in
14247	''|0) try='int getgrent_r(struct group*, char*, size_t, struct group**);'
14248	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBWR ;;
14249	esac
14250	case "$getgrent_r_proto" in
14251	''|0) try='int getgrent_r(struct group*, char*, int, struct group**);'
14252	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIR ;;
14253	esac
14254	case "$getgrent_r_proto" in
14255	''|0) try='struct group* getgrent_r(struct group*, char*, size_t);'
14256	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBW ;;
14257	esac
14258	case "$getgrent_r_proto" in
14259	''|0) try='struct group* getgrent_r(struct group*, char*, int);'
14260	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBI ;;
14261	esac
14262	case "$getgrent_r_proto" in
14263	''|0) try='int getgrent_r(struct group*, char*, int);'
14264	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBI ;;
14265	esac
14266	case "$getgrent_r_proto" in
14267	''|0) try='int getgrent_r(struct group*, char*, int, FILE**);'
14268	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIH ;;
14269	esac
14270	case "$getgrent_r_proto" in
14271	''|0)	d_getgrent_r=undef
14272		getgrent_r_proto=0
14273		echo "Disabling getgrent_r, cannot determine prototype." >&4 ;;
14274	* )	case "$getgrent_r_proto" in
14275		REENTRANT_PROTO*) ;;
14276		*) getgrent_r_proto="REENTRANT_PROTO_$getgrent_r_proto" ;;
14277		esac
14278		echo "Prototype: $try" ;;
14279	esac
14280	;;
14281	*)	case "$usethreads" in
14282		define) echo "getgrent_r has no prototype, not using it." >&4 ;;
14283		esac
14284		d_getgrent_r=undef
14285		getgrent_r_proto=0
14286		;;
14287	esac
14288	;;
14289*)	getgrent_r_proto=0
14290	;;
14291esac
14292
14293: see if getgrgid_r exists
14294set getgrgid_r d_getgrgid_r
14295eval $inlibc
14296case "$d_getgrgid_r" in
14297"$define")
14298	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
14299	case "$d_getgrgid_r_proto:$usethreads" in
14300	":define")	d_getgrgid_r_proto=define
14301		set d_getgrgid_r_proto getgrgid_r $hdrs
14302		eval $hasproto ;;
14303	*)	;;
14304	esac
14305	case "$d_getgrgid_r_proto" in
14306	define)
14307	case "$getgrgid_r_proto" in
14308	''|0) try='int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**);'
14309	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
14310	esac
14311	case "$getgrgid_r_proto" in
14312	''|0) try='int getgrgid_r(gid_t, struct group*, char*, int, struct group**);'
14313	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
14314	esac
14315	case "$getgrgid_r_proto" in
14316	''|0) try='int getgrgid_r(gid_t, struct group*, char*, int);'
14317	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
14318	esac
14319	case "$getgrgid_r_proto" in
14320	''|0) try='struct group* getgrgid_r(gid_t, struct group*, char*, int);'
14321	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
14322	esac
14323	case "$getgrgid_r_proto" in
14324	''|0)	d_getgrgid_r=undef
14325		getgrgid_r_proto=0
14326		echo "Disabling getgrgid_r, cannot determine prototype." >&4 ;;
14327	* )	case "$getgrgid_r_proto" in
14328		REENTRANT_PROTO*) ;;
14329		*) getgrgid_r_proto="REENTRANT_PROTO_$getgrgid_r_proto" ;;
14330		esac
14331		echo "Prototype: $try" ;;
14332	esac
14333	;;
14334	*)	case "$usethreads" in
14335		define) echo "getgrgid_r has no prototype, not using it." >&4 ;;
14336		esac
14337		d_getgrgid_r=undef
14338		getgrgid_r_proto=0
14339		;;
14340	esac
14341	;;
14342*)	getgrgid_r_proto=0
14343	;;
14344esac
14345
14346: see if getgrnam_r exists
14347set getgrnam_r d_getgrnam_r
14348eval $inlibc
14349case "$d_getgrnam_r" in
14350"$define")
14351	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
14352	case "$d_getgrnam_r_proto:$usethreads" in
14353	":define")	d_getgrnam_r_proto=define
14354		set d_getgrnam_r_proto getgrnam_r $hdrs
14355		eval $hasproto ;;
14356	*)	;;
14357	esac
14358	case "$d_getgrnam_r_proto" in
14359	define)
14360	case "$getgrnam_r_proto" in
14361	''|0) try='int getgrnam_r(const char*, struct group*, char*, size_t, struct group**);'
14362	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
14363	esac
14364	case "$getgrnam_r_proto" in
14365	''|0) try='int getgrnam_r(const char*, struct group*, char*, int, struct group**);'
14366	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
14367	esac
14368	case "$getgrnam_r_proto" in
14369	''|0) try='struct group* getgrnam_r(const char*, char*, int);'
14370	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CBI ;;
14371	esac
14372	case "$getgrnam_r_proto" in
14373	''|0) try='int getgrnam_r(const char*, struct group*, char*, int);'
14374	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
14375	esac
14376	case "$getgrnam_r_proto" in
14377	''|0) try='struct group* getgrnam_r(const char*, struct group*, char*, int);'
14378	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
14379	esac
14380	case "$getgrnam_r_proto" in
14381	''|0)	d_getgrnam_r=undef
14382		getgrnam_r_proto=0
14383		echo "Disabling getgrnam_r, cannot determine prototype." >&4 ;;
14384	* )	case "$getgrnam_r_proto" in
14385		REENTRANT_PROTO*) ;;
14386		*) getgrnam_r_proto="REENTRANT_PROTO_$getgrnam_r_proto" ;;
14387		esac
14388		echo "Prototype: $try" ;;
14389	esac
14390	;;
14391	*)	case "$usethreads" in
14392		define) echo "getgrnam_r has no prototype, not using it." >&4 ;;
14393		esac
14394		d_getgrnam_r=undef
14395		getgrnam_r_proto=0
14396		;;
14397	esac
14398	;;
14399*)	getgrnam_r_proto=0
14400	;;
14401esac
14402
14403: see if gethostbyaddr exists
14404set gethostbyaddr d_gethbyaddr
14405eval $inlibc
14406
14407: see if gethostbyname exists
14408set gethostbyname d_gethbyname
14409eval $inlibc
14410
14411: see if gethostent exists
14412set gethostent d_gethent
14413eval $inlibc
14414
14415: see how we will look up host name
14416echo " "
14417call=''
14418if set gethostname val -f d_gethname; eval $csym; $val; then
14419	echo 'gethostname() found.' >&4
14420	d_gethname="$define"
14421	call=gethostname
14422fi
14423if set uname val -f d_uname; eval $csym; $val; then
14424	if ./xenix; then
14425		$cat <<'EOM'
14426uname() was found, but you're running xenix, and older versions of xenix
14427have a broken uname(). If you don't really know whether your xenix is old
14428enough to have a broken system call, use the default answer.
14429
14430EOM
14431		dflt=y
14432		case "$d_uname" in
14433		"$define") dflt=n;;
14434		esac
14435		rp='Is your uname() broken?'
14436		. ./myread
14437		case "$ans" in
14438		n*) d_uname="$define"; call=uname;;
14439		esac
14440	else
14441		echo 'uname() found.' >&4
14442		d_uname="$define"
14443		case "$call" in
14444		'') call=uname ;;
14445		esac
14446	fi
14447fi
14448case "$d_gethname" in
14449'') d_gethname="$undef";;
14450esac
14451case "$d_uname" in
14452'') d_uname="$undef";;
14453esac
14454case "$d_uname$d_gethname" in
14455*define*)
14456	dflt=n
14457	cat <<EOM
14458
14459Every now and then someone has a $call() that lies about the hostname
14460but can't be fixed for political or economic reasons.  If you wish, I can
14461pretend $call() isn't there and maybe compute hostname at run-time
14462thanks to the '$phostname' command.
14463
14464EOM
14465	rp="Shall I ignore $call() from now on?"
14466	. ./myread
14467	case "$ans" in
14468	y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
14469	esac;;
14470esac
14471case "$phostname" in
14472'') aphostname='';;
14473*) case "$aphostname" in
14474	/*) ;;
14475	*) set X $phostname
14476		shift
14477		file=$1
14478		shift
14479		file=`./loc $file $file $pth`
14480		aphostname=`echo $file $*`
14481		;;
14482	esac
14483	;;
14484esac
14485case "$d_uname$d_gethname" in
14486*define*) ;;
14487*)
14488	case "$phostname" in
14489	'')
14490		echo "There will be no way for $package to get your hostname." >&4;;
14491	*)
14492	echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
14493		;;
14494	esac;;
14495esac
14496case "$d_phostname" in
14497'') d_phostname="$undef";;
14498esac
14499
14500: see if gethostbyaddr_r exists
14501set gethostbyaddr_r d_gethostbyaddr_r
14502eval $inlibc
14503case "$d_gethostbyaddr_r" in
14504"$define")
14505	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14506	case "$d_gethostbyaddr_r_proto:$usethreads" in
14507	":define")	d_gethostbyaddr_r_proto=define
14508		set d_gethostbyaddr_r_proto gethostbyaddr_r $hdrs
14509		eval $hasproto ;;
14510	*)	;;
14511	esac
14512	case "$d_gethostbyaddr_r_proto" in
14513	define)
14514	case "$gethostbyaddr_r_proto" in
14515	''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
14516	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
14517	esac
14518	case "$gethostbyaddr_r_proto" in
14519	''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, int, int*);'
14520	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
14521	esac
14522	case "$gethostbyaddr_r_proto" in
14523	''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, int, int*);'
14524	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
14525	esac
14526	case "$gethostbyaddr_r_proto" in
14527	''|0) try='struct hostent* gethostbyaddr_r(const void*, size_t, int, struct hostent*, char*, int, int*);'
14528	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
14529	esac
14530	case "$gethostbyaddr_r_proto" in
14531	''|0) try='struct hostent* gethostbyaddr_r(const char*, int, int, struct hostent*, char*, int, int*);'
14532	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
14533	esac
14534	case "$gethostbyaddr_r_proto" in
14535	''|0) try='struct hostent* gethostbyaddr_r(const char*, struct hostent*, char*, int, int*);'
14536	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
14537	esac
14538	case "$gethostbyaddr_r_proto" in
14539	''|0) try='struct hostent* gethostbyaddr_r(const void*, struct hostent*, char*, int, int*);'
14540	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
14541	esac
14542	case "$gethostbyaddr_r_proto" in
14543	''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, struct hostent_data*);'
14544	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
14545	esac
14546	case "$gethostbyaddr_r_proto" in
14547	''|0) try='int gethostbyaddr_r(const char*, int, int, struct hostent*, struct hostent_data*);'
14548	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
14549	esac
14550	case "$gethostbyaddr_r_proto" in
14551	''|0) try='int gethostbyaddr_r(const char*, int, int);'
14552	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
14553	esac
14554	case "$gethostbyaddr_r_proto" in
14555	''|0) try='int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
14556	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
14557	esac
14558	case "$gethostbyaddr_r_proto" in
14559	''|0)	d_gethostbyaddr_r=undef
14560		gethostbyaddr_r_proto=0
14561		echo "Disabling gethostbyaddr_r, cannot determine prototype." >&4 ;;
14562	* )	case "$gethostbyaddr_r_proto" in
14563		REENTRANT_PROTO*) ;;
14564		*) gethostbyaddr_r_proto="REENTRANT_PROTO_$gethostbyaddr_r_proto" ;;
14565		esac
14566		echo "Prototype: $try" ;;
14567	esac
14568	;;
14569	*)	case "$usethreads" in
14570		define) echo "gethostbyaddr_r has no prototype, not using it." >&4 ;;
14571		esac
14572		d_gethostbyaddr_r=undef
14573		gethostbyaddr_r_proto=0
14574		;;
14575	esac
14576	;;
14577*)	gethostbyaddr_r_proto=0
14578	;;
14579esac
14580
14581: see if gethostbyname_r exists
14582set gethostbyname_r d_gethostbyname_r
14583eval $inlibc
14584case "$d_gethostbyname_r" in
14585"$define")
14586	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14587	case "$d_gethostbyname_r_proto:$usethreads" in
14588	":define")	d_gethostbyname_r_proto=define
14589		set d_gethostbyname_r_proto gethostbyname_r $hdrs
14590		eval $hasproto ;;
14591	*)	;;
14592	esac
14593	case "$d_gethostbyname_r_proto" in
14594	define)
14595	case "$gethostbyname_r_proto" in
14596	''|0) try='int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);'
14597	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
14598	esac
14599	case "$gethostbyname_r_proto" in
14600	''|0) try='struct hostent* gethostbyname_r(const char*, struct hostent*, char*, int, int*);'
14601	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
14602	esac
14603	case "$gethostbyname_r_proto" in
14604	''|0) try='int gethostbyname_r(const char*, struct hostent*, struct hostent_data*);'
14605	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
14606	esac
14607	case "$gethostbyname_r_proto" in
14608	''|0)	d_gethostbyname_r=undef
14609		gethostbyname_r_proto=0
14610		echo "Disabling gethostbyname_r, cannot determine prototype." >&4 ;;
14611	* )	case "$gethostbyname_r_proto" in
14612		REENTRANT_PROTO*) ;;
14613		*) gethostbyname_r_proto="REENTRANT_PROTO_$gethostbyname_r_proto" ;;
14614		esac
14615		echo "Prototype: $try" ;;
14616	esac
14617	;;
14618	*)	case "$usethreads" in
14619		define) echo "gethostbyname_r has no prototype, not using it." >&4 ;;
14620		esac
14621		d_gethostbyname_r=undef
14622		gethostbyname_r_proto=0
14623		;;
14624	esac
14625	;;
14626*)	gethostbyname_r_proto=0
14627	;;
14628esac
14629
14630: see if gethostent_r exists
14631set gethostent_r d_gethostent_r
14632eval $inlibc
14633case "$d_gethostent_r" in
14634"$define")
14635	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14636	case "$d_gethostent_r_proto:$usethreads" in
14637	":define")	d_gethostent_r_proto=define
14638		set d_gethostent_r_proto gethostent_r $hdrs
14639		eval $hasproto ;;
14640	*)	;;
14641	esac
14642	case "$d_gethostent_r_proto" in
14643	define)
14644	case "$gethostent_r_proto" in
14645	''|0) try='int gethostent_r(struct hostent*, char*, size_t, struct hostent**, int*);'
14646	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
14647	esac
14648	case "$gethostent_r_proto" in
14649	''|0) try='int gethostent_r(struct hostent*, char*, int, int*);'
14650	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBIE ;;
14651	esac
14652	case "$gethostent_r_proto" in
14653	''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int, int*);'
14654	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBIE ;;
14655	esac
14656	case "$gethostent_r_proto" in
14657	''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int);'
14658	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBI ;;
14659	esac
14660	case "$gethostent_r_proto" in
14661	''|0) try='int gethostent_r(struct hostent*, char*, int);'
14662	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBI ;;
14663	esac
14664	case "$gethostent_r_proto" in
14665	''|0) try='int gethostent_r(struct hostent*, struct hostent_data*);'
14666	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SD ;;
14667	esac
14668	case "$gethostent_r_proto" in
14669	''|0)	d_gethostent_r=undef
14670		gethostent_r_proto=0
14671		echo "Disabling gethostent_r, cannot determine prototype." >&4 ;;
14672	* )	case "$gethostent_r_proto" in
14673		REENTRANT_PROTO*) ;;
14674		*) gethostent_r_proto="REENTRANT_PROTO_$gethostent_r_proto" ;;
14675		esac
14676		echo "Prototype: $try" ;;
14677	esac
14678	;;
14679	*)	case "$usethreads" in
14680		define) echo "gethostent_r has no prototype, not using it." >&4 ;;
14681		esac
14682		d_gethostent_r=undef
14683		gethostent_r_proto=0
14684		;;
14685	esac
14686	;;
14687*)	gethostent_r_proto=0
14688	;;
14689esac
14690
14691: see if prototypes for various gethostxxx netdb.h functions are available
14692echo " "
14693set d_gethostprotos gethostent $i_netdb netdb.h
14694eval $hasproto
14695
14696: see if getitimer exists
14697set getitimer d_getitimer
14698eval $inlibc
14699
14700: see if getlogin exists
14701set getlogin d_getlogin
14702eval $inlibc
14703
14704: see if getlogin_r exists
14705set getlogin_r d_getlogin_r
14706eval $inlibc
14707case "$d_getlogin_r" in
14708"$define")
14709	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
14710	case "$d_getlogin_r_proto:$usethreads" in
14711	":define")	d_getlogin_r_proto=define
14712		set d_getlogin_r_proto getlogin_r $hdrs
14713		eval $hasproto ;;
14714	*)	;;
14715	esac
14716	case "$d_getlogin_r_proto" in
14717	define)
14718	case "$getlogin_r_proto" in
14719	''|0) try='int getlogin_r(char*, size_t);'
14720	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BW ;;
14721	esac
14722	case "$getlogin_r_proto" in
14723	''|0) try='int getlogin_r(char*, int);'
14724	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BI ;;
14725	esac
14726	case "$getlogin_r_proto" in
14727	''|0) try='char* getlogin_r(char*, size_t);'
14728	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BW ;;
14729	esac
14730	case "$getlogin_r_proto" in
14731	''|0) try='char* getlogin_r(char*, int);'
14732	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BI ;;
14733	esac
14734	case "$getlogin_r_proto" in
14735	''|0)	d_getlogin_r=undef
14736		getlogin_r_proto=0
14737		echo "Disabling getlogin_r, cannot determine prototype." >&4 ;;
14738	* )	case "$getlogin_r_proto" in
14739		REENTRANT_PROTO*) ;;
14740		*) getlogin_r_proto="REENTRANT_PROTO_$getlogin_r_proto" ;;
14741		esac
14742		echo "Prototype: $try" ;;
14743	esac
14744	;;
14745	*)	case "$usethreads" in
14746		define) echo "getlogin_r has no prototype, not using it." >&4 ;;
14747		esac
14748		d_getlogin_r=undef
14749		getlogin_r_proto=0
14750		;;
14751	esac
14752	;;
14753*)	getlogin_r_proto=0
14754	;;
14755esac
14756
14757: see if getmnt exists
14758set getmnt d_getmnt
14759eval $inlibc
14760
14761: see if getmntent exists
14762set getmntent d_getmntent
14763eval $inlibc
14764
14765: see if getnameinfo exists
14766set getnameinfo d_getnameinfo
14767eval $inlibc
14768
14769: see if getnetbyaddr exists
14770set getnetbyaddr d_getnbyaddr
14771eval $inlibc
14772
14773: see if getnetbyname exists
14774set getnetbyname d_getnbyname
14775eval $inlibc
14776
14777: see if getnetent exists
14778set getnetent d_getnent
14779eval $inlibc
14780
14781: see if getnetbyaddr_r exists
14782set getnetbyaddr_r d_getnetbyaddr_r
14783eval $inlibc
14784case "$d_getnetbyaddr_r" in
14785"$define")
14786	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14787	case "$d_getnetbyaddr_r_proto:$usethreads" in
14788	":define")	d_getnetbyaddr_r_proto=define
14789		set d_getnetbyaddr_r_proto getnetbyaddr_r $hdrs
14790		eval $hasproto ;;
14791	*)	;;
14792	esac
14793	case "$d_getnetbyaddr_r_proto" in
14794	define)
14795	case "$getnetbyaddr_r_proto" in
14796	''|0) try='int getnetbyaddr_r(unsigned long, int, struct netent*, char*, size_t, struct netent**, int*);'
14797	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
14798	esac
14799	case "$getnetbyaddr_r_proto" in
14800	''|0) try='int getnetbyaddr_r(long, int, struct netent*, char*, int);'
14801	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
14802	esac
14803	case "$getnetbyaddr_r_proto" in
14804	''|0) try='struct netent* getnetbyaddr_r(in_addr_t, int, struct netent*, char*, int);'
14805	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
14806	esac
14807	case "$getnetbyaddr_r_proto" in
14808	''|0) try='struct netent* getnetbyaddr_r(long, int, struct netent*, char*, int);'
14809	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
14810	esac
14811	case "$getnetbyaddr_r_proto" in
14812	''|0) try='int getnetbyaddr_r(in_addr_t, int, struct netent*, struct netent_data*);'
14813	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
14814	esac
14815	case "$getnetbyaddr_r_proto" in
14816	''|0) try='int getnetbyaddr_r(long, int, struct netent*, struct netent_data*);'
14817	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
14818	esac
14819	case "$getnetbyaddr_r_proto" in
14820	''|0) try='int getnetbyaddr_r(int, int, struct netent*, struct netent_data*);'
14821	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
14822	esac
14823	case "$getnetbyaddr_r_proto" in
14824	''|0) try='int getnetbyaddr_r(uint32_t, int, struct netent*, char*, size_t, struct netent**, int*);'
14825	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
14826	esac
14827	case "$getnetbyaddr_r_proto" in
14828	''|0)	d_getnetbyaddr_r=undef
14829		getnetbyaddr_r_proto=0
14830		echo "Disabling getnetbyaddr_r, cannot determine prototype." >&4 ;;
14831	* )	case "$getnetbyaddr_r_proto" in
14832		REENTRANT_PROTO*) ;;
14833		*) getnetbyaddr_r_proto="REENTRANT_PROTO_$getnetbyaddr_r_proto" ;;
14834		esac
14835		echo "Prototype: $try" ;;
14836	esac
14837	;;
14838	*)	case "$usethreads" in
14839		define) echo "getnetbyaddr_r has no prototype, not using it." >&4 ;;
14840		esac
14841		d_getnetbyaddr_r=undef
14842		getnetbyaddr_r_proto=0
14843		;;
14844	esac
14845	;;
14846*)	getnetbyaddr_r_proto=0
14847	;;
14848esac
14849
14850: see if getnetbyname_r exists
14851set getnetbyname_r d_getnetbyname_r
14852eval $inlibc
14853case "$d_getnetbyname_r" in
14854"$define")
14855	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14856	case "$d_getnetbyname_r_proto:$usethreads" in
14857	":define")	d_getnetbyname_r_proto=define
14858		set d_getnetbyname_r_proto getnetbyname_r $hdrs
14859		eval $hasproto ;;
14860	*)	;;
14861	esac
14862	case "$d_getnetbyname_r_proto" in
14863	define)
14864	case "$getnetbyname_r_proto" in
14865	''|0) try='int getnetbyname_r(const char*, struct netent*, char*, size_t, struct netent**, int*);'
14866	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
14867	esac
14868	case "$getnetbyname_r_proto" in
14869	''|0) try='int getnetbyname_r(const char*, struct netent*, char*, int);'
14870	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
14871	esac
14872	case "$getnetbyname_r_proto" in
14873	''|0) try='struct netent* getnetbyname_r(const char*, struct netent*, char*, int);'
14874	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
14875	esac
14876	case "$getnetbyname_r_proto" in
14877	''|0) try='int getnetbyname_r(const char*, struct netent*, struct netent_data*);'
14878	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
14879	esac
14880	case "$getnetbyname_r_proto" in
14881	''|0)	d_getnetbyname_r=undef
14882		getnetbyname_r_proto=0
14883		echo "Disabling getnetbyname_r, cannot determine prototype." >&4 ;;
14884	* )	case "$getnetbyname_r_proto" in
14885		REENTRANT_PROTO*) ;;
14886		*) getnetbyname_r_proto="REENTRANT_PROTO_$getnetbyname_r_proto" ;;
14887		esac
14888		echo "Prototype: $try" ;;
14889	esac
14890	;;
14891	*)	case "$usethreads" in
14892		define) echo "getnetbyname_r has no prototype, not using it." >&4 ;;
14893		esac
14894		d_getnetbyname_r=undef
14895		getnetbyname_r_proto=0
14896		;;
14897	esac
14898	;;
14899*)	getnetbyname_r_proto=0
14900	;;
14901esac
14902
14903: see if getnetent_r exists
14904set getnetent_r d_getnetent_r
14905eval $inlibc
14906case "$d_getnetent_r" in
14907"$define")
14908	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14909	case "$d_getnetent_r_proto:$usethreads" in
14910	":define")	d_getnetent_r_proto=define
14911		set d_getnetent_r_proto getnetent_r $hdrs
14912		eval $hasproto ;;
14913	*)	;;
14914	esac
14915	case "$d_getnetent_r_proto" in
14916	define)
14917	case "$getnetent_r_proto" in
14918	''|0) try='int getnetent_r(struct netent*, char*, size_t, struct netent**, int*);'
14919	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
14920	esac
14921	case "$getnetent_r_proto" in
14922	''|0) try='int getnetent_r(struct netent*, char*, int, int*);'
14923	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBIE ;;
14924	esac
14925	case "$getnetent_r_proto" in
14926	''|0) try='struct netent* getnetent_r(struct netent*, char*, int, int*);'
14927	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBIE ;;
14928	esac
14929	case "$getnetent_r_proto" in
14930	''|0) try='struct netent* getnetent_r(struct netent*, char*, int);'
14931	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBI ;;
14932	esac
14933	case "$getnetent_r_proto" in
14934	''|0) try='int getnetent_r(struct netent*, char*, int);'
14935	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBI ;;
14936	esac
14937	case "$getnetent_r_proto" in
14938	''|0) try='int getnetent_r(struct netent*, struct netent_data*);'
14939	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SD ;;
14940	esac
14941	case "$getnetent_r_proto" in
14942	''|0)	d_getnetent_r=undef
14943		getnetent_r_proto=0
14944		echo "Disabling getnetent_r, cannot determine prototype." >&4 ;;
14945	* )	case "$getnetent_r_proto" in
14946		REENTRANT_PROTO*) ;;
14947		*) getnetent_r_proto="REENTRANT_PROTO_$getnetent_r_proto" ;;
14948		esac
14949		echo "Prototype: $try" ;;
14950	esac
14951	;;
14952	*)	case "$usethreads" in
14953		define) echo "getnetent_r has no prototype, not using it." >&4 ;;
14954		esac
14955		d_getnetent_r=undef
14956		getnetent_r_proto=0
14957		;;
14958	esac
14959	;;
14960*)	getnetent_r_proto=0
14961	;;
14962esac
14963
14964: see if prototypes for various getnetxxx netdb.h functions are available
14965echo " "
14966set d_getnetprotos getnetent $i_netdb netdb.h
14967eval $hasproto
14968
14969: see if getpagesize exists
14970set getpagesize d_getpagsz
14971eval $inlibc
14972
14973: Optional checks for getprotobyname and getprotobynumber
14974
14975: see if getprotobyname exists
14976set getprotobyname d_getpbyname
14977eval $inlibc
14978
14979: see if getprotobynumber exists
14980set getprotobynumber d_getpbynumber
14981eval $inlibc
14982
14983: see if getprotoent exists
14984set getprotoent d_getpent
14985eval $inlibc
14986
14987: see if getpgid exists
14988set getpgid d_getpgid
14989eval $inlibc
14990
14991: see if getpgrp2 exists
14992set getpgrp2 d_getpgrp2
14993eval $inlibc
14994
14995: see if getppid exists
14996set getppid d_getppid
14997eval $inlibc
14998
14999: see if getpriority exists
15000set getpriority d_getprior
15001eval $inlibc
15002
15003: see if getprotobyname_r exists
15004set getprotobyname_r d_getprotobyname_r
15005eval $inlibc
15006case "$d_getprotobyname_r" in
15007"$define")
15008	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15009	case "$d_getprotobyname_r_proto:$usethreads" in
15010	":define")	d_getprotobyname_r_proto=define
15011		set d_getprotobyname_r_proto getprotobyname_r $hdrs
15012		eval $hasproto ;;
15013	*)	;;
15014	esac
15015	case "$d_getprotobyname_r_proto" in
15016	define)
15017	case "$getprotobyname_r_proto" in
15018	''|0) try='int getprotobyname_r(const char*, struct protoent*, char*, size_t, struct protoent**);'
15019	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
15020	esac
15021	case "$getprotobyname_r_proto" in
15022	''|0) try='struct protoent* getprotobyname_r(const char*, struct protoent*, char*, int);'
15023	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
15024	esac
15025	case "$getprotobyname_r_proto" in
15026	''|0) try='int getprotobyname_r(const char*, struct protoent*, struct protoent_data*);'
15027	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
15028	esac
15029	case "$getprotobyname_r_proto" in
15030	''|0)	d_getprotobyname_r=undef
15031		getprotobyname_r_proto=0
15032		echo "Disabling getprotobyname_r, cannot determine prototype." >&4 ;;
15033	* )	case "$getprotobyname_r_proto" in
15034		REENTRANT_PROTO*) ;;
15035		*) getprotobyname_r_proto="REENTRANT_PROTO_$getprotobyname_r_proto" ;;
15036		esac
15037		echo "Prototype: $try" ;;
15038	esac
15039	;;
15040	*)	case "$usethreads" in
15041		define) echo "getprotobyname_r has no prototype, not using it." >&4 ;;
15042		esac
15043		d_getprotobyname_r=undef
15044		getprotobyname_r_proto=0
15045		;;
15046	esac
15047	;;
15048*)	getprotobyname_r_proto=0
15049	;;
15050esac
15051
15052: see if getprotobynumber_r exists
15053set getprotobynumber_r d_getprotobynumber_r
15054eval $inlibc
15055case "$d_getprotobynumber_r" in
15056"$define")
15057	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15058	case "$d_getprotobynumber_r_proto:$usethreads" in
15059	":define")	d_getprotobynumber_r_proto=define
15060		set d_getprotobynumber_r_proto getprotobynumber_r $hdrs
15061		eval $hasproto ;;
15062	*)	;;
15063	esac
15064	case "$d_getprotobynumber_r_proto" in
15065	define)
15066	case "$getprotobynumber_r_proto" in
15067	''|0) try='int getprotobynumber_r(int, struct protoent*, char*, size_t, struct protoent**);'
15068	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
15069	esac
15070	case "$getprotobynumber_r_proto" in
15071	''|0) try='struct protoent* getprotobynumber_r(int, struct protoent*, char*, int);'
15072	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
15073	esac
15074	case "$getprotobynumber_r_proto" in
15075	''|0) try='int getprotobynumber_r(int, struct protoent*, struct protoent_data*);'
15076	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
15077	esac
15078	case "$getprotobynumber_r_proto" in
15079	''|0)	d_getprotobynumber_r=undef
15080		getprotobynumber_r_proto=0
15081		echo "Disabling getprotobynumber_r, cannot determine prototype." >&4 ;;
15082	* )	case "$getprotobynumber_r_proto" in
15083		REENTRANT_PROTO*) ;;
15084		*) getprotobynumber_r_proto="REENTRANT_PROTO_$getprotobynumber_r_proto" ;;
15085		esac
15086		echo "Prototype: $try" ;;
15087	esac
15088	;;
15089	*)	case "$usethreads" in
15090		define) echo "getprotobynumber_r has no prototype, not using it." >&4 ;;
15091		esac
15092		d_getprotobynumber_r=undef
15093		getprotobynumber_r_proto=0
15094		;;
15095	esac
15096	;;
15097*)	getprotobynumber_r_proto=0
15098	;;
15099esac
15100
15101: see if getprotoent_r exists
15102set getprotoent_r d_getprotoent_r
15103eval $inlibc
15104case "$d_getprotoent_r" in
15105"$define")
15106	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15107	case "$d_getprotoent_r_proto:$usethreads" in
15108	":define")	d_getprotoent_r_proto=define
15109		set d_getprotoent_r_proto getprotoent_r $hdrs
15110		eval $hasproto ;;
15111	*)	;;
15112	esac
15113	case "$d_getprotoent_r_proto" in
15114	define)
15115	case "$getprotoent_r_proto" in
15116	''|0) try='int getprotoent_r(struct protoent*, char*, size_t, struct protoent**);'
15117	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
15118	esac
15119	case "$getprotoent_r_proto" in
15120	''|0) try='int getprotoent_r(struct protoent*, char*, int);'
15121	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBI ;;
15122	esac
15123	case "$getprotoent_r_proto" in
15124	''|0) try='struct protoent* getprotoent_r(struct protoent*, char*, int);'
15125	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=S_SBI ;;
15126	esac
15127	case "$getprotoent_r_proto" in
15128	''|0) try='int getprotoent_r(struct protoent*, struct protoent_data*);'
15129	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SD ;;
15130	esac
15131	case "$getprotoent_r_proto" in
15132	''|0)	d_getprotoent_r=undef
15133		getprotoent_r_proto=0
15134		echo "Disabling getprotoent_r, cannot determine prototype." >&4 ;;
15135	* )	case "$getprotoent_r_proto" in
15136		REENTRANT_PROTO*) ;;
15137		*) getprotoent_r_proto="REENTRANT_PROTO_$getprotoent_r_proto" ;;
15138		esac
15139		echo "Prototype: $try" ;;
15140	esac
15141	;;
15142	*)	case "$usethreads" in
15143		define) echo "getprotoent_r has no prototype, not using it." >&4 ;;
15144		esac
15145		d_getprotoent_r=undef
15146		getprotoent_r_proto=0
15147		;;
15148	esac
15149	;;
15150*)	getprotoent_r_proto=0
15151	;;
15152esac
15153
15154: see if prototypes for various getprotoxxx netdb.h functions are available
15155echo " "
15156set d_getprotoprotos getprotoent $i_netdb netdb.h
15157eval $hasproto
15158
15159: see if getprpwnam exists
15160set getprpwnam d_getprpwnam
15161eval $inlibc
15162
15163: see if getpwent exists
15164set getpwent d_getpwent
15165eval $inlibc
15166
15167: see if getpwent_r exists
15168set getpwent_r d_getpwent_r
15169eval $inlibc
15170case "$d_getpwent_r" in
15171"$define")
15172	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
15173	case "$d_getpwent_r_proto:$usethreads" in
15174	":define")	d_getpwent_r_proto=define
15175		set d_getpwent_r_proto getpwent_r $hdrs
15176		eval $hasproto ;;
15177	*)	;;
15178	esac
15179	case "$d_getpwent_r_proto" in
15180	define)
15181	case "$getpwent_r_proto" in
15182	''|0) try='int getpwent_r(struct passwd*, char*, size_t, struct passwd**);'
15183	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBWR ;;
15184	esac
15185	case "$getpwent_r_proto" in
15186	''|0) try='int getpwent_r(struct passwd*, char*, int, struct passwd**);'
15187	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIR ;;
15188	esac
15189	case "$getpwent_r_proto" in
15190	''|0) try='struct passwd* getpwent_r(struct passwd*, char*, size_t);'
15191	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBW ;;
15192	esac
15193	case "$getpwent_r_proto" in
15194	''|0) try='struct passwd* getpwent_r(struct passwd*, char*, int);'
15195	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBI ;;
15196	esac
15197	case "$getpwent_r_proto" in
15198	''|0) try='int getpwent_r(struct passwd*, char*, int);'
15199	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBI ;;
15200	esac
15201	case "$getpwent_r_proto" in
15202	''|0) try='int getpwent_r(struct passwd*, char*, int, FILE**);'
15203	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIH ;;
15204	esac
15205	case "$getpwent_r_proto" in
15206	''|0)	d_getpwent_r=undef
15207		getpwent_r_proto=0
15208		echo "Disabling getpwent_r, cannot determine prototype." >&4 ;;
15209	* )	case "$getpwent_r_proto" in
15210		REENTRANT_PROTO*) ;;
15211		*) getpwent_r_proto="REENTRANT_PROTO_$getpwent_r_proto" ;;
15212		esac
15213		echo "Prototype: $try" ;;
15214	esac
15215	;;
15216	*)	case "$usethreads" in
15217		define) echo "getpwent_r has no prototype, not using it." >&4 ;;
15218		esac
15219		d_getpwent_r=undef
15220		getpwent_r_proto=0
15221		;;
15222	esac
15223	;;
15224*)	getpwent_r_proto=0
15225	;;
15226esac
15227
15228: see if getpwnam_r exists
15229set getpwnam_r d_getpwnam_r
15230eval $inlibc
15231case "$d_getpwnam_r" in
15232"$define")
15233	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
15234	case "$d_getpwnam_r_proto:$usethreads" in
15235	":define")	d_getpwnam_r_proto=define
15236		set d_getpwnam_r_proto getpwnam_r $hdrs
15237		eval $hasproto ;;
15238	*)	;;
15239	esac
15240	case "$d_getpwnam_r_proto" in
15241	define)
15242	case "$getpwnam_r_proto" in
15243	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);'
15244	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
15245	esac
15246	case "$getpwnam_r_proto" in
15247	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int, struct passwd**);'
15248	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
15249	esac
15250	case "$getpwnam_r_proto" in
15251	''|0) try='struct passwd* getpwnam_r(const char*, struct passwd*, char*, int);'
15252	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
15253	esac
15254	case "$getpwnam_r_proto" in
15255	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int);'
15256	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
15257	esac
15258	case "$getpwnam_r_proto" in
15259	''|0)	d_getpwnam_r=undef
15260		getpwnam_r_proto=0
15261		echo "Disabling getpwnam_r, cannot determine prototype." >&4 ;;
15262	* )	case "$getpwnam_r_proto" in
15263		REENTRANT_PROTO*) ;;
15264		*) getpwnam_r_proto="REENTRANT_PROTO_$getpwnam_r_proto" ;;
15265		esac
15266		echo "Prototype: $try" ;;
15267	esac
15268	;;
15269	*)	case "$usethreads" in
15270		define) echo "getpwnam_r has no prototype, not using it." >&4 ;;
15271		esac
15272		d_getpwnam_r=undef
15273		getpwnam_r_proto=0
15274		;;
15275	esac
15276	;;
15277*)	getpwnam_r_proto=0
15278	;;
15279esac
15280
15281: see if getpwuid_r exists
15282set getpwuid_r d_getpwuid_r
15283eval $inlibc
15284case "$d_getpwuid_r" in
15285"$define")
15286	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
15287	case "$d_getpwuid_r_proto:$usethreads" in
15288	":define")	d_getpwuid_r_proto=define
15289		set d_getpwuid_r_proto getpwuid_r $hdrs
15290		eval $hasproto ;;
15291	*)	;;
15292	esac
15293	case "$d_getpwuid_r_proto" in
15294	define)
15295	case "$getpwuid_r_proto" in
15296	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);'
15297	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
15298	esac
15299	case "$getpwuid_r_proto" in
15300	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int, struct passwd**);'
15301	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
15302	esac
15303	case "$getpwuid_r_proto" in
15304	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int);'
15305	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
15306	esac
15307	case "$getpwuid_r_proto" in
15308	''|0) try='struct passwd* getpwuid_r(uid_t, struct passwd*, char*, int);'
15309	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
15310	esac
15311	case "$getpwuid_r_proto" in
15312	''|0)	d_getpwuid_r=undef
15313		getpwuid_r_proto=0
15314		echo "Disabling getpwuid_r, cannot determine prototype." >&4 ;;
15315	* )	case "$getpwuid_r_proto" in
15316		REENTRANT_PROTO*) ;;
15317		*) getpwuid_r_proto="REENTRANT_PROTO_$getpwuid_r_proto" ;;
15318		esac
15319		echo "Prototype: $try" ;;
15320	esac
15321	;;
15322	*)	case "$usethreads" in
15323		define) echo "getpwuid_r has no prototype, not using it." >&4 ;;
15324		esac
15325		d_getpwuid_r=undef
15326		getpwuid_r_proto=0
15327		;;
15328	esac
15329	;;
15330*)	getpwuid_r_proto=0
15331	;;
15332esac
15333
15334: Optional checks for getsbyname and getsbyport
15335
15336: see if getservbyname exists
15337set getservbyname d_getsbyname
15338eval $inlibc
15339
15340: see if getservbyport exists
15341set getservbyport d_getsbyport
15342eval $inlibc
15343
15344: see if getservent exists
15345set getservent d_getsent
15346eval $inlibc
15347
15348: see if getservbyname_r exists
15349set getservbyname_r d_getservbyname_r
15350eval $inlibc
15351case "$d_getservbyname_r" in
15352"$define")
15353	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15354	case "$d_getservbyname_r_proto:$usethreads" in
15355	":define")	d_getservbyname_r_proto=define
15356		set d_getservbyname_r_proto getservbyname_r $hdrs
15357		eval $hasproto ;;
15358	*)	;;
15359	esac
15360	case "$d_getservbyname_r_proto" in
15361	define)
15362	case "$getservbyname_r_proto" in
15363	''|0) try='int getservbyname_r(const char*, const char*, struct servent*, char*, size_t, struct servent**);'
15364	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
15365	esac
15366	case "$getservbyname_r_proto" in
15367	''|0) try='struct servent* getservbyname_r(const char*, const char*, struct servent*, char*, int);'
15368	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
15369	esac
15370	case "$getservbyname_r_proto" in
15371	''|0) try='int getservbyname_r(const char*, const char*, struct servent*, struct servent_data*);'
15372	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
15373	esac
15374	case "$getservbyname_r_proto" in
15375	''|0)	d_getservbyname_r=undef
15376		getservbyname_r_proto=0
15377		echo "Disabling getservbyname_r, cannot determine prototype." >&4 ;;
15378	* )	case "$getservbyname_r_proto" in
15379		REENTRANT_PROTO*) ;;
15380		*) getservbyname_r_proto="REENTRANT_PROTO_$getservbyname_r_proto" ;;
15381		esac
15382		echo "Prototype: $try" ;;
15383	esac
15384	;;
15385	*)	case "$usethreads" in
15386		define) echo "getservbyname_r has no prototype, not using it." >&4 ;;
15387		esac
15388		d_getservbyname_r=undef
15389		getservbyname_r_proto=0
15390		;;
15391	esac
15392	;;
15393*)	getservbyname_r_proto=0
15394	;;
15395esac
15396
15397: see if getservbyport_r exists
15398set getservbyport_r d_getservbyport_r
15399eval $inlibc
15400case "$d_getservbyport_r" in
15401"$define")
15402	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15403	case "$d_getservbyport_r_proto:$usethreads" in
15404	":define")	d_getservbyport_r_proto=define
15405		set d_getservbyport_r_proto getservbyport_r $hdrs
15406		eval $hasproto ;;
15407	*)	;;
15408	esac
15409	case "$d_getservbyport_r_proto" in
15410	define)
15411	case "$getservbyport_r_proto" in
15412	''|0) try='int getservbyport_r(int, const char*, struct servent*, char*, size_t, struct servent**);'
15413	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
15414	esac
15415	case "$getservbyport_r_proto" in
15416	''|0) try='struct servent* getservbyport_r(int, const char*, struct servent*, char*, int);'
15417	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
15418	esac
15419	case "$getservbyport_r_proto" in
15420	''|0) try='int getservbyport_r(int, const char*, struct servent*, struct servent_data*);'
15421	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
15422	esac
15423	case "$getservbyport_r_proto" in
15424	''|0)	d_getservbyport_r=undef
15425		getservbyport_r_proto=0
15426		echo "Disabling getservbyport_r, cannot determine prototype." >&4 ;;
15427	* )	case "$getservbyport_r_proto" in
15428		REENTRANT_PROTO*) ;;
15429		*) getservbyport_r_proto="REENTRANT_PROTO_$getservbyport_r_proto" ;;
15430		esac
15431		echo "Prototype: $try" ;;
15432	esac
15433	;;
15434	*)	case "$usethreads" in
15435		define) echo "getservbyport_r has no prototype, not using it." >&4 ;;
15436		esac
15437		d_getservbyport_r=undef
15438		getservbyport_r_proto=0
15439		;;
15440	esac
15441	;;
15442*)	getservbyport_r_proto=0
15443	;;
15444esac
15445
15446: see if getservent_r exists
15447set getservent_r d_getservent_r
15448eval $inlibc
15449case "$d_getservent_r" in
15450"$define")
15451	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15452	case "$d_getservent_r_proto:$usethreads" in
15453	":define")	d_getservent_r_proto=define
15454		set d_getservent_r_proto getservent_r $hdrs
15455		eval $hasproto ;;
15456	*)	;;
15457	esac
15458	case "$d_getservent_r_proto" in
15459	define)
15460	case "$getservent_r_proto" in
15461	''|0) try='int getservent_r(struct servent*, char*, size_t, struct servent**);'
15462	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBWR ;;
15463	esac
15464	case "$getservent_r_proto" in
15465	''|0) try='int getservent_r(struct servent*, char*, int);'
15466	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBI ;;
15467	esac
15468	case "$getservent_r_proto" in
15469	''|0) try='struct servent* getservent_r(struct servent*, char*, int);'
15470	./protochk "$extern_C $try" $hdrs && getservent_r_proto=S_SBI ;;
15471	esac
15472	case "$getservent_r_proto" in
15473	''|0) try='int getservent_r(struct servent*, struct servent_data*);'
15474	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SD ;;
15475	esac
15476	case "$getservent_r_proto" in
15477	''|0)	d_getservent_r=undef
15478		getservent_r_proto=0
15479		echo "Disabling getservent_r, cannot determine prototype." >&4 ;;
15480	* )	case "$getservent_r_proto" in
15481		REENTRANT_PROTO*) ;;
15482		*) getservent_r_proto="REENTRANT_PROTO_$getservent_r_proto" ;;
15483		esac
15484		echo "Prototype: $try" ;;
15485	esac
15486	;;
15487	*)	case "$usethreads" in
15488		define) echo "getservent_r has no prototype, not using it." >&4 ;;
15489		esac
15490		d_getservent_r=undef
15491		getservent_r_proto=0
15492		;;
15493	esac
15494	;;
15495*)	getservent_r_proto=0
15496	;;
15497esac
15498
15499: see if prototypes for various getservxxx netdb.h functions are available
15500echo " "
15501set d_getservprotos getservent $i_netdb netdb.h
15502eval $hasproto
15503
15504: see if getspnam exists
15505set getspnam d_getspnam
15506eval $inlibc
15507
15508: see if this is a shadow.h system
15509set shadow.h i_shadow
15510eval $inhdr
15511
15512: see if getspnam_r exists
15513set getspnam_r d_getspnam_r
15514eval $inlibc
15515case "$d_getspnam_r" in
15516"$define")
15517	hdrs="$i_systypes sys/types.h define stdio.h $i_shadow shadow.h"
15518	case "$d_getspnam_r_proto:$usethreads" in
15519	":define")	d_getspnam_r_proto=define
15520		set d_getspnam_r_proto getspnam_r $hdrs
15521		eval $hasproto ;;
15522	*)	;;
15523	esac
15524	case "$d_getspnam_r_proto" in
15525	define)
15526	case "$getspnam_r_proto" in
15527	''|0) try='int getspnam_r(const char*, struct spwd*, char*, size_t, struct spwd**);'
15528	./protochk "$extern_C $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
15529	esac
15530	case "$getspnam_r_proto" in
15531	''|0) try='struct spwd* getspnam_r(const char*, struct spwd*, char*, int);'
15532	./protochk "$extern_C $try" $hdrs && getspnam_r_proto=S_CSBI ;;
15533	esac
15534	case "$getspnam_r_proto" in
15535	''|0)	d_getspnam_r=undef
15536		getspnam_r_proto=0
15537		echo "Disabling getspnam_r, cannot determine prototype." >&4 ;;
15538	* )	case "$getspnam_r_proto" in
15539		REENTRANT_PROTO*) ;;
15540		*) getspnam_r_proto="REENTRANT_PROTO_$getspnam_r_proto" ;;
15541		esac
15542		echo "Prototype: $try" ;;
15543	esac
15544	;;
15545	*)	case "$usethreads" in
15546		define) echo "getspnam_r has no prototype, not using it." >&4 ;;
15547		esac
15548		d_getspnam_r=undef
15549		getspnam_r_proto=0
15550		;;
15551	esac
15552	;;
15553*)	getspnam_r_proto=0
15554	;;
15555esac
15556
15557: see if gettimeofday or ftime exists
15558set gettimeofday d_gettimeod
15559eval $inlibc
15560case "$d_gettimeod" in
15561"$undef")
15562	set ftime d_ftime
15563	eval $inlibc
15564	;;
15565*)
15566	val="$undef"; set d_ftime; eval $setvar
15567	;;
15568esac
15569case "$d_gettimeod$d_ftime" in
15570"$undef$undef")
15571	echo " "
15572	echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
15573	;;
15574esac
15575
15576: see if gmtime_r exists
15577set gmtime_r d_gmtime_r
15578eval $inlibc
15579case "$d_gmtime_r" in
15580"$define")
15581	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
15582	case "$d_gmtime_r_proto:$usethreads" in
15583	":define")	d_gmtime_r_proto=define
15584		set d_gmtime_r_proto gmtime_r $hdrs
15585		eval $hasproto ;;
15586	*)	;;
15587	esac
15588	case "$d_gmtime_r_proto" in
15589	define)
15590	case "$gmtime_r_proto" in
15591	''|0) try='struct tm* gmtime_r(const time_t*, struct tm*);'
15592	./protochk "$extern_C $try" $hdrs && gmtime_r_proto=S_TS ;;
15593	esac
15594	case "$gmtime_r_proto" in
15595	''|0) try='int gmtime_r(const time_t*, struct tm*);'
15596	./protochk "$extern_C $try" $hdrs && gmtime_r_proto=I_TS ;;
15597	esac
15598	case "$gmtime_r_proto" in
15599	''|0)	d_gmtime_r=undef
15600		gmtime_r_proto=0
15601		echo "Disabling gmtime_r, cannot determine prototype." >&4 ;;
15602	* )	case "$gmtime_r_proto" in
15603		REENTRANT_PROTO*) ;;
15604		*) gmtime_r_proto="REENTRANT_PROTO_$gmtime_r_proto" ;;
15605		esac
15606		echo "Prototype: $try" ;;
15607	esac
15608	;;
15609	*)	case "$usethreads" in
15610		define) echo "gmtime_r has no prototype, not using it." >&4 ;;
15611		esac
15612		d_gmtime_r=undef
15613		gmtime_r_proto=0
15614		;;
15615	esac
15616	;;
15617*)	gmtime_r_proto=0
15618	;;
15619esac
15620
15621: see if hasmntopt exists
15622set hasmntopt d_hasmntopt
15623eval $inlibc
15624
15625: see if this is a netinet/in.h or sys/in.h system
15626set netinet/in.h i_niin sys/in.h i_sysin
15627eval $inhdr
15628
15629: see if arpa/inet.h has to be included
15630set arpa/inet.h i_arpainet
15631eval $inhdr
15632
15633: see if htonl --and friends-- exists
15634val=''
15635set htonl val
15636eval $inlibc
15637
15638: Maybe they are macros.
15639case "$val" in
15640$undef)
15641	$cat >htonl.c <<EOM
15642#include <stdio.h>
15643#include <sys/types.h>
15644#$i_niin I_NETINET_IN
15645#$i_sysin I_SYS_IN
15646#$i_arpainet I_ARPA_INET
15647#ifdef I_NETINET_IN
15648#include <netinet/in.h>
15649#endif
15650#ifdef I_SYS_IN
15651#include <sys/in.h>
15652#endif
15653#ifdef I_ARPA_INET
15654#include <arpa/inet.h>
15655#endif
15656#ifdef htonl
15657printf("Defined as a macro.");
15658#endif
15659EOM
15660	$cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
15661	if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
15662		val="$define"
15663		echo "But it seems to be defined as a macro." >&4
15664	fi
15665	$rm -f htonl.?
15666	;;
15667esac
15668set d_htonl
15669eval $setvar
15670
15671: see if hypot exists
15672set hypot d_hypot
15673eval $inlibc
15674
15675: see if ilogb exists
15676set ilogb d_ilogb
15677eval $inlibc
15678
15679: see if ilogbl exists
15680set ilogbl d_ilogbl
15681eval $inlibc
15682
15683: check whether inet_aton exists
15684set inet_aton d_inetaton
15685eval $inlibc
15686
15687: see if inet_ntop exists
15688set inet_ntop d_inetntop
15689eval $inlibc
15690
15691: see if inet_pton exists
15692set inet_pton d_inetpton
15693eval $inlibc
15694
15695: Look for isascii
15696echo " "
15697$cat >isascii.c <<EOCP
15698#include <stdio.h>
15699#include <ctype.h>
15700#$i_stdlib I_STDLIB
15701#ifdef I_STDLIB
15702#include <stdlib.h>
15703#endif
15704int main() {
15705	int c = 'A';
15706	if (isascii(c))
15707		exit(0);
15708	else
15709		exit(1);
15710}
15711EOCP
15712set isascii
15713if eval $compile; then
15714	echo "isascii() found." >&4
15715	val="$define"
15716else
15717	echo "isascii() NOT found." >&4
15718	val="$undef"
15719fi
15720set d_isascii
15721eval $setvar
15722$rm -f isascii*
15723
15724: Look for isblank
15725echo " "
15726$cat >isblank.c <<'EOCP'
15727#include <stdio.h>
15728#include <ctype.h>
15729int main() {
15730	int c = ' ';
15731	if (isblank(c))
15732		return 0 ;
15733	else
15734		return 1 ;
15735}
15736EOCP
15737if $cc $ccflags $ldflags -o isblank isblank.c $libs >/dev/null 2>&1 ; then
15738	echo "isblank() found." >&4
15739	val="$define"
15740else
15741	echo "isblank() NOT found." >&4
15742	val="$undef"
15743fi
15744set d_isblank
15745eval $setvar
15746$rm -f isblank*
15747
15748: check for isfinite
15749echo "Checking to see if you have isfinite..." >&4
15750$cat >try.c <<EOCP
15751#include <math.h>
15752int main() { return isfinite(0.0); }
15753EOCP
15754set try
15755if eval $compile; then
15756	val="$define"
15757	echo "You have isfinite."
15758else
15759	val="$undef"
15760	echo "You do not have isfinite."
15761fi
15762$rm_try
15763set d_isfinite
15764eval $setvar
15765
15766: see if isfinitel exists
15767set isfinitel d_isfinitel
15768eval $inlibc
15769
15770: check for isinf
15771echo "Checking to see if you have isinf..." >&4
15772$cat >try.c <<EOCP
15773#include <math.h>
15774int main() { return isinf(0.0); }
15775EOCP
15776set try
15777if eval $compile; then
15778	val="$define"
15779	echo "You have isinf."
15780else
15781	val="$undef"
15782	echo "You do not have isinf."
15783fi
15784$rm_try
15785set d_isinf
15786eval $setvar
15787
15788: see if isinfl exists
15789set isinfl d_isinfl
15790eval $inlibc
15791
15792: check for isless
15793echo "Checking to see if you have isless..." >&4
15794$cat >try.c <<EOCP
15795#include <math.h>
15796int main() { return isless(0.0); }
15797EOCP
15798set try
15799if eval $compile; then
15800	val="$define"
15801	echo "You have isless."
15802else
15803	val="$undef"
15804	echo "You do not have isless."
15805fi
15806$rm_try
15807set d_isless
15808eval $setvar
15809
15810: check for isnan
15811echo "Checking to see if you have isnan..." >&4
15812$cat >try.c <<EOCP
15813#include <math.h>
15814int main() { return isnan(0.0); }
15815EOCP
15816set try
15817if eval $compile; then
15818	val="$define"
15819	echo "You have isnan."
15820else
15821	val="$undef"
15822	echo "You do not have isnan."
15823fi
15824$rm_try
15825set d_isnan
15826eval $setvar
15827
15828: see if isnanl exists
15829set isnanl d_isnanl
15830eval $inlibc
15831
15832: check for isnormal
15833echo "Checking to see if you have isnormal..." >&4
15834$cat >try.c <<EOCP
15835#include <math.h>
15836int main() { return isnormal(0.0); }
15837EOCP
15838set try
15839if eval $compile; then
15840	val="$define"
15841	echo "You have isnormal."
15842else
15843	val="$undef"
15844	echo "You do not have isnormal."
15845fi
15846$rm_try
15847set d_isnormal
15848eval $setvar
15849
15850: see if j0 exists
15851set j0 d_j0
15852eval $inlibc
15853
15854: see if j0l exists
15855set j0l d_j0l
15856eval $inlibc
15857
15858: see if killpg exists
15859set killpg d_killpg
15860eval $inlibc
15861
15862: see if localeconv exists
15863set localeconv d_locconv
15864eval $inlibc
15865
15866: see if libc has the POSIX.1-2008 currency locale rules
15867case "$d_locconv:$d_lc_monetary_2008" in
15868$define:)
15869	$cat >try.c <<EOCP
15870#include <locale.h>
15871int main() {
15872	struct lconv *lc = localeconv();
15873	char int_p_cs_precedes = lc->int_p_cs_precedes;
15874	return 0;
15875}
15876EOCP
15877	set try
15878	if eval $compile; then
15879		d_lc_monetary_2008="$define"
15880	else
15881		d_lc_monetary_2008="$undef"
15882	fi;
15883	$rm_try
15884	;;
15885esac
15886
15887: see if lchown exists
15888echo " "
15889$cat > try.c <<'EOCP'
15890/* System header to define __stub macros and hopefully few prototypes,
15891    which can conflict with char lchown(); below.  */
15892#include <assert.h>
15893/* Override any gcc2 internal prototype to avoid an error.  */
15894/* We use char because int might match the return type of a gcc2
15895   builtin and then its argument prototype would still apply.  */
15896char lchown();
15897int main() {
15898    /*  The GNU C library defines this for functions which it implements
15899        to always fail with ENOSYS.  Some functions are actually named
15900	something starting with __ and the normal name is an alias.  */
15901#if defined (__stub_lchown) || defined (__stub___lchown)
15902choke me
15903#else
15904lchown();
15905#endif
15906; return 0; }
15907EOCP
15908set try
15909if eval $compile; then
15910    $echo "lchown() found." >&4
15911    val="$define"
15912else
15913    $echo "lchown() NOT found." >&4
15914    val="$undef"
15915fi
15916set d_lchown
15917eval $setvar
15918
15919: See if number of significant digits in a double precision number is known
15920echo " "
15921$cat >ldbl_dig.c <<EOM
15922#include <limits.h>
15923#include <float.h>
15924#ifdef LDBL_DIG
15925printf("Contains LDBL_DIG");
15926#endif
15927EOM
15928$cppstdin $cppflags $cppminus < ldbl_dig.c >ldbl_dig.E 2>/dev/null
15929if $contains 'LDBL_DIG' ldbl_dig.E >/dev/null 2>&1; then
15930	echo "LDBL_DIG found." >&4
15931	val="$define"
15932else
15933	echo "LDBL_DIG NOT found." >&4
15934	val="$undef"
15935fi
15936$rm -f ldbl_dig.?
15937set d_ldbl_dig
15938eval $setvar
15939
15940: see if lgamma exists
15941set lgamma d_lgamma
15942eval $inlibc
15943
15944: see if lgamma_r exists
15945set lgamma_r d_lgamma_r
15946eval $inlibc
15947
15948: check to see if math.h defines _LIB_VERSION
15949d_libm_lib_version="$undef"
15950echo " "
15951echo "Checking to see if your libm supports _LIB_VERSION..." >&4
15952$cat >try.c <<EOCP
15953#include <unistd.h>
15954#include <math.h>
15955int main (int argc, char *argv[])
15956{
15957    printf ("%d\n", _LIB_VERSION);
15958    return (0);
15959    } /* main */
15960EOCP
15961set try
15962if eval $compile; then
15963    foo=`$run ./try`
15964    echo "Yes, it does ($foo)" >&4
15965    d_libm_lib_version="$define"
15966else
15967    echo "No, it does not (probably harmless)" >&4
15968    fi
15969$rm_try
15970
15971: see if link exists
15972set link d_link
15973eval $inlibc
15974
15975: see if llrint exists
15976set llrint d_llrint
15977eval $inlibc
15978
15979: see if llrintl exists
15980set llrintl d_llrintl
15981eval $inlibc
15982
15983: see if llround exists
15984set llround d_llround
15985eval $inlibc
15986
15987: see if llroundl exists
15988set llroundl d_llroundl
15989eval $inlibc
15990
15991: see if localeconv_l exists
15992set localeconv_l d_localeconv_l
15993eval $inlibc
15994
15995: see if localtime_r exists
15996set localtime_r d_localtime_r
15997eval $inlibc
15998case "$d_localtime_r" in
15999"$define")
16000	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
16001	case "$d_localtime_r_proto:$usethreads" in
16002	":define")	d_localtime_r_proto=define
16003		set d_localtime_r_proto localtime_r $hdrs
16004		eval $hasproto ;;
16005	*)	;;
16006	esac
16007	case "$d_localtime_r_proto" in
16008	define)
16009	case "$localtime_r_proto" in
16010	''|0) try='struct tm* localtime_r(const time_t*, struct tm*);'
16011	./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;;
16012	esac
16013	case "$localtime_r_proto" in
16014	''|0) try='int localtime_r(const time_t*, struct tm*);'
16015	./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;;
16016	esac
16017	case "$localtime_r_proto" in
16018	''|0)	d_localtime_r=undef
16019		localtime_r_proto=0
16020		echo "Disabling localtime_r, cannot determine prototype." >&4 ;;
16021	* )	case "$localtime_r_proto" in
16022		REENTRANT_PROTO*) ;;
16023		*) localtime_r_proto="REENTRANT_PROTO_$localtime_r_proto" ;;
16024		esac
16025		echo "Prototype: $try" ;;
16026	esac
16027	;;
16028	*)	case "$usethreads" in
16029		define) echo "localtime_r has no prototype, not using it." >&4 ;;
16030		esac
16031		d_localtime_r=undef
16032		localtime_r_proto=0
16033		;;
16034	esac
16035	;;
16036*)	localtime_r_proto=0
16037	;;
16038esac
16039
16040: see if localtime_r calls tzset
16041case "$localtime_r_proto" in
16042REENTRANT_PROTO*)
16043	$cat >try.c <<EOCP
16044/*  Does our libc's localtime_r call tzset ?
16045 *  return 0 if so, 1 otherwise.
16046 */
16047#$i_systypes	I_SYS_TYPES
16048#$i_unistd	I_UNISTD
16049#$i_time	I_TIME
16050#$i_stdlib	I_STDLIB
16051#$i_malloc	I_MALLOC
16052#ifdef I_SYS_TYPES
16053#  include <sys/types.h>
16054#endif
16055#ifdef I_UNISTD
16056#  include <unistd.h>
16057#endif
16058#ifdef I_TIME
16059#  include <time.h>
16060#endif
16061#ifdef I_STDLIB
16062#include <stdlib.h>
16063#endif
16064#include <string.h>
16065#ifdef I_MALLOC
16066#  include <malloc.h>
16067#endif
16068int main()
16069{
16070    time_t t = time(0L);
16071    char w_tz[]="TZ" "=GMT+5",
16072	 e_tz[]="TZ" "=GMT-5",
16073	*tz_e = (char*)malloc(16),
16074	*tz_w = (char*)malloc(16);
16075    struct tm tm_e, tm_w;
16076    memset(&tm_e,'\0',sizeof(struct tm));
16077    memset(&tm_w,'\0',sizeof(struct tm));
16078    strcpy(tz_e,e_tz);
16079    strcpy(tz_w,w_tz);
16080
16081    putenv(tz_e);
16082    localtime_r(&t, &tm_e);
16083
16084    putenv(tz_w);
16085    localtime_r(&t, &tm_w);
16086
16087    if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
16088	return 1;
16089    return 0;
16090}
16091EOCP
16092	set try
16093	if eval $compile; then
16094	    if $run ./try; then
16095		d_localtime_r_needs_tzset=undef;
16096	    else
16097		d_localtime_r_needs_tzset=define;
16098	    fi;
16099	else
16100	    d_localtime_r_needs_tzset=undef;
16101	fi;
16102     ;;
16103  *)
16104     d_localtime_r_needs_tzset=undef;
16105     ;;
16106esac
16107$rm_try
16108
16109: see if lockf exists
16110set lockf d_lockf
16111eval $inlibc
16112
16113: see if log1p exists
16114set log1p d_log1p
16115eval $inlibc
16116
16117: see if log2 exists
16118set log2 d_log2
16119eval $inlibc
16120
16121: see if logb exists
16122set logb d_logb
16123eval $inlibc
16124
16125: see if lrint exists
16126set lrint d_lrint
16127eval $inlibc
16128
16129: see if lrintl exists
16130set lrintl d_lrintl
16131eval $inlibc
16132
16133: see if lround exists
16134set lround d_lround
16135eval $inlibc
16136
16137: see if lroundl exists
16138set lroundl d_lroundl
16139eval $inlibc
16140
16141: see if prototype for lseek is available
16142echo " "
16143set d_lseekproto lseek $i_systypes sys/types.h $i_unistd unistd.h
16144eval $hasproto
16145
16146: see if lstat exists
16147set lstat d_lstat
16148eval $inlibc
16149
16150: see if madvise exists
16151set madvise d_madvise
16152eval $inlibc
16153
16154: see if malloc_size exists
16155set malloc_size d_malloc_size
16156eval $inlibc
16157
16158: see if malloc_size_good exists
16159set malloc_good_size d_malloc_good_size
16160eval $inlibc
16161
16162: see if mblen exists
16163set mblen d_mblen
16164eval $inlibc
16165
16166: see if mbrlen exists
16167set mbrlen d_mbrlen
16168eval $inlibc
16169
16170: see if mbrtowc exists
16171set mbrtowc d_mbrtowc
16172eval $inlibc
16173
16174: see if mbstowcs exists
16175set mbstowcs d_mbstowcs
16176eval $inlibc
16177
16178: see if mbtowc exists
16179set mbtowc d_mbtowc
16180eval $inlibc
16181
16182: see if memmem exists
16183: We need both a prototype in string.h and the symbol in libc.
16184echo " "
16185d_memmem_proto=''
16186xx1="#$d_gnulibc HAS_GNULIBC"
16187xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
16188xx3='#   define _GNU_SOURCE'
16189xx4='#endif'
16190set d_memmem_proto memmem literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
16191eval $hasproto
16192case "$d_memmem_proto" in
16193    define) # see if memmem exists
16194	set memmem d_memmem
16195	eval $inlibc
16196	;;
16197    *)  val=$undef
16198	set d_memmem
16199	eval $setvar
16200	;;
16201esac
16202
16203: see if memrchr exists
16204: We need both a prototype in string.h and the symbol in libc.
16205echo " "
16206d_memrchr_proto=''
16207xx1="#$d_gnulibc HAS_GNULIBC"
16208xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
16209xx3='#   define _GNU_SOURCE'
16210xx4='#endif'
16211set d_memrchr_proto memrchr literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
16212eval $hasproto
16213case "$d_memrchr_proto" in
16214    define) # see if memrchr exists
16215	set memrchr d_memrchr
16216	eval $inlibc
16217	;;
16218    *)  val=$undef
16219	set d_memrchr
16220	eval $setvar
16221	;;
16222esac
16223
16224: see if mkdir exists
16225set mkdir d_mkdir
16226eval $inlibc
16227
16228: see if mkdtemp exists
16229set mkdtemp d_mkdtemp
16230eval $inlibc
16231
16232: see if mkfifo exists
16233set mkfifo d_mkfifo
16234eval $inlibc
16235
16236: see if mkostemp exists
16237set mkostemp d_mkostemp
16238eval $inlibc
16239
16240: see if mkstemp exists
16241set mkstemp d_mkstemp
16242eval $inlibc
16243
16244: see if mkstemps exists
16245set mkstemps d_mkstemps
16246eval $inlibc
16247
16248: see if mktime exists
16249set mktime d_mktime
16250eval $inlibc
16251
16252: see if sys/mman.h has to be included
16253set sys/mman.h i_sysmman
16254eval $inhdr
16255
16256: see if mmap exists
16257set mmap d_mmap
16258eval $inlibc
16259: see what shmat returns
16260: default to something harmless
16261mmaptype='void *'
16262case "$i_sysmman$d_mmap" in
16263"$define$define")
16264	$cat >mmap.c <<'END'
16265#include <sys/mman.h>
16266void *mmap();
16267END
16268	if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
16269		mmaptype='void *'
16270	else
16271		mmaptype='caddr_t'
16272	fi
16273	echo "and it returns ($mmaptype)." >&4
16274	;;
16275esac
16276
16277: see if sqrtl exists
16278set sqrtl d_sqrtl
16279eval $inlibc
16280
16281: see if scalbnl exists
16282set scalbnl d_scalbnl
16283eval $inlibc
16284
16285: see if truncl exists
16286set truncl d_truncl
16287eval $inlibc
16288
16289: see if modfl exists
16290set modfl d_modfl
16291eval $inlibc
16292
16293: see if prototype for modfl is available
16294echo " "
16295set d_modflproto modfl define math.h
16296eval $hasproto
16297
16298if $test "$uselongdouble" = "$define"; then
16299    message=""
16300    if $test "$d_sqrtl" != "$define"; then
16301	message="$message sqrtl"
16302    fi
16303    if $test "$d_modfl" != "$define"; then
16304	if $test "$d_truncl:$d_copysignl" = "$define:$define"; then
16305	    echo "You have both truncl and copysignl, so I can emulate modfl."
16306	else
16307	    if $test "$d_aintl:$d_copysignl" = "$define:$define"; then
16308		echo "You have both aintl and copysignl, so I can emulate modfl."
16309	    else
16310		message="$message modfl"
16311	    fi
16312	fi
16313    fi
16314    if $test "$d_frexpl" != "$define"; then
16315	if $test "$d_ilogbl:$d_scalbnl" = "$define:$define"; then
16316	    echo "You have both ilogbl and scalbnl, so I can emulate frexpl."
16317	else
16318	    message="$message frexpl"
16319	fi
16320    fi
16321    if $test "$d_ldexpl" != "$define"; then
16322	message="$message ldexpl"
16323    fi
16324
16325    if $test "$message" != ""; then
16326	$cat <<EOM >&4
16327
16328*** You requested the use of long doubles but you do not seem to have
16329*** the following mathematical functions needed for long double support:
16330***    $message
16331*** Please rerun Configure without -Duselongdouble and/or -Dusemorebits.
16332*** Cannot continue, aborting.
16333
16334EOM
16335
16336	exit 1
16337    fi
16338fi
16339
16340: see if mprotect exists
16341set mprotect d_mprotect
16342eval $inlibc
16343
16344: see if msgctl exists
16345set msgctl d_msgctl
16346eval $inlibc
16347
16348: see if msgget exists
16349set msgget d_msgget
16350eval $inlibc
16351
16352: see if msgsnd exists
16353set msgsnd d_msgsnd
16354eval $inlibc
16355
16356: see if msgrcv exists
16357set msgrcv d_msgrcv
16358eval $inlibc
16359
16360: see how much of the 'msg*(2)' library is present.
16361h_msg=true
16362echo " "
16363case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
16364*"$undef"*) h_msg=false;;
16365esac
16366case "$osname" in
16367freebsd)
16368    case "`ipcs 2>&1`" in
16369    "SVID messages"*"not configured"*)
16370	echo "Your $osname does not have the msg*(2) configured." >&4
16371        h_msg=false
16372	val="$undef"
16373	set msgctl d_msgctl
16374	eval $setvar
16375	set msgget d_msgget
16376	eval $setvar
16377	set msgsnd d_msgsnd
16378	eval $setvar
16379	set msgrcv d_msgrcv
16380	eval $setvar
16381	;;
16382    esac
16383    ;;
16384esac
16385: we could also check for sys/ipc.h ...
16386if $h_msg && $test `./findhdr sys/msg.h`; then
16387	echo "You have the full msg*(2) library." >&4
16388	val="$define"
16389else
16390	echo "You don't have the full msg*(2) library." >&4
16391	val="$undef"
16392fi
16393set d_msg
16394eval $setvar
16395
16396: Check for msghdr_s
16397echo " "
16398echo "Checking to see if your system supports struct msghdr..." >&4
16399set d_msghdr_s msghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
16400eval $hasstruct
16401case "$d_msghdr_s" in
16402"$define")      echo "Yes, it does."   ;;
16403*)              echo "No, it doesn't." ;;
16404esac
16405
16406: see if msync exists
16407set msync d_msync
16408eval $inlibc
16409
16410: see if munmap exists
16411set munmap d_munmap
16412eval $inlibc
16413
16414: see if nan exists
16415set nan d_nan
16416eval $inlibc
16417
16418: see if nanosleep exists
16419set nanosleep d_nanosleep
16420eval $inlibc
16421
16422: see if nearbyint exists
16423set nearbyint d_nearbyint
16424eval $inlibc
16425
16426: see if nextafter exists
16427set nextafter d_nextafter
16428eval $inlibc
16429
16430: see if nexttoward exists
16431set nexttoward d_nexttoward
16432eval $inlibc
16433
16434: see if nice exists
16435set nice d_nice
16436eval $inlibc
16437
16438: see if this is a langinfo.h system
16439set langinfo.h i_langinfo
16440eval $inhdr
16441
16442: see if nl_langinfo exists
16443set nl_langinfo d_nl_langinfo
16444eval $inlibc
16445
16446: see if this is a quadmath.h system
16447set quadmath.h i_quadmath
16448eval $inhdr
16449
16450: Check basic sizes
16451echo " "
16452$echo "Choosing the C types to be used for Perl's internal types..." >&4
16453
16454case "$use64bitint:$d_quad:$quadtype" in
16455define:define:?*)
16456	ivtype="$quadtype"
16457	uvtype="$uquadtype"
16458	ivsize=8
16459	uvsize=8
16460	;;
16461*)	ivtype="long"
16462	uvtype="unsigned long"
16463	ivsize=$longsize
16464	uvsize=$longsize
16465	;;
16466esac
16467
16468case "$uselongdouble:$d_longdbl" in
16469define:define)
16470	nvtype="long double"
16471	nvsize=$longdblsize
16472	;;
16473*)	nvtype=double
16474	nvsize=$doublesize
16475	;;
16476esac
16477
16478case "$usequadmath:$i_quadmath" in
16479define:define)
16480  nvtype="__float128"
16481  nvsize=16
16482  case "$libs" in
16483  *quadmath*) ;;
16484  *) $cat <<EOM >&4
16485
16486*** You requested the use of the quadmath library, but you
16487*** do not seem to have the quadmath library installed.
16488*** Cannot continue, aborting.
16489EOM
16490    exit 1
16491    ;;
16492  esac
16493  ;;
16494define:*) $cat <<EOM >&4
16495
16496*** You requested the use of the quadmath library, but you
16497*** do not seem to have the required header, <quadmath.h>.
16498EOM
16499  case "$gccversion" in
16500  [23].*|4.[0-5]*)
16501   $cat <<EOM >&4
16502*** Your gcc looks a bit old:
16503*** $gccversion
16504EOM
16505    ;;
16506  '')
16507   $cat <<EOM >&4
16508*** You are not running a gcc.
16509EOM
16510    ;;
16511  esac
16512  $cat <<EOM >&4
16513*** For the quadmath library you need at least gcc 4.6.
16514*** Cannot continue, aborting.
16515EOM
16516  exit 1
16517  ;;
16518esac
16519
16520$echo "(IV will be "$ivtype", $ivsize bytes)"
16521$echo "(UV will be "$uvtype", $uvsize bytes)"
16522$echo "(NV will be "$nvtype", $nvsize bytes)"
16523
16524$cat >try.c <<EOCP
16525#$i_inttypes I_INTTYPES
16526#ifdef I_INTTYPES
16527#include <inttypes.h>
16528#endif
16529#include <stdio.h>
16530int main() {
16531#ifdef INT8
16532   int8_t i =  INT8_MAX;
16533  uint8_t u = UINT8_MAX;
16534  printf("int8_t\n");
16535#endif
16536#ifdef INT16
16537   int16_t i =  INT16_MAX;
16538  uint16_t u = UINT16_MAX;
16539  printf("int16_t\n");
16540#endif
16541#ifdef INT32
16542   int32_t i =  INT32_MAX;
16543  uint32_t u = UINT32_MAX;
16544  printf("int32_t\n");
16545#endif
16546}
16547EOCP
16548
16549i8type="signed char"
16550u8type="unsigned char"
16551i8size=1
16552u8size=1
16553
16554case "$i16type" in
16555'')	case "$shortsize" in
16556	2)	i16type=short
16557		u16type="unsigned short"
16558		i16size=$shortsize
16559		u16size=$shortsize
16560		;;
16561	esac
16562	;;
16563esac
16564case "$i16type" in
16565'')	set try -DINT16
16566	if eval $compile; then
16567		case "`$run ./try`" in
16568		int16_t)
16569			i16type=int16_t
16570			u16type=uint16_t
16571			i16size=2
16572			u16size=2
16573			;;
16574		esac
16575	fi
16576	;;
16577esac
16578case "$i16type" in
16579'')	if $test $shortsize -ge 2; then
16580		i16type=short
16581		u16type="unsigned short"
16582		i16size=$shortsize
16583		u16size=$shortsize
16584	fi
16585	;;
16586esac
16587
16588case "$i32type" in
16589'')	case "$longsize" in
16590	4)	i32type=long
16591		u32type="unsigned long"
16592		i32size=$longsize
16593		u32size=$longsize
16594		;;
16595	*)	case "$intsize" in
16596		4)	i32type=int
16597			u32type="unsigned int"
16598			i32size=$intsize
16599			u32size=$intsize
16600			;;
16601		esac
16602		;;
16603	esac
16604	;;
16605esac
16606case "$i32type" in
16607'')	set try -DINT32
16608	if eval $compile; then
16609		case "`$run ./try`" in
16610		int32_t)
16611			i32type=int32_t
16612			u32type=uint32_t
16613			i32size=4
16614			u32size=4
16615			;;
16616		esac
16617	fi
16618	;;
16619esac
16620case "$i32type" in
16621'')	if $test $intsize -ge 4; then
16622		i32type=int
16623		u32type="unsigned int"
16624		i32size=$intsize
16625		u32size=$intsize
16626	fi
16627	;;
16628esac
16629
16630case "$i64type" in
16631'')	case "$d_quad:$quadtype" in
16632	define:?*)
16633		i64type="$quadtype"
16634		u64type="$uquadtype"
16635		i64size=8
16636		u64size=8
16637		;;
16638	esac
16639	;;
16640esac
16641
16642$echo "Checking how many bits of your UVs your NVs can preserve..." >&4
16643$cat <<EOP >try.c
16644#include <stdio.h>
16645#$i_stdlib I_STDLIB
16646#ifdef I_STDLIB
16647#include <stdlib.h>
16648#endif
16649#include <sys/types.h>
16650#include <signal.h>
16651#ifdef SIGFPE
16652/* volatile so that the compiler has to store it out to memory */
16653volatile int bletched = 0;
16654$signal_t blech(int s) { bletched = 1; }
16655#endif
16656int main() {
16657    $uvtype u = 0;
16658    $nvtype d;
16659    int     n = 8 * $uvsize;
16660    int     i;
16661#ifdef SIGFPE
16662    signal(SIGFPE, blech);
16663#endif
16664
16665    for (i = 0; i < n; i++) {
16666      u = u << 1 | ($uvtype)1;
16667      d = ($nvtype)u;
16668      if (($uvtype)d != u)
16669        break;
16670      if (d <= 0)
16671	break;
16672      d = ($nvtype)(u - 1);
16673      if (($uvtype)d != (u - 1))
16674        break;
16675#ifdef SIGFPE
16676      if (bletched)
16677	break;
16678#endif
16679    }
16680    printf("%d\n", ((i == n) ? -n : i));
16681    exit(0);
16682}
16683EOP
16684set try
16685
16686d_nv_preserves_uv="$undef"
16687if eval $compile; then
16688	nv_preserves_uv_bits="`$run ./try`"
16689fi
16690case "$nv_preserves_uv_bits" in
16691\-[1-9]*)
16692	nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
16693	$echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs."  2>&1
16694	d_nv_preserves_uv="$define"
16695	;;
16696[1-9]*)	$echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs."  2>&1
16697	d_nv_preserves_uv="$undef" ;;
16698*)	$echo "Can't figure out how many bits your NVs preserve." 2>&1
16699	nv_preserves_uv_bits="0" ;;
16700esac
16701$rm_try
16702
16703$echo "Checking to find the largest integer value your NVs can hold..." >&4
16704$cat <<EOP >try.c
16705#include <stdio.h>
16706
16707typedef $nvtype NV;
16708
16709int
16710main() {
16711  NV value = 2;
16712  int count = 1;
16713
16714  while(count < 256) {
16715    /* volatile so that the compiler has to store it out to memory */
16716    volatile NV up = value + 1.0;
16717    volatile NV negated = -value;
16718    volatile NV down = negated - 1.0;
16719    volatile NV got_up = up - value;
16720    int up_good = got_up == 1.0;
16721    int got_down = down - negated;
16722    int down_good = got_down == -1.0;
16723
16724    if (down_good != up_good) {
16725      fprintf(stderr,
16726	      "Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n",
16727	      up_good, (double) got_up, down_good, (double) got_down,
16728	      count, (double) value);
16729      return 1;
16730    }
16731    if (!up_good) {
16732      while (1) {
16733	if (count > 8) {
16734	  count -= 8;
16735	  fputs("256.0", stdout);
16736	} else {
16737	  count--;
16738	  fputs("2.0", stdout);
16739	}
16740	if (!count) {
16741	  puts("");
16742	  return 0;
16743	}
16744	fputs("*", stdout);
16745      }
16746    }
16747    value *= 2;
16748    ++count;
16749  }
16750  fprintf(stderr, "Cannot overflow integer range, even at 2**%d (%.20f)\n",
16751	  count, (double) value);
16752  return 1;
16753}
16754EOP
16755set try
16756
16757nv_overflows_integers_at='0'
16758if eval $compile; then
16759    xxx="`$run ./try`"
16760    case "$?" in
16761	0)
16762	    case "$xxx" in
16763		2*)  cat >&4 <<EOM
16764The largest integer your NVs can preserve is equal to $xxx
16765EOM
16766		    nv_overflows_integers_at="$xxx"
16767		    ;;
16768		*)  cat >&4 <<EOM
16769Cannot determine the largest integer value your NVs can hold, unexpected output
16770'$xxx'
16771EOM
16772		    ;;
16773	    esac
16774	    ;;
16775	*)  cat >&4 <<EOM
16776Cannot determine the largest integer value your NVs can hold
16777EOM
16778	    ;;
16779    esac
16780fi
16781$rm_try
16782
16783$echo "Checking whether NV 0.0 is all bits zero in memory..." >&4
16784$cat <<EOP >try.c
16785#include <stdio.h>
16786#$i_stdlib I_STDLIB
16787#ifdef I_STDLIB
16788#include <stdlib.h>
16789#endif
16790#include <string.h>
16791#include <sys/types.h>
16792#include <signal.h>
16793#ifdef SIGFPE
16794/* volatile so that the compiler has to store it out to memory */
16795volatile int bletched = 0;
16796$signal_t blech(int s) { bletched = 1; }
16797#endif
16798
16799int checkit($nvtype d, const char *where) {
16800    void *v = &d;
16801    unsigned char *p = (unsigned char *)v;
16802    unsigned char *end = p + sizeof(d);
16803    int fail = 0;
16804
16805    while (p < end)
16806	fail += *p++;
16807
16808    if (!fail)
16809	return 0;
16810
16811    p = (unsigned char *)v;
16812    printf("No - %s: 0x", where);
16813    while (p < end)
16814	printf ("%02X", *p++);
16815    printf("\n");
16816    return 1;
16817}
16818
16819int main(int argc, char **argv) {
16820    $nvtype d = 0.0;
16821    int fail = 0;
16822    fail += checkit(d, "0.0");
16823
16824    /* The compiler shouldn't be assuming that bletched is 0  */
16825    d = bletched;
16826
16827    fail += checkit(d, "bleched");
16828
16829#ifdef SIGFPE
16830    signal(SIGFPE, blech);
16831#endif
16832
16833    /* Paranoia - the compiler should have no way of knowing that ANSI says
16834       that argv[argc] will always be NULL.  Actually, if it did assume this it
16835       would be buggy, as this is C and main() can be called from elsewhere in
16836       the program.  */
16837    d = argv[argc] ? 1 : 0;
16838
16839    if (d) {
16840	printf("Odd argv[argc]=%p, d=%g\n", argv[argc], d);
16841    }
16842
16843    fail += checkit(d, "ternary");
16844
16845    memset(&d, sizeof(d), argv[argc] ? 1 : 0);
16846
16847    if (d != 0.0) {
16848	printf("No - memset doesn't give 0.0\n");
16849	/* This might just blow up:  */
16850	printf("(gives %g)\n", d);
16851	return 1;
16852    }
16853
16854#ifdef SIGFPE
16855    if (bletched) {
16856	printf("No - something bleched\n");
16857	return 1;
16858    }
16859#endif
16860    if (fail) {
16861      printf("No - %d fail(s)\n", fail);
16862      return 1;
16863    }
16864    printf("Yes\n");
16865    return 0;
16866}
16867EOP
16868set try
16869
16870d_nv_zero_is_allbits_zero="$undef"
16871if eval $compile; then
16872    xxx="`$run ./try`"
16873    case "$?" in
16874	0)
16875	    case "$xxx" in
16876		Yes)  cat >&4 <<EOM
168770.0 is represented as all bits zero in memory
16878EOM
16879		    d_nv_zero_is_allbits_zero="$define"
16880		    ;;
16881		*)  cat >&4 <<EOM
168820.0 is not represented as all bits zero in memory
16883EOM
16884		    d_nv_zero_is_allbits_zero="$undef"
16885		    ;;
16886	    esac
16887	    ;;
16888	*)  cat >&4 <<EOM
168890.0 is not represented as all bits zero in memory
16890EOM
16891	    d_nv_zero_is_allbits_zero="$undef"
16892	    ;;
16893    esac
16894fi
16895$rm_try
16896
16897: check for off64_t
16898echo " "
16899echo "Checking to see if you have off64_t..." >&4
16900$cat >try.c <<EOCP
16901#include <sys/types.h>
16902#include <unistd.h>
16903int main() { off64_t x = 7; }
16904EOCP
16905set try
16906if eval $compile; then
16907	val="$define"
16908	echo "You have off64_t."
16909else
16910	val="$undef"
16911	echo "You do not have off64_t."
16912	case "$lseeksize" in
16913	8) echo "(Your off_t is 64 bits, so you could use that.)" ;;
16914	esac
16915fi
16916$rm_try
16917set d_off64_t
16918eval $setvar
16919
16920: how to create joinable pthreads
16921if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
16922	echo " "
16923	echo "Checking what constant to use for creating joinable pthreads..." >&4
16924	$cat >try.c <<'EOCP'
16925#include <pthread.h>
16926int main() {
16927    int detachstate = JOINABLE;
16928}
16929EOCP
16930	set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
16931	if eval $compile; then
16932		echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
16933		val="$undef" # Yes, undef.
16934		set d_old_pthread_create_joinable
16935		eval $setvar
16936		val=""
16937		set old_pthread_create_joinable
16938		eval $setvar
16939	else
16940		set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
16941		if eval $compile; then
16942			echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
16943			val="$define"
16944			set d_old_pthread_create_joinable
16945			eval $setvar
16946			val=PTHREAD_CREATE_UNDETACHED
16947			set old_pthread_create_joinable
16948			eval $setvar
16949		else
16950			set try -DJOINABLE=__UNDETACHED
16951			if eval $compile; then
16952				echo "You seem to use __UNDETACHED." >&4
16953				val="$define"
16954				set d_old_pthread_create_joinable
16955				eval $setvar
16956				val=__UNDETACHED
16957				set old_pthread_create_joinable
16958				eval $setvar
16959			else
16960				echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
16961				val="$define"
16962				set d_old_pthread_create_joinable
16963				eval $setvar
16964				val=0
16965				set old_pthread_create_joinable
16966				eval $setvar
16967			fi
16968		fi
16969	fi
16970	$rm_try
16971else
16972    d_old_pthread_create_joinable="$undef"
16973    old_pthread_create_joinable=""
16974fi
16975
16976: see if pause exists
16977set pause d_pause
16978eval $inlibc
16979
16980: see if pipe2 exists
16981set pipe2 d_pipe2
16982eval $inlibc
16983
16984: see if poll exists
16985set poll d_poll
16986eval $inlibc
16987
16988: see if prctl exists
16989set prctl d_prctl
16990eval $inlibc
16991
16992: see if prctl supports PR_SET_NAME
16993d_prctl_set_name=$undef
16994case $d_prctl in
16995    $define)
16996	$cat >try.c <<EOM
16997#ifdef __ANDROID__
16998#include <unistd.h>
16999#endif
17000#include <sys/prctl.h>
17001
17002int main (int argc, char *argv[])
17003{
17004    return (prctl (PR_SET_NAME, "Test"));
17005    } /* main */
17006EOM
17007	set try
17008	if eval $compile_ok && $run ./try; then
17009	    echo "Your prctl (PR_SET_NAME, ...) works"
17010	    d_prctl_set_name=$define
17011	    fi
17012	$rm_try
17013	;;
17014    esac
17015
17016: see if readlink exists
17017set readlink d_readlink
17018eval $inlibc
17019
17020: Check if there is a /proc symlink to the abs path of
17021: the executing program.  We will honor hints of d_procselfexe=$undef
17022: or procselfexe being non-empty, otherwise will try to determine both
17023: if we have readlink.
17024: AmigaOS will attempt to mount proc: aka /proc, if /proc/... is
17025: referenced, and AmigaOS does not have a proc filesystem anyway.
17026echo " "
17027val="$undef"
17028if $test "X$d_procselfexe" = Xundef; then
17029	procselfexe=''
17030elif $test "X$procselfexe" != X -a "X$procselfexe" != 'X '; then
17031	val="$define"
17032elif $test "X$d_readlink" = Xdefine; then
17033        : NetBSD first as /proc/self is a symlink to /proc/curproc,
17034        : and it feels more tidy to avoid an extra level of symlink
17035	set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
17036	while test $# -gt 0; do
17037	    type=$1; try=$2
17038	    shift; shift
17039	    if $issymlink $try; then
17040		$ls -l $try > reflect
17041		if $contains /`basename $ls` reflect >/dev/null 2>&1; then
17042		    echo "You have $type-like $try."
17043		    procselfexe='"'$try'"'
17044		    val="$define"
17045		    : This will break out of the loop
17046		    set X; shift
17047		fi
17048	    fi
17049	done
17050fi
17051$rm -f reflect
17052set d_procselfexe
17053eval $setvar
17054
17055: backward compatibility for d_hvfork
17056if test X$d_hvfork != X; then
17057	d_vfork="$d_hvfork"
17058	d_hvfork=''
17059fi
17060: see if there is a vfork
17061val=''
17062set vfork val
17063eval $inlibc
17064
17065d_pseudofork=$undef
17066
17067: Ok, but do we want to use it. vfork is reportedly unreliable in
17068: perl on Solaris 2.x, and probably elsewhere.
17069case "$val" in
17070$define)
17071	echo " "
17072	case "$usevfork" in
17073	false) dflt='n';;
17074	*) dflt='y';;
17075	esac
17076	cat <<'EOM'
17077
17078Perl can only use a vfork() that doesn't suffer from strict
17079restrictions on calling functions or modifying global data in
17080the child.  For example, glibc-2.1 contains such a vfork()
17081that is unsuitable.  If your system provides a proper fork()
17082call, chances are that you do NOT want perl to use vfork().
17083
17084EOM
17085	rp="Do you still want to use vfork()?"
17086	. ./myread
17087	case "$ans" in
17088	y|Y) ;;
17089	*)
17090		echo "Ok, we won't use vfork()."
17091		val="$undef"
17092		;;
17093	esac
17094	;;
17095esac
17096set d_vfork
17097eval $setvar
17098case "$d_vfork" in
17099$define) usevfork='true';;
17100*) usevfork='false';;
17101esac
17102
17103: see whether the pthread_atfork exists
17104$cat >try.c <<EOP
17105#include <pthread.h>
17106#include <stdio.h>
17107int main() {
17108#ifdef  PTHREAD_ATFORK
17109        pthread_atfork(NULL,NULL,NULL);
17110#endif
17111}
17112EOP
17113
17114: see if pthread_atfork exists
17115set try -DPTHREAD_ATFORK
17116if eval $compile; then
17117    val="$define"
17118else
17119    val="$undef"
17120fi
17121case "$usethreads" in
17122$define)
17123        case "$val" in
17124        $define) echo 'pthread_atfork found.' >&4        ;;
17125        *)       echo 'pthread_atfork NOT found.' >&4    ;;
17126        esac
17127esac
17128set d_pthread_atfork
17129eval $setvar
17130
17131: see if pthread_attr_setscope exists
17132set pthread_attr_setscope d_pthread_attr_setscope
17133eval $inlibc
17134
17135: see whether the various POSIXish _yields exist
17136$cat >try.c <<EOP
17137#include <pthread.h>
17138#include <stdio.h>
17139int main() {
17140#ifdef SCHED_YIELD
17141	sched_yield();
17142#else
17143#ifdef PTHREAD_YIELD
17144	pthread_yield();
17145#else
17146#ifdef PTHREAD_YIELD_NULL
17147	pthread_yield(NULL);
17148#endif
17149#endif
17150#endif
17151}
17152EOP
17153: see if sched_yield exists
17154set try -DSCHED_YIELD
17155if eval $compile; then
17156    val="$define"
17157    sched_yield='sched_yield()'
17158else
17159    val="$undef"
17160fi
17161case "$usethreads" in
17162$define)
17163	case "$val" in
17164	$define) echo 'sched_yield() found.' >&4	;;
17165	*)	 echo 'sched_yield() NOT found.' >&4	;;
17166	esac
17167esac
17168set d_sched_yield
17169eval $setvar
17170
17171: see if pthread_yield exists
17172set try -DPTHREAD_YIELD
17173if eval $compile; then
17174    val="$define"
17175    case "$sched_yield" in
17176    '') sched_yield='pthread_yield()' ;;
17177    esac
17178else
17179    set try -DPTHREAD_YIELD_NULL
17180    if eval $compile; then
17181	val="$define"
17182	case "$sched_yield" in
17183	'') sched_yield='pthread_yield(NULL)' ;;
17184	esac
17185    else
17186	val="$undef"
17187    fi
17188fi
17189case "$usethreads" in
17190$define)
17191	case "$val" in
17192	$define) echo 'pthread_yield() found.' >&4	;;
17193	*)	 echo 'pthread_yield() NOT found.' >&4	;;
17194	esac
17195	;;
17196esac
17197set d_pthread_yield
17198eval $setvar
17199case "$sched_yield" in
17200'') sched_yield=undef ;;
17201esac
17202$rm_try
17203
17204: check for ptrdiff_t
17205echo " "
17206echo "Checking to see if you have ptrdiff_t..." >&4
17207$cat >try.c <<EOCP
17208#include <stddef.h>
17209int main() { ptrdiff_t x = 7; }
17210EOCP
17211set try
17212if eval $compile; then
17213	val="$define"
17214	echo "You have ptrdiff_t."
17215else
17216	val="$undef"
17217	echo "You do not have ptrdiff_t."
17218fi
17219$rm_try
17220set d_ptrdiff_t
17221eval $setvar
17222
17223: see if random_r exists
17224set random_r d_random_r
17225eval $inlibc
17226case "$d_random_r" in
17227"$define")
17228	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
17229	case "$d_random_r_proto:$usethreads" in
17230	":define")	d_random_r_proto=define
17231		set d_random_r_proto random_r $hdrs
17232		eval $hasproto ;;
17233	*)	;;
17234	esac
17235	case "$d_random_r_proto" in
17236	define)
17237	case "$random_r_proto" in
17238	''|0) try='int random_r(int*, struct random_data*);'
17239	./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;;
17240	esac
17241	case "$random_r_proto" in
17242	''|0) try='int random_r(long*, struct random_data*);'
17243	./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;;
17244	esac
17245	case "$random_r_proto" in
17246	''|0) try='int random_r(struct random_data*, int32_t*);'
17247	./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;;
17248	esac
17249	case "$random_r_proto" in
17250	''|0)	d_random_r=undef
17251		random_r_proto=0
17252		echo "Disabling random_r, cannot determine prototype." >&4 ;;
17253	* )	case "$random_r_proto" in
17254		REENTRANT_PROTO*) ;;
17255		*) random_r_proto="REENTRANT_PROTO_$random_r_proto" ;;
17256		esac
17257		echo "Prototype: $try" ;;
17258	esac
17259	;;
17260	*)	case "$usethreads" in
17261		define) echo "random_r has no prototype, not using it." >&4 ;;
17262		esac
17263		d_random_r=undef
17264		random_r_proto=0
17265		;;
17266	esac
17267	;;
17268*)	random_r_proto=0
17269	;;
17270esac
17271
17272: see if readdir and friends exist
17273set readdir d_readdir
17274eval $inlibc
17275set seekdir d_seekdir
17276eval $inlibc
17277set telldir d_telldir
17278eval $inlibc
17279set rewinddir d_rewinddir
17280eval $inlibc
17281
17282: see if readdir64_r exists
17283set readdir64_r d_readdir64_r
17284eval $inlibc
17285case "$d_readdir64_r" in
17286"$define")
17287	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
17288	case "$d_readdir64_r_proto:$usethreads" in
17289	":define")	d_readdir64_r_proto=define
17290		set d_readdir64_r_proto readdir64_r $hdrs
17291		eval $hasproto ;;
17292	*)	;;
17293	esac
17294	case "$d_readdir64_r_proto" in
17295	define)
17296	case "$readdir64_r_proto" in
17297	''|0) try='int readdir64_r(DIR*, struct dirent64*, struct dirent64**);'
17298	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TSR ;;
17299	esac
17300	case "$readdir64_r_proto" in
17301	''|0) try='int readdir64_r(DIR*, struct dirent64*);'
17302	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TS ;;
17303	esac
17304	case "$readdir64_r_proto" in
17305	''|0)	d_readdir64_r=undef
17306		readdir64_r_proto=0
17307		echo "Disabling readdir64_r, cannot determine prototype." >&4 ;;
17308	* )	case "$readdir64_r_proto" in
17309		REENTRANT_PROTO*) ;;
17310		*) readdir64_r_proto="REENTRANT_PROTO_$readdir64_r_proto" ;;
17311		esac
17312		echo "Prototype: $try" ;;
17313	esac
17314	;;
17315	*)	case "$usethreads" in
17316		define) echo "readdir64_r has no prototype, not using it." >&4 ;;
17317		esac
17318		d_readdir64_r=undef
17319		readdir64_r_proto=0
17320		;;
17321	esac
17322	;;
17323*)	readdir64_r_proto=0
17324	;;
17325esac
17326
17327: see if readdir_r exists
17328set readdir_r d_readdir_r
17329eval $inlibc
17330case "$d_readdir_r" in
17331"$define")
17332	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
17333	case "$d_readdir_r_proto:$usethreads" in
17334	":define")	d_readdir_r_proto=define
17335		set d_readdir_r_proto readdir_r $hdrs
17336		eval $hasproto ;;
17337	*)	;;
17338	esac
17339	case "$d_readdir_r_proto" in
17340	define)
17341	case "$readdir_r_proto" in
17342	''|0) try='int readdir_r(DIR*, struct dirent*, struct dirent**);'
17343	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TSR ;;
17344	esac
17345	case "$readdir_r_proto" in
17346	''|0) try='int readdir_r(DIR*, struct dirent*);'
17347	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TS ;;
17348	esac
17349	case "$readdir_r_proto" in
17350	''|0)	d_readdir_r=undef
17351		readdir_r_proto=0
17352		echo "Disabling readdir_r, cannot determine prototype." >&4 ;;
17353	* )	case "$readdir_r_proto" in
17354		REENTRANT_PROTO*) ;;
17355		*) readdir_r_proto="REENTRANT_PROTO_$readdir_r_proto" ;;
17356		esac
17357		echo "Prototype: $try" ;;
17358	esac
17359	;;
17360	*)	case "$usethreads" in
17361		define) echo "readdir_r has no prototype, not using it." >&4 ;;
17362		esac
17363		d_readdir_r=undef
17364		readdir_r_proto=0
17365		;;
17366	esac
17367	;;
17368*)	readdir_r_proto=0
17369	;;
17370esac
17371
17372: see if readv exists
17373set readv d_readv
17374eval $inlibc
17375
17376: see if recvmsg exists
17377set recvmsg d_recvmsg
17378eval $inlibc
17379
17380: see if regcomp, regcmp, or re_comp exist, for regular pattern matching
17381echo " "
17382if set regcomp val -f d_regcomp; eval $csym; $val; then
17383	echo 'regcomp() found.' >&4
17384	d_regcomp="$define"
17385	d_regcmp="$undef"
17386	d_re_comp="$undef"
17387elif set regcmp val -f d_regcmp; eval $csym; $val; then
17388	echo 'regcmp() found.' >&4
17389	d_regcmp="$define"
17390	d_regcomp="$undef"
17391	d_re_comp="$undef"
17392elif set re_comp val -f d_re_comp; eval $csym; $val; then
17393	echo 're_comp() found, assuming re_exec() also exists.' >&4
17394	d_re_comp="$define"
17395	d_regcomp="$undef"
17396	d_regcmp="$undef"
17397else
17398	$cat >&4 <<EOM
17399No regcomp(), regcmp() nor re_comp() found !! No regular pattern matching.
17400EOM
17401	d_regcmp="$undef"
17402	d_re_comp="$undef"
17403	d_regcomp="$undef"
17404fi
17405
17406: see if remainder exists
17407set remainder d_remainder
17408eval $inlibc
17409
17410: see if remquo exists
17411set remquo d_remquo
17412eval $inlibc
17413
17414: see if rename exists
17415set rename d_rename
17416eval $inlibc
17417
17418: see if rint exists
17419set rint d_rint
17420eval $inlibc
17421
17422: see if rmdir exists
17423set rmdir d_rmdir
17424eval $inlibc
17425
17426: see if round exists
17427set round d_round
17428eval $inlibc
17429
17430: see if prototype for sbrk is available
17431echo " "
17432set d_sbrkproto sbrk $i_unistd unistd.h
17433eval $hasproto
17434
17435: see if scalbn exists
17436set scalbn d_scalbn
17437eval $inlibc
17438
17439: see if select exists
17440set select d_select
17441eval $inlibc
17442
17443: see if semctl exists
17444set semctl d_semctl
17445eval $inlibc
17446
17447: see if semget exists
17448set semget d_semget
17449eval $inlibc
17450
17451: see if semop exists
17452set semop d_semop
17453eval $inlibc
17454
17455: see how much of the 'sem*(2)' library is present.
17456h_sem=true
17457echo " "
17458case "$d_semctl$d_semget$d_semop" in
17459*"$undef"*) h_sem=false;;
17460esac
17461case "$osname" in
17462freebsd)
17463    case "`ipcs 2>&1`" in
17464    "SVID messages"*"not configured"*)
17465	echo "Your $osname does not have the sem*(2) configured." >&4
17466        h_sem=false
17467	val="$undef"
17468	set semctl d_semctl
17469	eval $setvar
17470	set semget d_semget
17471	eval $setvar
17472	set semop d_semop
17473	eval $setvar
17474	;;
17475    esac
17476    ;;
17477esac
17478: we could also check for sys/ipc.h ...
17479if $h_sem && $test `./findhdr sys/sem.h`; then
17480	echo "You have the full sem*(2) library." >&4
17481	val="$define"
17482else
17483	echo "You don't have the full sem*(2) library." >&4
17484	val="$undef"
17485fi
17486set d_sem
17487eval $setvar
17488
17489: see whether sys/sem.h defines union semun
17490echo " "
17491$cat > try.c <<'END'
17492#include <sys/types.h>
17493#include <sys/ipc.h>
17494#include <sys/sem.h>
17495int main () { union semun semun; semun.buf = 0; }
17496END
17497set try
17498if eval $compile; then
17499    echo "You have union semun in <sys/sem.h>." >&4
17500    val="$define"
17501else
17502    echo "You do not have union semun in <sys/sem.h>." >&4
17503    val="$undef"
17504fi
17505$rm_try
17506set d_union_semun
17507eval $setvar
17508
17509: see how to do semctl IPC_STAT
17510case "$d_sem" in
17511$define)
17512    echo " "
17513    $cat > tryh.h <<END
17514#ifndef S_IRUSR
17515#   ifdef S_IREAD
17516#	define S_IRUSR S_IREAD
17517#	define S_IWUSR S_IWRITE
17518#	define S_IXUSR S_IEXEC
17519#   else
17520#	define S_IRUSR 0400
17521#	define S_IWUSR 0200
17522#	define S_IXUSR 0100
17523#   endif
17524#   define S_IRGRP (S_IRUSR>>3)
17525#   define S_IWGRP (S_IWUSR>>3)
17526#   define S_IXGRP (S_IXUSR>>3)
17527#   define S_IROTH (S_IRUSR>>6)
17528#   define S_IWOTH (S_IWUSR>>6)
17529#   define S_IXOTH (S_IXUSR>>6)
17530#endif
17531#ifndef S_IRWXU
17532#   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
17533#   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
17534#   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
17535#endif
17536END
17537    : see whether semctl IPC_STAT can use union semun
17538    case "$d_semctl_semun" in
17539    '')
17540      val="$undef"
17541      $cat > try.c <<END
17542#include <sys/types.h>
17543#include <sys/ipc.h>
17544#include <sys/sem.h>
17545#include <sys/stat.h>
17546#include <stdio.h>
17547#include <errno.h>
17548#include "tryh.h"
17549#ifndef errno
17550extern int errno;
17551#endif
17552#$d_union_semun HAS_UNION_SEMUN
17553int main() {
17554    union semun
17555#ifndef HAS_UNION_SEMUN
17556    {
17557	int val;
17558	struct semid_ds *buf;
17559	unsigned short *array;
17560    }
17561#endif
17562    arg;
17563    int sem, st;
17564
17565#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
17566    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17567    if (sem > -1) {
17568	struct semid_ds argbuf;
17569	arg.buf = &argbuf;
17570#	ifdef IPC_STAT
17571	st = semctl(sem, 0, IPC_STAT, arg);
17572	if (st == 0)
17573	    printf("semun\n");
17574	else
17575#	endif /* IPC_STAT */
17576	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
17577#	ifdef IPC_RMID
17578	if (semctl(sem, 0, IPC_RMID, arg) != 0)
17579#	endif /* IPC_RMID */
17580	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
17581    } else
17582#endif /* IPC_PRIVATE && ... */
17583	printf("semget failed: errno = %d\n", errno);
17584  return 0;
17585}
17586END
17587      set try
17588      if eval $compile; then
17589	  xxx=`$run ./try`
17590          case "$xxx" in
17591          semun) val="$define" ;;
17592          esac
17593      fi
17594      $rm_try
17595      set d_semctl_semun
17596      eval $setvar
17597      ;;
17598    esac
17599    case "$d_semctl_semun" in
17600    $define)
17601        echo "You can use union semun for semctl IPC_STAT." >&4
17602	also='also'
17603        ;;
17604    *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
17605	also=''
17606        ;;
17607    esac
17608
17609    : see whether semctl IPC_STAT can use struct semid_ds pointer
17610    case "$d_semctl_semid_ds" in
17611    '')
17612      val="$undef"
17613      $cat > try.c <<'END'
17614#include <sys/types.h>
17615#include <sys/ipc.h>
17616#include <sys/sem.h>
17617#include <sys/stat.h>
17618#include "tryh.h"
17619#include <stdio.h>
17620#include <errno.h>
17621#ifndef errno
17622extern int errno;
17623#endif
17624int main() {
17625    union semun
17626#ifndef HAS_UNION_SEMUN
17627    {
17628	int val;
17629	struct semid_ds *buf;
17630	unsigned short *array;
17631    }
17632#endif
17633    arg;
17634    struct semid_ds argbuf;
17635    int sem, st;
17636
17637#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
17638    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17639    if (sem > -1) {
17640	arg.buf = &argbuf;
17641#	ifdef IPC_STAT
17642	st = semctl(sem, 0, IPC_STAT, arg);
17643	if (st == 0)
17644	    printf("semid_ds\n");
17645	else
17646#	endif /* IPC_STAT */
17647	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
17648#	ifdef IPC_RMID
17649	if (semctl(sem, 0, IPC_RMID, arg) != 0)
17650#	endif /* IPC_RMID */
17651	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
17652    } else
17653#endif /* IPC_PRIVATE && ... */
17654	printf("semget failed: errno = %d\n", errno);
17655
17656    return 0;
17657}
17658END
17659      set try
17660      if eval $compile; then
17661          xxx=`$run ./try`
17662          case "$xxx" in
17663          semid_ds) val="$define" ;;
17664          esac
17665      fi
17666      $rm_try
17667      set d_semctl_semid_ds
17668      eval $setvar
17669      ;;
17670    esac
17671    case "$d_semctl_semid_ds" in
17672    $define)
17673        echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
17674        ;;
17675    *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
17676        ;;
17677    esac
17678    ;;
17679*)  val="$undef"
17680
17681    # We do not have the full sem*(2) library, so assume we can not
17682    # use either.
17683
17684    set d_semctl_semun
17685    eval $setvar
17686
17687    set d_semctl_semid_ds
17688    eval $setvar
17689    ;;
17690esac
17691$rm_try tryh.h
17692
17693: see if sendmsg exists
17694set sendmsg d_sendmsg
17695eval $inlibc
17696
17697: see if setegid exists
17698set setegid d_setegid
17699eval $inlibc
17700
17701: see if seteuid exists
17702set seteuid d_seteuid
17703eval $inlibc
17704
17705: see if setgrent exists
17706set setgrent d_setgrent
17707eval $inlibc
17708
17709: see if setgrent_r exists
17710set setgrent_r d_setgrent_r
17711eval $inlibc
17712case "$d_setgrent_r" in
17713"$define")
17714	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
17715	case "$d_setgrent_r_proto:$usethreads" in
17716	":define")	d_setgrent_r_proto=define
17717		set d_setgrent_r_proto setgrent_r $hdrs
17718		eval $hasproto ;;
17719	*)	;;
17720	esac
17721	case "$d_setgrent_r_proto" in
17722	define)
17723	case "$setgrent_r_proto" in
17724	''|0) try='int setgrent_r(FILE**);'
17725	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=I_H ;;
17726	esac
17727	case "$setgrent_r_proto" in
17728	''|0) try='void setgrent_r(FILE**);'
17729	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=V_H ;;
17730	esac
17731	case "$setgrent_r_proto" in
17732	''|0)	d_setgrent_r=undef
17733		setgrent_r_proto=0
17734		echo "Disabling setgrent_r, cannot determine prototype." >&4 ;;
17735	* )	case "$setgrent_r_proto" in
17736		REENTRANT_PROTO*) ;;
17737		*) setgrent_r_proto="REENTRANT_PROTO_$setgrent_r_proto" ;;
17738		esac
17739		echo "Prototype: $try" ;;
17740	esac
17741	;;
17742	*)	case "$usethreads" in
17743		define) echo "setgrent_r has no prototype, not using it." >&4 ;;
17744		esac
17745		d_setgrent_r=undef
17746		setgrent_r_proto=0
17747		;;
17748	esac
17749	;;
17750*)	setgrent_r_proto=0
17751	;;
17752esac
17753
17754: see if sethostent exists
17755set sethostent d_sethent
17756eval $inlibc
17757
17758: see if sethostent_r exists
17759set sethostent_r d_sethostent_r
17760eval $inlibc
17761case "$d_sethostent_r" in
17762"$define")
17763	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
17764	case "$d_sethostent_r_proto:$usethreads" in
17765	":define")	d_sethostent_r_proto=define
17766		set d_sethostent_r_proto sethostent_r $hdrs
17767		eval $hasproto ;;
17768	*)	;;
17769	esac
17770	case "$d_sethostent_r_proto" in
17771	define)
17772	case "$sethostent_r_proto" in
17773	''|0) try='int sethostent_r(int, struct hostent_data*);'
17774	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=I_ID ;;
17775	esac
17776	case "$sethostent_r_proto" in
17777	''|0) try='void sethostent_r(int, struct hostent_data*);'
17778	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=V_ID ;;
17779	esac
17780	case "$sethostent_r_proto" in
17781	''|0)	d_sethostent_r=undef
17782		sethostent_r_proto=0
17783		echo "Disabling sethostent_r, cannot determine prototype." >&4 ;;
17784	* )	case "$sethostent_r_proto" in
17785		REENTRANT_PROTO*) ;;
17786		*) sethostent_r_proto="REENTRANT_PROTO_$sethostent_r_proto" ;;
17787		esac
17788		echo "Prototype: $try" ;;
17789	esac
17790	;;
17791	*)	case "$usethreads" in
17792		define) echo "sethostent_r has no prototype, not using it." >&4 ;;
17793		esac
17794		d_sethostent_r=undef
17795		sethostent_r_proto=0
17796		;;
17797	esac
17798	;;
17799*)	sethostent_r_proto=0
17800	;;
17801esac
17802
17803: see if setitimer exists
17804set setitimer d_setitimer
17805eval $inlibc
17806
17807: see if setlinebuf exists
17808set setlinebuf d_setlinebuf
17809eval $inlibc
17810
17811: see if locale.h is available
17812set locale.h i_locale
17813eval $inhdr
17814
17815: see if this system has wctype.h
17816set wctype.h i_wctype
17817eval $inhdr
17818
17819: see if towupper exists
17820set towupper d_towupper
17821eval $inlibc
17822
17823: check for setlocale function and behavior
17824$cat <<EOM
17825
17826Checking to see if you have setlocale() and its behavior
17827EOM
17828$cat >try.c <<EOCP
17829#include <stdlib.h>
17830#include <string.h>
17831#$i_locale I_LOCALE
17832#ifdef I_LOCALE
17833#  include <locale.h>
17834#endif
17835#$i_wctype I_WCTYPE
17836#ifdef I_WCTYPE
17837#  include <wctype.h>
17838#endif
17839
17840int main() {
17841    const char * invalid_name = "\a";   /* This is really invalid! */
17842    int accepts_any_locale_name = 0;
17843    int has_C_UTF8 = 0;
17844    unsigned char bad_setlocale = 255;
17845
17846    /* If LC_CTYPE isn't defined the compilation will fail, and locales will be
17847     * disabled.  It's hard to imagine an instance where meaningful locale
17848     * handling could be done without LC_CTYPE */
17849    const char *  name = setlocale(LC_CTYPE, "C");
17850
17851    if (name == NULL || strcmp(name, "C") != 0) {
17852        exit(bad_setlocale);
17853    }
17854
17855    name = setlocale(LC_CTYPE, invalid_name);
17856    if (name != NULL) {
17857
17858        /* Let it pass if it accepts the name but gives back one of the C
17859         * locales */
17860        if (strcmp(name, "C") != 0 && strcmp(name, "C.UTF-8") != 0) {
17861            accepts_any_locale_name = 1;
17862        }
17863    }
17864
17865    name = setlocale(LC_CTYPE, "C.UTF-8");
17866    if (name != NULL) {
17867        unsigned char y_with_diaeresis = ('A' == 193) ? 0xDF : 0xFF;
17868
17869#$d_towupper HAS_TOWUPPER
17870#ifdef HAS_TOWUPPER
17871
17872        /* We assume that if the machine doesn't have the C99 towupper, it
17873         * doesn't have C.UTF-8, even if we successfully changed locales to
17874         * include it.  This seems safer even on platforms that didn't accept
17875         * the really invalid name */
17876
17877        if (towupper(y_with_diaeresis) == 0x178) {
17878            has_C_UTF8 = 1;
17879        }
17880
17881#endif
17882
17883    }
17884
17885#if 0
17886
17887    /* Currently unused code to determine if LC_ALL with disparate values uses
17888     * category = value pairs or positional, and to determine the separator
17889     * between the categories.  We could add code so that if the separator were
17890     * > '9', we subtract 10; similarly for 'Z' and 'z', and then just about
17891     * every possible ASCII separator would fit in the 5 bits available in the
17892     * exit code.  This would not be true in EBCDIC.  And then if LC_ALL is
17893     * positional, we probably would want to know the order of the categories.
17894     * Using a file between the C program and the shell script would really be
17895     * require to do that */
17896#ifdef LC_ALL
17897
17898    unsigned char min_separator = ' ' - 1;
17899    unsigned char separator = min_separator;
17900    int uses_name_value_pair_names = 0;
17901
17902    name = setlocale(LC_ALL, "C");
17903    if (name == NULL || strcmp(name, "C") != 0) {
17904        exit(bad_setlocale);
17905    }
17906
17907    if (has_C_UTF8) {
17908        char * pos;
17909
17910        name = setlocale(LC_CTYPE, "C.UTF-8");
17911        if (name == NULL) {
17912            exit(bad_setlocale);
17913        }
17914        name = setlocale(LC_ALL, NULL);
17915        if (name == NULL) {
17916            exit(bad_setlocale);
17917        }
17918
17919        pos = strstr(name, "LC_CTYPE" "=C.UTF-8");
17920        if (pos != NULL) {
17921            uses_name_value_pair_names = 1;
17922            if (pos == name) {
17923                separator = name[sizeof("LC_CTYPE=C.UTF-8") - 1];
17924            }
17925            else {
17926                separator = *(pos - 1);
17927            }
17928        }
17929        else {
17930            pos = strstr(name, "C.UTF-8");
17931            if (pos == NULL) {
17932                /* bad */
17933            }
17934            else if (pos == name) {
17935                separator = name[sizeof("C.UTF-8") - 1];
17936            }
17937            else {
17938                separator = *(pos - 1);
17939            }
17940        }
17941    }
17942
17943#endif
17944#endif
17945
17946    exit( 0 /* (separator - min_separator) << 3
17947        | uses_name_value_pair_names      << 2
17948          */
17949        | has_C_UTF8                      << 1
17950        | accepts_any_locale_name);
17951
17952}
17953EOCP
17954set try
17955if eval $compile; then
17956    echo "Your system has setlocale()..." >&4
17957    $run ./try
17958    case $? in
17959        0) echo "and it seems sane" >&4
17960           d_setlocale="$define"
17961           d_setlocale_accepts_any_locale_name="$undef"
17962           d_has_C_UTF8="false"
17963           ;;
17964        1) echo "and it seems sane, but accepts any locale name as valid" >&4
17965           d_setlocale="$define"
17966           d_setlocale_accepts_any_locale_name="$define"
17967           d_has_C_UTF8="false"
17968           ;;
17969        2) echo "and it seems sane" >&4
17970           d_setlocale="$define"
17971           d_setlocale_accepts_any_locale_name="$undef"
17972           d_has_C_UTF8="true"
17973           ;;
17974        3) echo "and it seems sane, but accepts any locale name as valid" >&4
17975           d_setlocale="$define"
17976           d_setlocale_accepts_any_locale_name="$define"
17977           d_has_C_UTF8="true"
17978           ;;
17979        *) echo "but it doesn't seem to work, so we won't use it." >&4
17980           d_setlocale="$undef"
17981           d_setlocale_accepts_any_locale_name="$undef"
17982           d_has_C_UTF8="false"
17983           ;;
17984    esac
17985else
17986    echo "your system does not have setlocale()" >&4
17987    d_setlocale="$undef"
17988    d_setlocale_accepts_any_locale_name="$undef"
17989    d_has_C_UTF8="false"
17990fi
17991$rm_try
17992
17993: see if setlocale_r exists
17994set setlocale_r d_setlocale_r
17995eval $inlibc
17996case "$d_setlocale_r" in
17997"$define")
17998	hdrs="$i_systypes sys/types.h define stdio.h $i_locale locale.h"
17999	case "$d_setlocale_r_proto:$usethreads" in
18000	":define")	d_setlocale_r_proto=define
18001		set d_setlocale_r_proto setlocale_r $hdrs
18002		eval $hasproto ;;
18003	*)	;;
18004	esac
18005	case "$d_setlocale_r_proto" in
18006	define)
18007	case "$setlocale_r_proto" in
18008	''|0) try='int setlocale_r(int, const char*, char*, int);'
18009	./protochk "$extern_C $try" $hdrs && setlocale_r_proto=I_ICBI ;;
18010	esac
18011	case "$setlocale_r_proto" in
18012	''|0)	d_setlocale_r=undef
18013		setlocale_r_proto=0
18014		echo "Disabling setlocale_r, cannot determine prototype." >&4 ;;
18015	* )	case "$setlocale_r_proto" in
18016		REENTRANT_PROTO*) ;;
18017		*) setlocale_r_proto="REENTRANT_PROTO_$setlocale_r_proto" ;;
18018		esac
18019		echo "Prototype: $try" ;;
18020	esac
18021	;;
18022	*)	case "$usethreads" in
18023		define) echo "setlocale_r has no prototype, not using it." >&4 ;;
18024		esac
18025		d_setlocale_r=undef
18026		setlocale_r_proto=0
18027		;;
18028	esac
18029	;;
18030*)	setlocale_r_proto=0
18031	;;
18032esac
18033
18034: see if setnetent exists
18035set setnetent d_setnent
18036eval $inlibc
18037
18038: see if setnetent_r exists
18039set setnetent_r d_setnetent_r
18040eval $inlibc
18041case "$d_setnetent_r" in
18042"$define")
18043	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18044	case "$d_setnetent_r_proto:$usethreads" in
18045	":define")	d_setnetent_r_proto=define
18046		set d_setnetent_r_proto setnetent_r $hdrs
18047		eval $hasproto ;;
18048	*)	;;
18049	esac
18050	case "$d_setnetent_r_proto" in
18051	define)
18052	case "$setnetent_r_proto" in
18053	''|0) try='int setnetent_r(int, struct netent_data*);'
18054	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=I_ID ;;
18055	esac
18056	case "$setnetent_r_proto" in
18057	''|0) try='void setnetent_r(int, struct netent_data*);'
18058	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=V_ID ;;
18059	esac
18060	case "$setnetent_r_proto" in
18061	''|0)	d_setnetent_r=undef
18062		setnetent_r_proto=0
18063		echo "Disabling setnetent_r, cannot determine prototype." >&4 ;;
18064	* )	case "$setnetent_r_proto" in
18065		REENTRANT_PROTO*) ;;
18066		*) setnetent_r_proto="REENTRANT_PROTO_$setnetent_r_proto" ;;
18067		esac
18068		echo "Prototype: $try" ;;
18069	esac
18070	;;
18071	*)	case "$usethreads" in
18072		define) echo "setnetent_r has no prototype, not using it." >&4 ;;
18073		esac
18074		d_setnetent_r=undef
18075		setnetent_r_proto=0
18076		;;
18077	esac
18078	;;
18079*)	setnetent_r_proto=0
18080	;;
18081esac
18082
18083: see if setprotoent exists
18084set setprotoent d_setpent
18085eval $inlibc
18086
18087: see if setpgid exists
18088set setpgid d_setpgid
18089eval $inlibc
18090
18091: see if setpgrp2 exists
18092set setpgrp2 d_setpgrp2
18093eval $inlibc
18094
18095: see if setpriority exists
18096set setpriority d_setprior
18097eval $inlibc
18098
18099: see if setproctitle exists
18100set setproctitle d_setproctitle
18101eval $inlibc
18102
18103: see if setprotoent_r exists
18104set setprotoent_r d_setprotoent_r
18105eval $inlibc
18106case "$d_setprotoent_r" in
18107"$define")
18108	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18109	case "$d_setprotoent_r_proto:$usethreads" in
18110	":define")	d_setprotoent_r_proto=define
18111		set d_setprotoent_r_proto setprotoent_r $hdrs
18112		eval $hasproto ;;
18113	*)	;;
18114	esac
18115	case "$d_setprotoent_r_proto" in
18116	define)
18117	case "$setprotoent_r_proto" in
18118	''|0) try='int setprotoent_r(int, struct protoent_data*);'
18119	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=I_ID ;;
18120	esac
18121	case "$setprotoent_r_proto" in
18122	''|0) try='void setprotoent_r(int, struct protoent_data*);'
18123	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=V_ID ;;
18124	esac
18125	case "$setprotoent_r_proto" in
18126	''|0)	d_setprotoent_r=undef
18127		setprotoent_r_proto=0
18128		echo "Disabling setprotoent_r, cannot determine prototype." >&4 ;;
18129	* )	case "$setprotoent_r_proto" in
18130		REENTRANT_PROTO*) ;;
18131		*) setprotoent_r_proto="REENTRANT_PROTO_$setprotoent_r_proto" ;;
18132		esac
18133		echo "Prototype: $try" ;;
18134	esac
18135	;;
18136	*)	case "$usethreads" in
18137		define) echo "setprotoent_r has no prototype, not using it." >&4 ;;
18138		esac
18139		d_setprotoent_r=undef
18140		setprotoent_r_proto=0
18141		;;
18142	esac
18143	;;
18144*)	setprotoent_r_proto=0
18145	;;
18146esac
18147
18148: see if setpwent exists
18149set setpwent d_setpwent
18150eval $inlibc
18151
18152: see if setpwent_r exists
18153set setpwent_r d_setpwent_r
18154eval $inlibc
18155case "$d_setpwent_r" in
18156"$define")
18157	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
18158	case "$d_setpwent_r_proto:$usethreads" in
18159	":define")	d_setpwent_r_proto=define
18160		set d_setpwent_r_proto setpwent_r $hdrs
18161		eval $hasproto ;;
18162	*)	;;
18163	esac
18164	case "$d_setpwent_r_proto" in
18165	define)
18166	case "$setpwent_r_proto" in
18167	''|0) try='int setpwent_r(FILE**);'
18168	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=I_H ;;
18169	esac
18170	case "$setpwent_r_proto" in
18171	''|0) try='void setpwent_r(FILE**);'
18172	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=V_H ;;
18173	esac
18174	case "$setpwent_r_proto" in
18175	''|0)	d_setpwent_r=undef
18176		setpwent_r_proto=0
18177		echo "Disabling setpwent_r, cannot determine prototype." >&4 ;;
18178	* )	case "$setpwent_r_proto" in
18179		REENTRANT_PROTO*) ;;
18180		*) setpwent_r_proto="REENTRANT_PROTO_$setpwent_r_proto" ;;
18181		esac
18182		echo "Prototype: $try" ;;
18183	esac
18184	;;
18185	*)	case "$usethreads" in
18186		define) echo "setpwent_r has no prototype, not using it." >&4 ;;
18187		esac
18188		d_setpwent_r=undef
18189		setpwent_r_proto=0
18190		;;
18191	esac
18192	;;
18193*)	setpwent_r_proto=0
18194	;;
18195esac
18196
18197: see if setregid exists
18198set setregid d_setregid
18199eval $inlibc
18200set setresgid d_setresgid
18201eval $inlibc
18202
18203: see if setreuid exists
18204set setreuid d_setreuid
18205eval $inlibc
18206set setresuid d_setresuid
18207eval $inlibc
18208
18209: see if setrgid exists
18210set setrgid d_setrgid
18211eval $inlibc
18212
18213: see if setruid exists
18214set setruid d_setruid
18215eval $inlibc
18216
18217: see if setservent exists
18218set setservent d_setsent
18219eval $inlibc
18220
18221: see if setservent_r exists
18222set setservent_r d_setservent_r
18223eval $inlibc
18224case "$d_setservent_r" in
18225"$define")
18226	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18227	case "$d_setservent_r_proto:$usethreads" in
18228	":define")	d_setservent_r_proto=define
18229		set d_setservent_r_proto setservent_r $hdrs
18230		eval $hasproto ;;
18231	*)	;;
18232	esac
18233	case "$d_setservent_r_proto" in
18234	define)
18235	case "$setservent_r_proto" in
18236	''|0) try='int setservent_r(int, struct servent_data*);'
18237	./protochk "$extern_C $try" $hdrs && setservent_r_proto=I_ID ;;
18238	esac
18239	case "$setservent_r_proto" in
18240	''|0) try='void setservent_r(int, struct servent_data*);'
18241	./protochk "$extern_C $try" $hdrs && setservent_r_proto=V_ID ;;
18242	esac
18243	case "$setservent_r_proto" in
18244	''|0)	d_setservent_r=undef
18245		setservent_r_proto=0
18246		echo "Disabling setservent_r, cannot determine prototype." >&4 ;;
18247	* )	case "$setservent_r_proto" in
18248		REENTRANT_PROTO*) ;;
18249		*) setservent_r_proto="REENTRANT_PROTO_$setservent_r_proto" ;;
18250		esac
18251		echo "Prototype: $try" ;;
18252	esac
18253	;;
18254	*)	case "$usethreads" in
18255		define) echo "setservent_r has no prototype, not using it." >&4 ;;
18256		esac
18257		d_setservent_r=undef
18258		setservent_r_proto=0
18259		;;
18260	esac
18261	;;
18262*)	setservent_r_proto=0
18263	;;
18264esac
18265
18266: see if setsid exists
18267set setsid d_setsid
18268eval $inlibc
18269
18270: see if setvbuf exists
18271set setvbuf d_setvbuf
18272eval $inlibc
18273
18274: see if shmctl exists
18275set shmctl d_shmctl
18276eval $inlibc
18277
18278: see if shmget exists
18279set shmget d_shmget
18280eval $inlibc
18281
18282: see if shmat exists
18283set shmat d_shmat
18284eval $inlibc
18285: see what shmat returns
18286case "$d_shmat" in
18287"$define")
18288	$cat >shmat.c <<'END'
18289#include <sys/shm.h>
18290void *shmat();
18291END
18292	if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
18293		shmattype='void *'
18294	else
18295		shmattype='char *'
18296	fi
18297	echo "and it returns ($shmattype)." >&4
18298	: see if a prototype for shmat is available
18299	xxx=`./findhdr sys/shm.h`
18300	$cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
18301	if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
18302		val="$define"
18303	else
18304		val="$undef"
18305	fi
18306	$rm -f shmat.[co]
18307	;;
18308*)
18309	val="$undef"
18310	;;
18311esac
18312set d_shmatprototype
18313eval $setvar
18314
18315: see if shmdt exists
18316set shmdt d_shmdt
18317eval $inlibc
18318
18319: see how much of the 'shm*(2)' library is present.
18320h_shm=true
18321echo " "
18322case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
18323*"$undef"*) h_shm=false;;
18324esac
18325case "$osname" in
18326freebsd)
18327    case "`ipcs 2>&1`" in
18328    "SVID shared memory"*"not configured"*)
18329	echo "Your $osname does not have the shm*(2) configured." >&4
18330        h_shm=false
18331	val="$undef"
18332	set shmctl d_shmctl
18333	eval $setvar
18334	set shmget d_shmget
18335	eval $setvar
18336	set shmat d_shmat
18337	eval $setvar
18338	set shmdt d_shmdt
18339	eval $setvar
18340	;;
18341    esac
18342    ;;
18343esac
18344: we could also check for sys/ipc.h ...
18345if $h_shm && $test `./findhdr sys/shm.h`; then
18346	echo "You have the full shm*(2) library." >&4
18347	val="$define"
18348else
18349	echo "You don't have the full shm*(2) library." >&4
18350	val="$undef"
18351fi
18352set d_shm
18353eval $setvar
18354
18355: see if we have sigaction
18356echo " "
18357if set sigaction val -f d_sigaction; eval $csym; $val; then
18358	echo 'sigaction() found.' >&4
18359	$cat > try.c <<EOP
18360#include <stdio.h>
18361#include <sys/types.h>
18362#include <signal.h>
18363#$i_stdlib I_STDLIB
18364#ifdef I_STDLIB
18365#include <stdlib.h>
18366#endif
18367int main()
18368{
18369    struct sigaction act, oact;
18370    act.sa_flags = 0;
18371    oact.sa_handler = 0;
18372    /* so that act and oact are used */
18373    exit(act.sa_flags == 0 &&  oact.sa_handler == 0);
18374}
18375EOP
18376	set try
18377	if eval $compile_ok; then
18378		val="$define"
18379	else
18380		echo "But you don't seem to have a usable struct sigaction." >&4
18381		val="$undef"
18382	fi
18383else
18384	echo 'sigaction NOT found.' >&4
18385	val="$undef"
18386fi
18387set d_sigaction; eval $setvar
18388$rm_try
18389
18390: see what type pids are declared as in the kernel
18391rp="What is the type of process ids on this system?"
18392set pid_t pidtype int stdio.h sys/types.h
18393eval $typedef_ask
18394
18395: see what type uids are declared as in the kernel
18396echo " "
18397echo "Looking for the type for user ids returned by getuid()."
18398set uid_t uidtype xxx stdio.h sys/types.h
18399eval $typedef
18400case "$uidtype" in
18401xxx)
18402	xxx=`./findhdr sys/user.h`
18403	set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
18404	case $1 in
18405	unsigned) dflt="$1 $2" ;;
18406	*) dflt="$1" ;;
18407	esac
18408	;;
18409*) dflt="$uidtype";;
18410esac
18411case "$uidtype" in
18412uid_t)	echo "uid_t found." ;;
18413*)	rp="What is the type for user ids returned by getuid()?"
18414	. ./myread
18415	uidtype="$ans"
18416	;;
18417esac
18418
18419: Define hasfield_t macro for Configure internal use
18420hasfield_t='varname=$1; struct=$2; type=$3; field=$4; shift; shift; shift; shift;
18421while $test $# -ge 2; do
18422    case "$1" in
18423	$define) echo "#include <$2>";;
18424    esac ;
18425    shift 2;
18426done > try.c;
18427echo "int main () { $struct foo; $type bar = foo.$field; }" >> try.c;
18428set try;
18429if eval $compile; then
18430	val="$define";
18431else
18432	val="$undef";
18433fi;
18434set $varname;
18435eval $setvar;
18436$rm_try'
18437
18438: see what siginfo fields we have
18439case "$d_sigaction" in
18440"$define")
18441	echo "Checking if your siginfo_t has si_errno field...">&4
18442	set d_siginfo_si_errno siginfo_t int si_errno $d_sigaction signal.h
18443	eval $hasfield_t;
18444
18445	echo "Checking if your siginfo_t has si_pid field...">&4
18446	set d_siginfo_si_pid siginfo_t $pidtype si_pid $d_sigaction signal.h
18447	eval $hasfield_t;
18448
18449	echo "Checking if your siginfo_t has si_uid field...">&4
18450	set d_siginfo_si_uid siginfo_t $uidtype si_uid $d_sigaction signal.h
18451	eval $hasfield_t;
18452
18453	echo "Checking if your siginfo_t has si_addr field...">&4
18454	set d_siginfo_si_addr siginfo_t "void *" si_addr $d_sigaction signal.h
18455	eval $hasfield_t;
18456
18457	echo "Checking if your siginfo_t has si_status field...">&4
18458	set d_siginfo_si_status siginfo_t int si_status $d_sigaction signal.h
18459	eval $hasfield_t;
18460
18461	echo "Checking if your siginfo_t has si_band field...">&4
18462	set d_siginfo_si_band siginfo_t long si_band $d_sigaction signal.h
18463	eval $hasfield_t;
18464
18465	echo "Checking if your siginfo_t has si_value field...">&4
18466	set d_siginfo_si_value siginfo_t "union sigval" si_value $d_sigaction signal.h
18467	eval $hasfield_t;
18468
18469	echo "Checking if your siginfo_t has si_fd field...">&4
18470	set d_siginfo_si_fd siginfo_t int si_fd $d_sigaction signal.h
18471	eval $hasfield_t;
18472
18473	;;
18474*)
18475	d_siginfo_si_errno="$undef"
18476	d_siginfo_si_pid="$undef"
18477	d_siginfo_si_uid="$undef"
18478	d_siginfo_si_addr="$undef"
18479	d_siginfo_si_status="$undef"
18480	d_siginfo_si_band="$undef"
18481	d_siginfo_si_value="$undef"
18482	d_siginfo_si_fd="$undef"
18483	;;
18484esac
18485
18486: see if this is a sunmath.h system
18487set sunmath.h i_sunmath
18488eval $inhdr
18489
18490: see if signbit exists
18491$echo $n "Checking to see if you have signbit() available to work on $nvtype... $c" >&4
18492$cat >try.c <<EOCP
18493#$i_sunmath I_SUNMATH
18494#include <math.h>
18495#ifdef I_SUNMATH  /* Solaris special math library */
18496#  include <sunmath.h>
18497#endif
18498#define NV $nvtype
18499int main(int argc, char **argv)
18500{
18501    NV x = 0.0;
18502    NV y = -1.0;
18503    if ((signbit(x) == 0) && (signbit(y) != 0))
18504	return 0;
18505    else
18506	return 1;
18507}
18508EOCP
18509val="$undef"
18510set try
18511if eval $compile; then
18512    if $run ./try; then
18513        $echo "Yes." >&4
18514	val="$define"
18515    else
18516        $echo "Signbit seems to be available, but doesn't work as I expected."
18517        $echo "I won't use it." >&4
18518	val="$undef"
18519    fi
18520else
18521    $echo "Nope." >&4
18522    dflt="$undef"
18523fi
18524set d_signbit
18525eval $setvar
18526$rm_try
18527
18528: see if sigprocmask exists
18529set sigprocmask d_sigprocmask
18530eval $inlibc
18531
18532: see if sigsetjmp exists
18533echo " "
18534case "$d_sigsetjmp" in
18535'')
18536	$cat >try.c <<EOP
18537#include <setjmp.h>
18538#$i_stdlib I_STDLIB
18539#ifdef I_STDLIB
18540#include <stdlib.h>
18541#endif
18542sigjmp_buf env;
18543int set = 1;
18544int main()
18545{
18546	if (sigsetjmp(env,1))
18547		exit(set);
18548	set = 0;
18549	siglongjmp(env, 1);
18550	exit(1);
18551}
18552EOP
18553	set try
18554	if eval $compile; then
18555		if $run ./try >/dev/null 2>&1; then
18556			echo "POSIX sigsetjmp found." >&4
18557			val="$define"
18558		else
18559			$cat >&4 <<EOM
18560Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
18561I'll ignore them.
18562EOM
18563			val="$undef"
18564		fi
18565	else
18566		echo "sigsetjmp not found." >&4
18567		val="$undef"
18568	fi
18569	;;
18570*) val="$d_sigsetjmp"
18571	case "$d_sigsetjmp" in
18572	$define) echo "POSIX sigsetjmp found." >&4;;
18573	$undef) echo "sigsetjmp not found." >&4;;
18574	esac
18575	;;
18576esac
18577set d_sigsetjmp
18578eval $setvar
18579$rm_try
18580
18581: see if snprintf exists
18582set snprintf d_snprintf
18583eval $inlibc
18584
18585: see if vsnprintf exists
18586set vsnprintf d_vsnprintf
18587eval $inlibc
18588
18589case "$d_snprintf-$d_vsnprintf" in
18590"$define-$define")
18591    $cat <<EOM
18592Checking whether your snprintf() and vsnprintf() work okay...
18593EOM
18594    $cat >try.c <<'EOCP'
18595/* v?snprintf testing logic courtesy of Russ Allbery.
18596 * According to C99:
18597 * - if the buffer is too short it still must be \0-terminated
18598 * - if the buffer is too short the potentially required length
18599 *   must be returned and not -1
18600 * - if the buffer is NULL the potentially required length
18601 *   must be returned and not -1 or core dump
18602 */
18603#include <stdio.h>
18604#include <stdarg.h>
18605
18606char buf[2];
18607
18608int test (char *format, ...)
18609{
18610    va_list args;
18611    int count;
18612
18613    va_start (args, format);
18614    count = vsnprintf (buf, sizeof buf, format, args);
18615    va_end (args);
18616    return count;
18617}
18618
18619int main ()
18620{
18621    return ((test ("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0'
18622             && snprintf (NULL, 0, "%s", "abcd") == 4) ? 0 : 1);
18623}
18624EOCP
18625    set try
18626    if eval $compile; then
18627	`$run ./try`
18628	case "$?" in
18629	0) echo "Your snprintf() and vsnprintf() seem to be working okay." ;;
18630	*) cat <<EOM >&4
18631Your snprintf() and snprintf() don't seem to be working okay.
18632EOM
18633	   d_snprintf="$undef"
18634	   d_vsnprintf="$undef"
18635	   ;;
18636	esac
18637    else
18638	echo "(I can't seem to compile the test program--assuming they don't)"
18639	d_snprintf="$undef"
18640	d_vsnprintf="$undef"
18641    fi
18642    $rm_try
18643    ;;
18644esac
18645
18646: see if sockatmark exists
18647set sockatmark d_sockatmark
18648eval $inlibc
18649
18650: see if prototype for sockatmark is available
18651echo " "
18652set d_sockatmarkproto sockatmark $d_socket sys/socket.h
18653eval $hasproto
18654
18655: see if socks5_init exists
18656set socks5_init d_socks5_init
18657eval $inlibc
18658
18659: see if srand48_r exists
18660set srand48_r d_srand48_r
18661eval $inlibc
18662case "$d_srand48_r" in
18663"$define")
18664	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
18665	case "$d_srand48_r_proto:$usethreads" in
18666	":define")	d_srand48_r_proto=define
18667		set d_srand48_r_proto srand48_r $hdrs
18668		eval $hasproto ;;
18669	*)	;;
18670	esac
18671	case "$d_srand48_r_proto" in
18672	define)
18673	case "$srand48_r_proto" in
18674	''|0) try='int srand48_r(long, struct drand48_data*);'
18675	./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;;
18676	esac
18677	case "$srand48_r_proto" in
18678	''|0)	d_srand48_r=undef
18679		srand48_r_proto=0
18680		echo "Disabling srand48_r, cannot determine prototype." >&4 ;;
18681	* )	case "$srand48_r_proto" in
18682		REENTRANT_PROTO*) ;;
18683		*) srand48_r_proto="REENTRANT_PROTO_$srand48_r_proto" ;;
18684		esac
18685		echo "Prototype: $try" ;;
18686	esac
18687	;;
18688	*)	case "$usethreads" in
18689		define) echo "srand48_r has no prototype, not using it." >&4 ;;
18690		esac
18691		d_srand48_r=undef
18692		srand48_r_proto=0
18693		;;
18694	esac
18695	;;
18696*)	srand48_r_proto=0
18697	;;
18698esac
18699
18700: see if srandom_r exists
18701set srandom_r d_srandom_r
18702eval $inlibc
18703case "$d_srandom_r" in
18704"$define")
18705	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
18706	case "$d_srandom_r_proto:$usethreads" in
18707	":define")	d_srandom_r_proto=define
18708		set d_srandom_r_proto srandom_r $hdrs
18709		eval $hasproto ;;
18710	*)	;;
18711	esac
18712	case "$d_srandom_r_proto" in
18713	define)
18714	case "$srandom_r_proto" in
18715	''|0) try='int srandom_r(unsigned int, struct random_data*);'
18716	./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;;
18717	esac
18718	case "$srandom_r_proto" in
18719	''|0)	d_srandom_r=undef
18720		srandom_r_proto=0
18721		echo "Disabling srandom_r, cannot determine prototype." >&4 ;;
18722	* )	case "$srandom_r_proto" in
18723		REENTRANT_PROTO*) ;;
18724		*) srandom_r_proto="REENTRANT_PROTO_$srandom_r_proto" ;;
18725		esac
18726		echo "Prototype: $try" ;;
18727	esac
18728	;;
18729	*)	case "$usethreads" in
18730		define) echo "srandom_r has no prototype, not using it." >&4 ;;
18731		esac
18732		d_srandom_r=undef
18733		srandom_r_proto=0
18734		;;
18735	esac
18736	;;
18737*)	srandom_r_proto=0
18738	;;
18739esac
18740
18741: see if prototype for setresgid is available
18742echo " "
18743set d_sresgproto setresgid $i_unistd unistd.h
18744eval $hasproto
18745
18746: see if prototype for setresuid is available
18747echo " "
18748set d_sresuproto setresuid $i_unistd unistd.h
18749eval $hasproto
18750
18751: see if stat exists
18752set stat d_stat
18753eval $inlibc
18754
18755: see if sys/stat.h is available
18756set sys/stat.h i_sysstat
18757eval $inhdr
18758
18759: see if stat knows about block sizes
18760echo " "
18761echo "Checking to see if your struct stat has st_blocks field..." >&4
18762set d_statblks stat st_blocks $i_sysstat sys/stat.h
18763eval $hasfield
18764
18765: see if this is a sys/vfs.h system
18766set sys/vfs.h i_sysvfs
18767eval $inhdr
18768
18769: see if this is a sys/statfs.h system
18770set sys/statfs.h i_sysstatfs
18771eval $inhdr
18772
18773: Check for statfs_s
18774echo " "
18775echo "Checking to see if your system supports struct statfs..." >&4
18776set 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
18777eval $hasstruct
18778case "$d_statfs_s" in
18779"$define")      echo "Yes, it does."   ;;
18780*)              echo "No, it doesn't." ;;
18781esac
18782
18783: see if struct statfs knows about f_flags
18784case "$d_statfs_s" in
18785define)
18786	echo " "
18787	echo "Checking to see if your struct statfs has f_flags field..." >&4
18788	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
18789	eval $hasfield
18790	;;
18791*)	val="$undef"
18792	set d_statfs_f_flags
18793	eval $setvar
18794	;;
18795esac
18796case "$d_statfs_f_flags" in
18797"$define")      echo "Yes, it does."   ;;
18798*)              echo "No, it doesn't." ;;
18799esac
18800
18801: see what flavor, if any, of static inline is supported
18802echo " "
18803echo "Checking to see if your system supports static inline..."
18804$cat > try.c <<'EOCP'
18805#include <stdlib.h>
18806extern int f_via_a(int x);
18807extern int f_via_b(int x);
18808int main(int argc, char **argv)
18809{
18810    int y;
18811
18812    y = f_via_a(0);
18813#ifdef USE_B
18814    y = f_via_b(0);
18815#endif
18816    if (y == 42) {
18817        return EXIT_SUCCESS;
18818    }
18819    else {
18820        return EXIT_FAILURE;
18821    }
18822}
18823EOCP
18824$cat > a.c <<'EOCP'
18825static INLINE int f(int x) {
18826    int y;
18827    y = x + 42;
18828    return y;
18829}
18830
18831int f_via_a(int x)
18832{
18833    return f(x);
18834}
18835EOCP
18836$cat > b.c <<'EOCP'
18837extern int f(int x);
18838
18839int f_via_b(int x)
18840{
18841    return f(x);
18842}
18843EOCP
18844
18845# Respect a hint (or previous) value for perl_static_inline, if there is one.
18846case "$perl_static_inline" in
18847'')	# Check the various possibilities, and break out on success.
18848	# For gcc, prefer __inline__, which will still permit
18849	# cflags.SH to add in -ansi.
18850	case "$gccversion" in
18851		'') xxx="inline __inline__ __inline _inline";;
18852		*)  xxx="__inline__ inline __inline _inline";;
18853	esac
18854	for inline in $xxx; do
18855		set try -DINLINE=$inline a.c
18856		if eval $compile && $run ./try; then
18857			# Now make sure there is no external linkage of static
18858			# functions
18859			set try -DINLINE=$inline -DUSE_B a.c b.c
18860			if eval $compile && $run ./try; then
18861				$echo "Your compiler supports static $inline, " >&4
18862				$echo "but it also creates an external definition," >&4
18863				$echo "so I won't use it." >&4
18864				val=$undef
18865			else
18866				$echo "Your compiler supports static $inline." >&4
18867				val=$define
18868				perl_static_inline="static $inline";
18869				break;
18870			fi
18871		else
18872			$echo "Your compiler does NOT support static $inline." >&4
18873			val="$undef"
18874		fi
18875	done
18876	;;
18877*inline*) # Some variant of inline exists.
18878	echo "Keeping your $hint value of $perl_static_inline."
18879	val=$define
18880	;;
18881static)  # No inline capabilities
18882	echo "Keeping your $hint value of $perl_static_inline."
18883	val=$undef
18884	;;
18885*)  # Unrecognized previous value -- blindly trust the supplied
18886	# value and hope it makes sense.  Use old value for
18887	# d_static_inline, if there is one.
18888	echo "Keeping your $hint value of $perl_static_inline."
18889	case "$d_static_inline" in
18890		'') val=$define ;;
18891		*)  val=$d_static_inline ;;
18892	esac
18893	;;
18894esac
18895# Fallback to plain 'static' if nothing worked.
18896case "$perl_static_inline" in
18897'')
18898	perl_static_inline="static"
18899	val=$undef
18900	;;
18901esac
18902set d_static_inline
18903eval $setvar
18904$rm -f a.[co] b.[co]
18905$rm_try
18906
18907: Check stream access
18908$cat >&4 <<EOM
18909Checking how to access stdio streams by file descriptor number...
18910EOM
18911case "$stdio_stream_array" in
18912'')	$cat >try.c <<EOCP
18913#include <stdio.h>
18914int main() {
18915  if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
18916    printf("yes\n");
18917}
18918EOCP
18919	for s in _iob __iob __sF
18920	do
18921	        set try -DSTDIO_STREAM_ARRAY=$s
18922		if eval $compile; then
18923			case "`$run ./try`" in
18924			yes)	stdio_stream_array=$s; break ;;
18925			esac
18926		fi
18927	done
18928	$rm_try
18929esac
18930case "$stdio_stream_array" in
18931'')	$cat >&4 <<EOM
18932I can't figure out how to access stdio streams by file descriptor number.
18933EOM
18934	d_stdio_stream_array="$undef"
18935	;;
18936*)	$cat >&4 <<EOM
18937You can access stdio streams by file descriptor number by the $stdio_stream_array array.
18938EOM
18939	d_stdio_stream_array="$define"
18940	;;
18941esac
18942
18943: see if strcoll exists
18944set strcoll d_strcoll
18945eval $inlibc
18946
18947: see if strerror_l exists
18948set strerror_l d_strerror_l
18949eval $inlibc
18950
18951: see if strerror_r exists
18952set strerror_r d_strerror_r
18953eval $inlibc
18954case "$d_strerror_r" in
18955"$define")
18956	hdrs="$i_systypes sys/types.h define stdio.h define string.h"
18957	case "$d_strerror_r_proto:$usethreads" in
18958	":define")	d_strerror_r_proto=define
18959		set d_strerror_r_proto strerror_r $hdrs
18960		eval $hasproto ;;
18961	*)	;;
18962	esac
18963	case "$d_strerror_r_proto" in
18964	define)
18965	case "$strerror_r_proto" in
18966	''|0) try='int strerror_r(int, char*, size_t);'
18967	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBW ;;
18968	esac
18969	case "$strerror_r_proto" in
18970	''|0) try='int strerror_r(int, char*, int);'
18971	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBI ;;
18972	esac
18973	case "$strerror_r_proto" in
18974	''|0) try='char* strerror_r(int, char*, size_t);'
18975	./protochk "$extern_C $try" $hdrs && strerror_r_proto=B_IBW ;;
18976	esac
18977	case "$strerror_r_proto" in
18978	''|0)	d_strerror_r=undef
18979		strerror_r_proto=0
18980		echo "Disabling strerror_r, cannot determine prototype." >&4 ;;
18981	* )	case "$strerror_r_proto" in
18982		REENTRANT_PROTO*) ;;
18983		*) strerror_r_proto="REENTRANT_PROTO_$strerror_r_proto" ;;
18984		esac
18985		echo "Prototype: $try" ;;
18986	esac
18987	;;
18988	*)	case "$usethreads" in
18989		define) echo "strerror_r has no prototype, not using it." >&4 ;;
18990		esac
18991		d_strerror_r=undef
18992		strerror_r_proto=0
18993		;;
18994	esac
18995	;;
18996*)	strerror_r_proto=0
18997	;;
18998esac
18999
19000: see if strftime exists
19001set strftime d_strftime
19002eval $inlibc
19003
19004: see if strlcat exists
19005: We need both a prototype in string.h and the symbol in libc.
19006echo " "
19007d_strlcat_proto=''
19008xx1="#$d_gnulibc HAS_GNULIBC"
19009xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
19010xx3='#   define _GNU_SOURCE'
19011xx4='#endif'
19012set d_strlcat_proto strlcat literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
19013eval $hasproto
19014case "$d_strlcat_proto" in
19015    define) # see if strlcat exists
19016	set strlcat d_strlcat
19017	eval $inlibc
19018	;;
19019    *)  val=$undef
19020	set d_strlcat
19021	eval $setvar
19022	;;
19023esac
19024
19025: see if strlcpy exists
19026: We need both a prototype in string.h and the symbol in libc.
19027echo " "
19028d_strlcpy_proto=''
19029xx1="#$d_gnulibc HAS_GNULIBC"
19030xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
19031xx3='#   define _GNU_SOURCE'
19032xx4='#endif'
19033set d_strlcpy_proto strlcpy literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
19034eval $hasproto
19035case "$d_strlcpy_proto" in
19036    define) # see if strlcpy exists
19037	set strlcpy d_strlcpy
19038	eval $inlibc
19039	;;
19040    *)  val=$undef
19041	set d_strlcpy
19042	eval $setvar
19043	;;
19044esac
19045
19046: see if strnlen exists
19047set strnlen d_strnlen
19048eval $inlibc
19049
19050: see if strtod exists
19051set strtod d_strtod
19052eval $inlibc
19053
19054: see if strtod_l exists
19055set strtod_l d_strtod_l
19056eval $inlibc
19057
19058: see if strtol exists
19059set strtol d_strtol
19060eval $inlibc
19061
19062: see if strtold exists
19063set strtold d_strtold
19064eval $inlibc
19065
19066: see if strtold_l exists
19067set strtold_l d_strtold_l
19068eval $inlibc
19069
19070: see if strtoll exists
19071set strtoll d_strtoll
19072eval $inlibc
19073
19074case "$d_longlong-$d_strtoll" in
19075"$define-$define")
19076	$cat <<EOM
19077Checking whether your strtoll() works okay...
19078EOM
19079	$cat >try.c <<'EOCP'
19080#include <errno.h>
19081#ifdef __hpux
19082#define strtoll __strtoll
19083#endif
19084#ifdef __EMX__
19085#define strtoll _strtoll
19086#endif
19087#include <stdio.h>
19088extern long long int strtoll(char *s, char **, int);
19089static int bad = 0;
19090int check(char *s, long long ell, int een) {
19091	long long gll;
19092	errno = 0;
19093	gll = strtoll(s, 0, 10);
19094	if (!((gll == ell) && (errno == een)))
19095		bad++;
19096}
19097int main() {
19098	check(" 1",                                      1LL, 0);
19099	check(" 0",                                      0LL, 0);
19100	check("-1",                                     -1LL, 0);
19101	check("-9223372036854775808", -9223372036854775808LL, 0);
19102	check("-9223372036854775808", -9223372036854775808LL, 0);
19103	check(" 9223372036854775807",  9223372036854775807LL, 0);
19104	check("-9223372036854775808", -9223372036854775808LL, 0);
19105	check(" 9223372036854775808",  9223372036854775807LL, ERANGE);
19106	check("-9223372036854775809", -9223372036854775808LL, ERANGE);
19107	if (!bad)
19108		printf("ok\n");
19109}
19110EOCP
19111	set try
19112	if eval $compile; then
19113		yyy=`$run ./try`
19114		case "$yyy" in
19115		ok) echo "Your strtoll() seems to be working okay." ;;
19116		*) cat <<EOM >&4
19117Your strtoll() doesn't seem to be working okay.
19118EOM
19119		   d_strtoll="$undef"
19120		   ;;
19121		esac
19122	else
19123		echo "(I can't seem to compile the test program--assuming it doesn't)"
19124		d_strtoll="$undef"
19125	fi
19126	;;
19127esac
19128
19129: see if strtoq exists
19130set strtoq d_strtoq
19131eval $inlibc
19132
19133: see if strtoul exists
19134set strtoul d_strtoul
19135eval $inlibc
19136
19137case "$d_strtoul" in
19138"$define")
19139	$cat <<EOM
19140Checking whether your strtoul() works okay...
19141EOM
19142	$cat >try.c <<'EOCP'
19143#include <errno.h>
19144#include <stdio.h>
19145extern unsigned long int strtoul(char *s, char **, int);
19146static int bad = 0;
19147void check(char *s, unsigned long eul, int een) {
19148	unsigned long gul;
19149	errno = 0;
19150	gul = strtoul(s, 0, 10);
19151	if (!((gul == eul) && (errno == een)))
19152		bad++;
19153}
19154int main() {
19155	check(" 1", 1L, 0);
19156	check(" 0", 0L, 0);
19157EOCP
19158	case "$longsize" in
19159	8)
19160	    $cat >>try.c <<'EOCP'
19161	check("18446744073709551615", 18446744073709551615UL, 0);
19162	check("18446744073709551616", 18446744073709551615UL, ERANGE);
19163#if 0 /* strtoul() for /^-/ strings is undefined. */
19164	check("-1", 18446744073709551615UL, 0);
19165	check("-18446744073709551614", 2, 0);
19166	check("-18446744073709551615", 1, 0);
19167	check("-18446744073709551616", 18446744073709551615UL, ERANGE);
19168	check("-18446744073709551617", 18446744073709551615UL, ERANGE);
19169#endif
19170EOCP
19171		;;
19172	4)
19173		    $cat >>try.c <<'EOCP'
19174	check("4294967295", 4294967295UL, 0);
19175	check("4294967296", 4294967295UL, ERANGE);
19176#if 0 /* strtoul() for /^-/ strings is undefined. */
19177	check("-1", 4294967295UL, 0);
19178	check("-4294967294", 2, 0);
19179	check("-4294967295", 1, 0);
19180	check("-4294967296", 4294967295UL, ERANGE);
19181	check("-4294967297", 4294967295UL, ERANGE);
19182#endif
19183EOCP
19184		;;
19185	*)
19186: Should we write these tests to be more portable by sprintf-ing
19187: ~0 and then manipulating that char string as input for strtol?
19188		;;
19189	esac
19190	$cat >>try.c <<'EOCP'
19191	if (!bad)
19192		printf("ok\n");
19193	return 0;
19194}
19195EOCP
19196	set try
19197	if eval $compile; then
19198		case "`$run ./try`" in
19199		ok) echo "Your strtoul() seems to be working okay." ;;
19200		*) cat <<EOM >&4
19201Your strtoul() doesn't seem to be working okay.
19202EOM
19203		   d_strtoul="$undef"
19204		   ;;
19205		esac
19206	else
19207		echo "(I can't seem to compile the test program--assuming it doesn't)"
19208		d_strtoul="$undef"
19209	fi
19210	;;
19211esac
19212
19213: see if strtoull exists
19214set strtoull d_strtoull
19215eval $inlibc
19216
19217case "$d_longlong-$d_strtoull" in
19218"$define-$define")
19219	$cat <<EOM
19220Checking whether your strtoull() works okay...
19221EOM
19222	$cat >try.c <<'EOCP'
19223#include <errno.h>
19224#ifdef __hpux
19225#define strtoull __strtoull
19226#endif
19227#include <stdio.h>
19228extern unsigned long long int strtoull(char *s, char **, int);
19229static int bad = 0;
19230int check(char *s, long long eull, int een) {
19231	long long gull;
19232	errno = 0;
19233	gull = strtoull(s, 0, 10);
19234	if (!((gull == eull) && (errno == een)))
19235		bad++;
19236}
19237int main() {
19238	check(" 1",                                        1LL, 0);
19239	check(" 0",                                        0LL, 0);
19240	check("18446744073709551615",  18446744073709551615ULL, 0);
19241	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
19242#if 0 /* strtoull() for /^-/ strings is undefined. */
19243	check("-1",                    18446744073709551615ULL, 0);
19244	check("-18446744073709551614",                     2LL, 0);
19245	check("-18446744073709551615",                     1LL, 0);
19246	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
19247	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
19248#endif
19249	if (!bad)
19250		printf("ok\n");
19251}
19252EOCP
19253	set try
19254	if eval $compile; then
19255		case "`$run ./try`" in
19256		ok) echo "Your strtoull() seems to be working okay." ;;
19257		*) cat <<EOM >&4
19258Your strtoull() doesn't seem to be working okay.
19259EOM
19260		   d_strtoull="$undef"
19261		   ;;
19262		esac
19263	else
19264		echo "(I can't seem to compile the test program--assuming it doesn't)"
19265		d_strtoull="$undef"
19266	fi
19267	;;
19268esac
19269
19270: see if strtouq exists
19271set strtouq d_strtouq
19272eval $inlibc
19273
19274case "$d_strtouq" in
19275"$define")
19276	$cat <<EOM
19277Checking whether your strtouq() works okay...
19278EOM
19279	$cat >try.c <<'EOCP'
19280#include <errno.h>
19281#include <stdio.h>
19282extern unsigned long long int strtouq(char *s, char **, int);
19283static int bad = 0;
19284void check(char *s, unsigned long long eull, int een) {
19285	unsigned long long gull;
19286	errno = 0;
19287	gull = strtouq(s, 0, 10);
19288	if (!((gull == eull) && (errno == een)))
19289		bad++;
19290}
19291int main() {
19292	check(" 1",                                        1LL, 0);
19293	check(" 0",                                        0LL, 0);
19294	check("18446744073709551615",  18446744073709551615ULL, 0);
19295	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
19296#if 0 /* strtouq() for /^-/ strings is undefined. */
19297	check("-1",                    18446744073709551615ULL, 0);
19298	check("-18446744073709551614",                     2LL, 0);
19299	check("-18446744073709551615",                     1LL, 0);
19300	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
19301	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
19302#endif
19303	if (!bad)
19304		printf("ok\n");
19305	return 0;
19306}
19307EOCP
19308	set try
19309	if eval $compile; then
19310		case "`$run ./try`" in
19311		ok) echo "Your strtouq() seems to be working okay." ;;
19312		*) cat <<EOM >&4
19313Your strtouq() doesn't seem to be working okay.
19314EOM
19315		   d_strtouq="$undef"
19316		   ;;
19317		esac
19318	else
19319		echo "(I can't seem to compile the test program--assuming it doesn't)"
19320		d_strtouq="$undef"
19321	fi
19322	;;
19323esac
19324
19325: see if strxfrm exists
19326set strxfrm d_strxfrm
19327eval $inlibc
19328
19329: see if symlink exists
19330set symlink d_symlink
19331eval $inlibc
19332
19333: see if syscall exists
19334set syscall d_syscall
19335eval $inlibc
19336
19337: see if prototype for syscall is available
19338echo " "
19339set d_syscallproto syscall $i_unistd unistd.h
19340eval $hasproto
19341
19342: see if sysconf exists
19343set sysconf d_sysconf
19344eval $inlibc
19345
19346: see if sys_errlist[] exists
19347echo " "
19348if test "X$d_syserrlst" = X; then
19349	if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
19350		echo "You have sys_errlist[], so we could roll our own strerror."
19351		d_syserrlst="$define"
19352	else
19353		echo "You don't have sys_errlist[], so strerror() is welcome."
19354		d_syserrlst="$undef"
19355	fi
19356fi
19357
19358: see if system exists
19359set system d_system
19360eval $inlibc
19361
19362: see if tcgetpgrp exists
19363set tcgetpgrp d_tcgetpgrp
19364eval $inlibc
19365
19366: see if tcsetpgrp exists
19367set tcsetpgrp d_tcsetpgrp
19368eval $inlibc
19369
19370: see if prototype for telldir is available
19371echo " "
19372set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
19373eval $hasproto
19374
19375: see if tgamma exists
19376set tgamma d_tgamma
19377eval $inlibc
19378
19379: check for thread_safe_nl_langinfo_l item
19380$cat <<EOM
19381
19382Checking to see if you have nl_langinfo_l() and that it is thread-safe
19383EOM
19384$cat >try.c <<EOCP
19385#$i_stdlib I_STDLIB
19386#ifdef I_STDLIB
19387#  include <stdlib.h>
19388#endif
19389#include <string.h>
19390#$i_langinfo I_LANGINFO
19391#ifdef I_LANGINFO
19392#  include <langinfo.h>
19393#endif
19394#$i_pthread I_PTHREAD
19395#ifdef I_PTHREAD
19396#  include <pthread.h>
19397#endif
19398#$i_locale I_LOCALE
19399#ifdef I_LOCALE
19400#  include <locale.h>
19401#endif
19402
19403void *
19404thread_start(void * arg)
19405{
19406    nl_langinfo(RADIXCHAR);
19407}
19408
19409int main() {
19410    char * main_buffer;
19411    char save_main_buffer[1000];
19412    pthread_t subthread;
19413    pthread_attr_t attr;
19414
19415    main_buffer = nl_langinfo_l(CODESET, newlocale(LC_ALL_MASK, "C", 0));
19416
19417    /* If too large for our generous allowance, just assume we don't have
19418     * it. */
19419    if (strlen(main_buffer) >= sizeof(save_main_buffer)) {
19420        exit(1);
19421    }
19422
19423    strcpy(save_main_buffer, main_buffer);
19424
19425    if (pthread_attr_init(&attr) != 0) {
19426        exit(1);
19427    }
19428
19429    if (pthread_create(&subthread, &attr, thread_start, NULL) != 0) {
19430        exit(1);
19431    }
19432
19433    if (pthread_join(subthread, NULL) != 0) {
19434        exit(1);
19435    }
19436
19437    exit(! (strcmp(main_buffer, save_main_buffer) == 0));
19438}
19439EOCP
19440case "$usethreads" in
19441    define)
19442        set try
19443        if eval $compile; then
19444            echo "Your system has nl_langinfo_l()..." >&4
19445            if $run ./try; then
19446                echo "and it is thread-safe (just as I'd hoped)." >&4
19447                d_thread_safe_nl_langinfo_l="$define"
19448                echo "$d_thread_safe_nl_langinfo_l" >&4
19449            else
19450                echo "but it isn't thread-safe, so we won't use it." >&4
19451            fi
19452        else
19453            echo "your system does not have nl_langinfo_l()" >&4
19454        fi
19455        ;;
19456    *) echo "Since threads aren't selected, we won't bother looking for nl_langinfo_l()" >&4
19457esac
19458if test X"$d_thread_safe_nl_langinfo_l" = X; then
19459	d_thread_safe_nl_langinfo_l="$undef"
19460fi
19461$rm_try
19462
19463: see if time exists
19464echo " "
19465if test "X$d_time" = X -o X"$timetype" = X; then
19466    if set time val -f d_time; eval $csym; $val; then
19467		echo 'time() found.' >&4
19468		val="$define"
19469		rp="What is the type returned by time() on this system?"
19470		set time_t timetype long stdio.h sys/types.h
19471		eval $typedef_ask
19472    else
19473		echo 'time() not found, hope that will do.' >&4
19474		val="$undef"
19475		timetype='int';
19476    fi
19477    set d_time
19478    eval $setvar
19479fi
19480
19481: see if timegm exists
19482set timegm d_timegm
19483eval $inlibc
19484
19485: see if this is a sys/times.h system
19486set sys/times.h i_systimes
19487eval $inhdr
19488
19489: see if times exists
19490echo " "
19491if set times val -f d_times; eval $csym; $val; then
19492	echo 'times() found.' >&4
19493	d_times="$define"
19494	inc=''
19495	case "$i_systimes" in
19496	"$define") inc='sys/times.h';;
19497	esac
19498	rp="What is the type returned by times() on this system?"
19499	set clock_t clocktype long stdio.h sys/types.h $inc
19500	eval $typedef_ask
19501else
19502	echo 'times() NOT found, hope that will do.' >&4
19503	d_times="$undef"
19504	clocktype='int'
19505fi
19506
19507: see if tmpnam_r exists
19508set tmpnam_r d_tmpnam_r
19509eval $inlibc
19510case "$d_tmpnam_r" in
19511"$define")
19512	hdrs="$i_systypes sys/types.h define stdio.h "
19513	case "$d_tmpnam_r_proto:$usethreads" in
19514	":define")	d_tmpnam_r_proto=define
19515		set d_tmpnam_r_proto tmpnam_r $hdrs
19516		eval $hasproto ;;
19517	*)	;;
19518	esac
19519	case "$d_tmpnam_r_proto" in
19520	define)
19521	case "$tmpnam_r_proto" in
19522	''|0) try='char* tmpnam_r(char*);'
19523	./protochk "$extern_C $try" $hdrs && tmpnam_r_proto=B_B ;;
19524	esac
19525	case "$tmpnam_r_proto" in
19526	''|0)	d_tmpnam_r=undef
19527		tmpnam_r_proto=0
19528		echo "Disabling tmpnam_r, cannot determine prototype." >&4 ;;
19529	* )	case "$tmpnam_r_proto" in
19530		REENTRANT_PROTO*) ;;
19531		*) tmpnam_r_proto="REENTRANT_PROTO_$tmpnam_r_proto" ;;
19532		esac
19533		echo "Prototype: $try" ;;
19534	esac
19535	;;
19536	*)	case "$usethreads" in
19537		define) echo "tmpnam_r has no prototype, not using it." >&4 ;;
19538		esac
19539		d_tmpnam_r=undef
19540		tmpnam_r_proto=0
19541		;;
19542	esac
19543	;;
19544*)	tmpnam_r_proto=0
19545	;;
19546esac
19547
19548: see if towlower exists
19549set towlower d_towlower
19550eval $inlibc
19551
19552: see if trunc exists
19553set trunc d_trunc
19554eval $inlibc
19555
19556: see if truncate exists
19557set truncate d_truncate
19558eval $inlibc
19559
19560: see if ttyname_r exists
19561set ttyname_r d_ttyname_r
19562eval $inlibc
19563case "$d_ttyname_r" in
19564"$define")
19565	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
19566	case "$d_ttyname_r_proto:$usethreads" in
19567	":define")	d_ttyname_r_proto=define
19568		set d_ttyname_r_proto ttyname_r $hdrs
19569		eval $hasproto ;;
19570	*)	;;
19571	esac
19572	case "$d_ttyname_r_proto" in
19573	define)
19574	case "$ttyname_r_proto" in
19575	''|0) try='int ttyname_r(int, char*, size_t);'
19576	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBW ;;
19577	esac
19578	case "$ttyname_r_proto" in
19579	''|0) try='int ttyname_r(int, char*, int);'
19580	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBI ;;
19581	esac
19582	case "$ttyname_r_proto" in
19583	''|0) try='char* ttyname_r(int, char*, int);'
19584	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=B_IBI ;;
19585	esac
19586	case "$ttyname_r_proto" in
19587	''|0)	d_ttyname_r=undef
19588		ttyname_r_proto=0
19589		echo "Disabling ttyname_r, cannot determine prototype." >&4 ;;
19590	* )	case "$ttyname_r_proto" in
19591		REENTRANT_PROTO*) ;;
19592		*) ttyname_r_proto="REENTRANT_PROTO_$ttyname_r_proto" ;;
19593		esac
19594		echo "Prototype: $try" ;;
19595	esac
19596	;;
19597	*)	case "$usethreads" in
19598		define) echo "ttyname_r has no prototype, not using it." >&4 ;;
19599		esac
19600		d_ttyname_r=undef
19601		ttyname_r_proto=0
19602		;;
19603	esac
19604	;;
19605*)	ttyname_r_proto=0
19606	;;
19607esac
19608
19609: see if tzname[] exists
19610echo " "
19611if set tzname val -a d_tzname; eval $csym; $val; then
19612	val="$define"
19613	echo 'tzname[] found.' >&4
19614else
19615	val="$undef"
19616	echo 'tzname[] NOT found.' >&4
19617fi
19618set d_tzname
19619eval $setvar
19620
19621: Check if is a multiplatform env
19622case "$osname" in
19623darwin) multiarch="$define" ;;
19624esac
19625case "$multiarch" in
19626''|[nN]*) multiarch="$undef" ;;
19627esac
19628
19629: check for ordering of bytes in a UV
19630echo " "
19631case "$multiarch" in
19632*$define*)
19633	$cat <<EOM
19634You seem to be doing a multiarchitecture build,
19635skipping the byteorder check.
19636
19637EOM
19638	byteorder='ffff'
19639	;;
19640*)
19641	case "$byteorder" in
19642	'')
19643		$cat <<'EOM'
19644In the following, larger digits indicate more significance.  A big-endian
19645machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
19646little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
19647machines may have weird orders like 3412.  A Cray will report 87654321,
19648an Alpha will report 12345678. If the test program works the default is
19649probably right.
19650I'm now running the test program...
19651EOM
19652		$cat >try.c <<EOCP
19653#include <stdio.h>
19654#$i_stdlib I_STDLIB
19655#ifdef I_STDLIB
19656#include <stdlib.h>
19657#endif
19658#include <sys/types.h>
19659typedef $uvtype UV;
19660int main()
19661{
19662	int i;
19663	union {
19664		UV l;
19665		char c[$uvsize];
19666	} u;
19667
19668	if ($uvsize > 4)
19669		u.l = (((UV)0x08070605) << 32) | (UV)0x04030201;
19670	else
19671		u.l = (UV)0x04030201;
19672	for (i = 0; i < $uvsize; i++)
19673		printf("%c", u.c[i]+'0');
19674	printf("\n");
19675	exit(0);
19676}
19677EOCP
19678		xxx_prompt=y
19679		set try
19680		if eval $compile && $run ./try > /dev/null; then
19681			dflt=`$run ./try`
19682			case "$dflt" in
19683			[1-4][1-4][1-4][1-4]|12345678|87654321)
19684				echo "(The test program ran ok.)"
19685				echo "byteorder=$dflt"
19686				xxx_prompt=n
19687			;;
19688			????|????????) echo "(The test program ran ok.)" ;;
19689			*) echo "(The test program didn't run right for some reason.)" ;;
19690			esac
19691		else
19692			dflt='4321'
19693			cat <<'EOM'
19694(I can't seem to compile the test program.  Guessing big-endian...)
19695EOM
19696		fi
19697		case "$xxx_prompt" in
19698		y)
19699			rp="What is the order of bytes in $uvtype?"
19700			. ./myread
19701			byteorder="$ans"
19702			;;
19703		*)	byteorder=$dflt
19704			;;
19705		esac
19706		;;
19707	esac
19708	$rm_try
19709	;;
19710esac
19711
19712: Checking 32bit alignedness
19713$cat <<EOM
19714
19715Checking to see whether you can access character data unalignedly...
19716EOM
19717case "$d_u32align" in
19718'')   $cat >try.c <<EOCP
19719#include <stdio.h>
19720#$i_stdlib I_STDLIB
19721#ifdef I_STDLIB
19722#include <stdlib.h>
19723#endif
19724#define U32 $u32type
19725#define BYTEORDER 0x$byteorder
19726#define U8 $u8type
19727#include <signal.h>
19728#ifdef SIGBUS
19729$signal_t bletch(int s) { exit(4); }
19730#endif
19731int main() {
19732#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
19733    volatile U8 buf[8];
19734    volatile U32 *up;
19735    int i;
19736
19737    if (sizeof(U32) != 4) {
19738	printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
19739	exit(1);
19740    }
19741
19742    fflush(stdout);
19743
19744#ifdef SIGBUS
19745    signal(SIGBUS, bletch);
19746#endif
19747
19748    buf[0] = 0;
19749    buf[1] = 0;
19750    buf[2] = 0;
19751    buf[3] = 1;
19752    buf[4] = 0;
19753    buf[5] = 0;
19754    buf[6] = 0;
19755    buf[7] = 1;
19756
19757    for (i = 0; i < 4; i++) {
19758	up = (U32*)(buf + i);
19759	if (! ((*up == 1 << (8*i)) ||   /* big-endian */
19760	       (*up == 1 << (8*(3-i)))  /* little-endian */
19761	      )
19762	   )
19763	{
19764	    printf("read failed (%x)\n", *up);
19765	    exit(2);
19766	}
19767    }
19768
19769    /* write test */
19770    for (i = 0; i < 4; i++) {
19771	up = (U32*)(buf + i);
19772	*up = 0xBeef;
19773	if (*up != 0xBeef) {
19774	    printf("write failed (%x)\n", *up);
19775	    exit(3);
19776	}
19777    }
19778
19779    exit(0);
19780#else
19781    printf("1\n");
19782    exit(1);
19783#endif
19784    return 0;
19785}
19786EOCP
19787set try
19788if eval $compile_ok; then
19789	echo "(Testing for character data alignment may crash the test.  That's okay.)" >&4
19790	$run ./try 2>&1 >/dev/null
19791	case "$?" in
19792	0)	cat >&4 <<EOM
19793You can access character data pretty unalignedly.
19794EOM
19795		d_u32align="$undef"
19796		;;
19797	*)	cat >&4 <<EOM
19798It seems that you must access character data in an aligned manner.
19799EOM
19800		d_u32align="$define"
19801		;;
19802	esac
19803else
19804	rp='Can you access character data at unaligned addresses?'
19805	dflt='n'
19806	. ./myread
19807	case "$ans" in
19808	[yY]*)	d_u32align="$undef"  ;;
19809	*)	d_u32align="$define" ;;
19810	esac
19811fi
19812$rm_try
19813;;
19814esac
19815
19816: see if ualarm exists
19817set ualarm d_ualarm
19818eval $inlibc
19819
19820: see if umask exists
19821set umask d_umask
19822eval $inlibc
19823
19824: see if unordered exists
19825set unordered d_unordered
19826eval $inlibc
19827
19828: see if unsetenv exists
19829set unsetenv d_unsetenv
19830eval $inlibc
19831
19832: see if usleep exists
19833set usleep d_usleep
19834eval $inlibc
19835
19836: see if prototype for usleep is available
19837echo " "
19838set d_usleepproto usleep $i_unistd unistd.h
19839eval $hasproto
19840
19841: see if ustat exists
19842set ustat d_ustat
19843eval $inlibc
19844
19845: see if closedir exists
19846set closedir d_closedir
19847eval $inlibc
19848
19849case "$d_closedir" in
19850"$define")
19851	echo " "
19852	echo "Checking whether closedir() returns a status..." >&4
19853	cat > try.c <<EOM
19854#$i_dirent I_DIRENT		/**/
19855#$i_sysdir I_SYS_DIR		/**/
19856#$i_sysndir I_SYS_NDIR		/**/
19857#$i_systypes I_SYS_TYPES	/**/
19858
19859#if defined(I_SYS_TYPES)
19860#include <sys/types.h>
19861#endif
19862#if defined(I_DIRENT)
19863#include <dirent.h>
19864#else
19865#ifdef I_SYS_NDIR
19866#include <sys/ndir.h>
19867#else
19868#ifdef I_SYS_DIR
19869#include <sys/dir.h>
19870#endif
19871#endif
19872#endif
19873int main() { return closedir(opendir(".")); }
19874EOM
19875	set try
19876	if eval $compile_ok; then
19877		if $run ./try > /dev/null 2>&1 ; then
19878			echo "Yes, it does."
19879			val="$undef"
19880		else
19881			echo "No, it doesn't."
19882			val="$define"
19883		fi
19884	else
19885		echo "(I can't seem to compile the test program--assuming it doesn't)"
19886		val="$define"
19887	fi
19888	;;
19889*)
19890	val="$undef";
19891	;;
19892esac
19893set d_void_closedir
19894eval $setvar
19895$rm_try
19896
19897: see if there is a wait4
19898set wait4 d_wait4
19899eval $inlibc
19900
19901: see if waitpid exists
19902set waitpid d_waitpid
19903eval $inlibc
19904
19905: look for wcscmp
19906echo " "
19907$cat >try.c <<'EOCP'
19908#include <stdio.h>
19909#include <wchar.h>
19910int main ()
19911{
19912    wchar_t *s = L" ";
19913    return (wcscmp (s, s) ? 1 : 0);
19914    }
19915EOCP
19916set try
19917val="$undef"
19918if eval $compile; then
19919    `$run ./try`
19920    case "$?" in
19921	0)  echo "A working wcscmp() found." >&4
19922	    val="$define" ;;
19923	*)  echo "wcscmp() found, but it doesn't work" >&4
19924	    ;;
19925	esac
19926else
19927    echo "wcscmp() NOT found." >&4
19928    fi
19929set d_wcscmp
19930eval $setvar
19931$rm_try
19932
19933: see if wcstombs exists
19934set wcstombs d_wcstombs
19935eval $inlibc
19936
19937: look for wcsxfrm
19938echo " "
19939$cat >try.c <<'EOCP'
19940#include <errno.h>
19941#include <wchar.h>
19942int main ()
19943{
19944    wchar_t dst[4], *src = L" ";
19945    errno = 0;
19946    return (wcsxfrm (dst, src, 1) ? errno ? errno : 0 : 1);
19947    }
19948EOCP
19949set try
19950val="$undef"
19951if eval $compile; then
19952    `$run ./try`
19953    case "$?" in
19954	0)  echo "A working wcsxfrm() found." >&4
19955	    val="$define" ;;
19956	*)  echo "wcsxfrm() found, but it doesn't work" >&4
19957	    ;;
19958	esac
19959else
19960    echo "wcsxfrm() NOT found." >&4
19961    fi
19962set d_wcsxfrm
19963eval $setvar
19964$rm_try
19965
19966: see if wctomb exists
19967set wctomb d_wctomb
19968eval $inlibc
19969
19970: see if writev exists
19971set writev d_writev
19972eval $inlibc
19973
19974: check for alignment requirements
19975echo " "
19976case "$alignbytes" in
19977    '') echo "Checking alignment constraints..." >&4
19978	$cat >try.c <<EOCP
19979#include <stdio.h>
19980struct foobar {
19981    char foo;
19982    $nvtype bar;
19983} try_algn;
19984int main()
19985{
19986    printf("%d\n", (int)((char *)&try_algn.bar - (char *)&try_algn.foo));
19987    return(0);
19988}
19989EOCP
19990	set try
19991	if eval $compile_ok; then
19992	    dflt=`$run ./try`
19993	else
19994	    dflt='8'
19995	    echo "(I can't seem to compile the test program...)"
19996	fi
19997	case "$multiarch" in
19998	    *$define*)
19999		: The usual safe value is 8, but Darwin with -Duselongdouble
20000		: needs 16.  Hence, we will take 8 as a minimum, but allow
20001		: Configure to pick a larger value if needed.
20002		if $test "$dflt" -lt 8; then
20003		    dflt='8'
20004		    echo "Setting alignment to 8 for multiarch support.">&4
20005		fi
20006		;;
20007	esac
20008	;;
20009    *) dflt="$alignbytes"
20010	;;
20011esac
20012rp="Doubles must be aligned on a how-many-byte boundary?"
20013. ./myread
20014alignbytes="$ans"
20015$rm_try
20016
20017: set the base revision
20018baserev=5.0
20019
20020: length of character in bytes. Is always 1, otherwise it is not C
20021: This used to be a test using sizeof
20022charsize=1
20023
20024: Check for the number of bits in a character
20025case "$charbits" in
20026'')	echo "Checking how long a character is (in bits)..." >&4
20027	$cat >try.c <<EOCP
20028#include <stdio.h>
20029int main ()
20030{
20031    int n;
20032    unsigned char c;
20033    for (c = 1, n = 0; c; c <<= 1, n++) ;
20034    printf ("%d\n", n);
20035    return (0);
20036    }
20037EOCP
20038	set try
20039	if eval $compile_ok; then
20040		dflt=`$run ./try`
20041	else
20042		dflt='8'
20043		echo "(I can't seem to compile the test program.  Guessing...)"
20044	fi
20045	;;
20046*)
20047	dflt="$charbits"
20048	;;
20049esac
20050rp="What is the length of a character (in bits)?"
20051. ./myread
20052charbits="$ans"
20053$rm_try
20054case "$charbits" in
200558)	;;
20056*)	cat >&4 << EOM
20057Your system has an unsigned character size of $charbits bits, which
20058is rather unusual (normally it is 8 bits).  Perl likely will not work
20059correctly on your system, with subtle bugs in various places.
20060EOM
20061	rp='Do you really want to continue?'
20062	dflt='n'
20063	. ./myread
20064	case "$ans" in
20065		[yY])	echo >&4 "Okay, continuing."	;;
20066		*)	exit 1				;;
20067	esac
20068esac
20069
20070: how do we concatenate cpp tokens here?
20071echo " "
20072echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
20073$cat >cpp_stuff.c <<'EOCP'
20074#define RCAT(a,b)a/**/b
20075#define ACAT(a,b)a ## b
20076RCAT(Rei,ser)
20077ACAT(Cir,cus)
20078EOCP
20079$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
20080if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
20081	echo "Oh!  Smells like ANSI's been here." >&4
20082	echo "We can catify or stringify, separately or together!"
20083	cpp_stuff=42
20084elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
20085	echo "Ah, yes!  The good old days!" >&4
20086	echo "However, in the good old days we don't know how to stringify and"
20087	echo "catify at the same time."
20088	cpp_stuff=1
20089else
20090	$cat >&4 <<EOM
20091Hmm, I don't seem to be able to concatenate tokens with your cpp.
20092You're going to have to edit the values of CAT[2-5] in config.h...
20093EOM
20094	cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
20095fi
20096$rm -f cpp_stuff.*
20097
20098: see if this is a db.h system
20099set db.h i_db
20100eval $inhdr
20101
20102case "$i_db" in
20103$define)
20104	: Check db version.
20105	echo " "
20106	echo "Checking Berkeley DB version ..." >&4
20107	$cat >try.c <<EOCP
20108#include <sys/types.h>
20109#include <stdio.h>
20110#$i_stdlib I_STDLIB
20111#ifdef I_STDLIB
20112#include <stdlib.h>
20113#endif
20114#include <db.h>
20115int main(int argc, char *argv[])
20116{
20117#ifdef DB_VERSION_MAJOR	/* DB version >= 2 */
20118    int Major, Minor, Patch ;
20119    unsigned long Version ;
20120    (void)db_version(&Major, &Minor, &Patch) ;
20121    if (argc == 2) {
20122        printf("%d %d %d %d %d %d\n",
20123               DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
20124               Major, Minor, Patch);
20125        exit(0);
20126    }
20127    printf("You have Berkeley DB Version 2 or greater.\n");
20128
20129    printf("db.h is from Berkeley DB Version %d.%d.%d\n",
20130		DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
20131    printf("libdb is from Berkeley DB Version %d.%d.%d\n",
20132		Major, Minor, Patch) ;
20133
20134    /* check that db.h & libdb are compatible */
20135    if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
20136	printf("db.h and libdb are incompatible.\n") ;
20137        exit(3);
20138    }
20139
20140    printf("db.h and libdb are compatible.\n") ;
20141
20142    Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
20143		+ DB_VERSION_PATCH ;
20144
20145    /* needs to be >= 2.3.4 */
20146    if (Version < 2003004) {
20147    /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
20148	printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
20149        exit(2);
20150    }
20151
20152    exit(0);
20153#else
20154#if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
20155    if (argc == 2) {
20156        printf("1 0 0\n");
20157        exit(0);
20158    }
20159    printf("You have Berkeley DB Version 1.\n");
20160    exit(0);	/* DB version < 2: the coast is clear. */
20161#else
20162    exit(1);	/* <db.h> not Berkeley DB? */
20163#endif
20164#endif
20165}
20166EOCP
20167	set try
20168	if eval $compile_ok && $run ./try; then
20169		echo 'Looks OK.' >&4
20170		set `$run ./try 1`
20171		db_version_major=$1
20172		db_version_minor=$2
20173		db_version_patch=$3
20174	else
20175		echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
20176		i_db=$undef
20177		case " $libs " in
20178		*"-ldb "*)
20179			: Remove db from list of libraries to use
20180			echo "Removing unusable -ldb from library list" >&4
20181			set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
20182			shift
20183			libs="$*"
20184			echo "libs = $libs" >&4
20185			;;
20186		esac
20187	fi
20188	$rm_try
20189	;;
20190esac
20191
20192case "$i_db" in
20193define)
20194	: Check the return type needed for hash
20195	echo " "
20196	echo "Checking return type needed for hash for Berkeley DB ..." >&4
20197	$cat >try.c <<EOCP
20198#include <sys/types.h>
20199#include <db.h>
20200
20201#ifndef DB_VERSION_MAJOR
20202u_int32_t hash_cb (const void* ptr, size_t size)
20203{
20204	return 0;
20205}
20206HASHINFO info;
20207int main()
20208{
20209	info.hash = hash_cb;
20210}
20211#endif
20212EOCP
20213	if $cc $ccflags -c try.c >try.out 2>&1 ; then
20214		if $contains warning try.out >>/dev/null 2>&1 ; then
20215			db_hashtype='int'
20216		else
20217			db_hashtype='u_int32_t'
20218		fi
20219	else
20220		: XXX Maybe we should just give up here.
20221		db_hashtype=u_int32_t
20222		$cat try.out >&4
20223		echo "Help:  I can't seem to compile the db test program." >&4
20224		echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
20225	fi
20226	$rm_try
20227	echo "Your version of Berkeley DB uses $db_hashtype for hash."
20228	;;
20229*)	db_hashtype=u_int32_t
20230	;;
20231esac
20232case "$i_db" in
20233define)
20234	: Check the return type needed for prefix
20235	echo " "
20236	echo "Checking return type needed for prefix for Berkeley DB ..." >&4
20237	cat >try.c <<EOCP
20238#include <sys/types.h>
20239#include <db.h>
20240
20241#ifndef DB_VERSION_MAJOR
20242size_t prefix_cb (const DBT *key1, const DBT *key2)
20243{
20244	return 0;
20245}
20246BTREEINFO info;
20247int main()
20248{
20249	info.prefix = prefix_cb;
20250}
20251#endif
20252EOCP
20253	if $cc $ccflags -c try.c  >try.out 2>&1 ; then
20254		if $contains warning try.out >>/dev/null 2>&1 ; then
20255			db_prefixtype='int'
20256		else
20257			db_prefixtype='size_t'
20258		fi
20259	else
20260		db_prefixtype='size_t'
20261		: XXX Maybe we should just give up here.
20262		$cat try.out >&4
20263		echo "Help:  I can't seem to compile the db test program." >&4
20264		echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
20265	fi
20266	$rm_try
20267	echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
20268	;;
20269*)	db_prefixtype='size_t'
20270	;;
20271esac
20272
20273: Include . in @INC
20274$cat <<EOM
20275
20276Historically Perl has provided a final fallback of the current working
20277directory '.' when searching for a library. This, however, can lead to
20278problems when a Perl program which loads optional modules is called from
20279a shared directory. This can lead to executing unexpected code.
20280
20281EOM
20282
20283# When changing to exclude by default:
20284case "$default_inc_excludes_dot" in
20285    $undef|false|[nN]*) dflt="n" ;;
20286    *)                  dflt="y" ;;
20287esac
20288# To turn exclude off by default:
20289#case "$default_inc_excludes_dot" in
20290#    $define|true|[yY]*) dflt="y" ;;
20291#    *)                  dflt="n" ;;
20292#esac
20293
20294rp='Exclude '.' from @INC by default? '
20295. ./myread
20296case "$ans" in
20297    [nN]|undef) default_inc_excludes_dot="$undef"  ;;
20298    *)          default_inc_excludes_dot="$define" ;;
20299esac
20300
20301: Check what kind of inf/nan your system has
20302$echo "Checking the kind of infinities and nans you have..." >&4
20303$echo "(The following tests may crash.  That's okay.)" >&4
20304$cat >try.c <<EOP
20305#define DOUBLESIZE $doublesize
20306#$d_longdbl HAS_LONG_DOUBLE
20307#ifdef HAS_LONG_DOUBLE
20308#define LONG_DOUBLESIZE $longdblsize
20309#define LONG_DOUBLEKIND $longdblkind
20310#endif
20311#include <math.h>
20312#include <string.h>
20313#include <stdio.h>
20314/* Note that whether the sign bit is on or off
20315 * for NaN depends on the CPU/FPU, and possibly
20316 * can be affected by the build toolchain.
20317 *
20318 * For example for older MIPS and HP-PA 2.0 the quiet NaN is:
20319 * 0x7f, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
20320 * 0x7f, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20321 * (respectively) as opposed to the more usual
20322 * 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20323 *
20324 * Pre-IEEE-754 floating point format do not even have inf/nan support
20325 * at all.  They might have a "max" value (DBL_MAX), which may be deadly
20326 * to even mention, causing immediate SIGFPE or equivalent: this is
20327 * the case with VAX floating point, for example.
20328 */
20329static void bytes(void *v, unsigned int n) {
20330  unsigned char *p = (unsigned char *)v;
20331  int i;
20332  for (i = 0; i < n; i++) {
20333    printf("0x%02x%s", p[i], i < n - 1 ? ", " : "\n");
20334  }
20335}
20336int main(int argc, char *argv[]) {
20337   /* We cannot use 1.0/0.0 and 0.0/0.0 (with L suffixes for long double)
20338    * because some compilers are 'smart' and not only warn but refuse to
20339    * compile such 'illegal' values. */
20340   double dinf = exp(1e9);
20341   double dnan = sqrt(-1.0);
20342#ifdef HAS_LONG_DOUBLE
20343   long double ldinf = (long double)exp(1e9);
20344   long double ldnan = (long double)sqrt(-1.0);
20345# if LONG_DOUBLEKIND == 3 || LONG_DOUBLEKIND == 4
20346/* the 80-bit long doubles might have garbage in their excess bytes */
20347    memset((char *)&ldinf + 10, '\0', LONG_DOUBLESIZE - 10);
20348    memset((char *)&ldnan + 10, '\0', LONG_DOUBLESIZE - 10);
20349# endif
20350  if (argc == 2) {
20351    switch (argv[1][0]) {
20352    case '1': bytes(&dinf, sizeof(dinf)); break;
20353    case '2': bytes(&dnan, sizeof(dnan)); break;
20354    case '3': bytes(&ldinf, sizeof(ldinf)); break;
20355    case '4': bytes(&ldnan, sizeof(ldnan)); break;
20356#endif
20357    }
20358  }
20359  return 0;
20360}
20361EOP
20362set try
20363if eval $compile; then
20364    doubleinfbytes=`$run ./try 1`
20365    doublenanbytes=`$run ./try 2`
20366    case "$d_longdbl" in
20367    $define)
20368      longdblinfbytes=`$run ./try 3`
20369      longdblnanbytes=`$run ./try 4`
20370      ;;
20371    esac
20372else
20373    # Defaults in case the above test program failed.
20374    case "$doublekind" in
20375    1) # IEEE 754 32-bit LE
20376       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f'
20377       doublenanbytes='0x00, 0x00, 0xf8, 0x7f'
20378       ;;
20379    2) # IEEE 754 32-bit BE
20380       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00'
20381       doublenanbytes='0x7f, 0xf8, 0x00, 0x00'
20382       ;;
20383    3) # IEEE 754 64-bit LE
20384       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20385       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20386       ;;
20387    4) # IEEE 754 64-bit BE
20388       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20389       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20390       ;;
20391    5) # IEEE 754 128-bit LE
20392       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20393       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20394       ;;
20395    6) # IEEE 754 128-bit BE
20396       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20397       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20398       ;;
20399    7) # IEEE 754 64-bit mixed: 32-bit LEs in BE
20400       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00'
20401       doublenanbytes='0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00'
20402       ;;
20403    8) # IEEE 754 64-bit mixed: 32-bit BEs in LE
20404       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00'
20405       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00'
20406       ;;
20407    9|10|11|12|13|14) # VAX/Cray/IBM floating point formats, no inf/nan.
20408       doubleinfbytes=$undef
20409       doublenanbytes=$undef
20410       ;;
20411    *) # No idea.
20412       doubleinfbytes=$undef
20413       doublenanbytes=$undef
20414       ;;
20415    esac
20416    case "$longdblkind" in
20417    1) # IEEE 754 128-bit LE
20418       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f'
20419       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f'
20420       ;;
20421    2) # IEEE 754 128-bit BE
20422       longdblinfbytes='0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20423       longdblnanbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20424       ;;
20425    3) # IEEE 754 80-bit LE, 12 or 16 bytes (x86)
20426       case "$longdblsize" in
20427       12) # x86 32-bit (96 bits, or 4 x 32, or 12 x 8)
20428           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00'
20429           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00'
20430           ;;
20431       16) # x86_64
20432           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20433           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20434           ;;
20435       *)  # No idea.
20436           longdblinfbytes=$undef
20437           longdblnanbytes=$undef
20438       ;;
20439       esac
20440       ;;
20441    4) # IEEE 754 80-bit BE, 12 or 16 bytes
20442       case "$longdblsize" in
20443       12) # 32-bit system
20444           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20445           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20446           ;;
20447       16) # 64-bit system
20448           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20449           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20450           ;;
20451       *)  # No idea.
20452           longdblinfbytes=$undef
20453           longdblnanbytes=$undef
20454       ;;
20455       esac
20456       ;;
20457    5) # 128-bit LE-LE "double double"
20458       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20459       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20460       ;;
20461    6) # 128-bit BE-BE "double double"
20462       longdblinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20463       longdblnanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20464       ;;
20465    7) # 128-bit LE-BE "double double"
20466       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20467       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20468       ;;
20469    8) # 128-bit BE-LE "double double"
20470       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20471       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20472       ;;
20473    9|10|11|12|13|14) # VAX/Cray/IBM floating point formats, no inf/nan.
20474       longdblinfbytes=$undef
20475       longdblnanbytes=$undef
20476       ;;
20477    *) # No idea.
20478       longdblinfbytes=$undef
20479       longdblnanbytes=$undef
20480       ;;
20481    esac
20482fi
20483# In case the program crashed the values are empty, turn them undef.
20484case "$doubleinfbytes" in
20485'') doubleinfbytes=$undef ;;
20486esac
20487case "$doublenanbytes" in
20488'') doublenanbytes=$undef ;;
20489esac
20490case "$longdblinfbytes" in
20491'') longdblinfbytes=$undef ;;
20492esac
20493case "$longdblnanbytes" in
20494'') longdblnanbytes=$undef ;;
20495esac
20496$rm_try
20497
20498: Check the length of the double mantissa
20499$echo "Checking how many mantissa bits your doubles have..." >&4
20500$cat >try.c <<EOP
20501#$i_sunmath I_SUNMATH
20502#include <float.h>
20503#ifdef I_SUNMATH
20504# include <sunmath.h>
20505#endif
20506#ifdef DBL_MANT_DIG
20507# define BITS (DBL_MANT_DIG - 1) /* the implicit bit does not count */
20508#endif
20509#include <stdio.h>
20510int main(int argc, char *argv[]) {
20511#ifdef BITS
20512  printf("%d\n", BITS);
20513#endif
20514  return 0;
20515}
20516EOP
20517set try
20518if eval $compile; then
20519    doublemantbits=`$run ./try`
20520else
20521    doublemantbits="$undef"
20522fi
20523$rm_try
20524
20525: Check the length of the longdouble mantissa
20526$echo "Checking how many mantissa bits your long doubles have..." >&4
20527$cat >try.c <<EOP
20528#$i_sunmath I_SUNMATH
20529#include <float.h>
20530#ifdef I_SUNMATH
20531# include <sunmath.h>
20532#endif
20533#$d_longdbl HAS_LONG_DOUBLE
20534#if defined(HAS_LONG_DOUBLE) && defined(LDBL_MANT_DIG)
20535# if ($longdblkind == 3) || ($longdblkind == 4) /* 80-bit extended precision */
20536/* This format has no implicit bit.  Beware, however, that for
20537 * this format the bare LDBL_MANT_DIG is misleading for inf/nan:
20538 * the top three bits are used for inf (100) / qnan (11x) / snan (101),
20539 * and the top bit must have been one since 387, zero is plain invalid.
20540 * For normal fp values, the LDBL_MANT_DIG is fine, though. */
20541#  define BITS LDBL_MANT_DIG
20542# elif ($longdblkind == 5 || $longdblkind == 6 || $longdblkind == 7 || $longdblkind == 8) /* double double */
20543/* LDBL_MANT_DIG of 106 (twice 53) would be logical, but for some
20544 * reason e.g. Irix thinks 107.  But in any case, we want only
20545 * the number of real bits, the implicit bits are of no interest.  */
20546#  define BITS 2 * (DBL_MANT_DIG - 1)
20547# else
20548#  define BITS (LDBL_MANT_DIG - 1) /* the implicit bit does not count */
20549# endif
20550#endif
20551#include <stdio.h>
20552int main(int argc, char *argv[]) {
20553#ifdef BITS
20554  printf("%d\n", BITS);
20555#endif
20556  return 0;
20557}
20558EOP
20559set try
20560if eval $compile; then
20561    longdblmantbits=`$run ./try`
20562else
20563    longdblmantbits="$undef"
20564fi
20565$rm_try
20566
20567: Check the length of the NV mantissa
20568$echo "Checking how many mantissa bits your NVs have..." >&4
20569if test "X$usequadmath" = "X$define"; then
20570  nvmantbits=112 # 128-1-15
20571else
20572  if test "X$nvsize" = "X$doublesize"; then
20573    nvmantbits="$doublemantbits"
20574  else
20575     if test "X$nvsize" = "X$longdblsize"; then
20576       nvmantbits="$longdblmantbits"
20577     else
20578       nvmantbits="$undef"
20579     fi
20580  fi
20581fi
20582
20583: How can we generate normalized random numbers ?
20584echo " "
20585echo "Using our internal random number implementation..." >&4
20586
20587case "$ccflags" in
20588*-Dmy_rand=*|*-Dmy_srand=*)
20589	echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
20590	ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
20591	ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
20592	ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
20593	;;
20594esac
20595
20596randfunc=drand48
20597drand01="drand48()"
20598seedfunc="srand48"
20599randbits=48
20600randseedtype=U32
20601
20602: Probe whether dtrace builds an object, as newer Illumos requires an input
20603: object file that uses at least one of the probes defined in the .d file
20604case "$usedtrace" in
20605$define)
20606    case "$dtracexnolibs" in
20607    $define|true|[yY]*)
20608        dtracexnolibs=$define
20609	$dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h
20610	;;
20611    ' '|'')
20612        if $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
20613	     dtracexnolibs=$define
20614	     echo "Your dtrace accepts -xnolibs"
20615	elif $dtrace -h -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
20616	     dtracexnolibs=$undef
20617	     echo "Your dtrace doesn't accept -xnolibs"
20618	else
20619             echo "Your dtrace doesn't work at all, try building without dtrace support" >&4
20620	     exit 1
20621	fi
20622	;;
20623    *)
20624        dtracexnolibs=$undef
20625	$dtrace -h -s ../perldtrace.d -o perldtrace.h
20626	;;
20627    esac
20628    case $dtracexnolibs in
20629    $define) xnolibs=-xnolibs ;;
20630    *) xnolibs= ;;
20631    esac
20632
20633    case "$dtraceobject" in
20634    $define|true|[yY]*)
20635        dtraceobject=$define
20636        ;;
20637    ' '|'')
20638        $cat >try.c <<EOM
20639#include "perldtrace.h"
20640int main(void) {
20641    PERL_LOADED_FILE("dummy");
20642    return 0;
20643}
20644EOM
20645        dtraceobject=$undef
20646        if $cc -c -o try.o $optimize $ccflags try.c \
20647                    && $dtrace -G $xnolibs -s ../perldtrace.d try.o >/dev/null 2>&1; then
20648                dtraceobject=$define
20649            echo "Your dtrace builds an object file"
20650        fi
20651        ;;
20652    *) dtraceobject=$undef ;;
20653    esac
20654    $rm_try perldtrace.o perldtrace.h
20655esac
20656
20657: Determine if this is an EBCDIC system
20658echo " "
20659echo "Determining whether or not we are on an EBCDIC system..." >&4
20660$cat >try.c <<'EOM'
20661int main()
20662{
20663  if ('M'==0xd4) return 0;
20664  return 1;
20665}
20666EOM
20667
20668val=$undef
20669set try
20670if eval $compile_ok; then
20671	if $run ./try; then
20672		echo "You seem to speak EBCDIC." >&4
20673		val="$define"
20674	else
20675		echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF-8." >&4
20676	fi
20677else
20678	echo "I'm unable to compile the test program." >&4
20679	echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
20680fi
20681$rm_try
20682set ebcdic
20683eval $setvar
20684
20685: Check how to flush
20686echo " "
20687$cat >&4 <<EOM
20688Checking how to flush all pending stdio output...
20689EOM
20690# I only know how to find the first 32 possibly open files on SunOS.
20691# See also hints/sunos_4_1.sh and util.c  --AD
20692case "$osname" in
20693sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
20694esac
20695$cat >>try.c <<EOCP
20696#include <stdio.h>
20697#$i_stdlib I_STDLIB
20698#ifdef I_STDLIB
20699#include <stdlib.h>
20700#endif
20701#$i_unistd I_UNISTD
20702#ifdef I_UNISTD
20703# include <unistd.h>
20704#endif
20705#$d_sysconf HAS_SYSCONF
20706#$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
20707#ifdef HAS_STDIO_STREAM_ARRAY
20708# define STDIO_STREAM_ARRAY $stdio_stream_array
20709#endif
20710int main() {
20711  FILE* p;
20712  unlink("try.out");
20713  p = fopen("try.out", "w");
20714#ifdef TRY_FPUTC
20715  fputc('x', p);
20716#else
20717# ifdef TRY_FPRINTF
20718  fprintf(p, "x");
20719# endif
20720#endif
20721#ifdef TRY_FFLUSH_NULL
20722  fflush(NULL);
20723#endif
20724#ifdef TRY_FFLUSH_ALL
20725  {
20726    long open_max = -1;
20727# ifdef PERL_FFLUSH_ALL_FOPEN_MAX
20728    open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
20729# else
20730#  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
20731    open_max = sysconf(_SC_OPEN_MAX);
20732#  else
20733#   ifdef FOPEN_MAX
20734    open_max = FOPEN_MAX;
20735#   else
20736#    ifdef OPEN_MAX
20737    open_max = OPEN_MAX;
20738#    else
20739#     ifdef _NFILE
20740    open_max = _NFILE;
20741#     endif
20742#    endif
20743#   endif
20744#  endif
20745# endif
20746# ifdef HAS_STDIO_STREAM_ARRAY
20747    if (open_max > 0) {
20748      long i;
20749      for (i = 0; i < open_max; i++)
20750	    if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
20751		STDIO_STREAM_ARRAY[i]._file < open_max &&
20752		STDIO_STREAM_ARRAY[i]._flag)
20753		fflush(&STDIO_STREAM_ARRAY[i]);
20754    }
20755  }
20756# endif
20757#endif
20758  _exit(42);
20759}
20760EOCP
20761: first we have to find out how _not_ to flush
20762$to try.c
20763if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
20764    output=''
20765    set try -DTRY_FPUTC
20766    if eval $compile; then
20767	    $run ./try 2>/dev/null
20768	    code="$?"
20769	    $from try.out
20770	    if $test ! -s try.out -a "X$code" = X42; then
20771		output=-DTRY_FPUTC
20772	    fi
20773    fi
20774    case "$output" in
20775    '')
20776	    set try -DTRY_FPRINTF
20777	    if eval $compile; then
20778		    $run ./try 2>/dev/null
20779		    code="$?"
20780		    $from try.out
20781		    if $test ! -s try.out -a "X$code" = X42; then
20782			output=-DTRY_FPRINTF
20783		    fi
20784	    fi
20785	;;
20786    esac
20787fi
20788: check for fflush NULL behavior
20789case "$fflushNULL" in
20790'')	set try -DTRY_FFLUSH_NULL $output
20791	if eval $compile; then
20792		$run ./try 2>/dev/null
20793		code="$?"
20794		$from try.out
20795		if $test -s try.out -a "X$code" = X42; then
20796			fflushNULL="`$cat try.out`"
20797		else
20798			if $test "X$code" != X42; then
20799				$cat >&4 <<EOM
20800(If this test failed, don't worry, we'll try another method shortly.)
20801EOM
20802			fi
20803		fi
20804	fi
20805	$rm -f core try.core core.try.*
20806	case "$fflushNULL" in
20807	x)	$cat >&4 <<EOM
20808Your fflush(NULL) works okay for output streams.
20809Let's see if it clobbers input pipes...
20810EOM
20811# As of mid-March 2000 all versions of Solaris appear to have a stdio
20812# bug that improperly flushes the input end of pipes.  So we avoid the
20813# autoflush on fork/system/exec support for now. :-(
20814$cat >tryp.c <<EOCP
20815#include <stdio.h>
20816int
20817main(int argc, char **argv)
20818{
20819    char buf[1024];
20820    int i;
20821    char *bp = buf;
20822    while (1) {
20823	while ((i = getc(stdin)) != -1
20824	       && (*bp++ = i) != '\n'
20825	       && bp < &buf[1024])
20826	/* DO NOTHING */ ;
20827	*bp = '\0';
20828	fprintf(stdout, "%s", buf);
20829	fflush(NULL);
20830	if (i == -1)
20831	    return 0;
20832	bp = buf;
20833    }
20834}
20835EOCP
20836		fflushNULL="$define"
20837		set tryp
20838		if eval $compile; then
20839		    $rm -f tryp.out
20840		    # Copy the .c file to the remote host ($to is an ssh-alike if targethost is set)
20841		    if $test "X$targethost" != X; then
20842			$to tryp.c
20843			$to tryp
20844			$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
20845		    else
20846			$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
20847		    fi
20848		    if cmp tryp.c tryp.out >/dev/null 2>&1; then
20849		       $cat >&4 <<EOM
20850fflush(NULL) seems to behave okay with input streams.
20851EOM
20852			fflushNULL="$define"
20853		    else
20854			$cat >&4 <<EOM
20855Ouch, fflush(NULL) clobbers input pipes!  We will not use it.
20856EOM
20857			fflushNULL="$undef"
20858		    fi
20859		fi
20860		$rm -f core tryp.c tryp.core core.tryp.*
20861		;;
20862	'')	$cat >&4 <<EOM
20863Your fflush(NULL) isn't working (contrary to ANSI C).
20864EOM
20865		fflushNULL="$undef"
20866		;;
20867	*)	$cat >&4 <<EOM
20868Cannot figure out whether your fflush(NULL) works or not.
20869I'm assuming it doesn't (contrary to ANSI C).
20870EOM
20871		fflushNULL="$undef"
20872		;;
20873	esac
20874	;;
20875$define|true|[yY]*)
20876	fflushNULL="$define"
20877	;;
20878*)
20879	fflushNULL="$undef"
20880	;;
20881esac
20882: check explicit looping only if NULL did not work, and if the pipe
20883: bug does not show up on an explicit flush too
20884case "$fflushNULL" in
20885"$undef")
20886	$cat >tryp.c <<EOCP
20887#include <stdio.h>
20888int
20889main(int argc, char **argv)
20890{
20891    char buf[1024];
20892    int i;
20893    char *bp = buf;
20894    while (1) {
20895	while ((i = getc(stdin)) != -1
20896	       && (*bp++ = i) != '\n'
20897	       && bp < &buf[1024])
20898	/* DO NOTHING */ ;
20899	*bp = '\0';
20900	fprintf(stdout, "%s", buf);
20901	fflush(stdin);
20902	if (i == -1)
20903	    return 0;
20904	bp = buf;
20905    }
20906}
20907EOCP
20908	set tryp
20909	if eval $compile; then
20910	    $rm -f tryp.out
20911	    if $test "X$targethost" != X; then
20912		$to tryp.c
20913		$to tryp
20914		$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
20915	    else
20916		$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
20917	    fi
20918	    if cmp tryp.c tryp.out >/dev/null 2>&1; then
20919	       $cat >&4 <<EOM
20920Good, at least fflush(stdin) seems to behave okay when stdin is a pipe.
20921EOM
20922		: now check for fflushall behaviour
20923		case "$fflushall" in
20924		'')	set try -DTRY_FFLUSH_ALL $output
20925			if eval $compile; then
20926				$cat >&4 <<EOM
20927(Now testing the other method--but note that this also may fail.)
20928EOM
20929				$run ./try 2>/dev/null
20930				code=$?
20931				$from try.out
20932				if $test -s try.out -a "X$code" = X42; then
20933					fflushall="`$cat try.out`"
20934				fi
20935			fi
20936			$rm_try
20937			case "$fflushall" in
20938			x)	$cat >&4 <<EOM
20939Whew. Flushing explicitly all the stdio streams works.
20940EOM
20941				fflushall="$define"
20942				;;
20943			'')	$cat >&4 <<EOM
20944Sigh. Flushing explicitly all the stdio streams doesn't work.
20945EOM
20946				fflushall="$undef"
20947				;;
20948			*)	$cat >&4 <<EOM
20949Cannot figure out whether flushing stdio streams explicitly works or not.
20950I'm assuming it doesn't.
20951EOM
20952				fflushall="$undef"
20953				;;
20954			esac
20955			;;
20956		"$define"|true|[yY]*)
20957			fflushall="$define"
20958			;;
20959		*)
20960			fflushall="$undef"
20961			;;
20962		esac
20963	    else
20964		$cat >&4 <<EOM
20965All is futile.  Even fflush(stdin) clobbers input pipes!
20966EOM
20967		fflushall="$undef"
20968	    fi
20969	else
20970	    fflushall="$undef"
20971	fi
20972	$rm -f core tryp.c tryp.core core.tryp.*
20973	;;
20974*)	fflushall="$undef"
20975	;;
20976esac
20977
20978case "$fflushNULL$fflushall" in
20979undefundef)
20980	$cat <<EOM
20981OK, I give up.  I cannot figure out how to flush pending stdio output.
20982We won't be flushing handles at all before fork/exec/popen.
20983EOM
20984	;;
20985esac
20986$rm_try tryp
20987
20988: Store the full pathname to the ar program for use in the C program
20989: Respect a hint or command line value for full_ar.
20990case "$full_ar" in
20991'') full_ar=$ar ;;
20992esac
20993
20994: Store the full pathname to the sed program for use in the C program
20995full_sed=$sed
20996
20997: see what type gids are declared as in the kernel
20998echo " "
20999echo "Looking for the type for group ids returned by getgid()."
21000set gid_t gidtype xxx stdio.h sys/types.h
21001eval $typedef
21002case "$gidtype" in
21003xxx)
21004	xxx=`./findhdr sys/user.h`
21005	set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
21006	case $1 in
21007	unsigned) dflt="$1 $2" ;;
21008	*) dflt="$1" ;;
21009	esac
21010	;;
21011*) dflt="$gidtype";;
21012esac
21013case "$gidtype" in
21014gid_t) echo "gid_t found." ;;
21015*)	rp="What is the type for group ids returned by getgid()?"
21016	. ./myread
21017	gidtype="$ans"
21018	;;
21019esac
21020
21021: Check the size of GID
21022echo " "
21023case "$gidtype" in
21024*_t) zzz="$gidtype"	;;
21025*)   zzz="gid"		;;
21026esac
21027echo "Checking the size of $zzz..." >&4
21028cat > try.c <<EOCP
21029#include <sys/types.h>
21030#include <stdio.h>
21031#$i_stdlib I_STDLIB
21032#ifdef I_STDLIB
21033#include <stdlib.h>
21034#endif
21035int main() {
21036    printf("%d\n", (int)sizeof($gidtype));
21037    exit(0);
21038}
21039EOCP
21040set try
21041if eval $compile_ok; then
21042	yyy=`$run ./try`
21043	case "$yyy" in
21044	'')	gidsize=4
21045		echo "(I can't execute the test program--guessing $gidsize.)" >&4
21046		;;
21047	*)	gidsize=$yyy
21048		echo "Your $zzz is $gidsize bytes long."
21049		;;
21050	esac
21051else
21052	gidsize=4
21053	echo "(I can't compile the test program--guessing $gidsize.)" >&4
21054fi
21055
21056: Check if GID is signed
21057echo " "
21058case "$gidtype" in
21059*_t) zzz="$gidtype"	;;
21060*)   zzz="gid"		;;
21061esac
21062echo "Checking the sign of $zzz..." >&4
21063cat > try.c <<EOCP
21064#include <sys/types.h>
21065#include <stdio.h>
21066int main() {
21067	$gidtype foo = -1;
21068	if (foo < 0)
21069		printf("-1\n");
21070	else
21071		printf("1\n");
21072}
21073EOCP
21074set try
21075if eval $compile; then
21076	yyy=`$run ./try`
21077	case "$yyy" in
21078	'')	gidsign=1
21079		echo "(I can't execute the test program--guessing unsigned.)" >&4
21080		;;
21081	*)	gidsign=$yyy
21082		case "$gidsign" in
21083		 1) echo "Your $zzz is unsigned." ;;
21084		-1) echo "Your $zzz is signed."   ;;
21085		esac
21086		;;
21087	esac
21088else
21089	gidsign=1
21090	echo "(I can't compile the test program--guessing unsigned.)" >&4
21091fi
21092
21093: Check 64bit sizes
21094echo " "
21095
21096if $test X"$quadtype" != X; then
21097
21098echo "Checking how to print 64-bit integers..." >&4
21099
21100if $test X"$sPRId64" = X -a X"$quadtype" = Xint; then
21101	$cat >try.c <<'EOCP'
21102#include <sys/types.h>
21103#include <stdio.h>
21104int main() {
21105  int q = 12345678901;
21106  printf("%ld\n", q);
21107}
21108EOCP
21109	set try
21110	if eval $compile; then
21111		yyy=`$run ./try`
21112		case "$yyy" in
21113		12345678901)
21114			sPRId64='"d"'; sPRIi64='"i"'; sPRIu64='"u"';
21115			sPRIo64='"o"'; sPRIx64='"x"'; sPRIXU64='"X"';
21116			echo "We will use %d."
21117			;;
21118		esac
21119	fi
21120fi
21121
21122if $test X"$sPRId64" = X -a X"$quadtype" = Xlong; then
21123	$cat >try.c <<'EOCP'
21124#include <sys/types.h>
21125#include <stdio.h>
21126int main() {
21127  long q = 12345678901;
21128  printf("%ld\n", q);
21129}
21130EOCP
21131	set try
21132	if eval $compile; then
21133		yyy=`$run ./try`
21134		case "$yyy" in
21135		12345678901)
21136			sPRId64='"ld"'; sPRIi64='"li"'; sPRIu64='"lu"';
21137			sPRIo64='"lo"'; sPRIx64='"lx"'; sPRIXU64='"lX"';
21138			echo "We will use %ld."
21139			;;
21140		esac
21141	fi
21142fi
21143
21144if $test X"$sPRId64" = X -a X"$i_inttypes" = X"$define" -a X"$quadtype" = Xint64_t; then
21145	$cat >try.c <<'EOCP'
21146#include <sys/types.h>
21147#include <inttypes.h>
21148#include <stdio.h>
21149int main() {
21150  int64_t q = 12345678901;
21151  printf("%" PRId64 "\n", q);
21152}
21153EOCP
21154	set try
21155	if eval $compile; then
21156		yyy=`$run ./try`
21157		case "$yyy" in
21158		12345678901)
21159			sPRId64=PRId64; sPRIi64=PRIi64; sPRIu64=PRIu64;
21160			sPRIo64=PRIo64; sPRIx64=PRIx64; sPRIXU64=PRIXU64;
21161			echo "We will use the C9X style."
21162			;;
21163		esac
21164	fi
21165fi
21166
21167if $test X"$sPRId64" = X -a X"$quadtype" != X; then
21168	$cat >try.c <<EOCP
21169#include <sys/types.h>
21170#include <stdio.h>
21171int main() {
21172  $quadtype q = 12345678901;
21173  printf("%Ld\n", q);
21174}
21175EOCP
21176	set try
21177	if eval $compile; then
21178		yyy=`$run ./try`
21179		case "$yyy" in
21180		12345678901)
21181			sPRId64='"Ld"'; sPRIi64='"Li"'; sPRIu64='"Lu"';
21182			sPRIo64='"Lo"'; sPRIx64='"Lx"'; sPRIXU64='"LX"';
21183			echo "We will use %Ld."
21184			;;
21185		esac
21186	fi
21187fi
21188
21189if $test X"$sPRId64" = X -a X"$quadtype" = X"long long"; then
21190	$cat >try.c <<'EOCP'
21191#include <sys/types.h>
21192#include <stdio.h>
21193int main() {
21194  long long q = 12345678901LL; /* AIX cc requires the LL suffix. */
21195  printf("%lld\n", q);
21196}
21197EOCP
21198	set try
21199	if eval $compile; then
21200		yyy=`$run ./try`
21201		case "$yyy" in
21202		12345678901)
21203			sPRId64='"lld"'; sPRIi64='"lli"'; sPRIu64='"llu"';
21204			sPRIo64='"llo"'; sPRIx64='"llx"'; sPRIXU64='"llX"';
21205			echo "We will use the %lld style."
21206			;;
21207		esac
21208	fi
21209fi
21210
21211if $test X"$sPRId64" = X -a X"$quadtype" != X; then
21212	$cat >try.c <<EOCP
21213#include <sys/types.h>
21214#include <stdio.h>
21215int main() {
21216  $quadtype q = 12345678901;
21217  printf("%qd\n", q);
21218}
21219EOCP
21220	set try
21221	if eval $compile; then
21222		yyy=`$run ./try`
21223		case "$yyy" in
21224		12345678901)
21225			sPRId64='"qd"'; sPRIi64='"qi"'; sPRIu64='"qu"';
21226			sPRIo64='"qo"'; sPRIx64='"qx"'; sPRIXU64='"qX"';
21227			echo "We will use %qd."
21228			;;
21229		esac
21230	fi
21231fi
21232
21233if $test X"$sPRId64" = X; then
21234	echo "Cannot figure out how to print 64-bit integers." >&4
21235fi
21236$rm_try
21237
21238fi
21239
21240case "$sPRId64" in
21241'')	d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef";
21242	d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef";
21243	;;
21244*)	d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define";
21245	d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define";
21246	;;
21247esac
21248
21249: Check format strings for internal types
21250echo " "
21251$echo "Checking the format strings to be used for Perl's internal types..." >&4
21252
21253if $test X"$ivsize" = X8; then
21254	ivdformat="$sPRId64"
21255	uvuformat="$sPRIu64"
21256	uvoformat="$sPRIo64"
21257	uvxformat="$sPRIx64"
21258	uvXUformat="$sPRIXU64"
21259else
21260	if $test X"$ivsize" = X"$longsize"; then
21261		ivdformat='"ld"'
21262		uvuformat='"lu"'
21263		uvoformat='"lo"'
21264		uvxformat='"lx"'
21265		uvXUformat='"lX"'
21266	else
21267		if $test X"$ivsize" = X"$intsize"; then
21268			ivdformat='"d"'
21269			uvuformat='"u"'
21270			uvoformat='"o"'
21271			uvxformat='"x"'
21272			uvXUformat='"X"'
21273		else
21274			: far out
21275			if $test X"$ivsize" = X"$shortsize"; then
21276				ivdformat='"hd"'
21277				uvuformat='"hu"'
21278				uvoformat='"ho"'
21279				uvxformat='"hx"'
21280				uvXUformat='"hX"'
21281			fi
21282		fi
21283	fi
21284fi
21285
21286if $test X"$usequadmath" = X"$define"; then
21287    nveformat='"Qe"'
21288    nvfformat='"Qf"'
21289    nvgformat='"Qg"'
21290    nvEUformat='"QE"'
21291    nvFUformat='"QF"'
21292    nvGUformat='"QG"'
21293else
21294    if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
21295	nveformat="$sPRIeldbl"
21296	nvfformat="$sPRIfldbl"
21297	nvgformat="$sPRIgldbl"
21298	nvEUformat="$sPRIEUldbl"
21299	nvFUformat="$sPRIFUldbl"
21300	nvGUformat="$sPRIGUldbl"
21301    else
21302	nveformat='"e"'
21303	nvfformat='"f"'
21304	nvgformat='"g"'
21305	nvEUformat='"E"'
21306	nvFUformat='"F"'
21307	nvGUformat='"G"'
21308    fi
21309fi
21310
21311case "$ivdformat" in
21312'') echo "$0: Fatal: failed to find format strings, cannot continue." >&4
21313    exit 1
21314    ;;
21315esac
21316
21317: Check format string for GID
21318
21319echo " "
21320$echo "Checking the format string to be used for gids..." >&4
21321
21322case "$gidsign" in
21323-1)	if $test X"$gidsize" = X"$ivsize"; then
21324		gidformat="$ivdformat"
21325	else
21326		if $test X"$gidsize" = X"$longsize"; then
21327			gidformat='"ld"'
21328		else
21329			if $test X"$gidsize" = X"$intsize"; then
21330				gidformat='"d"'
21331			else
21332				if $test X"$gidsize" = X"$shortsize"; then
21333					gidformat='"hd"'
21334				fi
21335			fi
21336		fi
21337	fi
21338	;;
21339*)	if $test X"$gidsize" = X"$uvsize"; then
21340		gidformat="$uvuformat"
21341	else
21342		if $test X"$gidsize" = X"$longsize"; then
21343			gidformat='"lu"'
21344		else
21345			if $test X"$gidsize" = X"$intsize"; then
21346				gidformat='"u"'
21347			else
21348				if $test X"$gidsize" = X"$shortsize"; then
21349					gidformat='"hu"'
21350				fi
21351			fi
21352		fi
21353	fi
21354	;;
21355esac
21356
21357: see if getgroups exists
21358set getgroups d_getgrps
21359eval $inlibc
21360
21361: see if setgroups exists
21362set setgroups d_setgrps
21363eval $inlibc
21364
21365: Find type of 2nd arg to 'getgroups()' and 'setgroups()'
21366echo " "
21367case "$d_getgrps$d_setgrps" in
21368*define*)
21369	case "$groupstype" in
21370	'') dflt="$gidtype" ;;
21371	*)  dflt="$groupstype" ;;
21372	esac
21373	$cat <<EOM
21374What type of pointer is the second argument to getgroups() and setgroups()?
21375Usually this is the same as group ids, $gidtype, but not always.
21376
21377EOM
21378	rp='What type pointer is the second argument to getgroups() and setgroups()?'
21379	. ./myread
21380	groupstype="$ans"
21381	;;
21382*)  groupstype="$gidtype";;
21383esac
21384
21385: check whether make sets MAKE
21386echo " "
21387echo "Checking if your $make program sets \$(MAKE)..." >&4
21388case "$make_set_make" in
21389'')
21390	$sed 's/^X //' > testmake.mak << 'EOF'
21391Xall:
21392X 	@echo 'maketemp="$(MAKE)"'
21393EOF
21394	case "`$make -f testmake.mak 2>/dev/null`" in
21395	*maketemp=*) make_set_make='#' ;;
21396	*)	make_set_make="MAKE=$make" ;;
21397	esac
21398	$rm -f testmake.mak
21399	;;
21400esac
21401case "$make_set_make" in
21402'#') echo "Yup, it does.";;
21403*) echo "Nope, it doesn't.";;
21404esac
21405
21406: see what type is used for mode_t
21407rp="What is the type used for file modes for system calls (e.g. fchmod())?"
21408set mode_t modetype int stdio.h sys/types.h
21409eval $typedef_ask
21410
21411: see if we need va_copy
21412echo " "
21413$cat >try.c <<EOCP
21414#include <stdarg.h>
21415#include <stdio.h>
21416#include <stdlib.h>
21417#include <signal.h>
21418
21419int
21420ivfprintf(FILE *f, const char *fmt, va_list *valp)
21421{
21422  return vfprintf(f, fmt, *valp);
21423}
21424
21425int
21426myvfprintf(FILE *f, const  char *fmt, va_list val)
21427{
21428  return ivfprintf(f, fmt, &val);
21429}
21430
21431int
21432myprintf(char *fmt, ...)
21433{
21434  va_list val;
21435  va_start(val, fmt);
21436  return myvfprintf(stdout, fmt, val);
21437}
21438
21439int
21440main(int ac, char **av)
21441{
21442  signal(SIGSEGV, exit);
21443
21444  myprintf("%s%cs all right, then\n", "that", '\'');
21445  exit(0);
21446}
21447EOCP
21448set try
21449if eval $compile && $run ./try 2>&1 >/dev/null; then
21450	case "`$run ./try`" in
21451	"that's all right, then")
21452		okay=yes
21453		;;
21454	esac
21455fi
21456case "$okay" in
21457yes)	echo "It seems that you don't need va_copy()." >&4
21458	need_va_copy="$undef"
21459	;;
21460*)	echo "It seems that va_copy() or similar will be needed." >&4
21461	need_va_copy="$define"
21462	;;
21463esac
21464$rm_try
21465
21466: see what type is used for size_t
21467rp="What is the type used for the length parameter for string functions?"
21468set size_t sizetype 'unsigned int' stdio.h sys/types.h
21469eval $typedef_ask
21470
21471: check for type of arguments to gethostbyaddr.
21472if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
21473	case "$d_gethbyaddr" in
21474	$define)
21475		$cat <<EOM
21476
21477Checking to see what type of arguments are accepted by gethostbyaddr().
21478EOM
21479		hdrs="$define sys/types.h
21480			$d_socket sys/socket.h
21481			$i_niin netinet/in.h
21482			$i_netdb netdb.h
21483			$i_unistd unistd.h"
21484		: The first arg can 'char *' or 'void *'
21485		: The second arg is some of integral type
21486		for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
21487			for yyy in size_t long int; do
21488				case "$netdb_host_type" in
21489				'')	try="$extern_C struct hostent *gethostbyaddr($xxx, $yyy, int);"
21490					if ./protochk "$try" $hdrs; then
21491						echo "Your system accepts $xxx for the first arg."
21492						echo "...and $yyy for the second arg."
21493						netdb_host_type="$xxx"
21494						netdb_hlen_type="$yyy"
21495					fi
21496					;;
21497				esac
21498			done
21499		done
21500		: In case none of those worked, prompt the user.
21501		case "$netdb_host_type" in
21502		'')	rp='What is the type for the 1st argument to gethostbyaddr?'
21503			dflt='char *'
21504			. ./myread
21505			netdb_host_type=$ans
21506			rp='What is the type for the 2nd argument to gethostbyaddr?'
21507			dflt="$sizetype"
21508			. ./myread
21509			netdb_hlen_type=$ans
21510			;;
21511		esac
21512		;;
21513	*)	: no gethostbyaddr, so pick harmless defaults
21514		netdb_host_type='char *'
21515		netdb_hlen_type="$sizetype"
21516		;;
21517	esac
21518	# Remove the "const" if needed. -- but then we'll have a
21519	# prototype clash!
21520	# netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
21521fi
21522
21523: check for type of argument to gethostbyname.
21524if test "X$netdb_name_type" = X ; then
21525	case "$d_gethbyname" in
21526	$define)
21527		$cat <<EOM
21528
21529Checking to see what type of argument is accepted by gethostbyname().
21530EOM
21531		hdrs="$define sys/types.h
21532			$d_socket sys/socket.h
21533			$i_niin netinet/in.h
21534			$i_netdb netdb.h
21535			$i_unistd unistd.h"
21536		for xxx in "const char *" "char *"; do
21537			case "$netdb_name_type" in
21538			'')	try="$extern_C struct hostent *gethostbyname($xxx);"
21539				if ./protochk "$try" $hdrs; then
21540					echo "Your system accepts $xxx."
21541					netdb_name_type="$xxx"
21542				fi
21543				;;
21544			esac
21545		done
21546		: In case none of those worked, prompt the user.
21547		case "$netdb_name_type" in
21548		'')	rp='What is the type for the 1st argument to gethostbyname?'
21549			dflt='char *'
21550			. ./myread
21551			netdb_name_type=$ans
21552			;;
21553		esac
21554		;;
21555	*)	: no gethostbyname, so pick harmless default
21556		netdb_name_type='char *'
21557		;;
21558	esac
21559fi
21560
21561: check for type of 1st argument to getnetbyaddr.
21562if test "X$netdb_net_type" = X ; then
21563	case "$d_getnbyaddr" in
21564	$define)
21565		$cat <<EOM
21566
21567Checking to see what type of 1st argument is accepted by getnetbyaddr().
21568EOM
21569		hdrs="$define sys/types.h
21570			$d_socket sys/socket.h
21571			$i_niin netinet/in.h
21572			$i_netdb netdb.h
21573			$i_unistd unistd.h"
21574		for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
21575			case "$netdb_net_type" in
21576			'')	try="$extern_C struct netent *getnetbyaddr($xxx, int);"
21577				if ./protochk "$try" $hdrs; then
21578					echo "Your system accepts $xxx."
21579					netdb_net_type="$xxx"
21580				fi
21581				;;
21582			esac
21583		done
21584		: In case none of those worked, prompt the user.
21585		case "$netdb_net_type" in
21586		'')	rp='What is the type for the 1st argument to getnetbyaddr?'
21587			dflt='long'
21588			. ./myread
21589			netdb_net_type=$ans
21590			;;
21591		esac
21592		;;
21593	*)	: no getnetbyaddr, so pick harmless default
21594		netdb_net_type='long'
21595		;;
21596	esac
21597fi
21598: locate the preferred pager for this system
21599fn=f/
21600case "$pager" in
21601'')
21602	dflt=''
21603	case "$pg" in
21604	/*) dflt=$pg;;
21605	[a-zA-Z]:/*) dflt=$pg;;
21606	esac
21607	case "$more" in
21608	/*) dflt=$more;;
21609	[a-zA-Z]:/*) dflt=$more;;
21610	esac
21611	case "$less" in
21612	/*) dflt=$less;;
21613	[a-zA-Z]:/*) dflt=$less;;
21614	esac
21615	case "$dflt" in
21616	'') dflt=/usr/ucb/more;;
21617	esac
21618	;;
21619*)	dflt="$pager"
21620	;;
21621esac
21622fn="f/($dflt)"
21623echo " "
21624rp='What pager is used on your system?'
21625. ./getfile
21626pager="$ans"
21627
21628: see if ar generates random libraries by itself
21629echo " "
21630echo "Checking how to generate random libraries on your machine..." >&4
21631echo 'int bar1() { return bar2(); }' > bar1.c
21632echo 'int bar2() { return 2; }' > bar2.c
21633$cat > foo.c <<EOP
21634#$i_stdlib I_STDLIB
21635#ifdef I_STDLIB
21636#include <stdlib.h>
21637#endif
21638int main() { printf("%d\n", bar1()); exit(0); }
21639EOP
21640$cc $ccflags -c bar1.c >/dev/null 2>&1
21641$cc $ccflags -c bar2.c >/dev/null 2>&1
21642$cc $ccflags -c foo.c >/dev/null 2>&1
21643$ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
21644if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
21645	$run ./foobar >/dev/null 2>&1; then
21646	echo "$ar appears to generate random libraries itself."
21647	orderlib=false
21648	if [ "X$ranlib" = "X" ]; then
21649	    ranlib=":"
21650	fi
21651elif $ar s bar$_a >/dev/null 2>&1 &&
21652	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
21653	$run ./foobar >/dev/null 2>&1; then
21654		echo "a table of contents needs to be added with '$ar s'."
21655		orderlib=false
21656		ranlib="$ar s"
21657elif $ar ts bar$_a >/dev/null 2>&1 &&
21658	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
21659	$run ./foobar >/dev/null 2>&1; then
21660		echo "a table of contents needs to be added with '$ar ts'."
21661		orderlib=false
21662		ranlib="$ar ts"
21663else
21664	case "$ranlib" in
21665	:) ranlib='';;
21666	'')
21667		ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
21668		$test -f $ranlib || ranlib=''
21669		;;
21670	esac
21671	if $test -n "$ranlib"; then
21672		echo "your system has '$ranlib'; we'll use that."
21673		orderlib=false
21674	else
21675		echo "your system doesn't seem to support random libraries"
21676		echo "so we'll use lorder and tsort to order the libraries."
21677		orderlib=true
21678		ranlib=":"
21679	fi
21680fi
21681$rm -f foo* bar*
21682
21683: Check the max offset that gmtime and localtime accept
21684echo "Checking max offsets that gmtime () accepts"
21685
21686case "$sGMTIME_min/$sGMTIME_max" in
21687    0/0|/)
21688	$cat >try.c <<EOCP
21689#include <sys/types.h>
21690#include <stdio.h>
21691#include <time.h>
21692
21693int i;
21694struct tm *tmp;
21695time_t pt;
21696
21697void gm_check (time_t t, int min_year, int max_year)
21698{
21699    tmp = gmtime (&t);
21700    if ( tmp == NULL ||
21701	/* Check tm_year overflow */
21702	 tmp->tm_year < min_year || tmp->tm_year > max_year)
21703	tmp = NULL;
21704    else
21705	pt = t;
21706    } /* gm_check */
21707
21708int check_max ()
21709{
21710    tmp = NULL;
21711    pt  = 0;
21712#ifdef MAXLONG
21713    gm_check (MAXLONG, 69, 0x7fffffff);
21714#endif
21715    if (tmp == NULL || tmp->tm_year < 0) {
21716	for (i = 63; i >= 0; i--) {
21717	    time_t x = pt | ((time_t)1 << i);
21718	    if (x < 0 || x < pt) continue;
21719	    gm_check (x, 69, 0x7fffffff);
21720	    }
21721	}
21722    printf ("sGMTIME_max=%ld\n", pt);
21723    return (0);
21724    } /* check_max */
21725
21726int check_min ()
21727{
21728    tmp = NULL;
21729    pt  = 0;
21730#ifdef MINLONG
21731    gm_check (MINLONG, -1900, 70);
21732#endif
21733    if (tmp == NULL) {
21734	for (i = 36; i >= 0; i--) {
21735	    time_t x = pt - ((time_t)1 << i);
21736	    if (x > 0) continue;
21737	    gm_check (x, -1900, 70);
21738	    }
21739	}
21740    printf ("sGMTIME_min=%ld\n", pt);
21741    return (0);
21742    } /* check_min */
21743
21744int main (int argc, char *argv[])
21745{
21746    /* fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t)); */
21747    check_max ();
21748    check_min ();
21749    return (0);
21750    } /* main */
21751EOCP
21752	set try
21753	if eval $compile; then
21754	    eval `$run ./try 2>/dev/null`
21755	else
21756	    echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
21757	    fi
21758	$rm_try
21759	;;
21760    esac
21761
21762echo "Checking max offsets that localtime () accepts"
21763
21764case "$sLOCALTIME_min/$sLOCALTIME_max" in
21765    0/0|/)
21766	$cat >try.c <<EOCP
21767#include <sys/types.h>
21768#include <stdio.h>
21769#include <time.h>
21770
21771int i;
21772struct tm *tmp;
21773time_t pt;
21774
21775void local_check (time_t t, int min_year, int max_year)
21776{
21777    if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
21778	tmp = NULL;
21779    else
21780	tmp = localtime (&t);
21781    if ( tmp == NULL ||
21782	/* Check tm_year overflow */
21783	 tmp->tm_year < min_year || tmp->tm_year > max_year)
21784	tmp = NULL;
21785    else
21786	pt = t;
21787    } /* local_check */
21788
21789int check_max ()
21790{
21791    tmp = NULL;
21792    pt  = 0;
21793#ifdef MAXLONG
21794    local_check (MAXLONG, 69, 0x7fffffff);
21795#endif
21796    if (tmp == NULL || tmp->tm_year < 0) {
21797	for (i = 63; i >= 0; i--) {
21798	    time_t x = pt | ((time_t)1 << i);
21799	    if (x < 0 || x < pt) continue;
21800	    local_check (x, 69, 0x7fffffff);
21801	    }
21802	}
21803    printf ("sLOCALTIME_max=%ld\n", pt);
21804    return (0);
21805   } /* check_max */
21806
21807int check_min ()
21808{
21809    tmp = NULL;
21810    pt  = 0;
21811#ifdef MINLONG
21812    local_check (MINLONG, -1900, 70);
21813#endif
21814    if (tmp == NULL) {
21815	for (i = 36; i >= 0; i--) {
21816	    time_t x = pt - ((time_t)1 << i);
21817	    if (x > 0) continue;
21818	    local_check (x, -1900, 70);
21819	    }
21820	}
21821    printf ("sLOCALTIME_min=%ld\n", pt);
21822    return (0);
21823    } /* check_min */
21824
21825int main (int argc, char *argv[])
21826{
21827    check_max ();
21828    check_min ();
21829    return (0);
21830    } /* main */
21831EOCP
21832	set try
21833	if eval $compile; then
21834	    eval `$run ./try 2>/dev/null`
21835	else
21836	    echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
21837	    fi
21838	$rm_try
21839	;;
21840    esac
21841
21842: check for type of arguments to select.
21843case "$selecttype" in
21844'') case "$d_select" in
21845	$define)
21846		echo " "
21847		$cat <<EOM
21848Checking to see what type of arguments are accepted by select().
21849EOM
21850		hdrs="$define sys/types.h
21851			$i_systime sys/time.h
21852			$i_sysselct sys/select.h
21853			$d_socket sys/socket.h"
21854		: The first arg can be int, unsigned, or size_t
21855		: The last arg may or may not be 'const'
21856		val=''
21857		: void pointer has been seen but using that
21858		: breaks the selectminbits test
21859		for xxx in 'fd_set *' 'int *'; do
21860			for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
21861				for tmo in 'struct timeval *' 'const struct timeval *'; do
21862					case "$val" in
21863					'')	try="$extern_C select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
21864						if ./protochk "$try" $hdrs; then
21865							echo "Your system accepts $xxx."
21866							val="$xxx"
21867						fi
21868						;;
21869					esac
21870				done
21871			done
21872		done
21873		case "$val" in
21874		'')	rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
21875			case "$d_fd_set" in
21876				$define) dflt="fd_set *" ;;
21877				*)		dflt="int *" ;;
21878			esac
21879			. ./myread
21880			val=$ans
21881			;;
21882		esac
21883		selecttype="$val"
21884		;;
21885	*)	: no select, so pick a harmless default
21886		selecttype='int *'
21887		;;
21888	esac
21889	;;
21890esac
21891
21892: check for the select 'width'
21893case "$selectminbits" in
21894'') safebits=`expr $ptrsize \* 8`
21895    case "$d_select" in
21896	$define)
21897		$cat <<EOM
21898
21899Checking to see on how many bits at a time your select() operates...
21900EOM
21901		$cat >try.c <<EOCP
21902#include <sys/types.h>
21903#$i_time I_TIME
21904#$i_systime I_SYS_TIME
21905#$i_systimek I_SYS_TIME_KERNEL
21906#ifdef I_TIME
21907#   include <time.h>
21908#endif
21909#ifdef I_SYS_TIME
21910#   ifdef I_SYS_TIME_KERNEL
21911#	define KERNEL
21912#   endif
21913#   include <sys/time.h>
21914#   ifdef I_SYS_TIME_KERNEL
21915#	undef KERNEL
21916#   endif
21917#endif
21918#$i_sysselct I_SYS_SELECT
21919#ifdef I_SYS_SELECT
21920#include <sys/select.h>
21921#endif
21922#$d_socket HAS_SOCKET
21923#ifdef HAS_SOCKET
21924#   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
21925#endif
21926#include <stdio.h>
21927#$i_stdlib I_STDLIB
21928#ifdef I_STDLIB
21929#include <stdlib.h>
21930#endif
21931$selecttype b;
21932#define S sizeof(*(b))
21933#define MINBITS	64
21934#define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
21935#define NBITS  (NBYTES * 8)
21936int main() {
21937    char *s = (char *)malloc(NBYTES);
21938    struct timeval t;
21939    int i;
21940    FILE* fp;
21941    int fd;
21942
21943    if (!s)
21944	exit(1);
21945    fclose(stdin);
21946    fp = fopen("try.c", "r");
21947    if (fp == 0)
21948      exit(2);
21949    fd = fileno(fp);
21950    if (fd < 0)
21951      exit(3);
21952    b = ($selecttype)s;
21953    for (i = 0; i < NBITS; i++)
21954	FD_SET(i, b);
21955    t.tv_sec  = 0;
21956    t.tv_usec = 0;
21957    select(fd + 1, b, 0, 0, &t);
21958    for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
21959    free(s);
21960    printf("%d\n", i + 1);
21961    return 0;
21962}
21963EOCP
21964		set try
21965		if eval $compile_ok; then
21966			selectminbits=`$run ./try 2>/dev/null`
21967			case "$selectminbits" in
21968			'')	cat >&4 <<EOM
21969Cannot figure out on how many bits at a time your select() operates.
21970I'll play safe and guess it is $safebits bits.
21971EOM
21972				selectminbits=$safebits
21973				bits="$safebits bits"
21974				;;
21975			1)	bits="1 bit" ;;
21976			*)	bits="$selectminbits bits" ;;
21977			esac
21978			echo "Your select() operates on $bits at a time." >&4
21979		else
21980			rp='What is the minimum number of bits your select() operates on?'
21981			case "$byteorder" in
21982			12345678)	dflt=64 ;;
21983			1234)		dflt=32 ;;
21984			*)		dflt=1	;;
21985			esac
21986			. ./myread
21987			val=$ans
21988			selectminbits="$val"
21989		fi
21990		$rm_try
21991		;;
21992	*)	: no select, so pick a harmless default
21993		selectminbits=$safebits
21994		;;
21995	esac
21996	;;
21997esac
21998
21999: Trace out the files included by signal.h, then look for SIGxxx names.
22000case "$sig_num_init" in
22001'')
22002if [ "X$fieldn" = X ]; then
22003	: Just make some guesses.  We check them later.
22004	xxx="$sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h"
22005else
22006	xxx=`echo '#include <signal.h>' |
22007	$cppstdin $cppminus $cppflags 2>/dev/null |
22008	$grep '^[ 	]*#.*include' |
22009	$awk "{print \\$$fieldn}" | $sed 's!"!!g' |\
22010		$sed 's!\\\\\\\\!/!g' | $sort | $uniq`
22011fi
22012xxxfiles=''
22013for xx in $xxx /dev/null ; do
22014	$test -f "$xx" && xxxfiles="$xxxfiles $xx"
22015done
22016case "$xxxfiles" in
22017'')	xxxfiles=`./findhdr signal.h` ;;
22018esac
22019xxx=`awk '
22020$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
22021	print substr($2, 4, 20)
22022}
22023$1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
22024	print substr($3, 4, 20)
22025}' $xxxfiles`
22026: Append some common names just in case the awk scan failed.
22027xxx="$xxx ABRT ALRM BUS CANCEL CHLD CLD CONT DIL EMT FPE"
22028xxx="$xxx FREEZE HUP ILL INT IO IOT KILL LOST LWP PHONE"
22029xxx="$xxx PIPE POLL PROF PWR QUIT RTMAX RTMIN SEGV STKFLT STOP"
22030xxx="$xxx SYS TERM THAW TRAP TSTP TTIN TTOU URG USR1 USR2"
22031xxx="$xxx USR3 USR4 VTALRM WAITING WINCH WIND WINDOW XCPU XFSZ"
22032
22033: generate a few handy files for later
22034$cat > signal.c <<EOCP
22035#include <sys/types.h>
22036#include <signal.h>
22037#$i_stdlib I_STDLIB
22038#ifdef I_STDLIB
22039#include <stdlib.h>
22040#endif
22041#include <stdio.h>
22042int main() {
22043
22044/* Strange style to avoid deeply-nested #if/#else/#endif */
22045#ifndef NSIG
22046#  ifdef _NSIG
22047#    define NSIG (_NSIG)
22048#  endif
22049#endif
22050
22051#ifndef NSIG
22052#  ifdef SIGMAX
22053#    define NSIG (SIGMAX+1)
22054#  endif
22055#endif
22056
22057#ifndef NSIG
22058#  ifdef SIG_MAX
22059#    define NSIG (SIG_MAX+1)
22060#  endif
22061#endif
22062
22063#ifndef NSIG
22064#  ifdef _SIG_MAX
22065#    define NSIG (_SIG_MAX+1)
22066#  endif
22067#endif
22068
22069#ifndef NSIG
22070#  ifdef MAXSIG
22071#    define NSIG (MAXSIG+1)
22072#  endif
22073#endif
22074
22075#ifndef NSIG
22076#  ifdef MAX_SIG
22077#    define NSIG (MAX_SIG+1)
22078#  endif
22079#endif
22080
22081#ifndef NSIG
22082#  ifdef SIGARRAYSIZE
22083#    define NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */
22084#  endif
22085#endif
22086
22087#ifndef NSIG
22088#  ifdef _sys_nsig
22089#    define NSIG (_sys_nsig) /* Solaris 2.5 */
22090#  endif
22091#endif
22092
22093/* Default to some arbitrary number that's big enough to get most
22094   of the common signals.
22095*/
22096#ifndef NSIG
22097#    define NSIG 50
22098#endif
22099
22100printf("NSIG %d\n", NSIG);
22101
22102#ifndef JUST_NSIG
22103
22104EOCP
22105
22106echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
22107{
22108	printf "#ifdef SIG"; printf $1; printf "\n"
22109	printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
22110	printf $1; printf ");\n"
22111	printf "#endif\n"
22112}
22113END {
22114	printf "#endif /* JUST_NSIG */\n";
22115	printf "exit(0);\n}\n";
22116}
22117' >>signal.c
22118$cat >signal.awk <<'EOP'
22119BEGIN { ndups = 0 }
22120$1 ~ /^NSIG$/ { nsig = $2 }
22121($1 !~ /^NSIG$/) && (NF == 2) && ($2 ~ /^[0-9][0-9]*$/) {
22122    if ($2 > maxsig) { maxsig = $2 }
22123    if (sig_name[$2]) {
22124	dup_name[ndups] = $1
22125	dup_num[ndups] = $2
22126	ndups++
22127    }
22128    else {
22129	sig_name[$2] = $1
22130	sig_num[$2] = $2
22131    }
22132}
22133END {
22134    if (nsig == 0) {
22135    	nsig = maxsig + 1
22136    }
22137    printf("NSIG %d\n", nsig);
22138    for (n = 1; n < nsig; n++) {
22139 	if (sig_name[n]) {
22140 	    printf("%s %d\n", sig_name[n], sig_num[n])
22141	}
22142 	else {
22143 	    printf("NUM%d %d\n", n, n)
22144 	}
22145    }
22146    for (n = 0; n < ndups; n++) {
22147 	printf("%s %d\n", dup_name[n], dup_num[n])
22148    }
22149}
22150EOP
22151$cat >signal_cmd <<EOS
22152$startsh
22153if $test -s signal.lst; then
22154    echo "Using your existing signal.lst file"
22155	exit 0
22156fi
22157xxx="$xxx"
22158EOS
22159$cat >>signal_cmd <<'EOS'
22160
22161set signal
22162if eval $compile_ok; then
22163	$run ./signal$_exe | ($sort -n -k 2 2>/dev/null || $sort -n +1) |\
22164		$uniq | $awk -f signal.awk >signal.lst
22165else
22166	echo "(I can't seem be able to compile the whole test program)" >&4
22167	echo "(I'll try it in little pieces.)" >&4
22168	set signal -DJUST_NSIG
22169	if eval $compile_ok; then
22170		$run ./signal$_exe > signal.nsg
22171		$cat signal.nsg
22172	else
22173		echo "I can't seem to figure out how many signals you have." >&4
22174		echo "Guessing 50." >&4
22175		echo 'NSIG 50' > signal.nsg
22176	fi
22177	: Now look at all the signal names, one at a time.
22178	for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
22179		$cat > signal.c <<EOCP
22180#include <sys/types.h>
22181#include <signal.h>
22182#include <stdio.h>
22183int main() {
22184printf("$xx %d\n", SIG${xx});
22185return 0;
22186}
22187EOCP
22188		set signal
22189		if eval $compile; then
22190			echo "SIG${xx} found."
22191			$run ./signal$_exe  >> signal.ls1
22192		else
22193			echo "SIG${xx} NOT found."
22194		fi
22195	done
22196	if $test -s signal.ls1; then
22197		$cat signal.nsg signal.ls1 |
22198			$sort -n | $uniq | $awk -f signal.awk >signal.lst
22199	fi
22200
22201fi
22202if $test -s signal.lst; then
22203	:
22204else
22205	echo "(AAK! I can't compile the test programs -- Guessing)" >&4
22206	echo 'kill -l' >signal
22207	set X `csh -f <signal`
22208	$rm -f signal
22209	shift
22210	case $# in
22211	0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
22212	esac
22213	echo $@ | $tr ' ' $trnl | \
22214 	    $awk '{ printf "%s %d\n", $1, ++s; }
22215 		  END { printf "NSIG %d\n", ++s }' >signal.lst
22216fi
22217$rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
22218EOS
22219chmod a+x signal_cmd
22220$eunicefix signal_cmd
22221;;
22222esac
22223
22224: generate list of signal names
22225case "$sig_num_init" in
22226'')
22227echo " "
22228case "$sig_name_init" in
22229'') doinit=yes ;;
22230*)  case "$sig_num_init" in
22231    ''|*,*) doinit=yes ;;
22232    esac ;;
22233esac
22234case "$doinit" in
22235yes)
22236	echo "Generating a list of signal names and numbers..." >&4
22237	. ./signal_cmd
22238	sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
22239	sig_name=`$awk 'BEGIN { printf "ZERO " }
22240			!/^NSIG/ { printf "%s ", $1 }' signal.lst`
22241	sig_num=`$awk  'BEGIN { printf "0 " }
22242			!/^NSIG/ { printf "%d ", $2 }' signal.lst`
22243	sig_name_init=`$awk 'BEGIN	{ printf "\"ZERO\", " }
22244			     !/^NSIG/	{ printf "\"%s\", ", $1 }
22245			     END	{ printf "0\n" }' signal.lst`
22246	sig_num_init=`$awk  'BEGIN	{ printf "0, " }
22247			     !/^NSIG/	{ printf "%d, ", $2}
22248			     END	{ printf "0\n"}' signal.lst`
22249	;;
22250esac
22251echo "The following $sig_count signals are available:"
22252echo " "
22253echo $sig_name | $awk \
22254'BEGIN { linelen = 0 }
22255{
22256	for (i = 1; i <= NF; i++) {
22257		name = "SIG" $i " "
22258		linelen = linelen + length(name)
22259		if (linelen > 70) {
22260			printf "\n"
22261			linelen = length(name)
22262		}
22263		printf "%s", name
22264	}
22265	printf "\n"
22266}'
22267sig_size=`echo $sig_name | awk '{print NF}'`
22268$rm -f signal signal.c signal.awk signal.lst signal_cmd
22269;;
22270esac
22271
22272: Check size of size
22273echo " "
22274case "$sizetype" in
22275*_t) zzz="$sizetype"	;;
22276*)   zzz="filesize"	;;
22277esac
22278echo "Checking the size of $zzz..." >&4
22279cat > try.c <<EOCP
22280#include <sys/types.h>
22281#include <stdio.h>
22282#$i_stdlib I_STDLIB
22283#ifdef I_STDLIB
22284#include <stdlib.h>
22285#endif
22286int main() {
22287    printf("%d\n", (int)sizeof($sizetype));
22288    exit(0);
22289}
22290EOCP
22291set try
22292if eval $compile_ok; then
22293	yyy=`$run ./try`
22294	case "$yyy" in
22295	'')	sizesize=4
22296		echo "(I can't execute the test program--guessing $sizesize.)" >&4
22297		;;
22298	*)	sizesize=$yyy
22299		echo "Your $zzz size is $sizesize bytes."
22300		;;
22301	esac
22302else
22303	sizesize=4
22304	echo "(I can't compile the test program--guessing $sizesize.)" >&4
22305fi
22306
22307: check for socklen_t
22308echo " "
22309echo "Checking to see if you have socklen_t..." >&4
22310$cat >try.c <<EOCP
22311#include <sys/types.h>
22312#$d_socket HAS_SOCKET
22313#ifdef HAS_SOCKET
22314#include <sys/socket.h>
22315#endif
22316int main() { socklen_t x = 16; }
22317EOCP
22318set try
22319if eval $compile; then
22320	val="$define"
22321	echo "You have socklen_t."
22322else
22323	val="$undef"
22324	echo "You do not have socklen_t."
22325	case "$sizetype" in
22326	size_t) echo "(You do have size_t, that might work. Some people are happy with just an int.)" ;;
22327	esac
22328fi
22329$rm_try
22330set d_socklen_t
22331eval $setvar
22332
22333: see if this is a socks.h system
22334set socks.h i_socks
22335eval $inhdr
22336
22337: check for type of the size argument to socket calls
22338case "$d_socket" in
22339"$define")
22340	$cat <<EOM
22341
22342Checking to see what type is the last argument of accept().
22343EOM
22344	yyy=''
22345	case "$d_socklen_t" in
22346	"$define") yyy="$yyy socklen_t"
22347	esac
22348	yyy="$yyy $sizetype int long unsigned"
22349	for xxx in $yyy; do
22350		case "$socksizetype" in
22351		'')	try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
22352			case "$usesocks" in
22353			"$define")
22354				if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
22355					echo "Your system accepts '$xxx *' for the last argument of accept()."
22356					socksizetype="$xxx"
22357				fi
22358				;;
22359			*)	if ./protochk "$try"  $i_systypes sys/types.h $d_socket sys/socket.h; then
22360					echo "Your system accepts '$xxx *' for the last argument of accept()."
22361					socksizetype="$xxx"
22362				fi
22363				;;
22364			esac
22365			;;
22366		esac
22367	done
22368: In case none of those worked, prompt the user.
22369	case "$socksizetype" in
22370	'')	rp='What is the type for socket address structure sizes?'
22371		dflt='int'
22372		. ./myread
22373		socksizetype=$ans
22374		;;
22375	esac
22376	;;
22377*)	: no sockets, so pick relatively harmless default
22378	socksizetype='int'
22379	;;
22380esac
22381
22382: see what type is used for signed size_t
22383set ssize_t ssizetype int stdio.h sys/types.h
22384eval $typedef
22385dflt="$ssizetype"
22386$cat > try.c <<EOM
22387#include <stdio.h>
22388#$i_stdlib I_STDLIB
22389#ifdef I_STDLIB
22390#include <stdlib.h>
22391#endif
22392#include <sys/types.h>
22393#define Size_t $sizetype
22394#define SSize_t $dflt
22395int main()
22396{
22397	if (sizeof(Size_t) == sizeof(SSize_t))
22398		printf("$dflt\n");
22399	else if (sizeof(Size_t) == sizeof(int))
22400		printf("int\n");
22401	else
22402		printf("long\n");
22403	exit(0);
22404}
22405EOM
22406echo " "
22407set try
22408if eval $compile_ok && $run ./try > /dev/null; then
22409	ssizetype=`$run ./try`
22410	echo "I'll be using $ssizetype for functions returning a byte count." >&4
22411else
22412	$cat >&4 <<EOM
22413Help! I can't compile and run the ssize_t test program: please enlighten me!
22414(This is probably a misconfiguration in your system or libraries, and
22415you really ought to fix it.  Still, I'll try anyway.)
22416
22417I need a type that is the same size as $sizetype, but is guaranteed to
22418be signed.  Common values are ssize_t, int and long.
22419
22420EOM
22421	rp="What signed type is the same size as $sizetype?"
22422	. ./myread
22423	ssizetype="$ans"
22424fi
22425$rm_try
22426
22427: Check the size of st_ino
22428$echo " "
22429$echo "Checking the size of st_ino..." >&4
22430$cat > try.c <<EOCP
22431#include <sys/stat.h>
22432#include <stdio.h>
22433#$i_stdlib I_STDLIB
22434#ifdef I_STDLIB
22435#include <stdlib.h>
22436#endif
22437int main() {
22438    struct stat st;
22439    printf("%d\n", (int)sizeof(st.st_ino));
22440    exit(0);
22441}
22442EOCP
22443set try
22444if eval $compile_ok; then
22445	val=`$run ./try`
22446	case "$val" in
22447	'')	st_ino_size=4
22448		$echo "(I can't execute the test program--guessing $st_ino_size.)" >&4
22449		;;
22450	*)	st_ino_size=$val
22451		$echo "Your st_ino is $st_ino_size bytes long."
22452		;;
22453	esac
22454else
22455	st_ino_size=4
22456	$echo "(I can't compile the test program--guessing $st_ino_size.)" >&4
22457fi
22458$rm_try
22459
22460: Check if st_ino is signed
22461$echo " "
22462$echo "Checking the sign of st_ino..." >&4
22463$cat > try.c <<EOCP
22464#include <sys/stat.h>
22465#include <stdio.h>
22466int main() {
22467	struct stat foo;
22468        foo.st_ino = -1;
22469	if (foo.st_ino < 0)
22470		printf("-1\n");
22471	else
22472		printf("1\n");
22473}
22474EOCP
22475set try
22476if eval $compile; then
22477	val=`$run ./try`
22478	case "$val" in
22479	'')	st_ino_sign=1
22480		$echo "(I can't execute the test program--guessing unsigned.)" >&4
22481		;;
22482	*)	st_ino_sign=$val
22483		case "$st_ino_sign" in
22484		 1) $echo "Your st_ino is unsigned." ;;
22485		-1) $echo "Your st_ino is signed."   ;;
22486		esac
22487		;;
22488	esac
22489else
22490	st_ino_sign=1
22491	$echo "(I can't compile the test program--guessing unsigned.)" >&4
22492fi
22493$rm_try
22494
22495: see what type of char stdio uses.
22496echo " "
22497echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
22498if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
22499	echo "Your stdio uses unsigned chars." >&4
22500	stdchar="unsigned char"
22501else
22502	echo "Your stdio uses signed chars." >&4
22503	stdchar="char"
22504fi
22505$rm -f stdioh
22506
22507: Check size of UID
22508echo " "
22509case "$uidtype" in
22510*_t) zzz="$uidtype"	;;
22511*)   zzz="uid"		;;
22512esac
22513echo "Checking the size of $zzz..." >&4
22514cat > try.c <<EOCP
22515#include <sys/types.h>
22516#include <stdio.h>
22517#$i_stdlib I_STDLIB
22518#ifdef I_STDLIB
22519#include <stdlib.h>
22520#endif
22521int main() {
22522    printf("%d\n", (int)sizeof($uidtype));
22523    exit(0);
22524}
22525EOCP
22526set try
22527if eval $compile_ok; then
22528	yyy=`$run ./try`
22529	case "$yyy" in
22530	'')	uidsize=4
22531		echo "(I can't execute the test program--guessing $uidsize.)" >&4
22532		;;
22533	*)	uidsize=$yyy
22534		echo "Your $zzz is $uidsize bytes long."
22535		;;
22536	esac
22537else
22538	uidsize=4
22539	echo "(I can't compile the test program--guessing $uidsize.)" >&4
22540fi
22541
22542: Check if UID is signed
22543echo " "
22544case "$uidtype" in
22545*_t) zzz="$uidtype"	;;
22546*)   zzz="uid"		;;
22547esac
22548echo "Checking the sign of $zzz..." >&4
22549cat > try.c <<EOCP
22550#include <sys/types.h>
22551#include <stdio.h>
22552int main() {
22553	$uidtype foo = -1;
22554	if (foo < 0)
22555		printf("-1\n");
22556	else
22557		printf("1\n");
22558}
22559EOCP
22560set try
22561if eval $compile; then
22562	yyy=`$run ./try`
22563	case "$yyy" in
22564	'')	uidsign=1
22565		echo "(I can't execute the test program--guessing unsigned.)" >&4
22566		;;
22567	*)	uidsign=$yyy
22568		case "$uidsign" in
22569		 1) echo "Your $zzz is unsigned." ;;
22570		-1) echo "Your $zzz is signed."   ;;
22571		esac
22572		;;
22573	esac
22574else
22575	uidsign=1
22576	echo "(I can't compile the test program--guessing unsigned.)" >&4
22577fi
22578
22579: Check format string for UID
22580echo " "
22581$echo "Checking the format string to be used for uids..." >&4
22582
22583case "$uidsign" in
22584-1)	if $test X"$uidsize" = X"$ivsize"; then
22585		uidformat="$ivdformat"
22586	else
22587		if $test X"$uidsize" = X"$longsize"; then
22588			uidformat='"ld"'
22589		else
22590			if $test X"$uidsize" = X"$intsize"; then
22591				uidformat='"d"'
22592			else
22593				if $test X"$uidsize" = X"$shortsize"; then
22594					uidformat='"hd"'
22595				fi
22596			fi
22597		fi
22598	fi
22599	;;
22600*)	if $test X"$uidsize" = X"$uvsize"; then
22601		uidformat="$uvuformat"
22602	else
22603		if $test X"$uidsize" = X"$longsize"; then
22604			uidformat='"lu"'
22605		else
22606			if $test X"$uidsize" = X"$intsize"; then
22607				uidformat='"u"'
22608			else
22609				if $test X"$uidsize" = X"$shortsize"; then
22610					uidformat='"hu"'
22611				fi
22612			fi
22613		fi
22614	fi
22615	;;
22616esac
22617
22618: Determine if we can use sysctl with KERN_PROC_PATHNAME to find executing program
22619echo " "
22620echo "Determining whether we can use sysctl with KERN_PROC_PATHNAME to find executing program..." >&4
22621$cat >try.c <<'EOM'
22622/* Intentionally a long probe as I'd like to sanity check that the exact
22623   approach is going to work, as thinking it will work, but only having it
22624   part working at runtime is worse than not having it.  */
22625
22626#include <sys/types.h>
22627#include <sys/sysctl.h>
22628#include <sys/param.h>
22629#include <stdio.h>
22630#include <string.h>
22631#include <stdlib.h>
22632#include <unistd.h>
22633
22634int
22635main(int argc, char **argv) {
22636    char *buffer;
22637    char *argv_leaf = strrchr(argv[0], '/');
22638    char *buffer_leaf;
22639    size_t size = 0;
22640    int mib[4];
22641
22642    mib[0] = CTL_KERN;
22643    mib[1] = KERN_PROC;
22644    mib[2] = KERN_PROC_PATHNAME;
22645    mib[3] = -1;
22646
22647    if (!argv_leaf) {
22648	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
22649	return 1;
22650    }
22651
22652    if (sysctl(mib, 4, NULL, &size, NULL, 0)) {
22653	perror("sysctl");
22654	return 2;
22655    }
22656
22657    if (size < strlen(argv_leaf) + 1) {
22658	fprintf(stderr, "size %lu is too short for a path\n",
22659		(unsigned long) size);
22660	return 3;
22661    }
22662
22663    if (size > MAXPATHLEN * MAXPATHLEN) {
22664	fprintf(stderr, "size %lu is too long for a path\n",
22665		(unsigned long) size);
22666	return 4;
22667    }
22668
22669    buffer = (char *)malloc(size);
22670    if (!buffer) {
22671	perror("malloc");
22672	return 5;
22673    }
22674
22675    if (sysctl(mib, 4, buffer, &size, NULL, 0)) {
22676	perror("sysctl");
22677	return 6;
22678    }
22679
22680    if (strlen(buffer) + 1 != size) {
22681	fprintf(stderr, "size != strlen(buffer) + 1 (%lu != %lu)\n",
22682		(unsigned long)size, (unsigned long)strlen(buffer) + 1);
22683        return 7;
22684    }
22685
22686
22687    if (*buffer != '/') {
22688	fprintf(stderr, "Not an absolute path: '%s'\n", buffer);
22689	return 8;
22690    }
22691
22692    if (strstr(buffer, "/./")) {
22693	fprintf(stderr, "Contains /./: '%s'\n", buffer);
22694	return 9;
22695    }
22696
22697    if (strstr(buffer, "/../")) {
22698	fprintf(stderr, "Contains /../: '%s'\n", buffer);
22699	return 10;
22700    }
22701
22702    buffer_leaf = strrchr(buffer, '/');
22703    if (strcmp(buffer_leaf, argv_leaf) != 0) {
22704	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], buffer);
22705	return 11;
22706    }
22707
22708    free(buffer);
22709
22710    return 0;
22711}
22712EOM
22713
22714val=$undef
22715set try
22716if eval $compile; then
22717	if $run ./try; then
22718		echo "You can use sysctl with KERN_PROC_PATHNAME to find the executing program." >&4
22719		val="$define"
22720	else
22721		echo "Nope, sysctl with KERN_PROC_PATHNAME doesn't work here." >&4
22722		val="$undef"
22723	fi
22724else
22725	echo "I'm unable to compile the test program." >&4
22726	echo "I'll assume no sysctl with KERN_PROC_PATHNAME here." >&4
22727	val="$undef"
22728fi
22729$rm_try
22730set usekernprocpathname
22731eval $setvar
22732
22733: Determine if we can use _NSGetExecutablePath to find executing program
22734echo " "
22735echo "Determining whether we can use _NSGetExecutablePath to find executing program..." >&4
22736$cat >try.c <<'EOM'
22737/* Intentionally a long probe as I'd like to sanity check that the exact
22738   approach is going to work, as thinking it will work, but only having it
22739   part working at runtime is worse than not having it.  */
22740#include <mach-o/dyld.h>
22741#include <stdio.h>
22742#include <stdlib.h>
22743#include <sys/param.h>
22744#include <string.h>
22745
22746int
22747main(int argc, char **argv) {
22748    char buf[1];
22749    uint32_t size = sizeof(buf);
22750    int result;
22751    char *buffer;
22752    char *tidied;
22753    char *argv_leaf = strrchr(argv[0], '/');
22754    char *tidied_leaf;
22755
22756    if (!argv_leaf) {
22757	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
22758	return 1;
22759    }
22760
22761    _NSGetExecutablePath(buf, &size);
22762    if (size > MAXPATHLEN * MAXPATHLEN) {
22763	fprintf(stderr, "_NSGetExecutablePath size %u is too long for a path\n",
22764		(unsigned int) size);
22765	return 2;
22766    }
22767
22768    buffer = (char *)malloc(size);
22769    if (!buffer) {
22770	perror("malloc");
22771	return 3;
22772    }
22773
22774    result = _NSGetExecutablePath(buffer, &size);
22775    if (result != 0) {
22776	fprintf(stderr, "_NSGetExecutablePath returned %i for a size of %u\n",
22777		result, (unsigned int) size);
22778	return 4;
22779    }
22780
22781    tidied = realpath(buffer, NULL);
22782    if (!tidied) {
22783	perror("realpath");
22784	return 5;
22785    }
22786
22787    free(buffer);
22788
22789    if (*tidied != '/') {
22790	fprintf(stderr, "Not an absolute path: '%s'\n", tidied);
22791	return 6;
22792    }
22793
22794    if (strstr(tidied, "/./")) {
22795	fprintf(stderr, "Contains /./: '%s'\n", tidied);
22796	return 7;
22797    }
22798
22799    if (strstr(tidied, "/../")) {
22800	fprintf(stderr, "Contains /../: '%s'\n", tidied);
22801	return 8;
22802    }
22803
22804    tidied_leaf = strrchr(tidied, '/');
22805    if (strcmp(tidied_leaf, argv_leaf) != 0) {
22806	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], tidied);
22807	return 9;
22808    }
22809
22810    free(tidied);
22811
22812    return 0;
22813}
22814EOM
22815
22816val=$undef
22817set try
22818if eval $compile; then
22819	if $run ./try; then
22820		echo "You can use _NSGetExecutablePath to find the executing program." >&4
22821		val="$define"
22822	else
22823		echo "Nope, _NSGetExecutablePath doesn't work here." >&4
22824	fi
22825else
22826	echo "I'm unable to compile the test program." >&4
22827	echo "I'll assume no _NSGetExecutablePath here." >&4
22828fi
22829$rm_try
22830set usensgetexecutablepath
22831eval $setvar
22832
22833: Check if site customization support was requested
22834case "$usesitecustomize" in
22835    $define|true|[Yy]*)
22836	usesitecustomize="$define"
22837	;;
22838    *)
22839	usesitecustomize="$undef"
22840	;;
22841    esac
22842
22843: determine compiler compiler
22844case "$yacc" in
22845'')
22846	dflt=yacc;;
22847*)
22848	dflt="$yacc";;
22849esac
22850echo " "
22851comp='yacc'
22852if $test -f "$byacc$_exe"; then
22853	dflt="$byacc"
22854	comp="byacc or $comp"
22855fi
22856if $test -f "$bison$_exe"; then
22857	comp="$comp or bison -y"
22858fi
22859rp="Which compiler compiler ($comp) shall I use?"
22860. ./myread
22861yacc="$ans"
22862case "$yacc" in
22863*bis*)
22864	case "$yacc" in
22865	*-y*) ;;
22866	*)
22867		yacc="$yacc -y"
22868		echo "(Adding -y option to bison to get yacc-compatible behavior.)"
22869		;;
22870	esac
22871	;;
22872esac
22873
22874: see if this is a bfd.h system
22875set bfd.h i_bfd
22876eval $inhdr
22877
22878: see if this is an execinfo.h system
22879set execinfo.h i_execinfo
22880eval $inhdr
22881
22882: see if this is a fenv.h system
22883set fenv.h i_fenv
22884eval $inhdr
22885
22886: see if this is a fp.h system
22887set fp.h i_fp
22888eval $inhdr
22889
22890: see if this is a fp_class.h system
22891set fp_class.h i_fp_class
22892eval $inhdr
22893
22894: see if gdbm.h is available
22895set gdbm.h t_gdbm
22896eval $inhdr
22897case "$t_gdbm" in
22898$define)
22899	: see if gdbm_open exists
22900	set gdbm_open d_gdbm_open
22901	eval $inlibc
22902	case "$d_gdbm_open" in
22903	$undef)
22904		t_gdbm="$undef"
22905		echo "We won't be including <gdbm.h>"
22906		;;
22907	esac
22908	;;
22909esac
22910val="$t_gdbm"
22911set i_gdbm
22912eval $setvar
22913
22914: see if this is a ieeefp.h system
22915case "$i_ieeefp" in
22916'' ) set ieeefp.h i_ieeefp
22917     eval $inhdr
22918     ;;
22919esac
22920
22921: see if this is a libutil.h system
22922set libutil.h i_libutil
22923eval $inhdr
22924
22925: see if mach cthreads are available
22926if test "X$usethreads" = "X$define"; then
22927	set mach/cthreads.h i_machcthr
22928	eval $inhdr
22929else
22930	i_machcthr="$undef"
22931fi
22932
22933: see if this is a mntent.h system
22934set mntent.h i_mntent
22935eval $inhdr
22936
22937: see if net/errno.h is available
22938val=''
22939set net/errno.h val
22940eval $inhdr
22941
22942: Unfortunately, it causes problems on some systems.  Arrgh.
22943case "$val" in
22944$define)
22945	cat > try.c <<'EOM'
22946#include <stdio.h>
22947#include <errno.h>
22948#include <net/errno.h>
22949int func()
22950{
22951	return ENOTSOCK;
22952}
22953EOM
22954	if $cc $ccflags -c try.c >/dev/null 2>&1; then
22955		echo "We'll be including <net/errno.h>." >&4
22956	else
22957		echo "We won't be including <net/errno.h>." >&4
22958		val="$undef"
22959	fi
22960	$rm_try
22961	;;
22962esac
22963set i_neterrno
22964eval $setvar
22965
22966: see if netinet/tcp.h is available
22967set netinet/tcp.h i_netinettcp
22968eval $inhdr
22969
22970: see if this is a poll.h system
22971set poll.h i_poll
22972eval $inhdr
22973
22974: see if this is a prot.h system
22975set prot.h i_prot
22976eval $inhdr
22977
22978: Preprocessor symbols
22979echo " "
22980$echo "Guessing which symbols your C compiler and preprocessor define..." >&4
22981$cat <<'EOSH' > Cppsym.know
22982a29k aarch64 ABI64 aegis AES_SOURCE AIX AIX32 AIX370 AIX41 AIX42
22983AIX43 aixpc AIX_SOURCE alliant ALL_SOURCE alpha AM29000 am29000
22984AMD64 amd64 amiga AMIGAOS AMIX ansi ANSI_C_SOURCE apollo arch_ppc
22985arch_pwr ardent ARM ARM32 atarist att386 att3b
22986BeOS BIG_ENDIAN BIT_MSF BSD bsd bsd43 bsd4_2 BSD4_3 bsd4_3 bsd4_4
22987BSDCOMPAT bsdi BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES bull
22988byteorder byte_order
22989c cadmus clang clipper CMU COFF COMPILER_VERSION concurrent
22990convex cpu CRAY cray CRAYMPP ctix CX_UX CYGWIN
22991DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO Dynix DynixPTX
22992ELF encore EPI EXTENSIONS
22993FAVOR_BSD FILE_OFFSET_BITS FORTIFY_SOURCE FreeBSD
22994GCC_NEW_VARARGS gcos gcx gimpel GLIBC GLIBC_MINOR GNUC GNUC_MINOR
22995GNU_LIBRARY GNU_SOURCE GO32 gould GOULD_PN
22996H3050R H3050RX hbullx20 hcx host_mips hp200 hp300 HP700 hp700
22997hp800 hp9000 hp9000s200 hp9000s300 hp9000s400
22998hp9000s700 hp9000s800 hp9k8 hppa hpux HPUX_SOURCE hp_osf
22999i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960 IA32 IA64
23000iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
23001INLINE_INTRINSICS INT64 INTEL interdata INTRINSICS is68k itanium
23002ksr1
23003LANGUAGE_C LARGEFILE64_SOURCE LARGEFILE_SOURCE LARGE_FILE_API
23004LFS64_LARGEFILE LFS_LARGEFILE LIBCATAMOUNT Linux LITTLE_ENDIAN
23005LONG64 LONGDOUBLE LONGLONG LONG_DOUBLE LONG_LONG LP64 luna
23006luna88k Lynx
23007M68000 m68k m88100 m88k M88KBCS_TARGET MACH machine MachTen
23008MATH_HAS_NO_SIDE_EFFECTS mc300 mc500 mc68000 mc68010 mc68020
23009mc68030 mc68040 mc68060 mc68k mc68k32 mc700 mc88000 mc88100
23010merlin mert MiNT mips MIPSEB MIPSEL MIPS_FPSET MIPS_ISA MIPS_SIM
23011MIPS_SZINT MIPS_SZLONG MIPS_SZPTR MODERN_C motorola mpeix MSDOS
23012MTXINU MULTIMAX MVS mvs M_AMD64 M_ARM M_ARMT M_COFF M_I186 M_I286
23013M_I386 M_I8086 M_I86 M_I86SM M_IA64 M_IX86 M_PPC M_SYS3 M_SYS5
23014M_SYSIII M_SYSV M_UNIX M_X86 M_XENIX
23015n16 ncl_el ncl_mr NetBSD news1500 news1700 news1800 news1900
23016news3700 news700 news800 news900 NeXT NLS nonstopux ns16000
23017ns32000 ns32016 ns32332 ns32k nsc32000
23018OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
23019PARAGON parisc pa_risc PA_RISC1_1 PA_RISC2_0 pc532 pdp11 PGC PIC
23020plexus PORTAR posix POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
23021POSIX_C_SOURCE POSIX_SOURCE POWER powerpc ppc PROTOTYPES PWB pyr
23022QK_USER QNX
23023R3000 REENTRANT RES Rhapsody RISC6000 riscix riscos RT
23024S390 S390x SA110 SCO scs sequent sgi SGI_SOURCE SH SH3 sinix
23025SIZE_INT SIZE_LONG SIZE_PTR SOCKETS_SOURCE SOCKET_SOURCE sony
23026sonyrisc sony_news sparc sparclite sparcv8 sparcv9 spectrum
23027stardent stdc STDC_EXT stratos sun sun3 sun386 Sun386i svr3 svr4
23028SVR4_2 SVR4_SOURCE svr5 SX system SYSTYPE_BSD SYSTYPE_BSD43
23029SYSTYPE_BSD44 SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3
23030SYSV4 SYSV5 sysV68 sysV88
23031Tek4132 Tek4300 thumb thw_370 thw_intel thw_rs6000 titan TM3200
23032TM5400 TM5600 tower tower32 tower32_200 tower32_600 tower32_700
23033tower32_800 tower32_850 tss
23034u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5 ultrix UMAXV UnicomPBB
23035UnicomPBD UNICOS UNICOSMK unix UNIX95 UNIX99 unixpc unos USE_BSD
23036USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE
23037USE_LARGEFILE64 USE_MISC USE_POSIX USE_POSIX199309
23038USE_POSIX199506 USE_POSIX2 USE_REENTRANT USE_SVID USE_UNIX98
23039USE_XOPEN USE_XOPEN_EXTENDED USGr4 USGr4_2 UTek Utek UTS UWIN
23040uxpm uxps
23041vax venix VMESA vms
23042x86_64 xenix Xenix286 XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2
23043XPG2_EXTENDED XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
23044z8000 zarch
23045EOSH
23046# Maybe put other stuff here too.
23047./tr '-' '_' <<EOSH >>Cppsym.know
23048$osname
23049EOSH
23050./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
23051./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b
23052$cat Cppsym.know > Cppsym.c
23053$cat Cppsym.a Cppsym.b Cppsym.c | $tr ' ' $trnl | $sort | $uniq > Cppsym.know
23054$rm -f Cppsym.a Cppsym.b Cppsym.c
23055cat <<EOSH > Cppsym
23056$startsh
23057if $test \$# -gt 0; then
23058    echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
23059    if $test -s Cppsym.got; then
23060	$rm -f Cppsym.got
23061	exit 0
23062    fi
23063    $rm -f Cppsym.got
23064    exit 1
23065else
23066    $tr " " "$trnl" | ./Cppsym.try
23067    exit 0
23068fi
23069EOSH
23070chmod +x Cppsym
23071$eunicefix Cppsym
23072cat <<EOSH > Cppsym.try
23073$startsh
23074cat <<'EOCP' > try.c
23075#include <stdio.h>
23076#if cpp_stuff == 1
23077#define STRINGIFY(a)    "a"
23078#endif
23079#if cpp_stuff == 42
23080#define StGiFy(a)  #a
23081#define STRINGIFY(a)    StGiFy(a)
23082#endif
23083#if $cpp_stuff != 1 && $cpp_stuff != 42
23084#   include "Bletch: How does this C preprocessor stringify macros?"
23085#endif
23086int main() {
23087EOCP
23088$awk \\
23089EOSH
23090cat <<'EOSH' >> Cppsym.try
23091'length($1) > 0 {
23092    printf "#ifdef %s\nprintf(\"%s=%%s\\n\", STRINGIFY(%s));\n#endif\n", $1, $1, $1
23093    printf "#ifdef _%s\nprintf(\"_%s=%%s\\n\", STRINGIFY(_%s));\n#endif\n", $1, $1, $1
23094    printf "#ifdef __%s\nprintf(\"__%s=%%s\\n\", STRINGIFY(__%s));\n#endif\n", $1, $1, $1
23095    printf "#ifdef __%s__\nprintf(\"__%s__=%%s\\n\", STRINGIFY(__%s__));\n#endif\n", $1, $1, $1
23096}' >> try.c
23097echo 'return 0;}' >> try.c
23098EOSH
23099cat <<EOSH >> Cppsym.try
23100ccflags="$ccflags"
23101case "$osname-$gccversion" in
23102irix-) ccflags="\$ccflags -woff 1178" ;;
23103os2-*) ccflags="\$ccflags -Zlinker /PM:VIO" ;;
23104esac
23105$cc -o try -Dcpp_stuff=$cpp_stuff $optimize \$ccflags $ldflags try.c $libs 2>/dev/null && $run ./try | $sed 's/ /\\\\ /g'
23106EOSH
23107chmod +x Cppsym.try
23108$eunicefix Cppsym.try
23109./Cppsym < Cppsym.know | $sort | $uniq > Cppsym.true
23110: Add in any Linux cpp "predefined macros":
23111case "$osname::$gccversion" in
23112  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
23113    tHdrH=_tmpHdr
23114    rm -f $tHdrH'.h' $tHdrH
23115    touch $tHdrH'.h'
23116    # Filter out macro arguments, such as Linux's __INT8_C(c)
23117    if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
23118       sed -e 's/#define[\ \  ]*//;s/[\ \     ].*$//' -e 's/(.*//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
23119       if [ -s $tHdrH'_cppsym.real' ]; then
23120	  cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
23121       fi
23122    fi
23123    rm -f $tHdrH'.h' $tHdrH'_cppsym.h' $tHdrH'_cppsym.real'
23124  ;;
23125esac
23126: now check the C compiler for additional symbols
23127postprocess_cc_v=''
23128case "$osname" in
23129aix) postprocess_cc_v="|$tr , ' '" ;;
23130esac
23131$cat >ccsym <<EOS
23132$startsh
23133$cat >tmp.c <<EOF
23134extern int foo;
23135EOF
23136for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
23137do
23138	case "\$i" in
23139	-D*) echo "\$i" | $sed 's/^-D//';;
23140	-A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A//' | $sed 's/\(.*\)(\(.*\))/\1=\2/';;
23141	esac
23142done
23143$rm_try
23144EOS
23145postprocess_cc_v=''
23146chmod +x ccsym
23147$eunicefix ccsym
23148./ccsym > ccsym1.raw
23149if $test -s ccsym1.raw; then
23150    $sort ccsym1.raw | $uniq >ccsym.raw
23151else
23152    mv ccsym1.raw ccsym.raw
23153fi
23154
23155$awk '/\=/ { print $0; next }
23156	{ print $0"=1" }' ccsym.raw >ccsym.list
23157$comm -13 Cppsym.true ccsym.list >ccsym.own
23158$comm -12 Cppsym.true ccsym.list >ccsym.com
23159$comm -23 Cppsym.true ccsym.list >ccsym.cpp
23160also=''
23161if $test -z ccsym.raw; then
23162	echo "Your C compiler doesn't seem to define any symbols!" >&4
23163	echo " "
23164	echo "However, your C preprocessor defines the following symbols:"
23165	$cat Cppsym.true
23166	ccsymbols=''
23167	cppsymbols=`$cat Cppsym.true`
23168	cppsymbols=`echo $cppsymbols`
23169	cppccsymbols="$cppsymbols"
23170else
23171	if $test -s ccsym.com; then
23172		echo "Your C compiler and pre-processor define these symbols:"
23173		$sed -e 's/\(..*\)=.*/\1/' ccsym.com
23174		also='also '
23175		symbols='ones'
23176		cppccsymbols=`$cat ccsym.com`
23177		cppccsymbols=`echo $cppccsymbols`
23178		$test "$silent" || sleep 1
23179	fi
23180	if $test -s ccsym.cpp; then
23181		$test "$also" && echo " "
23182		echo "Your C pre-processor ${also}defines the following symbols:"
23183		$sed -e 's/\(..*\)=.*/\1/' ccsym.cpp
23184		also='further '
23185		cppsymbols=`$cat ccsym.cpp`
23186		cppsymbols=`echo $cppsymbols`
23187		$test "$silent" || sleep 1
23188	fi
23189	if $test -s ccsym.own; then
23190		$test "$also" && echo " "
23191		echo "Your C compiler ${also}defines the following cpp symbols:"
23192		$sed -e 's/\(..*\)=1/\1/' ccsym.own
23193		$sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
23194		ccsymbols=`$cat ccsym.own`
23195		ccsymbols=`echo $ccsymbols`
23196		$test "$silent" || sleep 1
23197	fi
23198fi
23199
23200: add -D_FORTIFY_SOURCE if feasible and not already there
23201case "$gccversion" in
23202[456789].*|[1-9][0-9]*)	case "$optimize$ccflags" in
23203	*-O*)	case "$ccflags$cppsymbols" in
23204		*_FORTIFY_SOURCE=*) # Don't add it again.
23205			echo "You seem to have -D_FORTIFY_SOURCE already, not adding it." >&4
23206			;;
23207		*)	echo "Adding -D_FORTIFY_SOURCE=2 to ccflags..." >&4
23208			ccflags="$ccflags -D_FORTIFY_SOURCE=2"
23209			;;
23210		esac
23211		;;
23212	*)	echo "You have gcc 4.* or later but not optimizing, not adding -D_FORTIFY_SOURCE." >&4
23213		;;
23214	esac
23215	;;
23216*)	echo "You seem not to have gcc 4.* or later, not adding -D_FORTIFY_SOURCE." >&4
23217	;;
23218esac
23219
23220: script used to emit important warnings
23221cat >warn <<EOS
23222$startsh
23223if test \$# -gt 0; then
23224	echo "\$@" >msg
23225else
23226	cat >msg
23227fi
23228echo "*** WARNING:" >&4
23229sed -e 's/^/*** /' <msg >&4
23230echo "*** " >&4
23231cat msg >>config.msg
23232echo " " >>config.msg
23233rm -f msg
23234EOS
23235chmod +x warn
23236$eunicefix warn
23237
23238: see if this is a termio system
23239val="$undef"
23240val2="$undef"
23241val3="$undef"
23242if $test `./findhdr termios.h`; then
23243    set tcsetattr i_termios
23244    eval $inlibc
23245    val3="$i_termios"
23246fi
23247echo " "
23248case "$val3" in
23249    "$define") echo "You have POSIX termios.h... good!" >&4;;
23250    *)  if ./Cppsym pyr; then
23251	    case "`$run /bin/universe`" in
23252		ucb) if $test `./findhdr sgtty.h`; then
23253			val2="$define"
23254			echo "<sgtty.h> found." >&4
23255		    else
23256			echo "System is pyramid with BSD universe."
23257			./warn "<sgtty.h> not found--you could have problems."
23258		    fi;;
23259		*)  if $test `./findhdr termio.h`; then
23260			val="$define"
23261			echo "<termio.h> found." >&4
23262		    else
23263			echo "System is pyramid with USG universe."
23264			./warn "<termio.h> not found--you could have problems."
23265		    fi;;
23266	    esac
23267	elif ./usg; then
23268	    if $test `./findhdr termio.h`; then
23269		echo "<termio.h> found." >&4
23270		val="$define"
23271	    elif $test `./findhdr sgtty.h`; then
23272		echo "<sgtty.h> found." >&4
23273		val2="$define"
23274	    else
23275		./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
23276	    fi
23277	else
23278	    if $test `./findhdr sgtty.h`; then
23279		echo "<sgtty.h> found." >&4
23280		val2="$define"
23281	    elif $test `./findhdr termio.h`; then
23282		echo "<termio.h> found." >&4
23283		val="$define"
23284	    else
23285		./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
23286	    fi
23287	fi;;
23288esac
23289set i_termio; eval $setvar
23290val=$val2; set i_sgtty; eval $setvar
23291val=$val3; set i_termios; eval $setvar
23292
23293: see if stdbool is available
23294: we want a real compile instead of Inhdr because some Solaris systems
23295: have stdbool.h, but it can only be used if the compiler indicates it
23296: is sufficiently c99-compliant.
23297echo " "
23298$cat >try.c <<EOCP
23299#include <stdio.h>
23300#include <stdbool.h>
23301int func(bool x)
23302{
23303    return x ? 1 : 0;
23304}
23305int main(int argc, char **argv)
23306{
23307    return func(0);
23308}
23309EOCP
23310set try
23311if eval $compile; then
23312	echo "<stdbool.h> found." >&4
23313	val="$define"
23314else
23315	echo "<stdbool.h> NOT found." >&4
23316	val="$undef"
23317fi
23318$rm_try
23319set i_stdbool
23320eval $setvar
23321
23322: see if stdint is available
23323set stdint.h i_stdint
23324eval $inhdr
23325
23326: see if sys/access.h is available
23327set sys/access.h i_sysaccess
23328eval $inhdr
23329
23330: see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
23331set sys/filio.h i_sysfilio
23332eval $inhdr
23333echo " "
23334if $test `./findhdr sys/ioctl.h`; then
23335	val="$define"
23336	echo '<sys/ioctl.h> found.' >&4
23337else
23338	val="$undef"
23339	if $test $i_sysfilio = "$define"; then
23340	    echo '<sys/ioctl.h> NOT found.' >&4
23341	else
23342		$test $i_sgtty = "$define" && xxx="sgtty.h"
23343		$test $i_termio = "$define" && xxx="termio.h"
23344		$test $i_termios = "$define" && xxx="termios.h"
23345echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
23346	fi
23347fi
23348set i_sysioctl
23349eval $setvar
23350
23351: see if socket ioctl defs are in sys/sockio.h
23352echo " "
23353xxx=`./findhdr sys/sockio.h`
23354if $test "$xxx"; then
23355	if $contains SIOCATMARK $xxx >/dev/null 2>&1; then
23356		val="$define"
23357		echo "You have socket ioctls defined in <sys/sockio.h>." >&4
23358	else
23359		val="$undef"
23360		echo "No socket ioctls found in <sys/sockio.h>." >&4
23361	fi
23362else
23363	val="$undef"
23364	$cat <<EOM
23365<sys/sockio.h> not found, assuming socket ioctls are in <sys/ioctl.h>.
23366EOM
23367fi
23368set i_syssockio
23369eval $setvar
23370
23371: see if this is a syslog.h system
23372set syslog.h i_syslog
23373eval $inhdr
23374
23375: see if this is a sys/mode.h system
23376set sys/mode.h i_sysmode
23377eval $inhdr
23378
23379: see if there is a sys/poll.h file
23380set sys/poll.h i_syspoll
23381eval $inhdr
23382
23383: see if sys/resource.h has to be included
23384set sys/resource.h i_sysresrc
23385eval $inhdr
23386
23387: see if sys/security.h is available
23388set sys/security.h i_syssecrt
23389eval $inhdr
23390
23391: see if this is a sys/statvfs.h system
23392set sys/statvfs.h i_sysstatvfs
23393eval $inhdr
23394
23395: see if this is a sys/un.h system
23396set sys/un.h i_sysun
23397eval $inhdr
23398
23399: see if this is a sys/utsname.h system
23400set sys/utsname.h i_sysutsname
23401eval $inhdr
23402
23403: see if this is a syswait system
23404set sys/wait.h i_syswait
23405eval $inhdr
23406
23407: see if this is a ustat.h system
23408set ustat.h i_ustat
23409eval $inhdr
23410
23411: see if this is an utime system
23412set utime.h i_utime
23413eval $inhdr
23414
23415: see if this is a vfork system
23416case "$d_vfork" in
23417"$define")
23418	set vfork.h i_vfork
23419	eval $inhdr
23420	;;
23421*)
23422	i_vfork="$undef"
23423	;;
23424esac
23425
23426: see if wchar.h is present
23427set wchar.h i_wchar
23428eval $inhdr
23429
23430: Check extensions
23431echo " "
23432echo "Looking for extensions..." >&4
23433: If we are using the old config.sh, nonxs_extensions and xs_extensions may
23434: contain old or inaccurate or duplicate values.
23435nonxs_extensions=''
23436xs_extensions=''
23437: We do not use find because it might not be available.
23438: We do not just use MANIFEST because the user may have dropped
23439: some additional extensions into the source tree and expect them
23440: to be built.
23441
23442: Function to recursively find available extensions, ignoring DynaLoader
23443: NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
23444: In 5.10.1 and later, extensions are stored in directories
23445: like File-Glob instead of the older File/Glob/.
23446find_extensions='
23447    for xxx in *; do
23448	case "$xxx" in
23449	    CVS) ;;
23450	    DynaLoader|dynaload) ;;
23451	    *)
23452	    this_ext=`echo "$xxx" | $sed -e s/-/\\\//g`;
23453	    case "$this_ext" in
23454		Scalar/List/Utils) this_ext="List/Util"	;;
23455		PathTools)         this_ext="Cwd"	;;
23456	    esac;
23457	    echo " $xs_extensions $nonxs_extensions" > "$tdir/$$.tmp";
23458	    if $contains " $this_ext " "$tdir/$$.tmp"; then
23459		echo >&4;
23460		echo "Duplicate directories detected for extension $xxx" >&4;
23461		echo "Configure cannot correctly recover from this - shall I abort?" >&4;
23462		case "$knowitall" in
23463		"") dflt=y;;
23464		*) dflt=n;;
23465		esac;
23466		. ../UU/myread;
23467		case "$ans" in
23468		n*|N*) ;;
23469		*) echo >&4;
23470		    echo "Ok.  Stopping Configure." >&4;
23471		    echo "Please remove the duplicate directory (e.g. using git clean) and then re-run Configure" >&4;
23472		    exit 1;;
23473		esac;
23474		echo "Ok.  You will need to correct config.sh before running make." >&4;
23475	    fi;
23476	    $ls -1 "$xxx" > "$tdir/$$.tmp";
23477	    if   $contains "\.xs$" "$tdir/$$.tmp" > /dev/null 2>&1; then
23478		xs_extensions="$xs_extensions $this_ext";
23479	    elif $contains "\.c$"  "$tdir/$$.tmp" > /dev/null 2>&1; then
23480		xs_extensions="$xs_extensions $this_ext";
23481	    elif $test -d "$xxx"; then
23482		nonxs_extensions="$nonxs_extensions $this_ext";
23483	    fi;
23484	    $rm -f "$tdir/$$.tmp";
23485	    ;;
23486	esac;
23487    done'
23488tdir=`pwd`
23489cd "$rsrc/cpan"
23490set X
23491shift
23492eval $find_extensions
23493cd "$rsrc/dist"
23494set X
23495shift
23496eval $find_extensions
23497cd "$rsrc/ext"
23498set X
23499shift
23500eval $find_extensions
23501set X $xs_extensions
23502shift
23503xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
23504set X $nonxs_extensions
23505shift
23506nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
23507cd "$tdir"
23508known_extensions=`echo $nonxs_extensions $xs_extensions  | tr ' ' $trnl | $sort | tr $trnl ' '`
23509
23510: Now see which are supported on this system.
23511avail_ext=''
23512for xxx in $xs_extensions ; do
23513	case "$xxx" in
23514	Amiga*)
23515		case "$osname" in
23516		amigaos) avail_ext="$avail_ext $xxx" ;;
23517		esac
23518		;;
23519	DB_File|db_file)
23520		case "$i_db" in
23521		$define) avail_ext="$avail_ext $xxx" ;;
23522		esac
23523		;;
23524	GDBM_File|gdbm_fil)
23525		case "$i_gdbm" in
23526		$define) avail_ext="$avail_ext $xxx" ;;
23527		esac
23528		;;
23529	IPC/SysV|ipc/sysv)
23530		: XXX Do we need a useipcsysv variable here
23531		case "${d_msg}${d_sem}${d_shm}" in
23532		*"${define}"*) avail_ext="$avail_ext $xxx" ;;
23533		esac
23534		;;
23535	NDBM_File|ndbm_fil)
23536		case "$d_ndbm" in
23537		$define)
23538		    case "$osname-$use64bitint" in
23539		    hpux-define)
23540			case "$libs" in
23541			*-lndbm*) avail_ext="$avail_ext $xxx" ;;
23542			esac
23543			;;
23544		    *) avail_ext="$avail_ext $xxx" ;;
23545		    esac
23546		    ;;
23547		esac
23548		;;
23549	ODBM_File|odbm_fil)
23550		case "${i_dbm}${i_rpcsvcdbm}" in
23551		*"${define}"*)
23552		    case "$d_cplusplus" in
23553		    define) ;; # delete as a function name will not work
23554		    *)  case "$osname-$use64bitint" in
23555			hpux-define)
23556			    case "$libs" in
23557			    *-ldbm*) avail_ext="$avail_ext $xxx" ;;
23558			    esac
23559			    ;;
23560			*) avail_ext="$avail_ext $xxx" ;;
23561			esac
23562			;;
23563		    esac
23564		    ;;
23565		esac
23566		;;
23567	Opcode|opcode)
23568		case "$useopcode" in
23569		true|define|y) avail_ext="$avail_ext $xxx" ;;
23570		esac
23571		;;
23572	POSIX|posix)
23573		case "$useposix" in
23574		true|define|y) avail_ext="$avail_ext $xxx" ;;
23575		esac
23576		;;
23577	Socket|socket)
23578		case "$d_socket" in
23579		true|$define|y) avail_ext="$avail_ext $xxx" ;;
23580		esac
23581		;;
23582	I18N/Langinfo|langinfo)
23583		case "$uselanginfo" in
23584		true|define|y) avail_ext="$avail_ext $xxx" ;;
23585		esac
23586		;;
23587	Sys/Syslog|sys/syslog)
23588		case $osname in
23589			amigaos) ;; # not really very useful on AmigaOS
23590			*)
23591			: XXX syslog requires socket
23592			case "$d_socket" in
23593			true|$define|y) avail_ext="$avail_ext $xxx" ;;
23594			esac
23595			;;
23596		esac
23597		;;
23598	Thread|thread)
23599                case "$usethreads" in
23600                true|$define|y)
23601                        case "$use5005threads" in
23602                        $define|true|[yY]*) avail_ext="$avail_ext $xxx" ;;
23603                        esac
23604		esac
23605		;;
23606	threads|threads/shared)
23607		# threads and threads::shared are special cases.
23608		# To stop people from asking "Perl 5.8.0 was supposed
23609		# to have this new fancy threads implementation but my
23610		# perl doesn't have it" and from people trying to
23611		# (re)install the threads module using CPAN.pm and
23612		# CPAN.pm then offering to reinstall Perl 5.8.0,
23613		# the threads.pm and threads/shared.pm will always be
23614		# there, croaking informatively ("you need to rebuild
23615		# all of Perl with threads, sorry") when threads haven't
23616		# been compiled in.
23617		# --jhi
23618		avail_ext="$avail_ext $xxx"
23619		;;
23620	VMS*)
23621		;;
23622	Win32*)
23623		case "$osname" in
23624		cygwin) avail_ext="$avail_ext $xxx" ;;
23625		esac
23626		;;
23627	XS/APItest|xs/apitest)
23628		# This is just for testing.  Skip it unless we have dynamic loading.
23629
23630		case "$usedl" in
23631		$define) avail_ext="$avail_ext $xxx" ;;
23632		esac
23633		;;
23634	XS/Typemap|xs/typemap)
23635		# This is just for testing.  Skip it unless we have dynamic loading.
23636		case "$usedl" in
23637		$define) avail_ext="$avail_ext $xxx" ;;
23638		esac
23639		;;
23640	*)	avail_ext="$avail_ext $xxx"
23641		;;
23642	esac
23643done
23644
23645set X $avail_ext
23646shift
23647avail_ext="$*"
23648
23649case "$onlyextensions" in
23650'') ;;
23651*)  keepextensions=''
23652    echo "You have requested that only certain extensions be included..." >&4
23653    for i in $onlyextensions; do
23654        case " $avail_ext " in
23655        *" $i "*)
23656            echo "Keeping extension $i."
23657            keepextensions="$keepextensions $i"
23658            ;;
23659        *) echo "Ignoring extension $i." ;;
23660        esac
23661    done
23662    avail_ext="$keepextensions"
23663    ;;
23664esac
23665
23666case "$noextensions" in
23667'') ;;
23668*)  keepextensions=''
23669    echo "You have requested that certain extensions be ignored..." >&4
23670    for i in $avail_ext; do
23671        case " $noextensions " in
23672        *" $i "*) echo "Ignoring extension $i." ;;
23673        *) echo "Keeping extension $i.";
23674           keepextensions="$keepextensions $i"
23675           ;;
23676        esac
23677    done
23678    avail_ext="$keepextensions"
23679    ;;
23680esac
23681
23682: Now see which nonxs extensions are supported on this system.
23683: For now assume all are.
23684nonxs_ext=''
23685for xxx in $nonxs_extensions ; do
23686	case "$xxx" in
23687	CVS|RCS|SCCS|.svn)
23688		;;
23689	VMS*)
23690		;;
23691	*)	nonxs_ext="$nonxs_ext $xxx"
23692		;;
23693	esac
23694done
23695
23696set X $nonxs_ext
23697shift
23698nonxs_ext="$*"
23699
23700case $usedl in
23701$define)
23702	$cat <<EOM
23703A number of extensions are supplied with $package.  You may choose to
23704compile these extensions for dynamic loading (the default), compile
23705them into the $package executable (static loading), or not include
23706them at all.  Answer "none" to include no extensions.
23707Note that DynaLoader is always built and need not be mentioned here.
23708
23709EOM
23710	case "$dynamic_ext" in
23711	'')
23712		: Exclude those listed in static_ext
23713		dflt=''
23714		for xxx in $avail_ext; do
23715			case " $static_ext " in
23716			*" $xxx "*) ;;
23717			*) dflt="$dflt $xxx" ;;
23718			esac
23719		done
23720		set X $dflt
23721		shift
23722		dflt="$*"
23723		;;
23724	*)	dflt="$dynamic_ext"
23725		# Perhaps we are reusing an old out-of-date config.sh.
23726		case "$hint" in
23727		previous)
23728			if test X"$dynamic_ext" != X"$avail_ext"; then
23729				$cat <<EOM
23730NOTICE:  Your previous config.sh list may be incorrect.
23731The extensions now available to you are
23732	${avail_ext}
23733but the default list from your previous config.sh is
23734	${dynamic_ext}
23735
23736EOM
23737			fi
23738			;;
23739		esac
23740		;;
23741	esac
23742	case "$dflt" in
23743	'')	dflt=none;;
23744	esac
23745	rp="What extensions do you wish to load dynamically?"
23746	. ./myread
23747	case "$ans" in
23748	none) dynamic_ext=' ' ;;
23749	*) dynamic_ext="$ans" ;;
23750	esac
23751
23752	case "$static_ext" in
23753	'')
23754		: Exclude those already listed in dynamic linking
23755		dflt=''
23756		for xxx in $avail_ext; do
23757			case " $dynamic_ext " in
23758			*" $xxx "*) ;;
23759			*) dflt="$dflt $xxx" ;;
23760			esac
23761		done
23762		set X $dflt
23763		shift
23764		dflt="$*"
23765		;;
23766	*)  dflt="$static_ext"
23767		;;
23768	esac
23769
23770	case "$dflt" in
23771	'')	dflt=none;;
23772	esac
23773	rp="What extensions do you wish to load statically?"
23774	. ./myread
23775	case "$ans" in
23776	none) static_ext=' ' ;;
23777	*) static_ext="$ans" ;;
23778	esac
23779	;;
23780*)
23781	$cat <<EOM
23782A number of extensions are supplied with $package.  Answer "none"
23783to include no extensions.
23784Note that DynaLoader is always built and need not be mentioned here.
23785
23786EOM
23787	case "$static_ext" in
23788	'') dflt="$avail_ext" ;;
23789	*)	dflt="$static_ext"
23790		# Perhaps we are reusing an old out-of-date config.sh.
23791		case "$hint" in
23792		previous)
23793			if test X"$static_ext" != X"$avail_ext"; then
23794				$cat <<EOM
23795NOTICE:  Your previous config.sh list may be incorrect.
23796The extensions now available to you are
23797	${avail_ext}
23798but the default list from your previous config.sh is
23799	${static_ext}
23800
23801EOM
23802			fi
23803			;;
23804		esac
23805		;;
23806	esac
23807	: Exclude those that are not xs extensions
23808	case "$dflt" in
23809	'')	dflt=none;;
23810	esac
23811	rp="What extensions do you wish to include?"
23812	. ./myread
23813	case "$ans" in
23814	none) static_ext=' ' ;;
23815	*) static_ext="$ans" ;;
23816	esac
23817	;;
23818esac
23819#
23820# Encode is a special case.  If we are building Encode as a static
23821# extension, we need to explicitly list its subextensions as well.
23822# For other nested extensions, this is handled automatically by
23823# the appropriate Makefile.PL.
23824case " $static_ext " in
23825	*" Encode "*) # Add the subextensions of Encode
23826	cd "$rsrc/cpan"
23827	for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
23828		static_ext="$static_ext Encode/$xxx"
23829		known_extensions="$known_extensions Encode/$xxx"
23830	done
23831	cd "$tdir"
23832	;;
23833esac
23834
23835set X $dynamic_ext $static_ext $nonxs_ext
23836shift
23837extensions="$*"
23838
23839# Sanity check:  We require an extension suitable for use with
23840# AnyDBM_File, as well as Fcntl and IO.  (Failure to have these
23841# should show up as failures in the test suite, but it's helpful to
23842# catch them now.) The 'extensions' list is normally sorted
23843# alphabetically, so we need to accept either
23844#    DB_File ... Fcntl ... IO  ....
23845# or something like
23846#    Fcntl ... NDBM_File ... IO  ....
23847case " $extensions"  in
23848*"_File "*" Fcntl "*" IO "*) ;; # DB_File
23849*" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
23850*" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
23851*) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
23852   echo "WARNING: The Perl you are building will be quite crippled." >& 4
23853   ;;
23854esac
23855
23856: Remove libraries needed only for extensions
23857: The appropriate ext/Foo/Makefile.PL will add them back in, if necessary.
23858: The exception is SunOS 4.x, which needs them.
23859case "${osname}X${osvers}" in
23860sunos*X4*)
23861    perllibs="$libs"
23862    ;;
23863*) case "$usedl" in
23864    $define|true|[yY]*)
23865	    set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
23866	    shift
23867	    perllibs="$*"
23868	    ;;
23869    *)	perllibs="$libs"
23870	    ;;
23871    esac
23872    ;;
23873esac
23874
23875: Remove build directory name from cppstdin so it can be used from
23876: either the present location or the final installed location.
23877echo " "
23878: Get out of the UU directory to get correct path name.
23879cd ..
23880case "$cppstdin" in
23881`pwd`/cppstdin)
23882	echo "Stripping down cppstdin path name"
23883	cppstdin=cppstdin
23884	;;
23885esac
23886cd UU
23887
23888: end of configuration questions
23889echo " "
23890echo "End of configuration questions."
23891echo " "
23892
23893: back to where it started
23894if test -d ../UU; then
23895	cd ..
23896fi
23897
23898: configuration may be unconditionally patched via a 'config.arch' file
23899if $test -f config.arch; then
23900	echo "I see a config.arch file, loading it." >&4
23901	. ./config.arch
23902fi
23903
23904: configuration may be patched via a 'config.over' file
23905if $test -f config.over; then
23906	echo " "
23907	dflt=y
23908	rp='I see a config.over file.  Do you wish to load it?'
23909	. UU/myread
23910	case "$ans" in
23911	n*) echo "OK, I'll ignore it.";;
23912	*)	. ./config.over
23913		echo "Configuration override changes have been loaded."
23914		;;
23915	esac
23916fi
23917
23918: in case they want portability, strip down executable paths
23919case "$d_portable" in
23920"$define")
23921	echo " "
23922	echo "Stripping down executable paths..." >&4
23923	for file in $loclist $trylist; do
23924		eval temp=\$$file
23925		eval $file=`basename $temp`
23926	done
23927	;;
23928esac
23929
23930: create config.sh file
23931echo " "
23932echo "Creating config.sh..." >&4
23933$spitshell <<EOT >config.sh
23934$startsh
23935#
23936# This file was produced by running the Configure script. It holds all the
23937# definitions figured out by Configure. Should you modify one of these values,
23938# do not forget to propagate your changes by running "Configure -der". You may
23939# instead choose to run each of the .SH files by yourself, or "Configure -S".
23940#
23941
23942# Package name      : $package
23943# Source directory  : $src
23944# Configuration time: $cf_time
23945# Configured by     : $cf_by
23946# Target system     : $myuname
23947
23948EOT
23949: Add in command line options if available
23950$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
23951
23952$spitshell <<EOT >>config.sh
23953
23954Author='$Author'
23955Date='$Date'
23956Header='$Header'
23957Id='$Id'
23958Locker='$Locker'
23959Log='$Log'
23960RCSfile='$RCSfile'
23961Revision='$Revision'
23962Source='$Source'
23963State='$State'
23964_a='$_a'
23965_exe='$_exe'
23966_o='$_o'
23967afs='$afs'
23968afsroot='$afsroot'
23969alignbytes='$alignbytes'
23970aphostname='$aphostname'
23971api_revision='$api_revision'
23972api_subversion='$api_subversion'
23973api_version='$api_version'
23974api_versionstring='$api_versionstring'
23975ar='$ar'
23976archlib='$archlib'
23977archlibexp='$archlibexp'
23978archname64='$archname64'
23979archname='$archname'
23980archobjs='$archobjs'
23981asctime_r_proto='$asctime_r_proto'
23982awk='$awk'
23983baserev='$baserev'
23984bash='$bash'
23985bin='$bin'
23986bin_ELF='$bin_ELF'
23987binexp='$binexp'
23988bison='$bison'
23989byacc='$byacc'
23990byteorder='$byteorder'
23991c='$c'
23992castflags='$castflags'
23993cat='$cat'
23994cc='$cc'
23995cccdlflags='$cccdlflags'
23996ccdlflags='$ccdlflags'
23997ccflags='$ccflags'
23998ccflags_uselargefiles='$ccflags_uselargefiles'
23999ccname='$ccname'
24000ccsymbols='$ccsymbols'
24001ccversion='$ccversion'
24002cf_by='$cf_by'
24003cf_email='$cf_email'
24004cf_time='$cf_time'
24005charbits='$charbits'
24006charsize='$charsize'
24007chgrp='$chgrp'
24008chmod='$chmod'
24009chown='$chown'
24010clocktype='$clocktype'
24011comm='$comm'
24012compress='$compress'
24013contains='$contains'
24014cp='$cp'
24015cpio='$cpio'
24016cpp='$cpp'
24017cpp_stuff='$cpp_stuff'
24018cppccsymbols='$cppccsymbols'
24019cppflags='$cppflags'
24020cpplast='$cpplast'
24021cppminus='$cppminus'
24022cpprun='$cpprun'
24023cppstdin='$cppstdin'
24024cppsymbols='$cppsymbols'
24025crypt_r_proto='$crypt_r_proto'
24026cryptlib='$cryptlib'
24027csh='$csh'
24028ctermid_r_proto='$ctermid_r_proto'
24029ctime_r_proto='$ctime_r_proto'
24030d_Gconvert='$d_Gconvert'
24031d_PRIEUldbl='$d_PRIEUldbl'
24032d_PRIFUldbl='$d_PRIFUldbl'
24033d_PRIGUldbl='$d_PRIGUldbl'
24034d_PRIXU64='$d_PRIXU64'
24035d_PRId64='$d_PRId64'
24036d_PRIeldbl='$d_PRIeldbl'
24037d_PRIfldbl='$d_PRIfldbl'
24038d_PRIgldbl='$d_PRIgldbl'
24039d_PRIi64='$d_PRIi64'
24040d_PRIo64='$d_PRIo64'
24041d_PRIu64='$d_PRIu64'
24042d_PRIx64='$d_PRIx64'
24043d_SCNfldbl='$d_SCNfldbl'
24044d__fwalk='$d__fwalk'
24045d_accept4='$d_accept4'
24046d_access='$d_access'
24047d_accessx='$d_accessx'
24048d_acosh='$d_acosh'
24049d_aintl='$d_aintl'
24050d_alarm='$d_alarm'
24051d_archlib='$d_archlib'
24052d_asctime64='$d_asctime64'
24053d_asctime_r='$d_asctime_r'
24054d_asinh='$d_asinh'
24055d_atanh='$d_atanh'
24056d_atolf='$d_atolf'
24057d_atoll='$d_atoll'
24058d_attribute_deprecated='$d_attribute_deprecated'
24059d_attribute_format='$d_attribute_format'
24060d_attribute_malloc='$d_attribute_malloc'
24061d_attribute_nonnull='$d_attribute_nonnull'
24062d_attribute_noreturn='$d_attribute_noreturn'
24063d_attribute_pure='$d_attribute_pure'
24064d_attribute_unused='$d_attribute_unused'
24065d_attribute_warn_unused_result='$d_attribute_warn_unused_result'
24066d_backtrace='$d_backtrace'
24067d_bsd='$d_bsd'
24068d_bsdgetpgrp='$d_bsdgetpgrp'
24069d_bsdsetpgrp='$d_bsdsetpgrp'
24070d_builtin_add_overflow='$d_builtin_add_overflow'
24071d_builtin_choose_expr='$d_builtin_choose_expr'
24072d_builtin_expect='$d_builtin_expect'
24073d_builtin_mul_overflow='$d_builtin_mul_overflow'
24074d_builtin_sub_overflow='$d_builtin_sub_overflow'
24075d_c99_variadic_macros='$d_c99_variadic_macros'
24076d_casti32='$d_casti32'
24077d_castneg='$d_castneg'
24078d_cbrt='$d_cbrt'
24079d_chown='$d_chown'
24080d_chroot='$d_chroot'
24081d_chsize='$d_chsize'
24082d_class='$d_class'
24083d_clearenv='$d_clearenv'
24084d_closedir='$d_closedir'
24085d_cmsghdr_s='$d_cmsghdr_s'
24086d_copysign='$d_copysign'
24087d_copysignl='$d_copysignl'
24088d_cplusplus='$d_cplusplus'
24089d_crypt='$d_crypt'
24090d_crypt_r='$d_crypt_r'
24091d_csh='$d_csh'
24092d_ctermid='$d_ctermid'
24093d_ctermid_r='$d_ctermid_r'
24094d_ctime64='$d_ctime64'
24095d_ctime_r='$d_ctime_r'
24096d_cuserid='$d_cuserid'
24097d_dbminitproto='$d_dbminitproto'
24098d_difftime64='$d_difftime64'
24099d_difftime='$d_difftime'
24100d_dir_dd_fd='$d_dir_dd_fd'
24101d_dirfd='$d_dirfd'
24102d_dirnamlen='$d_dirnamlen'
24103d_dladdr='$d_dladdr'
24104d_dlerror='$d_dlerror'
24105d_dlopen='$d_dlopen'
24106d_dlsymun='$d_dlsymun'
24107d_dosuid='$d_dosuid'
24108d_double_has_inf='$d_double_has_inf'
24109d_double_has_nan='$d_double_has_nan'
24110d_double_has_negative_zero='$d_double_has_negative_zero'
24111d_double_has_subnormals='$d_double_has_subnormals'
24112d_double_style_cray='$d_double_style_cray'
24113d_double_style_ibm='$d_double_style_ibm'
24114d_double_style_ieee='$d_double_style_ieee'
24115d_double_style_vax='$d_double_style_vax'
24116d_drand48_r='$d_drand48_r'
24117d_drand48proto='$d_drand48proto'
24118d_dup2='$d_dup2'
24119d_dup3='$d_dup3'
24120d_duplocale='$d_duplocale'
24121d_eaccess='$d_eaccess'
24122d_endgrent='$d_endgrent'
24123d_endgrent_r='$d_endgrent_r'
24124d_endhent='$d_endhent'
24125d_endhostent_r='$d_endhostent_r'
24126d_endnent='$d_endnent'
24127d_endnetent_r='$d_endnetent_r'
24128d_endpent='$d_endpent'
24129d_endprotoent_r='$d_endprotoent_r'
24130d_endpwent='$d_endpwent'
24131d_endpwent_r='$d_endpwent_r'
24132d_endsent='$d_endsent'
24133d_endservent_r='$d_endservent_r'
24134d_eofnblk='$d_eofnblk'
24135d_erf='$d_erf'
24136d_erfc='$d_erfc'
24137d_eunice='$d_eunice'
24138d_exp2='$d_exp2'
24139d_expm1='$d_expm1'
24140d_faststdio='$d_faststdio'
24141d_fchdir='$d_fchdir'
24142d_fchmod='$d_fchmod'
24143d_fchmodat='$d_fchmodat'
24144d_fchown='$d_fchown'
24145d_fcntl='$d_fcntl'
24146d_fcntl_can_lock='$d_fcntl_can_lock'
24147d_fd_macros='$d_fd_macros'
24148d_fd_set='$d_fd_set'
24149d_fdclose='$d_fdclose'
24150d_fdim='$d_fdim'
24151d_fds_bits='$d_fds_bits'
24152d_fegetround='$d_fegetround'
24153d_fgetpos='$d_fgetpos'
24154d_finite='$d_finite'
24155d_finitel='$d_finitel'
24156d_flexfnam='$d_flexfnam'
24157d_flock='$d_flock'
24158d_flockproto='$d_flockproto'
24159d_fma='$d_fma'
24160d_fmax='$d_fmax'
24161d_fmin='$d_fmin'
24162d_fork='$d_fork'
24163d_fp_class='$d_fp_class'
24164d_fp_classify='$d_fp_classify'
24165d_fp_classl='$d_fp_classl'
24166d_fpathconf='$d_fpathconf'
24167d_fpclass='$d_fpclass'
24168d_fpclassify='$d_fpclassify'
24169d_fpclassl='$d_fpclassl'
24170d_fpgetround='$d_fpgetround'
24171d_fpos64_t='$d_fpos64_t'
24172d_freelocale='$d_freelocale'
24173d_frexpl='$d_frexpl'
24174d_fs_data_s='$d_fs_data_s'
24175d_fseeko='$d_fseeko'
24176d_fsetpos='$d_fsetpos'
24177d_fstatfs='$d_fstatfs'
24178d_fstatvfs='$d_fstatvfs'
24179d_fsync='$d_fsync'
24180d_ftello='$d_ftello'
24181d_ftime='$d_ftime'
24182d_futimes='$d_futimes'
24183d_gai_strerror='$d_gai_strerror'
24184d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
24185d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
24186d_getaddrinfo='$d_getaddrinfo'
24187d_getcwd='$d_getcwd'
24188d_getespwnam='$d_getespwnam'
24189d_getfsstat='$d_getfsstat'
24190d_getgrent='$d_getgrent'
24191d_getgrent_r='$d_getgrent_r'
24192d_getgrgid_r='$d_getgrgid_r'
24193d_getgrnam_r='$d_getgrnam_r'
24194d_getgrps='$d_getgrps'
24195d_gethbyaddr='$d_gethbyaddr'
24196d_gethbyname='$d_gethbyname'
24197d_gethent='$d_gethent'
24198d_gethname='$d_gethname'
24199d_gethostbyaddr_r='$d_gethostbyaddr_r'
24200d_gethostbyname_r='$d_gethostbyname_r'
24201d_gethostent_r='$d_gethostent_r'
24202d_gethostprotos='$d_gethostprotos'
24203d_getitimer='$d_getitimer'
24204d_getlogin='$d_getlogin'
24205d_getlogin_r='$d_getlogin_r'
24206d_getmnt='$d_getmnt'
24207d_getmntent='$d_getmntent'
24208d_getnameinfo='$d_getnameinfo'
24209d_getnbyaddr='$d_getnbyaddr'
24210d_getnbyname='$d_getnbyname'
24211d_getnent='$d_getnent'
24212d_getnetbyaddr_r='$d_getnetbyaddr_r'
24213d_getnetbyname_r='$d_getnetbyname_r'
24214d_getnetent_r='$d_getnetent_r'
24215d_getnetprotos='$d_getnetprotos'
24216d_getpagsz='$d_getpagsz'
24217d_getpbyname='$d_getpbyname'
24218d_getpbynumber='$d_getpbynumber'
24219d_getpent='$d_getpent'
24220d_getpgid='$d_getpgid'
24221d_getpgrp2='$d_getpgrp2'
24222d_getpgrp='$d_getpgrp'
24223d_getppid='$d_getppid'
24224d_getprior='$d_getprior'
24225d_getprotobyname_r='$d_getprotobyname_r'
24226d_getprotobynumber_r='$d_getprotobynumber_r'
24227d_getprotoent_r='$d_getprotoent_r'
24228d_getprotoprotos='$d_getprotoprotos'
24229d_getprpwnam='$d_getprpwnam'
24230d_getpwent='$d_getpwent'
24231d_getpwent_r='$d_getpwent_r'
24232d_getpwnam_r='$d_getpwnam_r'
24233d_getpwuid_r='$d_getpwuid_r'
24234d_getsbyname='$d_getsbyname'
24235d_getsbyport='$d_getsbyport'
24236d_getsent='$d_getsent'
24237d_getservbyname_r='$d_getservbyname_r'
24238d_getservbyport_r='$d_getservbyport_r'
24239d_getservent_r='$d_getservent_r'
24240d_getservprotos='$d_getservprotos'
24241d_getspnam='$d_getspnam'
24242d_getspnam_r='$d_getspnam_r'
24243d_gettimeod='$d_gettimeod'
24244d_gmtime64='$d_gmtime64'
24245d_gmtime_r='$d_gmtime_r'
24246d_gnulibc='$d_gnulibc'
24247d_grpasswd='$d_grpasswd'
24248d_has_C_UTF8='$d_has_C_UTF8'
24249d_hasmntopt='$d_hasmntopt'
24250d_htonl='$d_htonl'
24251d_hypot='$d_hypot'
24252d_ilogb='$d_ilogb'
24253d_ilogbl='$d_ilogbl'
24254d_inc_version_list='$d_inc_version_list'
24255d_inetaton='$d_inetaton'
24256d_inetntop='$d_inetntop'
24257d_inetpton='$d_inetpton'
24258d_int64_t='$d_int64_t'
24259d_ip_mreq='$d_ip_mreq'
24260d_ip_mreq_source='$d_ip_mreq_source'
24261d_ipv6_mreq='$d_ipv6_mreq'
24262d_ipv6_mreq_source='$d_ipv6_mreq_source'
24263d_isascii='$d_isascii'
24264d_isblank='$d_isblank'
24265d_isfinite='$d_isfinite'
24266d_isfinitel='$d_isfinitel'
24267d_isinf='$d_isinf'
24268d_isinfl='$d_isinfl'
24269d_isless='$d_isless'
24270d_isnan='$d_isnan'
24271d_isnanl='$d_isnanl'
24272d_isnormal='$d_isnormal'
24273d_j0='$d_j0'
24274d_j0l='$d_j0l'
24275d_killpg='$d_killpg'
24276d_lc_monetary_2008='$d_lc_monetary_2008'
24277d_lchown='$d_lchown'
24278d_ldbl_dig='$d_ldbl_dig'
24279d_ldexpl='$d_ldexpl'
24280d_lgamma='$d_lgamma'
24281d_lgamma_r='$d_lgamma_r'
24282d_libm_lib_version='$d_libm_lib_version'
24283d_libname_unique='$d_libname_unique'
24284d_link='$d_link'
24285d_linkat='$d_linkat'
24286d_llrint='$d_llrint'
24287d_llrintl='$d_llrintl'
24288d_llround='$d_llround'
24289d_llroundl='$d_llroundl'
24290d_localeconv_l='$d_localeconv_l'
24291d_localtime64='$d_localtime64'
24292d_localtime_r='$d_localtime_r'
24293d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
24294d_locconv='$d_locconv'
24295d_lockf='$d_lockf'
24296d_log1p='$d_log1p'
24297d_log2='$d_log2'
24298d_logb='$d_logb'
24299d_long_double_style_ieee='$d_long_double_style_ieee'
24300d_long_double_style_ieee_doubledouble='$d_long_double_style_ieee_doubledouble'
24301d_long_double_style_ieee_extended='$d_long_double_style_ieee_extended'
24302d_long_double_style_ieee_std='$d_long_double_style_ieee_std'
24303d_long_double_style_vax='$d_long_double_style_vax'
24304d_longdbl='$d_longdbl'
24305d_longlong='$d_longlong'
24306d_lrint='$d_lrint'
24307d_lrintl='$d_lrintl'
24308d_lround='$d_lround'
24309d_lroundl='$d_lroundl'
24310d_lseekproto='$d_lseekproto'
24311d_lstat='$d_lstat'
24312d_madvise='$d_madvise'
24313d_malloc_good_size='$d_malloc_good_size'
24314d_malloc_size='$d_malloc_size'
24315d_mblen='$d_mblen'
24316d_mbrlen='$d_mbrlen'
24317d_mbrtowc='$d_mbrtowc'
24318d_mbstowcs='$d_mbstowcs'
24319d_mbtowc='$d_mbtowc'
24320d_memmem='$d_memmem'
24321d_memrchr='$d_memrchr'
24322d_mkdir='$d_mkdir'
24323d_mkdtemp='$d_mkdtemp'
24324d_mkfifo='$d_mkfifo'
24325d_mkostemp='$d_mkostemp'
24326d_mkstemp='$d_mkstemp'
24327d_mkstemps='$d_mkstemps'
24328d_mktime64='$d_mktime64'
24329d_mktime='$d_mktime'
24330d_mmap='$d_mmap'
24331d_modfl='$d_modfl'
24332d_modflproto='$d_modflproto'
24333d_mprotect='$d_mprotect'
24334d_msg='$d_msg'
24335d_msg_ctrunc='$d_msg_ctrunc'
24336d_msg_dontroute='$d_msg_dontroute'
24337d_msg_oob='$d_msg_oob'
24338d_msg_peek='$d_msg_peek'
24339d_msg_proxy='$d_msg_proxy'
24340d_msgctl='$d_msgctl'
24341d_msgget='$d_msgget'
24342d_msghdr_s='$d_msghdr_s'
24343d_msgrcv='$d_msgrcv'
24344d_msgsnd='$d_msgsnd'
24345d_msync='$d_msync'
24346d_munmap='$d_munmap'
24347d_mymalloc='$d_mymalloc'
24348d_nan='$d_nan'
24349d_nanosleep='$d_nanosleep'
24350d_ndbm='$d_ndbm'
24351d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
24352d_nearbyint='$d_nearbyint'
24353d_newlocale='$d_newlocale'
24354d_nextafter='$d_nextafter'
24355d_nexttoward='$d_nexttoward'
24356d_nice='$d_nice'
24357d_nl_langinfo='$d_nl_langinfo'
24358d_nv_preserves_uv='$d_nv_preserves_uv'
24359d_nv_zero_is_allbits_zero='$d_nv_zero_is_allbits_zero'
24360d_off64_t='$d_off64_t'
24361d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
24362d_oldpthreads='$d_oldpthreads'
24363d_oldsock='$d_oldsock'
24364d_open3='$d_open3'
24365d_openat='$d_openat'
24366d_pathconf='$d_pathconf'
24367d_pause='$d_pause'
24368d_perl_otherlibdirs='$d_perl_otherlibdirs'
24369d_phostname='$d_phostname'
24370d_pipe2='$d_pipe2'
24371d_pipe='$d_pipe'
24372d_poll='$d_poll'
24373d_portable='$d_portable'
24374d_prctl='$d_prctl'
24375d_prctl_set_name='$d_prctl_set_name'
24376d_printf_format_null='$d_printf_format_null'
24377d_procselfexe='$d_procselfexe'
24378d_pseudofork='$d_pseudofork'
24379d_pthread_atfork='$d_pthread_atfork'
24380d_pthread_attr_setscope='$d_pthread_attr_setscope'
24381d_pthread_yield='$d_pthread_yield'
24382d_ptrdiff_t='$d_ptrdiff_t'
24383d_pwage='$d_pwage'
24384d_pwchange='$d_pwchange'
24385d_pwclass='$d_pwclass'
24386d_pwcomment='$d_pwcomment'
24387d_pwexpire='$d_pwexpire'
24388d_pwgecos='$d_pwgecos'
24389d_pwpasswd='$d_pwpasswd'
24390d_pwquota='$d_pwquota'
24391d_qgcvt='$d_qgcvt'
24392d_quad='$d_quad'
24393d_querylocale='$d_querylocale'
24394d_random_r='$d_random_r'
24395d_re_comp='$d_re_comp'
24396d_readdir64_r='$d_readdir64_r'
24397d_readdir='$d_readdir'
24398d_readdir_r='$d_readdir_r'
24399d_readlink='$d_readlink'
24400d_readv='$d_readv'
24401d_recvmsg='$d_recvmsg'
24402d_regcmp='$d_regcmp'
24403d_regcomp='$d_regcomp'
24404d_remainder='$d_remainder'
24405d_remquo='$d_remquo'
24406d_rename='$d_rename'
24407d_renameat='$d_renameat'
24408d_rewinddir='$d_rewinddir'
24409d_rint='$d_rint'
24410d_rmdir='$d_rmdir'
24411d_round='$d_round'
24412d_sbrkproto='$d_sbrkproto'
24413d_scalbn='$d_scalbn'
24414d_scalbnl='$d_scalbnl'
24415d_sched_yield='$d_sched_yield'
24416d_scm_rights='$d_scm_rights'
24417d_seekdir='$d_seekdir'
24418d_select='$d_select'
24419d_sem='$d_sem'
24420d_semctl='$d_semctl'
24421d_semctl_semid_ds='$d_semctl_semid_ds'
24422d_semctl_semun='$d_semctl_semun'
24423d_semget='$d_semget'
24424d_semop='$d_semop'
24425d_sendmsg='$d_sendmsg'
24426d_setegid='$d_setegid'
24427d_seteuid='$d_seteuid'
24428d_setgrent='$d_setgrent'
24429d_setgrent_r='$d_setgrent_r'
24430d_setgrps='$d_setgrps'
24431d_sethent='$d_sethent'
24432d_sethostent_r='$d_sethostent_r'
24433d_setitimer='$d_setitimer'
24434d_setlinebuf='$d_setlinebuf'
24435d_setlocale='$d_setlocale'
24436d_setlocale_accepts_any_locale_name='$d_setlocale_accepts_any_locale_name'
24437d_setlocale_r='$d_setlocale_r'
24438d_setnent='$d_setnent'
24439d_setnetent_r='$d_setnetent_r'
24440d_setpent='$d_setpent'
24441d_setpgid='$d_setpgid'
24442d_setpgrp2='$d_setpgrp2'
24443d_setpgrp='$d_setpgrp'
24444d_setprior='$d_setprior'
24445d_setproctitle='$d_setproctitle'
24446d_setprotoent_r='$d_setprotoent_r'
24447d_setpwent='$d_setpwent'
24448d_setpwent_r='$d_setpwent_r'
24449d_setregid='$d_setregid'
24450d_setresgid='$d_setresgid'
24451d_setresuid='$d_setresuid'
24452d_setreuid='$d_setreuid'
24453d_setrgid='$d_setrgid'
24454d_setruid='$d_setruid'
24455d_setsent='$d_setsent'
24456d_setservent_r='$d_setservent_r'
24457d_setsid='$d_setsid'
24458d_setvbuf='$d_setvbuf'
24459d_shm='$d_shm'
24460d_shmat='$d_shmat'
24461d_shmatprototype='$d_shmatprototype'
24462d_shmctl='$d_shmctl'
24463d_shmdt='$d_shmdt'
24464d_shmget='$d_shmget'
24465d_sigaction='$d_sigaction'
24466d_siginfo_si_addr='$d_siginfo_si_addr'
24467d_siginfo_si_band='$d_siginfo_si_band'
24468d_siginfo_si_errno='$d_siginfo_si_errno'
24469d_siginfo_si_fd='$d_siginfo_si_fd'
24470d_siginfo_si_pid='$d_siginfo_si_pid'
24471d_siginfo_si_status='$d_siginfo_si_status'
24472d_siginfo_si_uid='$d_siginfo_si_uid'
24473d_siginfo_si_value='$d_siginfo_si_value'
24474d_signbit='$d_signbit'
24475d_sigprocmask='$d_sigprocmask'
24476d_sigsetjmp='$d_sigsetjmp'
24477d_sin6_scope_id='$d_sin6_scope_id'
24478d_sitearch='$d_sitearch'
24479d_snprintf='$d_snprintf'
24480d_sockaddr_in6='$d_sockaddr_in6'
24481d_sockaddr_sa_len='$d_sockaddr_sa_len'
24482d_sockatmark='$d_sockatmark'
24483d_sockatmarkproto='$d_sockatmarkproto'
24484d_socket='$d_socket'
24485d_socklen_t='$d_socklen_t'
24486d_sockpair='$d_sockpair'
24487d_socks5_init='$d_socks5_init'
24488d_sqrtl='$d_sqrtl'
24489d_srand48_r='$d_srand48_r'
24490d_srandom_r='$d_srandom_r'
24491d_sresgproto='$d_sresgproto'
24492d_sresuproto='$d_sresuproto'
24493d_stat='$d_stat'
24494d_statblks='$d_statblks'
24495d_statfs_f_flags='$d_statfs_f_flags'
24496d_statfs_s='$d_statfs_s'
24497d_static_inline='$d_static_inline'
24498d_statvfs='$d_statvfs'
24499d_stdio_cnt_lval='$d_stdio_cnt_lval'
24500d_stdio_ptr_lval='$d_stdio_ptr_lval'
24501d_stdio_ptr_lval_nochange_cnt='$d_stdio_ptr_lval_nochange_cnt'
24502d_stdio_ptr_lval_sets_cnt='$d_stdio_ptr_lval_sets_cnt'
24503d_stdio_stream_array='$d_stdio_stream_array'
24504d_stdiobase='$d_stdiobase'
24505d_stdstdio='$d_stdstdio'
24506d_strcoll='$d_strcoll'
24507d_strerror_l='$d_strerror_l'
24508d_strerror_r='$d_strerror_r'
24509d_strftime='$d_strftime'
24510d_strlcat='$d_strlcat'
24511d_strlcpy='$d_strlcpy'
24512d_strnlen='$d_strnlen'
24513d_strtod='$d_strtod'
24514d_strtod_l='$d_strtod_l'
24515d_strtol='$d_strtol'
24516d_strtold='$d_strtold'
24517d_strtold_l='$d_strtold_l'
24518d_strtoll='$d_strtoll'
24519d_strtoq='$d_strtoq'
24520d_strtoul='$d_strtoul'
24521d_strtoull='$d_strtoull'
24522d_strtouq='$d_strtouq'
24523d_strxfrm='$d_strxfrm'
24524d_suidsafe='$d_suidsafe'
24525d_symlink='$d_symlink'
24526d_syscall='$d_syscall'
24527d_syscallproto='$d_syscallproto'
24528d_sysconf='$d_sysconf'
24529d_sysernlst='$d_sysernlst'
24530d_syserrlst='$d_syserrlst'
24531d_system='$d_system'
24532d_tcgetpgrp='$d_tcgetpgrp'
24533d_tcsetpgrp='$d_tcsetpgrp'
24534d_telldir='$d_telldir'
24535d_telldirproto='$d_telldirproto'
24536d_tgamma='$d_tgamma'
24537d_thread_safe_nl_langinfo_l='$d_thread_safe_nl_langinfo_l'
24538d_time='$d_time'
24539d_timegm='$d_timegm'
24540d_times='$d_times'
24541d_tm_tm_gmtoff='$d_tm_tm_gmtoff'
24542d_tm_tm_zone='$d_tm_tm_zone'
24543d_tmpnam_r='$d_tmpnam_r'
24544d_towlower='$d_towlower'
24545d_towupper='$d_towupper'
24546d_trunc='$d_trunc'
24547d_truncate='$d_truncate'
24548d_truncl='$d_truncl'
24549d_ttyname_r='$d_ttyname_r'
24550d_tzname='$d_tzname'
24551d_u32align='$d_u32align'
24552d_ualarm='$d_ualarm'
24553d_umask='$d_umask'
24554d_uname='$d_uname'
24555d_union_semun='$d_union_semun'
24556d_unlinkat='$d_unlinkat'
24557d_unordered='$d_unordered'
24558d_unsetenv='$d_unsetenv'
24559d_uselocale='$d_uselocale'
24560d_usleep='$d_usleep'
24561d_usleepproto='$d_usleepproto'
24562d_ustat='$d_ustat'
24563d_vendorarch='$d_vendorarch'
24564d_vendorbin='$d_vendorbin'
24565d_vendorlib='$d_vendorlib'
24566d_vendorscript='$d_vendorscript'
24567d_vfork='$d_vfork'
24568d_void_closedir='$d_void_closedir'
24569d_voidsig='$d_voidsig'
24570d_voidtty='$d_voidtty'
24571d_vsnprintf='$d_vsnprintf'
24572d_wait4='$d_wait4'
24573d_waitpid='$d_waitpid'
24574d_wcscmp='$d_wcscmp'
24575d_wcstombs='$d_wcstombs'
24576d_wcsxfrm='$d_wcsxfrm'
24577d_wctomb='$d_wctomb'
24578d_writev='$d_writev'
24579d_xenix='$d_xenix'
24580date='$date'
24581db_hashtype='$db_hashtype'
24582db_prefixtype='$db_prefixtype'
24583db_version_major='$db_version_major'
24584db_version_minor='$db_version_minor'
24585db_version_patch='$db_version_patch'
24586default_inc_excludes_dot='$default_inc_excludes_dot'
24587direntrytype='$direntrytype'
24588dlext='$dlext'
24589dlsrc='$dlsrc'
24590doubleinfbytes='$doubleinfbytes'
24591doublekind='$doublekind'
24592doublemantbits='$doublemantbits'
24593doublenanbytes='$doublenanbytes'
24594doublesize='$doublesize'
24595drand01='$drand01'
24596drand48_r_proto='$drand48_r_proto'
24597dtrace='$dtrace'
24598dtraceobject='$dtraceobject'
24599dtracexnolibs='$dtracexnolibs'
24600dynamic_ext='$dynamic_ext'
24601eagain='$eagain'
24602ebcdic='$ebcdic'
24603echo='$echo'
24604egrep='$egrep'
24605emacs='$emacs'
24606endgrent_r_proto='$endgrent_r_proto'
24607endhostent_r_proto='$endhostent_r_proto'
24608endnetent_r_proto='$endnetent_r_proto'
24609endprotoent_r_proto='$endprotoent_r_proto'
24610endpwent_r_proto='$endpwent_r_proto'
24611endservent_r_proto='$endservent_r_proto'
24612eunicefix='$eunicefix'
24613exe_ext='$exe_ext'
24614expr='$expr'
24615extensions='$extensions'
24616extern_C='$extern_C'
24617extras='$extras'
24618fflushNULL='$fflushNULL'
24619fflushall='$fflushall'
24620find='$find'
24621firstmakefile='$firstmakefile'
24622flex='$flex'
24623fpossize='$fpossize'
24624fpostype='$fpostype'
24625freetype='$freetype'
24626from='$from'
24627full_ar='$full_ar'
24628full_csh='$full_csh'
24629full_sed='$full_sed'
24630gccansipedantic='$gccansipedantic'
24631gccosandvers='$gccosandvers'
24632gccversion='$gccversion'
24633getgrent_r_proto='$getgrent_r_proto'
24634getgrgid_r_proto='$getgrgid_r_proto'
24635getgrnam_r_proto='$getgrnam_r_proto'
24636gethostbyaddr_r_proto='$gethostbyaddr_r_proto'
24637gethostbyname_r_proto='$gethostbyname_r_proto'
24638gethostent_r_proto='$gethostent_r_proto'
24639getlogin_r_proto='$getlogin_r_proto'
24640getnetbyaddr_r_proto='$getnetbyaddr_r_proto'
24641getnetbyname_r_proto='$getnetbyname_r_proto'
24642getnetent_r_proto='$getnetent_r_proto'
24643getprotobyname_r_proto='$getprotobyname_r_proto'
24644getprotobynumber_r_proto='$getprotobynumber_r_proto'
24645getprotoent_r_proto='$getprotoent_r_proto'
24646getpwent_r_proto='$getpwent_r_proto'
24647getpwnam_r_proto='$getpwnam_r_proto'
24648getpwuid_r_proto='$getpwuid_r_proto'
24649getservbyname_r_proto='$getservbyname_r_proto'
24650getservbyport_r_proto='$getservbyport_r_proto'
24651getservent_r_proto='$getservent_r_proto'
24652getspnam_r_proto='$getspnam_r_proto'
24653gidformat='$gidformat'
24654gidsign='$gidsign'
24655gidsize='$gidsize'
24656gidtype='$gidtype'
24657glibpth='$glibpth'
24658gmake='$gmake'
24659gmtime_r_proto='$gmtime_r_proto'
24660gnulibc_version='$gnulibc_version'
24661grep='$grep'
24662groupcat='$groupcat'
24663groupstype='$groupstype'
24664gzip='$gzip'
24665h_fcntl='$h_fcntl'
24666h_sysfile='$h_sysfile'
24667hint='$hint'
24668hostcat='$hostcat'
24669hostgenerate='$hostgenerate'
24670hostosname='$hostosname'
24671hostperl='$hostperl'
24672html1dir='$html1dir'
24673html1direxp='$html1direxp'
24674html3dir='$html3dir'
24675html3direxp='$html3direxp'
24676i16size='$i16size'
24677i16type='$i16type'
24678i32size='$i32size'
24679i32type='$i32type'
24680i64size='$i64size'
24681i64type='$i64type'
24682i8size='$i8size'
24683i8type='$i8type'
24684i_arpainet='$i_arpainet'
24685i_bfd='$i_bfd'
24686i_bsdioctl='$i_bsdioctl'
24687i_crypt='$i_crypt'
24688i_db='$i_db'
24689i_dbm='$i_dbm'
24690i_dirent='$i_dirent'
24691i_dlfcn='$i_dlfcn'
24692i_execinfo='$i_execinfo'
24693i_fcntl='$i_fcntl'
24694i_fenv='$i_fenv'
24695i_fp='$i_fp'
24696i_fp_class='$i_fp_class'
24697i_gdbm='$i_gdbm'
24698i_gdbm_ndbm='$i_gdbm_ndbm'
24699i_gdbmndbm='$i_gdbmndbm'
24700i_grp='$i_grp'
24701i_ieeefp='$i_ieeefp'
24702i_inttypes='$i_inttypes'
24703i_langinfo='$i_langinfo'
24704i_libutil='$i_libutil'
24705i_locale='$i_locale'
24706i_machcthr='$i_machcthr'
24707i_malloc='$i_malloc'
24708i_mallocmalloc='$i_mallocmalloc'
24709i_mntent='$i_mntent'
24710i_ndbm='$i_ndbm'
24711i_netdb='$i_netdb'
24712i_neterrno='$i_neterrno'
24713i_netinettcp='$i_netinettcp'
24714i_niin='$i_niin'
24715i_poll='$i_poll'
24716i_prot='$i_prot'
24717i_pthread='$i_pthread'
24718i_pwd='$i_pwd'
24719i_quadmath='$i_quadmath'
24720i_rpcsvcdbm='$i_rpcsvcdbm'
24721i_sgtty='$i_sgtty'
24722i_shadow='$i_shadow'
24723i_socks='$i_socks'
24724i_stdbool='$i_stdbool'
24725i_stdint='$i_stdint'
24726i_stdlib='$i_stdlib'
24727i_sunmath='$i_sunmath'
24728i_sysaccess='$i_sysaccess'
24729i_sysdir='$i_sysdir'
24730i_sysfile='$i_sysfile'
24731i_sysfilio='$i_sysfilio'
24732i_sysin='$i_sysin'
24733i_sysioctl='$i_sysioctl'
24734i_syslog='$i_syslog'
24735i_sysmman='$i_sysmman'
24736i_sysmode='$i_sysmode'
24737i_sysmount='$i_sysmount'
24738i_sysndir='$i_sysndir'
24739i_sysparam='$i_sysparam'
24740i_syspoll='$i_syspoll'
24741i_sysresrc='$i_sysresrc'
24742i_syssecrt='$i_syssecrt'
24743i_sysselct='$i_sysselct'
24744i_syssockio='$i_syssockio'
24745i_sysstat='$i_sysstat'
24746i_sysstatfs='$i_sysstatfs'
24747i_sysstatvfs='$i_sysstatvfs'
24748i_systime='$i_systime'
24749i_systimek='$i_systimek'
24750i_systimes='$i_systimes'
24751i_systypes='$i_systypes'
24752i_sysuio='$i_sysuio'
24753i_sysun='$i_sysun'
24754i_sysutsname='$i_sysutsname'
24755i_sysvfs='$i_sysvfs'
24756i_syswait='$i_syswait'
24757i_termio='$i_termio'
24758i_termios='$i_termios'
24759i_time='$i_time'
24760i_unistd='$i_unistd'
24761i_ustat='$i_ustat'
24762i_utime='$i_utime'
24763i_vfork='$i_vfork'
24764i_wchar='$i_wchar'
24765i_wctype='$i_wctype'
24766i_xlocale='$i_xlocale'
24767ignore_versioned_solibs='$ignore_versioned_solibs'
24768inc_version_list='$inc_version_list'
24769inc_version_list_init='$inc_version_list_init'
24770incpath='$incpath'
24771incpth='$incpth'
24772inews='$inews'
24773initialinstalllocation='$initialinstalllocation'
24774installarchlib='$installarchlib'
24775installbin='$installbin'
24776installhtml1dir='$installhtml1dir'
24777installhtml3dir='$installhtml3dir'
24778installman1dir='$installman1dir'
24779installman3dir='$installman3dir'
24780installprefix='$installprefix'
24781installprefixexp='$installprefixexp'
24782installprivlib='$installprivlib'
24783installscript='$installscript'
24784installsitearch='$installsitearch'
24785installsitebin='$installsitebin'
24786installsitehtml1dir='$installsitehtml1dir'
24787installsitehtml3dir='$installsitehtml3dir'
24788installsitelib='$installsitelib'
24789installsiteman1dir='$installsiteman1dir'
24790installsiteman3dir='$installsiteman3dir'
24791installsitescript='$installsitescript'
24792installstyle='$installstyle'
24793installusrbinperl='$installusrbinperl'
24794installvendorarch='$installvendorarch'
24795installvendorbin='$installvendorbin'
24796installvendorhtml1dir='$installvendorhtml1dir'
24797installvendorhtml3dir='$installvendorhtml3dir'
24798installvendorlib='$installvendorlib'
24799installvendorman1dir='$installvendorman1dir'
24800installvendorman3dir='$installvendorman3dir'
24801installvendorscript='$installvendorscript'
24802intsize='$intsize'
24803issymlink='$issymlink'
24804ivdformat='$ivdformat'
24805ivsize='$ivsize'
24806ivtype='$ivtype'
24807known_extensions='$known_extensions'
24808ksh='$ksh'
24809ld='$ld'
24810ld_can_script='$ld_can_script'
24811lddlflags='$lddlflags'
24812ldflags='$ldflags'
24813ldflags_uselargefiles='$ldflags_uselargefiles'
24814ldlibpthname='$ldlibpthname'
24815less='$less'
24816lib_ext='$lib_ext'
24817libc='$libc'
24818libperl='$libperl'
24819libpth='$libpth'
24820libs='$libs'
24821libsdirs='$libsdirs'
24822libsfiles='$libsfiles'
24823libsfound='$libsfound'
24824libspath='$libspath'
24825libswanted='$libswanted'
24826libswanted_uselargefiles='$libswanted_uselargefiles'
24827line='$line'
24828lint='$lint'
24829lkflags='$lkflags'
24830ln='$ln'
24831lns='$lns'
24832localtime_r_proto='$localtime_r_proto'
24833locincpth='$locincpth'
24834loclibpth='$loclibpth'
24835longdblinfbytes='$longdblinfbytes'
24836longdblkind='$longdblkind'
24837longdblmantbits='$longdblmantbits'
24838longdblnanbytes='$longdblnanbytes'
24839longdblsize='$longdblsize'
24840longlongsize='$longlongsize'
24841longsize='$longsize'
24842lp='$lp'
24843lpr='$lpr'
24844ls='$ls'
24845lseeksize='$lseeksize'
24846lseektype='$lseektype'
24847mail='$mail'
24848mailx='$mailx'
24849make='$make'
24850make_set_make='$make_set_make'
24851mallocobj='$mallocobj'
24852mallocsrc='$mallocsrc'
24853malloctype='$malloctype'
24854man1dir='$man1dir'
24855man1direxp='$man1direxp'
24856man1ext='$man1ext'
24857man3dir='$man3dir'
24858man3direxp='$man3direxp'
24859man3ext='$man3ext'
24860mips_type='$mips_type'
24861mistrustnm='$mistrustnm'
24862mkdir='$mkdir'
24863mmaptype='$mmaptype'
24864modetype='$modetype'
24865more='$more'
24866multiarch='$multiarch'
24867mv='$mv'
24868myarchname='$myarchname'
24869mydomain='$mydomain'
24870myhostname='$myhostname'
24871myuname='$myuname'
24872n='$n'
24873need_va_copy='$need_va_copy'
24874netdb_hlen_type='$netdb_hlen_type'
24875netdb_host_type='$netdb_host_type'
24876netdb_name_type='$netdb_name_type'
24877netdb_net_type='$netdb_net_type'
24878nm='$nm'
24879nm_opt='$nm_opt'
24880nm_so_opt='$nm_so_opt'
24881nonxs_ext='$nonxs_ext'
24882nroff='$nroff'
24883nvEUformat='$nvEUformat'
24884nvFUformat='$nvFUformat'
24885nvGUformat='$nvGUformat'
24886nv_overflows_integers_at='$nv_overflows_integers_at'
24887nv_preserves_uv_bits='$nv_preserves_uv_bits'
24888nveformat='$nveformat'
24889nvfformat='$nvfformat'
24890nvgformat='$nvgformat'
24891nvmantbits='$nvmantbits'
24892nvsize='$nvsize'
24893nvtype='$nvtype'
24894o_nonblock='$o_nonblock'
24895obj_ext='$obj_ext'
24896old_pthread_create_joinable='$old_pthread_create_joinable'
24897optimize='$optimize'
24898orderlib='$orderlib'
24899osname='$osname'
24900osvers='$osvers'
24901otherlibdirs='$otherlibdirs'
24902package='$package'
24903pager='$pager'
24904passcat='$passcat'
24905patchlevel='$patchlevel'
24906path_sep='$path_sep'
24907perl5='$perl5'
24908perl='$perl'
24909perl_patchlevel='$perl_patchlevel'
24910perl_static_inline='$perl_static_inline'
24911perladmin='$perladmin'
24912perllibs='$perllibs'
24913perlpath='$perlpath'
24914pg='$pg'
24915phostname='$phostname'
24916pidtype='$pidtype'
24917plibpth='$plibpth'
24918pmake='$pmake'
24919pr='$pr'
24920prefix='$prefix'
24921prefixexp='$prefixexp'
24922privlib='$privlib'
24923privlibexp='$privlibexp'
24924procselfexe='$procselfexe'
24925ptrsize='$ptrsize'
24926quadkind='$quadkind'
24927quadtype='$quadtype'
24928randbits='$randbits'
24929randfunc='$randfunc'
24930random_r_proto='$random_r_proto'
24931randseedtype='$randseedtype'
24932ranlib='$ranlib'
24933rd_nodata='$rd_nodata'
24934readdir64_r_proto='$readdir64_r_proto'
24935readdir_r_proto='$readdir_r_proto'
24936revision='$revision'
24937rm='$rm'
24938rm_try='$rm_try'
24939rmail='$rmail'
24940run='$run'
24941runnm='$runnm'
24942sGMTIME_max='$sGMTIME_max'
24943sGMTIME_min='$sGMTIME_min'
24944sLOCALTIME_max='$sLOCALTIME_max'
24945sLOCALTIME_min='$sLOCALTIME_min'
24946sPRIEUldbl='$sPRIEUldbl'
24947sPRIFUldbl='$sPRIFUldbl'
24948sPRIGUldbl='$sPRIGUldbl'
24949sPRIXU64='$sPRIXU64'
24950sPRId64='$sPRId64'
24951sPRIeldbl='$sPRIeldbl'
24952sPRIfldbl='$sPRIfldbl'
24953sPRIgldbl='$sPRIgldbl'
24954sPRIi64='$sPRIi64'
24955sPRIo64='$sPRIo64'
24956sPRIu64='$sPRIu64'
24957sPRIx64='$sPRIx64'
24958sSCNfldbl='$sSCNfldbl'
24959sched_yield='$sched_yield'
24960scriptdir='$scriptdir'
24961scriptdirexp='$scriptdirexp'
24962sed='$sed'
24963seedfunc='$seedfunc'
24964selectminbits='$selectminbits'
24965selecttype='$selecttype'
24966sendmail='$sendmail'
24967setgrent_r_proto='$setgrent_r_proto'
24968sethostent_r_proto='$sethostent_r_proto'
24969setlocale_r_proto='$setlocale_r_proto'
24970setnetent_r_proto='$setnetent_r_proto'
24971setprotoent_r_proto='$setprotoent_r_proto'
24972setpwent_r_proto='$setpwent_r_proto'
24973setservent_r_proto='$setservent_r_proto'
24974sh='$sh'
24975shar='$shar'
24976sharpbang='$sharpbang'
24977shmattype='$shmattype'
24978shortsize='$shortsize'
24979shrpenv='$shrpenv'
24980shsharp='$shsharp'
24981sig_count='$sig_count'
24982sig_name='$sig_name'
24983sig_name_init='$sig_name_init'
24984sig_num='$sig_num'
24985sig_num_init='$sig_num_init'
24986sig_size='$sig_size'
24987signal_t='$signal_t'
24988sitearch='$sitearch'
24989sitearchexp='$sitearchexp'
24990sitebin='$sitebin'
24991sitebinexp='$sitebinexp'
24992sitehtml1dir='$sitehtml1dir'
24993sitehtml1direxp='$sitehtml1direxp'
24994sitehtml3dir='$sitehtml3dir'
24995sitehtml3direxp='$sitehtml3direxp'
24996sitelib='$sitelib'
24997sitelib_stem='$sitelib_stem'
24998sitelibexp='$sitelibexp'
24999siteman1dir='$siteman1dir'
25000siteman1direxp='$siteman1direxp'
25001siteman3dir='$siteman3dir'
25002siteman3direxp='$siteman3direxp'
25003siteprefix='$siteprefix'
25004siteprefixexp='$siteprefixexp'
25005sitescript='$sitescript'
25006sitescriptexp='$sitescriptexp'
25007sizesize='$sizesize'
25008sizetype='$sizetype'
25009sleep='$sleep'
25010smail='$smail'
25011so='$so'
25012sockethdr='$sockethdr'
25013socketlib='$socketlib'
25014socksizetype='$socksizetype'
25015sort='$sort'
25016spackage='$spackage'
25017spitshell='$spitshell'
25018srand48_r_proto='$srand48_r_proto'
25019srandom_r_proto='$srandom_r_proto'
25020src='$src'
25021ssizetype='$ssizetype'
25022st_ino_sign='$st_ino_sign'
25023st_ino_size='$st_ino_size'
25024startperl='$startperl'
25025startsh='$startsh'
25026static_ext='$static_ext'
25027stdchar='$stdchar'
25028stdio_base='$stdio_base'
25029stdio_bufsiz='$stdio_bufsiz'
25030stdio_cnt='$stdio_cnt'
25031stdio_filbuf='$stdio_filbuf'
25032stdio_ptr='$stdio_ptr'
25033stdio_stream_array='$stdio_stream_array'
25034strerror_r_proto='$strerror_r_proto'
25035submit='$submit'
25036subversion='$subversion'
25037sysman='$sysman'
25038sysroot='$sysroot'
25039tail='$tail'
25040tar='$tar'
25041targetarch='$targetarch'
25042targetdir='$targetdir'
25043targetenv='$targetenv'
25044targethost='$targethost'
25045targetmkdir='$targetmkdir'
25046targetport='$targetport'
25047targetsh='$targetsh'
25048tbl='$tbl'
25049tee='$tee'
25050test='$test'
25051timeincl='$timeincl'
25052timetype='$timetype'
25053tmpnam_r_proto='$tmpnam_r_proto'
25054to='$to'
25055touch='$touch'
25056tr='$tr'
25057trnl='$trnl'
25058troff='$troff'
25059ttyname_r_proto='$ttyname_r_proto'
25060u16size='$u16size'
25061u16type='$u16type'
25062u32size='$u32size'
25063u32type='$u32type'
25064u64size='$u64size'
25065u64type='$u64type'
25066u8size='$u8size'
25067u8type='$u8type'
25068uidformat='$uidformat'
25069uidsign='$uidsign'
25070uidsize='$uidsize'
25071uidtype='$uidtype'
25072uname='$uname'
25073uniq='$uniq'
25074uquadtype='$uquadtype'
25075use5005threads='$use5005threads'
25076use64bitall='$use64bitall'
25077use64bitint='$use64bitint'
25078usecbacktrace='$usecbacktrace'
25079usecrosscompile='$usecrosscompile'
25080usedevel='$usedevel'
25081usedl='$usedl'
25082usedtrace='$usedtrace'
25083usefaststdio='$usefaststdio'
25084useithreads='$useithreads'
25085usekernprocpathname='$usekernprocpathname'
25086uselanginfo='$uselanginfo'
25087uselargefiles='$uselargefiles'
25088uselongdouble='$uselongdouble'
25089usemallocwrap='$usemallocwrap'
25090usemorebits='$usemorebits'
25091usemultiplicity='$usemultiplicity'
25092usemymalloc='$usemymalloc'
25093usenm='$usenm'
25094usensgetexecutablepath='$usensgetexecutablepath'
25095useopcode='$useopcode'
25096useperlio='$useperlio'
25097useposix='$useposix'
25098usequadmath='$usequadmath'
25099usereentrant='$usereentrant'
25100userelocatableinc='$userelocatableinc'
25101useshrplib='$useshrplib'
25102usesitecustomize='$usesitecustomize'
25103usesocks='$usesocks'
25104usethreads='$usethreads'
25105usevendorprefix='$usevendorprefix'
25106useversionedarchname='$useversionedarchname'
25107usevfork='$usevfork'
25108usrinc='$usrinc'
25109uuname='$uuname'
25110uvXUformat='$uvXUformat'
25111uvoformat='$uvoformat'
25112uvsize='$uvsize'
25113uvtype='$uvtype'
25114uvuformat='$uvuformat'
25115uvxformat='$uvxformat'
25116vendorarch='$vendorarch'
25117vendorarchexp='$vendorarchexp'
25118vendorbin='$vendorbin'
25119vendorbinexp='$vendorbinexp'
25120vendorhtml1dir='$vendorhtml1dir'
25121vendorhtml1direxp='$vendorhtml1direxp'
25122vendorhtml3dir='$vendorhtml3dir'
25123vendorhtml3direxp='$vendorhtml3direxp'
25124vendorlib='$vendorlib'
25125vendorlib_stem='$vendorlib_stem'
25126vendorlibexp='$vendorlibexp'
25127vendorman1dir='$vendorman1dir'
25128vendorman1direxp='$vendorman1direxp'
25129vendorman3dir='$vendorman3dir'
25130vendorman3direxp='$vendorman3direxp'
25131vendorprefix='$vendorprefix'
25132vendorprefixexp='$vendorprefixexp'
25133vendorscript='$vendorscript'
25134vendorscriptexp='$vendorscriptexp'
25135version='$version'
25136version_patchlevel_string='$version_patchlevel_string'
25137versiononly='$versiononly'
25138vi='$vi'
25139xlibpth='$xlibpth'
25140yacc='$yacc'
25141yaccflags='$yaccflags'
25142zcat='$zcat'
25143zip='$zip'
25144EOT
25145
25146: add special variables
25147$test -f $src/patchlevel.h && \
25148awk '/^#define[ 	]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
25149echo "PERL_PATCHLEVEL='$perl_patchlevel'" >>config.sh
25150echo "PERL_CONFIG_SH=true" >>config.sh
25151
25152: propagate old symbols
25153if $test -f UU/config.sh; then
25154	<UU/config.sh $sort | $uniq >UU/oldconfig.sh
25155	$sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' \
25156		config.sh config.sh UU/oldconfig.sh |\
25157		$sort | $uniq -u >UU/oldsyms
25158	set X `$cat UU/oldsyms`
25159	shift
25160	case $# in
25161	0) ;;
25162	*)
25163		$cat <<EOM
25164Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
25165EOM
25166		echo ": Variables propagated from previous config.sh file." >>config.sh
25167		for sym in `$cat UU/oldsyms`; do
25168			echo "    Propagating $hint variable "'$'"$sym..."
25169			eval 'tmp="$'"${sym}"'"'
25170			echo "$tmp" | \
25171				sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
25172		done
25173		;;
25174	esac
25175fi
25176
25177: preserve RCS keywords in files with variable substitution, grrr
25178Id='$Id'
25179
25180: Finish up by extracting the .SH files
25181case "$alldone" in
25182exit)
25183	echo "Stopping at your request, leaving temporary files around."
25184	exit 0
25185	;;
25186cont)
25187	;;
25188'')
25189	dflt=''
25190	nostick=true
25191	$cat <<EOM
25192
25193If you'd like to make any changes to the config.sh file before I begin
25194to configure things, do it as a shell escape now (e.g. !vi config.sh).
25195
25196EOM
25197	rp="Press return or use a shell escape to edit config.sh:"
25198	. UU/myread
25199	nostick=''
25200	case "$ans" in
25201	'') ;;
25202	*) : in case they cannot read
25203		sh 1>&4 -c "$ans";;
25204	esac
25205	;;
25206esac
25207
25208: if this fails, just run all the .SH files by hand
25209. ./config.sh
25210
25211echo " "
25212exec 1>&4
25213pwd=`pwd`
25214. ./UU/extract
25215cd "$pwd"
25216
25217if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
25218	dflt=y
25219	case "$silent" in
25220	true) ;;
25221	*)
25222		$cat <<EOM
25223
25224Now you need to generate make dependencies by running "$make depend".
25225You might prefer to run it in background: "$make depend > makedepend.out &"
25226It can take a while, so you might not want to run it right now.
25227
25228EOM
25229		;;
25230	esac
25231	rp="Run $make depend now?"
25232	. UU/myread
25233	case "$ans" in
25234	y*)
25235		$make depend && echo "Now you must run '$make'."
25236		;;
25237	*)
25238		echo "You must run '$make depend' then '$make'."
25239		;;
25240	esac
25241elif test -f [Mm]akefile; then
25242	echo " "
25243	echo "Now you must run a $make."
25244else
25245	echo "Configure done."
25246fi
25247
25248if $test -f Policy.sh; then
25249    $cat <<EOM
25250
25251If you compile $package on a different machine or from a different object
25252directory, copy the Policy.sh file from this object directory to the
25253new one before you run Configure -- this will help you with most of
25254the policy defaults.
25255
25256EOM
25257fi
25258if $test -f UU/config.msg; then
25259    echo "Hmm.  I also noted the following information while running:"
25260    echo " "
25261    $cat UU/config.msg >&4
25262fi
25263$rm -f kit*isdone ark*isdone
25264$rm -rf UU
25265
25266: End of Configure
25267
25268