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/Perl/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 from https://github.com/Perl/metaconfig
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=''
368compiler_warning=''
369contains=''
370cpp_stuff=''
371cpplast=''
372cppminus=''
373cpprun=''
374cppstdin=''
375d__fwalk=''
376d_accept4=''
377d_access=''
378d_accessx=''
379d_acosh=''
380d_aintl=''
381d_alarm=''
382asctime_r_proto=''
383d_asctime_r=''
384d_asinh=''
385d_atanh=''
386d_attribute_always_inline=''
387d_attribute_deprecated=''
388d_attribute_format=''
389d_attribute_malloc=''
390d_attribute_nonnull=''
391d_attribute_noreturn=''
392d_attribute_pure=''
393d_attribute_unused=''
394d_attribute_visibility=''
395d_attribute_warn_unused_result=''
396d_printf_format_null=''
397d_backtrace=''
398d_non_int_bitfields=''
399d_builtin_choose_expr=''
400d_builtin_expect=''
401d_builtin_add_overflow=''
402d_builtin_mul_overflow=''
403d_builtin_sub_overflow=''
404d_c99_variadic_macros=''
405d_casti32=''
406castflags=''
407d_castneg=''
408d_cbrt=''
409d_chown=''
410d_chroot=''
411d_chsize=''
412d_class=''
413d_clearenv=''
414d_closedir=''
415d_void_closedir=''
416d_cmsghdr_s=''
417d_copysign=''
418d_copysignl=''
419d_cplusplus=''
420cryptlib=''
421d_crypt=''
422crypt_r_proto=''
423d_crypt_r=''
424d_csh=''
425full_csh=''
426d_ctermid=''
427ctermid_r_proto=''
428d_ctermid_r=''
429ctime_r_proto=''
430d_ctime_r=''
431d_cuserid=''
432d_dbminitproto=''
433d_difftime=''
434d_dir_dd_fd=''
435d_dirfd=''
436d_dladdr=''
437d_dlerror=''
438d_dlopen=''
439d_dlsymun=''
440d_dosuid=''
441d_suidsafe=''
442d_drand48_r=''
443drand48_r_proto=''
444d_drand48proto=''
445d_dup2=''
446d_dup3=''
447d_eaccess=''
448d_endgrent=''
449d_endgrent_r=''
450endgrent_r_proto=''
451d_endhent=''
452d_endhostent_r=''
453endhostent_r_proto=''
454d_endnent=''
455d_endnetent_r=''
456endnetent_r_proto=''
457d_endpent=''
458d_endprotoent_r=''
459endprotoent_r_proto=''
460d_endpwent=''
461d_endpwent_r=''
462endpwent_r_proto=''
463d_endsent=''
464d_endservent_r=''
465endservent_r_proto=''
466d_erf=''
467d_erfc=''
468d_exp2=''
469d_expm1=''
470d_faststdio=''
471d_fchdir=''
472d_fchmod=''
473d_fchown=''
474d_fcntl=''
475d_fcntl_can_lock=''
476d_fd_macros=''
477d_fd_set=''
478d_fds_bits=''
479d_fdclose=''
480d_fdim=''
481d_fegetround=''
482d_ffs=''
483d_ffsl=''
484d_fgetpos=''
485d_finite=''
486d_finitel=''
487d_flexfnam=''
488d_flock=''
489d_flockproto=''
490d_fma=''
491d_fmax=''
492d_fmin=''
493d_fork=''
494d_fp_class=''
495d_fp_classl=''
496d_fpclass=''
497d_fp_classify=''
498d_fpclassify=''
499d_fpclassl=''
500d_fpgetround=''
501d_fpos64_t=''
502d_frexpl=''
503d_fs_data_s=''
504d_fchmodat=''
505d_linkat=''
506d_openat=''
507d_renameat=''
508d_unlinkat=''
509d_fseeko=''
510d_fsetpos=''
511d_fstatfs=''
512d_fsync=''
513d_ftello=''
514d_ftime=''
515d_gettimeod=''
516d_futimes=''
517d_gai_strerror=''
518d_Gconvert=''
519d_getaddrinfo=''
520d_getcwd=''
521d_getenv_preserves_other_thread=''
522d_getespwnam=''
523d_getfsstat=''
524d_getgrent=''
525d_getgrent_r=''
526getgrent_r_proto=''
527d_getgrgid_r=''
528getgrgid_r_proto=''
529d_getgrnam_r=''
530getgrnam_r_proto=''
531d_getgrps=''
532d_gethbyaddr=''
533d_gethbyname=''
534d_gethent=''
535aphostname=''
536d_gethname=''
537d_phostname=''
538d_uname=''
539d_gethostbyaddr_r=''
540gethostbyaddr_r_proto=''
541d_gethostbyname_r=''
542gethostbyname_r_proto=''
543d_gethostent_r=''
544gethostent_r_proto=''
545d_gethostprotos=''
546d_getitimer=''
547d_getlogin=''
548d_getlogin_r=''
549getlogin_r_proto=''
550d_getmnt=''
551d_getmntent=''
552d_getnameinfo=''
553d_getnbyaddr=''
554d_getnbyname=''
555d_getnent=''
556d_getnetbyaddr_r=''
557getnetbyaddr_r_proto=''
558d_getnetbyname_r=''
559getnetbyname_r_proto=''
560d_getnetent_r=''
561getnetent_r_proto=''
562d_getnetprotos=''
563d_getpagsz=''
564d_getpent=''
565d_getpgid=''
566d_getpgrp2=''
567d_bsdgetpgrp=''
568d_getpgrp=''
569d_getppid=''
570d_getprior=''
571d_getpbyname=''
572d_getpbynumber=''
573d_getprotobyname_r=''
574getprotobyname_r_proto=''
575d_getprotobynumber_r=''
576getprotobynumber_r_proto=''
577d_getprotoent_r=''
578getprotoent_r_proto=''
579d_getprotoprotos=''
580d_getprpwnam=''
581d_getpwent=''
582d_getpwent_r=''
583getpwent_r_proto=''
584d_getpwnam_r=''
585getpwnam_r_proto=''
586d_getpwuid_r=''
587getpwuid_r_proto=''
588d_getsent=''
589d_getservbyname_r=''
590getservbyname_r_proto=''
591d_getservbyport_r=''
592getservbyport_r_proto=''
593d_getservent_r=''
594getservent_r_proto=''
595d_getservprotos=''
596d_getspnam=''
597d_getspnam_r=''
598getspnam_r_proto=''
599d_getsbyname=''
600d_getsbyport=''
601d_gmtime_r=''
602gmtime_r_proto=''
603d_gnulibc=''
604gnulibc_version=''
605d_hasmntopt=''
606d_htonl=''
607d_hypot=''
608d_ilogb=''
609d_ilogbl=''
610d_inetaton=''
611d_inetntop=''
612d_inetpton=''
613d_int64_t=''
614d_isascii=''
615d_isblank=''
616d_isfinite=''
617d_isfinitel=''
618d_isinf=''
619d_isinfl=''
620d_isless=''
621d_isnan=''
622d_isnanl=''
623d_isnormal=''
624d_j0=''
625d_j0l=''
626d_killpg=''
627d_lc_monetary_2008=''
628d_lchown=''
629d_ldbl_dig=''
630d_lgamma=''
631d_lgamma_r=''
632d_libm_lib_version=''
633d_link=''
634d_llrint=''
635d_llrintl=''
636d_llround=''
637d_llroundl=''
638d_localeconv_l=''
639d_localtime_r=''
640d_localtime_r_needs_tzset=''
641localtime_r_proto=''
642d_locconv=''
643d_lockf=''
644d_log1p=''
645d_log2=''
646d_logb=''
647d_ldexpl=''
648d_long_double_style_ieee=''
649d_long_double_style_ieee_doubledouble=''
650d_long_double_style_ieee_extended=''
651d_long_double_style_ieee_std=''
652d_long_double_style_vax=''
653d_longdbl=''
654longdblkind=''
655longdblsize=''
656d_longlong=''
657longlongsize=''
658d_lrint=''
659d_lrintl=''
660d_lround=''
661d_lroundl=''
662d_lseekproto=''
663d_lstat=''
664d_madvise=''
665d_malloc_good_size=''
666d_malloc_size=''
667d_malloc_usable_size=''
668d_mblen=''
669d_mbrlen=''
670d_mbrtowc=''
671d_mbstowcs=''
672d_mbtowc=''
673d_memmem=''
674d_memrchr=''
675d_mkdir=''
676d_mkdtemp=''
677d_mkfifo=''
678d_mkostemp=''
679d_mkstemp=''
680d_mkstemps=''
681d_mktime=''
682d_mmap=''
683mmaptype=''
684d_modfl=''
685d_modflproto=''
686d_mprotect=''
687d_msg=''
688d_msgctl=''
689d_msgget=''
690d_msghdr_s=''
691d_msgrcv=''
692d_msgsnd=''
693d_msync=''
694d_munmap=''
695d_nan=''
696d_nanosleep=''
697d_nearbyint=''
698d_duplocale=''
699d_freelocale=''
700d_newlocale=''
701d_querylocale=''
702d_uselocale=''
703i_xlocale=''
704xlocale_needed=''
705d_nextafter=''
706d_nexttoward=''
707d_nice=''
708d_nl_langinfo=''
709d_nl_langinfo_l=''
710d_thread_safe_nl_langinfo_l=''
711d_off64_t=''
712d_open3=''
713d_fpathconf=''
714d_pathconf=''
715d_pause=''
716d_pipe2=''
717d_pipe=''
718d_poll=''
719d_portable=''
720d_prctl=''
721d_prctl_set_name=''
722d_procselfexe=''
723procselfexe=''
724d_old_pthread_create_joinable=''
725old_pthread_create_joinable=''
726d_pthread_atfork=''
727d_pthread_attr_setscope=''
728d_pthread_yield=''
729d_sched_yield=''
730sched_yield=''
731d_ptrdiff_t=''
732d_qgcvt=''
733d_random_r=''
734random_r_proto=''
735d_readdir64_r=''
736readdir64_r_proto=''
737d_readdir=''
738d_rewinddir=''
739d_seekdir=''
740d_telldir=''
741d_readdir_r=''
742readdir_r_proto=''
743d_readlink=''
744d_readv=''
745d_recvmsg=''
746d_re_comp=''
747d_regcmp=''
748d_regcomp=''
749d_remainder=''
750d_remquo=''
751d_rename=''
752d_rint=''
753d_rmdir=''
754d_round=''
755d_sbrkproto=''
756d_scalbn=''
757d_scalbnl=''
758d_select=''
759d_sem=''
760d_semctl=''
761d_semget=''
762d_semop=''
763d_sendmsg=''
764d_setegid=''
765d_setenv=''
766d_seteuid=''
767d_setgrent=''
768d_setgrent_r=''
769setgrent_r_proto=''
770d_setgrps=''
771d_sethent=''
772d_sethostent_r=''
773sethostent_r_proto=''
774d_setitimer=''
775d_setlinebuf=''
776d_has_C_UTF8=''
777d_setlocale=''
778d_setlocale_accepts_any_locale_name=''
779d_setlocale_r=''
780setlocale_r_proto=''
781d_setnent=''
782d_setnetent_r=''
783setnetent_r_proto=''
784d_setpent=''
785d_setpgid=''
786d_setpgrp2=''
787d_bsdsetpgrp=''
788d_setpgrp=''
789d_setprior=''
790d_setproctitle=''
791d_setprotoent_r=''
792setprotoent_r_proto=''
793d_setpwent=''
794d_setpwent_r=''
795setpwent_r_proto=''
796d_setregid=''
797d_setresgid=''
798d_setresuid=''
799d_setreuid=''
800d_setrgid=''
801d_setruid=''
802d_setsent=''
803d_setservent_r=''
804setservent_r_proto=''
805d_setsid=''
806d_setvbuf=''
807d_shm=''
808d_shmat=''
809d_shmatprototype=''
810shmattype=''
811d_shmctl=''
812d_shmdt=''
813d_shmget=''
814d_sigaction=''
815d_siginfo_si_addr=''
816d_siginfo_si_band=''
817d_siginfo_si_errno=''
818d_siginfo_si_fd=''
819d_siginfo_si_pid=''
820d_siginfo_si_status=''
821d_siginfo_si_uid=''
822d_siginfo_si_value=''
823d_signbit=''
824d_sigprocmask=''
825d_sigsetjmp=''
826usesitecustomize=''
827d_snprintf=''
828d_vsnprintf=''
829d_sockatmark=''
830d_sockatmarkproto=''
831d_ip_mreq=''
832d_ip_mreq_source=''
833d_ipv6_mreq=''
834d_ipv6_mreq_source=''
835d_msg_ctrunc=''
836d_msg_dontroute=''
837d_msg_oob=''
838d_msg_peek=''
839d_msg_proxy=''
840d_oldsock=''
841d_scm_rights=''
842d_sin6_scope_id=''
843d_sockaddr_in6=''
844d_sockaddr_sa_len=''
845d_sockaddr_storage=''
846d_socket=''
847d_sockpair=''
848sockethdr=''
849socketlib=''
850d_socklen_t=''
851d_socks5_init=''
852d_sqrtl=''
853d_srand48_r=''
854srand48_r_proto=''
855d_srandom_r=''
856srandom_r_proto=''
857d_sresgproto=''
858d_sresuproto=''
859d_stat=''
860d_statblks=''
861d_statfs_f_flags=''
862d_statfs_s=''
863d_static_inline=''
864perl_static_inline=''
865d_fstatvfs=''
866d_statvfs=''
867d_stdio_cnt_lval=''
868d_stdio_ptr_lval=''
869d_stdio_ptr_lval_nochange_cnt=''
870d_stdio_ptr_lval_sets_cnt=''
871d_stdiobase=''
872d_stdstdio=''
873stdio_base=''
874stdio_bufsiz=''
875stdio_cnt=''
876stdio_filbuf=''
877stdio_ptr=''
878d_strcoll=''
879d_sysernlst=''
880d_syserrlst=''
881d_strerror_l=''
882d_strerror_r=''
883strerror_r_proto=''
884d_strftime=''
885d_strlcat=''
886d_strlcpy=''
887d_strnlen=''
888d_strtod=''
889d_strtod_l=''
890d_strtol=''
891d_strtold=''
892d_strtold_l=''
893d_strtoll=''
894d_strtoq=''
895d_strtoul=''
896d_strtoull=''
897d_strtouq=''
898d_strxfrm=''
899d_strxfrm_l=''
900d_symlink=''
901d_syscall=''
902d_syscallproto=''
903d_sysconf=''
904d_system=''
905d_tcgetpgrp=''
906d_tcsetpgrp=''
907d_telldirproto=''
908d_tgamma=''
909d_thread_local=''
910perl_thread_local=''
911d_time=''
912timetype=''
913d_asctime64=''
914d_ctime64=''
915d_difftime64=''
916d_gmtime64=''
917d_localtime64=''
918d_mktime64=''
919d_timegm=''
920clocktype=''
921d_times=''
922d_tmpnam_r=''
923tmpnam_r_proto=''
924d_towlower=''
925d_towupper=''
926d_trunc=''
927d_truncate=''
928d_truncl=''
929d_ttyname_r=''
930ttyname_r_proto=''
931d_tzname=''
932d_u32align=''
933d_ualarm=''
934d_umask=''
935d_semctl_semid_ds=''
936d_semctl_semun=''
937d_union_semun=''
938d_unordered=''
939d_unsetenv=''
940d_usleep=''
941d_usleepproto=''
942d_ustat=''
943d_pseudofork=''
944d_vfork=''
945usevfork=''
946d_voidsig=''
947signal_t=''
948d_wait4=''
949d_waitpid=''
950d_wcrtomb=''
951d_wcscmp=''
952d_wcstombs=''
953d_wcsxfrm=''
954d_wctomb=''
955d_writev=''
956default_inc_excludes_dot=''
957dlext=''
958bin_ELF=''
959cccdlflags=''
960ccdlflags=''
961dlsrc=''
962ld=''
963ld_can_script=''
964lddlflags=''
965usedl=''
966doublesize=''
967dtraceobject=''
968dtracexnolibs=''
969ebcdic=''
970fflushNULL=''
971fflushall=''
972fpossize=''
973fpostype=''
974gccansipedantic=''
975gccosandvers=''
976gccversion=''
977gidformat=''
978gidsign=''
979gidsize=''
980gidtype=''
981groupstype=''
982h_fcntl=''
983h_sysfile=''
984html1dir=''
985html1direxp=''
986installhtml1dir=''
987html3dir=''
988html3direxp=''
989installhtml3dir=''
990i_arpainet=''
991i_bfd=''
992i_crypt=''
993db_hashtype=''
994db_prefixtype=''
995db_version_major=''
996db_version_minor=''
997db_version_patch=''
998i_db=''
999i_dbm=''
1000i_rpcsvcdbm=''
1001d_dirnamlen=''
1002direntrytype=''
1003i_dirent=''
1004i_dlfcn=''
1005i_execinfo=''
1006i_fcntl=''
1007i_fenv=''
1008i_fp=''
1009i_fp_class=''
1010i_gdbm=''
1011d_grpasswd=''
1012i_grp=''
1013i_ieeefp=''
1014i_inttypes=''
1015i_langinfo=''
1016i_libutil=''
1017i_locale=''
1018i_machcthr=''
1019i_malloc=''
1020i_mallocmalloc=''
1021i_mntent=''
1022d_gdbm_ndbm_h_uses_prototypes=''
1023d_gdbmndbm_h_uses_prototypes=''
1024d_ndbm=''
1025d_ndbm_h_uses_prototypes=''
1026i_gdbm_ndbm=''
1027i_gdbmndbm=''
1028i_ndbm=''
1029i_netdb=''
1030i_neterrno=''
1031i_netinettcp=''
1032i_niin=''
1033i_sysin=''
1034i_poll=''
1035i_prot=''
1036i_pthread=''
1037d_pwage=''
1038d_pwchange=''
1039d_pwclass=''
1040d_pwcomment=''
1041d_pwexpire=''
1042d_pwgecos=''
1043d_pwpasswd=''
1044d_pwquota=''
1045i_pwd=''
1046i_quadmath=''
1047i_shadow=''
1048i_socks=''
1049i_stdbool=''
1050i_stdint=''
1051i_stdlib=''
1052i_sunmath=''
1053i_sysaccess=''
1054i_sysdir=''
1055i_sysfile=''
1056d_voidtty=''
1057i_bsdioctl=''
1058i_sysfilio=''
1059i_sysioctl=''
1060i_syssockio=''
1061i_syslog=''
1062i_sysmman=''
1063i_sysmode=''
1064i_sysmount=''
1065i_sysndir=''
1066i_sysparam=''
1067i_syspoll=''
1068i_sysresrc=''
1069i_syssecrt=''
1070i_sysselct=''
1071i_sysstat=''
1072i_sysstatfs=''
1073i_sysstatvfs=''
1074i_syssyscall=''
1075i_systimes=''
1076i_systypes=''
1077i_sysuio=''
1078i_sysun=''
1079i_sysutsname=''
1080i_sysvfs=''
1081i_syswait=''
1082i_sgtty=''
1083i_termio=''
1084i_termios=''
1085d_tm_tm_gmtoff=''
1086d_tm_tm_zone=''
1087i_systime=''
1088i_systimek=''
1089i_time=''
1090timeincl=''
1091i_unistd=''
1092i_ustat=''
1093i_utime=''
1094i_vfork=''
1095i_wchar=''
1096i_wctype=''
1097d_inc_version_list=''
1098inc_version_list=''
1099inc_version_list_init=''
1100doubleinfbytes=''
1101doublenanbytes=''
1102longdblinfbytes=''
1103longdblnanbytes=''
1104installprefix=''
1105installprefixexp=''
1106installstyle=''
1107installusrbinperl=''
1108intsize=''
1109longsize=''
1110shortsize=''
1111issymlink=''
1112libc=''
1113ldlibpthname=''
1114libperl=''
1115shrpenv=''
1116useshrplib=''
1117glibpth=''
1118incpth=''
1119libpth=''
1120loclibpth=''
1121plibpth=''
1122xlibpth=''
1123ignore_versioned_solibs=''
1124libs=''
1125libsdirs=''
1126libsfiles=''
1127libsfound=''
1128libspath=''
1129lns=''
1130d_PRIEUldbl=''
1131d_PRIFUldbl=''
1132d_PRIGUldbl=''
1133d_PRIeldbl=''
1134d_PRIfldbl=''
1135d_PRIgldbl=''
1136d_SCNfldbl=''
1137d_double_has_inf=''
1138d_double_has_nan=''
1139d_double_has_negative_zero=''
1140d_double_has_subnormals=''
1141d_double_style_cray=''
1142d_double_style_ibm=''
1143d_double_style_ieee=''
1144d_double_style_vax=''
1145doublekind=''
1146sPRIEUldbl=''
1147sPRIFUldbl=''
1148sPRIGUldbl=''
1149sPRIeldbl=''
1150sPRIfldbl=''
1151sPRIgldbl=''
1152sSCNfldbl=''
1153lseeksize=''
1154lseektype=''
1155make_set_make=''
1156d_mymalloc=''
1157freetype=''
1158mallocobj=''
1159mallocsrc=''
1160malloctype=''
1161usemallocwrap=''
1162usemymalloc=''
1163installman1dir=''
1164man1dir=''
1165man1direxp=''
1166man1ext=''
1167installman3dir=''
1168man3dir=''
1169man3direxp=''
1170man3ext=''
1171doublemantbits=''
1172longdblmantbits=''
1173nvmantbits=''
1174modetype=''
1175multiarch=''
1176mydomain=''
1177myhostname=''
1178phostname=''
1179c=''
1180n=''
1181d_eofnblk=''
1182eagain=''
1183o_nonblock=''
1184rd_nodata=''
1185need_va_copy=''
1186netdb_hlen_type=''
1187netdb_host_type=''
1188netdb_name_type=''
1189netdb_net_type=''
1190groupcat=''
1191hostcat=''
1192passcat=''
1193orderlib=''
1194ranlib=''
1195d_perl_otherlibdirs=''
1196otherlibdirs=''
1197package=''
1198spackage=''
1199pager=''
1200api_revision=''
1201api_subversion=''
1202api_version=''
1203api_versionstring=''
1204patchlevel=''
1205perl_patchlevel=''
1206revision=''
1207subversion=''
1208version=''
1209version_patchlevel_string=''
1210perl5=''
1211perladmin=''
1212perlpath=''
1213i32dformat=''
1214u32XUformat=''
1215u32oformat=''
1216u32uformat=''
1217u32xformat=''
1218d_nv_preserves_uv=''
1219d_nv_zero_is_allbits_zero=''
1220i16size=''
1221i16type=''
1222i32size=''
1223i32type=''
1224i64size=''
1225i64type=''
1226i8size=''
1227i8type=''
1228ivsize=''
1229ivtype=''
1230nv_overflows_integers_at=''
1231nv_preserves_uv_bits=''
1232nvsize=''
1233nvtype=''
1234u16size=''
1235u16type=''
1236u32size=''
1237u32type=''
1238u64size=''
1239u64type=''
1240u8size=''
1241u8type=''
1242uvsize=''
1243uvtype=''
1244ivdformat=''
1245nvEUformat=''
1246nvFUformat=''
1247nvGUformat=''
1248nveformat=''
1249nvfformat=''
1250nvgformat=''
1251uvXUformat=''
1252uvoformat=''
1253uvuformat=''
1254uvxformat=''
1255pidtype=''
1256prefix=''
1257prefixexp=''
1258installprivlib=''
1259privlib=''
1260privlibexp=''
1261ptrsize=''
1262d_PRIXU64=''
1263d_PRId64=''
1264d_PRIi64=''
1265d_PRIo64=''
1266d_PRIu64=''
1267d_PRIx64=''
1268sPRIXU64=''
1269sPRId64=''
1270sPRIi64=''
1271sPRIo64=''
1272sPRIu64=''
1273sPRIx64=''
1274d_quad=''
1275quadkind=''
1276quadtype=''
1277uquadtype=''
1278drand01=''
1279randbits=''
1280randfunc=''
1281randseedtype=''
1282seedfunc=''
1283installscript=''
1284scriptdir=''
1285scriptdirexp=''
1286selectminbits=''
1287selecttype=''
1288sh=''
1289targetsh=''
1290sig_count=''
1291sig_name=''
1292sig_name_init=''
1293sig_num=''
1294sig_num_init=''
1295sig_size=''
1296d_sitearch=''
1297installsitearch=''
1298sitearch=''
1299sitearchexp=''
1300installsitebin=''
1301sitebin=''
1302sitebinexp=''
1303installsitehtml1dir=''
1304sitehtml1dir=''
1305sitehtml1direxp=''
1306installsitehtml3dir=''
1307sitehtml3dir=''
1308sitehtml3direxp=''
1309installsitelib=''
1310sitelib=''
1311sitelib_stem=''
1312sitelibexp=''
1313installsiteman1dir=''
1314siteman1dir=''
1315siteman1direxp=''
1316installsiteman3dir=''
1317siteman3dir=''
1318siteman3direxp=''
1319siteprefix=''
1320siteprefixexp=''
1321installsitescript=''
1322sitescript=''
1323sitescriptexp=''
1324sizesize=''
1325sizetype=''
1326d_libname_unique=''
1327so=''
1328socksizetype=''
1329sharpbang=''
1330shsharp=''
1331spitshell=''
1332src=''
1333ssizetype=''
1334st_dev_sign=''
1335st_dev_size=''
1336st_ino_sign=''
1337st_ino_size=''
1338startperl=''
1339startsh=''
1340stdchar=''
1341d_stdio_stream_array=''
1342stdio_stream_array=''
1343sysman=''
1344sGMTIME_max=''
1345sGMTIME_min=''
1346sLOCALTIME_max=''
1347sLOCALTIME_min=''
1348trnl=''
1349uidformat=''
1350uidsign=''
1351uidsize=''
1352uidtype=''
1353archname64=''
1354use64bitall=''
1355use64bitint=''
1356usecbacktrace=''
1357usedefaultstrict=''
1358dtrace=''
1359usedtrace=''
1360usefaststdio=''
1361usekernprocpathname=''
1362ccflags_uselargefiles=''
1363ldflags_uselargefiles=''
1364libswanted_uselargefiles=''
1365uselargefiles=''
1366uselongdouble=''
1367usemorebits=''
1368usemultiplicity=''
1369nm_opt=''
1370nm_so_opt=''
1371runnm=''
1372usenm=''
1373usensgetexecutablepath=''
1374useperlio=''
1375usequadmath=''
1376usesocks=''
1377d_oldpthreads=''
1378useithreads=''
1379usereentrant=''
1380usethreads=''
1381incpath=''
1382mips_type=''
1383usrinc=''
1384d_vendorarch=''
1385installvendorarch=''
1386vendorarch=''
1387vendorarchexp=''
1388d_vendorbin=''
1389installvendorbin=''
1390vendorbin=''
1391vendorbinexp=''
1392installvendorhtml1dir=''
1393vendorhtml1dir=''
1394vendorhtml1direxp=''
1395installvendorhtml3dir=''
1396vendorhtml3dir=''
1397vendorhtml3direxp=''
1398d_vendorlib=''
1399installvendorlib=''
1400vendorlib=''
1401vendorlib_stem=''
1402vendorlibexp=''
1403installvendorman1dir=''
1404vendorman1dir=''
1405vendorman1direxp=''
1406installvendorman3dir=''
1407vendorman3dir=''
1408vendorman3direxp=''
1409usevendorprefix=''
1410vendorprefix=''
1411vendorprefixexp=''
1412d_vendorscript=''
1413installvendorscript=''
1414vendorscript=''
1415vendorscriptexp=''
1416versiononly=''
1417yacc=''
1418yaccflags=''
1419CONFIG=''
1420
1421: Detect odd OSs
1422define='define'
1423undef='undef'
1424smallmach='pdp11 i8086 z8000 i80286 iAPX286'
1425rmlist=''
1426
1427: We must find out about Eunice early
1428eunicefix=':'
1429if test -f /etc/unixtovms; then
1430	eunicefix=/etc/unixtovms
1431fi
1432if test -f /etc/unixtovms.exe; then
1433	eunicefix=/etc/unixtovms.exe
1434fi
1435
1436: Set executable suffix now -- needed before hints available
1437if test -f "/libs/version.library"; then
1438: Amiga OS
1439    _exe=""
1440elif test -f "/system/gnu_library/bin/ar.pm"; then
1441: Stratus VOS
1442    _exe=".pm"
1443elif test -n "$DJGPP"; then
1444: DOS DJGPP
1445    _exe=".exe"
1446elif test -f /kern/cookiejar; then
1447: MiNT
1448    _exe=""
1449elif test -d c:/. -o -n "$is_os2" ; then
1450: OS/2 or cygwin
1451    _exe=".exe"
1452fi
1453
1454groupstype=''
1455i_whoami=''
1456: Possible local include directories to search.
1457: Set locincpth to "" in a hint file to defeat local include searches.
1458locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
1459locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
1460:
1461: no include file wanted by default
1462inclwanted=''
1463
1464: Enable -DEBUGGING and -DDEBUGGING from the command line
1465EBUGGING=''
1466DEBUGGING=''
1467
1468: Trailing extension.  Override this in a hint file, if needed.
1469: Extra object files, if any, needed on this platform.
1470archobjs=''
1471libnames=''
1472: change the next line if compiling for Xenix/286 on Xenix/386
1473xlibpth='/usr/lib/386 /lib/386'
1474: Possible local library directories to search.
1475loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1476loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1477
1478: general looking path for locating libraries
1479glibpth="/lib /usr/lib $xlibpth"
1480glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
1481test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
1482test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
1483test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
1484
1485: Private path used by Configure to find libraries.  Its value
1486: is prepended to libpth. This variable takes care of special
1487: machines, like the mips.  Usually, it should be empty.
1488plibpth=''
1489
1490: default library list
1491libswanted=''
1492: some systems want to use only the non-versioned libso:s
1493ignore_versioned_solibs=''
1494ccname=''
1495ccversion=''
1496perllibs=''
1497: set useposix=false in your hint file to disable the POSIX extension.
1498useposix=true
1499: set useopcode=false in your hint file to disable the Opcode extension.
1500useopcode=true
1501: set uselanginfo=false in your hint file to disable the I18N::Langinfo extension.
1502uselanginfo=true
1503archname64=''
1504ccflags_uselargefiles=''
1505ldflags_uselargefiles=''
1506libswanted_uselargefiles=''
1507: set usemultiplicity on the Configure command line to enable multiplicity.
1508: set usesocks on the Configure command line to enable socks.
1509archname=''
1510: set usethreads on the Configure command line to enable threads.
1511usereentrant='undef'
1512: List of libraries we want.
1513: If anyone needs extra -lxxx, put those in a hint file.
1514libswanted="cl pthread socket bind inet ndbm gdbm dbm db malloc dl ld"
1515libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
1516: We probably want to search /usr/shlib before most other libraries.
1517: This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
1518glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
1519glibpth="/usr/shlib $glibpth"
1520: Do not use vfork unless overridden by a hint file.
1521usevfork=false
1522
1523: Find the basic shell for Bourne shell scripts
1524case "$sh" in
1525'')
1526	case "$SYSTYPE" in
1527	*bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
1528	*) xxx='/bin/sh';;
1529	esac
1530	if test -f "$xxx"; then
1531		sh="$xxx"
1532	else
1533		: Build up a list and do a single loop so we can 'break' out.
1534		pth=`echo $PATH | sed -e "s/$p_/ /g"`
1535		for xxx in sh bash ksh pdksh ash; do
1536			for p in $pth; do
1537				try="$try ${p}/${xxx}"
1538			done
1539		done
1540		for xxx in $try; do
1541			if test -f "$xxx"; then
1542				sh="$xxx";
1543				break
1544			elif test "X$_exe" != X -a -f "$xxx$_exe"; then
1545				sh="$xxx";
1546				break
1547			elif test -f "$xxx.exe"; then
1548				sh="$xxx";
1549				break
1550			fi
1551		done
1552	fi
1553	;;
1554esac
1555
1556case "$sh" in
1557'')	cat >&2 <<EOM
1558$me:  Fatal Error:  I can't find a Bourne Shell anywhere.
1559
1560Usually it's in /bin/sh.  How did you even get this far?
1561Please report this issue at https://github.com/Perl/perl5/issues
1562and we'll try to straighten this all out.
1563EOM
1564	exit 1
1565	;;
1566esac
1567
1568: When cross-compiling we need to separate the sh-to-run-Configure-with from the sh-to-use-in-Perl
1569: default both to the same thing, cross-compilers can then set targetsh differently if they like
1570targetsh=$sh
1571
1572: see if sh knows # comments
1573if `$sh -c '#' >/dev/null 2>&1`; then
1574	shsharp=true
1575	spitshell=cat
1576	xcat=/bin/cat
1577	test -f $xcat$_exe || xcat=/usr/bin/cat
1578	if test ! -f $xcat$_exe; then
1579		for p in `echo $PATH | sed -e "s/$p_/ /g"` $paths; do
1580			if test -f $p/cat$_exe; then
1581				xcat=$p/cat
1582				break
1583			fi
1584		done
1585		if test ! -f $xcat$_exe; then
1586			echo "Can't find cat anywhere!"
1587			exit 1
1588		fi
1589	fi
1590	echo "#!$xcat" >sharp
1591	$eunicefix sharp
1592	chmod +x sharp
1593	./sharp > today 2>/dev/null
1594	if test -s today; then
1595		sharpbang='#!'
1596	else
1597		echo "#! $xcat" > sharp
1598		$eunicefix sharp
1599		chmod +x sharp
1600		./sharp > today 2>/dev/null
1601		if test -s today; then
1602			sharpbang='#! '
1603		else
1604			sharpbang=': use '
1605		fi
1606	fi
1607else
1608	echo " "
1609	echo "Your $sh doesn't grok # comments--I will strip them later on."
1610	shsharp=false
1611	cd ..
1612	echo "exec grep -v '^[ 	]*#'" >spitshell
1613	chmod +x spitshell
1614	$eunicefix spitshell
1615	spitshell=`pwd`/spitshell
1616	cd UU
1617	echo "I presume that if # doesn't work, #! won't work either!"
1618	sharpbang=': use '
1619fi
1620rm -f sharp today
1621
1622: figure out how to guarantee sh startup
1623case "$startsh" in
1624'') startsh=${sharpbang}${sh} ;;
1625*)
1626esac
1627cat >sharp <<EOSS
1628$startsh
1629set abc
1630test "$?abc" != 1
1631EOSS
1632
1633chmod +x sharp
1634$eunicefix sharp
1635if ./sharp; then
1636	: echo "Yup, it does."
1637else
1638	echo "Hmm... '$startsh' does not guarantee sh startup..."
1639	echo "You may have to fix up the shell scripts to make sure $sh runs them."
1640fi
1641rm -f sharp
1642
1643: Save command line options in file UU/cmdline.opt for later use in
1644: generating config.sh.
1645cat > cmdline.opt <<EOSH
1646: Configure command line arguments.
1647config_arg0='$0'
1648config_args='$*'
1649config_argc=$#
1650EOSH
1651argn=1
1652args_exp=''
1653args_sep=''
1654for arg in "$@"; do
1655	cat >>cmdline.opt <<EOSH
1656config_arg$argn='$arg'
1657EOSH
1658	cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
1659$arg
1660EOC
1661	arg_exp=`cat cmdl.opt`
1662	args_exp="$args_exp$args_sep'$arg_exp'"
1663	argn=`expr $argn + 1`
1664	args_sep=' '
1665done
1666rm -f cmdl.opt
1667
1668: produce awk script to parse command line options
1669cat >options.awk <<'EOF'
1670BEGIN {
1671	optstr = "A:dD:eEf:hKOrsSU:V";	# getopt-style specification
1672
1673	len = length(optstr);
1674	for (i = 1; i <= len; i++) {
1675		c = substr(optstr, i, 1);
1676		if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1677		if (a == ":") {
1678			arg[c] = 1;
1679			i++;
1680		}
1681		opt[c] = 1;
1682	}
1683}
1684{
1685	expect = 0;
1686	str = $0;
1687	if (substr(str, 1, 1) != "-") {
1688		printf("'%s'\n", str);
1689		next;
1690	}
1691	len = length($0);
1692	for (i = 2; i <= len; i++) {
1693		c = substr(str, i, 1);
1694		if (!opt[c]) {
1695			printf("-%s\n", substr(str, i));
1696			next;
1697		}
1698		printf("-%s\n", c);
1699		if (arg[c]) {
1700			if (i < len)
1701				printf("'%s'\n", substr(str, i + 1));
1702			else
1703				expect = 1;
1704			next;
1705		}
1706	}
1707}
1708END {
1709	if (expect)
1710		print "?";
1711}
1712EOF
1713
1714: process the command line options
1715set X `for arg in "$@"; do echo "X$arg"; done |
1716	sed -e s/X// | awk -f options.awk`
1717eval "set $*"
1718shift
1719rm -f options.awk
1720
1721: set up default values
1722fastread=''
1723reuseval=false
1724config_sh=''
1725alldone=''
1726error=''
1727silent=''
1728extractsh=''
1729knowitall=''
1730rm -f optdef.sh posthint.sh
1731cat >optdef.sh <<EOS
1732$startsh
1733EOS
1734
1735
1736: option parsing
1737while test $# -gt 0; do
1738	case "$1" in
1739	-d) shift; fastread=yes;;
1740	-e) shift; alldone=cont;;
1741	-f)
1742		shift
1743		cd ..
1744		if test -r "$1"; then
1745			config_sh="$1"
1746		else
1747			echo "$me: cannot read config file $1." >&2
1748			error=true
1749		fi
1750		cd UU
1751		shift;;
1752	--help|\
1753	-h) shift; error=true;;
1754	-r) shift; reuseval=true;;
1755	-s) shift; silent=true; realsilent=true;;
1756	-E) shift; alldone=exit;;
1757	-K) shift; knowitall=true;;
1758	-O) shift;;
1759	-S) shift; silent=true; extractsh=true;;
1760	-D)
1761		shift
1762		case "$1" in
1763		*=)
1764			echo "$me: use '-U symbol=', not '-D symbol='." >&2
1765			echo "$me: ignoring -D $1" >&2
1766			;;
1767		*=*) echo "$1" | \
1768				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1769		*) echo "$1='define'" >> optdef.sh;;
1770		esac
1771		shift
1772		;;
1773	-U)
1774		shift
1775		case "$1" in
1776		*=) echo "$1" >> optdef.sh;;
1777		*=*)
1778			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1779			echo "$me: ignoring -U $1" >&2
1780			;;
1781		*) echo "$1='undef'" >> optdef.sh;;
1782		esac
1783		shift
1784		;;
1785	-A)
1786	    shift
1787	    xxx=''
1788	    yyy="$1"
1789	    zzz=''
1790	    uuu=undef
1791	    case "$yyy" in
1792            *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1793                 case "$zzz" in
1794                 *:*) zzz='' ;;
1795                 *)   xxx=append
1796                      zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1797                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1798                 esac
1799                 ;;
1800            esac
1801            case "$xxx" in
1802            '')  case "$yyy" in
1803                 *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1804                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1805                      zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1806                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1807                 *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
1808                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1809                 esac
1810                 ;;
1811            esac
1812	    case "$xxx" in
1813	    append)
1814		echo "$yyy=\"\${$yyy}$zzz\""	>> posthint.sh ;;
1815	    clear)
1816		echo "$yyy=''"			>> posthint.sh ;;
1817	    define)
1818	        case "$zzz" in
1819		'') zzz=define ;;
1820		esac
1821		echo "$yyy='$zzz'"		>> posthint.sh ;;
1822	    eval)
1823		echo "eval \"$yyy=$zzz\""	>> posthint.sh ;;
1824	    prepend)
1825		echo "$yyy=\"$zzz\${$yyy}\""	>> posthint.sh ;;
1826	    undef)
1827	        case "$zzz" in
1828		'') zzz="$uuu" ;;
1829		esac
1830		echo "$yyy=$zzz"		>> posthint.sh ;;
1831            *)  echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1832	    esac
1833	    shift
1834	    ;;
1835	-V) echo "$me generated by metaconfig 3.5 PL0." >&2
1836	    exit 0;;
1837	--) break;;
1838	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
1839	*) break;;
1840	esac
1841done
1842
1843case "$error" in
1844true)
1845	cat >&2 <<EOM
1846Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1847                 [-U symbol] [-U symbol=] [-A command:symbol...]
1848  -d : use defaults for all answers.
1849  -e : go on without questioning past the production of config.sh.
1850  -f : specify an alternate default configuration file.
1851  -h : print this help message and exit (with an error status).
1852  -r : reuse C symbols value if possible (skips costly nm extraction).
1853  -s : silent mode, only echoes questions and essential information.
1854  -D : define symbol to have some value:
1855         -D symbol                symbol gets the value 'define'
1856         -D symbol='some value'   symbol is set to 'some value'
1857       common used examples (see INSTALL for more info):
1858         -Duse64bitint            use 64bit integers
1859         -Duse64bitall            use 64bit integers and pointers
1860         -Dusethreads             use thread support
1861         -Dinc_version_list=none  do not include older perl trees in @INC
1862         -DEBUGGING=none          DEBUGGING options
1863         -Dcc=gcc                 choose your compiler
1864         -Dprefix=/opt/perl5      choose your destination
1865  -E : stop at the end of questions, after having produced config.sh.
1866  -K : do not use unless you know what you are doing.
1867  -O : ignored for backward compatibility
1868  -S : perform variable substitutions on all .SH files (can mix with -f)
1869  -U : undefine symbol:
1870         -U symbol    symbol gets the value 'undef'
1871         -U symbol=   symbol gets completely empty
1872       e.g.:  -Uversiononly
1873  -A : manipulate symbol after the platform specific hints have been applied:
1874         -A append:symbol=value   append value to symbol
1875         -A symbol=value          like append:, but with a separating space
1876         -A define:symbol=value   define symbol to have value
1877         -A clear:symbol          define symbol to be ''
1878         -A define:symbol         define symbol to be 'define'
1879         -A eval:symbol=value     define symbol to be eval of value
1880         -A prepend:symbol=value  prepend value to symbol
1881         -A undef:symbol          define symbol to be 'undef'
1882         -A undef:symbol=         define symbol to be ''
1883       e.g.:  -A prepend:libswanted='cl pthread '
1884              -A ccflags=-DSOME_MACRO
1885  -V : print version number and exit (with a zero status).
1886EOM
1887	exit 1
1888	;;
1889esac
1890
1891: Sanity checks
1892case "$fastread$alldone" in
1893yescont|yesexit) ;;
1894*)
1895	case "$extractsh" in
1896	true) ;;
1897	*)
1898		if test ! -t 0; then
1899			echo "Say 'sh Configure', not 'sh <Configure'"
1900			exit 1
1901		fi
1902		;;
1903	esac
1904	;;
1905esac
1906
1907exec 4>&1
1908case "$silent" in
1909true) exec 1>/dev/null;;
1910esac
1911
1912: run the defines and the undefines, if any, but leave the file out there...
1913touch optdef.sh
1914grep '\\' optdef.sh >/dev/null 2>&1
1915if test $? = 0; then
1916    echo "Configure does not support \\ in -D arguments"
1917    exit 1
1918fi
1919. ./optdef.sh
1920: create the posthint manipulation script and leave the file out there...
1921touch posthint.sh
1922
1923: set package name
1924package='perl5'
1925first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1926last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1927case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
1928ABYZ-abyz) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1929*) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1930esac
1931
1932: Some greps do not return status, grrr.
1933echo "grimblepritz" >grimble
1934if grep blurfldyick grimble >/dev/null 2>&1 ; then
1935	contains=contains
1936elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1937	contains=grep
1938else
1939	contains=contains
1940fi
1941rm -f grimble
1942: the following should work in any shell
1943case "$contains" in
1944contains*)
1945	echo " " >&4
1946	echo "AGH!  Grep doesn't return a status.  Attempting remedial action." >&4
1947	cat >contains <<'EOSS'
1948grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1949EOSS
1950contains=./contains
1951chmod +x $contains
1952esac
1953
1954: Find the path to the source tree
1955case "$src" in
1956'') case "$0" in
1957    */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
1958         case "$src" in
1959	 /*)	;;
1960	 .)	;;
1961         *)	src=`cd ../$src && pwd` ;;
1962	 esac
1963         ;;
1964    *)   src='.';;
1965    esac;;
1966esac
1967case "$src" in
1968'')	src=/
1969	rsrc=/
1970	;;
1971/*)	rsrc="$src";;
1972*)	rsrc="../$src";;
1973esac
1974if test -f $rsrc/Configure && \
1975	$contains "^package='$package'\$" $rsrc/Configure >/dev/null 2>&1
1976then
1977   : found it, so we are ok.
1978else
1979	rsrc=''
1980	for src in . .. ../.. ../../.. ../../../..; do
1981		if test -f ../$src/Configure && \
1982			$contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1983		then
1984			rsrc=../$src
1985			break
1986		fi
1987	done
1988fi
1989case "$rsrc" in
1990'')
1991	cat <<EOM >&4
1992
1993Sorry, I can't seem to locate the source dir for $package.  Please start
1994Configure with an explicit path -- i.e. /some/path/Configure.
1995
1996EOM
1997	exit 1
1998	;;
1999../.)	rsrc='..';;
2000*)
2001	echo " "
2002	echo "Sources for $package found in \"$src\"." >&4
2003	;;
2004esac
2005
2006: script used to extract .SH files with variable substitutions
2007cat >extract <<'EOS'
2008PERL_CONFIG_SH=true
2009echo "Doing variable substitutions on .SH files..."
2010if test -f MANIFEST; then
2011	set x `awk '{print $1}' < MANIFEST | grep '\.SH$'`
2012else
2013	echo "(Looking for .SH files under the source directory.)"
2014	set x `(cd "$src"; find . -name "*.SH" -print)`
2015fi
2016shift
2017case $# in
20180) set x `(cd "$src"; echo *.SH)`; shift;;
2019esac
2020if test ! -f "$src/$1"; then
2021	shift
2022fi
2023mkdir_p='
2024name=$1;
2025create="";
2026while test $name; do
2027	if test ! -d "$name"; then
2028		create="$name $create";
2029		name=`echo $name | sed -e "s|^[^/]*$||"`;
2030		name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
2031	else
2032		name="";
2033	fi;
2034done;
2035for file in $create; do
2036	mkdir $file;
2037done
2038'
2039for file in $*; do
2040	case "$src" in
2041	".")
2042		case "$file" in
2043		*/*)
2044			dir=`expr X$file : 'X\(.*\)/'`
2045			file=`expr X$file : 'X.*/\(.*\)'`
2046			(cd "$dir" && . ./$file)
2047			;;
2048		*)
2049			. ./$file
2050			;;
2051		esac
2052		;;
2053	*)
2054		case "$file" in
2055		*/*)
2056			dir=`expr X$file : 'X\(.*\)/'`
2057			file=`expr X$file : 'X.*/\(.*\)'`
2058			(set x $dir; shift; eval $mkdir_p)
2059			sh <"$src/$dir/$file"
2060			;;
2061		*)
2062			sh <"$src/$file"
2063			;;
2064		esac
2065		;;
2066	esac
2067done
2068if test -f "$src/config_h.SH"; then
2069	if test ! -f config.h; then
2070	: oops, they left it out of MANIFEST, probably, so do it anyway.
2071	. "$src/config_h.SH"
2072	fi
2073fi
2074EOS
2075
2076: extract files and exit if asked to do so
2077case "$extractsh" in
2078true)
2079	case "$realsilent" in
2080	true) ;;
2081	*) exec 1>&4;;
2082	esac
2083	case "$config_sh" in
2084	'') config_sh='config.sh';;
2085	esac
2086	echo " "
2087	echo "Fetching answers from $config_sh..."
2088	cd ..
2089	. $config_sh
2090	. UU/optdef.sh
2091	echo " "
2092	. UU/extract
2093	rm -rf UU
2094	echo "Extraction done."
2095	exit 0
2096	;;
2097esac
2098
2099: Eunice requires " " instead of "", can you believe it
2100echo " "
2101: Here we go...
2102echo "Beginning of configuration questions for $package."
2103
2104trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
2105
2106: first determine how to suppress newline on echo command
2107echo " "
2108echo "Checking echo to see how to suppress newlines..."
2109(echo "hi there\c" ; echo " ") >.echotmp
2110if $contains c .echotmp >/dev/null 2>&1 ; then
2111	echo "...using -n."
2112	n='-n'
2113	c=''
2114else
2115	cat <<'EOM'
2116...using \c
2117EOM
2118	n=''
2119	c='\c'
2120fi
2121echo $n "The star should be here-->$c"
2122echo '*'
2123rm -f .echotmp
2124
2125: Now test for existence of everything in MANIFEST
2126echo " "
2127if test -f "$rsrc/MANIFEST"; then
2128	echo "First let's make sure your kit is complete.  Checking..." >&4
2129	awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
2130		(split -l 50 2>/dev/null || split -50)
2131	rm -f missing
2132	tmppwd=`pwd`
2133	for filelist in x??; do
2134		(cd "$rsrc"; ls `cat "$tmppwd/$filelist"` \
2135			>/dev/null 2>>"$tmppwd/missing")
2136	done
2137	if test -s missing; then
2138		cat missing >&4
2139		cat >&4 <<'EOM'
2140
2141THIS PACKAGE SEEMS TO BE INCOMPLETE.
2142
2143You have the option of continuing the configuration process, despite the
2144distinct possibility that your kit is damaged, by typing 'y'es.  If you
2145do, don't blame me if something goes wrong.  I advise you to type 'n'o
2146and contact the author (https://github.com/Perl/perl5/issues).
2147
2148EOM
2149		echo $n "Continue? [n] $c" >&4
2150		read ans
2151		case "$ans" in
2152		y*)
2153			echo "Continuing..." >&4
2154			rm -f missing
2155			;;
2156		*)
2157			echo "ABORTING..." >&4
2158			kill $$
2159			;;
2160		esac
2161	else
2162		echo "Looks good..."
2163	fi
2164else
2165	echo "There is no MANIFEST file.  I hope your kit is complete !"
2166fi
2167rm -f missing x??
2168
2169: Find the appropriate value for a newline for tr
2170if test -n "$DJGPP"; then
2171       trnl='\012'
2172fi
2173if test X"$trnl" = X; then
2174	case "`echo foo | tr '\n' x 2>/dev/null`" in
2175	foox) trnl='\n' ;;
2176	esac
2177fi
2178if test X"$trnl" = X; then
2179	case "`echo foo | tr '\012' x 2>/dev/null`" in
2180	foox) trnl='\012' ;;
2181	esac
2182fi
2183if test X"$trnl" = X; then
2184       case "`echo foo | tr '\r\n' xy 2>/dev/null`" in
2185       fooxy) trnl='\n\r' ;;
2186       esac
2187fi
2188if test X"$trnl" = X; then
2189	cat <<EOM >&2
2190
2191$me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
2192
2193EOM
2194	exit 1
2195fi
2196
2197: compute the number of columns on the terminal for proper question formatting
2198case "$COLUMNS" in
2199'') COLUMNS='80';;
2200esac
2201
2202: set up the echo used in my read
2203myecho="case \"\$xxxm\" in
2204'') echo $n \"\$rp $c\" >&4;;
2205*) case \"\$rp\" in
2206	'') echo $n \"[\$xxxm] $c\";;
2207	*)
2208		if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
2209			echo \"\$rp\" >&4
2210			echo $n \"[\$xxxm] $c\" >&4
2211		else
2212			echo $n \"\$rp [\$xxxm] $c\" >&4
2213		fi
2214		;;
2215	esac;;
2216esac"
2217
2218: now set up to do reads with possible shell escape and default assignment
2219cat <<EOSC >myread
2220$startsh
2221xxxm=\$dflt
2222$myecho
2223ans='!'
2224counter=42
2225case "\$fastread" in
2226yes) case "\$dflt" in
2227	'') ;;
2228	*) ans='';
2229		case "\$silent-\$rp" in
2230		true-) ;;
2231		*) echo " " >&4;;
2232		esac;;
2233	esac;;
2234*) case "\$silent" in
2235	true) case "\$rp" in
2236		'') ans='';;
2237		esac;;
2238	esac;;
2239esac
2240while expr "X\$ans" : "X!" >/dev/null; do
2241	read answ
2242	set x \$xxxm
2243	shift
2244	aok=''; eval "ans=\\"\$answ\\"" && aok=y
2245	case  "\$answ" in
2246	"!")
2247		sh 1>&4
2248		echo " "
2249		$myecho
2250		;;
2251	!*)
2252		set x \`expr "X\$ans" : "X!\(.*\)\$"\`
2253		shift
2254		sh 1>&4 -c "\$*"
2255		echo " "
2256		$myecho
2257		;;
2258	"\$ans")
2259		case "\$ans" in
2260		\\&*)
2261			set x \`expr "X\$ans" : "X&\(.*\)\$"\`
2262			shift
2263			case "\$1" in
2264			-d)
2265				fastread=yes
2266				echo "(OK, I'll run with -d after this question.)" >&4
2267				;;
2268			-*)
2269				echo "*** Sorry, \$1 not supported yet." >&4
2270				;;
2271			esac
2272			$myecho
2273			ans=!
2274			;;
2275		esac;;
2276	*)
2277		case "\$aok" in
2278		y)
2279			echo "*** Substitution done -- please confirm."
2280			xxxm="\$ans"
2281			ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
2282			xxxm="\$ans"
2283			ans=!
2284			;;
2285		*)
2286			echo "*** Error -- try again."
2287			ans=!
2288			;;
2289		esac
2290		$myecho
2291		;;
2292	esac
2293	case "\$ans\$xxxm\$nostick" in
2294	'')
2295		ans=!
2296		$myecho
2297		;;
2298	esac
2299	counter=\`echo \$counter | awk '{ print --\$0 }'\`
2300	if [ \$counter = 0 ]; then
2301		echo >&4
2302		echo >&4 Too many attempts asking the same question.  Giving up.
2303		exit 1
2304	fi
2305done
2306case "\$ans" in
2307'') ans="\$xxxm";;
2308esac
2309EOSC
2310
2311: create .config dir to save info across Configure sessions
2312test -d ../.config || mkdir ../.config
2313cat >../.config/README <<EOF
2314This directory created by Configure to save information that should
2315persist across sessions for $package.
2316
2317You may safely delete it if you wish.
2318EOF
2319
2320: See if we are using a devel version and want that
2321xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
2322case "$usedevel" in
2323$define|true|[yY]*)
2324    usedevel="$define" ;;
2325*) case "$xversion" in
2326   *[13579])
2327	cat >&4 <<EOH
2328*** WHOA THERE!!! ***
2329
2330    This is an UNSTABLE DEVELOPMENT release.
2331    The version of this $package distribution is $xversion, that is, odd,
2332    (as opposed to even) and that signifies a development release.
2333    If you want a maintenance release, you want an even-numbered version.
2334
2335    Do ***NOT*** install this into production use.
2336    Data corruption and crashes are possible.
2337
2338    It is most seriously suggested that you do not continue any further
2339    unless you want to help in developing and debugging Perl.
2340
2341    If you *still* want to build perl, you can answer 'y' now,
2342    or pass -Dusedevel to Configure.
2343
2344EOH
2345	rp='Do you really want to continue?'
2346	dflt='n'
2347	. ./myread
2348	case "$ans" in
2349	[yY]) echo >&4 "Okay, continuing."
2350	      usedevel="$define" ;;
2351	*) echo >&4 "Okay, bye."
2352	   exit 1
2353	   ;;
2354	esac
2355	;;
2356    esac
2357    usedevel="$undef"
2358    ;;
2359esac
2360case "$usedevel" in
2361$define|true|[yY]*)
2362	case "$versiononly" in
2363	'') versiononly="$define" ;;
2364	esac
2365	case "$installusrbinperl" in
2366	'') installusrbinperl="$undef" ;;
2367	esac
2368	;;
2369esac
2370
2371: general instructions
2372needman=true
2373firsttime=true
2374user=`(logname) 2>/dev/null`
2375case "$user" in
2376'') user=`whoami 2>&1`;;
2377esac
2378if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
2379	firsttime=false
2380	echo " "
2381	rp='Would you like to see the instructions?'
2382	dflt=n
2383	. ./myread
2384	case "$ans" in
2385	[yY]*) ;;
2386	*) needman=false;;
2387	esac
2388fi
2389if $needman; then
2390	cat <<EOH
2391
2392This installation shell script will examine your system and ask you questions
2393to determine how the perl5 package should be installed. If you get
2394stuck on a question, you may use a ! shell escape to start a subshell or
2395execute a command.  Many of the questions will have default answers in square
2396brackets; typing carriage return will give you the default.
2397
2398On some of the questions which ask for file or directory names you are allowed
2399to use the ~name construct to specify the login directory belonging to "name",
2400even if you don't have a shell which knows about that.  Questions where this is
2401allowed will be marked "(~name ok)".
2402
2403EOH
2404	rp=''
2405	dflt='Type carriage return to continue'
2406	. ./myread
2407	cat <<'EOH'
2408
2409The prompter used in this script allows you to use shell variables and
2410backticks in your answers.  You may use $1, $2, etc...  to refer to the words
2411in the default answer, as if the default line was a set of arguments given to a
2412script shell.  This means you may also use $* to repeat the whole default line,
2413so you do not have to re-type everything to add something to the default.
2414
2415Every time there is a substitution, you will have to confirm.  If there is an
2416error (e.g. an unmatched backtick), the default answer will remain unchanged
2417and you will be prompted again.
2418
2419If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
2420the questions and use the computed defaults (or the previous answers if there
2421was already a config.sh file). Type 'Configure -h' for a list of options.
2422You may also start interactively and then answer '& -d' at any prompt to turn
2423on the non-interactive behaviour for the remainder of the execution.
2424
2425EOH
2426	. ./myread
2427	cat <<EOH
2428
2429Much effort has been expended to ensure that this shell script will run on any
2430Unix system.  If despite that it blows up on yours, your best bet is to edit
2431Configure and run it again.  If you can't run Configure for some reason,
2432you'll have to generate a config.sh file by hand.  Whatever problems you
2433have, let me (https://github.com/Perl/perl5/issues) know how I blew it.
2434
2435This installation script affects things in two ways:
2436
24371) it may do direct variable substitutions on some of the files included
2438   in this kit.
24392) it builds a config.h file for inclusion in C programs.  You may edit
2440   any of these files as the need arises after running this script.
2441
2442If you make a mistake on a question, there is no easy way to back up to it
2443currently.  The easiest thing to do is to edit config.sh and rerun all the SH
2444files.  Configure will offer to let you do this before it runs the SH files.
2445
2446EOH
2447	dflt='Type carriage return to continue'
2448	. ./myread
2449	case "$firsttime" in
2450	true) echo $user >>../.config/instruct;;
2451	esac
2452fi
2453
2454: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
2455: This is primarily meant for cross-compile environments, and may fail to be useful in other cases
2456if test "X$sysroot" = X; then
2457    sysroot=""
2458else
2459    case "$cc" in
2460	*gcc*|*g++*)
2461	    echo "Using $sysroot to find your headers and libraries, adding to ccflags"
2462	    # _sysroot is used in places where we need --sysroot=foo
2463	    # but using the rest of the flags could cause issues.
2464	    _sysroot="--sysroot=$sysroot";
2465	    case "$ccflags" in
2466		*sysroot*) ;;
2467		'undef'|*)
2468		ccflags="$ccflags $_sysroot"
2469	    esac
2470	    case "$ldflags" in
2471		*sysroot*) ;;
2472		'undef'|*)
2473		ldflags="$ldflags $_sysroot"
2474	    esac
2475	    case "$cppflags" in
2476		*sysroot*) ;;
2477		'undef'|*)
2478		cppflags="$cppflags $_sysroot"
2479	    esac
2480	    # lddlflags updated below in lddlflags section;
2481	    # same with cccdlflags
2482	    ;;
2483    esac
2484
2485    # Adjust some defaults to also use $sysroot
2486    for var in xlibpth loclibpth locincpth glibpth; do
2487	eval xxx=\$$var
2488	eval $var=''
2489	for path in $xxx; do
2490	    eval $var=\"\$$var $sysroot$path\"
2491	done
2492    done
2493
2494fi
2495
2496: find out where common programs are
2497echo " "
2498echo "Locating common programs..." >&4
2499cat <<EOSC >loc
2500$startsh
2501case \$# in
25020) exit 1;;
2503esac
2504thing=\$1
2505shift
2506dflt=\$1
2507shift
2508for dir in \$*; do
2509	case "\$thing" in
2510	.)
2511	if test -d \$dir/\$thing; then
2512		echo \$dir
2513		exit 0
2514	fi
2515	;;
2516	*)
2517	for thisthing in \$dir/\$thing; do
2518		: just loop through to pick last item
2519	done
2520	if test -f \$thisthing; then
2521		echo \$thisthing
2522		exit 0
2523	elif test "X$_exe" != X -a -f \$thisthing$_exe; then
2524		echo \$thisthing
2525		exit 0
2526	elif test -f \$dir/\$thing.exe; then
2527		if test -n "$DJGPP"; then
2528			echo \$dir/\$thing.exe
2529		elif test "$eunicefix" != ":"; then
2530			: on Eunice apparently
2531			echo \$dir/\$thing
2532		fi
2533		exit 0
2534	fi
2535	;;
2536	esac
2537done
2538echo \$dflt
2539exit 1
2540EOSC
2541chmod +x loc
2542$eunicefix loc
2543loclist="
2544awk
2545cat
2546chmod
2547comm
2548cp
2549echo
2550expr
2551grep
2552ls
2553mkdir
2554rm
2555sed
2556sort
2557touch
2558tr
2559uniq
2560"
2561trylist="
2562ar
2563bison
2564byacc
2565cpp
2566csh
2567date
2568egrep
2569gmake
2570gzip
2571less
2572ln
2573make
2574more
2575nm
2576nroff
2577perl
2578pg
2579test
2580uname
2581zip
2582"
2583pth=`echo $PATH | sed -e "s/$p_/ /g"`
2584pth="$pth $sysroot/lib $sysroot/usr/lib"
2585for file in $loclist; do
2586	eval xxx=\$$file
2587	case "$xxx" in
2588	/*|?:[\\/]*)
2589		if test -f "$xxx"; then
2590			: ok
2591		else
2592			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2593			xxx=`./loc $file $file $pth`
2594		fi
2595		;;
2596	'') xxx=`./loc $file $file $pth`;;
2597	*) xxx=`./loc $xxx $xxx $pth`;;
2598	esac
2599	eval $file=$xxx$_exe
2600	eval _$file=$xxx
2601	case "$xxx" in
2602	/*)
2603		echo $file is in $xxx.
2604		;;
2605	?:[\\/]*)
2606		echo $file is in $xxx.
2607		;;
2608	*)
2609		echo "I don't know where '$file' is, and my life depends on it." >&4
2610		echo "Go find a public domain implementation or fix your PATH setting!" >&4
2611		exit 1
2612		;;
2613	esac
2614done
2615echo " "
2616echo "Don't worry if any of the following aren't found..."
2617say=offhand
2618for file in $trylist; do
2619	eval xxx=\$$file
2620	case "$xxx" in
2621	/*|?:[\\/]*)
2622		if test -f "$xxx"; then
2623			: ok
2624		else
2625			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2626			xxx=`./loc $file $file $pth`
2627		fi
2628		;;
2629	'') xxx=`./loc $file $file $pth`;;
2630	*) xxx=`./loc $xxx $xxx $pth`;;
2631	esac
2632	eval $file=$xxx$_exe
2633	eval _$file=$xxx
2634	case "$xxx" in
2635	/*)
2636		echo $file is in $xxx.
2637		;;
2638	?:[\\/]*)
2639		echo $file is in $xxx.
2640		;;
2641	*)
2642		echo "I don't see $file out there, $say."
2643		say=either
2644		;;
2645	esac
2646done
2647case "$egrep" in
2648egrep)
2649	echo "Substituting grep for egrep."
2650	egrep=$grep
2651	_egrep=$grep
2652	;;
2653esac
2654case "$less" in
2655'')	;;
2656*)	if $less -R </dev/null >/dev/null 2>&1; then
2657	       echo "Substituting less -R for less."
2658	       less="$less -R"
2659	       _less=$less
2660	fi
2661	;;
2662esac
2663case "$ln" in
2664ln)
2665	echo "Substituting cp for ln."
2666	ln=$cp
2667	_ln=$cp
2668	;;
2669esac
2670case "$make" in
2671make)
2672	case "$gmake" in
2673	gmake)
2674	echo "I can't find make or gmake, and my life depends on it." >&4
2675	echo "Go find a public domain implementation or fix your PATH setting!" >&4
2676	exit 1
2677	;;
2678	esac
2679	;;
2680esac
2681case "$gmake" in
2682gmake)	;;
2683*)	# We can't have osname yet.
2684	if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
2685		# Assume that gmake, if found, is definitely GNU make
2686		# and prefer it over the system make.
2687		echo "Substituting gmake for make."
2688		make=$gmake
2689		_make=$gmake
2690	fi
2691	;;
2692esac
2693case "$test" in
2694test)
2695	echo "Hopefully test is built into your sh."
2696	;;
2697*)
2698	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
2699		echo "Using the test built into your sh."
2700		test=test
2701		_test=test
2702	fi
2703	;;
2704esac
2705case "$echo" in
2706echo)
2707	echo "Hopefully echo is built into your sh."
2708	;;
2709'') ;;
2710*)
2711	echo " "
2712echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
2713	$echo $n "hi there$c" >foo1
2714	echo $n "hi there$c" >foo2
2715	if cmp foo1 foo2 >/dev/null 2>&1; then
2716		echo "They are compatible.  In fact, they may be identical."
2717	else
2718		case "$n" in
2719		'-n') n='' c='\c';;
2720		*) n='-n' c='';;
2721		esac
2722		cat <<FOO
2723They are not compatible!  You are probably running ksh on a non-USG system.
2724I'll have to use $echo instead of the builtin, since Bourne shell doesn't
2725have echo built in and we may have to run some Bourne shell scripts.  That
2726means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
2727
2728FOO
2729		$echo $n "The star should be here-->$c"
2730		$echo "*"
2731	fi
2732	$rm -f foo1 foo2
2733	;;
2734esac
2735
2736# This question was auctioned at YAPC::Europe-2007 in Vienna
2737# I never promised you could answer it. I only auctioned the question.
2738cat <<FOO
2739The following message is sponsored by
2740
2741  Dresden.pm<--The stars should be here.
2742
2743Dear Perl user, system administrator or package
2744maintainer, the Perl community sends greetings to
2745you. Do you (emblematical) greet back [Y/n]? n
2746
2747FOO
2748
2749: Check what type of C compiler we use
2750cat <<EOS >trygcc
2751$startsh
2752EOS
2753cat <<'EOSC' >>trygcc
2754case "$cc" in
2755'') ;;
2756*)  $rm -f try try.*
2757    $cat >try.c <<EOM
2758int main(int argc, char *argv[]) {
2759  return 0;
2760}
2761EOM
2762    if $cc -o try $ccflags $ldflags try.c; then
2763       :
2764    else
2765        echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2766        despair=yes
2767        trygcc=yes
2768        case "$cc" in
2769        *gcc*) trygcc=no ;;
2770        esac
2771	# Skip this test because it gives a false match on output like:
2772	#    ./trygcc: line 23: cc: command not found
2773        # case "`$cc -v -c try.c 2>&1`" in
2774        # *gcc*) trygcc=no ;;
2775        # esac
2776        if $test X"$trygcc" = Xyes; then
2777            if gcc -o try -c try.c; then
2778                echo " "
2779                echo "You seem to have a working gcc, though." >&4
2780		# Switching compilers may undo the work of hints files.
2781		# The most common problem is -D_REENTRANT for threads.
2782		# This heuristic catches that case, but gets false positives
2783		# if -Dusethreads was not actually specified.  Better to
2784		# bail out here with a useful message than fail
2785		# mysteriously later. Should we perhaps just try to
2786		# re-invoke Configure -Dcc=gcc config_args ?
2787		if $test -f usethreads.cbu; then
2788			$cat >&4 <<EOM
2789
2790*** However, any setting of the C compiler flags (e.g. for thread support)
2791*** will be lost.  It may be necessary for you to restart Configure and
2792*** add -Dcc=gcc to your Configure command line.
2793
2794EOM
2795			rp="Would you like to go ahead and try gcc anyway?"
2796			dflt=n
2797		else
2798			rp="Would you like to use it?"
2799			dflt=y
2800		fi
2801                if $test -f myread; then
2802                    . ./myread
2803                else
2804                    if $test -f UU/myread; then
2805                        . ./UU/myread
2806                    else
2807                        echo "Cannot find myread, sorry.  Aborting." >&4
2808                        exit 1
2809                    fi
2810                fi
2811                case "$ans" in
2812                [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
2813                esac
2814            fi
2815        fi
2816    fi
2817    $rm -f try try.*
2818    ;;
2819esac
2820EOSC
2821
2822cat <<EOS >checkcc
2823$startsh
2824EOS
2825cat <<'EOSC' >>checkcc
2826case "$cc" in
2827'') ;;
2828*)  $rm -f try try.*
2829    $cat >try.c <<EOM
2830int main(int argc, char *argv[]) {
2831  return 0;
2832}
2833EOM
2834    if $cc -o try $ccflags $ldflags try.c; then
2835       :
2836    else
2837        if $test X"$despair" = Xyes; then
2838           echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2839        fi
2840        $cat >&4 <<EOM
2841You need to find a working C compiler.
2842Either (purchase and) install the C compiler supplied by your OS vendor,
2843or for a free C compiler try http://gcc.gnu.org/
2844I cannot continue any further, aborting.
2845EOM
2846        exit 1
2847    fi
2848    $rm -f try try.*
2849    ;;
2850esac
2851EOSC
2852
2853: determine whether symbolic links are supported
2854echo " "
2855$touch blurfl
2856if $ln -s blurfl sym > /dev/null 2>&1 ; then
2857	echo "Symbolic links are supported." >&4
2858	lns="$ln -s"
2859else
2860	echo "Symbolic links are NOT supported." >&4
2861	lns="$ln"
2862fi
2863$rm -f blurfl sym
2864
2865: determine whether symbolic links are supported
2866echo " "
2867case "$lns" in
2868*"ln"*" -s")
2869	echo "Checking how to test for symbolic links..." >&4
2870	$lns blurfl sym
2871	if $test "X$issymlink" = X; then
2872		case "$newsh" in
2873		'') sh     -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2874		*)  $newsh -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2875		esac
2876		if test $? = 0; then
2877			issymlink="test -h"
2878		else
2879			echo "Your builtin 'test -h' may be broken." >&4
2880			case "$test" in
2881			/*)	;;
2882			*)	pth=`echo $PATH | sed -e "s/$p_/ /g"`
2883				for p in $pth
2884				do
2885					if test -f "$p/$test"; then
2886						test="$p/$test"
2887						break
2888					fi
2889				done
2890				;;
2891			esac
2892			case "$test" in
2893			/*)
2894				echo "Trying external '$test -h'." >&4
2895				issymlink="$test -h"
2896				if $test ! -h sym >/dev/null 2>&1; then
2897					echo "External '$test -h' is broken, too." >&4
2898					issymlink=''
2899				fi
2900				;;
2901			*)	issymlink='' ;;
2902			esac
2903		fi
2904	fi
2905	if $test "X$issymlink" = X; then
2906		if $test -L sym 2>/dev/null; then
2907			issymlink="$test -L"
2908			echo "The builtin '$test -L' worked." >&4
2909		fi
2910	fi
2911	if $test "X$issymlink" != X; then
2912		echo "You can test for symbolic links with '$issymlink'." >&4
2913	else
2914		echo "I do not know how you can test for symbolic links." >&4
2915	fi
2916	$rm -f blurfl sym
2917	;;
2918*)	echo "No symbolic links, so not testing for their testing..." >&4
2919	;;
2920esac
2921
2922: Make symlinks util
2923case "$mksymlinks" in
2924$define|true|[yY]*)
2925	case "$src" in
2926	''|'.')	echo "Cannot create symlinks in the original directory." >&4
2927		exit 1
2928		;;
2929	*)	case "$lns:$issymlink" in
2930		*"ln"*" -s:"*"test -"?)
2931			echo "Creating the symbolic links..." >&4
2932			cd ..
2933			awk '{print $1}' $src/MANIFEST | sed -e 's:/\([^/]*\)$: \1:' |
2934			awk 'NF == 1 {
2935				dir=".";
2936				file=$1 "";
2937			     }
2938			     NF == 2 {
2939				dir=$1 "";
2940				file=$2 "";
2941			     }
2942			     {
2943				 print "# dir = ", dir, "file = ", file
2944				 mf[dir] = mf[dir]" "source"/"dir"/"file;
2945			     } END {
2946				 for (d in mf) {
2947				     if (d != ".") { print("mkdir -p "d) }
2948				     print("ln -sf "mf[d]" "d);
2949				 }
2950			     }' source="$src" > UU/mksymlinks.$$
2951			sh UU/mksymlinks.$$
2952			rm UU/mksymlinks.$$
2953			# Sanity check 1.
2954			if test ! -d t/base; then
2955				echo "Failed to create the subdirectories.  Aborting." >&4
2956				exit 1
2957			fi
2958			# Sanity check 2.
2959			if test ! -f t/base/lex.t; then
2960				echo "Failed to create the symlinks (t/base/lex.t missing).  Aborting." >&4
2961				exit 1
2962			fi
2963			if test ! -f win32/win32.c; then
2964				echo "Failed to create the symlinks (win32/win32.c missing).  Aborting." >&4
2965				exit 1
2966			fi
2967			cd UU
2968			;;
2969		*)	echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
2970			;;
2971		esac
2972		;;
2973	esac
2974	;;
2975esac
2976
2977: Check for Cross-Compilation
2978if $test "X$targethost" = "X"; then
2979    targethost=""
2980fi
2981if $test "X$targetenv" = "X"; then
2982    targetenv=""
2983fi
2984case "$usecrosscompile" in
2985$define|true|[yY]*)
2986	$echo "Cross-compiling..."
2987	croak=''
2988	case "$cc" in
2989	*-gcc*|*-g++*) # A cross-compiling gcc, probably.
2990	    # arm-linux-androideabi-gcc  -> arm-linux-androideabi
2991	    # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
2992	    targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
2993	    ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
2994	    # leave out ld, choosing it is more complex
2995	    nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
2996	    ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
2997	    # We are in a weird spot. Just before us, some values
2998	    # were 'saved', to be restored after the hints are
2999	    # run.  This means that the changes we made to ar,
3000	    # nm and ranlib will get reverted.
3001	    # To avoid that, we hijack the saving mechanism and
3002	    # have it save our new values.
3003	    for file in ar nm ranlib; do
3004		eval xxx=\$$file
3005		eval $file=$xxx$_exe
3006		eval _$file=$xxx
3007	    done
3008	;;
3009	esac
3010	case "$targetarch" in
3011	'') echo "Targetarch not defined." >&4; croak=y ;;
3012	*)  echo "Using targetarch $targetarch." >&4 ;;
3013	esac
3014	case "$targethost" in
3015	'') echo "Targethost not defined." >&4; croak=n ;;
3016	*)  echo "Using targethost $targethost." >&4
3017	esac
3018	locincpth=' '
3019	loclibpth=' '
3020	case "$croak" in
3021	y) echo "Cannot continue, aborting." >&4; exit 1 ;;
3022	esac
3023    : compile a host miniperl and generate_uudmap, unless we got passed them
3024    if $test "X$hostperl" = X; then
3025      echo "Building host miniperl and generate_uudmap binaries" >&4
3026      before_host=`pwd`
3027      cd ..
3028      cd $src
3029      src=`pwd`
3030      rm -rf $src/host
3031      mkdir $src/host
3032      cd $src/host
3033      $src/Configure -des -Dusedevel -Dmksymlinks
3034      $make miniperl
3035      case "$hostgenerate" in
3036      '') $make generate_uudmap
3037          hostgenerate=$src/host/generate_uudmap
3038          ;;
3039       "$undef") hostgenerate=''
3040          ;;
3041      esac
3042      hostperl=$src/host/miniperl
3043      cd $before_host
3044    fi
3045    hostosname=`$hostperl -le 'print $^O'`
3046    ;;
3047*)
3048    usecrosscompile="$undef"
3049    ;;
3050esac
3051
3052: Define -Dtargethost=somecomputer to run compiled tests on another machine
3053case "$targethost" in
3054    '') echo "Checking for cross-compile" >&4
3055    case "$usecrosscompile$multiarch" in
3056       *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
3057         if [ -f Makefile ]; then
3058           echo " "
3059           echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
3060         else
3061           echo "Configure done."
3062         fi
3063       exit 0
3064       ;;
3065     *) echo "No targethost for running compiler tests against defined, running locally" >&4
3066        run=''
3067        to=:
3068        from=:
3069        ;;
3070    esac
3071    ;;
3072    *) echo "Using targethost $targethost." >&4
3073	case "$src" in
3074	/*) run=$src/Cross/run
3075	    targetmkdir=$src/Cross/mkdir
3076	    to=$src/Cross/to
3077	    from=$src/Cross/from
3078	    ;;
3079	*)  pwd=`$test -f ../Configure & cd ..; pwd`
3080	    run=$pwd/Cross/run
3081	    targetmkdir=$pwd/Cross/mkdir
3082	    to=$pwd/Cross/to
3083	    from=$pwd/Cross/from
3084	    ;;
3085	esac
3086	case "$targetrun" in
3087	'') targetrun=ssh ;;
3088	esac
3089	case "$targetto" in
3090	'') targetto=scp ;;
3091	esac
3092	case "$targetfrom" in
3093	'') targetfrom=scp ;;
3094	esac
3095	run=$run-$targetrun
3096	to=$to-$targetto
3097	from=$from-$targetfrom
3098	case "$targetdir" in
3099	'')  targetdir=/tmp
3100	     echo "Guessing targetdir $targetdir." >&4
3101	     ;;
3102	esac
3103	case "$targetuser" in
3104	'')  targetuser=root
3105	     echo "Guessing targetuser $targetuser." >&4
3106	     ;;
3107	esac
3108	case "$targetport" in
3109	'')  targetport=22
3110	     echo "Guessing targetport $targetport." >&4
3111	     ;;
3112	esac
3113	case "$targetfrom" in
3114	scp)	q=-q ;;
3115	*)	q='' ;;
3116	esac
3117	case "$targetrun" in
3118	ssh|rsh)
3119	    cat >$run <<EOF
3120#!/bin/sh
3121env=''
3122case "\$1" in
3123-cwd)
3124  shift
3125  cwd=\$1
3126  shift
3127  ;;
3128esac
3129case "\$1" in
3130-env)
3131  shift
3132  env=\$1
3133  shift
3134  ;;
3135esac
3136case "\$cwd" in
3137'') cwd=$targetdir ;;
3138esac
3139exe=\$1
3140shift
3141$to \$exe
3142$targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
3143EOF
3144	    ;;
3145	adb)
3146	    $touch $run
3147	    ;;
3148	*)  echo "Unknown targetrun '$targetrun'" >&4
3149	    exit 1
3150	    ;;
3151	esac
3152	case "$targetmkdir" in
3153	*/Cross/mkdir)
3154	    cat >$targetmkdir <<EOF
3155#!/bin/sh
3156$targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
3157EOF
3158	    $chmod a+rx $targetmkdir
3159	    ;;
3160	*)  echo "Unknown targetmkdir '$targetmkdir'" >&4
3161	    exit 1
3162	    ;;
3163	esac
3164	case "$targetto" in
3165	scp|rcp)
3166	    cat >$to <<EOF
3167#!/bin/sh
3168for f in \$@
3169do
3170  case "\$f" in
3171  /*)
3172    $targetmkdir \`dirname \$f\`
3173    $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f           2>/dev/null  || exit 1
3174    ;;
3175  *)
3176    $targetmkdir $targetdir/\`dirname \$f\`
3177    $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
3178    ;;
3179  esac
3180done
3181exit 0
3182EOF
3183	    ;;
3184	cp) cat >$to <<EOF
3185#!/bin/sh
3186for f in \$@
3187do
3188  case "\$f" in
3189  /*)
3190    $mkdir -p $targetdir/\`dirname \$f\`
3191    $cp \$f $targetdir/\$f || exit 1
3192    ;;
3193  *)
3194    $targetmkdir $targetdir/\`dirname \$f\`
3195    $cp \$f $targetdir/\$f || exit 1
3196    ;;
3197  esac
3198done
3199exit 0
3200EOF
3201	    ;;
3202	*)  echo "Unknown targetto '$targetto'" >&4
3203	    exit 1
3204	    ;;
3205	esac
3206	case "$targetfrom" in
3207	scp|rcp)
3208	  cat >$from <<EOF
3209#!/bin/sh
3210for f in \$@
3211do
3212  $rm -f \$f
3213  $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
3214done
3215exit 0
3216EOF
3217	    ;;
3218	cp) cat >$from <<EOF
3219#!/bin/sh
3220for f in \$@
3221do
3222  $rm -f \$f
3223  cp $targetdir/\$f . || exit 1
3224done
3225exit 0
3226EOF
3227	    ;;
3228	*)  echo "Unknown targetfrom '$targetfrom'" >&4
3229	    exit 1
3230	    ;;
3231	esac
3232	if $test ! -f $run; then
3233	    echo "Target 'run' script '$run' not found." >&4
3234	else
3235	    $chmod a+rx $run
3236	fi
3237	if $test ! -f $to; then
3238	    echo "Target 'to' script '$to' not found." >&4
3239	else
3240	    $chmod a+rx $to
3241	fi
3242	if $test ! -f $from; then
3243	    echo "Target 'from' script '$from' not found." >&4
3244	else
3245	    $chmod a+rx $from
3246	fi
3247	if $test ! -f $run -o ! -f $to -o ! -f $from; then
3248	    exit 1
3249	fi
3250	cat >&4 <<EOF
3251Using '$run' for remote execution,
3252and '$from' and '$to'
3253for remote file transfer.
3254EOF
3255	;;
3256*)	run=''
3257	to=:
3258	from=:
3259	usecrosscompile="$undef"
3260	targetarch=''
3261	;;
3262esac
3263
3264: see whether [:lower:] and [:upper:] are supported character classes
3265echo " "
3266case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | $tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
3267ABYZ-abyz)
3268	echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
3269	up='[:upper:]'
3270	low='[:lower:]'
3271	;;
3272*)	# There is a discontinuity in EBCDIC between 'R' and 'S'
3273	# (0xd9 and 0xe2), therefore that is a nice testing point.
3274	if test "X$up" = X -o "X$low" = X; then
3275	    case "`echo RS | $tr '[R-S]' '[r-s]' 2>/dev/null`" in
3276	    rs) up='[A-Z]'
3277		low='[a-z]'
3278		;;
3279	    esac
3280	fi
3281	if test "X$up" = X -o "X$low" = X; then
3282	    case "`echo RS | $tr R-S r-s 2>/dev/null`" in
3283	    rs) up='A-Z'
3284		low='a-z'
3285		;;
3286	    esac
3287	fi
3288	if test "X$up" = X -o "X$low" = X; then
3289	    case "`echo RS | od -x 2>/dev/null`" in
3290	    *D9E2*|*d9e2*)
3291		echo "Hey, this might be EBCDIC." >&4
3292		if test "X$up" = X -o "X$low" = X; then
3293		    case "`echo RS | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
3294		    rs) up='[A-IJ-RS-Z]'
3295			low='[a-ij-rs-z]'
3296			;;
3297		    esac
3298		fi
3299		if test "X$up" = X -o "X$low" = X; then
3300		    case "`echo RS | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
3301		    rs) up='A-IJ-RS-Z'
3302			low='a-ij-rs-z'
3303			;;
3304		    esac
3305		fi
3306		;;
3307	    esac
3308	fi
3309esac
3310case "`echo RS | $tr \"$up\" \"$low\" 2>/dev/null`" in
3311rs)
3312    echo "Using $up and $low to convert case." >&4
3313    ;;
3314*)
3315    echo "I don't know how to translate letters from upper to lower case." >&4
3316    echo "Your tr is not acting any way I know of." >&4
3317    exit 1
3318    ;;
3319esac
3320: set up the translation script tr, must be called with ./tr of course
3321cat >tr <<EOSC
3322$startsh
3323case "\$1\$2" in
3324'[A-Z][a-z]') exec $tr '$up' '$low';;
3325'[a-z][A-Z]') exec $tr '$low' '$up';;
3326esac
3327exec $tr "\$@"
3328EOSC
3329chmod +x tr
3330$eunicefix tr
3331
3332: Try to determine whether config.sh was made on this system
3333case "$config_sh" in
3334'')
3335myuname=`$uname -a 2>/dev/null`
3336$test -z "$myuname" && myuname=`hostname 2>/dev/null`
3337# Downcase everything to avoid ambiguity.
3338# Remove slashes and single quotes so we can use parts of this in
3339# directory and file names.
3340# Remove newlines so myuname is sane to use elsewhere.
3341# tr '[A-Z]' '[a-z]' would not work in EBCDIC
3342# because the A-Z/a-z are not consecutive.
3343myuname=`echo $myuname | $sed -e "s,['/],,g" | \
3344	./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
3345newmyuname="$myuname"
3346dflt=n
3347case "$knowitall" in
3348'')
3349	if test -f ../config.sh; then
3350		if $contains myuname= ../config.sh >/dev/null 2>&1; then
3351			eval "`grep myuname= ../config.sh`"
3352		fi
3353		if test "X$myuname" = "X$newmyuname"; then
3354			dflt=y
3355		fi
3356	fi
3357	;;
3358*) dflt=y;;
3359esac
3360
3361: Get old answers from old config file if Configure was run on the
3362: same system, otherwise use the hints.
3363hint=default
3364cd ..
3365if test -f config.sh; then
3366	echo " "
3367	rp="I see a config.sh file.  Shall I use it to set the defaults?"
3368	. UU/myread
3369	case "$ans" in
3370	n*|N*) echo "OK, I'll ignore it."
3371		mv config.sh config.sh.old
3372		myuname="$newmyuname"
3373		;;
3374	*)  echo "Fetching default answers from your old config.sh file..." >&4
3375		tmp_n="$n"
3376		tmp_c="$c"
3377		tmp_sh="$sh"
3378		. ./config.sh
3379		cp config.sh UU
3380		n="$tmp_n"
3381		c="$tmp_c"
3382		: Older versions did not always set $sh.  Catch re-use of such
3383		: an old config.sh.
3384		case "$sh" in
3385		'') sh="$tmp_sh" ;;
3386		esac
3387		hint=previous
3388		;;
3389	esac
3390fi
3391. ./UU/checkcc
3392if test ! -f config.sh; then
3393	$cat <<EOM
3394
3395First time through, eh?  I have some defaults handy for some systems
3396that need some extra help getting the Configure answers right:
3397
3398EOM
3399	(cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
3400	dflt=''
3401	: Half the following guesses are probably wrong... If you have better
3402	: tests or hints, please send them to https://github.com/Perl/perl5/issues
3403	: The metaconfig authors would also appreciate a copy...
3404	$test -f /irix && osname=irix
3405	$test -f /xenix && osname=sco_xenix
3406	$test -f /dynix && osname=dynix
3407	$test -f /dnix && osname=dnix
3408	$test -f /lynx.os && osname=lynxos
3409	$test -f /unicos && osname=unicos && osvers=`$uname -r`
3410	$test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
3411	$test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
3412	$test -f /bin/mips && /bin/mips && osname=mips
3413	$test -d /usr/apollo/bin && osname=apollo
3414	$test -f /etc/saf/_sactab && osname=svr4
3415	$test -d /usr/include/minix && osname=minix && osvers=`$uname -r`
3416	$test -f /system/gnu_library/bin/ar.pm && osname=vos
3417	$test -f /sys/utilities/MultiView && osname=amigaos
3418	if $test -d /MachTen -o -d /MachTen_Folder; then
3419		osname=machten
3420		if $test -x /sbin/version; then
3421			osvers=`/sbin/version | $awk '{print $2}' |
3422			$sed -e 's/[A-Za-z]$//'`
3423		elif $test -x /usr/etc/version; then
3424			osvers=`/usr/etc/version | $awk '{print $2}' |
3425			$sed -e 's/[A-Za-z]$//'`
3426		else
3427			osvers="$2.$3"
3428		fi
3429	fi
3430
3431	$test -f /sys/posix.dll &&
3432		$test -f /usr/bin/what &&
3433		set X `/usr/bin/what /sys/posix.dll` &&
3434		$test "$3" = UWIN &&
3435		osname=uwin &&
3436		osvers="$5"
3437
3438	if $test -f $uname; then
3439		set X $myuname
3440		shift
3441
3442		case "$5" in
3443		fps*) osname=fps ;;
3444		mips*)
3445			case "$4" in
3446			umips) osname=umips ;;
3447			*) osname=mips ;;
3448			esac;;
3449		[23]100) osname=mips ;;
3450		i386*)
3451			tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
3452			if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
3453				osname='sco'
3454				osvers=$tmp
3455			elif $test -f /etc/kconfig; then
3456				osname=isc
3457				if test "$lns" = "$ln -s"; then
3458					osvers=4
3459				elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
3460					osvers=3
3461				elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
3462					osvers=2
3463				fi
3464			fi
3465			tmp=''
3466			;;
3467		pc*)
3468			if test -n "$DJGPP"; then
3469				osname=dos
3470				osvers=djgpp
3471			fi
3472			;;
3473		esac
3474
3475		case "$1" in
3476		aix) osname=aix
3477			tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
3478			case "$tmp" in
3479			# oslevel can fail with:
3480			# oslevel: Unable to acquire lock.
3481			*not\ found) osvers="$4"."$3" ;;
3482			'<3240'|'<>3240') osvers=3.2.0 ;;
3483			'=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
3484			'=3250'|'>3250') osvers=3.2.5 ;;
3485			*) osvers=$tmp;;
3486			esac
3487			;;
3488		bitrig) osname=bitrig
3489			osvers="$3"
3490			;;
3491		bsd386) osname=bsd386
3492			osvers=`$uname -r`
3493			;;
3494		cygwin*) osname=cygwin
3495			osvers="$3"
3496			;;
3497		*dc.osx) osname=dcosx
3498			osvers="$3"
3499			;;
3500		dnix) osname=dnix
3501			osvers="$3"
3502			;;
3503		domainos) osname=apollo
3504			osvers="$3"
3505			;;
3506		dgux)	osname=dgux
3507			osvers="$3"
3508			;;
3509		dragonfly) osname=dragonfly
3510			case "$3" in
3511			    [0-9]*) osvers="$3" ;;
3512			    *) osvers="$2" ;;
3513			esac
3514			;;
3515		dynixptx*) osname=dynixptx
3516			osvers=`echo "$4"|sed 's/^v//'`
3517			;;
3518		freebsd) osname=freebsd
3519			osvers="$3" ;;
3520		genix)	osname=genix ;;
3521		gnu)	osname=gnu
3522			osvers="$3" ;;
3523		hp*)	osname=hpux
3524			osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
3525			;;
3526		irix*)	osname=irix
3527			case "$3" in
3528			4*) osvers=4 ;;
3529			5*) osvers=5 ;;
3530			*)	osvers="$3" ;;
3531			esac
3532			;;
3533		linux)	osname=linux
3534			case "$3" in
3535			*)	osvers="$3" ;;
3536			esac
3537			$test -f /system/lib/libandroid.so && osname=linux-android
3538			;;
3539		MiNT)	osname=mint
3540			;;
3541		minix)	osname=minix
3542			osvers=`$uname -r`
3543			;;
3544		netbsd*) osname=netbsd
3545			osvers="$3"
3546			;;
3547		news-os) osvers="$3"
3548			case "$3" in
3549			4*) osname=newsos4 ;;
3550			*) osname=newsos ;;
3551			esac
3552			;;
3553		nonstop-ux) osname=nonstopux ;;
3554		openbsd) osname=openbsd
3555			osvers="$3"
3556			;;
3557		os2)	osname=os2
3558			osvers="$4"
3559			;;
3560		POSIX-BC | posix-bc ) osname=posix-bc
3561			osvers="$3"
3562			;;
3563		powerux | power_ux | powermax_os | powermaxos | \
3564		powerunix | power_unix) osname=powerux
3565			osvers="$3"
3566			;;
3567		qnx) osname=qnx
3568			osvers="$4"
3569			;;
3570		solaris) osname=solaris
3571			case "$3" in
3572			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3573			*)	osvers="$3" ;;
3574			esac
3575			;;
3576		sunos) osname=sunos
3577			case "$3" in
3578			5*) osname=solaris
3579				osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3580			*)	osvers="$3" ;;
3581			esac
3582			;;
3583		titanos) osname=titanos
3584			case "$3" in
3585			1*) osvers=1 ;;
3586			2*) osvers=2 ;;
3587			3*) osvers=3 ;;
3588			4*) osvers=4 ;;
3589			*)	osvers="$3" ;;
3590			esac
3591			;;
3592		ultrix) osname=ultrix
3593			osvers="$3"
3594			;;
3595		osf1|mls+)	case "$5" in
3596				alpha)
3597					osname=dec_osf
3598					osvers=`sizer -v | awk -FUNIX '{print $2}' | awk '{print $1}' |  tr '[A-Z]' '[a-z]' | sed 's/^[xvt]//'`
3599					case "$osvers" in
3600					[1-9].[0-9]*) ;;
3601					*) osvers=`echo "$3" | sed 's/^[xvt]//'` ;;
3602					esac
3603					;;
3604			hp*)	osname=hp_osf1	;;
3605			mips)	osname=mips_osf1 ;;
3606			esac
3607			;;
3608		# UnixWare 7.1.2 is known as Open UNIX 8
3609		openunix|unixware) osname=svr5
3610			osvers="$4"
3611			;;
3612		uts)	osname=uts
3613			osvers="$3"
3614			;;
3615		vos) osvers="$3"
3616			;;
3617		$2) case "$osname" in
3618			*isc*) ;;
3619			*freebsd*) ;;
3620			svr*)
3621				: svr4.x or possibly later
3622				case "svr$3" in
3623				${osname}*)
3624					osname=svr$3
3625					osvers=$4
3626					;;
3627				esac
3628				case "$osname" in
3629				svr4.0)
3630					: Check for ESIX
3631					if test -f /stand/boot ; then
3632						eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
3633						if test -n "$INITPROG" -a -f "$INITPROG"; then
3634			isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
3635							if test -n "$isesix"; then
3636								osname=esix4
3637							fi
3638						fi
3639					fi
3640					;;
3641				esac
3642				;;
3643			*)	if test -f /etc/systemid; then
3644					osname=sco
3645					set `echo $3 | $sed 's/\./ /g'` $4
3646					if $test -f $src/hints/sco_$1_$2_$3.sh; then
3647						osvers=$1.$2.$3
3648					elif $test -f $src/hints/sco_$1_$2.sh; then
3649						osvers=$1.$2
3650					elif $test -f $src/hints/sco_$1.sh; then
3651						osvers=$1
3652					fi
3653				else
3654					case "$osname" in
3655					'') : Still unknown.  Probably a generic Sys V.
3656						osname="sysv"
3657						osvers="$3"
3658						;;
3659					esac
3660				fi
3661				;;
3662			esac
3663			;;
3664		*)	case "$osname" in
3665			'') : Still unknown.  Probably a generic BSD.
3666				osname="$1"
3667				osvers="$3"
3668				;;
3669			esac
3670			;;
3671		esac
3672	else
3673		if test -f /vmunix -a -f $src/hints/news_os.sh; then
3674			(what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
3675			if $contains news-os UU/kernel.what >/dev/null 2>&1; then
3676				osname=news_os
3677			fi
3678			$rm -f UU/kernel.what
3679		elif test -d c:/. -o -n "$is_os2" ; then
3680			set X $myuname
3681			osname=os2
3682			osvers="$5"
3683		fi
3684	fi
3685
3686	case "$targetarch" in
3687	'') ;;
3688	*)  hostarch=$osname
3689	    case "$targetarch" in
3690		nto*|*-nto-*)
3691		    # Will load qnx.sh, which should change osname to nto
3692		    osname=qnx
3693		    osvers=''
3694		    ;;
3695		*linux-android*)
3696		    # Catch arm-linux-androideabi, mipsel-linux-android,
3697		    # and i686-linux-android
3698		    osname=linux-android
3699		    osvers=''
3700		    ;;
3701		*linux*)
3702		    # Something like arm-linux-gnueabihf is really just
3703		    # plain linux.
3704		    osname=linux
3705		    osvers=''
3706		    ;;
3707		*solaris*|*sunos*)
3708		    osname=solaris
3709		    # XXX perhaps we should just assume
3710		    # osvers to be 2, or maybe take the value
3711		    # from targetarch. Using $run before the
3712		    # hints are run is somewhat icky.
3713		    set X `$run $uname -a 2>/dev/null`
3714		    shift
3715		    case "$3" in
3716			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3717			*)  osvers="$3" ;;
3718		    esac
3719		    ;;
3720		*)
3721		    osname=`echo $targetarch|sed 's,^[^-]*-,,'`
3722		    osvers=''
3723		;;
3724	    esac
3725	    ;;
3726	esac
3727
3728	: Now look for a hint file osname_osvers, unless one has been
3729	: specified already.
3730	case "$hintfile" in
3731	''|' ')
3732		file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'`
3733		: Also try without trailing minor version numbers.
3734		xfile=`echo $file | $sed -e 's%_[^_]*$%%'`
3735		xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'`
3736		xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'`
3737		xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'`
3738		case "$file" in
3739		'') dflt=none ;;
3740		*)  case "$osvers" in
3741			'') dflt=$file
3742				;;
3743			*)  if $test -f $src/hints/$file.sh ; then
3744					dflt=$file
3745				elif $test -f $src/hints/$xfile.sh ; then
3746					dflt=$xfile
3747				elif $test -f $src/hints/$xxfile.sh ; then
3748					dflt=$xxfile
3749				elif $test -f $src/hints/$xxxfile.sh ; then
3750					dflt=$xxxfile
3751				elif $test -f $src/hints/$xxxxfile.sh ; then
3752					dflt=$xxxxfile
3753				elif $test -f "$src/hints/${osname}.sh" ; then
3754					dflt="${osname}"
3755				else
3756					dflt=none
3757				fi
3758				;;
3759			esac
3760			;;
3761		esac
3762		if $test -f Policy.sh ; then
3763			case "$dflt" in
3764			*Policy*) ;;
3765			none) dflt="Policy" ;;
3766			*) dflt="Policy $dflt" ;;
3767			esac
3768		fi
3769		;;
3770	*)
3771		dflt=`echo $hintfile | $sed 's/\.sh$//'`
3772		;;
3773	esac
3774
3775	if $test -f Policy.sh ; then
3776		$cat <<EOM
3777
3778There's also a Policy hint file available, which should make the
3779site-specific (policy) questions easier to answer.
3780EOM
3781
3782	fi
3783
3784	$cat <<EOM
3785
3786You may give one or more space-separated answers, or "none" if appropriate.
3787If you have a handcrafted Policy.sh file or a Policy.sh file generated by a
3788previous run of Configure, you may specify it as well as or instead of
3789OS-specific hints.  If hints are provided for your OS, you should use them:
3790although Perl can probably be built without hints on many platforms, using
3791hints often improve performance and may enable features that Configure can't
3792set up on its own. If there are no hints that match your OS, specify "none";
3793DO NOT give a wrong version or a wrong OS.
3794
3795EOM
3796
3797	rp="Which of these apply, if any?"
3798	. UU/myread
3799	tans=$ans
3800	for file in $tans; do
3801		if $test X$file = XPolicy -a -f Policy.sh; then
3802			. Policy.sh
3803			$cat Policy.sh >> UU/config.sh
3804		elif $test -f $src/hints/$file.sh; then
3805			. $src/hints/$file.sh
3806			$cat $src/hints/$file.sh >> UU/config.sh
3807		elif $test X"$tans" = X -o X"$tans" = Xnone ; then
3808			: nothing
3809		else
3810			: Give one chance to correct a possible typo.
3811			echo "$file.sh does not exist"
3812			dflt=$file
3813			rp="hint to use instead?"
3814			. UU/myread
3815			for file in $ans; do
3816				if $test -f "$src/hints/$file.sh"; then
3817					. $src/hints/$file.sh
3818					$cat $src/hints/$file.sh >> UU/config.sh
3819				elif $test X$ans = X -o X$ans = Xnone ; then
3820					: nothing
3821				else
3822					echo "$file.sh does not exist -- ignored."
3823				fi
3824			done
3825		fi
3826	done
3827
3828	hint=recommended
3829	: Remember our hint file for later.
3830	if $test -f "$src/hints/$file.sh" ; then
3831		hintfile="$file"
3832	else
3833		hintfile=''
3834	fi
3835fi
3836cd UU
3837;;
3838*)
3839	echo " "
3840	echo "Fetching default answers from $config_sh..." >&4
3841	tmp_n="$n"
3842	tmp_c="$c"
3843	cd ..
3844	cp $config_sh config.sh 2>/dev/null
3845	chmod +w config.sh
3846	. ./config.sh
3847	cd UU
3848	cp ../config.sh .
3849	n="$tmp_n"
3850	c="$tmp_c"
3851	hint=previous
3852	;;
3853esac
3854. ./optdef.sh
3855
3856: Restore computed paths
3857for file in $loclist $trylist; do
3858	eval $file="\$_$file"
3859done
3860
3861cat << EOM
3862
3863Configure uses the operating system name and version to set some defaults.
3864The default value is probably right if the name rings a bell. Otherwise,
3865since spelling matters for me, either accept the default or answer "none"
3866to leave it blank.
3867
3868EOM
3869case "$osname" in
3870	''|' ')
3871		case "$hintfile" in
3872		''|' '|none) dflt=none ;;
3873		*)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
3874		esac
3875		;;
3876	*) dflt="$osname" ;;
3877esac
3878rp="Operating system name?"
3879. ./myread
3880case "$ans" in
3881none)  osname='' ;;
3882*) osname=`echo "$ans" | $sed -e 's/[ 	][	]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
3883esac
3884echo " "
3885case "$osvers" in
3886	''|' ')
3887		case "$hintfile" in
3888		''|' '|none) dflt=none ;;
3889		*)	dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
3890			dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
3891			case "$dflt" in
3892			''|' ') dflt=none ;;
3893			esac
3894			;;
3895		esac
3896		;;
3897	*) dflt="$osvers" ;;
3898esac
3899rp="Operating system version?"
3900. ./myread
3901case "$ans" in
3902none)  osvers='' ;;
3903*) osvers="$ans" ;;
3904esac
3905
3906
3907. ./posthint.sh
3908
3909: who configured the system
3910cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
3911case "$cf_by" in
3912"")
3913	cf_by=`(logname) 2>/dev/null`
3914	case "$cf_by" in
3915	"")
3916		cf_by=`(whoami) 2>/dev/null`
3917		case "$cf_by" in
3918		"") cf_by=unknown ;;
3919		esac ;;
3920	esac ;;
3921esac
3922
3923: decide how portable to be.  Allow command line overrides.
3924case "$d_portable" in
3925"$undef") ;;
3926*)	d_portable="$define" ;;
3927esac
3928
3929: set up shell script to do ~ expansion
3930cat >filexp <<EOSS
3931$startsh
3932: expand filename
3933case "\$1" in
3934 \~/*|\~)
3935	echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
3936	;;
3937 \~*)
3938	if $test -f /bin/csh; then
3939		/bin/csh -f -c "glob \$1"
3940		failed=\$?
3941		echo ""
3942		exit \$failed
3943	else
3944		name=\`$expr x\$1 : '..\([^/]*\)'\`
3945		dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
3946		if $test ! -d "\$dir"; then
3947			me=\`basename \$0\`
3948			echo "\$me: can't locate home directory for: \$name" >&2
3949			exit 1
3950		fi
3951		case "\$1" in
3952		*/*)
3953			echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
3954			;;
3955		*)
3956			echo \$dir
3957			;;
3958		esac
3959	fi
3960	;;
3961*)
3962	echo \$1
3963	;;
3964esac
3965EOSS
3966chmod +x filexp
3967$eunicefix filexp
3968
3969: now set up to get a file name
3970cat <<EOS >getfile
3971$startsh
3972EOS
3973cat <<'EOSC' >>getfile
3974tilde=''
3975fullpath=''
3976already=''
3977skip=''
3978none_ok=''
3979exp_file=''
3980nopath_ok=''
3981orig_rp="$rp"
3982orig_dflt="$dflt"
3983case "$gfpth" in
3984'') gfpth='.' ;;
3985esac
3986
3987case "$fn" in
3988*\(*)
3989	: getfile will accept an answer from the comma-separated list
3990	: enclosed in parentheses even if it does not meet other criteria.
3991	expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
3992	fn=`echo $fn | sed 's/(.*)//'`
3993	;;
3994esac
3995
3996case "$fn" in
3997*:*)
3998	loc_file=`expr $fn : '.*:\(.*\)'`
3999	fn=`expr $fn : '\(.*\):.*'`
4000	;;
4001esac
4002
4003case "$fn" in
4004*~*) tilde=true;;
4005esac
4006case "$fn" in
4007*/*) fullpath=true;;
4008esac
4009case "$fn" in
4010*+*) skip=true;;
4011esac
4012case "$fn" in
4013*n*) none_ok=true;;
4014esac
4015case "$fn" in
4016*e*) exp_file=true;;
4017esac
4018case "$fn" in
4019*p*) nopath_ok=true;;
4020esac
4021
4022case "$fn" in
4023*f*) type='File';;
4024*d*) type='Directory';;
4025*l*) type='Locate';;
4026esac
4027
4028what="$type"
4029case "$what" in
4030Locate) what='File';;
4031esac
4032
4033case "$exp_file" in
4034'')
4035	case "$d_portable" in
4036	"$define") ;;
4037	*) exp_file=true;;
4038	esac
4039	;;
4040esac
4041
4042cd ..
4043while test "$type"; do
4044	redo=''
4045	rp="$orig_rp"
4046	dflt="$orig_dflt"
4047	case "$tilde" in
4048	true) rp="$rp (~name ok)";;
4049	esac
4050	. UU/myread
4051	if test -f UU/getfile.ok && \
4052		$contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
4053	then
4054		value="$ans"
4055		ansexp="$ans"
4056		break
4057	fi
4058	case "$ans" in
4059	none)
4060		value=''
4061		ansexp=''
4062		case "$none_ok" in
4063		true) type='';;
4064		esac
4065		;;
4066	*)
4067		case "$tilde" in
4068		'') value="$ans"
4069			ansexp="$ans";;
4070		*)
4071			value=`UU/filexp $ans`
4072			case $? in
4073			0)
4074				if test "$ans" != "$value"; then
4075					echo "(That expands to $value on this system.)"
4076				fi
4077				;;
4078			*) value="$ans";;
4079			esac
4080			ansexp="$value"
4081			case "$exp_file" in
4082			'') value="$ans";;
4083			esac
4084			;;
4085		esac
4086		case "$fullpath" in
4087		true)
4088			case "$ansexp" in
4089			/*) value="$ansexp" ;;
4090			[a-zA-Z]:/*) value="$ansexp" ;;
4091			*)
4092				redo=true
4093				case "$already" in
4094				true)
4095				echo "I shall only accept a full path name, as in /bin/ls." >&4
4096				echo "Use a ! shell escape if you wish to check pathnames." >&4
4097					;;
4098				*)
4099				echo "Please give a full path name, starting with slash." >&4
4100					case "$tilde" in
4101					true)
4102				echo "Note that using ~name is ok provided it expands well." >&4
4103						already=true
4104						;;
4105					esac
4106				esac
4107				;;
4108			esac
4109			;;
4110		esac
4111		case "$redo" in
4112		'')
4113			case "$type" in
4114			File)
4115				for fp in $gfpth; do
4116					if test "X$fp" = X.; then
4117					    pf="$ansexp"
4118					else    
4119					    pf="$fp/$ansexp"
4120					fi
4121					if test -f "$pf"; then
4122						type=''
4123					elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
4124					then
4125						echo "($value is not a plain file, but that's ok.)"
4126						type=''
4127					fi
4128					if test X"$type" = X; then
4129					    value="$pf"
4130					    break
4131					fi
4132				done
4133				;;
4134			Directory)
4135				for fp in $gfpth; do
4136					if test "X$fp" = X.; then
4137					    dir="$ans"
4138					    direxp="$ansexp"
4139					else    
4140					    dir="$fp/$ansexp"
4141					    direxp="$fp/$ansexp"
4142					fi
4143					if test -d "$direxp"; then
4144						type=''
4145						value="$dir"
4146						break
4147					fi
4148				done
4149				;;
4150			Locate)
4151				if test -d "$ansexp"; then
4152					echo "(Looking for $loc_file in directory $value.)"
4153					value="$value/$loc_file"
4154					ansexp="$ansexp/$loc_file"
4155				fi
4156				if test -f "$ansexp"; then
4157					type=''
4158				fi
4159				case "$nopath_ok" in
4160				true)	case "$value" in
4161					*/*) ;;
4162					*)	echo "Assuming $value will be in people's path."
4163						type=''
4164						;;
4165					esac
4166					;;
4167				esac
4168				;;
4169			esac
4170
4171			case "$skip" in
4172			true) type='';
4173			esac
4174
4175			case "$type" in
4176			'') ;;
4177			*)
4178				if test "$fastread" = yes; then
4179					dflt=y
4180				else
4181					dflt=n
4182				fi
4183				rp="$what $value doesn't exist.  Use that name anyway?"
4184				. UU/myread
4185				dflt=''
4186				case "$ans" in
4187				y*) type='';;
4188				*) echo " ";;
4189				esac
4190				;;
4191			esac
4192			;;
4193		esac
4194		;;
4195	esac
4196done
4197cd UU
4198ans="$value"
4199rp="$orig_rp"
4200dflt="$orig_dflt"
4201rm -f getfile.ok
4202test "X$gfpthkeep" != Xy && gfpth=""
4203EOSC
4204
4205: determine root of directory hierarchy where package will be installed.
4206case "$prefix" in
4207'')	dflt=`./loc . /usr/local /usr/local /local /opt /usr`
4208	;;
4209*)	dflt="$prefix"
4210	;;
4211esac
4212$cat <<EOM
4213
4214By default, $package will be installed in $dflt/bin, manual pages
4215under $dflt/man, etc..., i.e. with $dflt as prefix for all
4216installation directories. Typically this is something like /usr/local.
4217If you wish to have binaries under /usr/bin but other parts of the
4218installation under /usr/local, that's ok: you will be prompted
4219separately for each of the installation directories, the prefix being
4220only used to set the defaults.
4221
4222EOM
4223fn=d~
4224rp='Installation prefix to use?'
4225. ./getfile
4226oldprefix=''
4227case "$prefix" in
4228'')	;;
4229*)	case "$ans" in
4230	"$prefix") ;;
4231	*) oldprefix="$prefix";;
4232	esac
4233	;;
4234esac
4235
4236case "$ans" in
4237*?/)	prefix=`echo "$ans" | sed 's/.$//'`
4238	;;
4239*)	prefix="$ans"
4240esac
4241
4242case "$ansexp" in
4243*?/)	prefixexp=`echo "$ansexp" | sed 's/.$//'`
4244	;;
4245*)	prefixexp="$ansexp"
4246esac
4247
4248: allow them to override the AFS root
4249case "$afsroot" in
4250'')	afsroot=/afs ;;
4251*)	afsroot=$afsroot ;;
4252esac
4253
4254: is AFS running?
4255echo " "
4256case "$afs" in
4257$define|true)	afs=true ;;
4258$undef|false)	afs=false ;;
4259*)	if $test -d $afsroot; then
4260		afs=true
4261	else
4262		afs=false
4263	fi
4264	;;
4265esac
4266if $afs; then
4267	echo "AFS may be running... I'll be extra cautious then..." >&4
4268else
4269	echo "AFS does not seem to be running..." >&4
4270fi
4271
4272: determine installation prefix for where package is to be installed.
4273if $afs; then
4274$cat <<EOM
4275
4276Since you are running AFS, I need to distinguish the directory in which
4277files will reside from the directory in which they are installed (and from
4278which they are presumably copied to the former directory by occult means).
4279
4280EOM
4281	case "$installprefix" in
4282	'') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
4283	*) dflt="$installprefix";;
4284	esac
4285else
4286$cat <<EOM
4287
4288In some special cases, particularly when building $package for distribution,
4289it is convenient to distinguish the directory in which files should be
4290installed from the directory ($prefix) in which they will
4291eventually reside.  For most users, these two directories are the same.
4292
4293EOM
4294	case "$installprefix" in
4295	'') dflt=$prefix ;;
4296	*) dflt=$installprefix;;
4297	esac
4298fi
4299fn=d~
4300rp='What installation prefix should I use for installing files?'
4301. ./getfile
4302installprefix="$ans"
4303installprefixexp="$ansexp"
4304
4305: Perform the prefixexp/installprefixexp correction if necessary
4306cat <<EOS >installprefix
4307$startsh
4308EOS
4309cat <<'EOSC' >>installprefix
4310: Change installation prefix, if necessary.
4311if $test X"$prefix" != X"$installprefix"; then
4312    eval "install${prefixvar}=\`echo \$${prefixvar}exp | sed \"s#^\$prefixexp#\$installprefixexp#\"\`"
4313else
4314    eval "install${prefixvar}=\"\$${prefixvar}exp\""
4315fi
4316EOSC
4317chmod +x installprefix
4318$eunicefix installprefix
4319
4320: Set variables such as privlib and privlibexp from the output of ./getfile
4321: performing the prefixexp/installprefixexp correction if necessary.
4322cat <<EOS >setprefixvar
4323$startsh
4324EOS
4325cat <<'EOSC' >>setprefixvar
4326eval "${prefixvar}=\"\$ans\""
4327eval "${prefixvar}exp=\"\$ansexp\""
4328. ./installprefix
4329EOSC
4330chmod +x setprefixvar
4331$eunicefix setprefixvar
4332
4333: set up the script used to warn in case of inconsistency
4334cat <<EOS >whoa
4335$startsh
4336EOS
4337cat <<'EOSC' >>whoa
4338dflt=y
4339case "$hint" in
4340    recommended)
4341	case "$hintfile" in
4342	'')	echo "The $hint value for \$$var on this machine was \"$was\"!" >&4
4343		;;
4344	*)	echo "Hmm.  Based on the hints in hints/$hintfile.sh, " >&4
4345		echo "the $hint value for \$$var on this machine was \"$was\"!" >&4
4346		;;
4347	esac
4348	;;
4349    *)	echo " "
4350	echo "*** WHOA THERE!!! ***" >&4
4351	echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
4352	;;
4353esac
4354rp="    Keep the $hint value?"
4355. ./myread
4356case "$ans" in
4357y) td=$was; tu=$was;;
4358esac
4359EOSC
4360
4361: function used to set '$1' to '$val'
4362setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
4363case "$val$was" in
4364$define$undef) . ./whoa; eval "$var=\$td";;
4365$undef$define) . ./whoa; eval "$var=\$tu";;
4366*) eval "$var=$val";;
4367esac'
4368
4369: Do we want threads support and if so, what type
4370case "$usethreads" in
4371$define|true|[yY]*)     dflt='y';;
4372*)     # Catch case where user specified ithreads but
4373       # forgot -Dusethreads (A.D. 4/2002)
4374       case "$useithreads" in
4375       *$define*)	dflt='y';;
4376       *)		dflt='n';;
4377       esac
4378       ;;
4379esac
4380cat <<EOM
4381
4382Perl can be built to offer a form of threading support on some systems
4383To do so, Configure can be run with -Dusethreads.
4384
4385Note that Perl built with threading support runs slightly slower
4386and uses slightly more memory than plain Perl.
4387
4388If this doesn't make any sense to you, just accept the default '$dflt'.
4389EOM
4390rp='Build a threading Perl?'
4391. ./myread
4392case "$ans" in
4393y|Y)    val="$define" ;;
4394*)      val="$undef" ;;
4395esac
4396set usethreads
4397eval $setvar
4398
4399useithreads="$usethreads"
4400
4401case "$d_oldpthreads" in
4402'')	: Configure tests would be welcome here.  For now, assume undef.
4403	val="$undef" ;;
4404*)	val="$d_oldpthreads" ;;
4405esac
4406set d_oldpthreads
4407eval $setvar
4408
4409
4410: Look for a hint-file generated 'call-back-unit'.  If the
4411: user has specified that a threading perl is to be built,
4412: we may need to set or change some other defaults.
4413if $test -f usethreads.cbu; then
4414    echo "Your platform has some specific hints regarding threaded builds, using them..."
4415    . ./usethreads.cbu
4416else
4417    case "$usethreads" in
4418	"$define"|true|[yY]*)
4419		$cat <<EOM
4420(Your platform does not have any specific hints for threaded builds.
4421 Assuming POSIX threads, then.)
4422EOM
4423	;;
4424    esac
4425fi
4426
4427: Check if multiplicity is required
4428cat <<EOM
4429
4430Perl can be built so that multiple Perl interpreters can coexist
4431within the same Perl executable.
4432EOM
4433
4434case "$useithreads" in
4435$define)
4436	cat <<EOM
4437This multiple interpreter support is required for interpreter-based threads.
4438EOM
4439	val="$define"
4440	;;
4441*)	case "$usemultiplicity" in
4442	$define|true|[yY]*)	dflt='y';;
4443	*) dflt='n';;
4444	esac
4445	echo " "
4446	echo "If this doesn't make any sense to you, just accept the default '$dflt'."
4447	rp='Build Perl for multiplicity?'
4448	. ./myread
4449	case "$ans" in
4450	y|Y)	val="$define" ;;
4451	*)      val="$undef" ;;
4452	esac
4453	;;
4454esac
4455set usemultiplicity
4456eval $setvar
4457
4458: Check if morebits is requested
4459case "$usemorebits" in
4460"$define"|true|[yY]*)
4461	use64bitint="$define"
4462	uselongdouble="$define"
4463	usemorebits="$define"
4464	;;
4465*)	usemorebits="$undef"
4466	;;
4467esac
4468
4469: Determine the C compiler to be used
4470echo " "
4471case "$cc" in
4472'') dflt=cc;;
4473*) dflt="$cc";;
4474esac
4475rp="Use which C compiler?"
4476. ./myread
4477cc="$ans"
4478
4479: See whether they have no cc but they do have gcc
4480. ./trygcc
4481if $test -f cc.cbu; then
4482    . ./cc.cbu
4483fi
4484. ./checkcc
4485
4486: make some quick guesses about what we are up against
4487echo " "
4488$echo $n "Hmm...  $c"
4489echo exit 1 >bsd
4490echo exit 1 >usg
4491echo exit 1 >v7
4492echo exit 1 >osf1
4493echo exit 1 >eunice
4494echo exit 1 >xenix
4495echo exit 1 >venix
4496echo exit 1 >os2
4497d_bsd="$undef"
4498$cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null
4499if test -f /osf_boot || $contains 'OSF/1' $sysroot/usr/include/ctype.h >/dev/null 2>&1
4500then
4501	echo "Looks kind of like an OSF/1 system, but we'll see..."
4502	echo exit 0 >osf1
4503elif test `echo abc | $tr a-z A-Z` = Abc ; then
4504	xxx=`./loc addbib blurfl $pth`
4505	if $test -f $xxx; then
4506	echo "Looks kind of like a USG system with BSD features, but we'll see..."
4507		echo exit 0 >bsd
4508		echo exit 0 >usg
4509	else
4510		if $contains SIGTSTP foo >/dev/null 2>&1 ; then
4511			echo "Looks kind of like an extended USG system, but we'll see..."
4512		else
4513			echo "Looks kind of like a USG system, but we'll see..."
4514		fi
4515		echo exit 0 >usg
4516	fi
4517elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
4518	echo "Looks kind of like a BSD system, but we'll see..."
4519	d_bsd="$define"
4520	echo exit 0 >bsd
4521else
4522	echo "Looks kind of like a Version 7 system, but we'll see..."
4523	echo exit 0 >v7
4524fi
4525case "$eunicefix" in
4526*unixtovms*)
4527	$cat <<'EOI'
4528There is, however, a strange, musty smell in the air that reminds me of
4529something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
4530EOI
4531	echo exit 0 >eunice
4532	d_eunice="$define"
4533: it so happens the Eunice I know will not run shell scripts in Unix format
4534	;;
4535*)
4536	echo " "
4537	echo "Congratulations.  You aren't running Eunice."
4538	d_eunice="$undef"
4539	;;
4540esac
4541: Detect OS2.  The p_ variable is set above in the Head.U unit.
4542: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
4543: semicolon as a patch separator
4544case "$p_" in
4545:) ;;
4546*)
4547	$cat <<'EOI'
4548I have the feeling something is not exactly right, however...don't tell me...
4549lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
4550(Or you may be running DOS with DJGPP.)
4551EOI
4552	echo exit 0 >os2
4553	;;
4554esac
4555if test -f /xenix; then
4556	echo "Actually, this looks more like a XENIX system..."
4557	echo exit 0 >xenix
4558	d_xenix="$define"
4559else
4560	echo " "
4561	echo "It's not Xenix..."
4562	d_xenix="$undef"
4563fi
4564chmod +x xenix
4565$eunicefix xenix
4566if test -f /venix; then
4567	echo "Actually, this looks more like a VENIX system..."
4568	echo exit 0 >venix
4569else
4570	echo " "
4571	if ./xenix; then
4572		: null
4573	else
4574		echo "Nor is it Venix..."
4575	fi
4576fi
4577chmod +x bsd usg v7 osf1 eunice xenix venix os2
4578$eunicefix bsd usg v7 osf1 eunice xenix venix os2
4579$rm -f foo
4580
4581: Check if we are using GNU gcc and what its version is
4582echo " "
4583echo "Checking for GNU cc in disguise and/or its version number..." >&4
4584$cat >try.c <<EOM
4585#include <stdio.h>
4586int main() {
4587#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
4588#ifdef __VERSION__
4589	printf("%s\n", __VERSION__);
4590#else
4591	printf("%s\n", "1");
4592#endif
4593#endif
4594	return(0);
4595}
4596EOM
4597if $cc -o try $ccflags $ldflags try.c; then
4598	gccversion=`$run ./try`
4599	case "$gccversion" in
4600	'') echo "You are not using GNU cc." ;;
4601	*)  echo "You are using GNU cc $gccversion."
4602	    ccname=gcc
4603	    ;;
4604	esac
4605else
4606	echo " "
4607	echo "*** WHOA THERE!!! ***" >&4
4608	echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
4609	case "$knowitall" in
4610	'')
4611	echo "    You'd better start hunting for one and let me know about it." >&4
4612		exit 1
4613		;;
4614	esac
4615fi
4616$rm -f try try.*
4617case "$gccversion" in
46181.*) cpp=`./loc gcc-cpp $cpp $pth` ;;
4619esac
4620case "$gccversion" in
4621'') gccosandvers='' ;;
4622*) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
4623   gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
4624   gccshortvers=''
4625   case "$gccosandvers" in
4626   $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
4627   $osname$osvers) ;; # looking good
4628   $osname*) cat <<EOM >&4
4629
4630*** WHOA THERE!!! ***
4631
4632    Your gcc has not been compiled for the exact release of
4633    your operating system ($gccosandvers versus $osname$osvers).
4634
4635    In general it is a good idea to keep gcc synchronized with
4636    the operating system because otherwise serious problems
4637    may ensue when trying to compile software, like Perl.
4638
4639    I'm trying to be optimistic here, though, and will continue.
4640    If later during the configuration and build icky compilation
4641    problems appear (headerfile conflicts being the most common
4642    manifestation), I suggest reinstalling the gcc to match
4643    your operating system release.
4644
4645EOM
4646      ;;
4647   *) gccosandvers='' ;; # failed to parse, better be silent
4648   esac
4649   ;;
4650esac
4651case "$ccname" in
4652'') ccname="$cc" ;;
4653esac
4654
4655# gcc 3.* complain about adding -Idirectories that they already know about,
4656# so we will take those off from locincpth.
4657case "$gccversion" in
46583.*)
4659    echo "int main(){}">try.c
4660    for incdir in $locincpth; do
4661       warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
4662	     grep '^c[cp]p*[01]: warning: changing search order '`
4663       if test "X$warn" != X; then
4664	   locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
4665       fi
4666    done
4667    $rm -f try try.*
4668esac
4669
4670# gcc 4.9 by default does some optimizations that break perl.
4671# see ticket 121505.
4672#
4673# The -fwrapv disables those optimizations (and probably others,) so
4674# for gcc 4.9 (and later, since the optimizations probably won't go
4675# away), add -fwrapv unless the user requests -fno-wrapv, which
4676# disables -fwrapv, or if the user requests -fsanitize=undefined,
4677# which turns the overflows -fwrapv ignores into runtime errors.
4678case "$gccversion" in
46794.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*)
4680    case "$ccflags" in
4681    *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
4682    *) ccflags="$ccflags -fwrapv" ;;
4683    esac
4684esac
4685
4686# Really old versions of gcc default to C89 and will error for this code.
4687# See if the compiler (gcc or otherwise) needs a flag to compile C99 code
4688# Initialisations in for loops seem to be the particular problem
4689# (Does this syntax conflict with something else that was valid C89?)
4690# We also add a declaration after a statement to detect whether the compiler
4691# (or the user supplied -Accflags) consider such declarations to be errors.
4692# This causes 'Configure with -Accflags="-Werror=declaration-after-statement"'
4693# to fail hard and early.
4694#
4695# Annoyingly -std=c99 will cause gcc to tell glibc not to define prototypes for
4696# syscall, drand48 etc when including <unistd.h>, which messes up our build.
4697# I guess we *could* loop round trying -std=c99 first with checks both for the
4698# prototype found and the code compiling (because -std=gnu99 might do other
4699# things we don't want, particularly on non-GCC compilers) but
4700# 1) We would need to check for the prototype first (without any flags)
4701# 2) We would still end up with most Linux systems either being -std=gnu99
4702#    or "" (no flag), and so both common options would not rigorously check our
4703#    portability to other platforms.
4704# So it doesn't seem worth the complexity and chance of different failure.
4705$cat >try.c <<'EOCP'
4706int main(int argc, char **argv) {
4707    argc = argc + 1;
4708    /* This is deliberately a declaration after a statement. */
4709    unsigned long long count = 0;
4710    for (char **p = argv; *p; ++p) {
4711        ++count;
4712    }
4713    return count == 1 ? 0 : argc;
4714}
4715EOCP
4716c99_for=no
4717for flag in '' '-std=gnu99' '-std=c99'; do
4718    if $cc -o try $flag $ccflags $ldflags try.c 2>/dev/null && ./try; then
4719        c99_for="$flag"
4720        break;
4721    fi
4722done
4723case "$c99_for" in
4724'') echo "Your C compiler doesn't need any special flags to compile C99 code"
4725    ;;
4726no) echo >&4 "Your C compiler doesn't seem to be able to compile C99 code"
4727    rp='Do you really want to continue?'
4728    dflt='n'
4729    . ./myread
4730    case "$ans" in
4731	[yY])	echo >&4 "Okay, continuing."	;;
4732	*)	exit 1				;;
4733    esac
4734    ;;
4735*)  echo "Your C compiler needs $c99_for to compile C99 code"
4736    ccflags="$c99_for $ccflags"
4737    ;;
4738esac
4739$rm -f try try.*
4740
4741: What should the include directory be ?
4742: Use sysroot if set, so findhdr looks in the right place.
4743echo " "
4744$echo $n "Hmm...  $c"
4745dflt="$sysroot/usr/include"
4746incpath=''
4747mips_type=''
4748if $test -f /bin/mips && /bin/mips; then
4749	echo "Looks like a MIPS system..."
4750	$cat >usr.c <<'EOCP'
4751#ifdef SYSTYPE_BSD43
4752/bsd43
4753#endif
4754EOCP
4755	if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
4756		dflt='/bsd43/usr/include'
4757		incpath='/bsd43'
4758		mips_type='BSD 4.3'
4759	else
4760		mips_type='System V'
4761	fi
4762	$rm -f usr.c usr.out
4763	echo "and you're compiling with the $mips_type compiler and libraries."
4764	xxx_prompt=y
4765	echo "exit 0" >mips
4766else
4767	echo "Doesn't look like a MIPS system."
4768	xxx_prompt=n
4769	echo "exit 1" >mips
4770fi
4771chmod +x mips
4772$eunicefix mips
4773case "$usrinc" in
4774'') ;;
4775*) dflt="$usrinc";;
4776esac
4777case "$xxx_prompt" in
4778y)	fn=d/
4779	echo " "
4780	rp='Where are the include files you want to use?'
4781	. ./getfile
4782	usrinc="$ans"
4783	;;
4784*)	usrinc="$dflt"
4785	;;
4786esac
4787
4788: see how we invoke the C preprocessor
4789echo " "
4790echo "Now, how can we feed standard input to your C preprocessor..." >&4
4791cat <<'EOT' >testcpp.c
4792#define ABC abc
4793#define XYZ xyz
4794ABC.XYZ
4795EOT
4796cd ..
4797if test ! -f cppstdin; then
4798	if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
4799		# AIX cc -E doesn't show the absolute headerfile
4800		# locations but we'll cheat by using the -M flag.
4801		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
4802	else
4803		echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
4804	fi
4805else
4806	echo "Keeping your $hint cppstdin wrapper."
4807fi
4808chmod 755 cppstdin
4809wrapper=`pwd`/cppstdin
4810ok='false'
4811cd UU
4812
4813if $test "X$cppstdin" != "X" && \
4814	$cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
4815	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4816then
4817	echo "You used to use $cppstdin $cppminus so we'll use that again."
4818	case "$cpprun" in
4819	'') echo "But let's see if we can live without a wrapper..." ;;
4820	*)
4821		if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
4822			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4823		then
4824			echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
4825			ok='true'
4826		else
4827			echo "(However, $cpprun $cpplast does not work, let's see...)"
4828		fi
4829		;;
4830	esac
4831else
4832	case "$cppstdin" in
4833	'') ;;
4834	*)
4835		echo "Good old $cppstdin $cppminus does not seem to be of any help..."
4836		;;
4837	esac
4838fi
4839
4840if $ok; then
4841	: nothing
4842elif echo 'Maybe "'"$cc"' -E" will work...'; \
4843	$cc -E <testcpp.c >testcpp.out 2>&1; \
4844	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4845	echo "Yup, it does."
4846	x_cpp="$cc $cppflags -E"
4847	x_minus='';
4848elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
4849	$cc -E - <testcpp.c >testcpp.out 2>&1; \
4850	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4851	echo "Yup, it does."
4852	x_cpp="$cc $cppflags -E"
4853	x_minus='-';
4854elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
4855	$cc -P <testcpp.c >testcpp.out 2>&1; \
4856	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4857	echo "Yipee, that works!"
4858	x_cpp="$cc $cppflags -P"
4859	x_minus='';
4860elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
4861	$cc -P - <testcpp.c >testcpp.out 2>&1; \
4862	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4863	echo "At long last!"
4864	x_cpp="$cc $cppflags -P"
4865	x_minus='-';
4866elif echo 'No such luck, maybe "'$cpp'" will work...'; \
4867	$cpp <testcpp.c >testcpp.out 2>&1; \
4868	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4869	echo "It works!"
4870	x_cpp="$cpp $cppflags"
4871	x_minus='';
4872elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
4873	$cpp - <testcpp.c >testcpp.out 2>&1; \
4874	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4875	echo "Hooray, it works!  I was beginning to wonder."
4876	x_cpp="$cpp $cppflags"
4877	x_minus='-';
4878elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
4879	$wrapper <testcpp.c >testcpp.out 2>&1; \
4880	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4881	x_cpp="$wrapper"
4882	x_minus=''
4883	echo "Eureka!"
4884else
4885	dflt=''
4886	rp="No dice.  I can't find a C preprocessor.  Name one:"
4887	. ./myread
4888	x_cpp="$ans"
4889	x_minus=''
4890	$x_cpp <testcpp.c >testcpp.out 2>&1
4891	if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4892		echo "OK, that will do." >&4
4893	else
4894echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
4895		exit 1
4896	fi
4897fi
4898
4899case "$ok" in
4900false)
4901	cppstdin="$x_cpp"
4902	cppminus="$x_minus"
4903	cpprun="$x_cpp"
4904	cpplast="$x_minus"
4905	set X $x_cpp
4906	shift
4907	case "$1" in
4908	"$cpp")
4909		echo "Perhaps can we force $cc -E using a wrapper..."
4910		if $wrapper <testcpp.c >testcpp.out 2>&1; \
4911			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4912		then
4913			echo "Yup, we can."
4914			cppstdin="$wrapper"
4915			cppminus='';
4916		else
4917			echo "Nope, we'll have to live without it..."
4918		fi
4919		;;
4920	esac
4921	case "$cpprun" in
4922	"$wrapper")
4923		cpprun=''
4924		cpplast=''
4925		;;
4926	esac
4927	;;
4928esac
4929
4930case "$cppstdin" in
4931"$wrapper"|'cppstdin') ;;
4932*) $rm -f $wrapper;;
4933esac
4934$rm -f testcpp.c testcpp.out
4935
4936: Adjust cppfilter for path component separator
4937case "$osname" in
4938vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
4939os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
4940*)   cppfilter='' ;;
4941esac
4942
4943: Use gcc to determine libpth and incpth
4944# If using gcc or clang, we can get better values for libpth, incpth
4945# and usrinc directly from the compiler.
4946# Note that ccname for clang is also gcc.
4947case "$ccname" in
4948    gcc)
4949	realpath=`which realpath 2>/dev/null | sed 's/no realpath in.*//'`
4950	$echo 'extern int foo;' > try.c
4951	set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
4952	shift
4953	inclibpth=""
4954	if $test $# -gt 0; then
4955	    for i in $*; do
4956		case $realpath in
4957		    */realpath) i=`$realpath $i` ;;
4958		esac
4959		incpth="$incpth $i"
4960		j="`$echo $i | $sed 's,/include[^/]*,/lib,'`"
4961		if $test -d $j; then
4962		    inclibpth="$inclibpth $j"
4963		fi
4964	    done
4965	    incpth="`$echo $incpth | $sed 's/^ //'`"
4966	    for xxx in $inclibpth $loclibpth $plibpth $glibpth; do
4967		if $test -d $xxx; then
4968		    case $realpath in
4969			*/realpath) xxx=`$realpath $xxx` ;;
4970		    esac
4971		    case " $libpth " in
4972		    *" $xxx "*) ;;
4973		    *) libpth="$libpth $xxx";;
4974		    esac
4975		fi
4976	    done
4977	    libpth="`$echo $libpth | $sed 's/^ //'`"
4978	fi
4979	$rm -f try.c
4980	case "$usrinc" in
4981	'') for i in $incpth; do
4982		if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
4983		    usrinc="$i"
4984		    break
4985		fi
4986	    done
4987	    ;;
4988	esac
4989
4990	case "$usecrosscompile" in
4991	$define|true|[yY]*)
4992	    case "$incpth" in
4993		'') echo "Incpth not defined." >&4; croak=y ;;
4994		*)  echo "Using incpth '$incpth'." >&4 ;;
4995	    esac
4996	    case "$libpth" in
4997		'') echo "Libpth not defined." >&4; croak=y ;;
4998		*)  echo "Using libpth '$libpth'." >&4 ;;
4999	    esac
5000	    case "$usrinc" in
5001		'') echo "Usrinc not defined." >&4; croak=y ;;
5002		*)  echo "Using usrinc $usrinc." >&4 ;;
5003	    esac
5004	    case "$croak" in
5005		y)
5006		if test "X$sysroot" = X; then
5007		    echo "Cannot continue, aborting." >&4; exit 1
5008		else
5009		    echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
5010		fi
5011		;;
5012	    esac
5013	    ;;
5014	esac
5015    ;;
5016esac
5017
5018: Default value for incpth is just usrinc
5019case "$incpth" in
5020'') incpth="$usrinc";;
5021esac
5022
5023: Set private lib path
5024case "$plibpth" in
5025'') if ./mips; then
5026	plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
5027    fi;;
5028esac
5029case "$libpth" in
5030' ') dlist='';;
5031'') dlist="$loclibpth $plibpth $glibpth";;
5032*) dlist="$libpth";;
5033esac
5034
5035: Now check and see which directories actually exist, avoiding duplicates
5036for xxx in $dlist
5037do
5038    if $test -d $xxx; then
5039		case " $libpth " in
5040		*" $xxx "*) ;;
5041		*) libpth="$libpth $xxx";;
5042		esac
5043    fi
5044done
5045$cat <<'EOM'
5046
5047Some systems have incompatible or broken versions of libraries.  Among
5048the directories listed in the question below, please remove any you
5049know not to be holding relevant libraries, and add any that are needed.
5050Say "none" for none.
5051
5052EOM
5053
5054if test "X$sysroot" != X; then
5055    $cat <<EOM
5056You have set sysroot to $sysroot, please supply the directories excluding sysroot
5057
5058EOM
5059fi
5060
5061case "$libpth" in
5062'') dflt='none';;
5063*)
5064	set X $libpth
5065	shift
5066	dflt=${1+"$@"}
5067	;;
5068esac
5069rp="Directories to use for library searches?"
5070. ./myread
5071case "$ans" in
5072none) libpth=' ';;
5073*) libpth="$ans";;
5074esac
5075
5076: compute shared library extension
5077case "$so" in
5078'')
5079	if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
5080		dflt='sl'
5081	else
5082		dflt='so'
5083	fi
5084	;;
5085*) dflt="$so";;
5086esac
5087$cat <<EOM
5088
5089On some systems, shared libraries may be available.  Answer 'none' if
5090you want to suppress searching of shared libraries for the remainder
5091of this configuration.
5092
5093EOM
5094rp='What is the file extension used for shared libraries?'
5095. ./myread
5096so="$ans"
5097
5098: Does target system insist that shared library basenames are unique
5099$cat << EOM
5100
5101Some dynamic loaders assume that the *basename* of shared library filenames
5102are globally unique.  We'll default this to undef as we assume your system
5103is not this weird. Set to defined if you're on one of them.
5104
5105EOM
5106
5107dflt='n'
5108rp='Make shared library basenames unique?'
5109. ./myread
5110case "$ans" in
5111y|Y) val="$define" ;;
5112*)   val="$undef"  ;;
5113esac
5114set d_libname_unique
5115eval $setvar
5116
5117: Define several unixisms.
5118: Hints files or command line option can be used to override them.
5119: The convoluted testing is in case hints files set either the old
5120: or the new name.
5121case "$_exe" in
5122'')	case "$exe_ext" in
5123	'')	;;
5124	*)	_exe="$exe_ext" ;;
5125	esac
5126	;;
5127esac
5128case "$_a" in
5129'')	case "$lib_ext" in
5130    '')	_a='.a';;
5131	*)	_a="$lib_ext" ;;
5132	esac
5133	;;
5134esac
5135case "$_o" in
5136'') case "$obj_ext" in
5137	'')	_o='.o';;
5138	*)	_o="$obj_ext";;
5139	esac
5140	;;
5141esac
5142case "$p_" in
5143'') case "$path_sep" in
5144	'')	p_=':';;
5145	*)	p_="$path_sep";;
5146	esac
5147	;;
5148esac
5149exe_ext=$_exe
5150lib_ext=$_a
5151obj_ext=$_o
5152path_sep=$p_
5153
5154rm_try="$rm -f try try$_exe a.out .out try.[cho] try.$_o core core.try* try.core*"
5155
5156: Which makefile gets called first.  This is used by make depend.
5157case "$firstmakefile" in
5158'') firstmakefile='makefile';;
5159esac
5160
5161: Check is we will use socks
5162case "$usesocks" in
5163$define|true|[yY]*)	dflt='y';;
5164*) dflt='n';;
5165esac
5166cat <<EOM
5167
5168Perl can be built to use the SOCKS proxy protocol library.  To do so,
5169Configure must be run with -Dusesocks.  If you use SOCKS you also need
5170to use the PerlIO abstraction layer, this will be implicitly selected.
5171
5172If this doesn't make any sense to you, just accept the default '$dflt'.
5173EOM
5174rp='Build Perl for SOCKS?'
5175. ./myread
5176case "$ans" in
5177y|Y)	val="$define" ;;
5178*)      val="$undef" ;;
5179esac
5180set usesocks
5181eval $setvar
5182
5183: Check for uselongdouble support
5184case "$ccflags" in
5185*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
5186esac
5187
5188case "$uselongdouble" in
5189$define|true|[yY]*)	dflt='y';;
5190*) dflt='n';;
5191esac
5192cat <<EOM
5193
5194Perl can be built to take advantage of long doubles which
5195(if available) may give more accuracy and range for floating point numbers.
5196
5197If this doesn't make any sense to you, just accept the default '$dflt'.
5198EOM
5199rp='Try to use long doubles if available?'
5200. ./myread
5201case "$ans" in
5202y|Y)	val="$define"	;;
5203*)      val="$undef"	;;
5204esac
5205set uselongdouble
5206eval $setvar
5207
5208case "$uselongdouble" in
5209true|[yY]*) uselongdouble="$define" ;;
5210esac
5211
5212: Look for a hint-file generated 'call-back-unit'.  If the
5213: user has specified that long doubles should be used,
5214: we may need to set or change some other defaults.
5215if $test -f uselongdouble.cbu; then
5216    echo "Your platform has some specific hints regarding long doubles, using them..."
5217    . ./uselongdouble.cbu
5218else
5219    case "$uselongdouble" in
5220	$define)
5221		$cat <<EOM
5222(Your platform does not have any specific hints for long doubles.)
5223EOM
5224	;;
5225    esac
5226fi
5227
5228: Looking for optional libraries
5229echo " "
5230echo "Checking for optional libraries..." >&4
5231case "$libs" in
5232' '|'') dflt='';;
5233*) dflt="$libs";;
5234esac
5235case "$libswanted" in
5236'') libswanted='c_s';;
5237esac
5238case "$usesocks" in
5239"$define") libswanted="$libswanted socks5 socks5_sh" ;;
5240esac
5241case "$usecbacktrace" in
5242"$define") libswanted="$libswanted bfd" ;;
5243esac
5244libsfound=''
5245libsfiles=''
5246libsdirs=''
5247libspath=''
5248for thisdir in $libpth $xlibpth; do
5249  test -d $thisdir && libspath="$libspath $thisdir"
5250done
5251for thislib in $libswanted; do
5252	for thisdir in $libspath; do
5253	    xxx=''
5254	    if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
5255		xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|sed -n '$p'`
5256	        $test -f "$xxx" && eval $libscheck
5257		$test -f "$xxx" && libstyle=shared
5258		xxx=`ls $thisdir/lib$thislib.[0-9].$so 2>/dev/null|sed -n '$p'`
5259	        $test -f "$xxx" && eval $libscheck
5260		$test -f "$xxx" && libstyle=shared
5261	    fi
5262	    if test ! -f "$xxx"; then
5263		xxx=$thisdir/lib$thislib.$so$_a
5264		$test -f "$xxx" && eval $libscheck
5265		$test -f "$xxx" && libstyle="import"
5266	    fi
5267	    if test ! -f "$xxx"; then
5268		xxx=$thisdir/$thislib.$so$_a
5269		$test -f "$xxx" && eval $libscheck
5270		$test -f "$xxx" && libstyle="import"
5271	    fi
5272	    if test ! -f "$xxx"; then
5273		xxx=$thisdir/lib$thislib.$so
5274	        $test -f "$xxx" && eval $libscheck
5275		$test -f "$xxx" && libstyle=shared
5276	    fi
5277	    if test ! -f "$xxx"; then
5278		xxx=$thisdir/lib$thislib$_a
5279	        $test -f "$xxx" && eval $libscheck
5280		$test -f "$xxx" && libstyle=static
5281	    fi
5282	    if test ! -f "$xxx"; then
5283		xxx=$thisdir/$thislib$_a
5284	        $test -f "$xxx" && eval $libscheck
5285		$test -f "$xxx" && libstyle=static
5286	    fi
5287	    if test ! -f "$xxx"; then
5288		xxx=$thisdir/lib${thislib}_s$_a
5289	        $test -f "$xxx" && eval $libscheck
5290		$test -f "$xxx" && libstyle=static
5291		$test -f "$xxx" && thislib=${thislib}_s
5292	    fi
5293	    if test ! -f "$xxx"; then
5294		xxx=$thisdir/Slib$thislib$_a
5295	        $test -f "$xxx" && eval $libscheck
5296		$test -f "$xxx" && libstyle=static
5297	    fi
5298	    if $test -f "$xxx"; then
5299		case "$libstyle" in
5300		shared) echo "Found -l$thislib (shared)." ;;
5301		static) echo "Found -l$thislib." ;;
5302		*)      echo "Found -l$thislib ($libstyle)." ;;
5303		esac
5304		case " $dflt " in
5305		*"-l$thislib "*);;
5306		*) dflt="$dflt -l$thislib"
5307		   libsfound="$libsfound $xxx"
5308		   yyy=`basename $xxx`
5309		   libsfiles="$libsfiles $yyy"
5310		   yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"`
5311		   case " $libsdirs " in
5312		   *" $yyy "*) ;;
5313		   *) libsdirs="$libsdirs $yyy" ;;
5314		   esac
5315		   ;;
5316		esac
5317		break
5318	    fi
5319	done
5320	if $test ! -f "$xxx"; then
5321	    echo "No -l$thislib."
5322	fi
5323done
5324set X $dflt
5325shift
5326dflt="$*"
5327case "$libs" in
5328'') dflt="$dflt";;
5329*) dflt="$libs";;
5330esac
5331case "$dflt" in
5332' '|'') dflt='none';;
5333esac
5334
5335$cat <<EOM
5336
5337In order to compile $package on your machine, a number of libraries
5338are usually needed.  Include any other special libraries here as well.
5339Say "none" for none.  The default list is almost always right.
5340EOM
5341
5342echo " "
5343rp="What libraries to use?"
5344. ./myread
5345case "$ans" in
5346none) libs=' ';;
5347*) libs="$ans";;
5348esac
5349
5350: determine optimization, if desired, or use for debug flag also
5351case "$optimize" in
5352' '|$undef) dflt='none';;
5353'') dflt='-O';;
5354*) dflt="$optimize";;
5355esac
5356$cat <<EOH
5357
5358By default, $package compiles with the -O flag to use the optimizer.
5359Alternately, you might want to use the symbolic debugger, which uses
5360the -g flag (on traditional Unix systems).  Either flag can be
5361specified here.  To use neither flag, specify the word "none".
5362
5363EOH
5364rp="What optimizer/debugger flag should be used?"
5365. ./myread
5366optimize="$ans"
5367case "$optimize" in
5368'none') optimize=" ";;
5369esac
5370
5371: Check what DEBUGGING is required from the command line
5372: -DEBUGGING      or -DDEBUGGING or
5373: -DEBUGGING=both			= -g + -DDEBUGGING
5374: -DEBUGGING=-g   or -Doptimize=-g	= -g
5375: -DEBUGGING=none or -UDEBUGGING	=
5376: -DEBUGGING=old  or -DEBUGGING=default	= ? $optimize
5377case "$EBUGGING" in
5378'')	;;
5379*)	DEBUGGING=$EBUGGING ;;
5380esac
5381
5382case "$DEBUGGING" in
5383-g|both|$define)
5384    case "$optimize" in
5385	*-g*) ;;
5386	*)    optimize="$optimize -g" ;;
5387    esac ;;
5388none|$undef)
5389    case "$optimize" in
5390	*-g*)	set `echo "X $optimize " | sed 's/ -g / /'`
5391		shift
5392		optimize="$*"
5393		;;
5394    esac ;;
5395esac
5396
5397dflt=''
5398case "$DEBUGGING" in
5399both|$define) dflt='-DDEBUGGING'
5400esac
5401
5402: argument order is deliberate, as the flag will start with - which set could
5403: think is an option
5404checkccflag='check=$1; flag=$2; callback=$3;
5405echo " ";
5406echo "Checking if your compiler accepts $flag" >&4;
5407[ "X$sysroot" != "X" ] && echo "For sysroot = $sysroot";
5408echo "int main(void) { return 0; }" > gcctest.c;
5409if $cc $_sysroot -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
5410    echo "Yes, it does." >&4;
5411    if $test -s gcctest.out ; then
5412        echo "But your platform does not like it:";
5413        cat gcctest.out;
5414    else
5415	case "$ccflags" in
5416	*$check*)
5417	    echo "Leaving current flags $ccflags alone." >&4
5418	    ;;
5419	*) dflt="$dflt $flag";
5420	    eval $callback
5421	    ;;
5422	esac
5423    fi
5424else
5425    echo "Nope, it does not, but that is ok." >&4;
5426fi
5427'
5428
5429: We will not override a previous value, but we might want to
5430: augment a hint file
5431case "$hint" in
5432default|recommended)
5433	case "$gccversion" in
5434	1.*) dflt="$dflt -fpcc-struct-return" ;;
5435	esac
5436	case "$optimize:$DEBUGGING" in
5437	*-g*:old) dflt="$dflt -DDEBUGGING";;
5438	esac
5439	case "$gccversion" in
5440	2.*) if $test -d /etc/conf/kconfig.d &&
5441			$contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
5442		then
5443			# Interactive Systems (ISC) POSIX mode.
5444			dflt="$dflt -posix"
5445		fi
5446		;;
5447	esac
5448	case "$gccversion" in
5449	1.*) ;;
5450	2.[0-8]*) ;;
5451	?*)	set strict-aliasing -fno-strict-aliasing
5452		eval $checkccflag
5453		;;
5454	esac
5455	case "$gccversion" in
5456	1*) ;;
5457	2*) ;;
5458	?*) 	echo " "
5459		echo "Checking if your compiler accepts -fno-delete-null-pointer-checks" 2>&1
5460		echo 'int main(void) { return 0; }' > gcctest.c
5461		if $cc -O2 -fno-delete-null-pointer-checks -o gcctest gcctest.c; then
5462			echo "Yes, it does." 2>&1
5463			case "$ccflags" in
5464			*delete-null-pointer-checks*)
5465				echo "Leaving current flags $ccflags alone." 2>&1
5466				;;
5467			*) dflt="$dflt -fno-delete-null-pointer-checks" ;;
5468			esac
5469		else
5470			echo "Nope, it doesn't, but that's ok." 2>&1
5471		fi
5472		;;
5473	esac
5474	# For gcc, adding -pipe speeds up compilations for some, but apparently
5475	# some assemblers can't read from stdin.  (It also slows down compilations
5476	# in other cases, but those are apparently rarer these days.)  AD 5/2004.
5477	case "$gccversion" in
5478	?*)	set pipe -pipe
5479		eval $checkccflag
5480		;;
5481	esac
5482
5483	# on x86_64 (at least) we require an extra library (libssp) in the
5484	# link command line. This library is not named, so I infer that it is
5485	# an implementation detail that may change. Hence the safest approach
5486	# is to add the flag to the flags passed to the compiler at link time,
5487	# as that way the compiler can do the right implementation dependant
5488	# thing. (NWC)
5489	case "$ccflags" in
5490	*-fno-stack-protector*)
5491	    echo "Do not add -fstack-protector nor -fstack-protector-strong" 2>&1
5492	    ;;
5493	*) case "$gccversion" in
5494	   ?*)	set stack-protector-strong -fstack-protector-strong
5495		eval $checkccflag
5496		case "$dflt" in
5497		*-fstack-protector-strong*) ;; # It got added.
5498		*) # Try the plain/older -fstack-protector.
5499		   set stack-protector -fstack-protector
5500		   eval $checkccflag
5501		   ;;
5502		esac
5503		;;
5504	    esac
5505	    ;;
5506	esac
5507esac
5508
5509case "$mips_type" in
5510*BSD*|'') inclwanted="$locincpth $usrinc";;
5511*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
5512esac
5513for thisincl in $inclwanted; do
5514	if $test -d $thisincl; then
5515		if $test x$thisincl != x$usrinc; then
5516			case "$dflt" in
5517			*" -I$thisincl "*);;
5518			*) dflt="$dflt -I$thisincl ";;
5519			esac
5520		fi
5521	fi
5522done
5523
5524inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
5525	xxx=true;
5526elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
5527	xxx=true;
5528else
5529	xxx=false;
5530fi;
5531if $xxx; then
5532	case "$dflt" in
5533	*$2*);;
5534	*) dflt="$dflt -D$2";;
5535	esac;
5536fi'
5537
5538set signal.h LANGUAGE_C; eval $inctest
5539
5540case "$usesocks" in
5541$define)
5542	ccflags="$ccflags -DSOCKS"
5543	;;
5544esac
5545
5546case "$hint" in
5547default|recommended) dflt="$ccflags $dflt" ;;
5548*) dflt="$ccflags";;
5549esac
5550
5551case "$dflt" in
5552''|' ') dflt=none;;
5553esac
5554
5555$cat <<EOH
5556
5557Your C compiler may want other flags.  For this question you should include
5558-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
5559but you should NOT include libraries or ld flags like -lwhatever.  If you
5560want $package to honor its debug switch, you should include -DDEBUGGING here.
5561Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
5562
5563To use no flags, specify the word "none".
5564
5565EOH
5566set X $dflt
5567shift
5568dflt=${1+"$@"}
5569rp="Any additional cc flags?"
5570. ./myread
5571case "$ans" in
5572none) ccflags='';;
5573*) ccflags="$ans";;
5574esac
5575
5576: the following weeds options from ccflags that are of no interest to cpp
5577case "$cppflags" in
5578'') cppflags="$ccflags" ;;
5579*)  set X $ccflags; shift
5580    case " $cppflags " in
5581    *" $1 "*) ;;  # Try to avoid doubling the cppflags.
5582    *) cppflags="$cppflags $ccflags" ;;
5583    esac
5584    ;;
5585esac
5586case "$gccversion" in
55871.*) cppflags="$cppflags -D__GNUC__"
5588esac
5589case "$mips_type" in
5590'');;
5591*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
5592esac
5593case "$cppflags" in
5594'');;
5595*)
5596	echo " "
5597	echo "Let me guess what the preprocessor flags are..." >&4
5598	set X $cppflags
5599	shift
5600	cppflags=''
5601	$cat >cpp.c <<'EOM'
5602#define BLURFL foo
5603
5604BLURFL xx LFRULB
5605EOM
5606	previous=''
5607	for flag in $*
5608	do
5609		case "$flag" in
5610		-*) ftry="$flag";;
5611		*) ftry="$previous $flag";;
5612		esac
5613		if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
5614			>cpp1.out 2>/dev/null && \
5615			$cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
5616			>cpp2.out 2>/dev/null && \
5617			$contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
5618			$contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
5619		then
5620			cppflags="$cppflags $ftry"
5621			previous=''
5622		else
5623			previous="$flag"
5624		fi
5625	done
5626	set X $cppflags
5627	shift
5628	cppflags=${1+"$@"}
5629	case "$cppflags" in
5630	*-*)  echo "They appear to be: $cppflags";;
5631	esac
5632	$rm -f cpp.c cpp?.out
5633	;;
5634esac
5635
5636: flags used in final linking phase
5637case "$ldflags" in
5638'') if ./venix; then
5639		dflt='-i -z'
5640	else
5641		dflt=''
5642	fi
5643	case "$ccflags" in
5644	*-posix*) dflt="$dflt -posix" ;;
5645	esac
5646	;;
5647*) dflt="$ldflags";;
5648esac
5649# See note above about -fstack-protector
5650case "$ccflags" in
5651*-fstack-protector-strong*)
5652	case "$dflt" in
5653	*-fstack-protector-strong*) ;; # Don't add it again
5654	*) dflt="$dflt -fstack-protector-strong" ;;
5655	esac
5656	;;
5657*-fstack-protector*)
5658	case "$dflt" in
5659	*-fstack-protector*) ;; # Don't add it again
5660	*) dflt="$dflt -fstack-protector" ;;
5661	esac
5662	;;
5663esac
5664
5665: Try to guess additional flags to pick up local libraries.
5666for thislibdir in $libpth; do
5667	case " $loclibpth " in
5668	*" $thislibdir "*)
5669		case "$dflt " in
5670		*"-L$thislibdir "*) ;;
5671		*)  dflt="$dflt -L$thislibdir" ;;
5672		esac
5673		;;
5674	esac
5675done
5676
5677case "$dflt" in
5678'') dflt='none' ;;
5679esac
5680
5681$cat <<EOH
5682
5683Your C linker may need flags.  For this question you should
5684include -L/whatever and any other flags used by the C linker, but you
5685should NOT include libraries like -lwhatever.
5686
5687Make sure you include the appropriate -L/path flags if your C linker
5688does not normally search all of the directories you specified above,
5689namely
5690	$libpth
5691To use no flags, specify the word "none".
5692
5693EOH
5694
5695rp="Any additional ld flags (NOT including libraries)?"
5696. ./myread
5697case "$ans" in
5698none) ldflags='';;
5699*) ldflags="$ans";;
5700esac
5701rmlist="$rmlist pdp11"
5702
5703: coherency check
5704echo " "
5705echo "Checking your choice of C compiler and flags for coherency..." >&4
5706$cat > try.c <<'EOF'
5707#include <stdio.h>
5708int main() { printf("Ok\n"); return(0); }
5709EOF
5710set X $cc -o try $optimize $ccflags $ldflags try.c $libs
5711shift
5712$cat >try.msg <<'EOM'
5713I've tried to compile and run the following simple program:
5714
5715EOM
5716$cat try.c >> try.msg
5717
5718$cat >> try.msg <<EOM
5719
5720I used the command:
5721
5722	$*
5723	$run ./try
5724
5725and I got the following output:
5726
5727EOM
5728dflt=y
5729if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; then
5730	if $sh -c "$run ./try " >>try.msg 2>&1; then
5731		xxx=`$run ./try`
5732		case "$xxx" in
5733		"Ok") dflt=n ;;
5734		*)    echo 'The program compiled OK, but produced no output.' >> try.msg ;;
5735		esac
5736	else
5737		echo "The program compiled OK, but exited with status $?." >>try.msg
5738		rp="You have a problem.  Shall I abort Configure"
5739		dflt=y
5740	fi
5741else
5742	echo "I can't compile the test program." >>try.msg
5743	rp="You have a BIG problem.  Shall I abort Configure"
5744	dflt=y
5745fi
5746case "$dflt" in
5747y)
5748	$cat try.msg >&4
5749	case "$knowitall" in
5750	'')
5751		echo "(The supplied flags or libraries might be incorrect.)"
5752		;;
5753	*) dflt=n;;
5754	esac
5755	echo " "
5756	. ./myread
5757	case "$ans" in
5758	n*|N*) ;;
5759	*)	echo "Ok.  Stopping Configure." >&4
5760		exit 1
5761		;;
5762	esac
5763	;;
5764n) echo "OK, that should do.";;
5765esac
5766$rm_try gcctest gcctest.out
5767
5768: define a shorthand compile call
5769compile='
5770mc_file=$1;
5771shift;
5772case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
5773echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to https://github.com/Perl/perl5/issues" >&4;
5774exit 1;
5775fi;
5776esac;
5777$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5778: define a shorthand compile call for compilations that should be ok.
5779compile_ok='
5780mc_file=$1;
5781shift;
5782$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5783
5784: stub, used only to satisfy other units
5785i_stdlib='define'
5786
5787: check for lengths of integral types
5788echo " "
5789case "$intsize" in
5790'')
5791	echo "Checking to see how big your integers are..." >&4
5792	$cat >try.c <<EOCP
5793#include <stdio.h>
5794#$i_stdlib I_STDLIB
5795#ifdef I_STDLIB
5796#include <stdlib.h>
5797#endif
5798#include <stdio.h>
5799int main()
5800{
5801	printf("intsize=%d;\n", (int)sizeof(int));
5802	printf("longsize=%d;\n", (int)sizeof(long));
5803	printf("shortsize=%d;\n", (int)sizeof(short));
5804	exit(0);
5805}
5806EOCP
5807	set try
5808	if eval $compile_ok && $run ./try > /dev/null; then
5809		eval `$run ./try`
5810		echo "Your integers are $intsize bytes long."
5811		echo "Your long integers are $longsize bytes long."
5812		echo "Your short integers are $shortsize bytes long."
5813	else
5814		$cat >&4 <<EOM
5815!
5816Help! I can't compile and run the intsize test program: please enlighten me!
5817(This is probably a misconfiguration in your system or libraries, and
5818you really ought to fix it.  Still, I'll try anyway.)
5819!
5820EOM
5821		dflt=4
5822		rp="What is the size of an integer (in bytes)?"
5823		. ./myread
5824		intsize="$ans"
5825		dflt=$intsize
5826		rp="What is the size of a long integer (in bytes)?"
5827		. ./myread
5828		longsize="$ans"
5829		dflt=2
5830		rp="What is the size of a short integer (in bytes)?"
5831		. ./myread
5832		shortsize="$ans"
5833	fi
5834	;;
5835esac
5836$rm_try
5837
5838: check for long long
5839echo " "
5840echo "Checking to see if you have long long..." >&4
5841echo 'int main() { long long x = 7; return 0; }' > try.c
5842set try
5843if eval $compile; then
5844	val="$define"
5845	echo "You have long long."
5846else
5847	val="$undef"
5848	echo "You do not have long long."
5849fi
5850$rm_try
5851set d_longlong
5852eval $setvar
5853
5854: check for length of long long
5855case "${d_longlong}${longlongsize}" in
5856$define)
5857	echo " "
5858	echo "Checking to see how big your long longs are..." >&4
5859	$cat >try.c <<'EOCP'
5860#include <stdio.h>
5861int main()
5862{
5863    printf("%d\n", (int)sizeof(long long));
5864    return(0);
5865}
5866EOCP
5867	set try
5868	if eval $compile_ok; then
5869		longlongsize=`$run ./try`
5870		echo "Your long longs are $longlongsize bytes long."
5871	else
5872		dflt='8'
5873		echo " "
5874		echo "(I can't seem to compile the test program.  Guessing...)"
5875		rp="What is the size of a long long (in bytes)?"
5876		. ./myread
5877		longlongsize="$ans"
5878	fi
5879	if $test "X$longsize" = "X$longlongsize"; then
5880		echo "(That isn't any different from an ordinary long.)"
5881	fi
5882	;;
5883esac
5884$rm_try
5885
5886: determine filename position in cpp output
5887echo " "
5888echo "Computing filename position in cpp output for #include directives..." >&4
5889case "$osname" in
5890amigaos) fieldn=3 ;;  # Workaround for a bug in abc (pdksh).
5891esac
5892case "$fieldn" in
5893'')
5894case "$osname" in
5895vos) testaccess=-e ;;
5896*)   testaccess=-r ;;
5897esac
5898echo '#include <stdio.h>' > foo.c
5899$cat >fieldn <<EOF
5900$startsh
5901$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
5902$grep '^[ 	]*#.*stdio\.h' | \
5903while read cline; do
5904	pos=1
5905	set \$cline
5906	while $test \$# -gt 0; do
5907		if $test $testaccess \`echo \$1 | $tr -d '"'\`; then
5908			echo "\$pos"
5909			exit 0
5910		fi
5911		shift
5912		pos=\`expr \$pos + 1\`
5913	done
5914done
5915EOF
5916chmod +x fieldn
5917fieldn=`./fieldn`
5918$rm -f foo.c fieldn
5919;;
5920esac
5921case $fieldn in
5922'') pos='???';;
59231) pos=first;;
59242) pos=second;;
59253) pos=third;;
5926*) pos="${fieldn}th";;
5927esac
5928echo "Your cpp writes the filename in the $pos field of the line."
5929
5930: locate header file
5931$cat >findhdr <<EOF
5932$startsh
5933wanted=\$1
5934name=''
5935for usrincdir in $incpth
5936do
5937	if test -f \$usrincdir/\$wanted; then
5938		echo "\$usrincdir/\$wanted"
5939		exit 0
5940	fi
5941done
5942awkprg='{ print \$$fieldn }'
5943echo "#include <\$wanted>" > foo\$\$.c
5944$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
5945$cppfilter $grep "^[ 	]*#.*\$wanted" | \
5946while read cline; do
5947	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
5948	case "\$name" in
5949	*[/\\\\]\$wanted) echo "\$name"; exit 1;;
5950	*[\\\\/]\$wanted) echo "\$name"; exit 1;;
5951	*) exit 2;;
5952	esac;
5953done;
5954#
5955# status = 0: grep returned 0 lines, case statement not executed
5956# status = 1: headerfile found
5957# status = 2: while loop executed, no headerfile found
5958#
5959status=\$?
5960$rm -f foo\$\$.c;
5961if test \$status -eq 1; then
5962	exit 0;
5963fi
5964exit 1
5965EOF
5966chmod +x findhdr
5967
5968: define an alternate in-header-list? function
5969inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
5970cont=true; xxf="echo \"<\$1> found.\" >&4";
5971case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
5972*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
5973esac;
5974case $# in 4) instead=instead;; *) instead="at last";; esac;
5975while $test "$cont"; do
5976	xxx=`./findhdr $1`
5977	var=$2; eval "was=\$$2";
5978	if $test "$xxx" && $test -r "$xxx";
5979	then eval $xxf;
5980	eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
5981		cont="";
5982	else eval $xxnf;
5983	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
5984	set $yyy; shift; shift; yyy=$@;
5985	case $# in 0) cont="";;
5986	2) xxf="echo \"but I found <\$1> $instead.\" >&4";
5987		xxnf="echo \"and I did not find <\$1> either.\" >&4";;
5988	*) xxf="echo \"but I found <\$1\> instead.\" >&4";
5989		xxnf="echo \"there is no <\$1>, ...\" >&4";;
5990	esac;
5991done;
5992while $test "$yyy";
5993do set $yyy; var=$2; eval "was=\$$2";
5994	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
5995	set $yyy; shift; shift; yyy=$@;
5996done'
5997
5998: see if inttypes.h is available
5999: we want a real compile instead of Inhdr because some systems
6000: have an inttypes.h which includes non-existent headers
6001echo " "
6002$cat >try.c <<EOCP
6003#include <inttypes.h>
6004int main() {
6005	static int32_t foo32 = 0x12345678;
6006}
6007EOCP
6008set try
6009if eval $compile; then
6010	echo "<inttypes.h> found." >&4
6011	val="$define"
6012else
6013	echo "<inttypes.h> NOT found." >&4
6014	val="$undef"
6015fi
6016$rm_try
6017set i_inttypes
6018eval $setvar
6019
6020: check for int64_t
6021echo " "
6022echo "Checking to see if you have int64_t..." >&4
6023$cat >try.c <<EOCP
6024#include <sys/types.h>
6025#$i_inttypes I_INTTYPES
6026#ifdef I_INTTYPES
6027#include <inttypes.h>
6028#endif
6029int main() { int64_t x = 7; }
6030EOCP
6031set try
6032if eval $compile; then
6033	val="$define"
6034	echo "You have int64_t."
6035else
6036	val="$undef"
6037	echo "You do not have int64_t."
6038fi
6039$rm_try
6040set d_int64_t
6041eval $setvar
6042
6043: Check if 64bit ints have a quad type
6044echo " "
6045echo "Checking which 64-bit integer type we could use..." >&4
6046
6047case "$intsize" in
60488) val=int
6049   set quadtype
6050   eval $setvar
6051   val='"unsigned int"'
6052   set uquadtype
6053   eval $setvar
6054   quadkind=1
6055   ;;
6056*) case "$longsize" in
6057   8) val=long
6058      set quadtype
6059      eval $setvar
6060      val='"unsigned long"'
6061      set uquadtype
6062      eval $setvar
6063      quadkind=2
6064      ;;
6065   *) case "$d_longlong:$longlongsize" in
6066      define:8)
6067        val='"long long"'
6068        set quadtype
6069        eval $setvar
6070        val='"unsigned long long"'
6071        set uquadtype
6072        eval $setvar
6073        quadkind=3
6074        ;;
6075      *) case "$d_int64_t" in
6076         define)
6077           val=int64_t
6078           set quadtype
6079           eval $setvar
6080           val=uint64_t
6081           set uquadtype
6082           eval $setvar
6083           quadkind=4
6084           ;;
6085         esac
6086         ;;
6087      esac
6088      ;;
6089   esac
6090   ;;
6091esac
6092
6093case "$quadtype" in
6094'')	echo "Alas, no 64-bit integer types in sight." >&4
6095	d_quad="$undef"
6096	;;
6097*)	echo "We could use '$quadtype' for 64-bit integers." >&4
6098	d_quad="$define"
6099	;;
6100esac
6101
6102: Do we want 64bit support
6103case "$uselonglong" in
6104"$define"|true|[yY]*)
6105	cat <<EOM >&4
6106
6107*** Configure -Duselonglong is deprecated, using -Duse64bitint instead.
6108EOM
6109	use64bitint="$define"
6110	;;
6111esac
6112case "$use64bits" in
6113"$define"|true|[yY]*)
6114	cat <<EOM >&4
6115
6116*** Configure -Duse64bits is deprecated, using -Duse64bitint instead.
6117EOM
6118	use64bitint="$define"
6119	;;
6120esac
6121case "$use64bitints" in
6122"$define"|true|[yY]*)
6123	cat <<EOM >&4
6124
6125*** There is no Configure -Duse64bitints, using -Duse64bitint instead.
6126EOM
6127	use64bitint="$define"
6128	;;
6129esac
6130case "$use64bitsint" in
6131"$define"|true|[yY]*)
6132	cat <<EOM >&4
6133
6134*** There is no Configure -Duse64bitsint, using -Duse64bitint instead.
6135EOM
6136	use64bitint="$define"
6137	;;
6138esac
6139case "$uselonglongs" in
6140"$define"|true|[yY]*)
6141	cat <<EOM >&4
6142
6143*** There is no Configure -Duselonglongs, using -Duse64bitint instead.
6144EOM
6145	use64bitint="$define"
6146	;;
6147esac
6148case "$use64bitsall" in
6149"$define"|true|[yY]*)
6150	cat <<EOM >&4
6151
6152*** There is no Configure -Duse64bitsall, using -Duse64bitall instead.
6153EOM
6154	use64bitall="$define"
6155	;;
6156esac
6157
6158case "$ccflags" in
6159*-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
6160esac
6161case "$use64bitall" in
6162"$define"|true|[yY]*) use64bitint="$define" ;;
6163esac
6164
6165case "$longsize" in
61668) cat <<EOM
6167
6168You have natively 64-bit long integers.
6169EOM
6170   val="$define"
6171   ;;
6172*) case "$use64bitint" in
6173   "$define"|true|[yY]*) dflt='y';;
6174   *) dflt='n';;
6175   esac
6176   case "$d_quad" in
6177   "$define") ;;
6178   *) dflt='n' ;;
6179   esac
6180   cat <<EOM
6181
6182Perl can be built to take advantage of 64-bit integer types
6183on some systems.  To do so, Configure can be run with -Duse64bitint.
6184Choosing this option will most probably introduce binary incompatibilities.
6185
6186If this doesn't make any sense to you, just accept the default '$dflt'.
6187(The default has been chosen based on your configuration.)
6188EOM
6189   rp='Try to use 64-bit integers, if available?'
6190   . ./myread
6191   case "$ans" in
6192   [yY]*) val="$define" ;;
6193   *)     val="$undef"  ;;
6194   esac
6195   ;;
6196esac
6197set use64bitint
6198eval $setvar
6199
6200case "$use64bitall" in
6201"$define"|true|[yY]*) dflt='y' ;;
6202*) case "$longsize" in
6203   8) dflt='y' ;;
6204   *) dflt='n' ;;
6205   esac
6206   ;;
6207esac
6208cat <<EOM
6209
6210You may also choose to try maximal 64-bitness.  It means using as much
621164-bitness as possible on the platform.  This in turn means even more
6212binary incompatibilities.  On the other hand, your platform may not
6213have any more 64-bitness available than what you already have chosen.
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
6218rp='Try to use maximal 64-bit support, if available?'
6219. ./myread
6220case "$ans" in
6221[yY]*) val="$define" ;;
6222*)     val="$undef"  ;;
6223esac
6224set use64bitall
6225eval $setvar
6226case "$use64bitall" in
6227"$define")
6228	case "$use64bitint" in
6229	"$undef")
6230		cat <<EOM
6231
6232Since you have chosen a maximally 64-bit build, I'm also turning on
6233the use of 64-bit integers.
6234EOM
6235		use64bitint="$define" ;;
6236	esac
6237	;;
6238esac
6239
6240: Look for a hint-file generated 'call-back-unit'.  If the
6241: user has specified that a 64-bit perl is to be built,
6242: we may need to set or change some other defaults.
6243if $test -f use64bitint.cbu; then
6244	echo "Your platform has some specific hints regarding 64-bit integers, using them..."
6245	. ./use64bitint.cbu
6246fi
6247case "$use64bitint" in
6248"$define"|true|[yY]*)
6249	: This test was common to all the OpenBSD forks, and seems harmless for
6250	: other platforms:
6251	echo " "
6252	echo "Checking if your C library has broken 64-bit functions..." >&4
6253	cat >try.c <<EOCP
6254#include <stdio.h>
6255typedef $uquadtype myULL;
6256int main (void)
6257{
6258    struct {
6259	double d;
6260	myULL  u;
6261    } *p, test[] = {
6262	{4294967303.15, 4294967303ULL},
6263	{4294967294.2,  4294967294ULL},
6264	{4294967295.7,  4294967295ULL},
6265	{0.0, 0ULL}
6266    };
6267    for (p = test; p->u; p++) {
6268	myULL x = (myULL)p->d;
6269	if (x != p->u) {
6270	    printf("buggy\n");
6271	    return 0;
6272	}
6273    }
6274    printf("ok\n");
6275    return 0;
6276}
6277EOCP
6278	set try
6279	if eval $compile_ok; then
6280	    libcquad=`$run ./try`
6281	    echo "Your C library's 64-bit functions are $libcquad."
6282	else
6283	    echo "(I can't seem to compile the test program.)"
6284	    echo "Assuming that your C library's 64-bit functions are ok."
6285	    libcquad="ok"
6286	fi
6287	$rm_try
6288
6289	case "$libcquad" in
6290	    buggy*)
6291		cat >&4 <<EOM
6292
6293*** You have a C library with broken 64-bit functions.
6294*** 64-bit support does not work reliably in this configuration.
6295*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6296*** Cannot continue, aborting.
6297
6298EOM
6299		exit 1
6300		;;
6301	esac
6302	case "$longsize" in
6303	4) case "$archname64" in
6304	   '') archname64=64int ;;
6305	   esac
6306	   ;;
6307	esac
6308	;;
6309esac
6310
6311: Look for a hint-file generated 'call-back-unit'.  If the
6312: user has specified that a maximally 64-bit perl is to be built,
6313: we may need to set or change some other defaults.
6314if $test -f use64bitall.cbu; then
6315	echo "Your platform has some specific hints regarding 64-bit builds, using them..."
6316	. ./use64bitall.cbu
6317fi
6318case "$use64bitall" in
6319"$define"|true|[yY]*)
6320	case "$longsize" in
6321	4) case "$archname64" in
6322	   ''|64int) archname64=64all ;;
6323	   esac
6324	   ;;
6325	esac
6326	;;
6327esac
6328
6329case "$d_quad:$use64bitint" in
6330$undef:$define)
6331	cat >&4 <<EOF
6332
6333*** You have chosen to use 64-bit integers,
6334*** but none can be found.
6335*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6336*** Cannot continue, aborting.
6337
6338EOF
6339	exit 1
6340	;;
6341esac
6342
6343: Check if we are using the GNU C library
6344echo " "
6345echo "Checking for GNU C Library..." >&4
6346cat >try.c <<'EOCP'
6347/* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
6348   alone are insufficient to distinguish different versions, such as
6349   2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
6350   libc version 2.1.0.      A. Dougherty,  June 3, 2002.
6351*/
6352#include <stdio.h>
6353int main(void)
6354{
6355#ifdef __GLIBC__
6356#   ifdef __GLIBC_MINOR__
6357#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
6358#           include <gnu/libc-version.h>
6359	    printf("%s\n",  gnu_get_libc_version());
6360#       else
6361	    printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
6362#       endif
6363#   else
6364	printf("%d\n",  __GLIBC__);
6365#   endif
6366    return 0;
6367#else
6368    return 1;
6369#endif
6370}
6371EOCP
6372set try
6373if eval $compile_ok && $run ./try > glibc.ver; then
6374	val="$define"
6375	gnulibc_version=`$cat glibc.ver`
6376	echo "You are using the GNU C Library version $gnulibc_version"
6377else
6378	val="$undef"
6379	gnulibc_version=''
6380	echo "You are not using the GNU C Library"
6381fi
6382$rm_try glibc.ver
6383set d_gnulibc
6384eval $setvar
6385
6386: see if nm is to be used to determine whether a symbol is defined or not
6387case "$usenm" in
6388'')
6389	dflt=''
6390	case "$d_gnulibc" in
6391	"$define")
6392		echo " "
6393		echo "nm probably won't work on the GNU C Library." >&4
6394		dflt=n
6395		;;
6396	esac
6397	case "$dflt" in
6398	'')
6399		if $test "$osname" = aix -a "X$PASE" != "Xdefine" -a ! -f /lib/syscalls.exp; then
6400			echo " "
6401			echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
6402			echo "'nm' won't be sufficient on this system." >&4
6403			dflt=n
6404		fi
6405		;;
6406	esac
6407	case "$dflt" in
6408	'') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
6409		if $test $dflt -gt 20; then
6410			dflt=y
6411		else
6412			dflt=n
6413		fi
6414		;;
6415	esac
6416	;;
6417*)
6418	case "$usenm" in
6419	true|$define) dflt=y;;
6420	*) dflt=n;;
6421	esac
6422	;;
6423esac
6424$cat <<EOM
6425
6426I can use $nm to extract the symbols from your C libraries. This
6427is a time consuming task which may generate huge output on the disk (up
6428to 3 megabytes) but that should make the symbols extraction faster. The
6429alternative is to skip the 'nm' extraction part and to compile a small
6430test program instead to determine whether each symbol is present. If
6431you have a fast C compiler and/or if your 'nm' output cannot be parsed,
6432this may be the best solution.
6433
6434You probably shouldn't let me use 'nm' if you are using the GNU C Library.
6435
6436EOM
6437rp="Shall I use $nm to extract C symbols from the libraries?"
6438. ./myread
6439case "$ans" in
6440[Nn]*) usenm=false;;
6441*) usenm=true;;
6442esac
6443
6444runnm=$usenm
6445case "$reuseval" in
6446true) runnm=false;;
6447esac
6448
6449: nm options which may be necessary
6450case "$nm_opt" in
6451'') if $test -f /mach_boot; then
6452		nm_opt=''	# Mach
6453	elif $test -d /usr/ccs/lib; then
6454		nm_opt='-p'	# Solaris (and SunOS?)
6455	elif $test -f /dgux; then
6456		nm_opt='-p'	# DG-UX
6457	elif $test -f /lib64/rld; then
6458		nm_opt='-p'	# 64-bit Irix
6459	else
6460		nm_opt=''
6461	fi;;
6462esac
6463
6464: nm options which may be necessary for shared libraries but illegal
6465: for archive libraries.  Thank you, Linux.
6466case "$nm_so_opt" in
6467'')	case "$myuname" in
6468	*linux*|gnu*)
6469		if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
6470			nm_so_opt='--dynamic'
6471		fi
6472		;;
6473	esac
6474	;;
6475esac
6476
6477: Figure out where the libc is located
6478case "$runnm" in
6479true)
6480: get list of predefined functions in a handy place
6481echo " "
6482case "$libc" in
6483'') libc=unknown
6484	case "$libs" in
6485	*-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
6486	esac
6487	;;
6488esac
6489case "$libs" in
6490'') ;;
6491*)  for thislib in $libs; do
6492	case "$thislib" in
6493	-lc|-lc_s)
6494		: Handle C library specially below.
6495		;;
6496	-l*)
6497		thislib=`echo $thislib | $sed -e 's/^-l//'`
6498		if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
6499			:
6500		elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
6501			:
6502		elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
6503			:
6504		elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
6505			:
6506		elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
6507			:
6508		elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
6509			:
6510		elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
6511			:
6512		else
6513			try=''
6514		fi
6515		libnames="$libnames $try"
6516		;;
6517	*) libnames="$libnames $thislib" ;;
6518	esac
6519	done
6520	;;
6521esac
6522xxx=normal
6523case "$libc" in
6524unknown)
6525	set /lib/libc.$so
6526	for xxx in $libpth; do
6527		$test -r $1 || set $xxx/libc.$so
6528		: The messy sed command sorts on library version numbers.
6529		$test -r $1 || \
6530			set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
6531			tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
6532				h
6533				s/[0-9][0-9]*/0000&/g
6534				s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
6535				G
6536				s/\n/ /' | \
6537			 $sort | $sed -e 's/^.* //'`
6538		eval set \$$#
6539	done
6540	$test -r $1 || set $sysroot/usr/ccs/lib/libc.$so
6541	$test -r $1 || set $sysroot/lib/libsys_s$_a
6542	;;
6543*)
6544	set blurfl
6545	;;
6546esac
6547if $test -r "$1"; then
6548	echo "Your (shared) C library seems to be in $1."
6549	libc="$1"
6550elif $test -r /lib/libc && $test -r /lib/clib; then
6551	echo "Your C library seems to be in both /lib/clib and /lib/libc."
6552	xxx=apollo
6553	libc='/lib/clib /lib/libc'
6554	if $test -r /lib/syslib; then
6555		echo "(Your math library is in /lib/syslib.)"
6556		libc="$libc /lib/syslib"
6557	fi
6558elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
6559	echo "Your C library seems to be in $libc, as you said before."
6560elif $test -r $incpath/usr/lib/libc$_a; then
6561	libc=$incpath/usr/lib/libc$_a;
6562	echo "Your C library seems to be in $libc.  That's fine."
6563elif $test -r /lib/libc$_a; then
6564	libc=/lib/libc$_a;
6565	echo "Your C library seems to be in $libc.  You're normal."
6566else
6567	if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
6568		:
6569	elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
6570		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
6571	elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
6572		:
6573	elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
6574		:
6575	elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
6576		:
6577	else
6578		tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
6579	fi
6580	if $test -r "$tans"; then
6581		echo "Your C library seems to be in $tans, of all places."
6582		libc=$tans
6583	else
6584		libc='blurfl'
6585	fi
6586fi
6587if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
6588	dflt="$libc"
6589	cat <<EOM
6590
6591If the guess above is wrong (which it might be if you're using a strange
6592compiler, or your machine supports multiple models), you can override it here.
6593
6594EOM
6595else
6596	dflt=''
6597	echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
6598	cat >&4 <<EOM
6599I can't seem to find your C library.  I've looked in the following places:
6600
6601EOM
6602	$sed 's/^/	/' libpath
6603	cat <<EOM
6604
6605None of these seems to contain your C library. I need to get its name...
6606
6607EOM
6608fi
6609fn=f
6610rp='Where is your C library?'
6611. ./getfile
6612libc="$ans"
6613
6614echo " "
6615echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
6616set X `cat libnames`
6617shift
6618xxx=files
6619case $# in 1) xxx=file; esac
6620echo "Extracting names from the following $xxx for later perusal:" >&4
6621echo " "
6622$sed 's/^/	/' libnames >&4
6623echo " "
6624$echo $n "This may take a while...$c" >&4
6625
6626for file in $*; do
6627	case $file in
6628	*$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
6629	*) $nm $nm_opt $file 2>/dev/null;;
6630	esac
6631done >libc.tmp
6632
6633$echo $n ".$c"
6634$grep fprintf libc.tmp > libc.ptf
6635xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
6636xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
6637xxx='[ADTSIWi]'
6638if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
6639	eval $xscan;\
6640	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6641		eval $xrun
6642elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
6643	eval $xscan;\
6644	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6645		eval $xrun
6646elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
6647	eval $xscan;\
6648	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6649		eval $xrun
6650elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
6651	eval $xscan;\
6652	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6653		eval $xrun
6654elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
6655	eval $xscan;\
6656	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6657		eval $xrun
6658elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
6659	eval $xscan;\
6660	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6661		eval $xrun
6662elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
6663				-e '/ file/d' -e 's/^\([^ 	]*\).*/\1/p'";\
6664	eval $xscan;\
6665	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6666		eval $xrun
6667elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
6668	eval $xscan;\
6669	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6670		eval $xrun
6671elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
6672	eval $xscan;\
6673	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6674		eval $xrun
6675elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
6676	eval $xscan;\
6677	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6678		eval $xrun
6679elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
6680	eval $xscan;\
6681	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6682		eval $xrun
6683elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
6684	eval $xscan;\
6685	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6686		eval $xrun
6687elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
6688	eval $xscan;\
6689	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6690		eval $xrun
6691elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
6692	eval $xscan;\
6693	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6694		eval $xrun
6695else
6696	$nm -p $* 2>/dev/null >libc.tmp
6697	$grep fprintf libc.tmp > libc.ptf
6698	if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
6699		eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
6700	then
6701		nm_opt='-p'
6702		eval $xrun
6703	else
6704		echo " "
6705		echo "$nm didn't seem to work right. Trying $ar instead..." >&4
6706		com=''
6707		if $ar t $libc > libc.tmp && \
6708			$contains '^fprintf$' libc.tmp >/dev/null 2>&1
6709		then
6710			for thisname in $libnames $libc; do
6711				$ar t $thisname >>libc.tmp
6712			done
6713			$sed -e "s/\\$_o\$//" < libc.tmp > libc.list
6714			echo "Ok." >&4
6715		elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
6716			for thisname in $libnames $libc; do
6717				$ar tv $thisname >>libc.tmp
6718				emximp -o tmp.imp $thisname \
6719				    2>/dev/null && \
6720				    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
6721				    < tmp.imp >>libc.tmp
6722				$rm -f tmp.imp
6723			done
6724			$sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
6725			echo "Ok." >&4
6726		else
6727			echo "$ar didn't seem to work right." >&4
6728			echo "Maybe this is a Cray...trying bld instead..." >&4
6729			if  bld t $libc | \
6730				$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list &&
6731				$test -s libc.list
6732			then
6733				for thisname in $libnames; do
6734					bld t $libnames | \
6735					$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
6736					$ar t $thisname >>libc.tmp
6737				done
6738				echo "Ok." >&4
6739			else
6740				echo "That didn't work either.  Giving up." >&4
6741				exit 1
6742			fi
6743		fi
6744	fi
6745fi
6746nm_extract="$com"
6747case "$PASE" in
6748define)
6749    echo " "
6750    echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
6751    dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
6752    ;;
6753*)  if $test -f /lib/syscalls.exp; then
6754	echo " "
6755	echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
6756	$sed -n 's/^\([^ 	]*\)[ 	]*syscall[0-9]*[ 	]*$/\1/p' \
6757		/lib/syscalls.exp >>libc.list
6758    fi
6759    ;;
6760esac
6761;;
6762esac
6763$rm -f libnames libpath
6764
6765: Check if we are using C++
6766echo " "
6767echo "Checking for C++..." >&4
6768$cat >try.c <<'EOCP'
6769#include <stdio.h>
6770int main(void)
6771{
6772#ifdef __cplusplus
6773    return 0;
6774#else
6775    return 1;
6776#endif
6777}
6778EOCP
6779set try
6780if eval $compile_ok && $run ./try; then
6781	val="$define"
6782	echo "You are using a C++ compiler."
6783else
6784	val="$undef"
6785	echo "You are not using a C++ compiler."
6786fi
6787$rm_try cplusplus$$
6788set d_cplusplus
6789eval $setvar
6790
6791: is a C symbol defined?
6792csym='tlook=$1;
6793case "$3" in
6794-v) tf=libc.tmp; tdc="";;
6795-a) tf=libc.tmp; tdc="[]";;
6796*) tlook="^$1\$"; tf=libc.list; tdc="()";;
6797esac;
6798case "$d_cplusplus" in
6799    $define)	extern_C="extern \"C\""	;;
6800    *)		extern_C="extern"	;;
6801esac;
6802tx=yes;
6803case "$reuseval-$4" in
6804true-) ;;
6805true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
6806esac;
6807case "$tx" in
6808yes)
6809	tval=false;
6810	if $test "$runnm" = true; then
6811		if $contains $tlook $tf >/dev/null 2>&1; then
6812			tval=true;
6813		elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
6814			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;
6815			$cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
6816			$test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
6817			$rm_try;
6818		fi;
6819	else
6820		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;
6821		$cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
6822		$rm_try;
6823	fi;
6824	;;
6825*)
6826	case "$tval" in
6827	$define) tval=true;;
6828	*) tval=false;;
6829	esac;
6830	;;
6831esac;
6832eval "$2=$tval"'
6833
6834: define an is-in-libc? function
6835inlibc='echo " "; td=$define; tu=$undef;
6836sym=$1; var=$2; eval "was=\$$2";
6837tx=yes;
6838case "$reuseval$was" in
6839true) ;;
6840true*) tx=no;;
6841esac;
6842case "$tx" in
6843yes)
6844	set $sym tres -f;
6845	eval $csym;
6846	case "$tres" in
6847	true)
6848		echo "$sym() found." >&4;
6849		case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
6850	*)
6851		echo "$sym() NOT found." >&4;
6852		case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
6853	esac;;
6854*)
6855	case "$was" in
6856	$define) echo "$sym() found." >&4;;
6857	*) echo "$sym() NOT found." >&4;;
6858	esac;;
6859esac'
6860
6861: check for length of double
6862echo " "
6863case "$doublesize" in
6864'')
6865	echo "Checking to see how big your double precision numbers are..." >&4
6866	$cat >try.c <<EOCP
6867#include <stdio.h>
6868#$i_stdlib I_STDLIB
6869#ifdef I_STDLIB
6870#include <stdlib.h>
6871#endif
6872#include <stdio.h>
6873int main()
6874{
6875    printf("%d\n", (int)sizeof(double));
6876    exit(0);
6877}
6878EOCP
6879	set try
6880	if eval $compile_ok; then
6881		doublesize=`$run ./try`
6882		echo "Your double is $doublesize bytes long."
6883	else
6884		dflt='8'
6885		echo "(I can't seem to compile the test program.  Guessing...)"
6886		rp="What is the size of a double precision number (in bytes)?"
6887		. ./myread
6888		doublesize="$ans"
6889	fi
6890	;;
6891esac
6892$rm_try
6893
6894: check for long doubles
6895echo " " >&4
6896echo "Checking to see if you have long double..." >&4
6897echo 'int main() { long double x = 7.0; }' > try.c
6898set try
6899if eval $compile; then
6900	val="$define"
6901	echo "You have long double." >&4
6902else
6903	val="$undef"
6904	echo "You do not have long double." >&4
6905fi
6906$rm_try
6907set d_longdbl
6908eval $setvar
6909
6910: see if ldexpl exists
6911set ldexpl d_ldexpl
6912eval $inlibc
6913
6914: check for length of long double
6915case "${d_longdbl}${longdblsize}" in
6916$define)
6917	echo " " >&4
6918	echo "Checking to see how big your long doubles are..." >&4
6919	$cat >try.c <<'EOCP'
6920#include <stdio.h>
6921int main()
6922{
6923	printf("%d\n", sizeof(long double));
6924}
6925EOCP
6926	set try
6927	set try
6928	if eval $compile; then
6929		longdblsize=`$run ./try`
6930		echo "Your long doubles are $longdblsize bytes long." >&4
6931	else
6932		dflt='8'
6933		echo " " >&4
6934		echo "(I can't seem to compile the test program.  Guessing...)" >&4
6935		rp="What is the size of a long double (in bytes)?"
6936		. ./myread
6937		longdblsize="$ans"
6938	fi
6939	if $test "X$doublesize" = "X$longdblsize"; then
6940		echo "That isn't any different from an ordinary double." >&4
6941		echo "I'll keep your setting anyway, but you may see some" >&4
6942		echo "harmless compilation warnings." >&4
6943	fi
6944	;;
6945esac
6946$rm_try
6947
6948$echo "Checking the kind of long doubles you have..." >&4
6949case "$d_longdbl" in
6950define)
6951$cat <<EOP >try.c
6952#$i_stdlib I_STDLIB
6953#define LONGDBLSIZE $longdblsize
6954#define DOUBLESIZE $doublesize
6955#include <float.h>
6956#ifdef I_STDLIB
6957#include <stdlib.h>
6958#endif
6959#include <stdio.h>
6960static const long double d = -0.1L;
6961int main() {
6962  unsigned const char* b = (unsigned const char*)(&d);
6963#if DOUBLESIZE == LONGDBLSIZE
6964  printf("0\n"); /* if it floats like double */
6965  exit(0);
6966#endif
6967#if (LDBL_MANT_DIG == 113 || FLT128_MANT_DIG == 113) && LONGDBLSIZE == 16
6968  if (b[0] == 0x9A && b[1] == 0x99 && b[15] == 0xBF) {
6969    /* IEEE 754 128-bit little-endian */
6970    printf("1\n");
6971    exit(0);
6972  }
6973  if (b[0] == 0xBF && b[14] == 0x99 && b[15] == 0x9A) {
6974    /* IEEE 128-bit big-endian, e.g. solaris sparc */
6975    printf("2\n");
6976    exit(0);
6977  }
6978#endif
6979/* For alignment 32-bit platforms have the 80 bits in 12 bytes,
6980 * while 64-bits platforms have it in 16 bytes.  The trailing bytes
6981 * cannot be trusted. */
6982#if LDBL_MANT_DIG == 64 && (LONGDBLSIZE == 16 || LONGDBLSIZE == 12)
6983  if (b[0] == 0xCD && b[9] == 0xBF) {
6984    /* x86 80-bit little-endian, sizeof 12 (ILP32, Solaris x86)
6985     * or 16 (LP64, Linux and OS X), 4 or 6 bytes of padding.
6986     * Also known as "extended precision". */
6987    printf("3\n");
6988    exit(0);
6989  }
6990  if (b[0] == 0xBF && b[9] == 0xCD) {
6991    /* Is there ever big-endian 80-bit, really?
6992     *
6993     * The Motorola 68881 had another "extended precision" format:
6994     * sign:1 exp:15 zero:16 integer:1 mantissa:63
6995     * for total of 96 bits of bytes.  The zero bits were unused.
6996     * See "M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL" for more details.
6997     * If it ever becomes relevant, this format should be allocated a
6998     * new doublekind code since it is quite different from the Intel x87.
6999     */
7000    printf("4\n");
7001    exit(0);
7002  }
7003#endif
7004#if (LDBL_MANT_DIG == 106 || LDBL_MANT_DIG == 107) && LONGDBLSIZE == 16
7005  /* software "double double", the 106 is 53+53.
7006   * but irix thinks it is 107. */
7007  if (b[0] == 0x9A && b[7] == 0x3C && b[8] == 0x9A && b[15] == 0xBF) {
7008    /* double double 128-bit fully little-endian,
7009     * little-endian doubles in little-endian order,
7010     * 9a 99 99 99 99 99 59 3c 9a 99 99 99 99 99 b9 bf */
7011    printf("5\n");
7012    exit(0);
7013  }
7014  if (b[0] == 0xBF && b[7] == 0x9A && b[8] == 0x3C && b[15] == 0x9A) {
7015    /* double double 128-bit fully big-endian,
7016     * big-endian doubles in big-endian order,
7017     * e.g. PPC/Power and MIPS:
7018     * bf b9 99 99 99 99 99 9a 3c 59 99 99 99 99 99 9a */
7019    printf("6\n");
7020    exit(0);
7021  }
7022  if (b[0] == 0x9A && b[7] == 0xBF && b[8] == 0x9A && b[15] == 0x3C) {
7023    /* double double 128-bit mixed endian.
7024     * little-endian doubles in big-endian order,
7025     * e.g. ppc64el,
7026     * 9a 99 99 99 99 99 b9 bf 9a 99 99 99 99 99 59 3c */
7027    printf("7\n");
7028    exit(0);
7029  }
7030  if (b[0] == 0x3C && b[7] == 0x9A && b[8] == 0xBF && b[15] == 0x9A) {
7031    /* double double 128-bit mixed endian,
7032     * big-endian doubles in little-endian order,
7033     * 3c 59 99 99 99 99 99 9a bf b9 99 99 99 99 99 9a */
7034    printf("8\n");
7035    exit(0);
7036  }
7037#endif
7038/* We are largely making this up because it may well be
7039 * that the VAX format H was never made available to C,
7040 * only to Fortran. */
7041#if LONGDBLSIZE == 16 && defined(__vax__)
7042  if (b[0] == 0xFD && b[15] == 0x99) {
7043    /* VAX format H, PDP-11 mixed endian. */
7044    printf("9\n");
7045    exit(0);
7046  }
7047#endif
7048  printf("-1\n"); /* unknown */
7049  exit(0);
7050}
7051EOP
7052set try
7053if eval $compile; then
7054    longdblkind=`$run ./try`
7055else
7056    longdblkind=-1
7057fi
7058;;
7059*) longdblkind=0 ;;
7060esac
7061case "$longdblkind" in
70620) echo "Your long doubles are doubles." >&4 ;;
70631) echo "You have IEEE 754 128-bit little endian long doubles." >&4 ;;
70642) echo "You have IEEE 754 128-bit big endian long doubles." >&4 ;;
70653) echo "You have x86 80-bit little endian long doubles." >&4 ;;
70664) echo "You have x86 80-bit big endian long doubles." >&4 ;;
70675) echo "You have 128-bit fully little-endian double-double long doubles (64-bit LEs in LE)." >&4 ;;
70686) echo "You have 128-bit fully big-endian double-double long doubles (64-bit BEs in BE)." >&4 ;;
70697) echo "You have 128-bit mixed-endian double-double long doubles (64-bit LEs in BE)." >&4 ;;
70708) echo "You have 128-bit mixed-endian double-double long doubles (64-bit BEs in LE)." >&4 ;;
70719) echo "You have 128-bit PDP-style mixed-endian long doubles (VAX format H)." >&4 ;;
7072*) echo "Cannot figure out your long double." >&4 ;;
7073esac
7074d_long_double_style_ieee=$undef
7075d_long_double_style_ieee_std=$undef
7076d_long_double_style_ieee_extended=$undef
7077d_long_double_style_ieee_doubledouble=$undef
7078d_long_double_style_vax=$undef
7079case "$longdblkind" in
70801|2|3|4|5|6|7|8) d_long_double_style_ieee=$define ;;
7081esac
7082case "$longdblkind" in
70831|2) d_long_double_style_ieee_std=$define ;;
7084esac
7085case "$longdblkind" in
70863|4) d_long_double_style_ieee_extended=$define ;;
7087esac
7088case "$longdblkind" in
70895|6|7|8) d_long_double_style_ieee_doubledouble=$define ;;
7090esac
7091case "$longdblkind" in
70929) d_long_double_style_vax=$define ;;
7093esac
7094$rm_try
7095
7096: get the patchlevel
7097echo " "
7098echo "Getting the current patchlevel..." >&4
7099if $test -r $rsrc/patchlevel.h;then
7100	revision=`awk '/define[ 	]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
7101	patchlevel=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
7102	subversion=`awk '/define[ 	]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
7103	api_revision=`awk '/define[ 	]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
7104	api_version=`awk '/define[ 	]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
7105	api_subversion=`awk '/define[ 	]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
7106	perl_patchlevel=`egrep ',"(MAINT|SMOKE)[0-9][0-9]*"' $rsrc/patchlevel.h|tail -1|sed 's/[^0-9]//g'`
7107else
7108	revision=0
7109	patchlevel=0
7110	subversion=0
7111	api_revision=0
7112	api_version=0
7113	api_subversion=0
7114	perl_patchlevel=0
7115	$echo "(You do not have patchlevel.h.  Eek.)"
7116fi
7117: Define a handy string here to avoid duplication in myconfig.SH and configpm.
7118version_patchlevel_string="version $patchlevel subversion $subversion"
7119case "$perl_patchlevel" in
71200|'') ;;
7121*)  perl_patchlevel=`echo $perl_patchlevel | sed 's/.* //'`
7122    version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel"
7123    ;;
7124esac
7125
7126$echo "(You have $package $version_patchlevel_string.)"
7127
7128case "$osname" in
7129dos|vms)
7130	: XXX Should be a Configure test for double-dots in filenames.
7131	version=`echo $revision $patchlevel $subversion | \
7132		 $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
7133	api_versionstring=`echo $api_revision $api_version $api_subversion | \
7134		 $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
7135	;;
7136*)
7137	version=`echo $revision $patchlevel $subversion | \
7138		 $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
7139	api_versionstring=`echo $api_revision $api_version $api_subversion | \
7140		 $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
7141	;;
7142esac
7143: Special case the 5.005_xx maintenance series, which used 5.005
7144: without any subversion label as a subdirectory in $sitelib
7145if test "${api_revision}${api_version}${api_subversion}" = "550"; then
7146	api_versionstring='5.005'
7147fi
7148
7149: Check if quadmath is requested
7150case "$usequadmath" in
7151"$define"|true|[yY]*) usequadmath="$define" ;;
7152*)                    usequadmath="$undef"  ;;
7153esac
7154
7155: Fail if both uselongdouble and usequadmath are requested
7156case "$usequadmath:$uselongdouble" in
7157define:define)
7158	$cat <<EOM >&4
7159
7160*** You requested the use of the quadmath library and use
7161*** of long doubles.
7162***
7163*** Please select one or the other.
7164EOM
7165	exit 1
7166	;;
7167esac
7168
7169: determine the architecture name
7170echo " "
7171if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
7172	tarch=`arch`"-$osname"
7173elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
7174	if uname -m > tmparch 2>&1 ; then
7175		tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
7176			-e 's/$/'"-$osname/" tmparch`
7177	else
7178		tarch="$osname"
7179	fi
7180	$rm -f tmparch
7181else
7182	tarch="$osname"
7183fi
7184case "$myarchname" in
7185''|"$tarch") ;;
7186*)
7187	echo "(Your architecture name used to be $myarchname.)"
7188	archname=''
7189	;;
7190esac
7191case "$targetarch" in
7192'') ;;
7193*)  archname=`echo $targetarch|sed 's,^[^-]*-,,'` ;;
7194esac
7195myarchname="$tarch"
7196case "$archname" in
7197'') dflt="$tarch";;
7198*) dflt="$archname";;
7199esac
7200rp='What is your architecture name'
7201. ./myread
7202archname="$ans"
7203
7204: optionally add API version to the architecture for versioned archlibs
7205case "$useversionedarchname" in
7206$define|true|[yY]*) dflt='y';;
7207*)                  dflt='n';;
7208esac
7209rp='Add the Perl API version to your archname?'
7210. ./myread
7211case "$ans" in
7212y|Y)	useversionedarchname="$define" ;;
7213*)      useversionedarchname="$undef" ;;
7214esac
7215case "$useversionedarchname" in
7216$define)
7217	case "$archname" in
7218	*-$api_versionstring)
7219		echo "...and architecture name already has -$api_versionstring" >&4
7220		;;
7221	*)
7222		archname="$archname-$api_versionstring"
7223		echo "...setting architecture name to $archname." >&4
7224		;;
7225	esac
7226	;;
7227esac
7228
7229case "$usethreads" in
7230$define)
7231	echo "Threads selected." >&4
7232	case "$archname" in
7233	*-thread*) echo "...and architecture name already has -thread." >&4
7234		;;
7235	*)      archname="$archname-thread"
7236		echo "...setting architecture name to $archname." >&4
7237		;;
7238	esac
7239	;;
7240esac
7241case "$usemultiplicity" in
7242$define)
7243	echo "Multiplicity selected." >&4
7244	case "$archname" in
7245	*-multi*) echo "...and architecture name already has -multi." >&4
7246		;;
7247	*)      archname="$archname-multi"
7248		echo "...setting architecture name to $archname." >&4
7249		;;
7250	esac
7251	;;
7252esac
7253case "$use64bitint$use64bitall" in
7254*"$define"*)
7255	case "$archname64" in
7256	'')
7257		echo "This architecture is naturally 64-bit, not changing architecture name." >&4
7258		;;
7259	*)
7260		case "$use64bitint" in
7261		"$define") echo "64 bit integers selected." >&4 ;;
7262		esac
7263		case "$use64bitall" in
7264		"$define") echo "Maximal 64 bitness selected." >&4 ;;
7265		esac
7266		case "$archname" in
7267		*-$archname64*) echo "...and architecture name already has $archname64." >&4
7268			;;
7269		*)      archname="$archname-$archname64"
7270			echo "...setting architecture name to $archname." >&4
7271			;;
7272		esac
7273		;;
7274	esac
7275esac
7276case "$uselongdouble" in
7277$define)
7278	echo "Long doubles selected." >&4
7279	case "$longdblsize" in
7280	$doublesize)
7281		echo "...but long doubles are equal to doubles, not changing architecture name." >&4
7282		;;
7283	*)
7284		case "$archname" in
7285		*-ld*) echo "...and architecture name already has -ld." >&4
7286			;;
7287		*)      archname="$archname-ld"
7288			echo "...setting architecture name to $archname." >&4
7289			;;
7290		esac
7291		;;
7292	esac
7293	;;
7294esac
7295case "$usequadmath" in
7296$define)
7297	echo "quadmath selected." >&4
7298	case "$archname" in
7299	*-quadmath*) echo "...and architecture name already has -quadmath." >&4
7300		;;
7301	*)      archname="$archname-quadmath"
7302		echo "...setting architecture name to $archname." >&4
7303		;;
7304	esac
7305	;;
7306esac
7307if $test -f archname.cbu; then
7308	echo "Your platform has some specific hints for architecture name, using them..."
7309	. ./archname.cbu
7310fi
7311
7312: set the prefixit variable, to compute a suitable default value
7313prefixit='case "$3" in
7314""|none)
7315	case "$oldprefix" in
7316	"") eval "$1=\"\$$2\"";;
7317	*)
7318		case "$3" in
7319		"") eval "$1=";;
7320		none)
7321			eval "tp=\"\$$2\"";
7322			case "$tp" in
7323			""|" "|none) eval "$1=\"\$$2\"";;
7324			*) eval "$1=";;
7325			esac;;
7326		esac;;
7327	esac;;
7328*)
7329	eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
7330	case "$tp" in
7331	--|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
7332	/*-$oldprefix/*|\~*-$oldprefix/*)
7333		eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
7334	*) eval "$1=\"\$$2\"";;
7335	esac;;
7336esac'
7337
7338: determine installation style
7339: For now, try to deduce it from prefix unless it is already set.
7340: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
7341case "$installstyle" in
7342'')	case "$prefix" in
7343		*perl*) dflt='lib';;
7344		*) dflt='lib/perl5' ;;
7345	esac
7346	;;
7347*)	dflt="$installstyle" ;;
7348esac
7349: Probably not worth prompting for this since we prompt for all
7350: the directories individually, and the prompt would be too long and
7351: confusing anyway.
7352installstyle=$dflt
7353
7354: determine where public executables go
7355echo " "
7356set dflt bin bin
7357eval $prefixit
7358fn=d~
7359rp='Pathname where the public executables will reside?'
7360. ./getfile
7361if $test "X$ansexp" != "X$binexp"; then
7362	installbin=''
7363fi
7364prefixvar=bin
7365: XXX Bug? -- ignores Configure -Dinstallprefix setting.
7366: XXX If this is fixed, also fix the "start perl" hunk below, which relies on
7367:     this via initialinstalllocation
7368. ./setprefixvar
7369
7370case "$userelocatableinc" in
7371$define|true|[yY]*)	dflt='y' ;;
7372*)			dflt='n' ;;
7373esac
7374cat <<EOM
7375
7376Would you like to build Perl so that the installation is relocatable, so that
7377library paths in @INC are determined relative to the path of the perl binary?
7378This is not advised for system Perl installs, or if you need to run setid
7379scripts or scripts under taint mode.
7380
7381If this doesn't make any sense to you, just accept the default '$dflt'.
7382EOM
7383rp='Use relocatable @INC?'
7384. ./myread
7385case "$ans" in
7386y|Y)	val="$define" ;;
7387*)	val="$undef"  ;;
7388esac
7389set userelocatableinc
7390eval $setvar
7391
7392initialinstalllocation="$binexp"
7393: Default prefix is now "up one level from where the binaries are"
7394case "$userelocatableinc" in
7395$define|true|[yY]*)
7396    bin=".../"
7397    binexp=".../"
7398    prefix=".../.."
7399    prefixexp=".../.."
7400    installprefixexp=".../.."
7401    ;;
7402esac
7403
7404: determine where private library files go
7405: Usual default is /usr/local/lib/perl5/$version.
7406: Also allow things like /opt/perl/lib/$version, since
7407: /opt/perl/lib/perl5... would be redundant.
7408: The default "style" setting is made in installstyle.U
7409case "$installstyle" in
7410*lib/perl5*) set dflt privlib lib/$package/$version ;;
7411*)	 set dflt privlib lib/$version ;;
7412esac
7413eval $prefixit
7414$cat <<EOM
7415
7416There are some auxiliary files for $package that need to be put into a
7417private library directory that is accessible by everyone.
7418
7419EOM
7420fn=$binexp
7421fn=d~+
7422rp='Pathname where the private library files will reside?'
7423. ./getfile
7424prefixvar=privlib
7425. ./setprefixvar
7426
7427: set the prefixup variable, to restore leading tilda escape
7428prefixup='case "$prefixexp" in
7429"$prefix") ;;
7430*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
7431esac'
7432
7433: determine where public architecture dependent libraries go
7434set archlib archlib
7435eval $prefixit
7436: privlib default is /usr/local/lib/$package/$version
7437: archlib default is /usr/local/lib/$package/$version/$archname
7438: privlib may have an optional trailing /share.
7439tdflt=`echo $privlib | $sed 's,/share$,,'`
7440tdflt=$tdflt/$archname
7441case "$archlib" in
7442'')	dflt=$tdflt
7443	;;
7444*)	dflt="$archlib"
7445    ;;
7446esac
7447$cat <<EOM
7448
7449$spackage contains architecture-dependent library files.  If you are
7450sharing libraries in a heterogeneous environment, you might store
7451these files in a separate location.  Otherwise, you can just include
7452them with the rest of the public library files.
7453
7454EOM
7455fn=$binexp
7456fn=d+~
7457rp='Where do you want to put the public architecture-dependent libraries?'
7458. ./getfile
7459prefixvar=archlib
7460. ./setprefixvar
7461if $test X"$archlib" = X"$privlib"; then
7462	d_archlib="$undef"
7463else
7464	d_archlib="$define"
7465fi
7466
7467: see if setuid scripts can be secure
7468$cat <<EOM
7469
7470Some kernels have a bug that prevents setuid #! scripts from being
7471secure.  Some sites have disabled setuid #! scripts because of this.
7472
7473First let's decide if your kernel supports secure setuid #! scripts.
7474(If setuid #! scripts would be secure but have been disabled anyway,
7475don't say that they are secure if asked.)
7476
7477EOM
7478
7479val="$undef"
7480if $test -d /dev/fd; then
7481	echo "#!$ls" >reflect
7482	chmod +x,u+s reflect
7483	./reflect >flect 2>&1
7484	if $contains "/dev/fd" flect >/dev/null; then
7485		echo "Congratulations, your kernel has secure setuid scripts!" >&4
7486		val="$define"
7487	else
7488		$cat <<EOM
7489If you are not sure if they are secure, I can check but I'll need a
7490username and password different from the one you are using right now.
7491If you don't have such a username or don't want me to test, simply
7492enter 'none'.
7493
7494EOM
7495		rp='Other username to test security of setuid scripts with?'
7496		dflt='none'
7497		. ./myread
7498		case "$ans" in
7499		n|none)
7500			case "$d_suidsafe" in
7501			'')	echo "I'll assume setuid scripts are *not* secure." >&4
7502				dflt=n;;
7503			"$undef")
7504				echo "Well, the $hint value is *not* secure." >&4
7505				dflt=n;;
7506			*)	echo "Well, the $hint value *is* secure." >&4
7507				dflt=y;;
7508			esac
7509			;;
7510		*)
7511			$rm -f reflect flect
7512			echo "#!$ls" >reflect
7513			chmod +x,u+s reflect
7514			echo >flect
7515			chmod a+w flect
7516			echo '"su" will (probably) prompt you for '"$ans's password."
7517			su $ans -c './reflect >flect'
7518			if $contains "/dev/fd" flect >/dev/null; then
7519				echo "Okay, it looks like setuid scripts are secure." >&4
7520				dflt=y
7521			else
7522				echo "I don't think setuid scripts are secure." >&4
7523				dflt=n
7524			fi
7525			;;
7526		esac
7527		rp='Does your kernel have *secure* setuid scripts?'
7528		. ./myread
7529		case "$ans" in
7530		[yY]*)	val="$define";;
7531		*)	val="$undef";;
7532		esac
7533	fi
7534else
7535	echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
7536	echo "(That's for file descriptors, not floppy disks.)"
7537	val="$undef"
7538fi
7539set d_suidsafe
7540eval $setvar
7541
7542$rm -f reflect flect
7543
7544: now see if they want to do setuid emulation
7545if $test $patchlevel -lt 11; then
7546echo " "
7547val="$undef"
7548case "$d_suidsafe" in
7549"$define")
7550	val="$undef"
7551	echo "No need to emulate SUID scripts since they are secure here." >&4
7552	;;
7553*)
7554	$cat <<EOM
7555Some systems have disabled setuid scripts, especially systems where
7556setuid scripts cannot be secure.  On systems where setuid scripts have
7557been disabled, the setuid/setgid bits on scripts are currently
7558useless.  It is possible for $package to detect those bits and emulate
7559setuid/setgid in a secure fashion.  This emulation will only work if
7560setuid scripts have been disabled in your kernel.
7561
7562EOM
7563	case "$d_dosuid" in
7564	"$define") dflt=y ;;
7565	*) dflt=n ;;
7566	esac
7567	rp="Do you want to do setuid/setgid emulation?"
7568	. ./myread
7569	case "$ans" in
7570	[yY]*)	val="$define";;
7571	*)	val="$undef";;
7572	esac
7573	;;
7574esac
7575set d_dosuid
7576eval $setvar
7577else
7578    case "$d_dosuid" in
7579	"$define")
7580	cat >&4 <<EOH
7581
7582SUID emulation has been removed for 5.12
7583Please re-run Configure without -Dd_dosuid
7584
7585EOH
7586	exit 1;
7587	;;
7588    esac
7589    d_dosuid=undef
7590fi
7591
7592: Find perl5.005 or later.
7593echo "Looking for a previously installed perl5.005 or later... "
7594case "$perl5" in
7595'')	for tdir in `echo "$binexp$path_sep$PATH" | $sed "s/$path_sep/ /g"`; do
7596		: Check if this perl is recent and can load a simple module
7597		if $test -x $tdir/perl$exe_ext && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
7598			perl5=$tdir/perl
7599			break;
7600		elif $test -x $tdir/perl5$exe_ext && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
7601			perl5=$tdir/perl5
7602			break;
7603		fi
7604	done
7605	;;
7606*)	perl5="$perl5"
7607	;;
7608esac
7609case "$perl5" in
7610'')	echo "None found.  That's ok.";;
7611*)	echo "Using $perl5." ;;
7612esac
7613
7614: Set the siteprefix variables
7615$cat <<EOM
7616
7617After $package is installed, you may wish to install various
7618add-on modules and utilities.  Typically, these add-ons will
7619be installed under $prefix with the rest
7620of this package.  However, you may wish to install such add-ons
7621elsewhere under a different prefix.
7622
7623If you do not wish to put everything under a single prefix, that's
7624ok.  You will be prompted for the individual locations; this siteprefix
7625is only used to suggest the defaults.
7626
7627The default should be fine for most people.
7628
7629EOM
7630fn=d~+
7631rp='Installation prefix to use for add-on modules and utilities?'
7632: XXX Here might be another good place for an installstyle setting.
7633case "$siteprefix" in
7634'') dflt=$prefix ;;
7635*)  dflt=$siteprefix ;;
7636esac
7637. ./getfile
7638: XXX Prefixit unit does not yet support siteprefix and vendorprefix
7639oldsiteprefix=''
7640case "$siteprefix" in
7641'') ;;
7642*)	case "$ans" in
7643	"$prefix") ;;
7644	*) oldsiteprefix="$prefix";;
7645	esac
7646	;;
7647esac
7648siteprefix="$ans"
7649siteprefixexp="$ansexp"
7650
7651: determine where site specific libraries go.
7652: Usual default is /usr/local/lib/perl5/site_perl/$version
7653: The default "style" setting is made in installstyle.U
7654: XXX No longer works with Prefixit stuff.
7655prog=`echo $package | $sed 's/-*[0-9.]*$//'`
7656case "$sitelib" in
7657'') case "$installstyle" in
7658	*lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
7659	*)	 dflt=$siteprefix/lib/site_$prog/$version ;;
7660	esac
7661	;;
7662*)	dflt="$sitelib"
7663	;;
7664esac
7665$cat <<EOM
7666
7667The installation process will create a directory for
7668site-specific extensions and modules.  Most users find it convenient
7669to place all site-specific files in this directory rather than in the
7670main distribution directory.
7671
7672EOM
7673fn=d~+
7674rp='Pathname for the site-specific library files?'
7675. ./getfile
7676prefixvar=sitelib
7677. ./setprefixvar
7678sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
7679
7680: Determine list of previous versions to include in @INC
7681$cat > getverlist <<EOPL
7682#!$perl5
7683use strict;
7684use warnings;
7685use File::Basename;
7686my \$api_versionstring = "$api_versionstring";
7687my \$version = "$version";
7688my \$stem = "$sitelib_stem";
7689my \$archname = "$archname";
7690EOPL
7691	$cat >> getverlist <<'EOPL'
7692# The list found is stored twice for each entry: the original name, and
7693# the binary broken down version into pack "s>s>s>", so sorting is easy
7694# and unambiguous.  This will work for all versions that have a maximum
7695# of three digit per group separate by '.'s or '_'s. Names are extended
7696# with ".0.0" to ensure at least three elements for the pack.
7697#                                   -- H.Merijn Brand (m)'06 23-10-2006
7698
7699my @inc_version_list;
7700my @candidates;
7701# XXX Redo to do opendir/readdir?
7702if (-d $stem) {
7703    chdir($stem);
7704    ;@candidates = map {
7705	[ $_, pack "s>s>s>", split m/[._]/, "$_.0.0" ] } glob("5.*");
7706    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
7707}
7708else {
7709    ;@candidates = ();
7710}
7711
7712my ($pversion, $aversion, $vsn5005) = map {
7713    pack "s>s>s>", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005";
7714foreach my $d (@candidates) {
7715    if ($d->[1] lt $pversion) {
7716	if ($d->[1] ge $aversion) {
7717	    unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);
7718	}
7719	elsif ($d->[1] ge $vsn5005) {
7720	    unshift(@inc_version_list, grep { -d } $d->[0]);
7721	}
7722    }
7723    else {
7724	# Skip newer version.  I.e. don't look in
7725	# 5.7.0 if we're installing 5.6.1.
7726    }
7727}
7728
7729if (@inc_version_list) {
7730    print join(' ', @inc_version_list);
7731}
7732else {
7733    # Blank space to preserve value for next Configure run.
7734    print " ";
7735}
7736EOPL
7737chmod +x getverlist
7738case "$inc_version_list" in
7739'')	if test -x "$perl5$exe_ext"; then
7740		dflt=`$perl5 getverlist`
7741	else
7742		dflt='none'
7743	fi
7744	;;
7745$undef) dflt='none' ;;
7746*)  eval dflt=\"$inc_version_list\" ;;
7747esac
7748case "$dflt" in
7749''|' ') dflt=none ;;
7750esac
7751case "$dflt" in
77525.005) dflt=none ;;
7753esac
7754$cat <<EOM
7755
7756In order to ease the process of upgrading, this version of perl
7757can be configured to use modules built and installed with earlier
7758versions of perl that were installed under $prefix.  Specify here
7759the list of earlier versions that this version of perl should check.
7760If Configure detected no earlier versions of perl installed under
7761$prefix, then the list will be empty.  Answer 'none' to tell perl
7762to not search earlier versions.
7763
7764The default should almost always be sensible, so if you're not sure,
7765just accept the default.
7766EOM
7767
7768rp='List of earlier versions to include in @INC?'
7769. ./myread
7770case "$ans" in
7771[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
7772*) inc_version_list="$ans" ;;
7773esac
7774case "$inc_version_list" in
7775''|' ')
7776	inc_version_list_init='0'
7777	d_inc_version_list="$undef"
7778	;;
7779*)	inc_version_list_init=`echo $inc_version_list |
7780		$sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
7781	d_inc_version_list="$define"
7782	;;
7783esac
7784$rm -f getverlist
7785
7786: check for length of pointer
7787echo " "
7788case "$ptrsize" in
7789'')
7790	echo "Checking to see how big your pointers are..." >&4
7791	$cat >try.c <<EOCP
7792#include <stdio.h>
7793#$i_stdlib I_STDLIB
7794#ifdef I_STDLIB
7795#include <stdlib.h>
7796#endif
7797int main()
7798{
7799    printf("%d\n", (int)sizeof(void *));
7800    exit(0);
7801}
7802EOCP
7803	set try
7804	if eval $compile_ok; then
7805		ptrsize=`$run ./try`
7806		echo "Your pointers are $ptrsize bytes long."
7807	else
7808		dflt='4'
7809		echo "(I can't seem to compile the test program.  Guessing...)" >&4
7810		rp="What is the size of a pointer (in bytes)?"
7811		. ./myread
7812		ptrsize="$ans"
7813	fi
7814	;;
7815esac
7816$rm_try
7817case "$use64bitall" in
7818"$define"|true|[yY]*)
7819	case "$ptrsize" in
7820	4)	cat <<EOM >&4
7821
7822*** You have chosen a maximally 64-bit build,
7823*** but your pointers are only 4 bytes wide.
7824*** Please rerun Configure without -Duse64bitall.
7825EOM
7826		case "$d_quad" in
7827		define)
7828			cat <<EOM >&4
7829*** Since you have quads, you could possibly try with -Duse64bitint.
7830EOM
7831			;;
7832		esac
7833		cat <<EOM >&4
7834*** Cannot continue, aborting.
7835
7836EOM
7837
7838		exit 1
7839		;;
7840	esac
7841	;;
7842esac
7843
7844: determine whether to use malloc wrapping
7845echo " "
7846case "$usemallocwrap" in
7847[yY]*|true|$define)	dflt='y' ;;
7848[nN]*|false|$undef)	dflt='n' ;;
7849*)	case "$usedevel" in
7850	[yY]*|true|$define)	dflt='y' ;;
7851	*) dflt='n' ;;
7852	esac
7853	;;
7854esac
7855rp="Do you wish to wrap malloc calls to protect against potential overflows?"
7856. ./myread
7857usemallocwrap="$ans"
7858case "$ans" in
7859y*|true)
7860	usemallocwrap="$define" ;;
7861*)
7862	usemallocwrap="$undef" ;;
7863esac
7864
7865: determine which malloc to compile in
7866echo " "
7867case "$usemymalloc" in
7868[yY]*|true|$define)	dflt='y' ;;
7869[nN]*|false|$undef)	dflt='n' ;;
7870*)	case "$ptrsize" in
7871	4) dflt='y' ;;
7872	*) dflt='n' ;;
7873	esac
7874	if test "$useithreads" = "$define"; then dflt='n'; fi
7875	;;
7876esac
7877rp="Do you wish to attempt to use the malloc that comes with $package?"
7878. ./myread
7879usemymalloc="$ans"
7880case "$ans" in
7881y*|true)
7882	usemymalloc='y'
7883	mallocsrc='malloc.c'
7884	mallocobj="malloc$_o"
7885	d_mymalloc="$define"
7886	case "$libs" in
7887	*-lmalloc*)
7888		: Remove malloc from list of libraries to use
7889		echo "Removing unneeded -lmalloc from library list" >&4
7890		set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
7891		shift
7892		libs="$*"
7893		echo "libs = $libs" >&4
7894		;;
7895	esac
7896	;;
7897*)
7898	usemymalloc='n'
7899	mallocsrc=''
7900	mallocobj=''
7901	d_mymalloc="$undef"
7902	;;
7903esac
7904
7905: compute the return types of malloc and free
7906echo " "
7907case "$malloctype" in
7908'')
7909	malloctype='void *'
7910	;;
7911esac
7912echo "Your system wants malloc to return '$malloctype', it would seem." >&4
7913
7914case "$freetype" in
7915'')
7916	freetype='void'
7917	;;
7918esac
7919echo "Your system uses $freetype free(), it would seem." >&4
7920
7921: determine where site specific architecture-dependent libraries go.
7922: sitelib  default is /usr/local/lib/perl5/site_perl/$version
7923: sitearch default is /usr/local/lib/perl5/site_perl/$version/$archname
7924: sitelib may have an optional trailing /share.
7925case "$sitearch" in
7926'')	dflt=`echo $sitelib | $sed 's,/share$,,'`
7927	dflt="$dflt/$archname"
7928	;;
7929*)	dflt="$sitearch"
7930	;;
7931esac
7932set sitearch sitearch none
7933eval $prefixit
7934$cat <<EOM
7935
7936The installation process will also create a directory for
7937architecture-dependent site-specific extensions and modules.
7938
7939EOM
7940fn=d~+
7941rp='Pathname for the site-specific architecture-dependent library files?'
7942. ./getfile
7943prefixvar=sitearch
7944. ./setprefixvar
7945if $test X"$sitearch" = X"$sitelib"; then
7946	d_sitearch="$undef"
7947else
7948	d_sitearch="$define"
7949fi
7950
7951: Set the vendorprefix variables
7952$cat <<EOM
7953
7954The installation process will also create a directory for
7955vendor-supplied add-ons.  Vendors who supply perl with their system
7956may find it convenient to place all vendor-supplied files in this
7957directory rather than in the main distribution directory.  This will
7958ease upgrades between binary-compatible maintenance versions of perl.
7959
7960Of course you may also use these directories in whatever way you see
7961fit.  For example, you might use them to access modules shared over a
7962company-wide network.
7963
7964The default answer should be fine for most people.
7965This causes further questions about vendor add-ons to be skipped
7966and no vendor-specific directories will be configured for perl.
7967
7968EOM
7969rp='Do you want to configure vendor-specific add-on directories?'
7970case "$usevendorprefix" in
7971define|true|[yY]*) dflt=y ;;
7972*)	: User may have set vendorprefix directly on Configure command line.
7973	case "$vendorprefix" in
7974	''|' ') dflt=n ;;
7975	*)	dflt=y ;;
7976	esac
7977	;;
7978esac
7979. ./myread
7980case "$ans" in
7981[yY]*)	fn=d~+
7982	rp='Installation prefix to use for vendor-supplied add-ons?'
7983	case "$vendorprefix" in
7984	'') dflt="$prefix" ;;
7985	*)  dflt=$vendorprefix ;;
7986	esac
7987	. ./getfile
7988	: XXX Prefixit unit does not yet support siteprefix and vendorprefix
7989	oldvendorprefix=''
7990	case "$vendorprefix" in
7991	'') ;;
7992	*)	case "$ans" in
7993		"$prefix") ;;
7994		*) oldvendorprefix="$prefix";;
7995		esac
7996		;;
7997	esac
7998	usevendorprefix="$define"
7999	vendorprefix="$ans"
8000	vendorprefixexp="$ansexp"
8001	;;
8002*)	usevendorprefix="$undef"
8003	vendorprefix=''
8004	vendorprefixexp=''
8005	;;
8006esac
8007
8008: Set the vendorlib variables
8009case "$vendorprefix" in
8010'')	d_vendorlib="$undef"
8011	vendorlib=''
8012	vendorlibexp=''
8013	;;
8014*)	d_vendorlib="$define"
8015	: determine where vendor-supplied modules go.
8016	: Usual default is /usr/local/lib/perl5/vendor_perl/$version
8017	case "$vendorlib" in
8018	'')
8019		prog=`echo $package | $sed 's/-*[0-9.]*$//'`
8020		case "$installstyle" in
8021		*lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
8022		*)	     dflt=$vendorprefix/lib/vendor_$prog/$version ;;
8023		esac
8024		;;
8025	*)	dflt="$vendorlib"
8026		;;
8027	esac
8028	fn=d~+
8029	rp='Pathname for the vendor-supplied library files?'
8030	. ./getfile
8031	vendorlib="$ans"
8032	vendorlibexp="$ansexp"
8033	;;
8034esac
8035vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
8036prefixvar=vendorlib
8037. ./installprefix
8038
8039: Set the vendorarch variables
8040case "$vendorprefix" in
8041'')	d_vendorarch="$undef"
8042	vendorarch=''
8043	vendorarchexp=''
8044	;;
8045*)	d_vendorarch="$define"
8046	: determine where vendor-supplied architecture-dependent libraries go.
8047	: vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
8048	: vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
8049	: vendorlib may have an optional trailing /share.
8050	case "$vendorarch" in
8051	'')	dflt=`echo $vendorlib | $sed 's,/share$,,'`
8052		dflt="$dflt/$archname"
8053		;;
8054	*)	dflt="$vendorarch" ;;
8055	esac
8056	fn=d~+
8057	rp='Pathname for vendor-supplied architecture-dependent files?'
8058	. ./getfile
8059	vendorarch="$ans"
8060	vendorarchexp="$ansexp"
8061	;;
8062esac
8063prefixvar=vendorarch
8064. ./installprefix
8065if $test X"$vendorarch" = X"$vendorlib"; then
8066	d_vendorarch="$undef"
8067else
8068	d_vendorarch="$define"
8069fi
8070
8071: Final catch-all directories to search
8072$cat <<EOM
8073
8074Lastly, you can have perl look in other directories for extensions and
8075modules in addition to those already specified.
8076These directories will be searched after
8077	$sitearch
8078	$sitelib
8079EOM
8080test X"$vendorlib" != "X" && echo '	' $vendorlib
8081test X"$vendorarch" != "X" && echo '	' $vendorarch
8082echo ' '
8083case "$otherlibdirs" in
8084''|' ') dflt='none' ;;
8085*)	dflt="$otherlibdirs" ;;
8086esac
8087$cat <<EOM
8088Enter a colon-separated set of extra paths to include in perl's @INC
8089search path, or enter 'none' for no extra paths.
8090
8091EOM
8092
8093rp='Colon-separated list of additional directories for perl to search?'
8094. ./myread
8095case "$ans" in
8096' '|''|none)	otherlibdirs=' ' ;;
8097*)	otherlibdirs="$ans" ;;
8098esac
8099case "$otherlibdirs" in
8100' ') val=$undef ;;
8101*)	val=$define ;;
8102esac
8103set d_perl_otherlibdirs
8104eval $setvar
8105
8106: DTrace support
8107dflt_dtrace='/usr/sbin/dtrace'
8108$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/dtrace'
8109
8110cat <<EOM
8111
8112Perl can be built to support DTrace on platforms that support it.
8113DTrace is a diagnosis and performance analysis tool from Sun.
8114
8115If this doesn't make any sense to you, just accept the default.
8116EOM
8117
8118while $test 1 ; do
8119	case "$usedtrace" in
8120	$define|true|[yY]*)
8121		dflt='y'
8122		;;
8123	$undef|false|[nN]*)
8124		dflt='n'
8125		dflt_dtrace=""
8126		;;
8127	?*)
8128		dflt='y'
8129		dflt_dtrace=$usedtrace
8130		;;
8131	*)
8132		dflt='n'
8133		;;
8134	esac
8135
8136	rp='Support DTrace if available?'
8137	. ./myread
8138	case "$ans" in
8139	y|Y)	val="$define" ;;
8140	*)      val="$undef" ;;
8141	esac
8142	set usedtrace
8143	eval $setvar
8144
8145	test "X$usedtrace" != "X$define" && break
8146
8147	echo " "
8148	rp='Where is the dtrace executable?'
8149	dflt=$dflt_dtrace
8150	. ./getfile
8151	val="$ans"
8152	set dtrace
8153	eval $setvar
8154
8155	if $test -f $dtrace
8156	then
8157		if $dtrace -h -s ../perldtrace.d \
8158			-o perldtrace.tmp >/dev/null 2>&1 \
8159			&& rm -f perldtrace.tmp
8160		then
8161			echo " "
8162			echo "Good: your $dtrace knows about the -h flag."
8163		else
8164			cat >&2 <<EOM
8165
8166*** $me:  Fatal Error:  $dtrace doesn't support -h flag
8167***
8168*** Your installed dtrace doesn't support the -h switch to compile a D
8169*** program into a C header. Can't continue.
8170
8171EOM
8172			exit 1
8173		fi
8174		break;
8175	fi
8176
8177	case "$fastread" in
8178	yes)
8179		cat >&2 <<EOM
8180
8181*** $me:  Fatal Error:  $dtrace not found.
8182*** Can't continue.
8183
8184EOM
8185		exit 1
8186		;;
8187	*)
8188		echo "*** $dtrace was not found."
8189		echo " "
8190		;;
8191	esac
8192done
8193
8194: See if we want extra modules installed
8195echo " "
8196case "$extras" in
8197'') dflt='n';;
8198*) dflt='y';;
8199esac
8200cat <<EOM
8201Perl can be built with extra modules or bundles of modules which
8202will be fetched from the CPAN and installed alongside Perl.
8203
8204Notice that you will need access to the CPAN; either via the Internet,
8205or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
8206be asked later to configure the CPAN.pm module which will in turn do
8207the installation of the rest of the extra modules or bundles.)
8208
8209Notice also that if the modules require any external software such as
8210libraries and headers (the libz library and the zlib.h header for the
8211Compress::Zlib module, for example) you MUST have any such software
8212already installed, this configuration process will NOT install such
8213things for you.
8214
8215If this doesn't make any sense to you, just accept the default '$dflt'.
8216EOM
8217rp='Install any extra modules (y or n)?'
8218. ./myread
8219case "$ans" in
8220y|Y)
8221	cat <<EOM
8222
8223Please list any extra modules or bundles to be installed from CPAN,
8224with spaces between the names.  The names can be in any format the
8225'install' command of CPAN.pm will understand.  (Answer 'none',
8226without the quotes, to install no extra modules or bundles.)
8227EOM
8228	rp='Extras?'
8229	dflt="$extras"
8230	. ./myread
8231	extras="$ans"
8232esac
8233case "$extras" in
8234''|'none')
8235	val=''
8236	$rm -f ../extras.lst
8237	;;
8238*)	echo "(Saving the list of extras for later...)"
8239	echo "$extras" > ../extras.lst
8240	val="'$extras'"
8241	;;
8242esac
8243set extras
8244eval $setvar
8245echo " "
8246
8247: determine where html pages for programs go
8248set html1dir html1dir none
8249eval $prefixit
8250$cat <<EOM
8251
8252If you wish to install html files for programs in $spackage, indicate
8253the appropriate directory here.  To skip installing html files,
8254answer "none".
8255EOM
8256case "$html1dir" in
8257''|none|$undef|' ') dflt=none ;;
8258*) dflt=$html1dir ;;
8259esac
8260fn=dn+~
8261rp="Directory for the main $spackage html pages?"
8262. ./getfile
8263prefixvar=html1dir
8264. ./setprefixvar
8265: Use ' ' for none so value is preserved next time through Configure
8266$test X"$html1dir" = "X" && html1dir=' '
8267
8268: determine where html pages for libraries and modules go
8269set html3dir html3dir none
8270eval $prefixit
8271$cat <<EOM
8272
8273If you wish to install html files for modules associated with $spackage,
8274indicate the appropriate directory here.  To skip installing html files,
8275answer "none".
8276EOM
8277: There is no obvious default.  If they have specified html1dir, then
8278: try to key off that, possibly changing .../html1 into .../html3.
8279case "$html3dir" in
8280'') html3dir=`echo "$html1dir" | $sed 's/1$/3$/'` ;;
8281*) dflt=$html3dir ;;
8282esac
8283fn=dn+~
8284rp="Directory for the $spackage module html pages?"
8285. ./getfile
8286prefixvar=html3dir
8287. ./setprefixvar
8288: Use ' ' for none so value is preserved next time through Configure
8289$test X"$html3dir" = "X" && html3dir=' '
8290
8291: determine whether to install perl also as /usr/bin/perl
8292
8293echo " "
8294if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
8295	$cat <<EOM
8296Many scripts expect perl to be installed as /usr/bin/perl.
8297
8298If you want to, I can install the perl you are about to compile
8299as /usr/bin/perl (in addition to $bin/perl).
8300EOM
8301	if test -f /usr/bin/perl; then
8302	    $cat <<EOM
8303
8304However, please note that because you already have a /usr/bin/perl,
8305overwriting that with a new Perl would very probably cause problems.
8306Therefore I'm assuming you don't want to do that (unless you insist).
8307
8308EOM
8309	    case "$installusrbinperl" in
8310	    "$define"|[yY]*)	dflt='y';;
8311	    *)			dflt='n';;
8312	    esac
8313	else
8314	    $cat <<EOM
8315
8316Since you don't have a /usr/bin/perl I'm assuming creating one is okay.
8317
8318EOM
8319	    case "$installusrbinperl" in
8320	    "$undef"|[nN]*)	dflt='n';;
8321	    *)			dflt='y';;
8322	    esac
8323	fi
8324	rp="Do you want to install perl as /usr/bin/perl?"
8325	. ./myread
8326	case "$ans" in
8327	[yY]*)	val="$define";;
8328	*)	val="$undef" ;;
8329	esac
8330else
8331	val="$undef"
8332fi
8333set installusrbinperl
8334eval $setvar
8335
8336: see if dlopen exists
8337xxx_runnm="$runnm"
8338xxx_ccflags="$ccflags"
8339runnm=false
8340: with g++ one needs -shared to get is-in-libc to work for dlopen
8341case "$gccversion" in
8342'')	;;
8343*Clang*)	;;
8344*)	case "$d_cplusplus" in
8345	"$define") ccflags="$ccflags -shared" ;;
8346	esac
8347	;;
8348esac
8349set dlopen d_dlopen
8350eval $inlibc
8351runnm="$xxx_runnm"
8352ccflags="$xxx_ccflags"
8353
8354: see if this is a unistd.h system
8355set unistd.h i_unistd
8356eval $inhdr
8357
8358: determine which dynamic loading, if any, to compile in
8359echo " "
8360dldir="ext/DynaLoader"
8361case "$usedl" in
8362    $define|y|true)
8363	dflt='y'
8364	usedl="$define"
8365	;;
8366    $undef|n|false)
8367	dflt='n'
8368	usedl="$undef"
8369	;;
8370    *)
8371	dflt='n'
8372	case "$d_dlopen" in
8373	    $define) dflt='y' ;;
8374	esac
8375	: Does a dl_xxx.xs file exist for this operating system
8376	$test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
8377	;;
8378esac
8379rp="Do you wish to use dynamic loading?"
8380. ./myread
8381usedl="$ans"
8382bin_ELF="$undef"
8383case "$ans" in
8384    y*) usedl="$define"
8385	case "$dlsrc" in
8386	    '') if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
8387		    dflt="$dldir/dl_${osname}.xs"
8388		elif $test "$d_dlopen" = "$define" ; then
8389		    dflt="$dldir/dl_dlopen.xs"
8390		else
8391		    dflt=''
8392		fi
8393		;;
8394	    *)  dflt="$dldir/$dlsrc"
8395		;;
8396	esac
8397	echo "The following dynamic loading files are available:"
8398	: Can not go over to $dldir because getfile has path hard-coded in.
8399	tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir"
8400	rp="Source file to use for dynamic loading"
8401	fn="fne"
8402	gfpth="$src"
8403	. ./getfile
8404	usedl="$define"
8405	: emulate basename
8406	dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'`
8407
8408	$cat << EOM
8409
8410Some systems may require passing special flags to $cc -c to
8411compile modules that will be used to create a shared library.
8412To use no flags, say "none".
8413
8414EOM
8415	case "$cccdlflags" in
8416	    '') case "$gccversion" in
8417		'') case "$osname" in
8418			hpux)	dflt='+z' ;;
8419			irix*)	dflt='-KPIC' ;;
8420			svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
8421			sunos)	dflt='-pic' ;;
8422			*)	dflt='none' ;;
8423		    esac
8424		    ;;
8425		*)  case "$osname" in
8426			darwin) dflt='none' ;;
8427			*linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
8428			*)	dflt='-fpic' ;;
8429		    esac ;;
8430		esac ;;
8431	    ' ') dflt='none' ;;
8432	    *)   dflt="$cccdlflags" ;;
8433	esac
8434
8435	case "$dflt" in
8436	    none) dflt='' ;;
8437	esac
8438
8439	# If -Dsysroot was specified, now's the time to add it
8440	# to cccdlflags
8441	if test "X$sysroot" != X; then
8442	    case "$gccversion" in
8443		'') ;;
8444		*)  case "$dflt" in
8445			*sysroot*) ;;
8446			'undef'|*)
8447			    dflt="$dflt --sysroot=$sysroot" ;;
8448		    esac
8449		    ;;
8450	    esac
8451	fi
8452
8453	case "$dflt" in
8454	    '') dflt='none';;
8455	esac
8456
8457	rp="Any special flags to pass to $cc -c to compile shared library modules?"
8458	. ./myread
8459	case "$ans" in
8460	    none) cccdlflags=' ' ;;
8461	    *)    cccdlflags="$ans" ;;
8462	esac
8463
8464	cat << EOM
8465
8466Some systems use ld to create libraries that can be dynamically loaded,
8467while other systems (such as those using ELF) use $cc.
8468
8469EOM
8470
8471: Determine if this is ELF
8472	$cat >try.c <<EOM
8473/* Test for whether ELF binaries are produced */
8474#include <fcntl.h>
8475#$i_stdlib I_STDLIB
8476#ifdef I_STDLIB
8477#include <stdlib.h>
8478#endif
8479#$i_unistd I_UNISTD
8480#ifdef I_UNISTD
8481#include <unistd.h>
8482#endif
8483int main() {
8484    char b[4];
8485    int i = open("a.out",O_RDONLY);
8486    if(i == -1)
8487	exit(1); /* fail */
8488    if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
8489	exit(0); /* succeed (yes, it is ELF) */
8490    exit(1); /* fail */
8491}
8492EOM
8493	if $cc $ccflags $ldflags -o a.out try.c >/dev/null 2>&1 && $run ./a.out; then
8494	    bin_ELF="$define"
8495	fi
8496	$rm_try
8497
8498	case "$ld" in
8499	    '') if $test $bin_ELF = "$define"; then
8500		    cat <<EOM
8501You appear to have ELF support.  I'll use $cc to build dynamic libraries.
8502EOM
8503		    dflt="$cc"
8504		else
8505		    echo "I'll use ld to build dynamic libraries."
8506		    dflt='ld'
8507		fi
8508		;;
8509	    *)  dflt="$ld"
8510		;;
8511	esac
8512
8513	rp="What command should be used to create dynamic libraries?"
8514	. ./myread
8515	ld="$ans"
8516
8517	cat << EOM
8518
8519Some systems may require passing special flags to $ld to create a
8520library that can be dynamically loaded.  If your ld flags include
8521-L/other/path options to locate libraries outside your loader's normal
8522search path, you may need to specify those -L options here as well.  To
8523use no flags, say "none".
8524
8525EOM
8526	case "$lddlflags" in
8527	    '') case "$osname" in
8528		    haiku) dflt='-shared' ;;
8529		    hpux) dflt='-b';
8530			  case "$gccversion" in
8531			      '') dflt="$dflt +vnocompatwarnings" ;;
8532			  esac
8533			  ;;
8534		    *linux*|irix*|gnu*)  dflt="-shared $optimize" ;;
8535		    solaris) # See [perl #66604].
8536			    # On Solaris 11, gcc -m64 on amd64
8537			    # appears not to understand -G.  gcc versions at
8538			    # least as old as 3.4.3 support -shared, so just
8539			    # use that with Solaris 11 and later, but keep
8540			    # the old behavior for older Solaris versions.
8541			    case "$gccversion" in
8542				'') dflt='-G' ;;
8543				*)  case "$osvers" in
8544					2.?|2.10) dflt='-G' ;;
8545					*) dflt='-shared' ;;
8546				    esac
8547				    ;;
8548			    esac
8549			    ;;
8550		    sunos) dflt='-assert nodefinitions' ;;
8551		    svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
8552		    *)     dflt='none' ;;
8553		esac
8554		;;
8555	    *) dflt="$lddlflags" ;;
8556	esac
8557
8558	: Only do this for gcc, since, for example, qcc has no concept
8559	: of --sysroot.
8560	if $test "X$sysroot" != X; then
8561	    case "$gccversion" in
8562		'') ;;
8563		*)  dflt="$dflt --sysroot=$sysroot" ;;
8564	    esac
8565	fi
8566
8567	: Try to guess additional flags to pick up local libraries.
8568	: Be careful not to append to a plain 'none'
8569	case "$dflt" in
8570	    none) dflt='' ;;
8571	esac
8572	for thisflag in $ldflags; do
8573	    case "$thisflag" in
8574		-L*|-R*|-Wl,-R*)
8575		    case " $dflt " in
8576			*" $thisflag "*) ;;
8577			*) dflt="$dflt $thisflag" ;;
8578		    esac
8579		    ;;
8580	    esac
8581	done
8582
8583	case "$dflt" in
8584	    ''|' ') dflt='none' ;;
8585	esac
8586
8587	case "$ldflags" in
8588	    *-fstack-protector-strong*)
8589		case "$dflt" in
8590		    *-fstack-protector-strong*) ;; # Don't add it again
8591		    *) dflt="$dflt -fstack-protector-strong" ;;
8592		esac
8593		;;
8594	    *-fstack-protector*)
8595		case "$dflt" in
8596		    *-fstack-protector*) ;; # Don't add it again
8597		    *) dflt="$dflt -fstack-protector" ;;
8598		esac
8599		;;
8600	esac
8601
8602	rp="Any special flags to pass to $ld to create a dynamically loaded library?"
8603	. ./myread
8604	case "$ans" in
8605	    none) lddlflags=' ' ;;
8606	    *) lddlflags="$ans" ;;
8607	esac
8608
8609	cat <<EOM
8610
8611Some systems may require passing special flags to $cc to indicate that
8612the resulting executable will use dynamic linking.  To use no flags,
8613say "none".
8614
8615EOM
8616	case "$ccdlflags" in
8617	    '') case "$osname" in
8618		    *linux*|hpux|gnu*) dflt='-Wl,-E' ;;
8619		    sunos)             dflt='none'   ;;
8620		    *)                 dflt='none'   ;;
8621		esac ;;
8622	    ' ') dflt='none' ;;
8623	    *)   dflt="$ccdlflags" ;;
8624	esac
8625	rp="Any special flags to pass to $cc to use dynamic linking?"
8626	. ./myread
8627	case "$ans" in
8628	    none) ccdlflags=' ' ;;
8629	    *)    ccdlflags="$ans" ;;
8630	esac
8631	;;
8632
8633    *)  usedl="$undef"
8634	ld='ld'
8635	dlsrc='dl_none.xs'
8636	lddlflags=''
8637	ccdlflags=''
8638	;;
8639esac
8640
8641ld_can_script="$undef"
8642case "$bin_ELF$usedl" in
8643    $define$define)
8644	# Abuse try.h and a.out names for neat cleanup
8645	$cat >try.c <<EOM
8646void foo() {}
8647void bar() {}
8648EOM
8649	$cat >try.h <<EOM
8650LIBTEST_42 {
8651 global:
8652  foo;
8653 local: *;
8654 };
8655EOM
8656	if $cc $cccdlflags $ccdlflags $ccflags \
8657	       $ldflags $lddlflags -o a.out try.c \
8658	       -Wl,--version-script=try.h >/dev/null 2>&1 \
8659	   &&  $test -s a.out ; then
8660	    echo "ld supports scripting" >&4
8661	    ld_can_script="$define"
8662	else
8663	    echo "ld does not support scripting" >&4
8664	fi
8665	$rm_try
8666	;;
8667esac
8668
8669: Do we want a shared libperl?
8670also=''
8671case "$usedl" in
8672$undef)
8673	# No dynamic loading being used, so don't bother even to prompt.
8674	useshrplib='false'
8675	;;
8676*)	case "$useshrplib" in
8677	'')	case "$osname" in
8678		svr4*|nonstopux|dgux|dynixptx|esix|powerux|haiku|cygwin*)
8679			dflt=y
8680			also='Building a shared libperl is required for dynamic loading to work on your system.'
8681			;;
8682		*)	dflt=n
8683			;;
8684		esac
8685		;;
8686	$define|true|[Yy]*)
8687		dflt=y
8688		;;
8689	*)	dflt=n
8690		;;
8691	esac
8692	$cat << EOM
8693
8694The perl executable is normally obtained by linking perlmain.c with
8695libperl${_a}, any static extensions (usually just DynaLoader), and
8696any other libraries needed on this system (such as -lm, etc.).  Since
8697your system supports dynamic loading, it is probably possible to build
8698a shared libperl.$so.  If you will have more than one executable linked
8699to libperl.$so, this will significantly reduce the size of each
8700executable, but it may have a noticeable effect on performance.  The
8701default is probably sensible for your system.
8702$also
8703
8704EOM
8705	rp="Build a shared libperl.$so (y/n)"
8706	. ./myread
8707	case "$ans" in
8708	true|$define|[Yy]*)
8709		useshrplib='true'  ;;
8710	*)	useshrplib='false' ;;
8711	esac
8712	;;
8713esac
8714
8715case "$useshrplib" in
8716true)
8717	case "$userelocatableinc" in
8718	true|define)
8719		echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
8720		echo "See INSTALL for an explanation why that won't work." >&4
8721		exit 4
8722		;;
8723	esac
8724	case "$libperl" in
8725	'')
8726		# Figure out a good name for libperl.so.  Since it gets stored in
8727		# a version-specific architecture-dependent library, the version
8728		# number isn't really that important, except for making cc/ld happy.
8729		#
8730		# A name such as libperl.so.10.1
8731		majmin="libperl.$so.$patchlevel.$subversion"
8732		# A name such as libperl.so.100
8733		majonly=`echo $patchlevel $subversion |
8734			$awk '{printf "%d%02d", $1, $2}'`
8735		majonly=libperl.$so.$majonly
8736		# I'd prefer to keep the os-specific stuff here to a minimum, and
8737		# rely on figuring it out from the naming of libc.
8738		case "${osname}${osvers}" in
8739		*linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
8740			dflt=libperl.$so
8741			;;
8742		cygwin*) # ld links now against the dll directly
8743			majmin="cygperl5_${patchlevel}_${subversion}.${so}"
8744			majonly=`echo $patchlevel $subversion |
8745				$awk '{printf "%03d%03d", $1, $2}'`
8746			majonly=cygperl5.$majonly.$so
8747			dflt=$majmin
8748			;;
8749		*)	# Try to guess based on whether libc has major.minor.
8750			case "$libc" in
8751			*libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
8752			*libc.$so.[0-9]*) dflt=$majonly ;;
8753			*)	dflt=libperl.$so ;;
8754			esac
8755			;;
8756		esac
8757		;;
8758	*)	dflt=$libperl
8759		;;
8760	esac
8761	cat << EOM
8762
8763I need to select a good name for the shared libperl.  If your system uses
8764library names with major and minor numbers, then you might want something
8765like $majmin.  Alternatively, if your system uses a single version
8766number for shared libraries, then you might want to use $majonly.
8767Or, your system might be quite happy with a simple libperl.$so.
8768
8769Since the shared libperl will get installed into a version-specific
8770architecture-dependent directory, the version number of the shared perl
8771library probably isn't important, so the default should be o.k.
8772
8773EOM
8774	rp='What name do you want to give to the shared libperl?'
8775	. ./myread
8776	libperl=$ans
8777	echo "Ok, I'll use $libperl"
8778	;;
8779*)
8780	libperl="libperl${_a}"
8781	;;
8782esac
8783
8784# Detect old use of shrpdir via undocumented Configure -Dshrpdir
8785case "$shrpdir" in
8786'') ;;
8787*)	$cat >&4 <<EOM
8788WARNING:  Use of the shrpdir variable for the installation location of
8789the shared $libperl is not supported.  It was never documented and
8790will not work in this version.  Let me (https://github.com/Perl/perl5/issues)
8791know of any problems this may cause.
8792
8793EOM
8794	case "$shrpdir" in
8795	"$archlibexp/CORE")
8796		$cat >&4 <<EOM
8797But your current setting of $shrpdir is
8798the default anyway, so it's harmless.
8799EOM
8800		;;
8801	*)
8802		$cat >&4 <<EOM
8803Further, your current attempted setting of $shrpdir
8804conflicts with the value of $archlibexp/CORE
8805that installperl will use.
8806EOM
8807		;;
8808	esac
8809	;;
8810esac
8811
8812# How will the perl executable find the installed shared $libperl?
8813# Add $xxx to ccdlflags.
8814# If we can't figure out a command-line option, use $shrpenv to
8815# set env LD_RUN_PATH.  The main perl makefile uses this.
8816shrpdir=$archlibexp/CORE
8817xxx=''
8818tmp_shrpenv=''
8819if "$useshrplib"; then
8820    case "$osname" in
8821	aix)
8822		# We'll set it in Makefile.SH...
8823		;;
8824	solaris)
8825		xxx="-R $shrpdir"
8826		;;
8827	freebsd|minix|mirbsd|netbsd|openbsd|interix|dragonfly|bitrig)
8828		xxx="-Wl,-R$shrpdir"
8829		;;
8830	bsdos|linux|irix*|dec_osf|gnu*|haiku)
8831		xxx="-Wl,-rpath,$shrpdir"
8832		;;
8833	hpux*)
8834		# hpux doesn't like the default, either.
8835		tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
8836		;;
8837	cygwin)
8838		# cygwin needs only ldlibpth
8839		;;
8840	*)
8841		tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
8842		;;
8843	esac
8844	case "$xxx" in
8845	'') ;;
8846	*)
8847		# Only add $xxx if it isn't already in ccdlflags.
8848		case " $ccdlflags " in
8849		*" $xxx "*)	;;
8850		*)	ccdlflags="$ccdlflags $xxx"
8851			cat <<EOM >&4
8852
8853Adding $xxx to the flags
8854passed to $ld so that the perl executable will find the
8855installed shared $libperl.
8856
8857EOM
8858			;;
8859		esac
8860		;;
8861	esac
8862fi
8863# Fix ccdlflags in AIX for building external extensions.
8864# (For building Perl itself bare -bE:perl.exp is needed,
8865#  Makefile.SH takes care of this.)
8866case "$osname" in
8867aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
8868esac
8869# Respect a hint or command-line value.
8870case "$shrpenv" in
8871'') shrpenv="$tmp_shrpenv" ;;
8872esac
8873case "$ldlibpthname" in
8874'')	ldlibpthname=LD_LIBRARY_PATH ;;
8875none)	ldlibpthname='' ;;
8876esac
8877
8878: determine where manual pages are on this system
8879echo " "
8880case "$sysman" in
8881'')
8882	syspath='/usr/share/man/man1 /usr/man/man1'
8883	syspath="$syspath /usr/man/mann /usr/man/manl /usr/man/local/man1"
8884	syspath="$syspath /usr/man/u_man/man1"
8885	syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
8886	syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
8887	syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
8888	sysman=`./loc . /usr/man/man1 $syspath`
8889	;;
8890esac
8891if $test -d "$sysman"; then
8892	echo "System manual is in $sysman." >&4
8893else
8894	echo "Could not find manual pages in source form." >&4
8895fi
8896
8897: determine where manual pages go
8898set man1dir man1dir none
8899eval $prefixit
8900$cat <<EOM
8901
8902$spackage has manual pages available in source form.
8903EOM
8904case "$nroff" in
8905nroff)
8906	echo "However, you don't have nroff, so they're probably useless to you."
8907	case "$man1dir" in
8908	'') man1dir="none";;
8909	esac;;
8910esac
8911echo "If you don't want the manual sources installed, answer 'none'."
8912case "$man1dir" in
8913' ') dflt=none
8914	;;
8915'')
8916	lookpath="$prefixexp/share/man/man1"
8917	lookpath="$lookpath $prefixexp/man/man1 $prefixexp/man/l_man/man1"
8918	lookpath="$lookpath $prefixexp/man/p_man/man1"
8919	lookpath="$lookpath $prefixexp/man/u_man/man1"
8920	lookpath="$lookpath $prefixexp/man/man.1"
8921	case "$sysman" in
8922	*/?_man*)	dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
8923	*)	dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
8924	esac
8925	set dflt
8926	eval $prefixup
8927	;;
8928*)  dflt="$man1dir"
8929	;;
8930esac
8931echo " "
8932fn=dn+~
8933rp="Where do the main $spackage manual pages (source) go?"
8934. ./getfile
8935if $test "X$man1direxp" != "X$ansexp"; then
8936	installman1dir=''
8937fi
8938prefixvar=man1dir
8939. ./setprefixvar
8940
8941case "$man1dir" in
8942'')	man1dir=' '
8943	installman1dir='';;
8944esac
8945
8946: What suffix to use on installed man pages
8947
8948case "$man1dir" in
8949' ')
8950	man1ext='0'
8951	;;
8952*)
8953	rp="What suffix should be used for the main $spackage man pages?"
8954	case "$man1ext" in
8955	'')	case "$man1dir" in
8956		*1)  dflt=1 ;;
8957		*1p) dflt=1p ;;
8958		*1pm) dflt=1pm ;;
8959		*l) dflt=l;;
8960		*n) dflt=n;;
8961		*o) dflt=o;;
8962		*p) dflt=p;;
8963		*C) dflt=C;;
8964		*L) dflt=L;;
8965		*L1) dflt=L1;;
8966		*) dflt=1;;
8967		esac
8968		;;
8969	*)	dflt="$man1ext";;
8970	esac
8971	. ./myread
8972	man1ext="$ans"
8973	;;
8974esac
8975
8976: see if we can have long filenames
8977echo " "
8978first=123456789abcdef
8979$rm -f $first
8980if (echo hi >$first) 2>/dev/null; then
8981	if $test -f 123456789abcde; then
8982		echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
8983		val="$undef"
8984	else
8985		echo 'You can have filenames longer than 14 characters.'>&4
8986		val="$define"
8987	fi
8988else
8989	$cat <<'EOM'
8990You can't have filenames longer than 14 chars.
8991You can't even think about them!
8992EOM
8993	val="$undef"
8994fi
8995set d_flexfnam
8996eval $setvar
8997$rm -rf 123456789abcde*
8998
8999: determine where library module manual pages go
9000set man3dir man3dir none
9001eval $prefixit
9002$cat <<EOM
9003
9004$spackage has manual pages for many of the library modules.
9005EOM
9006
9007case "$nroff" in
9008nroff)
9009	$cat <<'EOM'
9010However, you don't have nroff, so they're probably useless to you.
9011EOM
9012	case "$man3dir" in
9013	'') man3dir="none";;
9014	esac;;
9015esac
9016
9017case "$d_flexfnam" in
9018undef)
9019	$cat <<'EOM'
9020However, your system can't handle the long file names like File::Basename.3.
9021EOM
9022	case "$man3dir" in
9023	'') man3dir="none";;
9024	esac;;
9025esac
9026
9027echo "If you don't want the manual sources installed, answer 'none'."
9028prog=`echo $package | $sed 's/-*[0-9.]*$//'`
9029case "$man3dir" in
9030'')	dflt=`echo "$man1dir" | $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'`
9031	if $test -d "$privlib/man/man3"; then
9032		cat <<EOM >&4
9033
9034WARNING:  Previous versions of perl installed man3 pages into
9035$privlib/man/man3.  This version will suggest a
9036new default of $dflt.
9037EOM
9038		tdflt=$dflt
9039		dflt='n'
9040		rp='Do you wish to preserve the old behavior?(y/n)'
9041		. ./myread
9042		case "$ans" in
9043		y*) dflt="$privlib/man/man3" ;;
9044		*)  dflt=$tdflt ;;
9045		esac
9046    fi
9047	;;
9048*)	dflt="$man3dir" ;;
9049esac
9050case "$dflt" in
9051' ') dflt=none ;;
9052esac
9053echo " "
9054fn=dn+~
9055rp="Where do the $package library man pages (source) go?"
9056. ./getfile
9057prefixvar=man3dir
9058. ./setprefixvar
9059
9060case "$man3dir" in
9061'')	man3dir=' '
9062	installman3dir='';;
9063esac
9064
9065: What suffix to use on installed man pages
9066case "$man3dir" in
9067' ')
9068	man3ext='0'
9069	;;
9070*)
9071	rp="What suffix should be used for the $package library man pages?"
9072	case "$man3ext" in
9073	'')	case "$man3dir" in
9074		*3)  dflt=3 ;;
9075		*3p) dflt=3p ;;
9076		*3pm) dflt=3pm ;;
9077		*l) dflt=l;;
9078		*n) dflt=n;;
9079		*o) dflt=o;;
9080		*p) dflt=p;;
9081		*C) dflt=C;;
9082		*L) dflt=L;;
9083		*L3) dflt=L3;;
9084		*) dflt=3;;
9085		esac
9086		;;
9087	*)	dflt="$man3ext";;
9088	esac
9089	. ./myread
9090	man3ext="$ans"
9091	;;
9092esac
9093
9094: see if we have to deal with yellow pages, now NIS.
9095if $test -d /usr/etc/yp || $test -d /etc/yp || $test -d /usr/lib/yp; then
9096	case "$hostcat" in
9097	nidump*) ;;
9098	*)
9099		case "$hostcat" in
9100		*ypcat*) dflt=y;;
9101		'') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
9102				dflt=y
9103			else
9104				dflt=n
9105			fi;;
9106		*) dflt=n;;
9107		esac
9108		echo " "
9109		rp='Are you getting the hosts file via yellow pages?'
9110		. ./myread
9111		case "$ans" in
9112		y*) hostcat='ypcat hosts';;
9113		*) hostcat='cat /etc/hosts';;
9114		esac
9115		;;
9116	esac
9117fi
9118case "$hostcat" in
9119'') test -f /etc/hosts && hostcat='cat /etc/hosts';;
9120esac
9121case "$groupcat" in
9122'') test -f /etc/group && groupcat='cat /etc/group';;
9123esac
9124case "$passcat" in
9125'') test -f /etc/passwd && passcat='cat /etc/passwd';;
9126esac
9127
9128: now get the host name
9129echo " "
9130echo "Figuring out host name..." >&4
9131case "$myhostname" in
9132'') cont=true
9133	echo 'Maybe "hostname" will work...'
9134	if tans=`sh -c hostname 2>&1` ; then
9135		myhostname=$tans
9136		phostname=hostname
9137		cont=''
9138	fi
9139	;;
9140*) cont='';;
9141esac
9142if $test "$cont"; then
9143	if ./xenix; then
9144		echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
9145		if tans=`cat /etc/systemid 2>&1` ; then
9146			myhostname=$tans
9147			phostname='cat /etc/systemid'
9148			echo "Whadyaknow.  Xenix always was a bit strange..."
9149			cont=''
9150		fi
9151	elif $test -r /etc/systemid; then
9152		echo "(What is a non-Xenix system doing with /etc/systemid?)"
9153	fi
9154fi
9155if $test "$cont"; then
9156	echo 'No, maybe "uuname -l" will work...'
9157	if tans=`sh -c 'uuname -l' 2>&1` ; then
9158		myhostname=$tans
9159		phostname='uuname -l'
9160	else
9161		echo 'Strange.  Maybe "uname -n" will work...'
9162		if tans=`sh -c 'uname -n' 2>&1` ; then
9163			myhostname=$tans
9164			phostname='uname -n'
9165		else
9166			echo 'Oh well, maybe I can mine it out of whoami.h...'
9167			if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
9168				myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
9169				phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
9170			else
9171				case "$myhostname" in
9172				'') echo "Does this machine have an identity crisis or something?"
9173					phostname='';;
9174				*)
9175					echo "Well, you said $myhostname before..."
9176					phostname='echo $myhostname';;
9177				esac
9178			fi
9179		fi
9180	fi
9181fi
9182case "$myhostname" in
9183'') myhostname=noname ;;
9184esac
9185: you do not want to know about this
9186set $myhostname
9187myhostname=$1
9188
9189: verify guess
9190if $test "$myhostname" ; then
9191	dflt=y
9192	rp='Your host name appears to be "'$myhostname'".'" Right?"
9193	. ./myread
9194	case "$ans" in
9195	y*) ;;
9196	*) myhostname='';;
9197	esac
9198fi
9199
9200: bad guess or no guess
9201while $test "X$myhostname" = X ; do
9202	dflt=''
9203	rp="Please type the (one word) name of your host:"
9204	. ./myread
9205	myhostname="$ans"
9206done
9207
9208: translate upper to lower if necessary
9209case "$myhostname" in
9210*[A-Z]*)
9211	echo "(Normalizing case in your host name)"
9212	myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
9213	;;
9214esac
9215
9216case "$myhostname" in
9217*.*)
9218	dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
9219	myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
9220	echo "(Trimming domain name from host name--host name is now $myhostname)"
9221	;;
9222*) case "$mydomain" in
9223	'')
9224		{
9225			test "X$hostcat" = "Xypcat hosts" &&
9226			ypmatch "$myhostname" hosts 2>/dev/null |\
9227				$sed -e 's/[	 ]*#.*//; s/$/ /' > hosts && \
9228			$test -s hosts
9229		} || {
9230			test "X$hostcat" != "X" &&
9231			$hostcat | $sed -n -e "s/[	 ]*#.*//; s/\$/ /
9232					/[	 ]$myhostname[	. ]/p" > hosts
9233		}
9234		tmp_re="[	. ]"
9235		if $test -f hosts; then
9236			$test x`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ { sum++ }
9237			     END { print sum }" hosts` = x1 || tmp_re="[	 ]"
9238			dflt=.`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
9239				hosts | $sort | $uniq | \
9240				$sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
9241			case `$echo X$dflt` in
9242			X*\ *)	echo "(Several hosts in the database matched hostname)"
9243				dflt=.
9244				;;
9245			X.) echo "(You do not have fully-qualified names in the hosts database)"
9246				;;
9247			esac
9248		else
9249			echo "(I cannot locate a hosts database anywhere)"
9250			dflt=.
9251		fi
9252		case "$dflt" in
9253		.)
9254			tans=`./loc resolv.conf X /etc /usr/etc`
9255			if $test -f "$tans"; then
9256				echo "(Attempting domain name extraction from $tans)"
9257				dflt=.`$sed -n -e 's/	/ /g' \
9258				  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
9259				  -e 1q 2>/dev/null`
9260				case "$dflt" in
9261				.) dflt=.`$sed -n -e 's/	/ /g' \
9262				     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
9263				     -e 1q 2>/dev/null`
9264					;;
9265				esac
9266			fi
9267			;;
9268		esac
9269		case "$dflt" in
9270		.) echo "(No help from resolv.conf either -- attempting clever guess)"
9271			dflt=.`sh -c domainname 2>/dev/null`
9272			case "$dflt" in
9273			'') dflt='.';;
9274			.nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
9275			esac
9276			;;
9277		esac
9278		case "$dflt$osname" in
9279		.os390) echo "(Attempting domain name extraction from //'SYS1.TCPPARMS(TCPDATA)')"
9280			dflt=.`awk '/^DOMAINORIGIN/ {print $2}' "//'SYS1.TCPPARMS(TCPDATA)'" 2>/dev/null`
9281			;;
9282		esac
9283		case "$dflt" in
9284		.) echo "(Lost all hope -- silly guess then)"
9285			dflt='.nonet'
9286			;;
9287		esac
9288		$rm -f hosts
9289		;;
9290	*) dflt="$mydomain";;
9291	esac;;
9292esac
9293echo " "
9294rp="What is your domain name?"
9295. ./myread
9296tans="$ans"
9297case "$ans" in
9298'') ;;
9299.*) ;;
9300*) tans=".$tans";;
9301esac
9302mydomain="$tans"
9303
9304: translate upper to lower if necessary
9305case "$mydomain" in
9306*[A-Z]*)
9307	echo "(Normalizing case in your domain name)"
9308	mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
9309	;;
9310esac
9311
9312: a little sanity check here
9313case "$phostname" in
9314'') ;;
9315*)
9316	case `$phostname | ./tr '[A-Z]' '[a-z]'` in
9317	$myhostname$mydomain|$myhostname) ;;
9318	*)
9319		case "$phostname" in
9320		sed*)
9321			echo "(That doesn't agree with your whoami.h file, by the way.)"
9322			;;
9323		*)
9324			echo "(That doesn't agree with your $phostname command, by the way.)"
9325			;;
9326		esac
9327	;;
9328	esac
9329	;;
9330esac
9331
9332: determine the e-mail address of the user who is running us
9333$cat <<EOM
9334
9335I need to get your e-mail address in Internet format if possible, i.e.
9336something like user@host.domain. Please answer accurately since I have
9337no easy means to double check it. The default value provided below
9338is most probably close to reality but may not be valid from outside
9339your organization...
9340
9341EOM
9342cont=x
9343while test "$cont"; do
9344	case "$MAILDOMAIN" in
9345	'')
9346		if $test -s /etc/mailname; then
9347			maildomain=`$cat /etc/mailname`
9348		else
9349			maildomain="$myhostname$mydomain"
9350		fi
9351		;;
9352	*)  maildomain="$MAILDOMAIN";;
9353	esac
9354	case "$cf_email" in
9355	'') dflt="$cf_by@$maildomain";;
9356	*)  dflt="$cf_email";;
9357	esac
9358	rp='What is your e-mail address?'
9359	. ./myread
9360	cf_email="$ans"
9361	case "$cf_email" in
9362	*@*.*) cont='' ;;
9363	*)
9364		rp='Address does not look like an Internet one.  Use it anyway?'
9365		case "$fastread" in
9366		yes) dflt=y ;;
9367		*) dflt=n ;;
9368		esac
9369		. ./myread
9370		case "$ans" in
9371		y*) cont='' ;;
9372		*) echo " " ;;
9373		esac
9374		;;
9375	esac
9376done
9377
9378: Ask e-mail of administrator
9379$cat <<EOM
9380
9381If you or somebody else will be maintaining perl at your site, please
9382fill in the correct e-mail address here so that they may be contacted
9383if necessary. You may enter "none" for no administrator.
9384
9385EOM
9386case "$perladmin" in
9387'') dflt="$cf_email";;
9388*) dflt="$perladmin";;
9389esac
9390rp='Perl administrator e-mail address'
9391. ./myread
9392perladmin="$ans"
9393
9394: determine whether to use a version number suffix for installed binaries
9395echo " "
9396$cat <<EOM
9397Do you want to use a version number suffix for installed binaries? This
9398will install 'perl$version' instead of 'perl', and likewise for other
9399binaries like 'perldoc' and 'cpan'. This allows many versions of perl
9400to be installed side-by-side. Unless you are a developer, you probably
9401do *not* want to do this.
9402EOM
9403case "$versiononly" in
9404"$define"|[Yy]*|true) dflt='y' ;;
9405*) dflt='n';
9406esac
9407rp="Do you want to use a version number suffix for installed binaries?"
9408. ./myread
9409case "$ans" in
9410[yY]*)	val="$define";;
9411*)	val="$undef" ;;
9412esac
9413set versiononly
9414eval $setvar
9415
9416case "$versiononly" in
9417"$define") inc_version_list=''
9418           inc_version_list_init=0
9419           ;;
9420esac
9421
9422: figure out how to guarantee perl startup
9423: XXX Note that this currently takes advantage of the bug that binexp ignores
9424:     the Configure -Dinstallprefix setting, which in turn means that under
9425:     relocatable @INC, initialinstalllocation is what binexp started as.
9426case "$startperl" in
9427'')
9428	case "$sharpbang" in
9429	*!)
9430		$cat <<EOH
9431
9432I can use the #! construct to start perl on your system. This will
9433make startup of perl scripts faster, but may cause problems if you
9434want to share those scripts and perl is not in a standard place
9435($initialinstalllocation/perl) on all your platforms. The alternative
9436is to force a shell by starting the script with a single ':' character.
9437
9438EOH
9439		case "$versiononly" in
9440		"$define")      dflt="$initialinstalllocation/perl$version";;
9441		*)              dflt="$initialinstalllocation/perl";;
9442		esac
9443		rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
9444		. ./myread
9445		case "$ans" in
9446		none)	startperl=": # use perl";;
9447		*)	startperl="#!$ans"
9448			if $test 30 -lt `echo "$ans" | wc -c`; then
9449				$cat >&4 <<EOM
9450
9451WARNING:  Some systems limit the #! command to 32 characters.
9452If you experience difficulty running Perl scripts with #!, try
9453installing Perl in a directory with a shorter pathname.
9454
9455EOM
9456			fi ;;
9457		esac
9458		;;
9459	*) startperl=": # use perl"
9460		;;
9461	esac
9462	;;
9463esac
9464echo "I'll use $startperl to start perl scripts."
9465
9466: figure best path for perl in scripts
9467case "$perlpath" in
9468'')
9469	case "$versiononly" in
9470	"$define")	perlpath="$initialinstalllocation/perl$version";;
9471	*)		perlpath="$initialinstalllocation/perl";;
9472	esac
9473	case "$startperl" in
9474	*!*) ;;
9475	*)
9476		$cat <<EOH
9477
9478I will use the "eval 'exec'" idiom to start Perl on your system.
9479I can use the full path of your Perl binary for this purpose, but
9480doing so may cause problems if you want to share those scripts and
9481Perl is not always in a standard place ($initialinstalllocation/perl).
9482
9483EOH
9484		dflt="$initialinstalllocation/perl"
9485		rp="What path shall I use in \"eval 'exec'\"?"
9486		. ./myread
9487		perlpath="$ans"
9488		;;
9489	esac
9490	;;
9491esac
9492case "$startperl" in
9493*!*)	;;
9494*)	echo "I'll use $perlpath in \"eval 'exec'\"" ;;
9495esac
9496
9497: determine where public executable scripts go
9498set scriptdir scriptdir
9499eval $prefixit
9500case "$scriptdir" in
9501'')
9502	dflt="$bin"
9503	: guess some guesses
9504	$test -d /usr/share/scripts && dflt=/usr/share/scripts
9505	$test -d /usr/share/bin     && dflt=/usr/share/bin
9506	$test -d /usr/local/script  && dflt=/usr/local/script
9507	$test -d /usr/local/scripts && dflt=/usr/local/scripts
9508	$test -d $prefixexp/script  && dflt=$prefixexp/script
9509	set dflt
9510	eval $prefixup
9511	;;
9512*)  dflt="$scriptdir"
9513	;;
9514esac
9515$cat <<EOM
9516
9517Some installations have a separate directory just for executable scripts so
9518that they can mount it across multiple architectures but keep the scripts in
9519one spot.  You might, for example, have a subdirectory of /usr/share for this.
9520Or you might just lump your scripts in with all your other executables.
9521
9522EOM
9523fn=d~
9524rp='Where do you keep publicly executable scripts?'
9525. ./getfile
9526if $test "X$ansexp" != "X$scriptdirexp"; then
9527	installscript=''
9528fi
9529installscriptdir=''
9530prefixvar=scriptdir
9531. ./setprefixvar
9532: A little fix up for an irregularly named variable.
9533installscript="$installscriptdir"
9534
9535: determine where add-on public executables go
9536case "$sitebin" in
9537'')	dflt=$siteprefix/bin ;;
9538*)	dflt=$sitebin ;;
9539esac
9540fn=d~
9541rp='Pathname where the add-on public executables should be installed?'
9542. ./getfile
9543prefixvar=sitebin
9544. ./setprefixvar
9545
9546: determine where add-on html pages go
9547: There is no standard location, so try to copy the previously-selected
9548: directory structure for the core html pages.
9549case "$sitehtml1dir" in
9550'')    dflt=`echo "$html1dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9551*)     dflt=$sitehtml1dir ;;
9552esac
9553case "$dflt" in
9554''|' ') dflt=none ;;
9555esac
9556fn=dn+~
9557rp='Pathname where the site-specific html pages should be installed?'
9558. ./getfile
9559prefixvar=sitehtml1dir
9560. ./setprefixvar
9561
9562: determine where add-on library html pages go
9563: There is no standard location, so try to copy the previously-selected
9564: directory structure for the core html pages.
9565case "$sitehtml3dir" in
9566'')    dflt=`echo "$html3dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9567*)     dflt=$sitehtml3dir ;;
9568esac
9569case "$dflt" in
9570''|' ') dflt=none ;;
9571esac
9572fn=dn+~
9573rp='Pathname where the site-specific library html pages should be installed?'
9574. ./getfile
9575prefixvar=sitehtml3dir
9576. ./setprefixvar
9577
9578: determine where add-on manual pages go
9579case "$siteman1dir" in
9580'')	dflt=`echo $man1dir | $sed "s#^$prefix#$siteprefix#"` ;;
9581*)	dflt=$siteman1dir ;;
9582esac
9583case "$dflt" in
9584''|' ') dflt=none ;;
9585esac
9586fn=dn+~
9587rp='Pathname where the site-specific manual pages should be installed?'
9588. ./getfile
9589prefixvar=siteman1dir
9590. ./setprefixvar
9591
9592: determine where add-on library man pages go
9593case "$siteman3dir" in
9594'')	dflt=`echo $man3dir | $sed "s#^$prefix#$siteprefix#"` ;;
9595*)	dflt=$siteman3dir ;;
9596esac
9597case "$dflt" in
9598''|' ') dflt=none ;;
9599esac
9600fn=dn+~
9601rp='Pathname where the site-specific library manual pages should be installed?'
9602. ./getfile
9603prefixvar=siteman3dir
9604. ./setprefixvar
9605
9606: determine where add-on public executable scripts go
9607case "$sitescript" in
9608'')	dflt=$siteprefix/script
9609	$test -d $dflt || dflt=$sitebin ;;
9610*)  dflt="$sitescript" ;;
9611esac
9612fn=d~+
9613rp='Pathname where add-on public executable scripts should be installed?'
9614. ./getfile
9615prefixvar=sitescript
9616. ./setprefixvar
9617
9618: see if backtrace exists
9619set backtrace d_backtrace
9620eval $inlibc
9621
9622: Check if C backtrace is actually supported.
9623case "$usecbacktrace" in
9624  "") usecbacktrace=$undef ;;
9625  [yY]*|true|$define)
9626    case "$d_backtrace" in
9627      [yY]*|true|$define)
9628        ;;
9629      *)
9630        echo "This system does not support backtrace" >&4
9631        usecbacktrace=$undef
9632        ;;
9633      esac
9634    ;;
9635  esac
9636
9637: Check if faststdio is requested and available
9638case "$usefaststdio" in
9639$define|true|[yY]*|'')
9640	xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
9641	case "$xversion" in
9642	[68])	dflt='y' ;;
9643	*)	dflt='n' ;;
9644	esac
9645	;;
9646*) dflt='n';;
9647esac
9648cat <<EOM
9649
9650Perl can be built to use 'fast stdio', which means using the stdio
9651library but also directly manipulating the stdio buffers to enable
9652faster I/O.  Using stdio is better for backward compatibility (especially
9653for Perl extensions), but on the other hand since Perl 5.8 the 'perlio'
9654interface has been preferred instead of stdio.
9655
9656If this doesn't make any sense to you, just accept the default '$dflt'.
9657EOM
9658rp='Use the "fast stdio" if available?'
9659. ./myread
9660case "$ans" in
9661y|Y)	val="$define" ;;
9662*)      val="$undef" ;;
9663esac
9664set usefaststdio
9665eval $setvar
9666
9667: define an is-a-typedef? function
9668typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9669case "$inclist" in
9670"") inclist="sys/types.h";;
9671esac;
9672eval "varval=\$$var";
9673case "$varval" in
9674"")
9675	$rm -f temp.c;
9676	for inc in $inclist; do
9677		echo "#include <$inc>" >>temp.c;
9678	done;
9679	echo "#ifdef $type" >> temp.c;
9680	echo "printf(\"We have $type\");" >> temp.c;
9681	echo "#endif" >> temp.c;
9682	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9683	if $contains $type temp.E >/dev/null 2>&1; then
9684		eval "$var=\$type";
9685	else
9686		eval "$var=\$def";
9687	fi;
9688	$rm -f temp.?;;
9689*) eval "$var=\$varval";;
9690esac'
9691
9692: define an is-a-typedef? function that prompts if the type is not available.
9693typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9694case "$inclist" in
9695"") inclist="sys/types.h";;
9696esac;
9697eval "varval=\$$var";
9698case "$varval" in
9699"")
9700	$rm -f temp.c;
9701	for inc in $inclist; do
9702		echo "#include <$inc>" >>temp.c;
9703	done;
9704	echo "#ifdef $type" >> temp.c;
9705	echo "printf(\"We have $type\");" >> temp.c;
9706	echo "#endif" >> temp.c;
9707	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9708	echo " " ;
9709	echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
9710	if $contains $type temp.E >/dev/null 2>&1; then
9711		echo "$type found." >&4;
9712		eval "$var=\$type";
9713	else
9714		echo "$type NOT found." >&4;
9715		dflt="$def";
9716		. ./myread ;
9717		eval "$var=\$ans";
9718	fi;
9719	$rm -f temp.?;;
9720*) eval "$var=\$varval";;
9721esac'
9722
9723: see what type lseek is declared as in the kernel
9724rp="What is the type used for lseek's offset on this system?"
9725set off_t lseektype long stdio.h sys/types.h
9726eval $typedef_ask
9727
9728echo " "
9729echo "Checking to see how big your file offsets are..." >&4
9730$cat >try.c <<EOCP
9731#include <sys/types.h>
9732#include <stdio.h>
9733int main()
9734{
9735    printf("%d\n", (int)sizeof($lseektype));
9736    return(0);
9737}
9738EOCP
9739set try
9740if eval $compile_ok; then
9741	lseeksize=`$run ./try`
9742	echo "Your file offsets are $lseeksize bytes long."
9743else
9744	dflt=$longsize
9745	echo " "
9746	echo "(I can't seem to compile the test program.  Guessing...)"
9747	rp="What is the size of your file offsets (in bytes)?"
9748	. ./myread
9749	lseeksize="$ans"
9750fi
9751$rm_try
9752
9753: see what type file positions are declared as in the library
9754rp="What is the type for file position used by fsetpos()?"
9755set fpos_t fpostype long stdio.h sys/types.h
9756eval $typedef_ask
9757
9758: Check size for Fpos_t
9759echo " "
9760case "$fpostype" in
9761*_t) zzz="$fpostype"	;;
9762*)   zzz="fpos_t"	;;
9763esac
9764echo "Checking the size of $zzz..." >&4
9765cat > try.c <<EOCP
9766#include <sys/types.h>
9767#include <stdio.h>
9768#$i_stdlib I_STDLIB
9769#ifdef I_STDLIB
9770#include <stdlib.h>
9771#endif
9772int main() {
9773    printf("%d\n", (int)sizeof($fpostype));
9774    exit(0);
9775}
9776EOCP
9777set try
9778if eval $compile_ok; then
9779	yyy=`$run ./try`
9780	case "$yyy" in
9781	'')	fpossize=4
9782		echo "(I can't execute the test program--guessing $fpossize.)" >&4
9783		;;
9784	*)	fpossize=$yyy
9785		echo "Your $zzz is $fpossize bytes long."
9786		;;
9787	esac
9788else
9789	dflt="$longsize"
9790	echo " " >&4
9791	echo "(I can't compile the test program.  Guessing...)" >&4
9792	rp="What is the size of your file positions (in bytes)?"
9793	. ./myread
9794	fpossize="$ans"
9795fi
9796
9797: Check for large file support
9798# Backward compatibility (uselfs is deprecated).
9799case "$uselfs" in
9800"$define"|true|[yY]*)
9801	cat <<EOM >&4
9802
9803*** Configure -Duselfs is deprecated, using -Duselargefiles instead.
9804EOM
9805	uselargefiles="$define"
9806	;;
9807esac
9808
9809case "$lseeksize:$fpossize" in
98108:8) cat <<EOM
9811
9812You can have files larger than 2 gigabytes.
9813EOM
9814   val="$define" ;;
9815*)    case "$uselargefiles" in
9816   "$undef"|false|[nN]*) dflt='n' ;;
9817   *)	dflt='y' ;;
9818   esac
9819   cat <<EOM
9820
9821Perl can be built to understand large files (files larger than 2 gigabytes)
9822on some systems.  To do so, Configure can be run with -Duselargefiles.
9823
9824If this doesn't make any sense to you, just accept the default '$dflt'.
9825EOM
9826   rp='Try to understand large files, if available?'
9827   . ./myread
9828   case "$ans" in
9829   y|Y)	val="$define" ;;
9830   *)	val="$undef"  ;;
9831   esac
9832   ;;
9833esac
9834set uselargefiles
9835eval $setvar
9836: Look for a hint-file generated 'call-back-unit'.  If the
9837: user has specified that a large files perl is to be built,
9838: we may need to set or change some other defaults.
9839if $test -f uselargefiles.cbu; then
9840	echo "Your platform has some specific hints regarding large file builds, using them..."
9841	. ./uselargefiles.cbu
9842fi
9843case "$uselargefiles" in
9844"$define")
9845	if $test -f uselargefiles.cbu; then
9846		echo " "
9847		echo "Rechecking to see how big your file offsets are..." >&4
9848		$cat >try.c <<EOCP
9849#include <sys/types.h>
9850#include <stdio.h>
9851int main()
9852{
9853    printf("%d\n", (int)sizeof($lseektype));
9854    return(0);
9855}
9856EOCP
9857		set try
9858		if eval $compile_ok; then
9859			lseeksize=`$run ./try`
9860			$echo "Your file offsets are now $lseeksize bytes long."
9861		else
9862			dflt="$lseeksize"
9863			echo " "
9864			echo "(I can't seem to compile the test program.  Guessing...)"
9865			rp="What is the size of your file offsets (in bytes)?"
9866			. ./myread
9867			lseeksize="$ans"
9868		fi
9869		case "$fpostype" in
9870		*_t) zzz="$fpostype"	;;
9871		*)   zzz="fpos_t"	;;
9872		esac
9873		$echo $n "Rechecking the size of $zzz...$c" >&4
9874		$cat > try.c <<EOCP
9875#include <sys/types.h>
9876#include <stdio.h>
9877#$i_stdlib I_STDLIB
9878#ifdef I_STDLIB
9879#include <stdlib.h>
9880#endif
9881int main() {
9882    printf("%d\n", (int)sizeof($fpostype));
9883    return(0);
9884}
9885EOCP
9886		set try
9887		if eval $compile_ok; then
9888			yyy=`$run ./try`
9889			dflt="$lseeksize"
9890			case "$yyy" in
9891			'')	echo " "
9892				echo "(I can't execute the test program--guessing $fpossize.)" >&4
9893				;;
9894			*)	fpossize=$yyy
9895				echo " $fpossize bytes." >&4
9896				;;
9897			esac
9898		else
9899			dflt="$fpossize"
9900			echo " "
9901			echo "(I can't compile the test program.  Guessing...)" >&4
9902			rp="What is the size of your file positions (in bytes)?"
9903			. ./myread
9904			fpossize="$ans"
9905		fi
9906		$rm_try
9907	fi
9908	;;
9909esac
9910
9911: Check if we want perlio
9912useperlio="$define"
9913
9914: Set the vendorbin variables
9915case "$vendorprefix" in
9916'')	d_vendorbin="$undef"
9917	vendorbin=''
9918	vendorbinexp=''
9919	;;
9920*)	d_vendorbin="$define"
9921	: determine where vendor-supplied executables go.
9922	case "$vendorbin" in
9923	'') dflt=$vendorprefix/bin ;;
9924	*)	dflt="$vendorbin" ;;
9925	esac
9926	fn=d~+
9927	rp='Pathname for the vendor-supplied executables directory?'
9928	. ./getfile
9929	vendorbin="$ans"
9930	vendorbinexp="$ansexp"
9931	;;
9932esac
9933prefixvar=vendorbin
9934. ./installprefix
9935
9936: Set the vendorhtml1dir variables
9937case "$vendorprefix" in
9938'')	vendorhtml1dir=''
9939	vendorhtml1direxp=''
9940	;;
9941*)	: determine where vendor-supplied html pages go.
9942	: There is no standard location, so try to copy the previously-selected
9943	: directory structure for the core html pages.
9944	: XXX Better default suggestions would be welcome.
9945	case "$vendorhtml1dir" in
9946	'')	dflt=`echo "$html1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9947	*)	dflt=$vendorhtml1dir ;;
9948	esac
9949	case "$dflt" in
9950	''|' ') dflt=none ;;
9951	esac
9952	fn=dn+~
9953	rp='Pathname for the vendor-supplied html pages?'
9954	. ./getfile
9955	vendorhtml1dir="$ans"
9956	vendorhtml1direxp="$ansexp"
9957	;;
9958esac
9959: Use ' ' for none so value is preserved next time through Configure
9960$test X"$vendorhtml1dir" = "X" && vendorhtml1dir=' '
9961prefixvar=vendorhtml1dir
9962. ./installprefix
9963
9964: Set the vendorhtml3dir variables
9965case "$vendorprefix" in
9966'')	vendorhtml3dir=''
9967	vendorhtml3direxp=''
9968	;;
9969*)	: determine where vendor-supplied module html pages go.
9970	: There is no standard location, so try to copy the previously-selected
9971	: directory structure for the core html pages.
9972	: XXX Better default suggestions would be welcome.
9973	case "$vendorhtml3dir" in
9974	'')	dflt=`echo "$html3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9975	*)	dflt=$vendorhtml3dir ;;
9976	esac
9977	case "$dflt" in
9978	''|' ') dflt=none ;;
9979	esac
9980	fn=dn+~
9981	rp='Pathname for the vendor-supplied html pages?'
9982	. ./getfile
9983	vendorhtml3dir="$ans"
9984	vendorhtml3direxp="$ansexp"
9985	;;
9986esac
9987: Use ' ' for none so value is preserved next time through Configure
9988$test X"$vendorhtml3dir" = "X" && vendorhtml3dir=' '
9989prefixvar=vendorhtml3dir
9990. ./installprefix
9991
9992: Set the vendorman1dir variables
9993case "$vendorprefix" in
9994'')	vendorman1dir=''
9995	vendorman1direxp=''
9996	;;
9997*)	: determine where vendor-supplied manual pages go.
9998	case "$vendorman1dir" in
9999	'') dflt=`echo "$man1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10000	*)	dflt=$vendorman1dir ;;
10001	esac
10002	case "$dflt" in
10003	''|' ') dflt=none ;;
10004	esac
10005	fn=nd~+
10006	rp='Pathname for the vendor-supplied manual section 1 pages?'
10007	. ./getfile
10008	vendorman1dir="$ans"
10009	vendorman1direxp="$ansexp"
10010	;;
10011esac
10012: Use ' ' for none so value is preserved next time through Configure
10013$test X"$vendorman1dir" = "X" && vendorman1dir=' '
10014prefixvar=vendorman1dir
10015. ./installprefix
10016
10017: Set the vendorman3dir variables
10018case "$vendorprefix" in
10019'')	vendorman3dir=''
10020	vendorman3direxp=''
10021	;;
10022*)	: determine where vendor-supplied module manual pages go.
10023	case "$vendorman3dir" in
10024	'') dflt=`echo "$man3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10025	*)	dflt=$vendorman3dir ;;
10026	esac
10027	case "$dflt" in
10028	''|' ') dflt=none ;;
10029	esac
10030	fn=nd~+
10031	rp='Pathname for the vendor-supplied manual section 3 pages?'
10032	. ./getfile
10033	vendorman3dir="$ans"
10034	vendorman3direxp="$ansexp"
10035	;;
10036esac
10037: Use ' ' for none so value is preserved next time through Configure
10038$test X"$vendorman3dir" = "X" && vendorman3dir=' '
10039prefixvar=vendorman3dir
10040. ./installprefix
10041
10042: Set the vendorscript variables
10043case "$vendorprefix" in
10044'')	d_vendorscript="$undef"
10045	vendorscript=''
10046	vendorscriptexp=''
10047	;;
10048*)	d_vendorscript="$define"
10049	: determine where vendor-supplied scripts go.
10050	case "$vendorscript" in
10051	'')	dflt=$vendorprefix/script
10052		$test -d $dflt || dflt=$vendorbin ;;
10053	*)  dflt="$vendorscript" ;;
10054	esac
10055	$cat <<EOM
10056
10057The installation process will create a directory for
10058vendor-supplied scripts.
10059
10060EOM
10061	fn=d~+
10062	rp='Pathname for the vendor-supplied scripts directory?'
10063	. ./getfile
10064	vendorscript="$ans"
10065	vendorscriptexp="$ansexp"
10066	;;
10067esac
10068prefixvar=vendorscript
10069. ./installprefix
10070
10071: see if qgcvt exists
10072set qgcvt d_qgcvt
10073eval $inlibc
10074
10075: Check what kind of doubles your system has
10076$echo "Checking the kind of doubles you have..." >&4
10077$cat >try.c <<EOP
10078#$i_stdlib I_STDLIB
10079#define DOUBLESIZE $doublesize
10080#ifdef I_STDLIB
10081#include <stdlib.h>
10082#endif
10083#include <stdio.h>
10084static const double d = -0.1;
10085int main() {
10086  unsigned const char* b = (unsigned const char*)(&d);
10087#if DOUBLESIZE == 4
10088  if (b[0] == 0xCD && b[3] == 0xBD) {
10089    /* IEEE 754 32-bit little-endian */
10090    printf("1\n");
10091    exit(0);
10092  }
10093  if (b[0] == 0xBD && b[3] == 0xCD) {
10094    /* IEEE 754 32-bit big-endian */
10095    printf("2\n");
10096    exit(0);
10097  }
10098  if (b[0] == 0xCC && b[3] == 0xCC) {
10099    /* VAX format F, 32-bit PDP-style mixed endian. */
10100    printf("9\n");
10101    exit(0);
10102  }
10103  if (b[0] == 0xC0 && b[3] == 0x9A) {
10104    /* IBM single 32-bit */
10105    printf("12\n");
10106    exit(0);
10107  }
10108#endif
10109#if DOUBLESIZE == 8
10110  if (b[0] == 0x9A && b[7] == 0xBF) {
10111    /* IEEE 754 64-bit little-endian */
10112    printf("3\n");
10113    exit(0);
10114  }
10115  if (b[0] == 0xBF && b[7] == 0x9A) {
10116    /* IEEE 754 64-bit big-endian */
10117    printf("4\n");
10118    exit(0);
10119  }
10120  if (b[0] == 0x99 && b[3] == 0xBF && b[4] == 0x9A && b[7] == 0x99) {
10121   /* ARM mixed endian: two little-endian 32-bit floats, in big endian order:
10122    * 4 5 6 7 0 1 2 3 (MSB = 7, LSB = 0)
10123    * 99 99 b9 bf 9a 99 99 99 */
10124    printf("7\n");
10125    exit(0);
10126  }
10127  if (b[0] == 0x99 && b[3] == 0x9A && b[4] == 0xBF && b[7] == 0x99) {
10128   /* The opposite of case 7, mixed endian: two big-endian 32-bit floats,
10129    * in little endian order: 3 2 1 0 7 6 5 4 (MSB = 7, LSB = 0)
10130    * 99 99 99 9a bf b9 99 99 */
10131    printf("8\n");
10132    exit(0);
10133  }
10134  if (b[0] == 0xCC && b[7] == 0xCC) {
10135   /* VAX format D, 64-bit PDP-style mixed endian. */
10136    printf("10\n");
10137    exit(0);
10138  }
10139  if (b[0] == 0xD9 && b[7] == 0x99) {
10140   /* VAX format G, 64-bit PDP-style mixed endian. */
10141    printf("11\n");
10142    exit(0);
10143  }
10144  if (b[0] == 0xC0 && b[7] == 0x9A) {
10145    /* IBM double 64-bit */
10146    printf("13\n");
10147    exit(0);
10148  }
10149  if (b[0] == 0xBF && b[7] == 0xCD) {
10150    /* CRAY single 64-bit */
10151    printf("14\n");
10152    exit(0);
10153  }
10154#endif
10155#if DOUBLESIZE == 16
10156  if (b[0] == 0x9A && b[15] == 0xBF) {
10157    /* IEEE 754 128-bit little-endian */
10158    printf("5\n");
10159    exit(0);
10160  }
10161  if (b[0] == 0xBF && b[15] == 0x9A) {
10162    /* IEEE 754 128-bit big-endian */
10163    printf("6\n");
10164    exit(0);
10165  }
10166#endif
10167  /* Then there are old mainframe/miniframe formats like IBM and CRAY.
10168   * Whether those environments can still build Perl is debatable. */
10169  printf("-1\n"); /* unknown */
10170  exit(0);
10171}
10172EOP
10173set try
10174if eval $compile; then
10175    doublekind=`$run ./try`
10176else
10177    doublekind=-1
10178fi
10179case "$doublekind" in
101801) echo "You have IEEE 754 32-bit little endian doubles." >&4 ;;
101812) echo "You have IEEE 754 32-bit big endian doubles." >&4 ;;
101823) echo "You have IEEE 754 64-bit little endian doubles." >&4 ;;
101834) echo "You have IEEE 754 64-bit big endian doubles." >&4 ;;
101845) echo "You have IEEE 754 128-bit little endian doubles." >&4 ;;
101856) echo "You have IEEE 754 128-bit big endian doubles." >&4 ;;
101867) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit LEs in BE)." >&4 ;;
101878) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit BEs in LE)." >&4 ;;
101889) echo "You have VAX format F 32-bit PDP-style mixed endian doubles." >&4 ;;
1018910) echo "You have VAX format D 64-bit PDP-style mixed endian doubles." >&4 ;;
1019011) echo "You have VAX format G 64-bit PDP-style mixed endian doubles." >&4 ;;
1019112) echo "You have IBM short 32-bit doubles." >&4 ;;
1019213) echo "You have IBM long 64-bit doubles." >&4 ;;
1019314) echo "You have Cray single 64-bit doubles." >&4 ;;
10194*) echo "Cannot figure out your double.  You Cyber, or something?" >&4 ;;
10195esac
10196d_double_style_ieee=$undef
10197d_double_style_vax=$undef
10198d_double_style_ibm=$undef
10199d_double_style_cray=$undef
10200case "$doublekind" in
102011|2|3|4|5|6|7|8) d_double_style_ieee=$define ;;
102029|10|11) d_double_style_vax=$define ;;
1020312|13) d_double_style_ibm=$define ;;
1020414) d_double_style_cray=$define ;;
10205esac
10206case "$d_double_style_ieee" in
10207$define)
10208    d_double_has_inf=$define
10209    d_double_has_nan=$define
10210    d_double_has_negative_zero=$define
10211    d_double_has_subnormals=$define
10212    ;;
10213*)
10214    d_double_has_inf=$undef
10215    d_double_has_nan=$undef
10216    d_double_has_negative_zero=$undef
10217    d_double_has_subnormals=$undef
10218    ;;
10219esac
10220$rm_try
10221
10222: Check print/scan long double stuff
10223echo " "
10224
10225if $test X"$d_longdbl" = X"$define"; then
10226
10227echo "Checking how to print long doubles..." >&4
10228
10229if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
10230	$cat >try.c <<'EOCP'
10231#include <sys/types.h>
10232#include <stdio.h>
10233int main() {
10234  double d = 123.456;
10235  printf("%.3f\n", d);
10236}
10237EOCP
10238	set try
10239	if eval $compile; then
10240		yyy=`$run ./try`
10241		case "$yyy" in
10242		123.456)
10243			sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
10244			sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
10245			echo "We will use %f."
10246			;;
10247		esac
10248	fi
10249fi
10250
10251if $test X"$sPRIfldbl" = X; then
10252	$cat >try.c <<'EOCP'
10253#include <sys/types.h>
10254#include <stdio.h>
10255int main() {
10256  long double d = 123.456;
10257  printf("%.3Lf\n", d);
10258}
10259EOCP
10260	set try
10261	if eval $compile; then
10262		yyy=`$run ./try`
10263		case "$yyy" in
10264		123.456)
10265			sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
10266			sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
10267			echo "We will use %Lf."
10268			;;
10269		esac
10270	fi
10271fi
10272
10273if $test X"$sPRIfldbl" = X; then
10274	$cat >try.c <<'EOCP'
10275#include <sys/types.h>
10276#include <stdio.h>
10277int main() {
10278  long double d = 123.456;
10279  printf("%.3llf\n", d);
10280}
10281EOCP
10282	set try
10283	if eval $compile; then
10284		yyy=`$run ./try`
10285		case "$yyy" in
10286		123.456)
10287			sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
10288			sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
10289			echo "We will use %llf."
10290			;;
10291		esac
10292	fi
10293fi
10294
10295if $test X"$sPRIfldbl" = X; then
10296	$cat >try.c <<'EOCP'
10297#include <sys/types.h>
10298#include <stdio.h>
10299int main() {
10300  long double d = 123.456;
10301  printf("%.3lf\n", d);
10302}
10303EOCP
10304	set try
10305	if eval $compile; then
10306		yyy=`$run ./try`
10307		case "$yyy" in
10308		123.456)
10309			sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
10310			sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
10311			echo "We will use %lf."
10312			;;
10313		esac
10314	fi
10315fi
10316
10317if $test X"$sPRIfldbl" = X; then
10318	echo "Cannot figure out how to print long doubles." >&4
10319else
10320	sSCNfldbl=$sPRIfldbl	# expect consistency
10321fi
10322
10323$rm_try
10324
10325fi # d_longdbl
10326
10327case "$sPRIfldbl" in
10328'')	d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
10329	d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
10330	d_SCNfldbl="$undef";
10331	;;
10332*)	d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
10333	d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
10334	d_SCNfldbl="$define";
10335	;;
10336esac
10337
10338: Before committing on uselongdouble, see whether that looks sane.
10339if $test "$uselongdouble" = "$define"; then
10340    message=""
10341    echo " "
10342    echo "Checking if your long double math functions work right..." >&4
10343    $cat > try.c <<EOF
10344#include <math.h>
10345#include <stdio.h>
10346int main() {
10347  printf("%"$sPRIgldbl"\n", sqrtl(logl(expl(cosl(sinl(0.0L))))+powl(2.0L, 3.0L)));
10348}
10349EOF
10350    case "$osname:$gccversion" in
10351    aix:)	saveccflags="$ccflags"
10352		ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
10353    esac
10354    set try
10355    if eval $compile_ok; then
10356      yyy=`$run ./try`
10357    fi
10358    case "$yyy" in
10359    3) echo "Your long double math functions are working correctly." >&4 ;;
10360    *) echo "Your long double math functions are broken, not using long doubles." >&4
10361       uselongdouble=$undef
10362       ;;
10363    esac
10364    $rm_try
10365    case "$osname:$gccversion" in
10366    aix:)	ccflags="$saveccflags" ;; # restore
10367    esac
10368fi
10369
10370: Check how to convert floats to strings.
10371
10372if test "X$d_Gconvert" = X; then
10373
10374echo " "
10375echo "Checking for an efficient way to convert floats to strings."
10376echo " " > try.c
10377case "$uselongdouble" in
10378"$define") echo "#define USE_LONG_DOUBLE" >>try.c ;;
10379esac
10380case "$d_longdbl" in
10381"$define") echo "#define HAS_LONG_DOUBLE" >>try.c ;;
10382esac
10383case "$d_PRIgldbl" in
10384"$define") echo "#define HAS_PRIgldbl"    >>try.c ;;
10385esac
10386$cat >>try.c <<EOP
10387#ifdef TRY_gconvert
10388#define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
10389const char *myname = "gconvert";
10390#endif
10391#ifdef TRY_gcvt
10392#define Gconvert(x,n,t,b) gcvt((x),(n),(b))
10393const char *myname = "gcvt";
10394#endif
10395#ifdef TRY_qgcvt
10396#define Gconvert(x,n,t,b) qgcvt((x),(n),(b))
10397const char *myname = "qgcvt";
10398#define DOUBLETYPE long double
10399#endif
10400#ifdef TRY_sprintf
10401#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10402#ifdef HAS_PRIgldbl
10403#define Gconvert(x,n,t,b) sprintf((b),"%.*"$sPRIgldbl,(n),(x))
10404#else
10405#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(double)(x))
10406#endif
10407#else
10408#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
10409#endif
10410const char *myname = "sprintf";
10411#endif
10412
10413#ifndef DOUBLETYPE
10414#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10415#define DOUBLETYPE long double
10416#else
10417#define DOUBLETYPE double
10418#endif
10419#endif
10420
10421#include <stdio.h>
10422
10423#$i_stdlib I_STDLIB
10424#ifdef I_STDLIB
10425#include <stdlib.h>
10426#endif
10427#include <string.h>
10428
10429void checkit(const char *expect, char *got)
10430{
10431    if (strcmp(expect, got)) {
10432		printf("%s oddity:  Expected %s, got %s\n",
10433			myname, expect, got);
10434		exit(1);
10435	}
10436}
10437
10438void lencheck(int expect, int got)
10439{
10440    if (expect != got) {
10441		printf("%s length mismatch:  Expected %d, got %d\n",
10442			myname, expect, got);
10443		exit(1);
10444	}
10445}
10446
10447int main()
10448{
10449	char buf[64];
10450	buf[63] = '\0';
10451
10452	/* This must be 1st test on (which?) platform */
10453	/* Alan Burlison <AlanBurlsin@unn.unisys.com> */
10454	Gconvert((DOUBLETYPE)0.1, 8, 0, buf);
10455	checkit("0.1", buf);
10456
10457	Gconvert((DOUBLETYPE)0.01, 8, 0, buf);
10458	checkit("0.01", buf);
10459
10460	Gconvert((DOUBLETYPE)0.001, 8, 0, buf);
10461	checkit("0.001", buf);
10462
10463	Gconvert((DOUBLETYPE)0.0001, 8, 0, buf);
10464	checkit("0.0001", buf);
10465
10466	Gconvert((DOUBLETYPE)0.00009, 8, 0, buf);
10467	if (strlen(buf) > 5)
10468	    checkit("9e-005", buf); /* for Microsoft ?? */
10469	else
10470	    checkit("9e-05", buf);
10471
10472	Gconvert((DOUBLETYPE)1.0, 8, 0, buf);
10473	checkit("1", buf);
10474
10475	Gconvert((DOUBLETYPE)1.1, 8, 0, buf);
10476	checkit("1.1", buf);
10477
10478	Gconvert((DOUBLETYPE)1.01, 8, 0, buf);
10479	checkit("1.01", buf);
10480
10481	Gconvert((DOUBLETYPE)1.001, 8, 0, buf);
10482	checkit("1.001", buf);
10483
10484	Gconvert((DOUBLETYPE)1.0001, 8, 0, buf);
10485	checkit("1.0001", buf);
10486
10487	Gconvert((DOUBLETYPE)1.00001, 8, 0, buf);
10488	checkit("1.00001", buf);
10489
10490	Gconvert((DOUBLETYPE)1.000001, 8, 0, buf);
10491	checkit("1.000001", buf);
10492
10493	Gconvert((DOUBLETYPE)0.0, 8, 0, buf);
10494	checkit("0", buf);
10495
10496	Gconvert((DOUBLETYPE)-1.0, 8, 0, buf);
10497	checkit("-1", buf);
10498
10499	/* Some Linux gcvt's give 1.e+5 here. */
10500	Gconvert((DOUBLETYPE)100000.0, 8, 0, buf);
10501	checkit("100000", buf);
10502
10503	/* Some Linux gcvt's give -1.e+5 here. */
10504	Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf);
10505	checkit("-100000", buf);
10506
10507	Gconvert((DOUBLETYPE)123.456, 8, 0, buf);
10508	checkit("123.456", buf);
10509
10510	/* Testing of 1e+129 in bigintpm.t must not get extra '.' here. */
10511	Gconvert((DOUBLETYPE)1e34, 8, 0, buf);
10512	/* 34 should be enough to scare even long double
10513	 * places into using the e notation. */
10514	if (strlen(buf) > 5)
10515	    checkit("1e+034", buf); /* for Microsoft */
10516	else
10517	    checkit("1e+34", buf);
10518
10519	/* Test for an Ubuntu/Debian bug in gcvt and qgcvt. See:        *
10520	 * https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1899553 */
10521
10522	Gconvert((DOUBLETYPE)0.4, 53, 0, buf);
10523	lencheck(55, (int)strlen(buf));
10524
10525	/* For Perl, if you add additional tests here, also add them to
10526	 * t/base/num.t for benefit of platforms not using Configure or
10527	 * overriding d_Gconvert */
10528
10529	exit(0);
10530}
10531EOP
10532: first add preferred functions to our list
10533xxx_list=""
10534for xxx_convert in $gconvert_preference; do
10535    case $xxx_convert in
10536    gcvt|gconvert|sprintf) xxx_list="$xxx_list $xxx_convert" ;;
10537    *) echo "Discarding unrecognized gconvert_preference $xxx_convert" >&4 ;;
10538    esac
10539done
10540: then add any others
10541for xxx_convert in gconvert gcvt sprintf; do
10542    case "$xxx_list" in
10543    *$xxx_convert*) ;;
10544    *) xxx_list="$xxx_list $xxx_convert" ;;
10545    esac
10546done
10547
10548case "$d_longdbl$uselongdouble" in
10549"$define$define")
10550    : again, add preferred functions to our list first
10551    xxx_ld_list=""
10552    for xxx_convert in $gconvert_ld_preference; do
10553        case $xxx_convert in
10554        qgcvt|gcvt|gconvert|sprintf) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10555        *) echo "Discarding unrecognized gconvert_ld_preference $xxx_convert" ;;
10556        esac
10557    done
10558    : then add qgcvt, sprintf--then, in xxx_list order, gconvert and gcvt
10559    for xxx_convert in qgcvt sprintf $xxx_list; do
10560        case "$xxx_ld_list" in
10561        $xxx_convert*|*" $xxx_convert"*) ;;
10562        *) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10563        esac
10564    done
10565    : if sprintf cannot do long doubles, move it to the end
10566    if test "$d_PRIgldbl" != "$define"; then
10567        xxx_ld_list="`echo $xxx_ld_list|sed s/sprintf//` sprintf"
10568    fi
10569    : if no qgcvt, remove it
10570    if test "$d_qgcvt" != "$define"; then
10571        xxx_ld_list="`echo $xxx_ld_list|sed s/qgcvt//`"
10572    fi
10573    : use the ld_list
10574    xxx_list="$xxx_ld_list"
10575    ;;
10576esac
10577
10578for xxx_convert in $xxx_list; do
10579	echo "Trying $xxx_convert..."
10580	$rm -f try try$_o core
10581	set try -DTRY_$xxx_convert
10582	if eval $compile; then
10583		echo "$xxx_convert() found." >&4
10584		if $run ./try; then
10585			echo "I'll use $xxx_convert to convert floats into a string." >&4
10586			break;
10587		else
10588			echo "...But $xxx_convert didn't work as I expected."
10589			xxx_convert=''
10590		fi
10591	else
10592		echo "$xxx_convert NOT found." >&4
10593		xxx_convert=''
10594	fi
10595done
10596
10597if test X$xxx_convert = X; then
10598    echo "*** WHOA THERE!!! ***" >&4
10599    echo "None of ($xxx_list)  seemed to work properly.  I'll use sprintf." >&4
10600    xxx_convert=sprintf
10601fi
10602
10603case "$xxx_convert" in
10604gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
10605gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
10606qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;;
10607*) case "$uselongdouble$d_longdbl$d_PRIgldbl" in
10608   "$define$define$define")
10609      d_Gconvert="sprintf((b),\"%.*\"$sPRIgldbl,(n),(x))" ;;
10610   "$define$define$undef")
10611      d_Gconvert='sprintf((b),"%.*g",(n),(double)(x))' ;;
10612   *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
10613   esac
10614   ;;
10615esac
10616
10617fi
10618$rm_try
10619
10620: see if _fwalk exists
10621set fwalk d__fwalk
10622eval $inlibc
10623
10624: see if accept4 exists
10625set accept4 d_accept4
10626eval $inlibc
10627
10628: Initialize h_fcntl
10629h_fcntl=false
10630
10631: Initialize h_sysfile
10632h_sysfile=false
10633
10634: access call always available on UNIX
10635set access d_access
10636eval $inlibc
10637
10638: locate the flags for 'access()'
10639case "$d_access" in
10640"$define")
10641	echo " "
10642	$cat >access.c <<EOCP
10643#include <sys/types.h>
10644#ifdef I_FCNTL
10645#include <fcntl.h>
10646#endif
10647#ifdef I_SYS_FILE
10648#include <sys/file.h>
10649#endif
10650#ifdef I_UNISTD
10651#include <unistd.h>
10652#endif
10653#$i_stdlib I_STDLIB
10654#ifdef I_STDLIB
10655#include <stdlib.h>
10656#endif
10657int main() {
10658	exit(R_OK);
10659}
10660EOCP
10661	: check sys/file.h first, no particular reason here
10662	if $test `./findhdr sys/file.h` && \
10663		$cc -o access $cppflags -DI_SYS_FILE access.c >/dev/null 2>&1 ; then
10664		h_sysfile=true;
10665		echo "<sys/file.h> defines the *_OK access constants." >&4
10666	elif $test `./findhdr fcntl.h` && \
10667		$cc -o access $cppflags -DI_FCNTL access.c >/dev/null 2>&1 ; then
10668		h_fcntl=true;
10669		echo "<fcntl.h> defines the *_OK access constants." >&4
10670	elif $test `./findhdr unistd.h` && \
10671		$cc -o access $cppflags -DI_UNISTD access.c >/dev/null 2>&1 ; then
10672		echo "<unistd.h> defines the *_OK access constants." >&4
10673	else
10674		echo "I can't find the four *_OK access constants--I'll use mine." >&4
10675	fi
10676	;;
10677esac
10678$rm -f access*
10679
10680: see if accessx exists
10681set accessx d_accessx
10682eval $inlibc
10683
10684: see if acosh exists
10685set acosh d_acosh
10686eval $inlibc
10687
10688: see if aintl exists
10689set aintl d_aintl
10690eval $inlibc
10691
10692: see if alarm exists
10693set alarm d_alarm
10694eval $inlibc
10695
10696: see if 64bit time functions exists
10697
10698set ctime64 d_ctime64
10699eval $inlibc
10700
10701set localtime64 d_localtime64
10702eval $inlibc
10703
10704set gmtime64 d_gmtime64
10705eval $inlibc
10706
10707set mktime64 d_mktime64
10708eval $inlibc
10709
10710set difftime64 d_difftime64
10711eval $inlibc
10712
10713set asctime64 d_asctime64
10714eval $inlibc
10715
10716: see if POSIX threads are available
10717set pthread.h i_pthread
10718eval $inhdr
10719
10720: define a function to check prototypes
10721$cat > protochk <<EOSH
10722$startsh
10723cc="$cc"
10724optimize="$optimize"
10725ccflags="$ccflags"
10726define="$define"
10727rm_try="$rm_try"
10728usethreads=$usethreads
10729i_pthread=$i_pthread
10730pthread_h_first=$pthread_h_first
10731EOSH
10732
10733$cat >> protochk <<'EOSH'
10734
10735$rm_try
10736foo="$1"
10737shift
10738while test $# -ge 2; do
10739	case "$1" in
10740		$define) echo "#include <$2>" >> try.c ;;
10741		literal) echo "$2" >> try.c ;;
10742	esac
10743    # Extra magic for the benefit of systems that need pthread.h
10744    # to be included early to correctly detect threadsafe functions.
10745    # Such functions must guarantee themselves, though, that the usethreads
10746    # and i_pthread have been defined, before calling protochk.
10747    if test "$usethreads" = "$define" -a "$i_pthread" = "$define" -a "$pthread_h_first" = "$define" -a "$pthread_h_done" = ""; then
10748	echo "#include <pthread.h>" >> try.c
10749	pthread_h_done=yes
10750    fi
10751    shift 2
10752done
10753cat >> try.c <<'EOCP'
10754#define _(args) args
10755EOCP
10756echo "$foo" >> try.c
10757echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
10758$cc $optimize $ccflags -c try.c > /dev/null 2>&1
10759status=$?
10760$rm_try
10761exit $status
10762EOSH
10763chmod +x protochk
10764$eunicefix protochk
10765
10766: Define hasproto macro for Configure internal use
10767hasproto='varname=$1; func=$2; shift; shift;
10768while $test $# -ge 2; do
10769	case "$1" in
10770	$define) echo "#include <$2>";;
10771	literal) echo "$2" ;;
10772	esac ;
10773    shift 2;
10774done > try.c;
10775$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
10776if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
10777	echo "$func() prototype found.";
10778	val="$define";
10779else
10780	echo "$func() prototype NOT found.";
10781	val="$undef";
10782fi;
10783set $varname;
10784eval $setvar;
10785$rm_try tryout.c'
10786
10787: see if sys/types.h has to be included
10788set sys/types.h i_systypes
10789eval $inhdr
10790
10791: see if sys/select.h has to be included
10792set sys/select.h i_sysselct
10793eval $inhdr
10794
10795: Define hasfield macro for Configure internal use
10796hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
10797while $test $# -ge 2; do
10798	case "$1" in
10799	$define) echo "#include <$2>";;
10800	esac ;
10801    shift 2;
10802done > try.c;
10803echo "int main () { struct $struct foo; char* bar; bar = (char*)foo.$field; }" >> try.c;
10804set try;
10805if eval $compile; then
10806	val="$define";
10807else
10808	val="$undef";
10809fi;
10810set $varname;
10811eval $setvar;
10812$rm_try'
10813
10814: see if we should include sys/time.h
10815echo " "
10816i_time='define'
10817if test "X$timeincl" = X; then
10818	echo "Testing to see if we should include <sys/time.h>." >&4
10819	$echo $n "I'm now running the test program...$c"
10820	$cat >try.c <<EOCP
10821#include <sys/types.h>
10822#include <time.h>
10823#ifdef I_SYSTIME
10824#ifdef SYSTIMEKERNEL
10825#define KERNEL
10826#endif
10827#include <sys/time.h>
10828#endif
10829#ifdef I_SYSSELECT
10830#include <sys/select.h>
10831#endif
10832#$i_stdlib I_STDLIB
10833#ifdef I_STDLIB
10834#include <stdlib.h>
10835#endif
10836int main()
10837{
10838	struct tm foo;
10839#ifdef S_TIMEVAL
10840	struct timeval bar;
10841#endif
10842#ifdef S_TIMEZONE
10843	struct timezone tzp;
10844#endif
10845	if (foo.tm_sec == foo.tm_sec)
10846		exit(0);
10847#ifdef S_TIMEVAL
10848	if (bar.tv_sec == bar.tv_sec)
10849		exit(0);
10850#endif
10851	exit(1);
10852}
10853EOCP
10854	flags=''
10855	for s_timezone in '-DS_TIMEZONE' ''; do
10856	sysselect=''
10857	for s_timeval in '-DS_TIMEVAL' ''; do
10858	for i_systimek in '' '-DSYSTIMEKERNEL'; do
10859	for i_systime in '-DI_SYSTIME' ''; do
10860		case "$flags" in
10861		'') $echo $n ".$c"
10862			set try $i_systime $i_systimek $sysselect $s_timeval $s_timezone
10863			if eval $compile; then
10864				set X $i_systime $i_systimek $sysselect $s_timeval
10865				shift
10866				flags="$*"
10867				echo " "
10868				$echo $n "Succeeded with $flags$c"
10869			fi
10870			;;
10871		esac
10872	done
10873	done
10874	done
10875	done
10876	timeincl=''
10877	echo " "
10878	case "$flags" in
10879	*SYSTIMEKERNEL*) i_systimek="$define"
10880		timeincl=`./findhdr sys/time.h`
10881		echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
10882	*) i_systimek="$undef";;
10883	esac
10884	case "$flags" in
10885	*I_SYSTIME*) i_systime="$define"
10886		timeincl=`./findhdr sys/time.h`" $timeincl"
10887		echo "We'll include <sys/time.h>." >&4;;
10888	*) i_systime="$undef";;
10889	esac
10890	$rm_try
10891fi
10892: see if struct tm knows about tm_zone
10893case "$i_systime$i_time" in
10894*$define*)
10895        echo " "
10896        echo "Checking to see if your struct tm has tm_zone field..." >&4
10897        set d_tm_tm_zone tm tm_zone $i_systime sys/time.h $i_time time.h
10898        eval $hasfield
10899        ;;
10900*)      val="$undef"
10901        set d_tm_tm_zone
10902        eval $setvar
10903        ;;
10904esac
10905case "$d_tm_tm_zone" in
10906"$define")      echo "Yes, it does."   ;;
10907*)              echo "No, it doesn't." ;;
10908esac
10909: see if struct tm knows about tm_gmtoff
10910case "$i_systime$i_time" in
10911*$define*)
10912        echo " "
10913        echo "Checking to see if your struct tm has tm_gmtoff field..." >&4
10914        set d_tm_tm_gmtoff tm tm_gmtoff $i_systime sys/time.h $i_time time.h
10915        eval $hasfield
10916        ;;
10917*)      val="$undef"
10918        set d_tm_tm_gmtoff
10919        eval $setvar
10920        ;;
10921esac
10922case "$d_tm_tm_gmtoff" in
10923"$define")      echo "Yes, it does."   ;;
10924*)              echo "No, it doesn't." ;;
10925esac
10926
10927: see if asctime_r exists
10928set asctime_r d_asctime_r
10929eval $inlibc
10930case "$d_asctime_r" in
10931"$define")
10932	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
10933	case "$d_asctime_r_proto:$usethreads" in
10934	":define")	d_asctime_r_proto=define
10935		set d_asctime_r_proto asctime_r $hdrs
10936		eval $hasproto ;;
10937	*)	;;
10938	esac
10939	case "$d_asctime_r_proto" in
10940	define)
10941	case "$asctime_r_proto" in
10942	''|0) try='char* asctime_r(const struct tm*, char*);'
10943	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SB ;;
10944	esac
10945	case "$asctime_r_proto" in
10946	''|0) try='char* asctime_r(const struct tm*, char*, int);'
10947	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SBI ;;
10948	esac
10949	case "$asctime_r_proto" in
10950	''|0) try='int asctime_r(const struct tm*, char*);'
10951	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SB ;;
10952	esac
10953	case "$asctime_r_proto" in
10954	''|0) try='int asctime_r(const struct tm*, char*, int);'
10955	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SBI ;;
10956	esac
10957	case "$asctime_r_proto" in
10958	''|0)	d_asctime_r=undef
10959		asctime_r_proto=0
10960		echo "Disabling asctime_r, cannot determine prototype." >&4 ;;
10961	* )	case "$asctime_r_proto" in
10962		REENTRANT_PROTO*) ;;
10963		*) asctime_r_proto="REENTRANT_PROTO_$asctime_r_proto" ;;
10964		esac
10965		echo "Prototype: $try" ;;
10966	esac
10967	;;
10968	*)	case "$usethreads" in
10969		define) echo "asctime_r has no prototype, not using it." >&4 ;;
10970		esac
10971		d_asctime_r=undef
10972		asctime_r_proto=0
10973		;;
10974	esac
10975	;;
10976*)	asctime_r_proto=0
10977	;;
10978esac
10979
10980: see if asinh exists
10981set asinh d_asinh
10982eval $inlibc
10983
10984: see if atanh exists
10985set atanh d_atanh
10986eval $inlibc
10987
10988: see if atolf exists
10989set atolf d_atolf
10990eval $inlibc
10991
10992: see if atoll exists
10993set atoll d_atoll
10994eval $inlibc
10995
10996: See if a file contains compiler warnings
10997: See if a file contains compiler warnings
10998case "$osname" in
10999  'aix')
11000	cat >compiler_warning <<EOSS
11001# Sample for aix ('.5' indicates the column number in the line):
11002#    "op.h", line 203.5: 1506-159 (E) Bit field type specified for op_type
11003# Since the word 'warning' isn't present, use a fairly rigorous match of what
11004# warning messages look like
11005#            "    o        p        .  h   ", line    203      .   5        :   1506     -    159      (  E  )
11006$grep -E "^\\"[A-Za-z][A-Za-z0-9_]*\.[ch]\\", line [1-9][0-9]*[.][1-9][0-9]*: [1-9][0-9]*-[1-9][0-9]* \([EW][)] " "\$1"
11007EOSS
11008        compiler_warning=./compiler_warning
11009        chmod +x $compiler_warning
11010    ;;
11011     # Maybe a colon after the 'warning' would be appropriate
11012  *) compiler_warning="$contains -i warning"
11013    ;;
11014esac
11015
11016: Look for GCC-style attribute format
11017case "$d_attribute_format" in
11018'')
11019echo " "
11020echo "Checking whether your compiler can handle __attribute__((format)) ..." >&4
11021$cat >attrib.c <<'EOCP'
11022#include <stdio.h>
11023void my_special_printf(char* pat,...) __attribute__((__format__(__printf__,1,2)));
11024EOCP
11025if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11026	if $compiler_warning attrib.out >/dev/null 2>&1; then
11027		echo "Your C compiler doesn't support __attribute__((format))."
11028		val="$undef"
11029	else
11030		echo "Your C compiler supports __attribute__((format))."
11031		val="$define"
11032	fi
11033else
11034	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11035	val="$undef"
11036fi
11037;;
11038*) val="$d_attribute_format" ;;
11039esac
11040set d_attribute_format
11041eval $setvar
11042$rm -f attrib*
11043
11044: Look for GCC-style attribute format with null format allowed
11045case "$d_printf_format_null" in
11046'') case "$d_attribute_format" in
11047    $define)
11048	echo " "
11049	echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
11050$cat >attrib.c <<EOCP
11051#include <stdio.h>
11052#$i_stdlib I_STDLIB
11053#ifdef I_STDLIB
11054#include <stdlib.h>
11055#endif
11056#$i_inttypes I_INTTYPES
11057#ifdef I_INTTYPES
11058#include <inttypes.h>
11059#endif
11060#ifndef INTPTR_MAX
11061#define intptr_t int
11062#endif
11063int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
11064int null_printf (char* pat,...) { return (int)(intptr_t)pat; }
11065int main () { exit(null_printf(NULL)); }
11066EOCP
11067	if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
11068	    : run the executable in case it produces a run-time warning
11069	    if $run ./attrib >>attrib.out 2>&1; then
11070		if $compiler_warning attrib.out >/dev/null 2>&1; then
11071		    echo "Your C compiler doesn't allow __printf__ format to be null."
11072		    val="$undef"
11073		else
11074		    echo "Your C compiler allows __printf__ format to be null."
11075		    val="$define"
11076		fi
11077	    else
11078	    echo "Your C compiler executable failed with __printf__ format null."
11079	    val="$undef"
11080	fi
11081    else
11082	echo "Your C compiler fails with __printf__ format null."
11083	val="$undef"
11084    fi
11085    ;;
11086    *)  val="$undef" ;;
11087    esac
11088;;
11089*)  val="$d_printf_format_null" ;;
11090esac
11091set d_printf_format_null
11092eval $setvar
11093$rm -f attrib*
11094
11095: Look for GCC-style attribute malloc
11096case "$d_attribute_malloc" in
11097'')
11098echo " "
11099echo "Checking whether your compiler can handle __attribute__((malloc)) ..." >&4
11100$cat >attrib.c <<'EOCP'
11101#include <stdio.h>
11102char *go_get_some_memory( int how_many_bytes ) __attribute__((malloc));
11103EOCP
11104if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11105	if $compiler_warning attrib.out >/dev/null 2>&1; then
11106		echo "Your C compiler doesn't support __attribute__((malloc))."
11107		val="$undef"
11108	else
11109		echo "Your C compiler supports __attribute__((malloc))."
11110		val="$define"
11111	fi
11112else
11113	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11114	val="$undef"
11115fi
11116;;
11117*) val="$d_attribute_malloc" ;;
11118esac
11119set d_attribute_malloc
11120eval $setvar
11121$rm -f attrib*
11122
11123: Look for GCC-style attribute nonnull
11124case "$d_attribute_nonnull" in
11125'')
11126echo " "
11127echo "Checking whether your compiler can handle __attribute__((nonnull(1))) ..." >&4
11128$cat >attrib.c <<'EOCP'
11129#include <stdio.h>
11130void do_something (char *some_pointer,...) __attribute__((nonnull(1)));
11131EOCP
11132if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11133	if $compiler_warning attrib.out >/dev/null 2>&1; then
11134		echo "Your C compiler doesn't support __attribute__((nonnull))."
11135		val="$undef"
11136	else
11137		echo "Your C compiler supports __attribute__((nonnull))."
11138		val="$define"
11139	fi
11140else
11141	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11142	val="$undef"
11143fi
11144;;
11145*) val="$d_attribute_nonnull" ;;
11146esac
11147set d_attribute_nonnull
11148eval $setvar
11149$rm -f attrib*
11150
11151: Look for GCC-style attribute noreturn
11152case "$d_attribute_noreturn" in
11153'')
11154echo " "
11155echo "Checking whether your compiler can handle __attribute__((noreturn)) ..." >&4
11156$cat >attrib.c <<'EOCP'
11157#include <stdio.h>
11158void fall_over_dead( void ) __attribute__((noreturn));
11159EOCP
11160if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11161	if $compiler_warning attrib.out >/dev/null 2>&1; then
11162		echo "Your C compiler doesn't support __attribute__((noreturn))."
11163		val="$undef"
11164	else
11165		echo "Your C compiler supports __attribute__((noreturn))."
11166		val="$define"
11167	fi
11168else
11169	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11170	val="$undef"
11171fi
11172;;
11173*) val="$d_attribute_noreturn" ;;
11174esac
11175set d_attribute_noreturn
11176eval $setvar
11177$rm -f attrib*
11178
11179: Look for GCC-style attribute pure
11180case "$d_attribute_pure" in
11181'')
11182echo " "
11183echo "Checking whether your compiler can handle __attribute__((pure)) ..." >&4
11184$cat >attrib.c <<'EOCP'
11185#include <stdio.h>
11186int square( int n ) __attribute__((pure));
11187EOCP
11188if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11189	if $compiler_warning attrib.out >/dev/null 2>&1; then
11190		echo "Your C compiler doesn't support __attribute__((pure))."
11191		val="$undef"
11192	else
11193		echo "Your C compiler supports __attribute__((pure))."
11194		val="$define"
11195	fi
11196else
11197	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11198	val="$undef"
11199fi
11200;;
11201*) val="$d_attribute_pure" ;;
11202esac
11203set d_attribute_pure
11204eval $setvar
11205$rm -f attrib*
11206
11207: Look for GCC-style attribute unused
11208case "$d_attribute_unused" in
11209'')
11210echo " "
11211echo "Checking whether your compiler can handle __attribute__((unused)) ..." >&4
11212$cat >attrib.c <<'EOCP'
11213#include <stdio.h>
11214int do_something( int dummy __attribute__((unused)), int n );
11215EOCP
11216if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11217	if $compiler_warning attrib.out >/dev/null 2>&1; then
11218		echo "Your C compiler doesn't support __attribute__((unused))."
11219		val="$undef"
11220	else
11221		echo "Your C compiler supports __attribute__((unused))."
11222		val="$define"
11223	fi
11224else
11225	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11226	val="$undef"
11227fi
11228;;
11229*) val="$d_attribute_unused" ;;
11230esac
11231set d_attribute_unused
11232eval $setvar
11233$rm -f attrib*
11234
11235: Look for GCC-style attribute deprecated
11236case "$d_attribute_deprecated" in
11237'')
11238echo " "
11239echo "Checking whether your compiler can handle __attribute__((deprecated)) ..." >&4
11240$cat >attrib.c <<'EOCP'
11241#include <stdio.h>
11242int I_am_deprecated(void) __attribute__((deprecated));
11243EOCP
11244if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11245	if $compiler_warning attrib.out >/dev/null 2>&1; then
11246		echo "Your C compiler doesn't support __attribute__((deprecated))."
11247		val="$undef"
11248	else
11249		echo "Your C compiler supports __attribute__((deprecated))."
11250		val="$define"
11251	fi
11252else
11253	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11254	val="$undef"
11255fi
11256;;
11257*) val="$d_attribute_deprecated" ;;
11258esac
11259set d_attribute_deprecated
11260eval $setvar
11261$rm -f attrib*
11262
11263: Look for GCC-style attribute warn_unused_result
11264case "$d_attribute_warn_unused_result" in
11265'')
11266echo " "
11267echo "Checking whether your compiler can handle __attribute__((warn_unused_result)) ..." >&4
11268$cat >attrib.c <<'EOCP'
11269#include <stdio.h>
11270int I_will_not_be_ignored(void) __attribute__((warn_unused_result));
11271EOCP
11272if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11273	if $compiler_warning attrib.out >/dev/null 2>&1; then
11274		echo "Your C compiler doesn't support __attribute__((warn_unused_result))."
11275		val="$undef"
11276	else
11277		echo "Your C compiler supports __attribute__((warn_unused_result))."
11278		val="$define"
11279	fi
11280else
11281	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11282	val="$undef"
11283fi
11284;;
11285*) val="$d_attribute_warn_unused_result" ;;
11286esac
11287set d_attribute_warn_unused_result
11288eval $setvar
11289$rm -f attrib*
11290
11291: Look for GCC-style attribute always_inline
11292case "$d_attribute_always_inline" in
11293'')
11294echo " "
11295echo "Checking whether your compiler can handle __attribute__((always_inline)) ..." >&4
11296$cat >attrib.c <<'EOCP'
11297#include <stdio.h>
11298static __inline__ __attribute__((always_inline)) int I_will_always_be_inlined(void);
11299EOCP
11300if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11301	if $compiler_warning attrib.out >/dev/null 2>&1; then
11302		echo "Your C compiler doesn't support __attribute__((always_inline))."
11303		val="$undef"
11304	else
11305		echo "Your C compiler supports __attribute__((always_inline))."
11306		val="$define"
11307	fi
11308else
11309	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11310	val="$undef"
11311fi
11312;;
11313*) val="$d_attribute_always_inline" ;;
11314esac
11315set d_attribute_always_inline
11316eval $setvar
11317$rm -f attrib*
11318
11319: Look for GCC-style attribute visibility
11320case "$d_attribute_visibility" in
11321'')
11322echo " "
11323echo "Checking whether your compiler can handle __attribute__((visibility)) ..." >&4
11324$cat >attrib.c <<'EOCP'
11325#include <stdio.h>
11326__attribute__((visibility("hidden"))) int I_will_be_hidden(void);
11327EOCP
11328if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11329	if $compiler_warning attrib.out >/dev/null 2>&1; then
11330		echo "Your C compiler doesn't support __attribute__((visibility))."
11331		val="$undef"
11332	else
11333		echo "Your C compiler supports __attribute__((visibility))."
11334		val="$define"
11335	fi
11336else
11337	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11338	val="$undef"
11339fi
11340;;
11341*) val="$d_attribute_visibility" ;;
11342esac
11343set d_attribute_visibility
11344eval $setvar
11345$rm -f attrib*
11346
11347: see if getpgrp exists
11348set getpgrp d_getpgrp
11349eval $inlibc
11350
11351case "$d_getpgrp" in
11352"$define")
11353	echo " "
11354	echo "Checking to see which flavor of getpgrp is in use..."
11355	$cat >try.c <<EOP
11356#include <stdio.h>
11357#$i_unistd I_UNISTD
11358#include <sys/types.h>
11359#ifdef I_UNISTD
11360#  include <unistd.h>
11361#endif
11362#$i_stdlib I_STDLIB
11363#ifdef I_STDLIB
11364#include <stdlib.h>
11365#endif
11366int main()
11367{
11368	if (getuid() == 0) {
11369		printf("(I see you are running Configure as super-user...)\n");
11370		setuid(1);
11371	}
11372#ifdef TRY_BSD_PGRP
11373	if (getpgrp(1) == 0)
11374		exit(0);
11375#else
11376	if (getpgrp() > 0)
11377		exit(0);
11378#endif
11379	exit(1);
11380}
11381EOP
11382	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11383		echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
11384		val="$define"
11385	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11386		echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
11387		val="$undef"
11388	else
11389		echo "I can't seem to compile and run the test program."
11390		if ./usg; then
11391			xxx="a USG one, i.e. you use getpgrp()."
11392		else
11393			# SVR4 systems can appear rather BSD-ish.
11394			case "$i_unistd" in
11395			$undef)
11396				xxx="a BSD one, i.e. you use getpgrp(pid)."
11397				val="$define"
11398				;;
11399			$define)
11400				xxx="probably a USG one, i.e. you use getpgrp()."
11401				val="$undef"
11402				;;
11403			esac
11404		fi
11405		echo "Assuming your getpgrp is $xxx" >&4
11406	fi
11407	;;
11408*) val="$undef";;
11409esac
11410set d_bsdgetpgrp
11411eval $setvar
11412$rm_try
11413
11414: see if setpgrp exists
11415set setpgrp d_setpgrp
11416eval $inlibc
11417
11418case "$d_setpgrp" in
11419"$define")
11420	echo " "
11421	echo "Checking to see which flavor of setpgrp is in use..."
11422	$cat >try.c <<EOP
11423#include <stdio.h>
11424#$i_unistd I_UNISTD
11425#include <sys/types.h>
11426#ifdef I_UNISTD
11427#  include <unistd.h>
11428#endif
11429#$i_stdlib I_STDLIB
11430#ifdef I_STDLIB
11431#include <stdlib.h>
11432#endif
11433int main()
11434{
11435	if (getuid() == 0) {
11436		printf("(I see you are running Configure as super-user...)\n");
11437		setuid(1);
11438	}
11439#ifdef TRY_BSD_PGRP
11440	if (-1 == setpgrp(1, 1))
11441		exit(0);
11442#else
11443	if (setpgrp() != -1)
11444		exit(0);
11445#endif
11446	exit(1);
11447}
11448EOP
11449	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11450		echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
11451		val="$define"
11452	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11453		echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
11454		val="$undef"
11455	else
11456		echo "(I can't seem to compile and run the test program.)"
11457		if ./usg; then
11458			xxx="a USG one, i.e. you use setpgrp()."
11459		else
11460			# SVR4 systems can appear rather BSD-ish.
11461			case "$i_unistd" in
11462			$undef)
11463				xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
11464				val="$define"
11465				;;
11466			$define)
11467				xxx="probably a USG one, i.e. you use setpgrp()."
11468				val="$undef"
11469				;;
11470			esac
11471		fi
11472		echo "Assuming your setpgrp is $xxx" >&4
11473	fi
11474	;;
11475*) val="$undef";;
11476esac
11477set d_bsdsetpgrp
11478eval $setvar
11479$rm_try
11480
11481: Look for GCC-style __builtin_add_overflow
11482case "$d_builtin_add_overflow" in
11483'')
11484    echo " "
11485    echo "Checking whether your compiler can handle __builtin_add_overflow ..." >&4
11486    $cat >try.c <<'EOCP'
11487int main(void) {
11488    const unsigned int uint_max = ~0u;
11489    int target_int = 0;
11490    if (__builtin_add_overflow(1, 2, &target_int) || target_int != 3) {
11491        return 1;
11492    }
11493    if (!__builtin_add_overflow((int)(uint_max >> 1), 1, &target_int)) {
11494        return 1;
11495    }
11496    if (!__builtin_add_overflow(uint_max, -1, &target_int)) {
11497        return 1;
11498    }
11499    return 0;
11500}
11501EOCP
11502    set try
11503    if eval $compile && $run ./try; then
11504        echo "Your C compiler supports __builtin_add_overflow."
11505        val="$define"
11506    else
11507        echo "Your C compiler doesn't seem to understand __builtin_add_overflow."
11508        val="$undef"
11509    fi
11510    ;;
11511*) val="$d_builtin_add_overflow" ;;
11512esac
11513
11514set d_builtin_add_overflow
11515eval $setvar
11516$rm_try
11517
11518: Look for GCC-style __builtin_sub_overflow
11519case "$d_builtin_sub_overflow" in
11520'')
11521    echo " "
11522    echo "Checking whether your compiler can handle __builtin_sub_overflow ..." >&4
11523    $cat >try.c <<'EOCP'
11524int main(void) {
11525    const unsigned int uint_max = ~0u;
11526    int target_int = 0;
11527    if (__builtin_sub_overflow(1, -2, &target_int) || target_int != 3) {
11528        return 1;
11529    }
11530    if (!__builtin_sub_overflow(-(int)(uint_max >> 1), 2, &target_int)) {
11531        return 1;
11532    }
11533    if (!__builtin_sub_overflow(uint_max, 1, &target_int)) {
11534        return 1;
11535    }
11536    return 0;
11537}
11538EOCP
11539    set try
11540    if eval $compile && $run ./try; then
11541        echo "Your C compiler supports __builtin_sub_overflow."
11542        val="$define"
11543    else
11544        echo "Your C compiler doesn't seem to understand __builtin_sub_overflow."
11545        val="$undef"
11546    fi
11547    ;;
11548*) val="$d_builtin_sub_overflow" ;;
11549esac
11550
11551set d_builtin_sub_overflow
11552eval $setvar
11553$rm_try
11554
11555: Look for GCC-style __builtin_mul_overflow
11556case "$d_builtin_mul_overflow" in
11557'')
11558    echo " "
11559    echo "Checking whether your compiler can handle __builtin_mul_overflow ..." >&4
11560    $cat >try.c <<'EOCP'
11561int main(void) {
11562    const unsigned int uint_max = ~0u;
11563    int target_int = 0;
11564    if (__builtin_mul_overflow(2, 3, &target_int) || target_int != 6) {
11565        return 1;
11566    }
11567    if (!__builtin_mul_overflow((int)(uint_max >> 1), 2, &target_int)) {
11568        return 1;
11569    }
11570    if (!__builtin_mul_overflow(uint_max, 1, &target_int)) {
11571        return 1;
11572    }
11573    return 0;
11574}
11575EOCP
11576    set try
11577    if eval $compile && $run ./try; then
11578        echo "Your C compiler supports __builtin_mul_overflow."
11579        val="$define"
11580    else
11581        echo "Your C compiler doesn't seem to understand __builtin_mul_overflow."
11582        val="$undef"
11583    fi
11584    ;;
11585*) val="$d_builtin_mul_overflow" ;;
11586esac
11587
11588set d_builtin_mul_overflow
11589eval $setvar
11590$rm_try
11591
11592: Look for GCC-style __builtin_choose_expr
11593case "$d_builtin_choose_expr" in
11594'')
11595    echo " "
11596    echo "Checking whether your compiler can handle __builtin_choose_expr ..." >&4
11597    $cat >try.c <<'EOCP'
11598#include <assert.h>
11599#include <stdlib.h>
11600#include <stdio.h>
11601
11602#define SYRINX(x) __builtin_choose_expr( x, (1056*2), (103*50) )
11603
11604int main(void) {
11605    assert( SYRINX(1) == 2112 );
11606    assert( SYRINX(1) != 5150 );
11607    assert( SYRINX(0) == 5150 );
11608    assert( SYRINX(0) != 2112 );
11609    puts( "All good!" );
11610    exit(0);
11611}
11612
11613EOCP
11614    set try
11615    if eval $compile && $run ./try; then
11616	echo "Your C compiler supports __builtin_choose_expr."
11617	val="$define"
11618    else
11619	echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
11620	val="$undef"
11621    fi
11622;;
11623*) val="$d_builtin_choose_expr" ;;
11624esac
11625
11626set d_builtin_choose_expr
11627eval $setvar
11628$rm_try
11629
11630: Look for GCC-style __builtin_expect
11631case "$d_builtin_expect" in
11632'')
11633    echo " "
11634    echo "Checking whether your compiler can handle __builtin_expect ..." >&4
11635    $cat >try.c <<'EOCP'
11636int main(void) {
11637    int n = 50;
11638    if ( __builtin_expect(n, 0) ) n = 1;
11639    /* Remember shell exit code truth is 0, C truth is non-zero */
11640    return !(n == 1);
11641}
11642EOCP
11643    set try
11644    if eval $compile && $run ./try; then
11645	echo "Your C compiler supports __builtin_expect."
11646	val="$define"
11647    else
11648	echo "Your C compiler doesn't seem to understand __builtin_expect."
11649	val="$undef"
11650    fi
11651    ;;
11652*) val="$d_builtin_expect" ;;
11653esac
11654
11655set d_builtin_expect
11656eval $setvar
11657$rm_try
11658
11659: see if the Compiler supports C99 variadic macros
11660echo "Checking for C99 variadic macros." >&4
11661$cat >try.c <<EOCP
11662#include <stdio.h>
11663#include <stdarg.h>
11664
11665#define foo(buffer, format, ...) sprintf(buffer, format, __VA_ARGS__)
11666
11667int main() {
11668  char buf[20];
11669  foo(buf, "%d %g %.*s", 123, 456.0, (int)3, "789fail");
11670  puts(buf);
11671  return 0;
11672}
11673EOCP
11674set try
11675if eval $compile && $run ./try 2>&1 >/dev/null; then
11676    case "`$run ./try`" in
11677	"123 456 789")
11678	echo "You have C99 variadic macros." >&4
11679	d_c99_variadic_macros="$define"
11680	;;
11681	*)
11682	echo "You don't have functional C99 variadic macros." >&4
11683	d_c99_variadic_macros="$undef"
11684	;;
11685    esac
11686else
11687    echo "I couldn't compile and run the test program, so I assume that you don't have functional C99 variadic macros." >&4
11688    d_c99_variadic_macros="$undef"
11689fi
11690$rm_try
11691
11692: see if signal is declared as pointer to function returning int or void
11693echo " "
11694xxx=`./findhdr signal.h`
11695$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
11696if $contains 'int.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11697	echo "You have int (*signal())() instead of void." >&4
11698	val="$undef"
11699elif $contains 'void.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11700	echo "You have void (*signal())()." >&4
11701	val="$define"
11702elif $contains 'extern[ 	]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
11703	echo "You have int (*signal())() instead of void." >&4
11704	val="$undef"
11705elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
11706	echo "You have void (*signal())()." >&4
11707	val="$define"
11708else
11709	case "$d_voidsig" in
11710	'')
11711	echo "I can't determine whether signal handler returns void or int..." >&4
11712		dflt=void
11713		rp="What type does your signal handler return?"
11714		. ./myread
11715		case "$ans" in
11716		v*) val="$define";;
11717		*) val="$undef";;
11718		esac;;
11719	"$define")
11720		echo "As you already told me, signal handler returns void." >&4
11721		val="$define"
11722		;;
11723	*)	echo "As you already told me, signal handler returns int." >&4
11724		val="$undef"
11725		;;
11726	esac
11727fi
11728set d_voidsig
11729eval $setvar
11730case "$d_voidsig" in
11731"$define") signal_t="void";;
11732*) signal_t="int";;
11733esac
11734$rm -f $$.tmp
11735
11736: check for ability to cast large floats to 32-bit ints.
11737echo " "
11738echo 'Checking whether your C compiler can cast large floats to int32.' >&4
11739if $test "$intsize" -ge 4; then
11740	xxx=int
11741else
11742	xxx=long
11743fi
11744$cat >try.c <<EOCP
11745#include <stdio.h>
11746#$i_stdlib I_STDLIB
11747#ifdef I_STDLIB
11748#include <stdlib.h>
11749#endif
11750#include <sys/types.h>
11751#include <signal.h>
11752$signal_t blech(int s) { exit(3); }
11753int main()
11754{
11755	$xxx i32;
11756	double f, g;
11757	int result = 0;
11758	char str[16];
11759	signal(SIGFPE, blech);
11760
11761	/* Don't let compiler optimize the test away.  Store the number
11762	   in a writable string for gcc to pass to sscanf under HP-UX.
11763	*/
11764	sprintf(str, "2147483647");
11765	sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
11766	g = 10 * f;
11767	i32  = ($xxx) g;
11768
11769	/* x86 processors will probably give 0x8000 0000, which is a
11770	   sign change.  We don't want that.  We want to mimic SPARC
11771	   behavior here, which is to preserve the sign and give
11772	   back 0x7fff ffff.
11773	*/
11774	if (i32 != ($xxx) f)
11775		result |= 1;
11776	exit(result);
11777}
11778EOCP
11779set try
11780if eval $compile_ok; then
11781	$run ./try 2>/dev/null
11782	yyy=$?
11783else
11784	echo "(I can't seem to compile the test program--assuming it can't)"
11785	yyy=1
11786fi
11787case "$yyy" in
117880)	val="$define"
11789	echo "Yup, it can."
11790	;;
11791*)	val="$undef"
11792	echo "Nope, it can't."
11793	;;
11794esac
11795set d_casti32
11796eval $setvar
11797$rm_try
11798
11799: check for ability to cast negative floats to unsigned
11800echo " "
11801echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
11802$cat >try.c <<EOCP
11803#include <stdio.h>
11804#$i_stdlib I_STDLIB
11805#ifdef I_STDLIB
11806#include <stdlib.h>
11807#endif
11808#include <sys/types.h>
11809#include <signal.h>
11810$signal_t blech(int s) { exit(7); }
11811$signal_t blech_in_list(int s) { exit(4); }
11812unsigned long dummy_long(unsigned long p) { return p; }
11813unsigned int dummy_int(unsigned int p) { return p; }
11814unsigned short dummy_short(unsigned short p) { return p; }
11815int main()
11816{
11817	double f;
11818	unsigned long along;
11819	unsigned int aint;
11820	unsigned short ashort;
11821	int result = 0;
11822	char str[16];
11823
11824	/* Frustrate gcc-2.7.2's optimizer which failed this test with
11825	   a direct f = -123. assignment.  gcc-2.8.0 reportedly
11826	   optimized the whole file away
11827	*/
11828	/* Store the number in a writable string for gcc to pass to
11829	   sscanf under HP-UX.
11830	*/
11831	sprintf(str, "-123");
11832	sscanf(str, "%lf", &f);  /* f = -123.; */
11833
11834	signal(SIGFPE, blech);
11835	along = (unsigned long)f;
11836	aint = (unsigned int)f;
11837	ashort = (unsigned short)f;
11838	if (along != (unsigned long)-123)
11839		result |= 1;
11840	if (aint != (unsigned int)-123)
11841		result |= 1;
11842	if (ashort != (unsigned short)-123)
11843		result |= 1;
11844	sprintf(str, "1073741824.");
11845	sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
11846	f = f + f;
11847	along = 0;
11848	along = (unsigned long)f;
11849	if (along != 0x80000000)
11850		result |= 2;
11851	f -= 1.;
11852	along = 0;
11853	along = (unsigned long)f;
11854	if (along != 0x7fffffff)
11855		result |= 1;
11856	f += 2.;
11857	along = 0;
11858	along = (unsigned long)f;
11859	if (along != 0x80000001)
11860		result |= 2;
11861	if (result)
11862		exit(result);
11863	signal(SIGFPE, blech_in_list);
11864	sprintf(str, "123.");
11865	sscanf(str, "%lf", &f);  /* f = 123.; */
11866	along = dummy_long((unsigned long)f);
11867	aint = dummy_int((unsigned int)f);
11868	ashort = dummy_short((unsigned short)f);
11869	if (along != (unsigned long)123)
11870		result |= 4;
11871	if (aint != (unsigned int)123)
11872		result |= 4;
11873	if (ashort != (unsigned short)123)
11874		result |= 4;
11875	exit(result);
11876
11877}
11878EOCP
11879set try
11880if eval $compile_ok; then
11881	$run ./try 2>/dev/null
11882	castflags=$?
11883else
11884	echo "(I can't seem to compile the test program--assuming it can't)"
11885	castflags=7
11886fi
11887case "$castflags" in
118880)	val="$define"
11889	echo "Yup, it can."
11890	;;
11891*)	val="$undef"
11892	echo "Nope, it can't."
11893	;;
11894esac
11895set d_castneg
11896eval $setvar
11897$rm_try
11898
11899: see if cbrt exists
11900set cbrt d_cbrt
11901eval $inlibc
11902
11903: see if chown exists
11904set chown d_chown
11905eval $inlibc
11906
11907: see if chroot exists
11908set chroot d_chroot
11909eval $inlibc
11910
11911: see if chsize exists
11912set chsize d_chsize
11913eval $inlibc
11914
11915: see if class exists
11916set class d_class
11917eval $inlibc
11918
11919: see if clearenv exists
11920set clearenv d_clearenv
11921eval $inlibc
11922
11923: Define hasstruct macro for Configure internal use
11924hasstruct='varname=$1; struct=$2; shift; shift;
11925while $test $# -ge 2; do
11926	case "$1" in
11927	$define) echo "#include <$2>";;
11928	esac ;
11929    shift 2;
11930done > try.c;
11931echo "int main () { struct $struct foo; }" >> try.c;
11932set try;
11933if eval $compile; then
11934	val="$define";
11935else
11936	val="$undef";
11937fi;
11938set $varname;
11939eval $setvar;
11940$rm_try'
11941
11942: see whether socket exists
11943socketlib=''
11944sockethdr=''
11945echo " "
11946$echo $n "Hmm... $c" >&4
11947if set socket val -f d_socket; eval $csym; $val; then
11948    echo "Looks like you have Berkeley networking support." >&4
11949    d_socket="$define"
11950    if set setsockopt val -f; eval $csym; $val; then
11951	d_oldsock="$undef"
11952    else
11953	echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
11954	d_oldsock="$define"
11955    fi
11956else
11957    if $contains socklib libc.list >/dev/null 2>&1; then
11958	echo "Looks like you have Berkeley networking support." >&4
11959	d_socket="$define"
11960	: we will have to assume that it supports the 4.2 BSD interface
11961	d_oldsock="$undef"
11962    else
11963	echo "You don't have Berkeley networking in libc$_a..." >&4
11964	if test "X$d_socket" = "X$define"; then
11965	    echo "...but you seem to believe that you have sockets." >&4
11966	else
11967	    for net in net socket
11968	    do
11969		if test -f $sysroot/usr/lib/lib$net$_a; then
11970		    ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) ||  \
11971		    $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list
11972		    if $contains socket libc.list >/dev/null 2>&1; then
11973			d_socket="$define"
11974			socketlib="-l$net"
11975			case "$net" in
11976			net)
11977			    echo "...but the Wollongong group seems to have hacked it in." >&4
11978			    sockethdr="-I$sysroot/usr/netinclude"
11979			    ;;
11980			esac
11981			echo "Found Berkeley sockets interface in lib$net." >&4
11982			if $contains setsockopt libc.list >/dev/null 2>&1; then
11983			    d_oldsock="$undef"
11984			else
11985			    echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
11986			    d_oldsock="$define"
11987			fi
11988			break
11989		    fi
11990		fi
11991	    done
11992	    if test "X$d_socket" != "X$define"; then
11993	       echo "or anywhere else I see." >&4
11994	       d_socket="$undef"
11995	       d_oldsock="$undef"
11996	    fi
11997	fi
11998    fi
11999fi
12000
12001: see if socketpair exists
12002set socketpair d_sockpair
12003eval $inlibc
12004
12005
12006echo "Checking the availability sa_len in the sock struct ..." >&4
12007$cat >try.c <<EOF
12008#include <sys/types.h>
12009#include <sys/socket.h>
12010int main() {
12011struct sockaddr sa;
12012return (sa.sa_len);
12013}
12014EOF
12015val="$undef"
12016set try; if eval $compile; then
12017    val="$define"
12018fi
12019set d_sockaddr_sa_len; eval $setvar
12020$rm_try
12021
12022echo "Checking the availability struct sockaddr_in6 ..." >&4
12023$cat >try.c <<EOF
12024#include <sys/types.h>
12025#include <sys/socket.h>
12026#include <netinet/in.h>
12027int main() {
12028struct sockaddr_in6 sin6;
12029return (sin6.sin6_family);
12030}
12031EOF
12032val="$undef"
12033set try; if eval $compile; then
12034    val="$define"
12035fi
12036set d_sockaddr_in6; eval $setvar
12037$rm_try
12038
12039echo "Checking the availability struct sockaddr_storage ..." >&4
12040$cat >try.c <<EOF
12041#include <sys/types.h>
12042#include <sys/socket.h>
12043#include <netinet/in.h>
12044int main() {
12045struct sockaddr_storage sastor;
12046return (sastor.ss_family);
12047}
12048EOF
12049val="$undef"
12050set try; if eval $compile; then
12051    val="$define"
12052fi
12053set d_sockaddr_storage; eval $setvar
12054$rm_try
12055
12056echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
12057$cat >try.c <<EOF
12058#include <sys/types.h>
12059#include <sys/socket.h>
12060#include <netinet/in.h>
12061int main() {
12062struct sockaddr_in6 sin6;
12063return (sin6.sin6_scope_id);
12064}
12065EOF
12066val="$undef"
12067set try; if eval $compile; then
12068    val="$define"
12069fi
12070set d_sin6_scope_id; eval $setvar
12071$rm_try
12072
12073echo "Checking the availability struct ip_mreq ..." >&4
12074$cat >try.c <<EOF
12075#include <sys/types.h>
12076#include <sys/socket.h>
12077#include <netinet/in.h>
12078int main() {
12079struct ip_mreq mreq;
12080return (mreq.imr_multiaddr.s_addr);
12081}
12082EOF
12083val="$undef"
12084set try; if eval $compile; then
12085       val="$define"
12086fi
12087set d_ip_mreq; eval $setvar
12088$rm_try
12089
12090echo "Checking the availability struct ip_mreq_source ..." >&4
12091$cat >try.c <<EOF
12092#include <sys/types.h>
12093#include <sys/socket.h>
12094#include <netinet/in.h>
12095int main() {
12096struct ip_mreq_source mreq;
12097return (mreq.imr_multiaddr.s_addr);
12098}
12099EOF
12100val="$undef"
12101set try; if eval $compile; then
12102       val="$define"
12103fi
12104set d_ip_mreq_source; eval $setvar
12105$rm_try
12106
12107echo "Checking the availability struct ipv6_mreq ..." >&4
12108$cat >try.c <<EOF
12109#include <sys/types.h>
12110#include <sys/socket.h>
12111#include <netinet/in.h>
12112int main() {
12113struct ipv6_mreq mreq;
12114return (mreq.ipv6mr_interface);
12115}
12116EOF
12117val="$undef"
12118set try; if eval $compile; then
12119    val="$define"
12120fi
12121set d_ipv6_mreq; eval $setvar
12122$rm_try
12123
12124echo "Checking the availability struct ipv6_mreq_source ..." >&4
12125$cat >try.c <<EOF
12126#include <sys/types.h>
12127#include <sys/socket.h>
12128#include <netinet/in.h>
12129int main() {
12130struct ipv6_mreq_source mreq;
12131return (mreq.imr_multiaddr.s_addr);
12132}
12133EOF
12134val="$undef"
12135set try; if eval $compile; then
12136       val="$define"
12137fi
12138set d_ipv6_mreq_source; eval $setvar
12139$rm_try
12140
12141echo "Checking the availability of certain socket constants..." >&4
12142for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
12143    enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
12144    $cat >try.c <<EOF
12145#include <sys/types.h>
12146#include <sys/socket.h>
12147int main() {
12148    int i = $ENUM;
12149}
12150EOF
12151    val="$undef"
12152    set try; if eval $compile; then
12153	val="$define"
12154    fi
12155    set d_${enum}; eval $setvar
12156    $rm_try
12157done
12158
12159: see if this is a sys/uio.h system
12160set sys/uio.h i_sysuio
12161eval $inhdr
12162
12163: Check for cmsghdr support
12164echo " "
12165echo "Checking to see if your system supports struct cmsghdr..." >&4
12166set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
12167eval $hasstruct
12168case "$d_cmsghdr_s" in
12169"$define")      echo "Yes, it does."   ;;
12170*)              echo "No, it doesn't." ;;
12171esac
12172
12173: see if copysign exists
12174set copysign d_copysign
12175eval $inlibc
12176
12177: see if copysignl exists
12178set copysignl d_copysignl
12179eval $inlibc
12180
12181: see if crypt exists
12182echo " "
12183set crypt d_crypt
12184eval $inlibc
12185case "$d_crypt" in
12186$define) cryptlib='' ;;
12187*)	if set crypt val -f d_crypt; eval $csym; $val; then
12188		echo 'crypt() found.' >&4
12189		val="$define"
12190		cryptlib=''
12191	else
12192		cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
12193		if $test -z "$cryptlib"; then
12194			cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
12195		else
12196			cryptlib=-lcrypt
12197		fi
12198		if $test -z "$cryptlib"; then
12199			cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
12200		else
12201			cryptlib=-lcrypt
12202		fi
12203		if $test -z "$cryptlib"; then
12204			cryptlib=`./loc libcrypt$_a "" $libpth`
12205		else
12206			cryptlib=-lcrypt
12207		fi
12208		if $test -z "$cryptlib"; then
12209			echo 'crypt() NOT found.' >&4
12210			val="$undef"
12211		else
12212			val="$define"
12213		fi
12214	fi
12215	set d_crypt
12216	eval $setvar
12217	;;
12218esac
12219
12220: see if this is a crypt.h system
12221set crypt.h i_crypt
12222eval $inhdr
12223
12224: see if crypt_r exists
12225set crypt_r d_crypt_r
12226eval $inlibc
12227case "$d_crypt_r" in
12228"$define")
12229	hdrs="$i_systypes sys/types.h define stdio.h $i_crypt crypt.h"
12230	case "$d_crypt_r_proto:$usethreads" in
12231	":define")	d_crypt_r_proto=define
12232		set d_crypt_r_proto crypt_r $hdrs
12233		eval $hasproto ;;
12234	*)	;;
12235	esac
12236	case "$d_crypt_r_proto" in
12237	define)
12238	case "$crypt_r_proto" in
12239	''|0) try='char* crypt_r(const char*, const char*, struct crypt_data*);'
12240	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCS ;;
12241	esac
12242	case "$crypt_r_proto" in
12243	''|0) try='char* crypt_r(const char*, const char*, CRYPTD*);'
12244	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCD ;;
12245	esac
12246	case "$crypt_r_proto" in
12247	''|0)	d_crypt_r=undef
12248		crypt_r_proto=0
12249		echo "Disabling crypt_r, cannot determine prototype." >&4 ;;
12250	* )	case "$crypt_r_proto" in
12251		REENTRANT_PROTO*) ;;
12252		*) crypt_r_proto="REENTRANT_PROTO_$crypt_r_proto" ;;
12253		esac
12254		echo "Prototype: $try" ;;
12255	esac
12256	;;
12257	*)	case "$usethreads" in
12258		define) echo "crypt_r has no prototype, not using it." >&4 ;;
12259		esac
12260		d_crypt_r=undef
12261		crypt_r_proto=0
12262		;;
12263	esac
12264	;;
12265*)	crypt_r_proto=0
12266	;;
12267esac
12268
12269: get csh whereabouts
12270case "$csh" in
12271'csh') val="$undef" ;;
12272*) val="$define" ;;
12273esac
12274set d_csh
12275eval $setvar
12276: Respect a hint or command line value for full_csh.
12277case "$full_csh" in
12278'') full_csh=$csh ;;
12279esac
12280
12281: see if ctermid exists
12282set ctermid d_ctermid
12283eval $inlibc
12284
12285: see if ctermid_r exists
12286set ctermid_r d_ctermid_r
12287eval $inlibc
12288case "$d_ctermid_r" in
12289"$define")
12290	hdrs="$i_systypes sys/types.h define stdio.h "
12291	case "$d_ctermid_r_proto:$usethreads" in
12292	":define")	d_ctermid_r_proto=define
12293		set d_ctermid_r_proto ctermid_r $hdrs
12294		eval $hasproto ;;
12295	*)	;;
12296	esac
12297	case "$d_ctermid_r_proto" in
12298	define)
12299	case "$ctermid_r_proto" in
12300	''|0) try='char* ctermid_r(char*);'
12301	./protochk "$extern_C $try" $hdrs && ctermid_r_proto=B_B ;;
12302	esac
12303	case "$ctermid_r_proto" in
12304	''|0)	d_ctermid_r=undef
12305		ctermid_r_proto=0
12306		echo "Disabling ctermid_r, cannot determine prototype." >&4 ;;
12307	* )	case "$ctermid_r_proto" in
12308		REENTRANT_PROTO*) ;;
12309		*) ctermid_r_proto="REENTRANT_PROTO_$ctermid_r_proto" ;;
12310		esac
12311		echo "Prototype: $try" ;;
12312	esac
12313	;;
12314	*)	case "$usethreads" in
12315		define) echo "ctermid_r has no prototype, not using it." >&4 ;;
12316		esac
12317		d_ctermid_r=undef
12318		ctermid_r_proto=0
12319		;;
12320	esac
12321	;;
12322*)	ctermid_r_proto=0
12323	;;
12324esac
12325
12326: see if ctime_r exists
12327set ctime_r d_ctime_r
12328eval $inlibc
12329case "$d_ctime_r" in
12330"$define")
12331	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
12332	case "$d_ctime_r_proto:$usethreads" in
12333	":define")	d_ctime_r_proto=define
12334		set d_ctime_r_proto ctime_r $hdrs
12335		eval $hasproto ;;
12336	*)	;;
12337	esac
12338	case "$d_ctime_r_proto" in
12339	define)
12340	case "$ctime_r_proto" in
12341	''|0) try='char* ctime_r(const time_t*, char*);'
12342	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SB ;;
12343	esac
12344	case "$ctime_r_proto" in
12345	''|0) try='char* ctime_r(const time_t*, char*, int);'
12346	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SBI ;;
12347	esac
12348	case "$ctime_r_proto" in
12349	''|0) try='int ctime_r(const time_t*, char*);'
12350	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SB ;;
12351	esac
12352	case "$ctime_r_proto" in
12353	''|0) try='int ctime_r(const time_t*, char*, int);'
12354	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SBI ;;
12355	esac
12356	case "$ctime_r_proto" in
12357	''|0)	d_ctime_r=undef
12358		ctime_r_proto=0
12359		echo "Disabling ctime_r, cannot determine prototype." >&4 ;;
12360	* )	case "$ctime_r_proto" in
12361		REENTRANT_PROTO*) ;;
12362		*) ctime_r_proto="REENTRANT_PROTO_$ctime_r_proto" ;;
12363		esac
12364		echo "Prototype: $try" ;;
12365	esac
12366	;;
12367	*)	case "$usethreads" in
12368		define) echo "ctime_r has no prototype, not using it." >&4 ;;
12369		esac
12370		d_ctime_r=undef
12371		ctime_r_proto=0
12372		;;
12373	esac
12374	;;
12375*)	ctime_r_proto=0
12376	;;
12377esac
12378
12379: see if cuserid exists
12380set cuserid d_cuserid
12381eval $inlibc
12382
12383: see if dbm.h is available
12384: see if dbmclose exists
12385set dbmclose d_dbmclose
12386eval $inlibc
12387
12388case "$d_dbmclose" in
12389$define)
12390	set dbm.h i_dbm
12391	eval $inhdr
12392	case "$i_dbm" in
12393	$define)
12394		val="$undef"
12395		set i_rpcsvcdbm
12396		eval $setvar
12397		;;
12398	*)	set rpcsvc/dbm.h i_rpcsvcdbm
12399		eval $inhdr
12400		;;
12401	esac
12402	;;
12403*)	echo "We won't be including <dbm.h>"
12404	val="$undef"
12405	set i_dbm
12406	eval $setvar
12407	val="$undef"
12408	set i_rpcsvcdbm
12409	eval $setvar
12410	;;
12411esac
12412
12413: see if prototype for dbminit is available
12414echo " "
12415set d_dbminitproto dbminit $i_dbm dbm.h
12416eval $hasproto
12417
12418: see if difftime exists
12419set difftime d_difftime
12420eval $inlibc
12421
12422: see if this is a dirent system
12423echo " "
12424if xinc=`./findhdr dirent.h`; $test "$xinc"; then
12425	val="$define"
12426	echo "<dirent.h> found." >&4
12427else
12428	val="$undef"
12429	if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
12430		echo "<sys/dir.h> found." >&4
12431		echo " "
12432	else
12433		xinc=`./findhdr sys/ndir.h`
12434	fi
12435	echo "<dirent.h> NOT found." >&4
12436fi
12437set i_dirent
12438eval $setvar
12439
12440: Look for type of directory structure.
12441echo " "
12442$cppstdin $cppflags $cppminus < "$xinc" > try.c
12443
12444case "$direntrytype" in
12445''|' ')
12446	case "$i_dirent" in
12447	$define) guess1='struct dirent' ;;
12448	*) guess1='struct direct'  ;;
12449	esac
12450	;;
12451*)	guess1="$direntrytype"
12452	;;
12453esac
12454
12455case "$guess1" in
12456'struct dirent') guess2='struct direct' ;;
12457*) guess2='struct dirent' ;;
12458esac
12459
12460if $contains "$guess1" try.c >/dev/null 2>&1; then
12461	direntrytype="$guess1"
12462	echo "Your directory entries are $direntrytype." >&4
12463elif $contains "$guess2" try.c >/dev/null 2>&1; then
12464	direntrytype="$guess2"
12465	echo "Your directory entries seem to be $direntrytype." >&4
12466else
12467	echo "I don't recognize your system's directory entries." >&4
12468	rp="What type is used for directory entries on this system?"
12469	dflt="$guess1"
12470	. ./myread
12471	direntrytype="$ans"
12472fi
12473$rm_try
12474
12475: see if the directory entry stores field length
12476echo " "
12477$cppstdin $cppflags $cppminus < "$xinc" > try.c
12478if $contains 'd_namlen' try.c >/dev/null 2>&1; then
12479	echo "Good, your directory entry keeps length information in d_namlen." >&4
12480	val="$define"
12481else
12482	echo "Your directory entry does not know about the d_namlen field." >&4
12483	val="$undef"
12484fi
12485set d_dirnamlen
12486eval $setvar
12487$rm_try
12488
12489: Look for DIR.dd_fd
12490case "$i_dirent" in
12491"$define")
12492    echo "Checking to see if DIR has a dd_fd member variable" >&4
12493    $cat >try.c <<EOCP
12494#$i_stdlib I_STDLIB
12495#ifdef I_STDLIB
12496#include <stdlib.h>
12497#endif
12498#include <dirent.h>
12499
12500int main() {
12501    DIR dir;
12502    dir.dd_fd = 1;
12503    return 0;
12504}
12505EOCP
12506    val=$undef
12507    set try
12508    if eval $compile; then
12509        echo "Yes, it does."
12510        val="$define"
12511    else
12512        echo "No, it does not."
12513        val="$undef"
12514    fi
12515    ;;
12516*)
12517    echo "You don't have a <dirent.h>, so not checking for dd_fd." >&4
12518    val="$undef"
12519    ;;
12520esac
12521set d_dir_dd_fd
12522eval $setvar
12523$rm_try
12524
12525: see if this is an sysdir system
12526set sys/dir.h i_sysdir
12527eval $inhdr
12528
12529: see if this is an sysndir system
12530set sys/ndir.h i_sysndir
12531eval $inhdr
12532
12533: Look for dirfd
12534echo " "
12535$cat >dirfd.c <<EOM
12536#include <stdio.h>
12537#$i_stdlib I_STDLIB
12538#ifdef I_STDLIB
12539#include <stdlib.h>
12540#endif
12541#$i_dirent I_DIRENT		/**/
12542#$i_sysdir I_SYS_DIR		/**/
12543#$i_sysndir I_SYS_NDIR		/**/
12544#$i_systypes I_SYS_TYPES	/**/
12545#if defined(I_SYS_TYPES)
12546#include <sys/types.h>
12547#endif
12548#if defined(I_DIRENT)
12549#include <dirent.h>
12550#else
12551#ifdef I_SYS_NDIR
12552#include <sys/ndir.h>
12553#else
12554#ifdef I_SYS_DIR
12555#include <sys/dir.h>
12556#endif
12557#endif
12558#endif
12559int main() {
12560	DIR *dirp = opendir(".");
12561	if (dirfd(dirp) >= 0)
12562		exit(0);
12563	else
12564		exit(1);
12565}
12566EOM
12567val=$undef
12568set dirfd
12569if eval $compile; then
12570	val="$define"
12571fi
12572case "$val" in
12573$define)	echo "dirfd() found." >&4	;;
12574*)		echo "dirfd() NOT found." >&4	;;
12575esac
12576set d_dirfd
12577eval $setvar
12578$rm -f dirfd*
12579
12580: see if dladdr exists
12581set dladdr d_dladdr
12582eval $inlibc
12583
12584: see if dlerror exists
12585xxx_runnm="$runnm"
12586runnm=false
12587set dlerror d_dlerror
12588eval $inlibc
12589runnm="$xxx_runnm"
12590
12591: see if dlfcn is available
12592set dlfcn.h i_dlfcn
12593eval $inhdr
12594
12595: Check what extension to use for shared libs
12596case "$usedl" in
12597$define|y|true)
12598	$cat << EOM
12599
12600On a few systems, the dynamically loaded modules that perl generates and uses
12601will need a different extension than shared libs. The default will probably
12602be appropriate.
12603
12604EOM
12605	case "$dlext" in
12606	'')	dflt="$so" ;;
12607	*)	dflt="$dlext" ;;
12608	esac
12609	rp='What is the extension of dynamically loaded modules'
12610	. ./myread
12611	dlext="$ans"
12612	;;
12613*)
12614	dlext="none"
12615	;;
12616esac
12617
12618: Check if dlsym need a leading underscore
12619echo " "
12620val="$undef"
12621
12622case "$dlsrc" in
12623dl_dlopen.xs)
12624	echo "Checking whether your dlsym() needs a leading underscore ..." >&4
12625	$cat >dyna.c <<'EOM'
12626void fred (void) { }
12627EOM
12628
12629$cat >fred.c<<EOM
12630
12631#include <stdio.h>
12632#$i_stdlib I_STDLIB
12633#ifdef I_STDLIB
12634#include <stdlib.h>
12635#endif
12636#$i_dlfcn I_DLFCN
12637#ifdef I_DLFCN
12638#include <dlfcn.h>      /* the dynamic linker include file for SunOS/Solaris */
12639#else
12640#include <sys/types.h>
12641#include <nlist.h>
12642#include <link.h>
12643#endif
12644
12645extern void fred(void) ;
12646
12647int main()
12648{
12649    void * handle ;
12650    void * symbol ;
12651#ifndef RTLD_LAZY
12652    int mode = 1 ;
12653#else
12654    int mode = RTLD_LAZY ;
12655#endif
12656    handle = dlopen("./dyna.$dlext", mode) ;
12657    if (handle == NULL) {
12658	printf ("1\n") ;
12659	fflush (stdout) ;
12660	exit(0);
12661    }
12662    symbol = dlsym(handle, "fred") ;
12663    if (symbol == NULL) {
12664	/* try putting a leading underscore */
12665	symbol = dlsym(handle, "_fred") ;
12666	if (symbol == NULL) {
12667	    printf ("2\n") ;
12668	    fflush (stdout) ;
12669	    exit(0);
12670	}
12671	printf ("3\n") ;
12672    }
12673    else
12674	printf ("4\n") ;
12675    fflush (stdout) ;
12676    exit(0);
12677}
12678EOM
12679	: Call the object file tmp-dyna.o in case dlext=o.
12680	if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 &&
12681		mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 &&
12682		$ld -o dyna.$dlext $ldflags $lddlflags tmp-dyna${_o} > /dev/null 2>&1 &&
12683		$cc -o fred $ccflags $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1 && $to dyna.$dlext; then
12684		xxx=`$run ./fred`
12685		case $xxx in
12686		1)	echo "Test program failed using dlopen." >&4
12687			echo "Perhaps you should not use dynamic loading." >&4;;
12688		2)	echo "Test program failed using dlsym." >&4
12689			echo "Perhaps you should not use dynamic loading." >&4;;
12690		3)	echo "dlsym needs a leading underscore" >&4
12691			val="$define" ;;
12692		4)	echo "dlsym doesn't need a leading underscore." >&4;;
12693		esac
12694	else
12695		echo "I can't compile and run the test program." >&4
12696                echo "I'm guessing that dlsym doesn't need a leading underscore." >&4
12697	fi
12698	;;
12699esac
12700
12701$rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.*
12702
12703set d_dlsymun
12704eval $setvar
12705
12706: see if drand48_r exists
12707set drand48_r d_drand48_r
12708eval $inlibc
12709case "$d_drand48_r" in
12710"$define")
12711	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
12712	case "$d_drand48_r_proto:$usethreads" in
12713	":define")	d_drand48_r_proto=define
12714		set d_drand48_r_proto drand48_r $hdrs
12715		eval $hasproto ;;
12716	*)	;;
12717	esac
12718	case "$d_drand48_r_proto" in
12719	define)
12720	case "$drand48_r_proto" in
12721	''|0) try='int drand48_r(struct drand48_data*, double*);'
12722	./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;;
12723	esac
12724	case "$drand48_r_proto" in
12725	''|0)	d_drand48_r=undef
12726		drand48_r_proto=0
12727		echo "Disabling drand48_r, cannot determine prototype." >&4 ;;
12728	* )	case "$drand48_r_proto" in
12729		REENTRANT_PROTO*) ;;
12730		*) drand48_r_proto="REENTRANT_PROTO_$drand48_r_proto" ;;
12731		esac
12732		echo "Prototype: $try" ;;
12733	esac
12734	;;
12735	*)	case "$usethreads" in
12736		define) echo "drand48_r has no prototype, not using it." >&4 ;;
12737		esac
12738		d_drand48_r=undef
12739		drand48_r_proto=0
12740		;;
12741	esac
12742	;;
12743*)	drand48_r_proto=0
12744	;;
12745esac
12746
12747: see if prototype for drand48 is available
12748echo " "
12749set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
12750eval $hasproto
12751
12752: see if dup2 exists
12753set dup2 d_dup2
12754eval $inlibc
12755
12756: see if dup3 exists
12757set dup3 d_dup3
12758eval $inlibc
12759
12760: see if localeconv_l exists
12761set localeconv_l d_localeconv_l
12762eval $inlibc
12763
12764: see if this is an xlocale.h system
12765set xlocale.h i_xlocale
12766eval $inhdr
12767
12768: see if newlocale exists
12769set newlocale d_newlocale
12770eval $inlibc
12771
12772: see if freelocale exists
12773set freelocale d_freelocale
12774eval $inlibc
12775
12776: see if uselocale exists
12777set uselocale d_uselocale
12778eval $inlibc
12779
12780: see if duplocale exists
12781set duplocale d_duplocale
12782eval $inlibc
12783
12784: see if querylocale exists
12785set querylocale d_querylocale
12786eval $inlibc
12787
12788: if we have xlocale.h, check whether it is needed
12789case "$i_xlocale$d_newlocale$xlocale_needed" in
12790"$define$define")
12791	echo "Checking if xlocale.h is needed..." >&4
12792	$cat >try.c <<EOF
12793#include <locale.h>
12794#include <stdio.h>
12795#ifdef TRY_XLOCALE
12796#include <xlocale.h>
12797#endif
12798#$d_localeconv_l HAVE_LOCALECONV_L
12799
12800#ifdef HAVE_LOCALECONV_L
12801struct lconv *(*lcptr)(locale_t) = localeconv_l;
12802#endif
12803
12804int main(void) {
12805  locale_t lc = newlocale(LC_ALL_MASK, "C", (locale_t)0);
12806
12807#ifdef HAVE_LOCALECONV_L
12808  /* FreeBSD hides only localeconv_l() in xlocale.h */
12809  struct lconv *lcbuf = localeconv_l(lc);
12810  printf("decimal: %s\n", lcbuf->decimal_point);
12811#endif
12812
12813  freelocale(lc);
12814  return 0;
12815}
12816EOF
12817	set try
12818	if eval $compile && $run ./try > /dev/null 2>&1 ; then
12819		echo "xlocale.h isn't needed" >&4
12820		xlocale_needed=$undef
12821	else
12822		set try -DTRY_XLOCALE
12823		if eval $compile && $run ./try > /dev/null 2>&1 ; then
12824			xlocale_needed=$define
12825			echo "xlocale.h is needed" >&4
12826		else
12827			echo "I can't build my test either way" >&4
12828			xlocale_needed=$undef
12829		fi
12830	fi
12831	$rm_try
12832	;;
12833*) xlocale_needed=$undef ;;
12834esac
12835
12836: see if eaccess exists
12837set eaccess d_eaccess
12838eval $inlibc
12839
12840: see if endgrent exists
12841set endgrent d_endgrent
12842eval $inlibc
12843
12844: see if this is an grp system
12845set grp.h i_grp
12846eval $inhdr
12847
12848case "$i_grp" in
12849$define)
12850	xxx=`./findhdr grp.h`
12851	$cppstdin $cppflags $cppminus < $xxx >$$.h
12852
12853	if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
12854		val="$define"
12855	else
12856		val="$undef"
12857	fi
12858	set d_grpasswd
12859	eval $setvar
12860
12861	$rm -f $$.h
12862	;;
12863*)
12864	val="$undef";
12865	set d_grpasswd; eval $setvar
12866	;;
12867esac
12868
12869: see if endgrent_r exists
12870set endgrent_r d_endgrent_r
12871eval $inlibc
12872case "$d_endgrent_r" in
12873"$define")
12874	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
12875	case "$d_endgrent_r_proto:$usethreads" in
12876	":define")	d_endgrent_r_proto=define
12877		set d_endgrent_r_proto endgrent_r $hdrs
12878		eval $hasproto ;;
12879	*)	;;
12880	esac
12881	case "$d_endgrent_r_proto" in
12882	define)
12883	case "$endgrent_r_proto" in
12884	''|0) try='int endgrent_r(FILE**);'
12885	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=I_H ;;
12886	esac
12887	case "$endgrent_r_proto" in
12888	''|0) try='void endgrent_r(FILE**);'
12889	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=V_H ;;
12890	esac
12891	case "$endgrent_r_proto" in
12892	''|0)	d_endgrent_r=undef
12893		endgrent_r_proto=0
12894		echo "Disabling endgrent_r, cannot determine prototype." >&4 ;;
12895	* )	case "$endgrent_r_proto" in
12896		REENTRANT_PROTO*) ;;
12897		*) endgrent_r_proto="REENTRANT_PROTO_$endgrent_r_proto" ;;
12898		esac
12899		echo "Prototype: $try" ;;
12900	esac
12901	;;
12902	*)	case "$usethreads" in
12903		define) echo "endgrent_r has no prototype, not using it." >&4 ;;
12904		esac
12905		d_endgrent_r=undef
12906		endgrent_r_proto=0
12907		;;
12908	esac
12909	;;
12910*)	endgrent_r_proto=0
12911	;;
12912esac
12913
12914: see if endhostent exists
12915set endhostent d_endhent
12916eval $inlibc
12917
12918: see if this is a netdb.h system
12919set netdb.h i_netdb
12920eval $inhdr
12921
12922: see if endhostent_r exists
12923set endhostent_r d_endhostent_r
12924eval $inlibc
12925case "$d_endhostent_r" in
12926"$define")
12927	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12928	case "$d_endhostent_r_proto:$usethreads" in
12929	":define")	d_endhostent_r_proto=define
12930		set d_endhostent_r_proto endhostent_r $hdrs
12931		eval $hasproto ;;
12932	*)	;;
12933	esac
12934	case "$d_endhostent_r_proto" in
12935	define)
12936	case "$endhostent_r_proto" in
12937	''|0) try='int endhostent_r(struct hostent_data*);'
12938	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=I_D ;;
12939	esac
12940	case "$endhostent_r_proto" in
12941	''|0) try='void endhostent_r(struct hostent_data*);'
12942	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=V_D ;;
12943	esac
12944	case "$endhostent_r_proto" in
12945	''|0)	d_endhostent_r=undef
12946		endhostent_r_proto=0
12947		echo "Disabling endhostent_r, cannot determine prototype." >&4 ;;
12948	* )	case "$endhostent_r_proto" in
12949		REENTRANT_PROTO*) ;;
12950		*) endhostent_r_proto="REENTRANT_PROTO_$endhostent_r_proto" ;;
12951		esac
12952		echo "Prototype: $try" ;;
12953	esac
12954	;;
12955	*)	case "$usethreads" in
12956		define) echo "endhostent_r has no prototype, not using it." >&4 ;;
12957		esac
12958		d_endhostent_r=undef
12959		endhostent_r_proto=0
12960		;;
12961	esac
12962	;;
12963*)	endhostent_r_proto=0
12964	;;
12965esac
12966
12967: see if endnetent exists
12968set endnetent d_endnent
12969eval $inlibc
12970
12971: see if endnetent_r exists
12972set endnetent_r d_endnetent_r
12973eval $inlibc
12974case "$d_endnetent_r" in
12975"$define")
12976	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12977	case "$d_endnetent_r_proto:$usethreads" in
12978	":define")	d_endnetent_r_proto=define
12979		set d_endnetent_r_proto endnetent_r $hdrs
12980		eval $hasproto ;;
12981	*)	;;
12982	esac
12983	case "$d_endnetent_r_proto" in
12984	define)
12985	case "$endnetent_r_proto" in
12986	''|0) try='int endnetent_r(struct netent_data*);'
12987	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=I_D ;;
12988	esac
12989	case "$endnetent_r_proto" in
12990	''|0) try='void endnetent_r(struct netent_data*);'
12991	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=V_D ;;
12992	esac
12993	case "$endnetent_r_proto" in
12994	''|0)	d_endnetent_r=undef
12995		endnetent_r_proto=0
12996		echo "Disabling endnetent_r, cannot determine prototype." >&4 ;;
12997	* )	case "$endnetent_r_proto" in
12998		REENTRANT_PROTO*) ;;
12999		*) endnetent_r_proto="REENTRANT_PROTO_$endnetent_r_proto" ;;
13000		esac
13001		echo "Prototype: $try" ;;
13002	esac
13003	;;
13004	*)	case "$usethreads" in
13005		define) echo "endnetent_r has no prototype, not using it." >&4 ;;
13006		esac
13007		d_endnetent_r=undef
13008		endnetent_r_proto=0
13009		;;
13010	esac
13011	;;
13012*)	endnetent_r_proto=0
13013	;;
13014esac
13015
13016: see if endprotoent exists
13017set endprotoent d_endpent
13018eval $inlibc
13019
13020: see if endprotoent_r exists
13021set endprotoent_r d_endprotoent_r
13022eval $inlibc
13023case "$d_endprotoent_r" in
13024"$define")
13025	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
13026	case "$d_endprotoent_r_proto:$usethreads" in
13027	":define")	d_endprotoent_r_proto=define
13028		set d_endprotoent_r_proto endprotoent_r $hdrs
13029		eval $hasproto ;;
13030	*)	;;
13031	esac
13032	case "$d_endprotoent_r_proto" in
13033	define)
13034	case "$endprotoent_r_proto" in
13035	''|0) try='int endprotoent_r(struct protoent_data*);'
13036	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=I_D ;;
13037	esac
13038	case "$endprotoent_r_proto" in
13039	''|0) try='void endprotoent_r(struct protoent_data*);'
13040	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=V_D ;;
13041	esac
13042	case "$endprotoent_r_proto" in
13043	''|0)	d_endprotoent_r=undef
13044		endprotoent_r_proto=0
13045		echo "Disabling endprotoent_r, cannot determine prototype." >&4 ;;
13046	* )	case "$endprotoent_r_proto" in
13047		REENTRANT_PROTO*) ;;
13048		*) endprotoent_r_proto="REENTRANT_PROTO_$endprotoent_r_proto" ;;
13049		esac
13050		echo "Prototype: $try" ;;
13051	esac
13052	;;
13053	*)	case "$usethreads" in
13054		define) echo "endprotoent_r has no prototype, not using it." >&4 ;;
13055		esac
13056		d_endprotoent_r=undef
13057		endprotoent_r_proto=0
13058		;;
13059	esac
13060	;;
13061*)	endprotoent_r_proto=0
13062	;;
13063esac
13064
13065: see if endpwent exists
13066set endpwent d_endpwent
13067eval $inlibc
13068
13069: see if this is a pwd.h system
13070set pwd.h i_pwd
13071eval $inhdr
13072
13073case "$i_pwd" in
13074$define)
13075	xxx=`./findhdr pwd.h`
13076	$cppstdin $cppflags $cppminus < $xxx >$$.h
13077
13078	if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
13079		val="$define"
13080	else
13081		val="$undef"
13082	fi
13083	set d_pwquota
13084	eval $setvar
13085
13086	if $contains 'pw_age' $$.h >/dev/null 2>&1; then
13087		val="$define"
13088	else
13089		val="$undef"
13090	fi
13091	set d_pwage
13092	eval $setvar
13093
13094	if $contains 'pw_change' $$.h >/dev/null 2>&1; then
13095		val="$define"
13096	else
13097		val="$undef"
13098	fi
13099	set d_pwchange
13100	eval $setvar
13101
13102	if $contains 'pw_class' $$.h >/dev/null 2>&1; then
13103		val="$define"
13104	else
13105		val="$undef"
13106	fi
13107	set d_pwclass
13108	eval $setvar
13109
13110	if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
13111		val="$define"
13112	else
13113		val="$undef"
13114	fi
13115	set d_pwexpire
13116	eval $setvar
13117
13118	if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
13119		val="$define"
13120	else
13121		val="$undef"
13122	fi
13123	set d_pwcomment
13124	eval $setvar
13125
13126	if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
13127		val="$define"
13128	else
13129		val="$undef"
13130	fi
13131	set d_pwgecos
13132	eval $setvar
13133
13134	if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
13135		val="$define"
13136	else
13137		val="$undef"
13138	fi
13139	set d_pwpasswd
13140	eval $setvar
13141
13142	$rm -f $$.h
13143	;;
13144*)
13145	val="$undef";
13146	set d_pwquota; eval $setvar
13147	set d_pwage; eval $setvar
13148	set d_pwchange; eval $setvar
13149	set d_pwclass; eval $setvar
13150	set d_pwexpire; eval $setvar
13151	set d_pwcomment; eval $setvar
13152	set d_pwgecos; eval $setvar
13153	set d_pwpasswd; eval $setvar
13154	;;
13155esac
13156
13157: see if endpwent_r exists
13158set endpwent_r d_endpwent_r
13159eval $inlibc
13160case "$d_endpwent_r" in
13161"$define")
13162	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
13163	case "$d_endpwent_r_proto:$usethreads" in
13164	":define")	d_endpwent_r_proto=define
13165		set d_endpwent_r_proto endpwent_r $hdrs
13166		eval $hasproto ;;
13167	*)	;;
13168	esac
13169	case "$d_endpwent_r_proto" in
13170	define)
13171	case "$endpwent_r_proto" in
13172	''|0) try='int endpwent_r(FILE**);'
13173	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=I_H ;;
13174	esac
13175	case "$endpwent_r_proto" in
13176	''|0) try='void endpwent_r(FILE**);'
13177	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=V_H ;;
13178	esac
13179	case "$endpwent_r_proto" in
13180	''|0)	d_endpwent_r=undef
13181		endpwent_r_proto=0
13182		echo "Disabling endpwent_r, cannot determine prototype." >&4 ;;
13183	* )	case "$endpwent_r_proto" in
13184		REENTRANT_PROTO*) ;;
13185		*) endpwent_r_proto="REENTRANT_PROTO_$endpwent_r_proto" ;;
13186		esac
13187		echo "Prototype: $try" ;;
13188	esac
13189	;;
13190	*)	case "$usethreads" in
13191		define) echo "endpwent_r has no prototype, not using it." >&4 ;;
13192		esac
13193		d_endpwent_r=undef
13194		endpwent_r_proto=0
13195		;;
13196	esac
13197	;;
13198*)	endpwent_r_proto=0
13199	;;
13200esac
13201
13202: see if endservent exists
13203set endservent d_endsent
13204eval $inlibc
13205
13206: see if endservent_r exists
13207set endservent_r d_endservent_r
13208eval $inlibc
13209case "$d_endservent_r" in
13210"$define")
13211	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
13212	case "$d_endservent_r_proto:$usethreads" in
13213	":define")	d_endservent_r_proto=define
13214		set d_endservent_r_proto endservent_r $hdrs
13215		eval $hasproto ;;
13216	*)	;;
13217	esac
13218	case "$d_endservent_r_proto" in
13219	define)
13220	case "$endservent_r_proto" in
13221	''|0) try='int endservent_r(struct servent_data*);'
13222	./protochk "$extern_C $try" $hdrs && endservent_r_proto=I_D ;;
13223	esac
13224	case "$endservent_r_proto" in
13225	''|0) try='void endservent_r(struct servent_data*);'
13226	./protochk "$extern_C $try" $hdrs && endservent_r_proto=V_D ;;
13227	esac
13228	case "$endservent_r_proto" in
13229	''|0)	d_endservent_r=undef
13230		endservent_r_proto=0
13231		echo "Disabling endservent_r, cannot determine prototype." >&4 ;;
13232	* )	case "$endservent_r_proto" in
13233		REENTRANT_PROTO*) ;;
13234		*) endservent_r_proto="REENTRANT_PROTO_$endservent_r_proto" ;;
13235		esac
13236		echo "Prototype: $try" ;;
13237	esac
13238	;;
13239	*)	case "$usethreads" in
13240		define) echo "endservent_r has no prototype, not using it." >&4 ;;
13241		esac
13242		d_endservent_r=undef
13243		endservent_r_proto=0
13244		;;
13245	esac
13246	;;
13247*)	endservent_r_proto=0
13248	;;
13249esac
13250
13251: Locate the flags for 'open()'
13252echo " "
13253$cat >try.c <<EOCP
13254#include <sys/types.h>
13255#ifdef I_FCNTL
13256#include <fcntl.h>
13257#endif
13258#ifdef I_SYS_FILE
13259#include <sys/file.h>
13260#endif
13261#$i_stdlib I_STDLIB
13262#ifdef I_STDLIB
13263#include <stdlib.h>
13264#endif
13265int main() {
13266	if(O_RDONLY);
13267#ifdef O_TRUNC
13268	exit(0);
13269#else
13270	exit(1);
13271#endif
13272}
13273EOCP
13274: check sys/file.h first to get FREAD on Sun
13275if $test `./findhdr sys/file.h` && \
13276		set try -DI_SYS_FILE && eval $compile; then
13277	h_sysfile=true;
13278	echo "<sys/file.h> defines the O_* constants..." >&4
13279	if $run ./try; then
13280		echo "and you have the 3 argument form of open()." >&4
13281		val="$define"
13282	else
13283		echo "but not the 3 argument form of open().  Oh, well." >&4
13284		val="$undef"
13285	fi
13286elif $test `./findhdr fcntl.h` && \
13287		set try -DI_FCNTL && eval $compile; then
13288	h_fcntl=true;
13289	echo "<fcntl.h> defines the O_* constants..." >&4
13290	if $run ./try; then
13291		echo "and you have the 3 argument form of open()." >&4
13292		val="$define"
13293	else
13294		echo "but not the 3 argument form of open().  Oh, well." >&4
13295		val="$undef"
13296	fi
13297else
13298	val="$undef"
13299	echo "I can't find the O_* constant definitions!  You got problems." >&4
13300fi
13301set d_open3
13302eval $setvar
13303$rm_try
13304
13305: see if this is a sys/file.h system
13306val=''
13307set sys/file.h val
13308eval $inhdr
13309
13310: do we need to include sys/file.h ?
13311case "$val" in
13312"$define")
13313	echo " "
13314	if $h_sysfile; then
13315		val="$define"
13316		echo "We'll be including <sys/file.h>." >&4
13317	else
13318		val="$undef"
13319		echo "We won't be including <sys/file.h>." >&4
13320	fi
13321	;;
13322*)
13323	h_sysfile=false
13324	;;
13325esac
13326set i_sysfile
13327eval $setvar
13328
13329: see if fcntl.h is there
13330val=''
13331set fcntl.h val
13332eval $inhdr
13333
13334: see if we can include fcntl.h
13335case "$val" in
13336"$define")
13337	echo " "
13338	if $h_fcntl; then
13339		val="$define"
13340		echo "We'll be including <fcntl.h>." >&4
13341	else
13342		val="$undef"
13343		if $h_sysfile; then
13344	echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
13345		else
13346			echo "We won't be including <fcntl.h>." >&4
13347		fi
13348	fi
13349	;;
13350*)
13351	h_fcntl=false
13352	val="$undef"
13353	;;
13354esac
13355set i_fcntl
13356eval $setvar
13357
13358: see if fork exists
13359set fork d_fork
13360eval $inlibc
13361
13362: see if pipe exists
13363set pipe d_pipe
13364eval $inlibc
13365
13366: check for non-blocking I/O stuff
13367case "$h_sysfile" in
13368true) echo "#include <sys/file.h>" > head.c;;
13369*)
13370       case "$h_fcntl" in
13371       true) echo "#include <fcntl.h>" > head.c;;
13372       *) echo "#include <sys/fcntl.h>" > head.c;;
13373       esac
13374       ;;
13375esac
13376echo " "
13377echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
13378case "$o_nonblock" in
13379'')
13380	$cat head.c > try.c
13381	$cat >>try.c <<EOCP
13382#include <stdio.h>
13383#$i_stdlib I_STDLIB
13384#ifdef I_STDLIB
13385#include <stdlib.h>
13386#endif
13387#$i_fcntl I_FCNTL
13388#ifdef I_FCNTL
13389#include <fcntl.h>
13390#endif
13391int main() {
13392#ifdef O_NONBLOCK
13393	printf("O_NONBLOCK\n");
13394	exit(0);
13395#endif
13396#ifdef O_NDELAY
13397	printf("O_NDELAY\n");
13398	exit(0);
13399#endif
13400#ifdef FNDELAY
13401	printf("FNDELAY\n");
13402	exit(0);
13403#endif
13404	exit(0);
13405}
13406EOCP
13407	set try
13408	if eval $compile_ok; then
13409		o_nonblock=`$run ./try`
13410		case "$o_nonblock" in
13411		'') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
13412		*) echo "Seems like we can use $o_nonblock.";;
13413		esac
13414	else
13415		echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
13416	fi
13417	;;
13418*) echo "Using $hint value $o_nonblock.";;
13419esac
13420$rm_try
13421
13422echo " "
13423echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
13424case "$eagain" in
13425'')
13426	case "$d_fork:$d_pipe:$d_alarm" in
13427	define:define:define)
13428	$cat head.c > try.c
13429	$cat >>try.c <<EOCP
13430#include <errno.h>
13431#include <sys/types.h>
13432#include <signal.h>
13433#include <stdio.h>
13434#$i_stdlib I_STDLIB
13435#ifdef I_STDLIB
13436#include <stdlib.h>
13437#endif
13438#$i_fcntl I_FCNTL
13439#ifdef I_FCNTL
13440#include <fcntl.h>
13441#endif
13442#define MY_O_NONBLOCK $o_nonblock
13443#ifndef errno  /* XXX need better Configure test */
13444extern int errno;
13445#endif
13446#$i_unistd I_UNISTD
13447#ifdef I_UNISTD
13448#include <unistd.h>
13449#endif
13450#include <string.h>
13451$signal_t blech(int x) { exit(3); }
13452EOCP
13453	$cat >> try.c <<'EOCP'
13454int main()
13455{
13456	int pd[2];
13457	int pu[2];
13458	char buf[1];
13459	char string[100];
13460	int ret;
13461
13462	ret = pipe(pd);	/* Down: child -> parent */
13463	if (ret != 0)
13464		exit(3);
13465	ret = pipe(pu);	/* Up: parent -> child */
13466	if (ret != 0)
13467		exit(3);
13468	if (0 != fork()) {
13469		close(pd[1]);	/* Parent reads from pd[0] */
13470		close(pu[0]);	/* Parent writes (blocking) to pu[1] */
13471#ifdef F_SETFL
13472		if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
13473			exit(1);
13474#else
13475		exit(4);
13476#endif
13477		signal(SIGALRM, blech);
13478		alarm(5);
13479		if ((ret = read(pd[0], buf, 1)) > 0)	/* Nothing to read! */
13480			exit(2);
13481		sprintf(string, "%d\n", ret);
13482		ret = write(2, string, strlen(string));
13483		if (ret != strlen(string))
13484			exit(3);
13485		alarm(0);
13486#ifdef EAGAIN
13487		if (errno == EAGAIN) {
13488			printf("EAGAIN\n");
13489			goto ok;
13490		}
13491#endif
13492#ifdef EWOULDBLOCK
13493		if (errno == EWOULDBLOCK)
13494			printf("EWOULDBLOCK\n");
13495#endif
13496	ok:
13497		ret = write(pu[1], buf, 1);	/* Unblocks child, tell it to close our pipe */
13498		if (ret != 1)
13499			exit(3);
13500		sleep(2);				/* Give it time to close our pipe */
13501		alarm(5);
13502		ret = read(pd[0], buf, 1);	/* Should read EOF */
13503		alarm(0);
13504		sprintf(string, "%d\n", ret);
13505		ret = write(4, string, strlen(string));
13506		if (ret != strlen(string))
13507			exit(3);
13508		exit(0);
13509	}
13510
13511	close(pd[0]);			/* We write to pd[1] */
13512	close(pu[1]);			/* We read from pu[0] */
13513	ret = read(pu[0], buf, 1);	/* Wait for parent to signal us we may continue */
13514	if (ret != 1)
13515		exit(3);
13516	close(pd[1]);			/* Pipe pd is now fully closed! */
13517	exit(0);				/* Bye bye, thank you for playing! */
13518}
13519EOCP
13520	set try
13521	if eval $compile_ok; then
13522		echo "$startsh" >mtry
13523		echo "$run ./try >try.out 2>try.ret 4>try.err || exit 4" >>mtry
13524		chmod +x mtry
13525		$run ./mtry >/dev/null 2>&1
13526		case $? in
13527		0) eagain=`$cat try.out`;;
13528		1) echo "Could not perform non-blocking setting!";;
13529		2) echo "I did a successful read() for something that was not there!";;
13530		3) echo "Hmm... non-blocking I/O does not seem to be working!";;
13531		4) echo "Could not find F_SETFL!";;
13532		*) echo "Something terribly wrong happened during testing.";;
13533		esac
13534		rd_nodata=`$cat try.ret`
13535		echo "A read() system call with no data present returns $rd_nodata."
13536		case "$rd_nodata" in
13537		0|-1) ;;
13538		*)
13539			echo "(That's peculiar, fixing that to be -1.)"
13540			rd_nodata=-1
13541			;;
13542		esac
13543		case "$eagain" in
13544		'')
13545			echo "Forcing errno EAGAIN on read() with no data available."
13546			eagain=EAGAIN
13547			;;
13548		*)
13549			echo "Your read() sets errno to $eagain when no data is available."
13550			;;
13551		esac
13552		status=`$cat try.err`
13553		case "$status" in
13554		0) echo "And it correctly returns 0 to signal EOF.";;
13555		-1) echo "But it also returns -1 to signal EOF, so be careful!";;
13556		*) echo "However, your read() returns '$status' on EOF??";;
13557		esac
13558		val="$define"
13559		if test "$status" = "$rd_nodata"; then
13560			echo "WARNING: you can't distinguish between EOF and no data!"
13561			val="$undef"
13562		fi
13563	else
13564		echo "I can't compile the test program--assuming errno EAGAIN will do."
13565		eagain=EAGAIN
13566	fi
13567	;;
13568	*)	echo "Can't figure out how to test this--assuming errno EAGAIN will do."
13569		eagain=EAGAIN
13570		val="$define"
13571		;;
13572	esac
13573	set d_eofnblk
13574	eval $setvar
13575	;;
13576*)
13577	echo "Using $hint value $eagain."
13578	echo "Your read() returns $rd_nodata when no data is present."
13579	case "$d_eofnblk" in
13580	"$define") echo "And you can see EOF because read() returns 0.";;
13581	"$undef") echo "But you can't see EOF status from read() returned value.";;
13582	*)
13583		echo "(Assuming you can't see EOF status from read anyway.)"
13584		d_eofnblk=$undef
13585		;;
13586	esac
13587	;;
13588esac
13589$rm_try head.c mtry
13590
13591: see if erf exists
13592set erf d_erf
13593eval $inlibc
13594
13595: see if erfc exists
13596set erfc d_erfc
13597eval $inlibc
13598
13599: see if exp2 exists
13600set exp2 d_exp2
13601eval $inlibc
13602
13603: see if expm1 exists
13604set expm1 d_expm1
13605eval $inlibc
13606
13607: see if _ptr and _cnt from stdio act std
13608echo " "
13609
13610if $contains '_lbfsize' `./findhdr stdio.h` >/dev/null 2>&1 ; then
13611	echo "(Looks like you have stdio.h from BSD.)"
13612	case "$stdio_ptr" in
13613	'') stdio_ptr='((fp)->_p)'
13614		ptr_lval=$define
13615		;;
13616	*)	ptr_lval=$d_stdio_ptr_lval;;
13617	esac
13618	case "$stdio_cnt" in
13619	'') stdio_cnt='((fp)->_r)'
13620		cnt_lval=$define
13621		;;
13622	*)	cnt_lval=$d_stdio_cnt_lval;;
13623	esac
13624	case "$stdio_base" in
13625	'') stdio_base='((fp)->_ub._base ? (fp)->_ub._base : (fp)->_bf._base)';;
13626	esac
13627	case "$stdio_bufsiz" in
13628	'') stdio_bufsiz='((fp)->_ub._base ? (fp)->_ub._size : (fp)->_bf._size)';;
13629	esac
13630elif $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
13631	echo "(Looks like you have stdio.h from Linux.)"
13632	case "$stdio_ptr" in
13633	'') stdio_ptr='((fp)->_IO_read_ptr)'
13634		ptr_lval=$define
13635		;;
13636	*)	ptr_lval=$d_stdio_ptr_lval;;
13637	esac
13638	case "$stdio_cnt" in
13639	'') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
13640		cnt_lval=$undef
13641		;;
13642	*)	cnt_lval=$d_stdio_cnt_lval;;
13643	esac
13644	case "$stdio_base" in
13645	'') stdio_base='((fp)->_IO_read_base)';;
13646	esac
13647	case "$stdio_bufsiz" in
13648	'') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
13649	esac
13650else
13651	case "$stdio_ptr" in
13652	'') stdio_ptr='((fp)->_ptr)'
13653		ptr_lval=$define
13654		;;
13655	*)	ptr_lval=$d_stdio_ptr_lval;;
13656	esac
13657	case "$stdio_cnt" in
13658	'') stdio_cnt='((fp)->_cnt)'
13659		cnt_lval=$define
13660		;;
13661	*)	cnt_lval=$d_stdio_cnt_lval;;
13662	esac
13663	case "$stdio_base" in
13664	'') stdio_base='((fp)->_base)';;
13665	esac
13666	case "$stdio_bufsiz" in
13667	'') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
13668	esac
13669fi
13670
13671: test whether _ptr and _cnt really work
13672echo "Checking how std your stdio is..." >&4
13673$cat >try.c <<EOP
13674#include <stdio.h>
13675#$i_stdlib I_STDLIB
13676#ifdef I_STDLIB
13677#include <stdlib.h>
13678#endif
13679#include <string.h>
13680#define FILE_ptr(fp)	$stdio_ptr
13681#define FILE_cnt(fp)	$stdio_cnt
13682int main() {
13683	FILE *fp = fopen("try.c", "r");
13684	char c = getc(fp);
13685	if (
13686		18 <= FILE_cnt(fp) &&
13687		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
13688	)
13689		exit(0);
13690	exit(1);
13691}
13692EOP
13693val="$undef"
13694set try
13695if eval $compile && $to try.c; then
13696	if $run ./try; then
13697		echo "Your stdio acts pretty std."
13698		val="$define"
13699	else
13700		echo "Your stdio isn't very std."
13701	fi
13702else
13703	echo "Your stdio doesn't appear very std."
13704fi
13705$rm_try
13706
13707# glibc 2.2.90 and above apparently change stdio streams so Perl's
13708# direct buffer manipulation no longer works.  The Configure tests
13709# should be changed to correctly detect this, but until then,
13710# the following check should at least let perl compile and run.
13711# (This quick fix should be updated before 5.8.1.)
13712# To be defensive, reject all unknown versions, and all versions  > 2.2.9.
13713# A. Dougherty, June 3, 2002.
13714case "$d_gnulibc" in
13715$define)
13716	case "$gnulibc_version" in
13717	2.[01]*)  ;;
13718	2.2) ;;
13719	2.2.[0-9]) ;;
13720	*)  echo "But I will not snoop inside glibc $gnulibc_version stdio buffers."
13721		val="$undef"
13722		;;
13723	esac
13724	;;
13725esac
13726set d_stdstdio
13727eval $setvar
13728
13729: Can _ptr be used as an lvalue?
13730case "$d_stdstdio$ptr_lval" in
13731$define$define) val=$define ;;
13732*) val=$undef ;;
13733esac
13734set d_stdio_ptr_lval
13735eval $setvar
13736
13737: Can _cnt be used as an lvalue?
13738case "$d_stdstdio$cnt_lval" in
13739$define$define) val=$define ;;
13740*) val=$undef ;;
13741esac
13742set d_stdio_cnt_lval
13743eval $setvar
13744
13745
13746: test whether setting _ptr sets _cnt as a side effect
13747d_stdio_ptr_lval_sets_cnt="$undef"
13748d_stdio_ptr_lval_nochange_cnt="$undef"
13749case "$d_stdio_ptr_lval$d_stdstdio" in
13750$define$define)
13751	echo "Checking to see what happens if we set the stdio ptr..." >&4
13752$cat >try.c <<EOP
13753#include <stdio.h>
13754/* Can we scream? */
13755/* Eat dust sed :-) */
13756/* In the buffer space, no one can hear you scream. */
13757#$i_stdlib I_STDLIB
13758#ifdef I_STDLIB
13759#include <stdlib.h>
13760#endif
13761#define FILE_ptr(fp)	$stdio_ptr
13762#define FILE_cnt(fp)	$stdio_cnt
13763#include <sys/types.h>
13764int main() {
13765	FILE *fp = fopen("try.c", "r");
13766	int c;
13767	char *ptr;
13768	size_t cnt;
13769	if (!fp) {
13770	    puts("Fail even to read");
13771	    exit(1);
13772	}
13773	c = getc(fp); /* Read away the first # */
13774	if (c == EOF) {
13775	    puts("Fail even to read");
13776	    exit(1);
13777	}
13778	if (!(
13779		18 <= FILE_cnt(fp) &&
13780		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
13781	)) {
13782		puts("Fail even to read");
13783		exit (1);
13784	}
13785	ptr = (char*) FILE_ptr(fp);
13786	cnt = (size_t)FILE_cnt(fp);
13787
13788	FILE_ptr(fp) += 42;
13789
13790	if ((char*)FILE_ptr(fp) != (ptr + 42)) {
13791		printf("Fail ptr check %p != %p", FILE_ptr(fp), (ptr + 42));
13792		exit (1);
13793	}
13794	if (FILE_cnt(fp) <= 20) {
13795		printf ("Fail (<20 chars to test)");
13796		exit (1);
13797	}
13798	if (strncmp(FILE_ptr(fp), "Eat dust sed :-) */\n", 20) != 0) {
13799		puts("Fail compare");
13800		exit (1);
13801	}
13802	if (cnt == FILE_cnt(fp)) {
13803		puts("Pass_unchanged");
13804		exit (0);
13805	}
13806	if (FILE_cnt(fp) == (cnt - 42)) {
13807		puts("Pass_changed");
13808		exit (0);
13809	}
13810	printf("Fail count was %d now %d\n", cnt, FILE_cnt(fp));
13811	return 1;
13812
13813}
13814EOP
13815	set try
13816	if eval $compile && $to try.c; then
13817		case `$run ./try` in
13818		Pass_changed)
13819			echo "Increasing ptr in your stdio decreases cnt by the same amount.  Good." >&4
13820			d_stdio_ptr_lval_sets_cnt="$define" ;;
13821		Pass_unchanged)
13822			echo "Increasing ptr in your stdio leaves cnt unchanged.  Good." >&4
13823			d_stdio_ptr_lval_nochange_cnt="$define" ;;
13824		Fail*)
13825			echo "Increasing ptr in your stdio didn't do exactly what I expected.  We'll not be doing that then." >&4 ;;
13826		*)
13827			echo "It appears attempting to set ptr in your stdio is a bad plan." >&4 ;;
13828	esac
13829	else
13830		echo "It seems we can't set ptr in your stdio.  Nevermind." >&4
13831	fi
13832	$rm_try
13833	;;
13834esac
13835
13836: see if _base is also standard
13837val="$undef"
13838case "$d_stdstdio" in
13839$define)
13840	$cat >try.c <<EOP
13841#include <stdio.h>
13842#$i_stdlib I_STDLIB
13843#ifdef I_STDLIB
13844#include <stdlib.h>
13845#endif
13846#define FILE_base(fp)	$stdio_base
13847#define FILE_bufsiz(fp)	$stdio_bufsiz
13848int main() {
13849	FILE *fp = fopen("try.c", "r");
13850	char c = getc(fp);
13851	if (
13852		19 <= FILE_bufsiz(fp) &&
13853		strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
13854	)
13855		exit(0);
13856	exit(1);
13857}
13858EOP
13859	set try
13860	if eval $compile && $to try.c; then
13861		if $run ./try; then
13862			echo "And its _base field acts std."
13863			val="$define"
13864		else
13865			echo "But its _base field isn't std."
13866		fi
13867	else
13868		echo "However, it seems to be lacking the _base field."
13869	fi
13870	$rm_try
13871	;;
13872esac
13873set d_stdiobase
13874eval $setvar
13875
13876: see if fast_stdio exists
13877val="$undef"
13878case "$d_stdstdio:$d_stdio_ptr_lval" in
13879"$define:$define")
13880	case "$d_stdio_cnt_lval$d_stdio_ptr_lval_sets_cnt" in
13881	*$define*)
13882		echo "You seem to have 'fast stdio' to directly manipulate the stdio buffers." >&4
13883		val="$define"
13884		;;
13885	esac
13886	;;
13887esac
13888set d_faststdio
13889eval $setvar
13890
13891: see if fchdir exists
13892set fchdir d_fchdir
13893eval $inlibc
13894
13895: see if fchmod exists
13896set fchmod d_fchmod
13897eval $inlibc
13898
13899: check for openat, unlinkat, renameat, linkat, fchmodat
13900set openat d_openat
13901eval $inlibc
13902
13903set unlinkat d_unlinkat
13904eval $inlibc
13905
13906set renameat d_renameat
13907eval $inlibc
13908
13909set linkat d_linkat
13910eval $inlibc
13911
13912set fchmodat d_fchmodat
13913eval $inlibc
13914
13915: see if fchown exists
13916set fchown d_fchown
13917eval $inlibc
13918
13919: see if this is an fcntl system
13920set fcntl d_fcntl
13921eval $inlibc
13922
13923: See if fcntl-based locking works.
13924echo " "
13925$cat >try.c <<EOCP
13926#$i_stdlib I_STDLIB
13927#ifdef I_STDLIB
13928#include <stdlib.h>
13929#endif
13930#include <unistd.h>
13931#include <fcntl.h>
13932#include <signal.h>
13933$signal_t blech(int x) { exit(3); }
13934int main() {
13935#if defined(F_SETLK) && defined(F_SETLKW)
13936     struct flock flock;
13937     int retval, fd;
13938     fd = open("try.c", O_RDONLY);
13939     flock.l_type = F_RDLCK;
13940     flock.l_whence = SEEK_SET;
13941     flock.l_start = flock.l_len = 0;
13942     signal(SIGALRM, blech);
13943     alarm(10);
13944     retval = fcntl(fd, F_SETLK, &flock);
13945     close(fd);
13946     (retval < 0 ? exit(2) : exit(0));
13947#else
13948     exit(2);
13949#endif
13950}
13951EOCP
13952echo "Checking if fcntl-based file locking works... "
13953case "$d_fcntl" in
13954"$define")
13955	set try
13956	if eval $compile_ok; then
13957		if $run ./try; then
13958			echo "Yes, it seems to work."
13959			val="$define"
13960		else
13961			echo "Nope, it didn't work."
13962			val="$undef"
13963			case "$?" in
13964			3) $cat >&4 <<EOM
13965***
13966*** I had to forcibly timeout from fcntl(..., F_SETLK, ...).
13967*** This is (almost) impossible.
13968*** If your NFS lock daemons are not feeling well, something like
13969*** this may happen, please investigate.  Cannot continue, aborting.
13970***
13971EOM
13972				exit 1
13973				;;
13974			esac
13975		fi
13976	else
13977		echo "I'm unable to compile the test program, so I'll assume not."
13978		val="$undef"
13979	fi
13980	;;
13981*) val="$undef";
13982	echo "Nope, since you don't even have fcntl()."
13983	;;
13984esac
13985set d_fcntl_can_lock
13986eval $setvar
13987$rm_try
13988
13989: check for fd_set items
13990$cat <<EOM
13991
13992Checking to see how well your C compiler handles fd_set and friends ...
13993EOM
13994$cat >try.c <<EOCP
13995#$i_stdlib I_STDLIB
13996#ifdef I_STDLIB
13997#include <stdlib.h>
13998#endif
13999#$i_systime I_SYS_TIME
14000#$i_sysselct I_SYS_SELECT
14001#$d_socket HAS_SOCKET
14002#include <sys/types.h>
14003#ifdef HAS_SOCKET
14004#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
14005#endif
14006#ifdef I_SYS_TIME
14007#include <sys/time.h>
14008#endif
14009#ifdef I_SYS_SELECT
14010#include <sys/select.h>
14011#endif
14012int main() {
14013	fd_set fds;
14014
14015#ifdef TRYBITS
14016	if(fds.fds_bits);
14017#endif
14018
14019#if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
14020	exit(0);
14021#else
14022	exit(1);
14023#endif
14024}
14025EOCP
14026set try -DTRYBITS
14027if eval $compile; then
14028	d_fds_bits="$define"
14029	d_fd_set="$define"
14030	echo "Well, your system knows about the normal fd_set typedef..." >&4
14031	if $run ./try; then
14032		echo "and you have the normal fd_set macros (just as I'd expect)." >&4
14033		d_fd_macros="$define"
14034	else
14035		$cat >&4 <<'EOM'
14036but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
14037EOM
14038		d_fd_macros="$undef"
14039	fi
14040else
14041	$cat <<'EOM'
14042Hmm, your compiler has some difficulty with fd_set.  Checking further...
14043EOM
14044	set try
14045	if eval $compile; then
14046		d_fds_bits="$undef"
14047		d_fd_set="$define"
14048		echo "Well, your system has some sort of fd_set available..." >&4
14049		if $run ./try; then
14050			echo "and you have the normal fd_set macros." >&4
14051			d_fd_macros="$define"
14052		else
14053			$cat <<'EOM'
14054but not the normal fd_set macros!  Gross!  More work for me...
14055EOM
14056			d_fd_macros="$undef"
14057		fi
14058	else
14059	echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
14060		d_fd_set="$undef"
14061		d_fds_bits="$undef"
14062		d_fd_macros="$undef"
14063	fi
14064fi
14065$rm_try
14066
14067: see if fdclose exists
14068set fdclose d_fdclose
14069eval $inlibc
14070
14071: see if fdim exists
14072set fdim d_fdim
14073eval $inlibc
14074
14075: see if fegetround exists
14076set fegetround d_fegetround
14077eval $inlibc
14078
14079: see if ffs exists
14080set ffs d_ffs
14081eval $inlibc
14082: see if ffsl exists
14083set ffsl d_ffsl
14084eval $inlibc
14085
14086: see if fgetpos exists
14087set fgetpos d_fgetpos
14088eval $inlibc
14089
14090: see if finite exists
14091set finite d_finite
14092eval $inlibc
14093
14094: see if finitel exists
14095set finitel d_finitel
14096eval $inlibc
14097
14098: see if flock exists
14099set flock d_flock
14100eval $inlibc
14101
14102: see if prototype for flock is available
14103echo " "
14104set d_flockproto flock $i_sysfile sys/file.h
14105eval $hasproto
14106
14107: see if fma exists
14108set fma d_fma
14109eval $inlibc
14110
14111: see if fmax exists
14112set fmax d_fmax
14113eval $inlibc
14114
14115: see if fmin exists
14116set fmin d_fmin
14117eval $inlibc
14118
14119: see if fp_class exists
14120set fp_class d_fp_class
14121eval $inlibc
14122
14123: check for fpclassify
14124echo "Checking to see if you have fpclassify..." >&4
14125$cat >try.c <<EOCP
14126#include <math.h>
14127int main() { return fpclassify(1.0) == FP_NORMAL ? 0 : 1; }
14128EOCP
14129set try
14130if eval $compile; then
14131	val="$define"
14132	echo "You have fpclassify."
14133else
14134	val="$undef"
14135	echo "You do not have fpclassify."
14136fi
14137$rm_try
14138set d_fpclassify
14139eval $setvar
14140
14141: see if fp_classify exists
14142set fp_classify d_fp_classify
14143eval $inlibc
14144
14145: see if fp_classl exists
14146set fp_classl d_fp_classl
14147eval $inlibc
14148
14149: see if pathconf exists
14150set pathconf d_pathconf
14151eval $inlibc
14152
14153: see if fpathconf exists
14154set fpathconf d_fpathconf
14155eval $inlibc
14156
14157: see if fpclass exists
14158set fpclass d_fpclass
14159eval $inlibc
14160
14161: see if fpclassl exists
14162set fpclassl d_fpclassl
14163eval $inlibc
14164
14165: see if fpgetround exists
14166set fpgetround d_fpgetround
14167eval $inlibc
14168
14169: check for fpos64_t
14170echo " "
14171echo "Checking to see if you have fpos64_t..." >&4
14172$cat >try.c <<EOCP
14173#include <stdio.h>
14174int main() { fpos64_t x = 7; }
14175EOCP
14176set try
14177if eval $compile; then
14178	val="$define"
14179	echo "You have fpos64_t."
14180else
14181	val="$undef"
14182	echo "You do not have fpos64_t."
14183	case "$fpossize" in
14184	8) echo "(Your fpos_t is 64 bits, so you could use that.)" ;;
14185	esac
14186fi
14187$rm_try
14188set d_fpos64_t
14189eval $setvar
14190
14191: see if frexpl exists
14192set frexpl d_frexpl
14193eval $inlibc
14194
14195: see if this is a sys/param system
14196set sys/param.h i_sysparam
14197eval $inhdr
14198
14199: see if this is a sys/mount.h system
14200set sys/mount.h i_sysmount
14201eval $inhdr
14202
14203: Check for fs_data_s
14204echo " "
14205echo "Checking to see if your system supports struct fs_data..." >&4
14206set d_fs_data_s fs_data $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h
14207eval $hasstruct
14208case "$d_fs_data_s" in
14209"$define")      echo "Yes, it does."   ;;
14210*)              echo "No, it doesn't." ;;
14211esac
14212
14213: see if fseeko exists
14214set fseeko d_fseeko
14215eval $inlibc
14216case "$longsize" in
142178) echo "(Your long is 64 bits, so you could use fseek.)" ;;
14218esac
14219
14220: see if fsetpos exists
14221set fsetpos d_fsetpos
14222eval $inlibc
14223
14224: see if fstatfs exists
14225set fstatfs d_fstatfs
14226eval $inlibc
14227
14228: see if statvfs exists
14229set statvfs d_statvfs
14230eval $inlibc
14231
14232: see if fstatvfs exists
14233set fstatvfs d_fstatvfs
14234eval $inlibc
14235
14236: see if fsync exists
14237set fsync d_fsync
14238eval $inlibc
14239
14240: see if ftello exists
14241set ftello d_ftello
14242eval $inlibc
14243case "$longsize" in
142448) echo "(Your long is 64 bits, so you could use ftell.)" ;;
14245esac
14246
14247: check for a working futimes
14248d_futimes="$undef"
14249echo " "
14250echo "Checking if you have a working futimes()" >&4
14251$cat >try.c <<EOCP
14252#include <stdio.h>
14253#include <stdlib.h>
14254#include <sys/time.h>
14255#include <errno.h>
14256#include <fcntl.h>
14257#include <stdlib.h>
14258
14259int main ()
14260{
14261    int fd, rv;
14262    fd = open ("try.c", O_RDWR);
14263    if (-1 == fd) exit (1);
14264    rv = futimes (fd, NULL);
14265    exit (rv == -1 ? errno : 0);
14266}
14267EOCP
14268set try
14269if eval $compile; then
14270    `$run ./try`
14271    rc=$?
14272    case "$rc" in
14273	0)  echo "Yes, you have" >&4
14274	    d_futimes="$define"
14275	    ;;
14276	*)  echo "No, you have futimes, but it isn't working ($rc) (probably harmless)" >&4
14277	    ;;
14278    esac
14279else
14280    echo "No, it does not (probably harmless)" >&4
14281fi
14282$rm_try
14283
14284: look for gai_strerror
14285echo " "
14286$cat >try.c <<'EOCP'
14287#include <sys/types.h>
14288#include <sys/socket.h>
14289#include <netdb.h>
14290int main ()
14291{
14292    return (gai_strerror (0) ? 0 : 1);
14293    }
14294EOCP
14295set try
14296val="$undef"
14297if eval $compile; then
14298    `$run ./try`
14299    case "$?" in
14300	0)  echo "A working gai_strerror() found." >&4
14301	    val="$define" ;;
14302	*)  echo "gai_strerror() found, but it doesn't work" >&4
14303	    ;;
14304	esac
14305else
14306    echo "gai_strerror() NOT found." >&4
14307    fi
14308set d_gai_strerror
14309eval $setvar
14310$rm_try
14311
14312: see if ndbm.h is available
14313set ndbm.h i_ndbm
14314eval $inhdr
14315: Compatibility location for RedHat 7.1
14316set gdbm/ndbm.h i_gdbmndbm
14317eval $inhdr
14318: Compatibility location for Debian 4.0
14319set gdbm-ndbm.h i_gdbm_ndbm
14320eval $inhdr
14321
14322val="$undef"
14323if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then
14324	: see if dbm_open exists
14325	set dbm_open d_dbm_open
14326	eval $inlibc
14327	case "$d_dbm_open" in
14328	$undef)
14329		i_ndbm="$undef"
14330		i_gdbmndbm="$undef"
14331		i_gdbm_ndbm="$undef"
14332		echo "We won't be including <ndbm.h>"
14333		val="$undef"
14334		;;
14335	*) val="$define"
14336	   ;;
14337	esac
14338fi
14339set d_ndbm
14340eval $setvar
14341
14342ndbm_hdr_protochk='name=$1; hdr=$2;
14343eval "ihdr=\$""i_$name";
14344val="$undef";
14345if $test "$ihdr" = "$define"; then
14346	$echo "Checking if your <$hdr> uses prototypes..." >&4;
14347	case "$d_cplusplus" in
14348	$define) ./protochk "$extern_C void dbm_close(DBM *);" literal "extern \"C\" {" $ihdr $hdr literal "}" && val="$define" ;;
14349	*) ./protochk "$extern_C void dbm_close(int, int);" $ihdr $hdr || val="$define" ;;
14350	esac;
14351	case "$val" in
14352	$define) $echo "Your <$hdr> seems to have prototypes";;
14353	*) $echo "Your <$hdr> does not seem to have prototypes";;
14354	esac;
14355fi;
14356set "d_${name}_h_uses_prototypes";
14357eval $setvar'
14358
14359set ndbm ndbm.h
14360eval $ndbm_hdr_protochk
14361set gdbmndbm gdbm/ndbm.h
14362eval $ndbm_hdr_protochk
14363set gdbm_ndbm gdbm-ndbm.h
14364eval $ndbm_hdr_protochk
14365
14366: see if getaddrinfo exists
14367set getaddrinfo d_getaddrinfo
14368eval $inlibc
14369
14370: see if getcwd exists
14371set getcwd d_getcwd
14372eval $inlibc
14373
14374: check for getenv behavior
14375case "$d_getenv_preserves_other_thread" in
14376'')
14377$echo "Checking to see if getenv() preserves a different thread's results" >&4
14378$cat >try.c <<EOCP
14379#$i_stdlib I_STDLIB
14380#ifdef I_STDLIB
14381#  include <stdlib.h>
14382#endif
14383#include <stdio.h>
14384#include <string.h>
14385#$i_pthread I_PTHREAD
14386#ifdef I_PTHREAD
14387#  include <pthread.h>
14388#endif
14389
14390void *
14391thread_start(void * arg)
14392{
14393    return (void *) getenv("HOME");
14394}
14395
14396int main() {
14397    char * main_buffer;
14398    char save_main_buffer[1000];
14399    pthread_t subthread;
14400    pthread_attr_t attr;
14401
14402    main_buffer = getenv("PATH");
14403
14404    /* If too large for our generous allowance, return we couldn't figure it
14405     * out. */
14406    if (strlen(main_buffer) >= sizeof(save_main_buffer)) {
14407        exit(2);
14408    }
14409
14410    strcpy(save_main_buffer, main_buffer);
14411
14412    if (pthread_attr_init(&attr) != 0) {
14413        exit(2);
14414    }
14415
14416    if (pthread_create(&subthread, &attr, thread_start, NULL) != 0) {
14417        exit(2);
14418    }
14419
14420    if (pthread_join(subthread, NULL) != 0) {
14421        exit(2);
14422    }
14423
14424    exit(! (strcmp(main_buffer, save_main_buffer) == 0));
14425}
14426EOCP
14427val=
14428set try
14429if eval $compile_ok; then
14430    $run ./try
14431    rc=$?
14432    case "$rc" in
14433	0) echo "getenv() didn't destroy another thread's buffer" >&4
14434	   val=$define
14435	   ;;
14436	1) echo "getenv() does destroy another thread's buffer" >&4
14437	   val=$undef
14438	   ;;
14439	*) echo "Couldn't determine if getenv() destroys another thread's return value (code=$rc); assuming it does" >&4
14440	   val=$undef
14441	   ;;
14442    esac
14443else
14444    echo "(I can't seem to compile the test program.)" >&4
14445    echo "Assuming that your C library's getenv destroys another thread's return value." >&4
14446    val=$undef
14447fi
14448set d_getenv_preserves_other_thread
14449eval $setvar
14450$rm_try
14451;;
14452esac
14453
14454: see if getespwnam exists
14455set getespwnam d_getespwnam
14456eval $inlibc
14457
14458: see if getfsstat exists
14459set getfsstat d_getfsstat
14460eval $inlibc
14461
14462: see if getgrent exists
14463set getgrent d_getgrent
14464eval $inlibc
14465
14466: see if getgrent_r exists
14467set getgrent_r d_getgrent_r
14468eval $inlibc
14469case "$d_getgrent_r" in
14470"$define")
14471	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
14472	case "$d_getgrent_r_proto:$usethreads" in
14473	":define")	d_getgrent_r_proto=define
14474		set d_getgrent_r_proto getgrent_r $hdrs
14475		eval $hasproto ;;
14476	*)	;;
14477	esac
14478	case "$d_getgrent_r_proto" in
14479	define)
14480	case "$getgrent_r_proto" in
14481	''|0) try='int getgrent_r(struct group*, char*, size_t, struct group**);'
14482	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBWR ;;
14483	esac
14484	case "$getgrent_r_proto" in
14485	''|0) try='int getgrent_r(struct group*, char*, int, struct group**);'
14486	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIR ;;
14487	esac
14488	case "$getgrent_r_proto" in
14489	''|0) try='struct group* getgrent_r(struct group*, char*, size_t);'
14490	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBW ;;
14491	esac
14492	case "$getgrent_r_proto" in
14493	''|0) try='struct group* getgrent_r(struct group*, char*, int);'
14494	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=S_SBI ;;
14495	esac
14496	case "$getgrent_r_proto" in
14497	''|0) try='int getgrent_r(struct group*, char*, int);'
14498	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBI ;;
14499	esac
14500	case "$getgrent_r_proto" in
14501	''|0) try='int getgrent_r(struct group*, char*, int, FILE**);'
14502	./protochk "$extern_C $try" $hdrs && getgrent_r_proto=I_SBIH ;;
14503	esac
14504	case "$getgrent_r_proto" in
14505	''|0)	d_getgrent_r=undef
14506		getgrent_r_proto=0
14507		echo "Disabling getgrent_r, cannot determine prototype." >&4 ;;
14508	* )	case "$getgrent_r_proto" in
14509		REENTRANT_PROTO*) ;;
14510		*) getgrent_r_proto="REENTRANT_PROTO_$getgrent_r_proto" ;;
14511		esac
14512		echo "Prototype: $try" ;;
14513	esac
14514	;;
14515	*)	case "$usethreads" in
14516		define) echo "getgrent_r has no prototype, not using it." >&4 ;;
14517		esac
14518		d_getgrent_r=undef
14519		getgrent_r_proto=0
14520		;;
14521	esac
14522	;;
14523*)	getgrent_r_proto=0
14524	;;
14525esac
14526
14527: see if getgrgid_r exists
14528set getgrgid_r d_getgrgid_r
14529eval $inlibc
14530case "$d_getgrgid_r" in
14531"$define")
14532	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
14533	case "$d_getgrgid_r_proto:$usethreads" in
14534	":define")	d_getgrgid_r_proto=define
14535		set d_getgrgid_r_proto getgrgid_r $hdrs
14536		eval $hasproto ;;
14537	*)	;;
14538	esac
14539	case "$d_getgrgid_r_proto" in
14540	define)
14541	case "$getgrgid_r_proto" in
14542	''|0) try='int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**);'
14543	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBWR ;;
14544	esac
14545	case "$getgrgid_r_proto" in
14546	''|0) try='int getgrgid_r(gid_t, struct group*, char*, int, struct group**);'
14547	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBIR ;;
14548	esac
14549	case "$getgrgid_r_proto" in
14550	''|0) try='int getgrgid_r(gid_t, struct group*, char*, int);'
14551	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=I_TSBI ;;
14552	esac
14553	case "$getgrgid_r_proto" in
14554	''|0) try='struct group* getgrgid_r(gid_t, struct group*, char*, int);'
14555	./protochk "$extern_C $try" $hdrs && getgrgid_r_proto=S_TSBI ;;
14556	esac
14557	case "$getgrgid_r_proto" in
14558	''|0)	d_getgrgid_r=undef
14559		getgrgid_r_proto=0
14560		echo "Disabling getgrgid_r, cannot determine prototype." >&4 ;;
14561	* )	case "$getgrgid_r_proto" in
14562		REENTRANT_PROTO*) ;;
14563		*) getgrgid_r_proto="REENTRANT_PROTO_$getgrgid_r_proto" ;;
14564		esac
14565		echo "Prototype: $try" ;;
14566	esac
14567	;;
14568	*)	case "$usethreads" in
14569		define) echo "getgrgid_r has no prototype, not using it." >&4 ;;
14570		esac
14571		d_getgrgid_r=undef
14572		getgrgid_r_proto=0
14573		;;
14574	esac
14575	;;
14576*)	getgrgid_r_proto=0
14577	;;
14578esac
14579
14580: see if getgrnam_r exists
14581set getgrnam_r d_getgrnam_r
14582eval $inlibc
14583case "$d_getgrnam_r" in
14584"$define")
14585	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
14586	case "$d_getgrnam_r_proto:$usethreads" in
14587	":define")	d_getgrnam_r_proto=define
14588		set d_getgrnam_r_proto getgrnam_r $hdrs
14589		eval $hasproto ;;
14590	*)	;;
14591	esac
14592	case "$d_getgrnam_r_proto" in
14593	define)
14594	case "$getgrnam_r_proto" in
14595	''|0) try='int getgrnam_r(const char*, struct group*, char*, size_t, struct group**);'
14596	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBWR ;;
14597	esac
14598	case "$getgrnam_r_proto" in
14599	''|0) try='int getgrnam_r(const char*, struct group*, char*, int, struct group**);'
14600	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBIR ;;
14601	esac
14602	case "$getgrnam_r_proto" in
14603	''|0) try='struct group* getgrnam_r(const char*, char*, int);'
14604	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CBI ;;
14605	esac
14606	case "$getgrnam_r_proto" in
14607	''|0) try='int getgrnam_r(const char*, struct group*, char*, int);'
14608	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=I_CSBI ;;
14609	esac
14610	case "$getgrnam_r_proto" in
14611	''|0) try='struct group* getgrnam_r(const char*, struct group*, char*, int);'
14612	./protochk "$extern_C $try" $hdrs && getgrnam_r_proto=S_CSBI ;;
14613	esac
14614	case "$getgrnam_r_proto" in
14615	''|0)	d_getgrnam_r=undef
14616		getgrnam_r_proto=0
14617		echo "Disabling getgrnam_r, cannot determine prototype." >&4 ;;
14618	* )	case "$getgrnam_r_proto" in
14619		REENTRANT_PROTO*) ;;
14620		*) getgrnam_r_proto="REENTRANT_PROTO_$getgrnam_r_proto" ;;
14621		esac
14622		echo "Prototype: $try" ;;
14623	esac
14624	;;
14625	*)	case "$usethreads" in
14626		define) echo "getgrnam_r has no prototype, not using it." >&4 ;;
14627		esac
14628		d_getgrnam_r=undef
14629		getgrnam_r_proto=0
14630		;;
14631	esac
14632	;;
14633*)	getgrnam_r_proto=0
14634	;;
14635esac
14636
14637: see if gethostbyaddr exists
14638set gethostbyaddr d_gethbyaddr
14639eval $inlibc
14640
14641: see if gethostbyname exists
14642set gethostbyname d_gethbyname
14643eval $inlibc
14644
14645: see if gethostent exists
14646set gethostent d_gethent
14647eval $inlibc
14648
14649: see how we will look up host name
14650echo " "
14651call=''
14652if set gethostname val -f d_gethname; eval $csym; $val; then
14653	echo 'gethostname() found.' >&4
14654	d_gethname="$define"
14655	call=gethostname
14656fi
14657if set uname val -f d_uname; eval $csym; $val; then
14658	if ./xenix; then
14659		$cat <<'EOM'
14660uname() was found, but you're running xenix, and older versions of xenix
14661have a broken uname(). If you don't really know whether your xenix is old
14662enough to have a broken system call, use the default answer.
14663
14664EOM
14665		dflt=y
14666		case "$d_uname" in
14667		"$define") dflt=n;;
14668		esac
14669		rp='Is your uname() broken?'
14670		. ./myread
14671		case "$ans" in
14672		n*) d_uname="$define"; call=uname;;
14673		esac
14674	else
14675		echo 'uname() found.' >&4
14676		d_uname="$define"
14677		case "$call" in
14678		'') call=uname ;;
14679		esac
14680	fi
14681fi
14682case "$d_gethname" in
14683'') d_gethname="$undef";;
14684esac
14685case "$d_uname" in
14686'') d_uname="$undef";;
14687esac
14688case "$d_uname$d_gethname" in
14689*define*)
14690	dflt=n
14691	cat <<EOM
14692
14693Every now and then someone has a $call() that lies about the hostname
14694but can't be fixed for political or economic reasons.  If you wish, I can
14695pretend $call() isn't there and maybe compute hostname at run-time
14696thanks to the '$phostname' command.
14697
14698EOM
14699	rp="Shall I ignore $call() from now on?"
14700	. ./myread
14701	case "$ans" in
14702	y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
14703	esac;;
14704esac
14705case "$phostname" in
14706'') aphostname='';;
14707*) case "$aphostname" in
14708	/*) ;;
14709	*) set X $phostname
14710		shift
14711		file=$1
14712		shift
14713		file=`./loc $file $file $pth`
14714		aphostname=`echo $file $*`
14715		;;
14716	esac
14717	;;
14718esac
14719case "$d_uname$d_gethname" in
14720*define*) ;;
14721*)
14722	case "$phostname" in
14723	'')
14724		echo "There will be no way for $package to get your hostname." >&4;;
14725	*)
14726	echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
14727		;;
14728	esac;;
14729esac
14730case "$d_phostname" in
14731'') d_phostname="$undef";;
14732esac
14733
14734: see if gethostbyaddr_r exists
14735set gethostbyaddr_r d_gethostbyaddr_r
14736eval $inlibc
14737case "$d_gethostbyaddr_r" in
14738"$define")
14739	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14740	case "$d_gethostbyaddr_r_proto:$usethreads" in
14741	":define")	d_gethostbyaddr_r_proto=define
14742		set d_gethostbyaddr_r_proto gethostbyaddr_r $hdrs
14743		eval $hasproto ;;
14744	*)	;;
14745	esac
14746	case "$d_gethostbyaddr_r_proto" in
14747	define)
14748	case "$gethostbyaddr_r_proto" in
14749	''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
14750	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISBWRE ;;
14751	esac
14752	case "$gethostbyaddr_r_proto" in
14753	''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, size_t, int, int*);'
14754	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBWIE ;;
14755	esac
14756	case "$gethostbyaddr_r_proto" in
14757	''|0) try='struct hostent* gethostbyaddr_r(const char*, size_t, int, struct hostent*, char*, int, int*);'
14758	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CWISBIE ;;
14759	esac
14760	case "$gethostbyaddr_r_proto" in
14761	''|0) try='struct hostent* gethostbyaddr_r(const void*, size_t, int, struct hostent*, char*, int, int*);'
14762	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TWISBIE ;;
14763	esac
14764	case "$gethostbyaddr_r_proto" in
14765	''|0) try='struct hostent* gethostbyaddr_r(const char*, int, int, struct hostent*, char*, int, int*);'
14766	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CIISBIE ;;
14767	esac
14768	case "$gethostbyaddr_r_proto" in
14769	''|0) try='struct hostent* gethostbyaddr_r(const char*, struct hostent*, char*, int, int*);'
14770	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_CSBIE ;;
14771	esac
14772	case "$gethostbyaddr_r_proto" in
14773	''|0) try='struct hostent* gethostbyaddr_r(const void*, struct hostent*, char*, int, int*);'
14774	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=S_TSBIE ;;
14775	esac
14776	case "$gethostbyaddr_r_proto" in
14777	''|0) try='int gethostbyaddr_r(const char*, size_t, int, struct hostent*, struct hostent_data*);'
14778	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CWISD ;;
14779	esac
14780	case "$gethostbyaddr_r_proto" in
14781	''|0) try='int gethostbyaddr_r(const char*, int, int, struct hostent*, struct hostent_data*);'
14782	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CIISD ;;
14783	esac
14784	case "$gethostbyaddr_r_proto" in
14785	''|0) try='int gethostbyaddr_r(const char*, int, int);'
14786	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_CII ;;
14787	esac
14788	case "$gethostbyaddr_r_proto" in
14789	''|0) try='int gethostbyaddr_r(const void*, socklen_t, int, struct hostent*, char*, size_t, struct hostent**, int*);'
14790	./protochk "$extern_C $try" $hdrs && gethostbyaddr_r_proto=I_TsISBWRE ;;
14791	esac
14792	case "$gethostbyaddr_r_proto" in
14793	''|0)	d_gethostbyaddr_r=undef
14794		gethostbyaddr_r_proto=0
14795		echo "Disabling gethostbyaddr_r, cannot determine prototype." >&4 ;;
14796	* )	case "$gethostbyaddr_r_proto" in
14797		REENTRANT_PROTO*) ;;
14798		*) gethostbyaddr_r_proto="REENTRANT_PROTO_$gethostbyaddr_r_proto" ;;
14799		esac
14800		echo "Prototype: $try" ;;
14801	esac
14802	;;
14803	*)	case "$usethreads" in
14804		define) echo "gethostbyaddr_r has no prototype, not using it." >&4 ;;
14805		esac
14806		d_gethostbyaddr_r=undef
14807		gethostbyaddr_r_proto=0
14808		;;
14809	esac
14810	;;
14811*)	gethostbyaddr_r_proto=0
14812	;;
14813esac
14814
14815: see if gethostbyname_r exists
14816set gethostbyname_r d_gethostbyname_r
14817eval $inlibc
14818case "$d_gethostbyname_r" in
14819"$define")
14820	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14821	case "$d_gethostbyname_r_proto:$usethreads" in
14822	":define")	d_gethostbyname_r_proto=define
14823		set d_gethostbyname_r_proto gethostbyname_r $hdrs
14824		eval $hasproto ;;
14825	*)	;;
14826	esac
14827	case "$d_gethostbyname_r_proto" in
14828	define)
14829	case "$gethostbyname_r_proto" in
14830	''|0) try='int gethostbyname_r(const char*, struct hostent*, char*, size_t, struct hostent**, int*);'
14831	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSBWRE ;;
14832	esac
14833	case "$gethostbyname_r_proto" in
14834	''|0) try='struct hostent* gethostbyname_r(const char*, struct hostent*, char*, int, int*);'
14835	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=S_CSBIE ;;
14836	esac
14837	case "$gethostbyname_r_proto" in
14838	''|0) try='int gethostbyname_r(const char*, struct hostent*, struct hostent_data*);'
14839	./protochk "$extern_C $try" $hdrs && gethostbyname_r_proto=I_CSD ;;
14840	esac
14841	case "$gethostbyname_r_proto" in
14842	''|0)	d_gethostbyname_r=undef
14843		gethostbyname_r_proto=0
14844		echo "Disabling gethostbyname_r, cannot determine prototype." >&4 ;;
14845	* )	case "$gethostbyname_r_proto" in
14846		REENTRANT_PROTO*) ;;
14847		*) gethostbyname_r_proto="REENTRANT_PROTO_$gethostbyname_r_proto" ;;
14848		esac
14849		echo "Prototype: $try" ;;
14850	esac
14851	;;
14852	*)	case "$usethreads" in
14853		define) echo "gethostbyname_r has no prototype, not using it." >&4 ;;
14854		esac
14855		d_gethostbyname_r=undef
14856		gethostbyname_r_proto=0
14857		;;
14858	esac
14859	;;
14860*)	gethostbyname_r_proto=0
14861	;;
14862esac
14863
14864: see if gethostent_r exists
14865set gethostent_r d_gethostent_r
14866eval $inlibc
14867case "$d_gethostent_r" in
14868"$define")
14869	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
14870	case "$d_gethostent_r_proto:$usethreads" in
14871	":define")	d_gethostent_r_proto=define
14872		set d_gethostent_r_proto gethostent_r $hdrs
14873		eval $hasproto ;;
14874	*)	;;
14875	esac
14876	case "$d_gethostent_r_proto" in
14877	define)
14878	case "$gethostent_r_proto" in
14879	''|0) try='int gethostent_r(struct hostent*, char*, size_t, struct hostent**, int*);'
14880	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBWRE ;;
14881	esac
14882	case "$gethostent_r_proto" in
14883	''|0) try='int gethostent_r(struct hostent*, char*, int, int*);'
14884	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBIE ;;
14885	esac
14886	case "$gethostent_r_proto" in
14887	''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int, int*);'
14888	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBIE ;;
14889	esac
14890	case "$gethostent_r_proto" in
14891	''|0) try='struct hostent* gethostent_r(struct hostent*, char*, int);'
14892	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=S_SBI ;;
14893	esac
14894	case "$gethostent_r_proto" in
14895	''|0) try='int gethostent_r(struct hostent*, char*, int);'
14896	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SBI ;;
14897	esac
14898	case "$gethostent_r_proto" in
14899	''|0) try='int gethostent_r(struct hostent*, struct hostent_data*);'
14900	./protochk "$extern_C $try" $hdrs && gethostent_r_proto=I_SD ;;
14901	esac
14902	case "$gethostent_r_proto" in
14903	''|0)	d_gethostent_r=undef
14904		gethostent_r_proto=0
14905		echo "Disabling gethostent_r, cannot determine prototype." >&4 ;;
14906	* )	case "$gethostent_r_proto" in
14907		REENTRANT_PROTO*) ;;
14908		*) gethostent_r_proto="REENTRANT_PROTO_$gethostent_r_proto" ;;
14909		esac
14910		echo "Prototype: $try" ;;
14911	esac
14912	;;
14913	*)	case "$usethreads" in
14914		define) echo "gethostent_r has no prototype, not using it." >&4 ;;
14915		esac
14916		d_gethostent_r=undef
14917		gethostent_r_proto=0
14918		;;
14919	esac
14920	;;
14921*)	gethostent_r_proto=0
14922	;;
14923esac
14924
14925: see if prototypes for various gethostxxx netdb.h functions are available
14926echo " "
14927set d_gethostprotos gethostent $i_netdb netdb.h
14928eval $hasproto
14929
14930: see if getitimer exists
14931set getitimer d_getitimer
14932eval $inlibc
14933
14934: see if getlogin exists
14935set getlogin d_getlogin
14936eval $inlibc
14937
14938: see if getlogin_r exists
14939set getlogin_r d_getlogin_r
14940eval $inlibc
14941case "$d_getlogin_r" in
14942"$define")
14943	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
14944	case "$d_getlogin_r_proto:$usethreads" in
14945	":define")	d_getlogin_r_proto=define
14946		set d_getlogin_r_proto getlogin_r $hdrs
14947		eval $hasproto ;;
14948	*)	;;
14949	esac
14950	case "$d_getlogin_r_proto" in
14951	define)
14952	case "$getlogin_r_proto" in
14953	''|0) try='int getlogin_r(char*, size_t);'
14954	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BW ;;
14955	esac
14956	case "$getlogin_r_proto" in
14957	''|0) try='int getlogin_r(char*, int);'
14958	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=I_BI ;;
14959	esac
14960	case "$getlogin_r_proto" in
14961	''|0) try='char* getlogin_r(char*, size_t);'
14962	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BW ;;
14963	esac
14964	case "$getlogin_r_proto" in
14965	''|0) try='char* getlogin_r(char*, int);'
14966	./protochk "$extern_C $try" $hdrs && getlogin_r_proto=B_BI ;;
14967	esac
14968	case "$getlogin_r_proto" in
14969	''|0)	d_getlogin_r=undef
14970		getlogin_r_proto=0
14971		echo "Disabling getlogin_r, cannot determine prototype." >&4 ;;
14972	* )	case "$getlogin_r_proto" in
14973		REENTRANT_PROTO*) ;;
14974		*) getlogin_r_proto="REENTRANT_PROTO_$getlogin_r_proto" ;;
14975		esac
14976		echo "Prototype: $try" ;;
14977	esac
14978	;;
14979	*)	case "$usethreads" in
14980		define) echo "getlogin_r has no prototype, not using it." >&4 ;;
14981		esac
14982		d_getlogin_r=undef
14983		getlogin_r_proto=0
14984		;;
14985	esac
14986	;;
14987*)	getlogin_r_proto=0
14988	;;
14989esac
14990
14991: see if getmnt exists
14992set getmnt d_getmnt
14993eval $inlibc
14994
14995: see if getmntent exists
14996set getmntent d_getmntent
14997eval $inlibc
14998
14999: see if getnameinfo exists
15000set getnameinfo d_getnameinfo
15001eval $inlibc
15002
15003: see if getnetbyaddr exists
15004set getnetbyaddr d_getnbyaddr
15005eval $inlibc
15006
15007: see if getnetbyname exists
15008set getnetbyname d_getnbyname
15009eval $inlibc
15010
15011: see if getnetent exists
15012set getnetent d_getnent
15013eval $inlibc
15014
15015: see if getnetbyaddr_r exists
15016set getnetbyaddr_r d_getnetbyaddr_r
15017eval $inlibc
15018case "$d_getnetbyaddr_r" in
15019"$define")
15020	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15021	case "$d_getnetbyaddr_r_proto:$usethreads" in
15022	":define")	d_getnetbyaddr_r_proto=define
15023		set d_getnetbyaddr_r_proto getnetbyaddr_r $hdrs
15024		eval $hasproto ;;
15025	*)	;;
15026	esac
15027	case "$d_getnetbyaddr_r_proto" in
15028	define)
15029	case "$getnetbyaddr_r_proto" in
15030	''|0) try='int getnetbyaddr_r(unsigned long, int, struct netent*, char*, size_t, struct netent**, int*);'
15031	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_UISBWRE ;;
15032	esac
15033	case "$getnetbyaddr_r_proto" in
15034	''|0) try='int getnetbyaddr_r(long, int, struct netent*, char*, int);'
15035	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISBI ;;
15036	esac
15037	case "$getnetbyaddr_r_proto" in
15038	''|0) try='struct netent* getnetbyaddr_r(in_addr_t, int, struct netent*, char*, int);'
15039	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_TISBI ;;
15040	esac
15041	case "$getnetbyaddr_r_proto" in
15042	''|0) try='struct netent* getnetbyaddr_r(long, int, struct netent*, char*, int);'
15043	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=S_LISBI ;;
15044	esac
15045	case "$getnetbyaddr_r_proto" in
15046	''|0) try='int getnetbyaddr_r(in_addr_t, int, struct netent*, struct netent_data*);'
15047	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_TISD ;;
15048	esac
15049	case "$getnetbyaddr_r_proto" in
15050	''|0) try='int getnetbyaddr_r(long, int, struct netent*, struct netent_data*);'
15051	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_LISD ;;
15052	esac
15053	case "$getnetbyaddr_r_proto" in
15054	''|0) try='int getnetbyaddr_r(int, int, struct netent*, struct netent_data*);'
15055	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_IISD ;;
15056	esac
15057	case "$getnetbyaddr_r_proto" in
15058	''|0) try='int getnetbyaddr_r(uint32_t, int, struct netent*, char*, size_t, struct netent**, int*);'
15059	./protochk "$extern_C $try" $hdrs && getnetbyaddr_r_proto=I_uISBWRE ;;
15060	esac
15061	case "$getnetbyaddr_r_proto" in
15062	''|0)	d_getnetbyaddr_r=undef
15063		getnetbyaddr_r_proto=0
15064		echo "Disabling getnetbyaddr_r, cannot determine prototype." >&4 ;;
15065	* )	case "$getnetbyaddr_r_proto" in
15066		REENTRANT_PROTO*) ;;
15067		*) getnetbyaddr_r_proto="REENTRANT_PROTO_$getnetbyaddr_r_proto" ;;
15068		esac
15069		echo "Prototype: $try" ;;
15070	esac
15071	;;
15072	*)	case "$usethreads" in
15073		define) echo "getnetbyaddr_r has no prototype, not using it." >&4 ;;
15074		esac
15075		d_getnetbyaddr_r=undef
15076		getnetbyaddr_r_proto=0
15077		;;
15078	esac
15079	;;
15080*)	getnetbyaddr_r_proto=0
15081	;;
15082esac
15083
15084: see if getnetbyname_r exists
15085set getnetbyname_r d_getnetbyname_r
15086eval $inlibc
15087case "$d_getnetbyname_r" in
15088"$define")
15089	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15090	case "$d_getnetbyname_r_proto:$usethreads" in
15091	":define")	d_getnetbyname_r_proto=define
15092		set d_getnetbyname_r_proto getnetbyname_r $hdrs
15093		eval $hasproto ;;
15094	*)	;;
15095	esac
15096	case "$d_getnetbyname_r_proto" in
15097	define)
15098	case "$getnetbyname_r_proto" in
15099	''|0) try='int getnetbyname_r(const char*, struct netent*, char*, size_t, struct netent**, int*);'
15100	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBWRE ;;
15101	esac
15102	case "$getnetbyname_r_proto" in
15103	''|0) try='int getnetbyname_r(const char*, struct netent*, char*, int);'
15104	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSBI ;;
15105	esac
15106	case "$getnetbyname_r_proto" in
15107	''|0) try='struct netent* getnetbyname_r(const char*, struct netent*, char*, int);'
15108	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=S_CSBI ;;
15109	esac
15110	case "$getnetbyname_r_proto" in
15111	''|0) try='int getnetbyname_r(const char*, struct netent*, struct netent_data*);'
15112	./protochk "$extern_C $try" $hdrs && getnetbyname_r_proto=I_CSD ;;
15113	esac
15114	case "$getnetbyname_r_proto" in
15115	''|0)	d_getnetbyname_r=undef
15116		getnetbyname_r_proto=0
15117		echo "Disabling getnetbyname_r, cannot determine prototype." >&4 ;;
15118	* )	case "$getnetbyname_r_proto" in
15119		REENTRANT_PROTO*) ;;
15120		*) getnetbyname_r_proto="REENTRANT_PROTO_$getnetbyname_r_proto" ;;
15121		esac
15122		echo "Prototype: $try" ;;
15123	esac
15124	;;
15125	*)	case "$usethreads" in
15126		define) echo "getnetbyname_r has no prototype, not using it." >&4 ;;
15127		esac
15128		d_getnetbyname_r=undef
15129		getnetbyname_r_proto=0
15130		;;
15131	esac
15132	;;
15133*)	getnetbyname_r_proto=0
15134	;;
15135esac
15136
15137: see if getnetent_r exists
15138set getnetent_r d_getnetent_r
15139eval $inlibc
15140case "$d_getnetent_r" in
15141"$define")
15142	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15143	case "$d_getnetent_r_proto:$usethreads" in
15144	":define")	d_getnetent_r_proto=define
15145		set d_getnetent_r_proto getnetent_r $hdrs
15146		eval $hasproto ;;
15147	*)	;;
15148	esac
15149	case "$d_getnetent_r_proto" in
15150	define)
15151	case "$getnetent_r_proto" in
15152	''|0) try='int getnetent_r(struct netent*, char*, size_t, struct netent**, int*);'
15153	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBWRE ;;
15154	esac
15155	case "$getnetent_r_proto" in
15156	''|0) try='int getnetent_r(struct netent*, char*, int, int*);'
15157	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBIE ;;
15158	esac
15159	case "$getnetent_r_proto" in
15160	''|0) try='struct netent* getnetent_r(struct netent*, char*, int, int*);'
15161	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBIE ;;
15162	esac
15163	case "$getnetent_r_proto" in
15164	''|0) try='struct netent* getnetent_r(struct netent*, char*, int);'
15165	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=S_SBI ;;
15166	esac
15167	case "$getnetent_r_proto" in
15168	''|0) try='int getnetent_r(struct netent*, char*, int);'
15169	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SBI ;;
15170	esac
15171	case "$getnetent_r_proto" in
15172	''|0) try='int getnetent_r(struct netent*, struct netent_data*);'
15173	./protochk "$extern_C $try" $hdrs && getnetent_r_proto=I_SD ;;
15174	esac
15175	case "$getnetent_r_proto" in
15176	''|0)	d_getnetent_r=undef
15177		getnetent_r_proto=0
15178		echo "Disabling getnetent_r, cannot determine prototype." >&4 ;;
15179	* )	case "$getnetent_r_proto" in
15180		REENTRANT_PROTO*) ;;
15181		*) getnetent_r_proto="REENTRANT_PROTO_$getnetent_r_proto" ;;
15182		esac
15183		echo "Prototype: $try" ;;
15184	esac
15185	;;
15186	*)	case "$usethreads" in
15187		define) echo "getnetent_r has no prototype, not using it." >&4 ;;
15188		esac
15189		d_getnetent_r=undef
15190		getnetent_r_proto=0
15191		;;
15192	esac
15193	;;
15194*)	getnetent_r_proto=0
15195	;;
15196esac
15197
15198: see if prototypes for various getnetxxx netdb.h functions are available
15199echo " "
15200set d_getnetprotos getnetent $i_netdb netdb.h
15201eval $hasproto
15202
15203: see if getpagesize exists
15204set getpagesize d_getpagsz
15205eval $inlibc
15206
15207: Optional checks for getprotobyname and getprotobynumber
15208
15209: see if getprotobyname exists
15210set getprotobyname d_getpbyname
15211eval $inlibc
15212
15213: see if getprotobynumber exists
15214set getprotobynumber d_getpbynumber
15215eval $inlibc
15216
15217: see if getprotoent exists
15218set getprotoent d_getpent
15219eval $inlibc
15220
15221: see if getpgid exists
15222set getpgid d_getpgid
15223eval $inlibc
15224
15225: see if getpgrp2 exists
15226set getpgrp2 d_getpgrp2
15227eval $inlibc
15228
15229: see if getppid exists
15230set getppid d_getppid
15231eval $inlibc
15232
15233: see if getpriority exists
15234set getpriority d_getprior
15235eval $inlibc
15236
15237: see if getprotobyname_r exists
15238set getprotobyname_r d_getprotobyname_r
15239eval $inlibc
15240case "$d_getprotobyname_r" in
15241"$define")
15242	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15243	case "$d_getprotobyname_r_proto:$usethreads" in
15244	":define")	d_getprotobyname_r_proto=define
15245		set d_getprotobyname_r_proto getprotobyname_r $hdrs
15246		eval $hasproto ;;
15247	*)	;;
15248	esac
15249	case "$d_getprotobyname_r_proto" in
15250	define)
15251	case "$getprotobyname_r_proto" in
15252	''|0) try='int getprotobyname_r(const char*, struct protoent*, char*, size_t, struct protoent**);'
15253	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSBWR ;;
15254	esac
15255	case "$getprotobyname_r_proto" in
15256	''|0) try='struct protoent* getprotobyname_r(const char*, struct protoent*, char*, int);'
15257	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=S_CSBI ;;
15258	esac
15259	case "$getprotobyname_r_proto" in
15260	''|0) try='int getprotobyname_r(const char*, struct protoent*, struct protoent_data*);'
15261	./protochk "$extern_C $try" $hdrs && getprotobyname_r_proto=I_CSD ;;
15262	esac
15263	case "$getprotobyname_r_proto" in
15264	''|0)	d_getprotobyname_r=undef
15265		getprotobyname_r_proto=0
15266		echo "Disabling getprotobyname_r, cannot determine prototype." >&4 ;;
15267	* )	case "$getprotobyname_r_proto" in
15268		REENTRANT_PROTO*) ;;
15269		*) getprotobyname_r_proto="REENTRANT_PROTO_$getprotobyname_r_proto" ;;
15270		esac
15271		echo "Prototype: $try" ;;
15272	esac
15273	;;
15274	*)	case "$usethreads" in
15275		define) echo "getprotobyname_r has no prototype, not using it." >&4 ;;
15276		esac
15277		d_getprotobyname_r=undef
15278		getprotobyname_r_proto=0
15279		;;
15280	esac
15281	;;
15282*)	getprotobyname_r_proto=0
15283	;;
15284esac
15285
15286: see if getprotobynumber_r exists
15287set getprotobynumber_r d_getprotobynumber_r
15288eval $inlibc
15289case "$d_getprotobynumber_r" in
15290"$define")
15291	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15292	case "$d_getprotobynumber_r_proto:$usethreads" in
15293	":define")	d_getprotobynumber_r_proto=define
15294		set d_getprotobynumber_r_proto getprotobynumber_r $hdrs
15295		eval $hasproto ;;
15296	*)	;;
15297	esac
15298	case "$d_getprotobynumber_r_proto" in
15299	define)
15300	case "$getprotobynumber_r_proto" in
15301	''|0) try='int getprotobynumber_r(int, struct protoent*, char*, size_t, struct protoent**);'
15302	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISBWR ;;
15303	esac
15304	case "$getprotobynumber_r_proto" in
15305	''|0) try='struct protoent* getprotobynumber_r(int, struct protoent*, char*, int);'
15306	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=S_ISBI ;;
15307	esac
15308	case "$getprotobynumber_r_proto" in
15309	''|0) try='int getprotobynumber_r(int, struct protoent*, struct protoent_data*);'
15310	./protochk "$extern_C $try" $hdrs && getprotobynumber_r_proto=I_ISD ;;
15311	esac
15312	case "$getprotobynumber_r_proto" in
15313	''|0)	d_getprotobynumber_r=undef
15314		getprotobynumber_r_proto=0
15315		echo "Disabling getprotobynumber_r, cannot determine prototype." >&4 ;;
15316	* )	case "$getprotobynumber_r_proto" in
15317		REENTRANT_PROTO*) ;;
15318		*) getprotobynumber_r_proto="REENTRANT_PROTO_$getprotobynumber_r_proto" ;;
15319		esac
15320		echo "Prototype: $try" ;;
15321	esac
15322	;;
15323	*)	case "$usethreads" in
15324		define) echo "getprotobynumber_r has no prototype, not using it." >&4 ;;
15325		esac
15326		d_getprotobynumber_r=undef
15327		getprotobynumber_r_proto=0
15328		;;
15329	esac
15330	;;
15331*)	getprotobynumber_r_proto=0
15332	;;
15333esac
15334
15335: see if getprotoent_r exists
15336set getprotoent_r d_getprotoent_r
15337eval $inlibc
15338case "$d_getprotoent_r" in
15339"$define")
15340	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15341	case "$d_getprotoent_r_proto:$usethreads" in
15342	":define")	d_getprotoent_r_proto=define
15343		set d_getprotoent_r_proto getprotoent_r $hdrs
15344		eval $hasproto ;;
15345	*)	;;
15346	esac
15347	case "$d_getprotoent_r_proto" in
15348	define)
15349	case "$getprotoent_r_proto" in
15350	''|0) try='int getprotoent_r(struct protoent*, char*, size_t, struct protoent**);'
15351	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBWR ;;
15352	esac
15353	case "$getprotoent_r_proto" in
15354	''|0) try='int getprotoent_r(struct protoent*, char*, int);'
15355	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SBI ;;
15356	esac
15357	case "$getprotoent_r_proto" in
15358	''|0) try='struct protoent* getprotoent_r(struct protoent*, char*, int);'
15359	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=S_SBI ;;
15360	esac
15361	case "$getprotoent_r_proto" in
15362	''|0) try='int getprotoent_r(struct protoent*, struct protoent_data*);'
15363	./protochk "$extern_C $try" $hdrs && getprotoent_r_proto=I_SD ;;
15364	esac
15365	case "$getprotoent_r_proto" in
15366	''|0)	d_getprotoent_r=undef
15367		getprotoent_r_proto=0
15368		echo "Disabling getprotoent_r, cannot determine prototype." >&4 ;;
15369	* )	case "$getprotoent_r_proto" in
15370		REENTRANT_PROTO*) ;;
15371		*) getprotoent_r_proto="REENTRANT_PROTO_$getprotoent_r_proto" ;;
15372		esac
15373		echo "Prototype: $try" ;;
15374	esac
15375	;;
15376	*)	case "$usethreads" in
15377		define) echo "getprotoent_r has no prototype, not using it." >&4 ;;
15378		esac
15379		d_getprotoent_r=undef
15380		getprotoent_r_proto=0
15381		;;
15382	esac
15383	;;
15384*)	getprotoent_r_proto=0
15385	;;
15386esac
15387
15388: see if prototypes for various getprotoxxx netdb.h functions are available
15389echo " "
15390set d_getprotoprotos getprotoent $i_netdb netdb.h
15391eval $hasproto
15392
15393: see if getprpwnam exists
15394set getprpwnam d_getprpwnam
15395eval $inlibc
15396
15397: see if getpwent exists
15398set getpwent d_getpwent
15399eval $inlibc
15400
15401: see if getpwent_r exists
15402set getpwent_r d_getpwent_r
15403eval $inlibc
15404case "$d_getpwent_r" in
15405"$define")
15406	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
15407	case "$d_getpwent_r_proto:$usethreads" in
15408	":define")	d_getpwent_r_proto=define
15409		set d_getpwent_r_proto getpwent_r $hdrs
15410		eval $hasproto ;;
15411	*)	;;
15412	esac
15413	case "$d_getpwent_r_proto" in
15414	define)
15415	case "$getpwent_r_proto" in
15416	''|0) try='int getpwent_r(struct passwd*, char*, size_t, struct passwd**);'
15417	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBWR ;;
15418	esac
15419	case "$getpwent_r_proto" in
15420	''|0) try='int getpwent_r(struct passwd*, char*, int, struct passwd**);'
15421	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIR ;;
15422	esac
15423	case "$getpwent_r_proto" in
15424	''|0) try='struct passwd* getpwent_r(struct passwd*, char*, size_t);'
15425	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBW ;;
15426	esac
15427	case "$getpwent_r_proto" in
15428	''|0) try='struct passwd* getpwent_r(struct passwd*, char*, int);'
15429	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=S_SBI ;;
15430	esac
15431	case "$getpwent_r_proto" in
15432	''|0) try='int getpwent_r(struct passwd*, char*, int);'
15433	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBI ;;
15434	esac
15435	case "$getpwent_r_proto" in
15436	''|0) try='int getpwent_r(struct passwd*, char*, int, FILE**);'
15437	./protochk "$extern_C $try" $hdrs && getpwent_r_proto=I_SBIH ;;
15438	esac
15439	case "$getpwent_r_proto" in
15440	''|0)	d_getpwent_r=undef
15441		getpwent_r_proto=0
15442		echo "Disabling getpwent_r, cannot determine prototype." >&4 ;;
15443	* )	case "$getpwent_r_proto" in
15444		REENTRANT_PROTO*) ;;
15445		*) getpwent_r_proto="REENTRANT_PROTO_$getpwent_r_proto" ;;
15446		esac
15447		echo "Prototype: $try" ;;
15448	esac
15449	;;
15450	*)	case "$usethreads" in
15451		define) echo "getpwent_r has no prototype, not using it." >&4 ;;
15452		esac
15453		d_getpwent_r=undef
15454		getpwent_r_proto=0
15455		;;
15456	esac
15457	;;
15458*)	getpwent_r_proto=0
15459	;;
15460esac
15461
15462: see if getpwnam_r exists
15463set getpwnam_r d_getpwnam_r
15464eval $inlibc
15465case "$d_getpwnam_r" in
15466"$define")
15467	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
15468	case "$d_getpwnam_r_proto:$usethreads" in
15469	":define")	d_getpwnam_r_proto=define
15470		set d_getpwnam_r_proto getpwnam_r $hdrs
15471		eval $hasproto ;;
15472	*)	;;
15473	esac
15474	case "$d_getpwnam_r_proto" in
15475	define)
15476	case "$getpwnam_r_proto" in
15477	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);'
15478	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBWR ;;
15479	esac
15480	case "$getpwnam_r_proto" in
15481	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int, struct passwd**);'
15482	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBIR ;;
15483	esac
15484	case "$getpwnam_r_proto" in
15485	''|0) try='struct passwd* getpwnam_r(const char*, struct passwd*, char*, int);'
15486	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=S_CSBI ;;
15487	esac
15488	case "$getpwnam_r_proto" in
15489	''|0) try='int getpwnam_r(const char*, struct passwd*, char*, int);'
15490	./protochk "$extern_C $try" $hdrs && getpwnam_r_proto=I_CSBI ;;
15491	esac
15492	case "$getpwnam_r_proto" in
15493	''|0)	d_getpwnam_r=undef
15494		getpwnam_r_proto=0
15495		echo "Disabling getpwnam_r, cannot determine prototype." >&4 ;;
15496	* )	case "$getpwnam_r_proto" in
15497		REENTRANT_PROTO*) ;;
15498		*) getpwnam_r_proto="REENTRANT_PROTO_$getpwnam_r_proto" ;;
15499		esac
15500		echo "Prototype: $try" ;;
15501	esac
15502	;;
15503	*)	case "$usethreads" in
15504		define) echo "getpwnam_r has no prototype, not using it." >&4 ;;
15505		esac
15506		d_getpwnam_r=undef
15507		getpwnam_r_proto=0
15508		;;
15509	esac
15510	;;
15511*)	getpwnam_r_proto=0
15512	;;
15513esac
15514
15515: see if getpwuid_r exists
15516set getpwuid_r d_getpwuid_r
15517eval $inlibc
15518case "$d_getpwuid_r" in
15519"$define")
15520	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
15521	case "$d_getpwuid_r_proto:$usethreads" in
15522	":define")	d_getpwuid_r_proto=define
15523		set d_getpwuid_r_proto getpwuid_r $hdrs
15524		eval $hasproto ;;
15525	*)	;;
15526	esac
15527	case "$d_getpwuid_r_proto" in
15528	define)
15529	case "$getpwuid_r_proto" in
15530	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);'
15531	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBWR ;;
15532	esac
15533	case "$getpwuid_r_proto" in
15534	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int, struct passwd**);'
15535	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBIR ;;
15536	esac
15537	case "$getpwuid_r_proto" in
15538	''|0) try='int getpwuid_r(uid_t, struct passwd*, char*, int);'
15539	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=I_TSBI ;;
15540	esac
15541	case "$getpwuid_r_proto" in
15542	''|0) try='struct passwd* getpwuid_r(uid_t, struct passwd*, char*, int);'
15543	./protochk "$extern_C $try" $hdrs && getpwuid_r_proto=S_TSBI ;;
15544	esac
15545	case "$getpwuid_r_proto" in
15546	''|0)	d_getpwuid_r=undef
15547		getpwuid_r_proto=0
15548		echo "Disabling getpwuid_r, cannot determine prototype." >&4 ;;
15549	* )	case "$getpwuid_r_proto" in
15550		REENTRANT_PROTO*) ;;
15551		*) getpwuid_r_proto="REENTRANT_PROTO_$getpwuid_r_proto" ;;
15552		esac
15553		echo "Prototype: $try" ;;
15554	esac
15555	;;
15556	*)	case "$usethreads" in
15557		define) echo "getpwuid_r has no prototype, not using it." >&4 ;;
15558		esac
15559		d_getpwuid_r=undef
15560		getpwuid_r_proto=0
15561		;;
15562	esac
15563	;;
15564*)	getpwuid_r_proto=0
15565	;;
15566esac
15567
15568: Optional checks for getsbyname and getsbyport
15569
15570: see if getservbyname exists
15571set getservbyname d_getsbyname
15572eval $inlibc
15573
15574: see if getservbyport exists
15575set getservbyport d_getsbyport
15576eval $inlibc
15577
15578: see if getservent exists
15579set getservent d_getsent
15580eval $inlibc
15581
15582: see if getservbyname_r exists
15583set getservbyname_r d_getservbyname_r
15584eval $inlibc
15585case "$d_getservbyname_r" in
15586"$define")
15587	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15588	case "$d_getservbyname_r_proto:$usethreads" in
15589	":define")	d_getservbyname_r_proto=define
15590		set d_getservbyname_r_proto getservbyname_r $hdrs
15591		eval $hasproto ;;
15592	*)	;;
15593	esac
15594	case "$d_getservbyname_r_proto" in
15595	define)
15596	case "$getservbyname_r_proto" in
15597	''|0) try='int getservbyname_r(const char*, const char*, struct servent*, char*, size_t, struct servent**);'
15598	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSBWR ;;
15599	esac
15600	case "$getservbyname_r_proto" in
15601	''|0) try='struct servent* getservbyname_r(const char*, const char*, struct servent*, char*, int);'
15602	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=S_CCSBI ;;
15603	esac
15604	case "$getservbyname_r_proto" in
15605	''|0) try='int getservbyname_r(const char*, const char*, struct servent*, struct servent_data*);'
15606	./protochk "$extern_C $try" $hdrs && getservbyname_r_proto=I_CCSD ;;
15607	esac
15608	case "$getservbyname_r_proto" in
15609	''|0)	d_getservbyname_r=undef
15610		getservbyname_r_proto=0
15611		echo "Disabling getservbyname_r, cannot determine prototype." >&4 ;;
15612	* )	case "$getservbyname_r_proto" in
15613		REENTRANT_PROTO*) ;;
15614		*) getservbyname_r_proto="REENTRANT_PROTO_$getservbyname_r_proto" ;;
15615		esac
15616		echo "Prototype: $try" ;;
15617	esac
15618	;;
15619	*)	case "$usethreads" in
15620		define) echo "getservbyname_r has no prototype, not using it." >&4 ;;
15621		esac
15622		d_getservbyname_r=undef
15623		getservbyname_r_proto=0
15624		;;
15625	esac
15626	;;
15627*)	getservbyname_r_proto=0
15628	;;
15629esac
15630
15631: see if getservbyport_r exists
15632set getservbyport_r d_getservbyport_r
15633eval $inlibc
15634case "$d_getservbyport_r" in
15635"$define")
15636	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15637	case "$d_getservbyport_r_proto:$usethreads" in
15638	":define")	d_getservbyport_r_proto=define
15639		set d_getservbyport_r_proto getservbyport_r $hdrs
15640		eval $hasproto ;;
15641	*)	;;
15642	esac
15643	case "$d_getservbyport_r_proto" in
15644	define)
15645	case "$getservbyport_r_proto" in
15646	''|0) try='int getservbyport_r(int, const char*, struct servent*, char*, size_t, struct servent**);'
15647	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSBWR ;;
15648	esac
15649	case "$getservbyport_r_proto" in
15650	''|0) try='struct servent* getservbyport_r(int, const char*, struct servent*, char*, int);'
15651	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=S_ICSBI ;;
15652	esac
15653	case "$getservbyport_r_proto" in
15654	''|0) try='int getservbyport_r(int, const char*, struct servent*, struct servent_data*);'
15655	./protochk "$extern_C $try" $hdrs && getservbyport_r_proto=I_ICSD ;;
15656	esac
15657	case "$getservbyport_r_proto" in
15658	''|0)	d_getservbyport_r=undef
15659		getservbyport_r_proto=0
15660		echo "Disabling getservbyport_r, cannot determine prototype." >&4 ;;
15661	* )	case "$getservbyport_r_proto" in
15662		REENTRANT_PROTO*) ;;
15663		*) getservbyport_r_proto="REENTRANT_PROTO_$getservbyport_r_proto" ;;
15664		esac
15665		echo "Prototype: $try" ;;
15666	esac
15667	;;
15668	*)	case "$usethreads" in
15669		define) echo "getservbyport_r has no prototype, not using it." >&4 ;;
15670		esac
15671		d_getservbyport_r=undef
15672		getservbyport_r_proto=0
15673		;;
15674	esac
15675	;;
15676*)	getservbyport_r_proto=0
15677	;;
15678esac
15679
15680: see if getservent_r exists
15681set getservent_r d_getservent_r
15682eval $inlibc
15683case "$d_getservent_r" in
15684"$define")
15685	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
15686	case "$d_getservent_r_proto:$usethreads" in
15687	":define")	d_getservent_r_proto=define
15688		set d_getservent_r_proto getservent_r $hdrs
15689		eval $hasproto ;;
15690	*)	;;
15691	esac
15692	case "$d_getservent_r_proto" in
15693	define)
15694	case "$getservent_r_proto" in
15695	''|0) try='int getservent_r(struct servent*, char*, size_t, struct servent**);'
15696	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBWR ;;
15697	esac
15698	case "$getservent_r_proto" in
15699	''|0) try='int getservent_r(struct servent*, char*, int);'
15700	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SBI ;;
15701	esac
15702	case "$getservent_r_proto" in
15703	''|0) try='struct servent* getservent_r(struct servent*, char*, int);'
15704	./protochk "$extern_C $try" $hdrs && getservent_r_proto=S_SBI ;;
15705	esac
15706	case "$getservent_r_proto" in
15707	''|0) try='int getservent_r(struct servent*, struct servent_data*);'
15708	./protochk "$extern_C $try" $hdrs && getservent_r_proto=I_SD ;;
15709	esac
15710	case "$getservent_r_proto" in
15711	''|0)	d_getservent_r=undef
15712		getservent_r_proto=0
15713		echo "Disabling getservent_r, cannot determine prototype." >&4 ;;
15714	* )	case "$getservent_r_proto" in
15715		REENTRANT_PROTO*) ;;
15716		*) getservent_r_proto="REENTRANT_PROTO_$getservent_r_proto" ;;
15717		esac
15718		echo "Prototype: $try" ;;
15719	esac
15720	;;
15721	*)	case "$usethreads" in
15722		define) echo "getservent_r has no prototype, not using it." >&4 ;;
15723		esac
15724		d_getservent_r=undef
15725		getservent_r_proto=0
15726		;;
15727	esac
15728	;;
15729*)	getservent_r_proto=0
15730	;;
15731esac
15732
15733: see if prototypes for various getservxxx netdb.h functions are available
15734echo " "
15735set d_getservprotos getservent $i_netdb netdb.h
15736eval $hasproto
15737
15738: see if getspnam exists
15739set getspnam d_getspnam
15740eval $inlibc
15741
15742: see if this is a shadow.h system
15743set shadow.h i_shadow
15744eval $inhdr
15745
15746: see if getspnam_r exists
15747set getspnam_r d_getspnam_r
15748eval $inlibc
15749case "$d_getspnam_r" in
15750"$define")
15751	hdrs="$i_systypes sys/types.h define stdio.h $i_shadow shadow.h"
15752	case "$d_getspnam_r_proto:$usethreads" in
15753	":define")	d_getspnam_r_proto=define
15754		set d_getspnam_r_proto getspnam_r $hdrs
15755		eval $hasproto ;;
15756	*)	;;
15757	esac
15758	case "$d_getspnam_r_proto" in
15759	define)
15760	case "$getspnam_r_proto" in
15761	''|0) try='int getspnam_r(const char*, struct spwd*, char*, size_t, struct spwd**);'
15762	./protochk "$extern_C $try" $hdrs && getspnam_r_proto=I_CSBWR ;;
15763	esac
15764	case "$getspnam_r_proto" in
15765	''|0) try='struct spwd* getspnam_r(const char*, struct spwd*, char*, int);'
15766	./protochk "$extern_C $try" $hdrs && getspnam_r_proto=S_CSBI ;;
15767	esac
15768	case "$getspnam_r_proto" in
15769	''|0)	d_getspnam_r=undef
15770		getspnam_r_proto=0
15771		echo "Disabling getspnam_r, cannot determine prototype." >&4 ;;
15772	* )	case "$getspnam_r_proto" in
15773		REENTRANT_PROTO*) ;;
15774		*) getspnam_r_proto="REENTRANT_PROTO_$getspnam_r_proto" ;;
15775		esac
15776		echo "Prototype: $try" ;;
15777	esac
15778	;;
15779	*)	case "$usethreads" in
15780		define) echo "getspnam_r has no prototype, not using it." >&4 ;;
15781		esac
15782		d_getspnam_r=undef
15783		getspnam_r_proto=0
15784		;;
15785	esac
15786	;;
15787*)	getspnam_r_proto=0
15788	;;
15789esac
15790
15791: see if gettimeofday or ftime exists
15792set gettimeofday d_gettimeod
15793eval $inlibc
15794case "$d_gettimeod" in
15795"$undef")
15796	set ftime d_ftime 
15797	eval $inlibc
15798	;;
15799*)
15800	val="$undef"; set d_ftime; eval $setvar
15801	;;
15802esac
15803case "$d_gettimeod$d_ftime" in
15804"$undef$undef")
15805	echo " "
15806	echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
15807	;;
15808esac
15809
15810: see if gmtime_r exists
15811set gmtime_r d_gmtime_r
15812eval $inlibc
15813case "$d_gmtime_r" in
15814"$define")
15815	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
15816	case "$d_gmtime_r_proto:$usethreads" in
15817	":define")	d_gmtime_r_proto=define
15818		set d_gmtime_r_proto gmtime_r $hdrs
15819		eval $hasproto ;;
15820	*)	;;
15821	esac
15822	case "$d_gmtime_r_proto" in
15823	define)
15824	case "$gmtime_r_proto" in
15825	''|0) try='struct tm* gmtime_r(const time_t*, struct tm*);'
15826	./protochk "$extern_C $try" $hdrs && gmtime_r_proto=S_TS ;;
15827	esac
15828	case "$gmtime_r_proto" in
15829	''|0) try='int gmtime_r(const time_t*, struct tm*);'
15830	./protochk "$extern_C $try" $hdrs && gmtime_r_proto=I_TS ;;
15831	esac
15832	case "$gmtime_r_proto" in
15833	''|0)	d_gmtime_r=undef
15834		gmtime_r_proto=0
15835		echo "Disabling gmtime_r, cannot determine prototype." >&4 ;;
15836	* )	case "$gmtime_r_proto" in
15837		REENTRANT_PROTO*) ;;
15838		*) gmtime_r_proto="REENTRANT_PROTO_$gmtime_r_proto" ;;
15839		esac
15840		echo "Prototype: $try" ;;
15841	esac
15842	;;
15843	*)	case "$usethreads" in
15844		define) echo "gmtime_r has no prototype, not using it." >&4 ;;
15845		esac
15846		d_gmtime_r=undef
15847		gmtime_r_proto=0
15848		;;
15849	esac
15850	;;
15851*)	gmtime_r_proto=0
15852	;;
15853esac
15854
15855: see if hasmntopt exists
15856set hasmntopt d_hasmntopt
15857eval $inlibc
15858
15859: see if this is a netinet/in.h or sys/in.h system
15860set netinet/in.h i_niin sys/in.h i_sysin
15861eval $inhdr
15862
15863: see if arpa/inet.h has to be included
15864set arpa/inet.h i_arpainet
15865eval $inhdr
15866
15867: see if htonl --and friends-- exists
15868val=''
15869set htonl val
15870eval $inlibc
15871
15872: Maybe they are macros.
15873case "$val" in
15874$undef)
15875	$cat >htonl.c <<EOM
15876#include <stdio.h>
15877#include <sys/types.h>
15878#$i_niin I_NETINET_IN
15879#$i_sysin I_SYS_IN
15880#$i_arpainet I_ARPA_INET
15881#ifdef I_NETINET_IN
15882#include <netinet/in.h>
15883#endif
15884#ifdef I_SYS_IN
15885#include <sys/in.h>
15886#endif
15887#ifdef I_ARPA_INET
15888#include <arpa/inet.h>
15889#endif
15890#ifdef htonl
15891printf("Defined as a macro.");
15892#endif
15893EOM
15894	$cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
15895	if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
15896		val="$define"
15897		echo "But it seems to be defined as a macro." >&4
15898	fi
15899	$rm -f htonl.?
15900	;;
15901esac
15902set d_htonl
15903eval $setvar
15904
15905: see if hypot exists
15906set hypot d_hypot
15907eval $inlibc
15908
15909: see if ilogb exists
15910set ilogb d_ilogb
15911eval $inlibc
15912
15913: see if ilogbl exists
15914set ilogbl d_ilogbl
15915eval $inlibc
15916
15917: check whether inet_aton exists
15918set inet_aton d_inetaton
15919eval $inlibc
15920
15921: see if inet_ntop exists
15922set inet_ntop d_inetntop
15923eval $inlibc
15924
15925: see if inet_pton exists
15926set inet_pton d_inetpton
15927eval $inlibc
15928
15929: Look for isascii
15930echo " "
15931$cat >isascii.c <<EOCP
15932#include <stdio.h>
15933#include <ctype.h>
15934#$i_stdlib I_STDLIB
15935#ifdef I_STDLIB
15936#include <stdlib.h>
15937#endif
15938int main() {
15939	int c = 'A';
15940	if (isascii(c))
15941		exit(0);
15942	else
15943		exit(1);
15944}
15945EOCP
15946set isascii
15947if eval $compile; then
15948	echo "isascii() found." >&4
15949	val="$define"
15950else
15951	echo "isascii() NOT found." >&4
15952	val="$undef"
15953fi
15954set d_isascii
15955eval $setvar
15956$rm -f isascii*
15957
15958: Look for isblank
15959echo " "
15960$cat >isblank.c <<'EOCP'
15961#include <stdio.h>
15962#include <ctype.h>
15963int main() {
15964	int c = ' ';
15965	if (isblank(c))
15966		return 0 ;
15967	else
15968		return 1 ;
15969}
15970EOCP
15971if $cc $ccflags $ldflags -o isblank isblank.c $libs >/dev/null 2>&1 ; then
15972	echo "isblank() found." >&4
15973	val="$define"
15974else
15975	echo "isblank() NOT found." >&4
15976	val="$undef"
15977fi
15978set d_isblank
15979eval $setvar
15980$rm -f isblank*
15981
15982: check for isfinite
15983echo "Checking to see if you have isfinite..." >&4
15984$cat >try.c <<EOCP
15985#include <math.h>
15986int main() { return isfinite(0.0); }
15987EOCP
15988set try
15989if eval $compile; then
15990	val="$define"
15991	echo "You have isfinite."
15992else
15993	val="$undef"
15994	echo "You do not have isfinite."
15995fi
15996$rm_try
15997set d_isfinite
15998eval $setvar
15999
16000: see if isfinitel exists
16001set isfinitel d_isfinitel
16002eval $inlibc
16003
16004: check for isinf
16005echo "Checking to see if you have isinf..." >&4
16006$cat >try.c <<EOCP
16007#include <math.h>
16008int main() { return isinf(0.0); }
16009EOCP
16010set try
16011if eval $compile; then
16012	val="$define"
16013	echo "You have isinf."
16014else
16015	val="$undef"
16016	echo "You do not have isinf."
16017fi
16018$rm_try
16019set d_isinf
16020eval $setvar
16021
16022: see if isinfl exists
16023set isinfl d_isinfl
16024eval $inlibc
16025
16026: check for isless
16027echo "Checking to see if you have isless..." >&4
16028$cat >try.c <<EOCP
16029#include <math.h>
16030int main() { return isless(2.0, 1.0); }
16031EOCP
16032set try
16033if eval $compile; then
16034	val="$define"
16035	echo "You have isless."
16036else
16037	val="$undef"
16038	echo "You do not have isless."
16039fi
16040$rm_try
16041set d_isless
16042eval $setvar
16043
16044: check for isnan
16045echo "Checking to see if you have isnan..." >&4
16046$cat >try.c <<EOCP
16047#include <math.h>
16048int main() { return isnan(0.0); }
16049EOCP
16050set try
16051if eval $compile; then
16052	val="$define"
16053	echo "You have isnan."
16054else
16055	val="$undef"
16056	echo "You do not have isnan."
16057fi
16058$rm_try
16059set d_isnan
16060eval $setvar
16061
16062: see if isnanl exists
16063set isnanl d_isnanl
16064eval $inlibc
16065
16066: check for isnormal
16067echo "Checking to see if you have isnormal..." >&4
16068$cat >try.c <<EOCP
16069#include <math.h>
16070int main() { return isnormal(0.0); }
16071EOCP
16072set try
16073if eval $compile; then
16074	val="$define"
16075	echo "You have isnormal."
16076else
16077	val="$undef"
16078	echo "You do not have isnormal."
16079fi
16080$rm_try
16081set d_isnormal
16082eval $setvar
16083
16084: see if j0 exists
16085set j0 d_j0
16086eval $inlibc
16087
16088: see if j0l exists
16089set j0l d_j0l
16090eval $inlibc
16091
16092: see if killpg exists
16093set killpg d_killpg
16094eval $inlibc
16095
16096: see if localeconv exists
16097set localeconv d_locconv
16098eval $inlibc
16099
16100: see if libc has the POSIX.1-2008 currency locale rules
16101case "$d_locconv:$d_lc_monetary_2008" in
16102$define:)
16103	$cat >try.c <<EOCP
16104#include <locale.h>
16105int main() {
16106	struct lconv *lc = localeconv();
16107	char int_p_cs_precedes = lc->int_p_cs_precedes;
16108	return 0;
16109}
16110EOCP
16111	set try
16112	if eval $compile; then
16113		d_lc_monetary_2008="$define"
16114	else
16115		d_lc_monetary_2008="$undef"
16116	fi;
16117	$rm_try
16118	;;
16119esac
16120
16121: see if lchown exists
16122echo " "
16123$cat > try.c <<EOCP
16124#include <pwd.h>
16125#include <stdio.h>
16126#include <stdlib.h>
16127#$i_unistd	I_UNISTD
16128#ifdef I_UNISTD
16129#  include <unistd.h>
16130#endif
16131int main(int argc, char *argv[])
16132{
16133   if (lchown("./try.c", -1, getgid()) == -1) {
16134       exit(EXIT_FAILURE);
16135   }
16136   exit(EXIT_SUCCESS);
16137}
16138EOCP
16139set try
16140if eval $compile && ./try; then
16141    $echo "lchown() found." >&4
16142    val="$define"
16143else
16144    $echo "lchown() NOT found." >&4
16145    val="$undef"
16146fi
16147set d_lchown
16148eval $setvar
16149$rm_try
16150
16151: See if number of significant digits in a double precision number is known
16152echo " "
16153$cat >ldbl_dig.c <<EOM
16154#include <limits.h>
16155#include <float.h>
16156#ifdef LDBL_DIG
16157printf("Contains LDBL_DIG");
16158#endif
16159EOM
16160$cppstdin $cppflags $cppminus < ldbl_dig.c >ldbl_dig.E 2>/dev/null
16161if $contains 'LDBL_DIG' ldbl_dig.E >/dev/null 2>&1; then
16162	echo "LDBL_DIG found." >&4
16163	val="$define"
16164else
16165	echo "LDBL_DIG NOT found." >&4
16166	val="$undef"
16167fi
16168$rm -f ldbl_dig.?
16169set d_ldbl_dig
16170eval $setvar
16171
16172: see if lgamma exists
16173set lgamma d_lgamma
16174eval $inlibc
16175
16176: see if lgamma_r exists
16177set lgamma_r d_lgamma_r
16178eval $inlibc
16179
16180: check to see if math.h defines _LIB_VERSION
16181d_libm_lib_version="$undef"
16182echo " "
16183echo "Checking to see if your libm supports _LIB_VERSION..." >&4
16184$cat >try.c <<EOCP
16185#include <unistd.h>
16186#include <math.h>
16187#include <stdio.h>
16188int main (int argc, char *argv[])
16189{
16190    printf ("%d\n", _LIB_VERSION);
16191    return (0);
16192    } /* main */
16193EOCP
16194set try
16195if eval $compile; then
16196    foo=`$run ./try`
16197    echo "Yes, it does ($foo)" >&4
16198    d_libm_lib_version="$define"
16199else
16200    echo "No, it does not (probably harmless)" >&4
16201    fi
16202$rm_try
16203
16204: see if link exists
16205set link d_link
16206eval $inlibc
16207
16208: see if llrint exists
16209set llrint d_llrint
16210eval $inlibc
16211
16212: see if llrintl exists
16213set llrintl d_llrintl
16214eval $inlibc
16215
16216: see if llround exists
16217set llround d_llround
16218eval $inlibc
16219
16220: see if llroundl exists
16221set llroundl d_llroundl
16222eval $inlibc
16223
16224: see if malloc/malloc.h has to be included
16225set malloc/malloc.h i_mallocmalloc
16226eval $inhdr
16227
16228: see if this is a malloc.h system
16229: we want a real compile instead of Inhdr because some systems have a
16230: malloc.h that just gives a compile error saying to use stdlib.h instead
16231echo " "
16232$cat >try.c <<EOCP
16233#include <stdlib.h>
16234#include <malloc.h>
16235#$i_mallocmalloc I_MALLOCMALLOC
16236#ifdef I_MALLOCMALLOC
16237# include <malloc/malloc.h>
16238#endif
16239
16240int main () { return 0; }
16241EOCP
16242set try
16243if eval $compile; then
16244    echo "<malloc.h> found." >&4
16245    val="$define"
16246else
16247    echo "<malloc.h> NOT found." >&4
16248    val="$undef"
16249fi
16250$rm_try
16251set i_malloc
16252eval $setvar
16253
16254: see if localtime_r exists
16255set localtime_r d_localtime_r
16256eval $inlibc
16257case "$d_localtime_r" in
16258"$define")
16259	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
16260	case "$d_localtime_r_proto:$usethreads" in
16261	":define")	d_localtime_r_proto=define
16262		set d_localtime_r_proto localtime_r $hdrs
16263		eval $hasproto ;;
16264	*)	;;
16265	esac
16266	case "$d_localtime_r_proto" in
16267	define)
16268	case "$localtime_r_proto" in
16269	''|0) try='struct tm* localtime_r(const time_t*, struct tm*);'
16270	./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;;
16271	esac
16272	case "$localtime_r_proto" in
16273	''|0) try='int localtime_r(const time_t*, struct tm*);'
16274	./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;;
16275	esac
16276	case "$localtime_r_proto" in
16277	''|0)	d_localtime_r=undef
16278		localtime_r_proto=0
16279		echo "Disabling localtime_r, cannot determine prototype." >&4 ;;
16280	* )	case "$localtime_r_proto" in
16281		REENTRANT_PROTO*) ;;
16282		*) localtime_r_proto="REENTRANT_PROTO_$localtime_r_proto" ;;
16283		esac
16284		echo "Prototype: $try" ;;
16285	esac
16286	;;
16287	*)	case "$usethreads" in
16288		define) echo "localtime_r has no prototype, not using it." >&4 ;;
16289		esac
16290		d_localtime_r=undef
16291		localtime_r_proto=0
16292		;;
16293	esac
16294	;;
16295*)	localtime_r_proto=0
16296	;;
16297esac
16298
16299: see if localtime_r calls tzset
16300case "$localtime_r_proto" in
16301REENTRANT_PROTO*)
16302	$cat >try.c <<EOCP
16303/*  Does our libc's localtime_r call tzset ?
16304 *  return 0 if so, 1 otherwise.
16305 */
16306#$i_systypes	I_SYS_TYPES
16307#$i_unistd	I_UNISTD
16308#$i_time	I_TIME
16309#$i_stdlib	I_STDLIB
16310#$i_malloc	I_MALLOC
16311#ifdef I_SYS_TYPES
16312#  include <sys/types.h>
16313#endif
16314#ifdef I_UNISTD
16315#  include <unistd.h>
16316#endif
16317#ifdef I_TIME
16318#  include <time.h>
16319#endif
16320#ifdef I_STDLIB
16321#include <stdlib.h>
16322#endif
16323#include <string.h>
16324#ifdef I_MALLOC
16325#  include <malloc.h>
16326#endif
16327int main()
16328{
16329    int result = 0;
16330    time_t t = time(0L);
16331    char w_tz[]="TZ" "=GMT+5",
16332	 e_tz[]="TZ" "=GMT-5",
16333	*tz_e = (char*)malloc(16),
16334	*tz_w = (char*)malloc(16);
16335    struct tm tm_e, tm_w;
16336    memset(&tm_e,'\0',sizeof(struct tm));
16337    memset(&tm_w,'\0',sizeof(struct tm));
16338    strcpy(tz_e,e_tz);
16339    strcpy(tz_w,w_tz);
16340
16341    putenv(tz_e);
16342    localtime_r(&t, &tm_e);
16343
16344    putenv(tz_w);
16345    localtime_r(&t, &tm_w);
16346
16347    if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
16348	result = 1;
16349
16350    free(tz_e);free(tz_w);
16351    return result;
16352}
16353EOCP
16354	set try
16355	if eval $compile; then
16356	    if $run ./try; then
16357		d_localtime_r_needs_tzset=undef;
16358	    else
16359		d_localtime_r_needs_tzset=define;
16360	    fi;
16361	else
16362	    d_localtime_r_needs_tzset=undef;
16363	fi;
16364     ;;
16365  *)
16366     d_localtime_r_needs_tzset=undef;
16367     ;;
16368esac
16369$rm_try
16370
16371: see if lockf exists
16372set lockf d_lockf
16373eval $inlibc
16374
16375: see if log1p exists
16376set log1p d_log1p
16377eval $inlibc
16378
16379: see if log2 exists
16380set log2 d_log2
16381eval $inlibc
16382
16383: see if logb exists
16384set logb d_logb
16385eval $inlibc
16386
16387: see if lrint exists
16388set lrint d_lrint
16389eval $inlibc
16390
16391: see if lrintl exists
16392set lrintl d_lrintl
16393eval $inlibc
16394
16395: see if lround exists
16396set lround d_lround
16397eval $inlibc
16398
16399: see if lroundl exists
16400set lroundl d_lroundl
16401eval $inlibc
16402
16403: see if prototype for lseek is available
16404echo " "
16405set d_lseekproto lseek $i_systypes sys/types.h $i_unistd unistd.h
16406eval $hasproto
16407
16408: see if lstat exists
16409set lstat d_lstat
16410eval $inlibc
16411
16412: see if madvise exists
16413set madvise d_madvise
16414eval $inlibc
16415
16416: see if malloc_size exists
16417set malloc_size d_malloc_size
16418eval $inlibc
16419
16420: see if malloc_size_good exists
16421set malloc_good_size d_malloc_good_size
16422eval $inlibc
16423
16424: see if malloc_usable_size exists
16425set malloc_usable_size d_malloc_usable_size
16426eval $inlibc
16427
16428: see if mblen exists
16429set mblen d_mblen
16430eval $inlibc
16431
16432: see if mbrlen exists
16433set mbrlen d_mbrlen
16434eval $inlibc
16435
16436: see if mbrtowc exists
16437set mbrtowc d_mbrtowc
16438eval $inlibc
16439
16440: see if mbstowcs exists
16441set mbstowcs d_mbstowcs
16442eval $inlibc
16443
16444: see if mbtowc exists
16445set mbtowc d_mbtowc
16446eval $inlibc
16447
16448: see if memmem exists
16449: We need both a prototype in string.h and the symbol in libc.
16450echo " "
16451d_memmem_proto=''
16452xx1="#$d_gnulibc HAS_GNULIBC"
16453xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
16454xx3='#   define _GNU_SOURCE'
16455xx4='#endif'
16456set d_memmem_proto memmem literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
16457eval $hasproto
16458case "$d_memmem_proto" in
16459    define) # see if memmem exists
16460	set memmem d_memmem
16461	eval $inlibc
16462	;;
16463    *)  val=$undef
16464	set d_memmem
16465	eval $setvar
16466	;;
16467esac
16468
16469: see if memrchr exists
16470: We need both a prototype in string.h and the symbol in libc.
16471echo " "
16472d_memrchr_proto=''
16473xx1="#$d_gnulibc HAS_GNULIBC"
16474xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
16475xx3='#   define _GNU_SOURCE'
16476xx4='#endif'
16477set d_memrchr_proto memrchr literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
16478eval $hasproto
16479case "$d_memrchr_proto" in
16480    define) # see if memrchr exists
16481	set memrchr d_memrchr
16482	eval $inlibc
16483	;;
16484    *)  val=$undef
16485	set d_memrchr
16486	eval $setvar
16487	;;
16488esac
16489
16490: see if mkdir exists
16491set mkdir d_mkdir
16492eval $inlibc
16493
16494: see if mkdtemp exists
16495set mkdtemp d_mkdtemp
16496eval $inlibc
16497
16498: see if mkfifo exists
16499set mkfifo d_mkfifo
16500eval $inlibc
16501
16502: see if mkostemp exists
16503set mkostemp d_mkostemp
16504eval $inlibc
16505
16506: see if mkstemp exists
16507set mkstemp d_mkstemp
16508eval $inlibc
16509
16510: see if mkstemps exists
16511set mkstemps d_mkstemps
16512eval $inlibc
16513
16514: see if mktime exists
16515set mktime d_mktime
16516eval $inlibc
16517
16518: see if sys/mman.h has to be included
16519set sys/mman.h i_sysmman
16520eval $inhdr
16521
16522: see if mmap exists
16523set mmap d_mmap
16524eval $inlibc
16525: see what shmat returns
16526: default to something harmless
16527mmaptype='void *'
16528case "$i_sysmman$d_mmap" in
16529"$define$define")
16530	$cat >mmap.c <<'END'
16531#include <sys/mman.h>
16532void *mmap();
16533END
16534	if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
16535		mmaptype='void *'
16536	else
16537		mmaptype='caddr_t'
16538	fi
16539	echo "and it returns ($mmaptype)." >&4
16540	;;
16541esac
16542
16543: see if sqrtl exists
16544set sqrtl d_sqrtl
16545eval $inlibc
16546
16547: see if scalbnl exists
16548set scalbnl d_scalbnl
16549eval $inlibc
16550
16551: see if truncl exists
16552set truncl d_truncl
16553eval $inlibc
16554
16555: see if modfl exists
16556set modfl d_modfl
16557eval $inlibc
16558
16559: see if prototype for modfl is available
16560echo " "
16561set d_modflproto modfl define math.h
16562eval $hasproto
16563
16564if $test "$uselongdouble" = "$define"; then
16565    message=""
16566    if $test "$d_sqrtl" != "$define"; then
16567	message="$message sqrtl"
16568    fi
16569    if $test "$d_modfl" != "$define"; then
16570	if $test "$d_truncl:$d_copysignl" = "$define:$define"; then
16571	    echo "You have both truncl and copysignl, so I can emulate modfl."
16572	else
16573	    if $test "$d_aintl:$d_copysignl" = "$define:$define"; then
16574		echo "You have both aintl and copysignl, so I can emulate modfl."
16575	    else
16576		message="$message modfl"
16577	    fi
16578	fi
16579    fi
16580    if $test "$d_frexpl" != "$define"; then
16581	if $test "$d_ilogbl:$d_scalbnl" = "$define:$define"; then
16582	    echo "You have both ilogbl and scalbnl, so I can emulate frexpl."
16583	else
16584	    message="$message frexpl"
16585	fi
16586    fi
16587    if $test "$d_ldexpl" != "$define"; then
16588	message="$message ldexpl"
16589    fi
16590
16591    if $test "$message" != ""; then
16592	$cat <<EOM >&4
16593
16594*** You requested the use of long doubles but you do not seem to have
16595*** the following mathematical functions needed for long double support:
16596***    $message
16597*** Please rerun Configure without -Duselongdouble and/or -Dusemorebits.
16598*** Cannot continue, aborting.
16599
16600EOM
16601
16602	exit 1
16603    fi
16604fi
16605
16606: see if mprotect exists
16607set mprotect d_mprotect
16608eval $inlibc
16609
16610: see if msgctl exists
16611set msgctl d_msgctl
16612eval $inlibc
16613
16614: see if msgget exists
16615set msgget d_msgget
16616eval $inlibc
16617
16618: see if msgsnd exists
16619set msgsnd d_msgsnd
16620eval $inlibc
16621
16622: see if msgrcv exists
16623set msgrcv d_msgrcv
16624eval $inlibc
16625
16626: see how much of the 'msg*(2)' library is present.
16627h_msg=true
16628echo " "
16629case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
16630*"$undef"*) h_msg=false;;
16631esac
16632case "$osname" in
16633freebsd)
16634    case "`ipcs 2>&1`" in
16635    "SVID messages"*"not configured"*)
16636	echo "Your $osname does not have the msg*(2) configured." >&4
16637        h_msg=false
16638	val="$undef"
16639	set msgctl d_msgctl
16640	eval $setvar
16641	set msgget d_msgget
16642	eval $setvar
16643	set msgsnd d_msgsnd
16644	eval $setvar
16645	set msgrcv d_msgrcv
16646	eval $setvar
16647	;;
16648    esac
16649    ;;
16650esac
16651: we could also check for sys/ipc.h ...
16652if $h_msg && $test `./findhdr sys/msg.h`; then
16653	echo "You have the full msg*(2) library." >&4
16654	val="$define"
16655else
16656	echo "You don't have the full msg*(2) library." >&4
16657	val="$undef"
16658fi
16659set d_msg
16660eval $setvar
16661
16662: Check for msghdr_s
16663echo " "
16664echo "Checking to see if your system supports struct msghdr..." >&4
16665set d_msghdr_s msghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
16666eval $hasstruct
16667case "$d_msghdr_s" in
16668"$define")      echo "Yes, it does."   ;;
16669*)              echo "No, it doesn't." ;;
16670esac
16671
16672: see if msync exists
16673set msync d_msync
16674eval $inlibc
16675
16676: see if munmap exists
16677set munmap d_munmap
16678eval $inlibc
16679
16680: see if nan exists
16681set nan d_nan
16682eval $inlibc
16683
16684: see if nanosleep exists
16685set nanosleep d_nanosleep
16686eval $inlibc
16687
16688: see if nearbyint exists
16689set nearbyint d_nearbyint
16690eval $inlibc
16691
16692: see if nextafter exists
16693set nextafter d_nextafter
16694eval $inlibc
16695
16696: see if nexttoward exists
16697set nexttoward d_nexttoward
16698eval $inlibc
16699
16700: see if nice exists
16701set nice d_nice
16702eval $inlibc
16703
16704: see if this is a langinfo.h system
16705set langinfo.h i_langinfo
16706eval $inhdr
16707
16708: see if nl_langinfo exists
16709set nl_langinfo d_nl_langinfo
16710eval $inlibc
16711
16712: see if locale.h is available
16713set locale.h i_locale
16714eval $inhdr
16715
16716: check for nl_langinfo_l item
16717$cat <<EOM
16718
16719Checking to see if you have nl_langinfo_l(), and that it is thread-safe
16720EOM
16721$cat >try.c <<EOCP
16722#$i_stdlib I_STDLIB
16723#ifdef I_STDLIB
16724#  include <stdlib.h>
16725#endif
16726#include <string.h>
16727#$i_langinfo I_LANGINFO
16728#ifdef I_LANGINFO
16729#  include <langinfo.h>
16730#endif
16731#$i_pthread I_PTHREAD
16732#ifdef I_PTHREAD
16733#  include <pthread.h>
16734#endif
16735#$i_locale I_LOCALE
16736#ifdef I_LOCALE
16737#  include <locale.h>
16738#endif
16739
16740void *
16741thread_start(void * arg)
16742{
16743    nl_langinfo(RADIXCHAR);
16744}
16745
16746int main() {
16747    char * main_buffer;
16748    char save_main_buffer[1000];
16749    pthread_t subthread;
16750    pthread_attr_t attr;
16751
16752    main_buffer = nl_langinfo_l(CODESET, newlocale(LC_ALL_MASK, "C", 0));
16753
16754    /* If too large for our generous allowance, just assume we don't have
16755     * it. */
16756    if (strlen(main_buffer) >= sizeof(save_main_buffer)) {
16757        exit(1);
16758    }
16759
16760    strcpy(save_main_buffer, main_buffer);
16761
16762    if (pthread_attr_init(&attr) != 0) {
16763        exit(1);
16764    }
16765
16766    if (pthread_create(&subthread, &attr, thread_start, NULL) != 0) {
16767        exit(1);
16768    }
16769
16770    if (pthread_join(subthread, NULL) != 0) {
16771        exit(1);
16772    }
16773
16774    exit(! (strcmp(main_buffer, save_main_buffer) == 0));
16775}
16776EOCP
16777case "$usethreads" in
16778    define)
16779        set try
16780        if eval $compile; then
16781            echo "Your system has nl_langinfo_l()..." >&4
16782            d_nl_langinfo_l="$define"
16783            echo "$d_nl_langinfo_l" >&4
16784            if $run ./try; then
16785                echo "and it is thread-safe (just as I'd hoped)." >&4
16786                d_thread_safe_nl_langinfo_l="$define"
16787                echo "$d_thread_safe_nl_langinfo_l" >&4
16788            else
16789                echo "but it isn't thread-safe." >&4
16790            fi
16791        else
16792            echo "your system does not have nl_langinfo_l()" >&4
16793        fi
16794        ;;
16795    *) echo "Since threads aren't selected, we won't bother looking for nl_langinfo_l()" >&4
16796esac
16797if test X"$d_nl_langinfo_l" = X; then
16798	d_nl_langinfo_l="$undef"
16799fi
16800if test X"$d_thread_safe_nl_langinfo_l" = X; then
16801	d_thread_safe_nl_langinfo_l="$undef"
16802fi
16803$rm_try
16804
16805: Look for non 'int'-sized bitfields
16806case "$d_non_int_bitfields" in
16807'')
16808echo " " >&4
16809echo "Checking whether your compiler can handle struct bitfields that aren't 'int' or 'unsigned int' ..." >&4
16810$cat >try.c <<'EOCP'
16811#include <stdio.h>
16812struct foo {
16813    unsigned char byte:1;
16814    unsigned short halfword:1;
16815} bar;
16816EOCP
16817if $cc $ccflags -c try.c >try.out 2>&1 ; then
16818	if $compiler_warning try.out >/dev/null 2>&1; then
16819		echo "Your C compiler doesn't support struct bitfields that aren't 'int' or 'unsigned int'." >&4
16820		val="$undef"
16821	else
16822		echo "Your C compiler supports struct bitfields besides 'int' and 'unsigned int'." >&4
16823		val="$define"
16824	fi
16825else
16826	echo "Your C compiler doesn't seem to understand struct bitfields that aren't 'int' or 'unsigned int' at all." >&4
16827	val="$undef"
16828fi
16829;;
16830*) val="$d_non_int_bitfields" ;;
16831esac
16832set d_non_int_bitfields
16833eval $setvar
16834$rm_try
16835
16836: see if this is a quadmath.h system
16837set quadmath.h i_quadmath
16838eval $inhdr
16839
16840: Check basic sizes
16841echo " "
16842$echo "Choosing the C types to be used for Perl's internal types..." >&4
16843
16844case "$use64bitint:$d_quad:$quadtype" in
16845define:define:?*)
16846	ivtype="$quadtype"
16847	uvtype="$uquadtype"
16848	ivsize=8
16849	uvsize=8
16850	;;
16851*)	ivtype="long"
16852	uvtype="unsigned long"
16853	ivsize=$longsize
16854	uvsize=$longsize
16855	;;
16856esac
16857
16858case "$uselongdouble:$d_longdbl" in
16859define:define)
16860	nvtype="long double"
16861	nvsize=$longdblsize
16862	;;
16863*)	nvtype=double
16864	nvsize=$doublesize
16865	;;
16866esac
16867
16868case "$usequadmath:$i_quadmath" in
16869define:define)
16870  nvtype="__float128"
16871  nvsize=16
16872  : libquadmath is not in the usual places, and the place
16873  : changes if the compiler is upgraded.  So ask the compiler if it
16874  : can find it.
16875  : We do not need to save this, if it fails we abort.
16876  libs="$libs -lquadmath"
16877  set try
16878  $cat >try.c <<EOM
16879#include <quadmath.h>
16880#include <stdio.h>
16881int main(int argc, char *argv[]) {
16882  __float128 x = 1.0;
16883  if (fabsq(logq(x)) > 1e-6) {
16884     fputs("quadmath is broken\n", stderr);
16885     return 1;
16886  }
16887  puts("define");
16888  return 0;
16889}
16890EOM
16891  yyy=''
16892  if eval $compile_ok; then
16893      yyy=`$run ./try`
16894      case "$yyy" in
16895      define) ;;
16896      *) cat <<EOM >&4
16897
16898*** You requested the use of the quadmath library, but
16899*** it appears to be nonfunctional.
16900*** Cannot continue, aborting.
16901
16902EOM
16903       exit 1
16904       ;;
16905       esac
16906  else
16907      $cat <<EOM >&4
16908
16909*** You requested the use of the quadmath library, but you
16910*** do not seem to have the quadmath library installed.
16911*** Cannot continue, aborting.
16912EOM
16913    exit 1
16914  fi
16915  ;;
16916define:*) $cat <<EOM >&4
16917
16918*** You requested the use of the quadmath library, but you
16919*** do not seem to have the required header, <quadmath.h>.
16920EOM
16921  case "$gccversion" in
16922  [23].*|4.[0-5]*)
16923   $cat <<EOM >&4
16924*** Your gcc looks a bit old:
16925*** $gccversion
16926EOM
16927    ;;
16928  '')
16929   $cat <<EOM >&4
16930*** You are not running a gcc.
16931EOM
16932    ;;
16933  esac
16934  $cat <<EOM >&4
16935*** For the quadmath library you need at least gcc 4.6.
16936*** Cannot continue, aborting.
16937EOM
16938  exit 1
16939  ;;
16940esac
16941
16942$echo "(IV will be "$ivtype", $ivsize bytes)"
16943$echo "(UV will be "$uvtype", $uvsize bytes)"
16944$echo "(NV will be "$nvtype", $nvsize bytes)"
16945
16946$cat >try.c <<EOCP
16947#$i_inttypes I_INTTYPES
16948#ifdef I_INTTYPES
16949#include <inttypes.h>
16950#endif
16951#include <stdio.h>
16952int main() {
16953#ifdef INT8
16954   int8_t i =  INT8_MAX;
16955  uint8_t u = UINT8_MAX;
16956  printf("int8_t\n");
16957#endif
16958#ifdef INT16
16959   int16_t i =  INT16_MAX;
16960  uint16_t u = UINT16_MAX;
16961  printf("int16_t\n");
16962#endif
16963#ifdef INT32
16964   int32_t i =  INT32_MAX;
16965  uint32_t u = UINT32_MAX;
16966  printf("int32_t\n");
16967#endif
16968}
16969EOCP
16970
16971i8type="signed char"
16972u8type="unsigned char"
16973i8size=1
16974u8size=1
16975
16976case "$i16type" in
16977'')	case "$shortsize" in
16978	2)	i16type=short
16979		u16type="unsigned short"
16980		i16size=$shortsize
16981		u16size=$shortsize
16982		;;
16983	esac
16984	;;
16985esac
16986case "$i16type" in
16987'')	set try -DINT16
16988	if eval $compile; then
16989		case "`$run ./try`" in
16990		int16_t)
16991			i16type=int16_t
16992			u16type=uint16_t
16993			i16size=2
16994			u16size=2
16995			;;
16996		esac
16997	fi
16998	;;
16999esac
17000case "$i16type" in
17001'')	if $test $shortsize -ge 2; then
17002		i16type=short
17003		u16type="unsigned short"
17004		i16size=$shortsize
17005		u16size=$shortsize
17006	fi
17007	;;
17008esac
17009
17010case "$i32type" in
17011'')	case "$longsize" in
17012	4)	i32type=long
17013		u32type="unsigned long"
17014		i32size=$longsize
17015		u32size=$longsize
17016		;;
17017	*)	case "$intsize" in
17018		4)	i32type=int
17019			u32type="unsigned int"
17020			i32size=$intsize
17021			u32size=$intsize
17022			;;
17023		esac
17024		;;
17025	esac
17026	;;
17027esac
17028case "$i32type" in
17029'')	set try -DINT32
17030	if eval $compile; then
17031		case "`$run ./try`" in
17032		int32_t)
17033			i32type=int32_t
17034			u32type=uint32_t
17035			i32size=4
17036			u32size=4
17037			;;
17038		esac
17039	fi
17040	;;
17041esac
17042case "$i32type" in
17043'')	if $test $intsize -ge 4; then
17044		i32type=int
17045		u32type="unsigned int"
17046		i32size=$intsize
17047		u32size=$intsize
17048	fi
17049	;;
17050esac
17051
17052case "$i64type" in
17053'')	case "$d_quad:$quadtype" in
17054	define:?*)
17055		i64type="$quadtype"
17056		u64type="$uquadtype"
17057		i64size=8
17058		u64size=8
17059		;;
17060	esac
17061	;;
17062esac
17063
17064$echo "Checking how many bits of your UVs your NVs can preserve..." >&4
17065$cat <<EOP >try.c
17066#include <stdio.h>
17067#$i_stdlib I_STDLIB
17068#ifdef I_STDLIB
17069#include <stdlib.h>
17070#endif
17071#$i_inttypes I_INTTYPES
17072#ifdef I_INTTYPES
17073#include <inttypes.h>
17074#endif
17075#include <sys/types.h>
17076#include <signal.h>
17077#ifdef SIGFPE
17078/* volatile so that the compiler has to store it out to memory */
17079volatile int bletched = 0;
17080$signal_t blech(int s) { bletched = 1; }
17081#endif
17082int main() {
17083    $uvtype u = 0;
17084    $nvtype d;
17085    int     n = 8 * $uvsize;
17086    int     i;
17087#ifdef SIGFPE
17088    signal(SIGFPE, blech);
17089#endif
17090
17091    for (i = 0; i < n; i++) {
17092      u = u << 1 | ($uvtype)1;
17093      d = ($nvtype)u;
17094      if (($uvtype)d != u)
17095        break;
17096      if (d <= 0)
17097	break;
17098      d = ($nvtype)(u - 1);
17099      if (($uvtype)d != (u - 1))
17100        break;
17101#ifdef SIGFPE
17102      if (bletched)
17103	break;
17104#endif
17105    }
17106    printf("%d\n", ((i == n) ? -n : i));
17107    exit(0);
17108}
17109EOP
17110set try
17111
17112d_nv_preserves_uv="$undef"
17113if eval $compile; then
17114	nv_preserves_uv_bits="`$run ./try`"
17115fi
17116case "$nv_preserves_uv_bits" in
17117\-[1-9]*)
17118	nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
17119	$echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs."  >&4
17120	d_nv_preserves_uv="$define"
17121	;;
17122[1-9]*)	$echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs."  >&4
17123	d_nv_preserves_uv="$undef" ;;
17124*)	$echo "Can't figure out how many bits your NVs preserve." >&4
17125	nv_preserves_uv_bits="0" ;;
17126esac
17127$rm_try
17128
17129$echo "Checking to find the largest integer value your NVs can hold..." >&4
17130$cat <<EOP >try.c
17131#include <stdio.h>
17132
17133typedef $nvtype NV;
17134
17135int
17136main() {
17137  NV value = 2;
17138  int count = 1;
17139
17140  while(count < 256) {
17141    /* volatile so that the compiler has to store it out to memory */
17142    volatile NV up = value + 1.0;
17143    volatile NV negated = -value;
17144    volatile NV down = negated - 1.0;
17145    volatile NV got_up = up - value;
17146    int up_good = got_up == 1.0;
17147    int got_down = down - negated;
17148    int down_good = got_down == -1.0;
17149
17150    if (down_good != up_good) {
17151      fprintf(stderr,
17152	      "Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n",
17153	      up_good, (double) got_up, down_good, (double) got_down,
17154	      count, (double) value);
17155      return 1;
17156    }
17157    if (!up_good) {
17158      while (1) {
17159	if (count > 8) {
17160	  count -= 8;
17161	  fputs("256.0", stdout);
17162	} else {
17163	  count--;
17164	  fputs("2.0", stdout);
17165	}
17166	if (!count) {
17167	  puts("");
17168	  return 0;
17169	}
17170	fputs("*", stdout);
17171      }
17172    }
17173    value *= 2;
17174    ++count;
17175  }
17176  fprintf(stderr, "Cannot overflow integer range, even at 2**%d (%.20f)\n",
17177	  count, (double) value);
17178  return 1;
17179}
17180EOP
17181set try
17182
17183nv_overflows_integers_at='0'
17184if eval $compile; then
17185    xxx="`$run ./try`"
17186    case "$?" in
17187	0)
17188	    case "$xxx" in
17189		2*)  cat >&4 <<EOM
17190The largest integer your NVs can preserve is equal to $xxx
17191EOM
17192		    nv_overflows_integers_at="$xxx"
17193		    ;;
17194		*)  cat >&4 <<EOM
17195Cannot determine the largest integer value your NVs can hold, unexpected output
17196'$xxx'
17197EOM
17198		    ;;
17199	    esac
17200	    ;;
17201	*)  cat >&4 <<EOM
17202Cannot determine the largest integer value your NVs can hold
17203EOM
17204	    ;;
17205    esac
17206fi
17207$rm_try
17208
17209$echo "Checking whether NV 0.0 is all bits zero in memory..." >&4
17210$cat <<EOP >try.c
17211#include <stdio.h>
17212#$i_stdlib I_STDLIB
17213#ifdef I_STDLIB
17214#include <stdlib.h>
17215#endif
17216#include <string.h>
17217#include <sys/types.h>
17218#include <signal.h>
17219#ifdef SIGFPE
17220/* volatile so that the compiler has to store it out to memory */
17221volatile int bletched = 0;
17222$signal_t blech(int s) { bletched = 1; }
17223#endif
17224
17225int checkit($nvtype d, const char *where) {
17226    void *v = &d;
17227    unsigned char *p = (unsigned char *)v;
17228    unsigned char *end = p + sizeof(d);
17229    int fail = 0;
17230
17231    while (p < end)
17232	fail += *p++;
17233
17234    if (!fail)
17235	return 0;
17236
17237    p = (unsigned char *)v;
17238    printf("No - %s: 0x", where);
17239    while (p < end)
17240	printf ("%02X", *p++);
17241    printf("\n");
17242    return 1;
17243}
17244
17245int main(int argc, char **argv) {
17246    $nvtype d = 0.0;
17247    int fail = 0;
17248    fail += checkit(d, "0.0");
17249
17250    /* The compiler shouldn't be assuming that bletched is 0  */
17251    d = bletched;
17252
17253    fail += checkit(d, "bleched");
17254
17255#ifdef SIGFPE
17256    signal(SIGFPE, blech);
17257#endif
17258
17259    /* Paranoia - the compiler should have no way of knowing that ANSI says
17260       that argv[argc] will always be NULL.  Actually, if it did assume this it
17261       would be buggy, as this is C and main() can be called from elsewhere in
17262       the program.  */
17263    d = argv[argc] ? 1 : 0;
17264
17265    if (d) {
17266	printf("Odd argv[argc]=%p, d=%g\n", argv[argc], d);
17267    }
17268
17269    fail += checkit(d, "ternary");
17270
17271    memset(&d, sizeof(d), argv[argc] ? 1 : 0);
17272
17273    if (d != 0.0) {
17274	printf("No - memset doesn't give 0.0\n");
17275	/* This might just blow up:  */
17276	printf("(gives %g)\n", d);
17277	return 1;
17278    }
17279
17280#ifdef SIGFPE
17281    if (bletched) {
17282	printf("No - something bleched\n");
17283	return 1;
17284    }
17285#endif
17286    if (fail) {
17287      printf("No - %d fail(s)\n", fail);
17288      return 1;
17289    }
17290    printf("Yes\n");
17291    return 0;
17292}
17293EOP
17294set try
17295
17296d_nv_zero_is_allbits_zero="$undef"
17297if eval $compile; then
17298    xxx="`$run ./try`"
17299    case "$?" in
17300	0)
17301	    case "$xxx" in
17302		Yes)  cat >&4 <<EOM
173030.0 is represented as all bits zero in memory
17304EOM
17305		    d_nv_zero_is_allbits_zero="$define"
17306		    ;;
17307		*)  cat >&4 <<EOM
173080.0 is not represented as all bits zero in memory
17309EOM
17310		    d_nv_zero_is_allbits_zero="$undef"
17311		    ;;
17312	    esac
17313	    ;;
17314	*)  cat >&4 <<EOM
173150.0 is not represented as all bits zero in memory
17316EOM
17317	    d_nv_zero_is_allbits_zero="$undef"
17318	    ;;
17319    esac
17320fi
17321$rm_try
17322
17323: check for off64_t
17324echo " "
17325echo "Checking to see if you have off64_t..." >&4
17326$cat >try.c <<EOCP
17327#include <sys/types.h>
17328#include <unistd.h>
17329int main() { off64_t x = 7; }
17330EOCP
17331set try
17332if eval $compile; then
17333	val="$define"
17334	echo "You have off64_t."
17335else
17336	val="$undef"
17337	echo "You do not have off64_t."
17338	case "$lseeksize" in
17339	8) echo "(Your off_t is 64 bits, so you could use that.)" ;;
17340	esac
17341fi
17342$rm_try
17343set d_off64_t
17344eval $setvar
17345
17346: how to create joinable pthreads
17347if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
17348	echo " "
17349	echo "Checking what constant to use for creating joinable pthreads..." >&4
17350	$cat >try.c <<'EOCP'
17351#include <pthread.h>
17352int main() {
17353    int detachstate = JOINABLE;
17354}
17355EOCP
17356	set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
17357	if eval $compile; then
17358		echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
17359		val="$undef" # Yes, undef.
17360		set d_old_pthread_create_joinable
17361		eval $setvar
17362		val=""
17363		set old_pthread_create_joinable
17364		eval $setvar
17365	else
17366		set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
17367		if eval $compile; then
17368			echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
17369			val="$define"
17370			set d_old_pthread_create_joinable
17371			eval $setvar
17372			val=PTHREAD_CREATE_UNDETACHED
17373			set old_pthread_create_joinable
17374			eval $setvar
17375		else
17376			set try -DJOINABLE=__UNDETACHED
17377			if eval $compile; then
17378				echo "You seem to use __UNDETACHED." >&4
17379				val="$define"
17380				set d_old_pthread_create_joinable
17381				eval $setvar
17382				val=__UNDETACHED
17383				set old_pthread_create_joinable
17384				eval $setvar
17385			else
17386				echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
17387				val="$define"
17388				set d_old_pthread_create_joinable
17389				eval $setvar
17390				val=0
17391				set old_pthread_create_joinable
17392				eval $setvar
17393			fi
17394		fi
17395	fi
17396	$rm_try
17397else
17398    d_old_pthread_create_joinable="$undef"
17399    old_pthread_create_joinable=""
17400fi
17401
17402: see if pause exists
17403set pause d_pause
17404eval $inlibc
17405
17406: see if pipe2 exists
17407set pipe2 d_pipe2
17408eval $inlibc
17409
17410: see if poll exists
17411set poll d_poll
17412eval $inlibc
17413
17414: see if prctl exists
17415set prctl d_prctl
17416eval $inlibc
17417
17418: see if prctl supports PR_SET_NAME
17419d_prctl_set_name=$undef
17420case $d_prctl in
17421    $define)
17422	$cat >try.c <<EOM
17423#ifdef __ANDROID__
17424#include <unistd.h>
17425#endif
17426#include <sys/prctl.h>
17427
17428int main (int argc, char *argv[])
17429{
17430    return (prctl (PR_SET_NAME, "Test"));
17431    } /* main */
17432EOM
17433	set try
17434	if eval $compile_ok && $run ./try; then
17435	    echo "Your prctl (PR_SET_NAME, ...) works"
17436	    d_prctl_set_name=$define
17437	    fi
17438	$rm_try
17439	;;
17440    esac
17441
17442: see if readlink exists
17443set readlink d_readlink
17444eval $inlibc
17445
17446: Check if there is a /proc symlink to the abs path of
17447: the executing program.  We will honor hints of d_procselfexe=$undef
17448: or procselfexe being non-empty, otherwise will try to determine both
17449: if we have readlink.
17450: AmigaOS will attempt to mount proc: aka /proc, if /proc/... is
17451: referenced, and AmigaOS does not have a proc filesystem anyway.
17452echo " "
17453val="$undef"
17454if $test "X$d_procselfexe" = Xundef; then
17455	procselfexe=''
17456elif $test "X$procselfexe" != X -a "X$procselfexe" != 'X '; then
17457	val="$define"
17458elif $test "X$d_readlink" = Xdefine; then
17459        : NetBSD first as /proc/self is a symlink to /proc/curproc,
17460        : and it feels more tidy to avoid an extra level of symlink
17461	set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
17462	while test $# -gt 0; do
17463	    type=$1; try=$2
17464	    shift; shift
17465	    if $issymlink $try; then
17466		$ls -l $try > reflect
17467		if $contains /`basename $ls` reflect >/dev/null 2>&1; then
17468		    echo "You have $type-like $try."
17469		    procselfexe='"'$try'"'
17470		    val="$define"
17471		    : This will break out of the loop
17472		    set X; shift
17473		fi
17474	    fi
17475	done
17476fi
17477$rm -f reflect
17478set d_procselfexe
17479eval $setvar
17480
17481: backward compatibility for d_hvfork
17482if test X$d_hvfork != X; then
17483	d_vfork="$d_hvfork"
17484	d_hvfork=''
17485fi
17486: see if there is a vfork
17487val=''
17488set vfork val
17489eval $inlibc
17490
17491d_pseudofork=$undef
17492
17493: Ok, but do we want to use it. vfork is reportedly unreliable in
17494: perl on Solaris 2.x, and probably elsewhere.
17495case "$val" in
17496$define)
17497	echo " "
17498	case "$usevfork" in
17499	false) dflt='n';;
17500	*) dflt='y';;
17501	esac
17502	cat <<'EOM'
17503
17504Perl can only use a vfork() that doesn't suffer from strict
17505restrictions on calling functions or modifying global data in
17506the child.  For example, glibc-2.1 contains such a vfork()
17507that is unsuitable.  If your system provides a proper fork()
17508call, chances are that you do NOT want perl to use vfork().
17509
17510EOM
17511	rp="Do you still want to use vfork()?"
17512	. ./myread
17513	case "$ans" in
17514	y|Y) ;;
17515	*)
17516		echo "Ok, we won't use vfork()."
17517		val="$undef"
17518		;;
17519	esac
17520	;;
17521esac
17522set d_vfork
17523eval $setvar
17524case "$d_vfork" in
17525$define) usevfork='true';;
17526*) usevfork='false';;
17527esac
17528
17529: see whether the pthread_atfork exists
17530$cat >try.c <<EOP
17531#include <pthread.h>
17532#include <stdio.h>
17533int main() {
17534#ifdef  PTHREAD_ATFORK
17535        pthread_atfork(NULL,NULL,NULL);
17536#endif
17537}
17538EOP
17539
17540: see if pthread_atfork exists
17541set try -DPTHREAD_ATFORK
17542if eval $compile; then
17543    val="$define"
17544else
17545    val="$undef"
17546fi
17547case "$usethreads" in
17548$define)
17549        case "$val" in
17550        $define) echo 'pthread_atfork found.' >&4        ;;
17551        *)       echo 'pthread_atfork NOT found.' >&4    ;;
17552        esac
17553esac
17554set d_pthread_atfork
17555eval $setvar
17556
17557: see if pthread_attr_setscope exists
17558set pthread_attr_setscope d_pthread_attr_setscope
17559eval $inlibc
17560
17561: see whether the various POSIXish _yields exist
17562$cat >try.c <<EOP
17563#include <pthread.h>
17564#include <stdio.h>
17565int main() {
17566#ifdef SCHED_YIELD
17567	sched_yield();
17568#else
17569#ifdef PTHREAD_YIELD
17570	pthread_yield();
17571#else
17572#ifdef PTHREAD_YIELD_NULL
17573	pthread_yield(NULL);
17574#endif
17575#endif
17576#endif
17577}
17578EOP
17579: see if sched_yield exists
17580set try -DSCHED_YIELD
17581if eval $compile; then
17582    val="$define"
17583    sched_yield='sched_yield()'
17584else
17585    val="$undef"
17586fi
17587case "$usethreads" in
17588$define)
17589	case "$val" in
17590	$define) echo 'sched_yield() found.' >&4	;;
17591	*)	 echo 'sched_yield() NOT found.' >&4	;;
17592	esac
17593esac
17594set d_sched_yield
17595eval $setvar
17596
17597: see if pthread_yield exists
17598set try -DPTHREAD_YIELD
17599if eval $compile; then
17600    val="$define"
17601    case "$sched_yield" in
17602    '') sched_yield='pthread_yield()' ;;
17603    esac
17604else
17605    set try -DPTHREAD_YIELD_NULL
17606    if eval $compile; then
17607	val="$define"
17608	case "$sched_yield" in
17609	'') sched_yield='pthread_yield(NULL)' ;;
17610	esac
17611    else
17612	val="$undef"
17613    fi
17614fi
17615case "$usethreads" in
17616$define)
17617	case "$val" in
17618	$define) echo 'pthread_yield() found.' >&4	;;
17619	*)	 echo 'pthread_yield() NOT found.' >&4	;;
17620	esac
17621	;;
17622esac
17623set d_pthread_yield
17624eval $setvar
17625case "$sched_yield" in
17626'') sched_yield=undef ;;
17627esac
17628$rm_try
17629
17630: check for ptrdiff_t
17631echo " "
17632echo "Checking to see if you have ptrdiff_t..." >&4
17633$cat >try.c <<EOCP
17634#include <stddef.h>
17635int main() { ptrdiff_t x = 7; }
17636EOCP
17637set try
17638if eval $compile; then
17639	val="$define"
17640	echo "You have ptrdiff_t."
17641else
17642	val="$undef"
17643	echo "You do not have ptrdiff_t."
17644fi
17645$rm_try
17646set d_ptrdiff_t
17647eval $setvar
17648
17649: see if random_r exists
17650set random_r d_random_r
17651eval $inlibc
17652case "$d_random_r" in
17653"$define")
17654	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
17655	case "$d_random_r_proto:$usethreads" in
17656	":define")	d_random_r_proto=define
17657		set d_random_r_proto random_r $hdrs
17658		eval $hasproto ;;
17659	*)	;;
17660	esac
17661	case "$d_random_r_proto" in
17662	define)
17663	case "$random_r_proto" in
17664	''|0) try='int random_r(int*, struct random_data*);'
17665	./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;;
17666	esac
17667	case "$random_r_proto" in
17668	''|0) try='int random_r(long*, struct random_data*);'
17669	./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;;
17670	esac
17671	case "$random_r_proto" in
17672	''|0) try='int random_r(struct random_data*, int32_t*);'
17673	./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;;
17674	esac
17675	case "$random_r_proto" in
17676	''|0)	d_random_r=undef
17677		random_r_proto=0
17678		echo "Disabling random_r, cannot determine prototype." >&4 ;;
17679	* )	case "$random_r_proto" in
17680		REENTRANT_PROTO*) ;;
17681		*) random_r_proto="REENTRANT_PROTO_$random_r_proto" ;;
17682		esac
17683		echo "Prototype: $try" ;;
17684	esac
17685	;;
17686	*)	case "$usethreads" in
17687		define) echo "random_r has no prototype, not using it." >&4 ;;
17688		esac
17689		d_random_r=undef
17690		random_r_proto=0
17691		;;
17692	esac
17693	;;
17694*)	random_r_proto=0
17695	;;
17696esac
17697
17698: see if readdir and friends exist
17699set readdir d_readdir
17700eval $inlibc
17701set seekdir d_seekdir
17702eval $inlibc
17703set telldir d_telldir
17704eval $inlibc
17705set rewinddir d_rewinddir
17706eval $inlibc
17707
17708: see if readdir64_r exists
17709set readdir64_r d_readdir64_r
17710eval $inlibc
17711case "$d_readdir64_r" in
17712"$define")
17713	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
17714	case "$d_readdir64_r_proto:$usethreads" in
17715	":define")	d_readdir64_r_proto=define
17716		set d_readdir64_r_proto readdir64_r $hdrs
17717		eval $hasproto ;;
17718	*)	;;
17719	esac
17720	case "$d_readdir64_r_proto" in
17721	define)
17722	case "$readdir64_r_proto" in
17723	''|0) try='int readdir64_r(DIR*, struct dirent64*, struct dirent64**);'
17724	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TSR ;;
17725	esac
17726	case "$readdir64_r_proto" in
17727	''|0) try='int readdir64_r(DIR*, struct dirent64*);'
17728	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TS ;;
17729	esac
17730	case "$readdir64_r_proto" in
17731	''|0)	d_readdir64_r=undef
17732		readdir64_r_proto=0
17733		echo "Disabling readdir64_r, cannot determine prototype." >&4 ;;
17734	* )	case "$readdir64_r_proto" in
17735		REENTRANT_PROTO*) ;;
17736		*) readdir64_r_proto="REENTRANT_PROTO_$readdir64_r_proto" ;;
17737		esac
17738		echo "Prototype: $try" ;;
17739	esac
17740	;;
17741	*)	case "$usethreads" in
17742		define) echo "readdir64_r has no prototype, not using it." >&4 ;;
17743		esac
17744		d_readdir64_r=undef
17745		readdir64_r_proto=0
17746		;;
17747	esac
17748	;;
17749*)	readdir64_r_proto=0
17750	;;
17751esac
17752
17753: see if readdir_r exists
17754set readdir_r d_readdir_r
17755eval $inlibc
17756case "$d_readdir_r" in
17757"$define")
17758	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
17759	case "$d_readdir_r_proto:$usethreads" in
17760	":define")	d_readdir_r_proto=define
17761		set d_readdir_r_proto readdir_r $hdrs
17762		eval $hasproto ;;
17763	*)	;;
17764	esac
17765	case "$d_readdir_r_proto" in
17766	define)
17767	case "$readdir_r_proto" in
17768	''|0) try='int readdir_r(DIR*, struct dirent*, struct dirent**);'
17769	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TSR ;;
17770	esac
17771	case "$readdir_r_proto" in
17772	''|0) try='int readdir_r(DIR*, struct dirent*);'
17773	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TS ;;
17774	esac
17775	case "$readdir_r_proto" in
17776	''|0)	d_readdir_r=undef
17777		readdir_r_proto=0
17778		echo "Disabling readdir_r, cannot determine prototype." >&4 ;;
17779	* )	case "$readdir_r_proto" in
17780		REENTRANT_PROTO*) ;;
17781		*) readdir_r_proto="REENTRANT_PROTO_$readdir_r_proto" ;;
17782		esac
17783		echo "Prototype: $try" ;;
17784	esac
17785	;;
17786	*)	case "$usethreads" in
17787		define) echo "readdir_r has no prototype, not using it." >&4 ;;
17788		esac
17789		d_readdir_r=undef
17790		readdir_r_proto=0
17791		;;
17792	esac
17793	;;
17794*)	readdir_r_proto=0
17795	;;
17796esac
17797
17798: see if readv exists
17799set readv d_readv
17800eval $inlibc
17801
17802: see if recvmsg exists
17803set recvmsg d_recvmsg
17804eval $inlibc
17805
17806: see if regcomp, regcmp, or re_comp exist, for regular pattern matching
17807echo " "
17808if set regcomp val -f d_regcomp; eval $csym; $val; then
17809	echo 'regcomp() found.' >&4
17810	d_regcomp="$define"
17811	d_regcmp="$undef"
17812	d_re_comp="$undef"
17813elif set regcmp val -f d_regcmp; eval $csym; $val; then
17814	echo 'regcmp() found.' >&4
17815	d_regcmp="$define"
17816	d_regcomp="$undef"
17817	d_re_comp="$undef"
17818elif set re_comp val -f d_re_comp; eval $csym; $val; then
17819	echo 're_comp() found, assuming re_exec() also exists.' >&4
17820	d_re_comp="$define"
17821	d_regcomp="$undef"
17822	d_regcmp="$undef"
17823else
17824	$cat >&4 <<EOM
17825No regcomp(), regcmp() nor re_comp() found !! No regular pattern matching.
17826EOM
17827	d_regcmp="$undef"
17828	d_re_comp="$undef"
17829	d_regcomp="$undef"
17830fi
17831
17832: see if remainder exists
17833set remainder d_remainder
17834eval $inlibc
17835
17836: see if remquo exists
17837set remquo d_remquo
17838eval $inlibc
17839
17840: see if rename exists
17841set rename d_rename
17842eval $inlibc
17843
17844: see if rint exists
17845set rint d_rint
17846eval $inlibc
17847
17848: see if rmdir exists
17849set rmdir d_rmdir
17850eval $inlibc
17851
17852: see if round exists
17853set round d_round
17854eval $inlibc
17855
17856: see if prototype for sbrk is available
17857echo " "
17858set d_sbrkproto sbrk $i_unistd unistd.h
17859eval $hasproto
17860
17861: see if scalbn exists
17862set scalbn d_scalbn
17863eval $inlibc
17864
17865: see if select exists
17866set select d_select
17867eval $inlibc
17868
17869: see if semctl exists
17870set semctl d_semctl
17871eval $inlibc
17872
17873: see if semget exists
17874set semget d_semget
17875eval $inlibc
17876
17877: see if semop exists
17878set semop d_semop
17879eval $inlibc
17880
17881: see how much of the 'sem*(2)' library is present.
17882h_sem=true
17883echo " "
17884case "$d_semctl$d_semget$d_semop" in
17885*"$undef"*) h_sem=false;;
17886esac
17887case "$osname" in
17888freebsd)
17889    case "`ipcs 2>&1`" in
17890    "SVID messages"*"not configured"*)
17891	echo "Your $osname does not have the sem*(2) configured." >&4
17892        h_sem=false
17893	val="$undef"
17894	set semctl d_semctl
17895	eval $setvar
17896	set semget d_semget
17897	eval $setvar
17898	set semop d_semop
17899	eval $setvar
17900	;;
17901    esac
17902    ;;
17903esac
17904: we could also check for sys/ipc.h ...
17905if $h_sem && $test `./findhdr sys/sem.h`; then
17906	echo "You have the full sem*(2) library." >&4
17907	val="$define"
17908else
17909	echo "You don't have the full sem*(2) library." >&4
17910	val="$undef"
17911fi
17912set d_sem
17913eval $setvar
17914
17915: see whether sys/sem.h defines union semun
17916echo " "
17917$cat > try.c <<'END'
17918#include <sys/types.h>
17919#include <sys/ipc.h>
17920#include <sys/sem.h>
17921int main () { union semun semun; semun.buf = 0; }
17922END
17923set try
17924if eval $compile; then
17925    echo "You have union semun in <sys/sem.h>." >&4
17926    val="$define"
17927else
17928    echo "You do not have union semun in <sys/sem.h>." >&4
17929    val="$undef"
17930fi
17931$rm_try
17932set d_union_semun
17933eval $setvar
17934
17935: see how to do semctl IPC_STAT
17936case "$d_sem" in
17937$define)
17938    echo " "
17939    $cat > tryh.h <<END
17940#ifndef S_IRUSR
17941#   ifdef S_IREAD
17942#	define S_IRUSR S_IREAD
17943#	define S_IWUSR S_IWRITE
17944#	define S_IXUSR S_IEXEC
17945#   else
17946#	define S_IRUSR 0400
17947#	define S_IWUSR 0200
17948#	define S_IXUSR 0100
17949#   endif
17950#   define S_IRGRP (S_IRUSR>>3)
17951#   define S_IWGRP (S_IWUSR>>3)
17952#   define S_IXGRP (S_IXUSR>>3)
17953#   define S_IROTH (S_IRUSR>>6)
17954#   define S_IWOTH (S_IWUSR>>6)
17955#   define S_IXOTH (S_IXUSR>>6)
17956#endif
17957#ifndef S_IRWXU
17958#   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
17959#   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
17960#   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
17961#endif
17962END
17963    : see whether semctl IPC_STAT can use union semun
17964    case "$d_semctl_semun" in
17965    '')
17966      val="$undef"
17967      $cat > try.c <<END
17968#include <sys/types.h>
17969#include <sys/ipc.h>
17970#include <sys/sem.h>
17971#include <sys/stat.h>
17972#include <stdio.h>
17973#include <errno.h>
17974#include "tryh.h"
17975#ifndef errno
17976extern int errno;
17977#endif
17978#$d_union_semun HAS_UNION_SEMUN
17979int main() {
17980    union semun
17981#ifndef HAS_UNION_SEMUN
17982    {
17983	int val;
17984	struct semid_ds *buf;
17985	unsigned short *array;
17986    }
17987#endif
17988    arg;
17989    int sem, st;
17990
17991#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
17992    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17993    if (sem > -1) {
17994	struct semid_ds argbuf;
17995	arg.buf = &argbuf;
17996#	ifdef IPC_STAT
17997	st = semctl(sem, 0, IPC_STAT, arg);
17998	if (st == 0)
17999	    printf("semun\n");
18000	else
18001#	endif /* IPC_STAT */
18002	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
18003#	ifdef IPC_RMID
18004	if (semctl(sem, 0, IPC_RMID, arg) != 0)
18005#	endif /* IPC_RMID */
18006	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
18007    } else
18008#endif /* IPC_PRIVATE && ... */
18009	printf("semget failed: errno = %d\n", errno);
18010  return 0;
18011}
18012END
18013      set try
18014      if eval $compile; then
18015	  xxx=`$run ./try`
18016          case "$xxx" in
18017          semun) val="$define" ;;
18018          esac
18019      fi
18020      $rm_try
18021      set d_semctl_semun
18022      eval $setvar
18023      ;;
18024    esac
18025    case "$d_semctl_semun" in
18026    $define)
18027        echo "You can use union semun for semctl IPC_STAT." >&4
18028	also='also'
18029        ;;
18030    *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
18031	also=''
18032        ;;
18033    esac
18034
18035    : see whether semctl IPC_STAT can use struct semid_ds pointer
18036    case "$d_semctl_semid_ds" in
18037    '')
18038      val="$undef"
18039      $cat > try.c <<'END'
18040#include <sys/types.h>
18041#include <sys/ipc.h>
18042#include <sys/sem.h>
18043#include <sys/stat.h>
18044#include "tryh.h"
18045#include <stdio.h>
18046#include <errno.h>
18047#ifndef errno
18048extern int errno;
18049#endif
18050int main() {
18051    union semun
18052#ifndef HAS_UNION_SEMUN
18053    {
18054	int val;
18055	struct semid_ds *buf;
18056	unsigned short *array;
18057    }
18058#endif
18059    arg;
18060    struct semid_ds argbuf;
18061    int sem, st;
18062
18063#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
18064    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
18065    if (sem > -1) {
18066	arg.buf = &argbuf;
18067#	ifdef IPC_STAT
18068	st = semctl(sem, 0, IPC_STAT, arg);
18069	if (st == 0)
18070	    printf("semid_ds\n");
18071	else
18072#	endif /* IPC_STAT */
18073	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
18074#	ifdef IPC_RMID
18075	if (semctl(sem, 0, IPC_RMID, arg) != 0)
18076#	endif /* IPC_RMID */
18077	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
18078    } else
18079#endif /* IPC_PRIVATE && ... */
18080	printf("semget failed: errno = %d\n", errno);
18081
18082    return 0;
18083}
18084END
18085      set try
18086      if eval $compile; then
18087          xxx=`$run ./try`
18088          case "$xxx" in
18089          semid_ds) val="$define" ;;
18090          esac
18091      fi
18092      $rm_try
18093      set d_semctl_semid_ds
18094      eval $setvar
18095      ;;
18096    esac
18097    case "$d_semctl_semid_ds" in
18098    $define)
18099        echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
18100        ;;
18101    *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
18102        ;;
18103    esac
18104    ;;
18105*)  val="$undef"
18106
18107    # We do not have the full sem*(2) library, so assume we can not
18108    # use either.
18109
18110    set d_semctl_semun
18111    eval $setvar
18112
18113    set d_semctl_semid_ds
18114    eval $setvar
18115    ;;
18116esac
18117$rm_try tryh.h
18118
18119: see if sendmsg exists
18120set sendmsg d_sendmsg
18121eval $inlibc
18122
18123: see if setegid exists
18124set setegid d_setegid
18125eval $inlibc
18126
18127: see if setenv exists
18128set setenv d_setenv
18129eval $inlibc
18130
18131: see if seteuid exists
18132set seteuid d_seteuid
18133eval $inlibc
18134
18135: see if setgrent exists
18136set setgrent d_setgrent
18137eval $inlibc
18138
18139: see if setgrent_r exists
18140set setgrent_r d_setgrent_r
18141eval $inlibc
18142case "$d_setgrent_r" in
18143"$define")
18144	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
18145	case "$d_setgrent_r_proto:$usethreads" in
18146	":define")	d_setgrent_r_proto=define
18147		set d_setgrent_r_proto setgrent_r $hdrs
18148		eval $hasproto ;;
18149	*)	;;
18150	esac
18151	case "$d_setgrent_r_proto" in
18152	define)
18153	case "$setgrent_r_proto" in
18154	''|0) try='int setgrent_r(FILE**);'
18155	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=I_H ;;
18156	esac
18157	case "$setgrent_r_proto" in
18158	''|0) try='void setgrent_r(FILE**);'
18159	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=V_H ;;
18160	esac
18161	case "$setgrent_r_proto" in
18162	''|0)	d_setgrent_r=undef
18163		setgrent_r_proto=0
18164		echo "Disabling setgrent_r, cannot determine prototype." >&4 ;;
18165	* )	case "$setgrent_r_proto" in
18166		REENTRANT_PROTO*) ;;
18167		*) setgrent_r_proto="REENTRANT_PROTO_$setgrent_r_proto" ;;
18168		esac
18169		echo "Prototype: $try" ;;
18170	esac
18171	;;
18172	*)	case "$usethreads" in
18173		define) echo "setgrent_r has no prototype, not using it." >&4 ;;
18174		esac
18175		d_setgrent_r=undef
18176		setgrent_r_proto=0
18177		;;
18178	esac
18179	;;
18180*)	setgrent_r_proto=0
18181	;;
18182esac
18183
18184: see if sethostent exists
18185set sethostent d_sethent
18186eval $inlibc
18187
18188: see if sethostent_r exists
18189set sethostent_r d_sethostent_r
18190eval $inlibc
18191case "$d_sethostent_r" in
18192"$define")
18193	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18194	case "$d_sethostent_r_proto:$usethreads" in
18195	":define")	d_sethostent_r_proto=define
18196		set d_sethostent_r_proto sethostent_r $hdrs
18197		eval $hasproto ;;
18198	*)	;;
18199	esac
18200	case "$d_sethostent_r_proto" in
18201	define)
18202	case "$sethostent_r_proto" in
18203	''|0) try='int sethostent_r(int, struct hostent_data*);'
18204	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=I_ID ;;
18205	esac
18206	case "$sethostent_r_proto" in
18207	''|0) try='void sethostent_r(int, struct hostent_data*);'
18208	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=V_ID ;;
18209	esac
18210	case "$sethostent_r_proto" in
18211	''|0)	d_sethostent_r=undef
18212		sethostent_r_proto=0
18213		echo "Disabling sethostent_r, cannot determine prototype." >&4 ;;
18214	* )	case "$sethostent_r_proto" in
18215		REENTRANT_PROTO*) ;;
18216		*) sethostent_r_proto="REENTRANT_PROTO_$sethostent_r_proto" ;;
18217		esac
18218		echo "Prototype: $try" ;;
18219	esac
18220	;;
18221	*)	case "$usethreads" in
18222		define) echo "sethostent_r has no prototype, not using it." >&4 ;;
18223		esac
18224		d_sethostent_r=undef
18225		sethostent_r_proto=0
18226		;;
18227	esac
18228	;;
18229*)	sethostent_r_proto=0
18230	;;
18231esac
18232
18233: see if setitimer exists
18234set setitimer d_setitimer
18235eval $inlibc
18236
18237: see if setlinebuf exists
18238set setlinebuf d_setlinebuf
18239eval $inlibc
18240
18241: see if this system has wctype.h
18242set wctype.h i_wctype
18243eval $inhdr
18244
18245: see if towupper exists
18246set towupper d_towupper
18247eval $inlibc
18248
18249: check for setlocale function and behavior
18250case "$d_setlocale" in
18251'')
18252$cat >&4 <<EOM
18253
18254Checking to see if you have setlocale() and its behavior
18255EOM
18256$cat >try.c <<EOCP
18257#include <stdlib.h>
18258#include <string.h>
18259#$i_locale I_LOCALE
18260#ifdef I_LOCALE
18261#  include <locale.h>
18262#endif
18263#$i_wctype I_WCTYPE
18264#ifdef I_WCTYPE
18265#  include <wctype.h>
18266#endif
18267
18268int main() {
18269    const char * invalid_name = "\a";   /* This is really invalid! */
18270    int accepts_any_locale_name = 0;
18271    int has_C_UTF8 = 0;
18272    unsigned char bad_setlocale = 255;
18273
18274    /* If LC_CTYPE isn't defined the compilation will fail, and locales will be
18275     * disabled.  It's hard to imagine an instance where meaningful locale
18276     * handling could be done without LC_CTYPE */
18277    const char *  name = setlocale(LC_CTYPE, "C");
18278
18279    if (name == NULL || strcmp(name, "C") != 0) {
18280        exit(bad_setlocale);
18281    }
18282
18283    name = setlocale(LC_CTYPE, invalid_name);
18284    if (name != NULL) {
18285
18286        /* Let it pass if it accepts the name but gives back one of the C
18287         * locales */
18288        if (strcmp(name, "C") != 0 && strcmp(name, "C.UTF-8") != 0) {
18289            accepts_any_locale_name = 1;
18290        }
18291    }
18292
18293    name = setlocale(LC_CTYPE, "C.UTF-8");
18294    if (name != NULL) {
18295        unsigned char y_with_diaeresis = ('A' == 193) ? 0xDF : 0xFF;
18296
18297#$d_towupper HAS_TOWUPPER
18298#ifdef HAS_TOWUPPER
18299
18300        /* We assume that if the machine doesn't have the C99 towupper, it
18301         * doesn't have C.UTF-8, even if we successfully changed locales to
18302         * include it.  This seems safer even on platforms that didn't accept
18303         * the really invalid name */
18304
18305        if (towupper(y_with_diaeresis) == 0x178) {
18306            has_C_UTF8 = 1;
18307        }
18308
18309#endif
18310
18311    }
18312
18313#if 0
18314
18315    /* Currently unused code to determine if LC_ALL with disparate values uses
18316     * category = value pairs or positional, and to determine the separator
18317     * between the categories.  We could add code so that if the separator were
18318     * > '9', we subtract 10; similarly for 'Z' and 'z', and then just about
18319     * every possible ASCII separator would fit in the 5 bits available in the
18320     * exit code.  This would not be true in EBCDIC.  And then if LC_ALL is
18321     * positional, we probably would want to know the order of the categories.
18322     * Using a file between the C program and the shell script would really be
18323     * require to do that */
18324#ifdef LC_ALL
18325
18326    unsigned char min_separator = ' ' - 1;
18327    unsigned char separator = min_separator;
18328    int uses_name_value_pair_names = 0;
18329
18330    name = setlocale(LC_ALL, "C");
18331    if (name == NULL || strcmp(name, "C") != 0) {
18332        exit(bad_setlocale);
18333    }
18334
18335    if (has_C_UTF8) {
18336        char * pos;
18337
18338        name = setlocale(LC_CTYPE, "C.UTF-8");
18339        if (name == NULL) {
18340            exit(bad_setlocale);
18341        }
18342        name = setlocale(LC_ALL, NULL);
18343        if (name == NULL) {
18344            exit(bad_setlocale);
18345        }
18346
18347        pos = strstr(name, "LC_CTYPE" "=C.UTF-8");
18348        if (pos != NULL) {
18349            uses_name_value_pair_names = 1;
18350            if (pos == name) {
18351                separator = name[sizeof("LC_CTYPE=C.UTF-8") - 1];
18352            }
18353            else {
18354                separator = *(pos - 1);
18355            }
18356        }
18357        else {
18358            pos = strstr(name, "C.UTF-8");
18359            if (pos == NULL) {
18360                /* bad */
18361            }
18362            else if (pos == name) {
18363                separator = name[sizeof("C.UTF-8") - 1];
18364            }
18365            else {
18366                separator = *(pos - 1);
18367            }
18368        }
18369    }
18370
18371#endif
18372#endif
18373
18374    exit( 0 /* (separator - min_separator) << 3
18375        | uses_name_value_pair_names      << 2
18376          */
18377        | has_C_UTF8                      << 1
18378        | accepts_any_locale_name);
18379
18380}
18381EOCP
18382val=
18383set d_setlocale
18384eval $setvar
18385case $d_setlocale in
18386    $undef) d_setlocale_accepts_any_locale_name="$undef"
18387            d_has_C_UTF8="false"
18388            ;;
18389    *) set try
18390       if eval $compile; then
18391           echo "Your system has setlocale()..." >&4
18392           $run ./try
18393           case $? in
18394               0) echo "and it seems sane; you don't have a C.UTF-8 locale" >&4
18395                  d_setlocale="$define"
18396                  d_setlocale_accepts_any_locale_name="$undef"
18397                  d_has_C_UTF8="false"
18398                  ;;
18399               1) echo "and it seems sane, but accepts any locale name as valid" >&4
18400                  d_setlocale="$define"
18401                  d_setlocale_accepts_any_locale_name="$define"
18402                  d_has_C_UTF8="false"
18403                  ;;
18404               2) echo "and it seems sane; you have a C.UTF-8 locale" >&4
18405                  d_setlocale="$define"
18406                  d_setlocale_accepts_any_locale_name="$undef"
18407                  d_has_C_UTF8="true"
18408                  ;;
18409               3) echo "and it seems sane, but accepts any locale name as valid" >&4
18410                  d_setlocale="$define"
18411                  d_setlocale_accepts_any_locale_name="$define"
18412                  d_has_C_UTF8="true"
18413                  ;;
18414               *) echo "but it doesn't seem to work, so we won't use it." >&4
18415                  d_setlocale="$undef"
18416                  d_setlocale_accepts_any_locale_name="$undef"
18417                  d_has_C_UTF8="false"
18418                  ;;
18419           esac
18420       else
18421           echo "your system does not have setlocale()" >&4
18422           d_setlocale="$undef"
18423           d_setlocale_accepts_any_locale_name="$undef"
18424           d_has_C_UTF8="false"
18425       fi
18426esac
18427$rm_try
18428;;
18429*) val="$d_setlocale"
18430    set d_setlocale
18431    eval $setvar
18432    case "$d_setlocale" in
18433        $undef) echo "There may be other ways to set the locale on your system, so we need to ask:" >&4
18434        ;;
18435    esac
18436    rp="Does your system have the C.UTF-8 locale?"
18437    dflt=n
18438    . ./myread
18439    case "$ans" in
18440        [Yy]*) d_has_C_UTF8="true"
18441               c_utf8_locale=" or C.UTF-8"
18442               ;;
18443        *)     d_has_C_UTF8="false"
18444               c_utf8_locale=""
18445               ;;
18446    esac
18447    case "$d_setlocale" in
18448        $define)
18449            rp="When you set your locale to something besides C$c_utf8_locale, does it do so, or just pretend to?" >&4
18450            dflt=n
18451            . ./myread
18452            case "$ans" in
18453                true|[Yy]*)
18454		   d_setlocale_accepts_any_locale_name="$undef"
18455		   ;;
18456		*) d_setlocale_accepts_any_locale_name="$define"
18457		   ;;
18458            esac
18459            ;;
18460        *) d_setlocale_accepts_any_locale_name="$undef"
18461	   ;;
18462    esac
18463esac
18464
18465: see if setlocale_r exists
18466set setlocale_r d_setlocale_r
18467eval $inlibc
18468case "$d_setlocale_r" in
18469"$define")
18470	hdrs="$i_systypes sys/types.h define stdio.h $i_locale locale.h"
18471	case "$d_setlocale_r_proto:$usethreads" in
18472	":define")	d_setlocale_r_proto=define
18473		set d_setlocale_r_proto setlocale_r $hdrs
18474		eval $hasproto ;;
18475	*)	;;
18476	esac
18477	case "$d_setlocale_r_proto" in
18478	define)
18479	case "$setlocale_r_proto" in
18480	''|0) try='int setlocale_r(int, const char*, char*, int);'
18481	./protochk "$extern_C $try" $hdrs && setlocale_r_proto=I_ICBI ;;
18482	esac
18483	case "$setlocale_r_proto" in
18484	''|0)	d_setlocale_r=undef
18485		setlocale_r_proto=0
18486		echo "Disabling setlocale_r, cannot determine prototype." >&4 ;;
18487	* )	case "$setlocale_r_proto" in
18488		REENTRANT_PROTO*) ;;
18489		*) setlocale_r_proto="REENTRANT_PROTO_$setlocale_r_proto" ;;
18490		esac
18491		echo "Prototype: $try" ;;
18492	esac
18493	;;
18494	*)	case "$usethreads" in
18495		define) echo "setlocale_r has no prototype, not using it." >&4 ;;
18496		esac
18497		d_setlocale_r=undef
18498		setlocale_r_proto=0
18499		;;
18500	esac
18501	;;
18502*)	setlocale_r_proto=0
18503	;;
18504esac
18505
18506: see if setnetent exists
18507set setnetent d_setnent
18508eval $inlibc
18509
18510: see if setnetent_r exists
18511set setnetent_r d_setnetent_r
18512eval $inlibc
18513case "$d_setnetent_r" in
18514"$define")
18515	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18516	case "$d_setnetent_r_proto:$usethreads" in
18517	":define")	d_setnetent_r_proto=define
18518		set d_setnetent_r_proto setnetent_r $hdrs
18519		eval $hasproto ;;
18520	*)	;;
18521	esac
18522	case "$d_setnetent_r_proto" in
18523	define)
18524	case "$setnetent_r_proto" in
18525	''|0) try='int setnetent_r(int, struct netent_data*);'
18526	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=I_ID ;;
18527	esac
18528	case "$setnetent_r_proto" in
18529	''|0) try='void setnetent_r(int, struct netent_data*);'
18530	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=V_ID ;;
18531	esac
18532	case "$setnetent_r_proto" in
18533	''|0)	d_setnetent_r=undef
18534		setnetent_r_proto=0
18535		echo "Disabling setnetent_r, cannot determine prototype." >&4 ;;
18536	* )	case "$setnetent_r_proto" in
18537		REENTRANT_PROTO*) ;;
18538		*) setnetent_r_proto="REENTRANT_PROTO_$setnetent_r_proto" ;;
18539		esac
18540		echo "Prototype: $try" ;;
18541	esac
18542	;;
18543	*)	case "$usethreads" in
18544		define) echo "setnetent_r has no prototype, not using it." >&4 ;;
18545		esac
18546		d_setnetent_r=undef
18547		setnetent_r_proto=0
18548		;;
18549	esac
18550	;;
18551*)	setnetent_r_proto=0
18552	;;
18553esac
18554
18555: see if setprotoent exists
18556set setprotoent d_setpent
18557eval $inlibc
18558
18559: see if setpgid exists
18560set setpgid d_setpgid
18561eval $inlibc
18562
18563: see if setpgrp2 exists
18564set setpgrp2 d_setpgrp2
18565eval $inlibc
18566
18567: see if setpriority exists
18568set setpriority d_setprior
18569eval $inlibc
18570
18571: see if setproctitle exists
18572set setproctitle d_setproctitle
18573eval $inlibc
18574
18575: see if setprotoent_r exists
18576set setprotoent_r d_setprotoent_r
18577eval $inlibc
18578case "$d_setprotoent_r" in
18579"$define")
18580	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18581	case "$d_setprotoent_r_proto:$usethreads" in
18582	":define")	d_setprotoent_r_proto=define
18583		set d_setprotoent_r_proto setprotoent_r $hdrs
18584		eval $hasproto ;;
18585	*)	;;
18586	esac
18587	case "$d_setprotoent_r_proto" in
18588	define)
18589	case "$setprotoent_r_proto" in
18590	''|0) try='int setprotoent_r(int, struct protoent_data*);'
18591	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=I_ID ;;
18592	esac
18593	case "$setprotoent_r_proto" in
18594	''|0) try='void setprotoent_r(int, struct protoent_data*);'
18595	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=V_ID ;;
18596	esac
18597	case "$setprotoent_r_proto" in
18598	''|0)	d_setprotoent_r=undef
18599		setprotoent_r_proto=0
18600		echo "Disabling setprotoent_r, cannot determine prototype." >&4 ;;
18601	* )	case "$setprotoent_r_proto" in
18602		REENTRANT_PROTO*) ;;
18603		*) setprotoent_r_proto="REENTRANT_PROTO_$setprotoent_r_proto" ;;
18604		esac
18605		echo "Prototype: $try" ;;
18606	esac
18607	;;
18608	*)	case "$usethreads" in
18609		define) echo "setprotoent_r has no prototype, not using it." >&4 ;;
18610		esac
18611		d_setprotoent_r=undef
18612		setprotoent_r_proto=0
18613		;;
18614	esac
18615	;;
18616*)	setprotoent_r_proto=0
18617	;;
18618esac
18619
18620: see if setpwent exists
18621set setpwent d_setpwent
18622eval $inlibc
18623
18624: see if setpwent_r exists
18625set setpwent_r d_setpwent_r
18626eval $inlibc
18627case "$d_setpwent_r" in
18628"$define")
18629	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
18630	case "$d_setpwent_r_proto:$usethreads" in
18631	":define")	d_setpwent_r_proto=define
18632		set d_setpwent_r_proto setpwent_r $hdrs
18633		eval $hasproto ;;
18634	*)	;;
18635	esac
18636	case "$d_setpwent_r_proto" in
18637	define)
18638	case "$setpwent_r_proto" in
18639	''|0) try='int setpwent_r(FILE**);'
18640	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=I_H ;;
18641	esac
18642	case "$setpwent_r_proto" in
18643	''|0) try='void setpwent_r(FILE**);'
18644	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=V_H ;;
18645	esac
18646	case "$setpwent_r_proto" in
18647	''|0)	d_setpwent_r=undef
18648		setpwent_r_proto=0
18649		echo "Disabling setpwent_r, cannot determine prototype." >&4 ;;
18650	* )	case "$setpwent_r_proto" in
18651		REENTRANT_PROTO*) ;;
18652		*) setpwent_r_proto="REENTRANT_PROTO_$setpwent_r_proto" ;;
18653		esac
18654		echo "Prototype: $try" ;;
18655	esac
18656	;;
18657	*)	case "$usethreads" in
18658		define) echo "setpwent_r has no prototype, not using it." >&4 ;;
18659		esac
18660		d_setpwent_r=undef
18661		setpwent_r_proto=0
18662		;;
18663	esac
18664	;;
18665*)	setpwent_r_proto=0
18666	;;
18667esac
18668
18669: see if setregid exists
18670set setregid d_setregid
18671eval $inlibc
18672set setresgid d_setresgid
18673eval $inlibc
18674
18675: see if setreuid exists
18676set setreuid d_setreuid
18677eval $inlibc
18678set setresuid d_setresuid
18679eval $inlibc
18680
18681: see if setrgid exists
18682set setrgid d_setrgid
18683eval $inlibc
18684
18685: see if setruid exists
18686set setruid d_setruid
18687eval $inlibc
18688
18689: see if setservent exists
18690set setservent d_setsent
18691eval $inlibc
18692
18693: see if setservent_r exists
18694set setservent_r d_setservent_r
18695eval $inlibc
18696case "$d_setservent_r" in
18697"$define")
18698	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18699	case "$d_setservent_r_proto:$usethreads" in
18700	":define")	d_setservent_r_proto=define
18701		set d_setservent_r_proto setservent_r $hdrs
18702		eval $hasproto ;;
18703	*)	;;
18704	esac
18705	case "$d_setservent_r_proto" in
18706	define)
18707	case "$setservent_r_proto" in
18708	''|0) try='int setservent_r(int, struct servent_data*);'
18709	./protochk "$extern_C $try" $hdrs && setservent_r_proto=I_ID ;;
18710	esac
18711	case "$setservent_r_proto" in
18712	''|0) try='void setservent_r(int, struct servent_data*);'
18713	./protochk "$extern_C $try" $hdrs && setservent_r_proto=V_ID ;;
18714	esac
18715	case "$setservent_r_proto" in
18716	''|0)	d_setservent_r=undef
18717		setservent_r_proto=0
18718		echo "Disabling setservent_r, cannot determine prototype." >&4 ;;
18719	* )	case "$setservent_r_proto" in
18720		REENTRANT_PROTO*) ;;
18721		*) setservent_r_proto="REENTRANT_PROTO_$setservent_r_proto" ;;
18722		esac
18723		echo "Prototype: $try" ;;
18724	esac
18725	;;
18726	*)	case "$usethreads" in
18727		define) echo "setservent_r has no prototype, not using it." >&4 ;;
18728		esac
18729		d_setservent_r=undef
18730		setservent_r_proto=0
18731		;;
18732	esac
18733	;;
18734*)	setservent_r_proto=0
18735	;;
18736esac
18737
18738: see if setsid exists
18739set setsid d_setsid
18740eval $inlibc
18741
18742: see if setvbuf exists
18743set setvbuf d_setvbuf
18744eval $inlibc
18745
18746: see if shmctl exists
18747set shmctl d_shmctl
18748eval $inlibc
18749
18750: see if shmget exists
18751set shmget d_shmget
18752eval $inlibc
18753
18754: see if shmat exists
18755set shmat d_shmat
18756eval $inlibc
18757: see what shmat returns
18758case "$d_shmat" in
18759"$define")
18760	$cat >shmat.c <<'END'
18761#include <sys/shm.h>
18762void *shmat();
18763END
18764	if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
18765		shmattype='void *'
18766	else
18767		shmattype='char *'
18768	fi
18769	echo "and it returns ($shmattype)." >&4
18770	: see if a prototype for shmat is available
18771	xxx=`./findhdr sys/shm.h`
18772	$cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
18773	if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
18774		val="$define"
18775	else
18776		val="$undef"
18777	fi
18778	$rm -f shmat.[co]
18779	;;
18780*)
18781	val="$undef"
18782	;;
18783esac
18784set d_shmatprototype
18785eval $setvar
18786
18787: see if shmdt exists
18788set shmdt d_shmdt
18789eval $inlibc
18790
18791: see how much of the 'shm*(2)' library is present.
18792h_shm=true
18793echo " "
18794case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
18795*"$undef"*) h_shm=false;;
18796esac
18797case "$osname" in
18798freebsd)
18799    case "`ipcs 2>&1`" in
18800    "SVID shared memory"*"not configured"*)
18801	echo "Your $osname does not have the shm*(2) configured." >&4
18802        h_shm=false
18803	val="$undef"
18804	set shmctl d_shmctl
18805	eval $setvar
18806	set shmget d_shmget
18807	eval $setvar
18808	set shmat d_shmat
18809	eval $setvar
18810	set shmdt d_shmdt
18811	eval $setvar
18812	;;
18813    esac
18814    ;;
18815esac
18816: we could also check for sys/ipc.h ...
18817if $h_shm && $test `./findhdr sys/shm.h`; then
18818	echo "You have the full shm*(2) library." >&4
18819	val="$define"
18820else
18821	echo "You don't have the full shm*(2) library." >&4
18822	val="$undef"
18823fi
18824set d_shm
18825eval $setvar
18826
18827: see if we have sigaction
18828echo " "
18829if set sigaction val -f d_sigaction; eval $csym; $val; then
18830	echo 'sigaction() found.' >&4
18831	$cat > try.c <<EOP
18832#include <stdio.h>
18833#include <sys/types.h>
18834#include <signal.h>
18835#$i_stdlib I_STDLIB
18836#ifdef I_STDLIB
18837#include <stdlib.h>
18838#endif
18839int main()
18840{
18841    struct sigaction act, oact;
18842    act.sa_flags = 0;
18843    oact.sa_handler = 0;
18844    /* so that act and oact are used */
18845    exit(act.sa_flags == 0 &&  oact.sa_handler == 0);
18846}
18847EOP
18848	set try
18849	if eval $compile_ok; then
18850		val="$define"
18851	else
18852		echo "But you don't seem to have a usable struct sigaction." >&4
18853		val="$undef"
18854	fi
18855else
18856	echo 'sigaction NOT found.' >&4
18857	val="$undef"
18858fi
18859set d_sigaction; eval $setvar
18860$rm_try
18861
18862: see what type pids are declared as in the kernel
18863rp="What is the type of process ids on this system?"
18864set pid_t pidtype int stdio.h sys/types.h
18865eval $typedef_ask
18866
18867: see what type uids are declared as in the kernel
18868echo " "
18869echo "Looking for the type for user ids returned by getuid()."
18870set uid_t uidtype xxx stdio.h sys/types.h
18871eval $typedef
18872case "$uidtype" in
18873xxx)
18874	xxx=`./findhdr sys/user.h`
18875	set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
18876	case $1 in
18877	unsigned) dflt="$1 $2" ;;
18878	*) dflt="$1" ;;
18879	esac
18880	;;
18881*) dflt="$uidtype";;
18882esac
18883case "$uidtype" in
18884uid_t)	echo "uid_t found." ;;
18885*)	rp="What is the type for user ids returned by getuid()?"
18886	. ./myread
18887	uidtype="$ans"
18888	;;
18889esac
18890
18891: Define hasfield_t macro for Configure internal use
18892hasfield_t='varname=$1; struct=$2; type=$3; field=$4; shift; shift; shift; shift;
18893while $test $# -ge 2; do
18894    case "$1" in
18895	$define) echo "#include <$2>";;
18896    esac ;
18897    shift 2;
18898done > try.c;
18899echo "int main () { $struct foo; $type bar = foo.$field; }" >> try.c;
18900set try;
18901if eval $compile; then
18902	val="$define";
18903else
18904	val="$undef";
18905fi;
18906set $varname;
18907eval $setvar;
18908$rm_try'
18909
18910: see what siginfo fields we have
18911case "$d_sigaction" in
18912"$define")
18913	echo "Checking if your siginfo_t has si_errno field...">&4
18914	set d_siginfo_si_errno siginfo_t int si_errno $d_sigaction signal.h
18915	eval $hasfield_t;
18916
18917	echo "Checking if your siginfo_t has si_pid field...">&4
18918	set d_siginfo_si_pid siginfo_t $pidtype si_pid $d_sigaction signal.h
18919	eval $hasfield_t;
18920
18921	echo "Checking if your siginfo_t has si_uid field...">&4
18922	set d_siginfo_si_uid siginfo_t $uidtype si_uid $d_sigaction signal.h
18923	eval $hasfield_t;
18924
18925	echo "Checking if your siginfo_t has si_addr field...">&4
18926	set d_siginfo_si_addr siginfo_t "void *" si_addr $d_sigaction signal.h
18927	eval $hasfield_t;
18928
18929	echo "Checking if your siginfo_t has si_status field...">&4
18930	set d_siginfo_si_status siginfo_t int si_status $d_sigaction signal.h
18931	eval $hasfield_t;
18932
18933	echo "Checking if your siginfo_t has si_band field...">&4
18934	set d_siginfo_si_band siginfo_t long si_band $d_sigaction signal.h
18935	eval $hasfield_t;
18936
18937	echo "Checking if your siginfo_t has si_value field...">&4
18938	set d_siginfo_si_value siginfo_t "union sigval" si_value $d_sigaction signal.h
18939	eval $hasfield_t;
18940
18941	echo "Checking if your siginfo_t has si_fd field...">&4
18942	set d_siginfo_si_fd siginfo_t int si_fd $d_sigaction signal.h
18943	eval $hasfield_t;
18944
18945	;;
18946*)
18947	d_siginfo_si_errno="$undef"
18948	d_siginfo_si_pid="$undef"
18949	d_siginfo_si_uid="$undef"
18950	d_siginfo_si_addr="$undef"
18951	d_siginfo_si_status="$undef"
18952	d_siginfo_si_band="$undef"
18953	d_siginfo_si_value="$undef"
18954	d_siginfo_si_fd="$undef"
18955	;;
18956esac
18957
18958: see if this is a sunmath.h system
18959set sunmath.h i_sunmath
18960eval $inhdr
18961
18962: see if signbit exists
18963$echo $n "Checking to see if you have signbit() available to work on $nvtype... $c" >&4
18964$cat >try.c <<EOCP
18965#$i_sunmath I_SUNMATH
18966#include <math.h>
18967#ifdef I_SUNMATH  /* Solaris special math library */
18968#  include <sunmath.h>
18969#endif
18970#define NV $nvtype
18971int main(int argc, char **argv)
18972{
18973    NV x = 0.0;
18974    NV y = -1.0;
18975    if ((signbit(x) == 0) && (signbit(y) != 0))
18976	return 0;
18977    else
18978	return 1;
18979}
18980EOCP
18981val="$undef"
18982set try
18983if eval $compile; then
18984    if $run ./try; then
18985        $echo "Yes." >&4
18986	val="$define"
18987    else
18988        $echo "Signbit seems to be available, but doesn't work as I expected."
18989        $echo "I won't use it." >&4
18990	val="$undef"
18991    fi
18992else
18993    $echo "Nope." >&4
18994    dflt="$undef"
18995fi
18996set d_signbit
18997eval $setvar
18998$rm_try
18999
19000: see if sigprocmask exists
19001set sigprocmask d_sigprocmask
19002eval $inlibc
19003
19004: see if sigsetjmp exists
19005echo " "
19006case "$d_sigsetjmp" in
19007'')
19008	$cat >try.c <<EOP
19009#include <setjmp.h>
19010#$i_stdlib I_STDLIB
19011#ifdef I_STDLIB
19012#include <stdlib.h>
19013#endif
19014sigjmp_buf env;
19015int set = 1;
19016int main()
19017{
19018	if (sigsetjmp(env,1))
19019		exit(set);
19020	set = 0;
19021	siglongjmp(env, 1);
19022	exit(1);
19023}
19024EOP
19025	set try
19026	if eval $compile; then
19027		if $run ./try >/dev/null 2>&1; then
19028			echo "POSIX sigsetjmp found." >&4
19029			val="$define"
19030		else
19031			$cat >&4 <<EOM
19032Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
19033I'll ignore them.
19034EOM
19035			val="$undef"
19036		fi
19037	else
19038		echo "sigsetjmp not found." >&4
19039		val="$undef"
19040	fi
19041	;;
19042*) val="$d_sigsetjmp"
19043	case "$d_sigsetjmp" in
19044	$define) echo "POSIX sigsetjmp found." >&4;;
19045	$undef) echo "sigsetjmp not found." >&4;;
19046	esac
19047	;;
19048esac
19049set d_sigsetjmp
19050eval $setvar
19051$rm_try
19052
19053: see if snprintf exists
19054set snprintf d_snprintf
19055eval $inlibc
19056
19057: see if vsnprintf exists
19058set vsnprintf d_vsnprintf
19059eval $inlibc
19060
19061case "$d_snprintf-$d_vsnprintf" in
19062"$define-$define")
19063    $cat <<EOM
19064Checking whether your snprintf() and vsnprintf() work okay...
19065EOM
19066    $cat >try.c <<'EOCP'
19067/* v?snprintf testing logic courtesy of Russ Allbery.
19068 * According to C99:
19069 * - if the buffer is too short it still must be \0-terminated
19070 * - if the buffer is too short the potentially required length
19071 *   must be returned and not -1
19072 * - if the buffer is NULL the potentially required length
19073 *   must be returned and not -1 or core dump
19074 */
19075#include <stdio.h>
19076#include <stdarg.h>
19077
19078char buf[2];
19079
19080int test (char *format, ...)
19081{
19082    va_list args;
19083    int count;
19084
19085    va_start (args, format);
19086    count = vsnprintf (buf, sizeof buf, format, args);
19087    va_end (args);
19088    return count;
19089}
19090
19091int main ()
19092{
19093    return ((test ("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0'
19094             && snprintf (NULL, 0, "%s", "abcd") == 4) ? 0 : 1);
19095}
19096EOCP
19097    set try
19098    if eval $compile; then
19099	`$run ./try`
19100	case "$?" in
19101	0) echo "Your snprintf() and vsnprintf() seem to be working okay." ;;
19102	*) cat <<EOM >&4
19103Your snprintf() and snprintf() don't seem to be working okay.
19104EOM
19105	   d_snprintf="$undef"
19106	   d_vsnprintf="$undef"
19107	   ;;
19108	esac
19109    else
19110	echo "(I can't seem to compile the test program--assuming they don't)"
19111	d_snprintf="$undef"
19112	d_vsnprintf="$undef"
19113    fi
19114    $rm_try
19115    ;;
19116esac
19117
19118: see if sockatmark exists
19119set sockatmark d_sockatmark
19120eval $inlibc
19121
19122: see if prototype for sockatmark is available
19123echo " "
19124set d_sockatmarkproto sockatmark $d_socket sys/socket.h
19125eval $hasproto
19126
19127: see if socks5_init exists
19128set socks5_init d_socks5_init
19129eval $inlibc
19130
19131: see if srand48_r exists
19132set srand48_r d_srand48_r
19133eval $inlibc
19134case "$d_srand48_r" in
19135"$define")
19136	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
19137	case "$d_srand48_r_proto:$usethreads" in
19138	":define")	d_srand48_r_proto=define
19139		set d_srand48_r_proto srand48_r $hdrs
19140		eval $hasproto ;;
19141	*)	;;
19142	esac
19143	case "$d_srand48_r_proto" in
19144	define)
19145	case "$srand48_r_proto" in
19146	''|0) try='int srand48_r(long, struct drand48_data*);'
19147	./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;;
19148	esac
19149	case "$srand48_r_proto" in
19150	''|0)	d_srand48_r=undef
19151		srand48_r_proto=0
19152		echo "Disabling srand48_r, cannot determine prototype." >&4 ;;
19153	* )	case "$srand48_r_proto" in
19154		REENTRANT_PROTO*) ;;
19155		*) srand48_r_proto="REENTRANT_PROTO_$srand48_r_proto" ;;
19156		esac
19157		echo "Prototype: $try" ;;
19158	esac
19159	;;
19160	*)	case "$usethreads" in
19161		define) echo "srand48_r has no prototype, not using it." >&4 ;;
19162		esac
19163		d_srand48_r=undef
19164		srand48_r_proto=0
19165		;;
19166	esac
19167	;;
19168*)	srand48_r_proto=0
19169	;;
19170esac
19171
19172: see if srandom_r exists
19173set srandom_r d_srandom_r
19174eval $inlibc
19175case "$d_srandom_r" in
19176"$define")
19177	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
19178	case "$d_srandom_r_proto:$usethreads" in
19179	":define")	d_srandom_r_proto=define
19180		set d_srandom_r_proto srandom_r $hdrs
19181		eval $hasproto ;;
19182	*)	;;
19183	esac
19184	case "$d_srandom_r_proto" in
19185	define)
19186	case "$srandom_r_proto" in
19187	''|0) try='int srandom_r(unsigned int, struct random_data*);'
19188	./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;;
19189	esac
19190	case "$srandom_r_proto" in
19191	''|0)	d_srandom_r=undef
19192		srandom_r_proto=0
19193		echo "Disabling srandom_r, cannot determine prototype." >&4 ;;
19194	* )	case "$srandom_r_proto" in
19195		REENTRANT_PROTO*) ;;
19196		*) srandom_r_proto="REENTRANT_PROTO_$srandom_r_proto" ;;
19197		esac
19198		echo "Prototype: $try" ;;
19199	esac
19200	;;
19201	*)	case "$usethreads" in
19202		define) echo "srandom_r has no prototype, not using it." >&4 ;;
19203		esac
19204		d_srandom_r=undef
19205		srandom_r_proto=0
19206		;;
19207	esac
19208	;;
19209*)	srandom_r_proto=0
19210	;;
19211esac
19212
19213: see if prototype for setresgid is available
19214echo " "
19215set d_sresgproto setresgid $i_unistd unistd.h
19216eval $hasproto
19217
19218: see if prototype for setresuid is available
19219echo " "
19220set d_sresuproto setresuid $i_unistd unistd.h
19221eval $hasproto
19222
19223: see if stat exists
19224set stat d_stat
19225eval $inlibc
19226
19227: see if sys/stat.h is available
19228set sys/stat.h i_sysstat
19229eval $inhdr
19230
19231: see if stat knows about block sizes
19232echo " "
19233echo "Checking to see if your struct stat has st_blocks field..." >&4
19234set d_statblks stat st_blocks $i_sysstat sys/stat.h
19235eval $hasfield
19236
19237: see if this is a sys/vfs.h system
19238set sys/vfs.h i_sysvfs
19239eval $inhdr
19240
19241: see if this is a sys/statfs.h system
19242set sys/statfs.h i_sysstatfs
19243eval $inhdr
19244
19245: Check for statfs_s
19246echo " "
19247echo "Checking to see if your system supports struct statfs..." >&4
19248set 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
19249eval $hasstruct
19250case "$d_statfs_s" in
19251"$define")      echo "Yes, it does."   ;;
19252*)              echo "No, it doesn't." ;;
19253esac
19254
19255: see if struct statfs knows about f_flags
19256case "$d_statfs_s" in
19257define)
19258	echo " "
19259	echo "Checking to see if your struct statfs has f_flags field..." >&4
19260	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
19261	eval $hasfield
19262	;;
19263*)	val="$undef"
19264	set d_statfs_f_flags
19265	eval $setvar
19266	;;
19267esac
19268case "$d_statfs_f_flags" in
19269"$define")      echo "Yes, it does."   ;;
19270*)              echo "No, it doesn't." ;;
19271esac
19272
19273: see what flavor, if any, of static inline is supported
19274echo " "
19275echo "Checking to see if your system supports static inline..."
19276$cat > try.c <<'EOCP'
19277#include <stdlib.h>
19278extern int f_via_a(int x);
19279extern int f_via_b(int x);
19280int main(int argc, char **argv)
19281{
19282    int y;
19283
19284    y = f_via_a(0);
19285#ifdef USE_B
19286    y = f_via_b(0);
19287#endif
19288    if (y == 42) {
19289        return EXIT_SUCCESS;
19290    }
19291    else {
19292        return EXIT_FAILURE;
19293    }
19294}
19295EOCP
19296$cat > a.c <<'EOCP'
19297static INLINE int f(int x) {
19298    int y;
19299    y = x + 42;
19300    return y;
19301}
19302
19303int f_via_a(int x)
19304{
19305    return f(x);
19306}
19307EOCP
19308$cat > b.c <<'EOCP'
19309extern int f(int x);
19310
19311int f_via_b(int x)
19312{
19313    return f(x);
19314}
19315EOCP
19316
19317# Respect a hint (or previous) value for perl_static_inline, if there is one.
19318case "$perl_static_inline" in
19319'')	# Check the various possibilities, and break out on success.
19320	# For gcc, prefer __inline__, which will still permit
19321	# cflags.SH to add in -ansi.
19322	case "$gccversion" in
19323		'') xxx="inline __inline__ __inline _inline";;
19324		*)  xxx="__inline__ inline __inline _inline";;
19325	esac
19326	for inline in $xxx; do
19327		set try -DINLINE=$inline a.c
19328		if eval $compile && $run ./try; then
19329			# Now make sure there is no external linkage of static
19330			# functions
19331			set try -DINLINE=$inline -DUSE_B a.c b.c
19332			if eval $compile && $run ./try; then
19333				$echo "Your compiler supports static $inline, " >&4
19334				$echo "but it also creates an external definition," >&4
19335				$echo "so I won't use it." >&4
19336				val=$undef
19337			else
19338				$echo "Your compiler supports static $inline." >&4
19339				val=$define
19340				perl_static_inline="static $inline";
19341				break;
19342			fi
19343		else
19344			$echo "Your compiler does NOT support static $inline." >&4
19345			val="$undef"
19346		fi
19347	done
19348	;;
19349*inline*) # Some variant of inline exists.
19350	echo "Keeping your $hint value of $perl_static_inline."
19351	val=$define
19352	;;
19353static)  # No inline capabilities
19354	echo "Keeping your $hint value of $perl_static_inline."
19355	val=$undef
19356	;;
19357*)  # Unrecognized previous value -- blindly trust the supplied
19358	# value and hope it makes sense.  Use old value for
19359	# d_static_inline, if there is one.
19360	echo "Keeping your $hint value of $perl_static_inline."
19361	case "$d_static_inline" in
19362		'') val=$define ;;
19363		*)  val=$d_static_inline ;;
19364	esac
19365	;;
19366esac
19367# Fallback to plain 'static' if nothing worked.
19368case "$perl_static_inline" in
19369'')
19370	perl_static_inline="static"
19371	val=$undef
19372	;;
19373esac
19374set d_static_inline
19375eval $setvar
19376$rm -f a.[co] b.[co]
19377$rm_try
19378
19379: Check stream access
19380$cat >&4 <<EOM
19381Checking how to access stdio streams by file descriptor number...
19382EOM
19383case "$stdio_stream_array" in
19384'')	$cat >try.c <<EOCP
19385#include <stdio.h>
19386int main() {
19387  if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
19388    printf("yes\n");
19389}
19390EOCP
19391	for s in _iob __iob __sF
19392	do
19393	        set try -DSTDIO_STREAM_ARRAY=$s
19394		if eval $compile; then
19395			case "`$run ./try`" in
19396			yes)	stdio_stream_array=$s; break ;;
19397			esac
19398		fi
19399	done
19400	$rm_try
19401esac
19402case "$stdio_stream_array" in
19403'')	$cat >&4 <<EOM
19404I can't figure out how to access stdio streams by file descriptor number.
19405EOM
19406	d_stdio_stream_array="$undef"
19407	;;
19408*)	$cat >&4 <<EOM
19409You can access stdio streams by file descriptor number by the $stdio_stream_array array.
19410EOM
19411	d_stdio_stream_array="$define"
19412	;;
19413esac
19414
19415: see if strcoll exists
19416set strcoll d_strcoll
19417eval $inlibc
19418
19419: see if strerror_l exists
19420set strerror_l d_strerror_l
19421eval $inlibc
19422
19423: see if strerror_r exists
19424set strerror_r d_strerror_r
19425eval $inlibc
19426case "$d_strerror_r" in
19427"$define")
19428	hdrs="$i_systypes sys/types.h define stdio.h define string.h"
19429	case "$d_strerror_r_proto:$usethreads" in
19430	":define")	d_strerror_r_proto=define
19431		set d_strerror_r_proto strerror_r $hdrs
19432		eval $hasproto ;;
19433	*)	;;
19434	esac
19435	case "$d_strerror_r_proto" in
19436	define)
19437	case "$strerror_r_proto" in
19438	''|0) try='int strerror_r(int, char*, size_t);'
19439	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBW ;;
19440	esac
19441	case "$strerror_r_proto" in
19442	''|0) try='int strerror_r(int, char*, int);'
19443	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBI ;;
19444	esac
19445	case "$strerror_r_proto" in
19446	''|0) try='char* strerror_r(int, char*, size_t);'
19447	./protochk "$extern_C $try" $hdrs && strerror_r_proto=B_IBW ;;
19448	esac
19449	case "$strerror_r_proto" in
19450	''|0)	d_strerror_r=undef
19451		strerror_r_proto=0
19452		echo "Disabling strerror_r, cannot determine prototype." >&4 ;;
19453	* )	case "$strerror_r_proto" in
19454		REENTRANT_PROTO*) ;;
19455		*) strerror_r_proto="REENTRANT_PROTO_$strerror_r_proto" ;;
19456		esac
19457		echo "Prototype: $try" ;;
19458	esac
19459	;;
19460	*)	case "$usethreads" in
19461		define) echo "strerror_r has no prototype, not using it." >&4 ;;
19462		esac
19463		d_strerror_r=undef
19464		strerror_r_proto=0
19465		;;
19466	esac
19467	;;
19468*)	strerror_r_proto=0
19469	;;
19470esac
19471
19472: see if strftime exists
19473set strftime d_strftime
19474eval $inlibc
19475
19476: see if strlcat exists
19477: We need both a prototype in string.h and the symbol in libc.
19478echo " "
19479d_strlcat_proto=''
19480xx1="#$d_gnulibc HAS_GNULIBC"
19481xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
19482xx3='#   define _GNU_SOURCE'
19483xx4='#endif'
19484set d_strlcat_proto strlcat literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
19485eval $hasproto
19486case "$d_strlcat_proto" in
19487    define) # see if strlcat exists
19488	set strlcat d_strlcat
19489	eval $inlibc
19490	;;
19491    *)  val=$undef
19492	set d_strlcat
19493	eval $setvar
19494	;;
19495esac
19496
19497: see if strlcpy exists
19498: We need both a prototype in string.h and the symbol in libc.
19499echo " "
19500d_strlcpy_proto=''
19501xx1="#$d_gnulibc HAS_GNULIBC"
19502xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
19503xx3='#   define _GNU_SOURCE'
19504xx4='#endif'
19505set d_strlcpy_proto strlcpy literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
19506eval $hasproto
19507case "$d_strlcpy_proto" in
19508    define) # see if strlcpy exists
19509	set strlcpy d_strlcpy
19510	eval $inlibc
19511	;;
19512    *)  val=$undef
19513	set d_strlcpy
19514	eval $setvar
19515	;;
19516esac
19517
19518: see if strnlen exists
19519set strnlen d_strnlen
19520eval $inlibc
19521
19522: see if strtod exists
19523set strtod d_strtod
19524eval $inlibc
19525
19526: see if strtod_l exists
19527set strtod_l d_strtod_l
19528eval $inlibc
19529
19530: see if strtol exists
19531set strtol d_strtol
19532eval $inlibc
19533
19534: see if strtold exists
19535set strtold d_strtold
19536eval $inlibc
19537
19538: see if strtold_l exists
19539set strtold_l d_strtold_l
19540eval $inlibc
19541
19542: see if strtoll exists
19543set strtoll d_strtoll
19544eval $inlibc
19545
19546case "$d_longlong-$d_strtoll" in
19547"$define-$define")
19548	$cat <<EOM
19549Checking whether your strtoll() works okay...
19550EOM
19551	$cat >try.c <<'EOCP'
19552#include <errno.h>
19553#ifdef __hpux
19554#define strtoll __strtoll
19555#endif
19556#ifdef __EMX__
19557#define strtoll _strtoll
19558#endif
19559#include <stdio.h>
19560#include <stdlib.h>
19561static int bad = 0;
19562void check(const char *s, long long ell, int een) {
19563	long long gll;
19564	errno = 0;
19565	gll = strtoll(s, 0, 10);
19566	if (!((gll == ell) && (errno == een)))
19567		bad++;
19568}
19569int main() {
19570	check(" 1",                                      1LL, 0);
19571	check(" 0",                                      0LL, 0);
19572	check("-1",                                     -1LL, 0);
19573	check("-9223372036854775808", -9223372036854775808LL, 0);
19574	check("-9223372036854775808", -9223372036854775808LL, 0);
19575	check(" 9223372036854775807",  9223372036854775807LL, 0);
19576	check("-9223372036854775808", -9223372036854775808LL, 0);
19577	check(" 9223372036854775808",  9223372036854775807LL, ERANGE);
19578	check("-9223372036854775809", -9223372036854775808LL, ERANGE);
19579	if (!bad)
19580		printf("ok\n");
19581}
19582EOCP
19583	set try
19584	if eval $compile; then
19585		yyy=`$run ./try`
19586		case "$yyy" in
19587		ok) echo "Your strtoll() seems to be working okay." ;;
19588		*) cat <<EOM >&4
19589Your strtoll() doesn't seem to be working okay.
19590EOM
19591		   d_strtoll="$undef"
19592		   ;;
19593		esac
19594	else
19595		echo "(I can't seem to compile the test program--assuming it doesn't)"
19596		d_strtoll="$undef"
19597	fi
19598	;;
19599esac
19600
19601: see if strtoq exists
19602set strtoq d_strtoq
19603eval $inlibc
19604
19605: see if strtoul exists
19606set strtoul d_strtoul
19607eval $inlibc
19608
19609case "$d_strtoul" in
19610"$define")
19611	$cat <<EOM
19612Checking whether your strtoul() works okay...
19613EOM
19614	$cat >try.c <<'EOCP'
19615#include <stdlib.h>
19616#include <errno.h>
19617#include <stdio.h>
19618static int bad = 0;
19619void check(const char *s, unsigned long eul, int een) {
19620	unsigned long gul;
19621	errno = 0;
19622	gul = strtoul(s, 0, 10);
19623	if (!((gul == eul) && (errno == een)))
19624		bad++;
19625}
19626int main() {
19627	check(" 1", 1L, 0);
19628	check(" 0", 0L, 0);
19629EOCP
19630	case "$longsize" in
19631	8)
19632	    $cat >>try.c <<'EOCP'
19633	check("18446744073709551615", 18446744073709551615UL, 0);
19634	check("18446744073709551616", 18446744073709551615UL, ERANGE);
19635#if 0 /* strtoul() for /^-/ strings is undefined. */
19636	check("-1", 18446744073709551615UL, 0);
19637	check("-18446744073709551614", 2, 0);
19638	check("-18446744073709551615", 1, 0);
19639	check("-18446744073709551616", 18446744073709551615UL, ERANGE);
19640	check("-18446744073709551617", 18446744073709551615UL, ERANGE);
19641#endif
19642EOCP
19643		;;
19644	4)
19645		    $cat >>try.c <<'EOCP'
19646	check("4294967295", 4294967295UL, 0);
19647	check("4294967296", 4294967295UL, ERANGE);
19648#if 0 /* strtoul() for /^-/ strings is undefined. */
19649	check("-1", 4294967295UL, 0);
19650	check("-4294967294", 2, 0);
19651	check("-4294967295", 1, 0);
19652	check("-4294967296", 4294967295UL, ERANGE);
19653	check("-4294967297", 4294967295UL, ERANGE);
19654#endif
19655EOCP
19656		;;
19657	*)
19658: Should we write these tests to be more portable by sprintf-ing
19659: ~0 and then manipulating that char string as input for strtol?
19660		;;
19661	esac
19662	$cat >>try.c <<'EOCP'
19663	if (!bad)
19664		printf("ok\n");
19665	return 0;
19666}
19667EOCP
19668	set try
19669	if eval $compile; then
19670		case "`$run ./try`" in
19671		ok) echo "Your strtoul() seems to be working okay." ;;
19672		*) cat <<EOM >&4
19673Your strtoul() doesn't seem to be working okay.
19674EOM
19675		   d_strtoul="$undef"
19676		   ;;
19677		esac
19678	else
19679		echo "(I can't seem to compile the test program--assuming it doesn't)"
19680		d_strtoul="$undef"
19681	fi
19682	;;
19683esac
19684
19685: see if strtoull exists
19686set strtoull d_strtoull
19687eval $inlibc
19688
19689case "$d_longlong-$d_strtoull" in
19690"$define-$define")
19691	$cat <<EOM
19692Checking whether your strtoull() works okay...
19693EOM
19694	$cat >try.c <<'EOCP'
19695#include <stdlib.h>
19696#include <errno.h>
19697#ifdef __hpux
19698#define strtoull __strtoull
19699#endif
19700#include <stdio.h>
19701static int bad = 0;
19702void check(const char *s, long long eull, int een) {
19703	long long gull;
19704	errno = 0;
19705	gull = strtoull(s, 0, 10);
19706	if (!((gull == eull) && (errno == een)))
19707		bad++;
19708}
19709int main() {
19710	check(" 1",                                        1LL, 0);
19711	check(" 0",                                        0LL, 0);
19712	check("18446744073709551615",  18446744073709551615ULL, 0);
19713	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
19714#if 0 /* strtoull() for /^-/ strings is undefined. */
19715	check("-1",                    18446744073709551615ULL, 0);
19716	check("-18446744073709551614",                     2LL, 0);
19717	check("-18446744073709551615",                     1LL, 0);
19718	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
19719	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
19720#endif
19721	if (!bad)
19722		printf("ok\n");
19723}
19724EOCP
19725	set try
19726	if eval $compile; then
19727		case "`$run ./try`" in
19728		ok) echo "Your strtoull() seems to be working okay." ;;
19729		*) cat <<EOM >&4
19730Your strtoull() doesn't seem to be working okay.
19731EOM
19732		   d_strtoull="$undef"
19733		   ;;
19734		esac
19735	else
19736		echo "(I can't seem to compile the test program--assuming it doesn't)"
19737		d_strtoull="$undef"
19738	fi
19739	;;
19740esac
19741
19742: see if strtouq exists
19743set strtouq d_strtouq
19744eval $inlibc
19745
19746case "$d_strtouq" in
19747"$define")
19748	$cat <<EOM
19749Checking whether your strtouq() works okay...
19750EOM
19751	$cat >try.c <<'EOCP'
19752#include <stdlib.h>
19753#include <errno.h>
19754#include <stdio.h>
19755static int bad = 0;
19756void check(const char *s, unsigned long long eull, int een) {
19757	unsigned long long gull;
19758	errno = 0;
19759	gull = strtouq(s, 0, 10);
19760	if (!((gull == eull) && (errno == een)))
19761		bad++;
19762}
19763int main() {
19764	check(" 1",                                        1LL, 0);
19765	check(" 0",                                        0LL, 0);
19766	check("18446744073709551615",  18446744073709551615ULL, 0);
19767	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
19768#if 0 /* strtouq() for /^-/ strings is undefined. */
19769	check("-1",                    18446744073709551615ULL, 0);
19770	check("-18446744073709551614",                     2LL, 0);
19771	check("-18446744073709551615",                     1LL, 0);
19772	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
19773	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
19774#endif
19775	if (!bad)
19776		printf("ok\n");
19777	return 0;
19778}
19779EOCP
19780	set try
19781	if eval $compile; then
19782		case "`$run ./try`" in
19783		ok) echo "Your strtouq() seems to be working okay." ;;
19784		*) cat <<EOM >&4
19785Your strtouq() doesn't seem to be working okay.
19786EOM
19787		   d_strtouq="$undef"
19788		   ;;
19789		esac
19790	else
19791		echo "(I can't seem to compile the test program--assuming it doesn't)"
19792		d_strtouq="$undef"
19793	fi
19794	;;
19795esac
19796
19797: see if strxfrm exists
19798set strxfrm d_strxfrm
19799eval $inlibc
19800
19801: see if strxfrm_l exists
19802set strxfrm_l d_strxfrm_l
19803eval $inlibc
19804
19805: see if symlink exists
19806set symlink d_symlink
19807eval $inlibc
19808
19809: see if syscall exists
19810set syscall d_syscall
19811eval $inlibc
19812
19813: see if this is a sys/syscall.h system
19814set sys/syscall.h i_syssyscall
19815eval $inhdr
19816
19817: see if prototype for syscall is available
19818echo " "
19819set d_syscallproto syscall $i_unistd unistd.h $i_syssyscall sys/syscall.h
19820eval $hasproto
19821
19822: see if sysconf exists
19823set sysconf d_sysconf
19824eval $inlibc
19825
19826: see if sys_errlist[] exists
19827echo " "
19828if test "X$d_syserrlst" = X; then
19829	if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
19830		echo "You have sys_errlist[], so we could roll our own strerror."
19831		d_syserrlst="$define"
19832	else
19833		echo "You don't have sys_errlist[], so strerror() is welcome."
19834		d_syserrlst="$undef"
19835	fi
19836fi
19837
19838: see if system exists
19839set system d_system
19840eval $inlibc
19841
19842: see if tcgetpgrp exists
19843set tcgetpgrp d_tcgetpgrp
19844eval $inlibc
19845
19846: see if tcsetpgrp exists
19847set tcsetpgrp d_tcsetpgrp
19848eval $inlibc
19849
19850: see if prototype for telldir is available
19851echo " "
19852set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
19853eval $hasproto
19854
19855: see if tgamma exists
19856set tgamma d_tgamma
19857eval $inlibc
19858
19859: see what flavor, if any, of thread local storage is supported
19860echo " "
19861echo "Checking to see if your system supports C11 thread local storage..."
19862$cat > try.c <<'EOCP'
19863#include <stdio.h>
19864#include <stdlib.h>
19865#include <pthread.h>
19866
19867static int plus_one = 1;
19868static int minus_one = -1;
19869
19870PROBE_MACRO int *minion;
19871
19872int callback (const void *a, const void *b) {
19873    int val_a = *minion * *(const int *)a;
19874    int val_b = *minion * *(const int *)b;
19875    return val_a < val_b ? -1 : val_a > val_b;
19876}
19877
19878#define SIZE 8
19879
19880void *thread_function(void *arg) {
19881    /* thread local variables should start zeroed in each thread. */
19882    if (minion != NULL) {
19883        fprintf(stderr, "__thread variable started with %p, should be NULL\n",
19884                minion);
19885        exit(2);
19886    }
19887    minion = &minus_one;
19888
19889    int array[SIZE];
19890    unsigned int i;
19891    for (i = 0; i < SIZE; ++i) {
19892        /* "Hash randomisation" - this array isn't in sorted order: */
19893        array[i ^ 5] = i * i;
19894    }
19895
19896    qsort(array, SIZE, sizeof(int), callback);
19897
19898    int bad = 0;
19899    for (i = 0; i < SIZE; ++i) {
19900        int want = (SIZE - 1 - i) * (SIZE - 1 - i);
19901        int have = array[i];
19902        if (want != have) {
19903            ++bad;
19904            fprintf(stderr, "array[%u] - want %i, have %i\n", i, want, have);
19905        }
19906    }
19907    if (bad)
19908        exit(3);
19909
19910    return NULL;
19911}
19912
19913int main(int argc, char **argv) {
19914    if (minion != NULL) {
19915        fprintf(stderr, "__thread variable started with %p, should be NULL\n",
19916                minion);
19917        exit(4);
19918    }
19919
19920    minion = &plus_one;
19921
19922    pthread_t tid;
19923    int result = pthread_create(&tid, NULL, thread_function, NULL);
19924    if (result) {
19925        fprintf(stderr, "pthread_create failed (%d)\n", result);
19926        exit(5);
19927    }
19928
19929    result = pthread_join(tid, NULL);
19930    if (result) {
19931        fprintf(stderr, "pthread_join failed (%d)\n", result);
19932        exit(6);
19933    }
19934
19935    if (minion == NULL) {
19936        fprintf(stderr, "__thread variable should not be NULL\n");
19937        exit(7);
19938    }
19939    if (!(minion == &plus_one && *minion == 1)) {
19940        fprintf(stderr, "__thread variable should be %d @ %p, not %d @ %p\n",
19941                1, &plus_one, *minion, minion);
19942        exit(8);
19943    }
19944
19945    return 0;
19946}
19947EOCP
19948
19949# Respect a hint (or previous) value for perl_thread_local, if there is one.
19950case "$perl_thread_local" in
19951'')	# Check the various possibilities, and break out on success.
19952	for thread_local in _Thread_local __thread; do
19953		set try -DPROBE_MACRO=$thread_local
19954		if eval $compile && $run ./try; then
19955			$echo "Your compiler supports $thread_local." >&4
19956			val=$define
19957			perl_thread_local="$thread_local";
19958			break;
19959		fi
19960		$echo "Your compiler does NOT support $thread_local." >&4
19961		val="$undef"
19962	done
19963	;;
19964*thread*|*Thread*) # Some variant of thread local exists.
19965	echo "Keeping your $hint value of $perl_thread_local."
19966	val=$define
19967	;;
19968*)  # Unrecognized previous value -- blindly trust the supplied
19969	# value and hope it makes sense.  Use old value for
19970	# d_thread_local, if there is one.
19971	echo "Keeping your $hint value of $perl_thread_local."
19972	case "$d_thread_local" in
19973		'') val=$define ;;
19974		*)  val=$d_thread_local ;;
19975	esac
19976	;;
19977esac
19978set d_thread_local
19979eval $setvar
19980$rm_try
19981
19982: see if time exists
19983echo " "
19984if test "X$d_time" = X -o X"$timetype" = X; then
19985    if set time val -f d_time; eval $csym; $val; then
19986		echo 'time() found.' >&4
19987		val="$define"
19988		rp="What is the type returned by time() on this system?"
19989		set time_t timetype long stdio.h sys/types.h
19990		eval $typedef_ask
19991    else
19992		echo 'time() not found, hope that will do.' >&4
19993		val="$undef"
19994		timetype='int';
19995    fi
19996    set d_time
19997    eval $setvar
19998fi
19999
20000: see if timegm exists
20001set timegm d_timegm
20002eval $inlibc
20003
20004: see if this is a sys/times.h system
20005set sys/times.h i_systimes
20006eval $inhdr
20007
20008: see if times exists
20009echo " "
20010if set times val -f d_times; eval $csym; $val; then
20011	echo 'times() found.' >&4
20012	d_times="$define"
20013	inc=''
20014	case "$i_systimes" in
20015	"$define") inc='sys/times.h';;
20016	esac
20017	rp="What is the type returned by times() on this system?"
20018	set clock_t clocktype long stdio.h sys/types.h $inc
20019	eval $typedef_ask
20020else
20021	echo 'times() NOT found, hope that will do.' >&4
20022	d_times="$undef"
20023	clocktype='int'
20024fi
20025
20026: see if tmpnam_r exists
20027set tmpnam_r d_tmpnam_r
20028eval $inlibc
20029case "$d_tmpnam_r" in
20030"$define")
20031	hdrs="$i_systypes sys/types.h define stdio.h "
20032	case "$d_tmpnam_r_proto:$usethreads" in
20033	":define")	d_tmpnam_r_proto=define
20034		set d_tmpnam_r_proto tmpnam_r $hdrs
20035		eval $hasproto ;;
20036	*)	;;
20037	esac
20038	case "$d_tmpnam_r_proto" in
20039	define)
20040	case "$tmpnam_r_proto" in
20041	''|0) try='char* tmpnam_r(char*);'
20042	./protochk "$extern_C $try" $hdrs && tmpnam_r_proto=B_B ;;
20043	esac
20044	case "$tmpnam_r_proto" in
20045	''|0)	d_tmpnam_r=undef
20046		tmpnam_r_proto=0
20047		echo "Disabling tmpnam_r, cannot determine prototype." >&4 ;;
20048	* )	case "$tmpnam_r_proto" in
20049		REENTRANT_PROTO*) ;;
20050		*) tmpnam_r_proto="REENTRANT_PROTO_$tmpnam_r_proto" ;;
20051		esac
20052		echo "Prototype: $try" ;;
20053	esac
20054	;;
20055	*)	case "$usethreads" in
20056		define) echo "tmpnam_r has no prototype, not using it." >&4 ;;
20057		esac
20058		d_tmpnam_r=undef
20059		tmpnam_r_proto=0
20060		;;
20061	esac
20062	;;
20063*)	tmpnam_r_proto=0
20064	;;
20065esac
20066
20067: see if towlower exists
20068set towlower d_towlower
20069eval $inlibc
20070
20071: see if trunc exists
20072set trunc d_trunc
20073eval $inlibc
20074
20075: see if truncate exists
20076set truncate d_truncate
20077eval $inlibc
20078
20079: see if ttyname_r exists
20080set ttyname_r d_ttyname_r
20081eval $inlibc
20082case "$d_ttyname_r" in
20083"$define")
20084	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
20085	case "$d_ttyname_r_proto:$usethreads" in
20086	":define")	d_ttyname_r_proto=define
20087		set d_ttyname_r_proto ttyname_r $hdrs
20088		eval $hasproto ;;
20089	*)	;;
20090	esac
20091	case "$d_ttyname_r_proto" in
20092	define)
20093	case "$ttyname_r_proto" in
20094	''|0) try='int ttyname_r(int, char*, size_t);'
20095	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBW ;;
20096	esac
20097	case "$ttyname_r_proto" in
20098	''|0) try='int ttyname_r(int, char*, int);'
20099	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBI ;;
20100	esac
20101	case "$ttyname_r_proto" in
20102	''|0) try='char* ttyname_r(int, char*, int);'
20103	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=B_IBI ;;
20104	esac
20105	case "$ttyname_r_proto" in
20106	''|0)	d_ttyname_r=undef
20107		ttyname_r_proto=0
20108		echo "Disabling ttyname_r, cannot determine prototype." >&4 ;;
20109	* )	case "$ttyname_r_proto" in
20110		REENTRANT_PROTO*) ;;
20111		*) ttyname_r_proto="REENTRANT_PROTO_$ttyname_r_proto" ;;
20112		esac
20113		echo "Prototype: $try" ;;
20114	esac
20115	;;
20116	*)	case "$usethreads" in
20117		define) echo "ttyname_r has no prototype, not using it." >&4 ;;
20118		esac
20119		d_ttyname_r=undef
20120		ttyname_r_proto=0
20121		;;
20122	esac
20123	;;
20124*)	ttyname_r_proto=0
20125	;;
20126esac
20127
20128: see if tzname[] exists
20129echo " "
20130if set tzname val -a d_tzname; eval $csym; $val; then
20131	val="$define"
20132	echo 'tzname[] found.' >&4
20133else
20134	val="$undef"
20135	echo 'tzname[] NOT found.' >&4
20136fi
20137set d_tzname
20138eval $setvar
20139
20140: Check if is a multiplatform env
20141case "$osname" in
20142darwin) multiarch="$define" ;;
20143esac
20144case "$multiarch" in
20145''|[nN]*) multiarch="$undef" ;;
20146esac
20147
20148: check for ordering of bytes in a UV
20149echo " "
20150case "$multiarch" in
20151*$define*)
20152	$cat <<EOM
20153You seem to be doing a multiarchitecture build,
20154skipping the byteorder check.
20155
20156EOM
20157	byteorder='ffff'
20158	;;
20159*)
20160	case "$byteorder" in
20161	'')
20162		$cat <<'EOM'
20163In the following, larger digits indicate more significance.  A big-endian
20164machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
20165little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
20166machines may have weird orders like 3412.  A Cray will report 87654321,
20167an Alpha will report 12345678. If the test program works the default is
20168probably right.
20169I'm now running the test program...
20170EOM
20171		$cat >try.c <<EOCP
20172#include <stdio.h>
20173#$i_stdlib I_STDLIB
20174#ifdef I_STDLIB
20175#include <stdlib.h>
20176#endif
20177#$i_inttypes I_INTTYPES
20178#ifdef I_INTTYPES
20179#include <inttypes.h>
20180#endif
20181#include <sys/types.h>
20182typedef $uvtype UV;
20183int main()
20184{
20185	int i;
20186	union {
20187		UV l;
20188		char c[$uvsize];
20189	} u;
20190
20191	if ($uvsize > 4)
20192		u.l = (((UV)0x08070605) << 32) | (UV)0x04030201;
20193	else
20194		u.l = (UV)0x04030201;
20195	for (i = 0; i < $uvsize; i++)
20196		printf("%c", u.c[i]+'0');
20197	printf("\n");
20198	exit(0);
20199}
20200EOCP
20201		xxx_prompt=y
20202		set try
20203		if eval $compile && $run ./try > /dev/null; then
20204			dflt=`$run ./try`
20205			case "$dflt" in
20206			[1-4][1-4][1-4][1-4]|12345678|87654321)
20207				echo "(The test program ran ok.)"
20208				echo "byteorder=$dflt"
20209				xxx_prompt=n
20210			;;
20211			????|????????) echo "(The test program ran ok.)" ;;
20212			*) echo "(The test program didn't run right for some reason.)" ;;
20213			esac
20214		else
20215			dflt='4321'
20216			cat <<'EOM'
20217(I can't seem to compile the test program.  Guessing big-endian...)
20218EOM
20219		fi
20220		case "$xxx_prompt" in
20221		y)
20222			rp="What is the order of bytes in $uvtype?"
20223			. ./myread
20224			byteorder="$ans"
20225			;;
20226		*)	byteorder=$dflt
20227			;;
20228		esac
20229		;;
20230	esac
20231	$rm_try
20232	;;
20233esac
20234
20235: Checking 32bit alignedness
20236$cat <<EOM
20237
20238Checking to see whether you can access character data unalignedly...
20239EOM
20240case "$d_u32align" in
20241'')   $cat >try.c <<EOCP
20242#include <stdio.h>
20243#$i_stdlib I_STDLIB
20244#ifdef I_STDLIB
20245#include <stdlib.h>
20246#endif
20247#define U32 $u32type
20248#define BYTEORDER 0x$byteorder
20249#define U8 $u8type
20250#include <signal.h>
20251#ifdef SIGBUS
20252$signal_t bletch(int s) { exit(4); }
20253#endif
20254int main() {
20255#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
20256    volatile U8 buf[8];
20257    volatile U32 *up;
20258    int i;
20259
20260    if (sizeof(U32) != 4) {
20261	printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
20262	exit(1);
20263    }
20264
20265    fflush(stdout);
20266
20267#ifdef SIGBUS
20268    signal(SIGBUS, bletch);
20269#endif
20270
20271    buf[0] = 0;
20272    buf[1] = 0;
20273    buf[2] = 0;
20274    buf[3] = 1;
20275    buf[4] = 0;
20276    buf[5] = 0;
20277    buf[6] = 0;
20278    buf[7] = 1;
20279
20280    for (i = 0; i < 4; i++) {
20281	up = (U32*)(buf + i);
20282	if (! ((*up == 1 << (8*i)) ||   /* big-endian */
20283	       (*up == 1 << (8*(3-i)))  /* little-endian */
20284	      )
20285	   )
20286	{
20287	    printf("read failed (%x)\n", *up);
20288	    exit(2);
20289	}
20290    }
20291
20292    /* write test */
20293    for (i = 0; i < 4; i++) {
20294	up = (U32*)(buf + i);
20295	*up = 0xBeef;
20296	if (*up != 0xBeef) {
20297	    printf("write failed (%x)\n", *up);
20298	    exit(3);
20299	}
20300    }
20301
20302    exit(0);
20303#else
20304    printf("1\n");
20305    exit(1);
20306#endif
20307    return 0;
20308}
20309EOCP
20310set try
20311if eval $compile_ok; then
20312	echo "(Testing for character data alignment may crash the test.  That's okay.)" >&4
20313	$run ./try 2>&1 >/dev/null
20314	case "$?" in
20315	0)	cat >&4 <<EOM
20316You can access character data pretty unalignedly.
20317EOM
20318		d_u32align="$undef"
20319		;;
20320	*)	cat >&4 <<EOM
20321It seems that you must access character data in an aligned manner.
20322EOM
20323		d_u32align="$define"
20324		;;
20325	esac
20326else
20327	rp='Can you access character data at unaligned addresses?'
20328	dflt='n'
20329	. ./myread
20330	case "$ans" in
20331	[yY]*)	d_u32align="$undef"  ;;
20332	*)	d_u32align="$define" ;;
20333	esac
20334fi
20335$rm_try
20336;;
20337esac
20338
20339: see if ualarm exists
20340set ualarm d_ualarm
20341eval $inlibc
20342
20343: see if umask exists
20344set umask d_umask
20345eval $inlibc
20346
20347: see if unordered exists
20348set unordered d_unordered
20349eval $inlibc
20350
20351: see if unsetenv exists
20352set unsetenv d_unsetenv
20353eval $inlibc
20354
20355: see if usleep exists
20356set usleep d_usleep
20357eval $inlibc
20358
20359: see if prototype for usleep is available
20360echo " "
20361set d_usleepproto usleep $i_unistd unistd.h
20362eval $hasproto
20363
20364: see if ustat exists
20365set ustat d_ustat
20366eval $inlibc
20367
20368: see if closedir exists
20369set closedir d_closedir
20370eval $inlibc
20371
20372case "$d_closedir" in
20373"$define")
20374	echo " "
20375	echo "Checking whether closedir() returns a status..." >&4
20376	cat > try.c <<EOM
20377#$i_dirent I_DIRENT		/**/
20378#$i_sysdir I_SYS_DIR		/**/
20379#$i_sysndir I_SYS_NDIR		/**/
20380#$i_systypes I_SYS_TYPES	/**/
20381
20382#if defined(I_SYS_TYPES)
20383#include <sys/types.h>
20384#endif
20385#if defined(I_DIRENT)
20386#include <dirent.h>
20387#else
20388#ifdef I_SYS_NDIR
20389#include <sys/ndir.h>
20390#else
20391#ifdef I_SYS_DIR
20392#include <sys/dir.h>
20393#endif
20394#endif
20395#endif
20396int main() { return closedir(opendir(".")); }
20397EOM
20398	set try
20399	if eval $compile_ok; then
20400		if $run ./try > /dev/null 2>&1 ; then
20401			echo "Yes, it does."
20402			val="$undef"
20403		else
20404			echo "No, it doesn't."
20405			val="$define"
20406		fi
20407	else
20408		echo "(I can't seem to compile the test program--assuming it doesn't)"
20409		val="$define"
20410	fi
20411	;;
20412*)
20413	val="$undef";
20414	;;
20415esac
20416set d_void_closedir
20417eval $setvar
20418$rm_try
20419
20420: see if there is a wait4
20421set wait4 d_wait4
20422eval $inlibc
20423
20424: see if waitpid exists
20425set waitpid d_waitpid
20426eval $inlibc
20427
20428: see if wcrtomb exists
20429set wcrtomb d_wcrtomb
20430eval $inlibc
20431
20432: look for wcscmp
20433echo " "
20434$cat >try.c <<'EOCP'
20435#include <stdio.h>
20436#include <wchar.h>
20437int main ()
20438{
20439    wchar_t *s = L" ";
20440    return (wcscmp (s, s) ? 1 : 0);
20441    }
20442EOCP
20443set try
20444val="$undef"
20445if eval $compile; then
20446    `$run ./try`
20447    case "$?" in
20448	0)  echo "A working wcscmp() found." >&4
20449	    val="$define" ;;
20450	*)  echo "wcscmp() found, but it doesn't work" >&4
20451	    ;;
20452	esac
20453else
20454    echo "wcscmp() NOT found." >&4
20455    fi
20456set d_wcscmp
20457eval $setvar
20458$rm_try
20459
20460: see if wcstombs exists
20461set wcstombs d_wcstombs
20462eval $inlibc
20463
20464: look for wcsxfrm
20465echo " "
20466$cat >try.c <<'EOCP'
20467#include <errno.h>
20468#include <wchar.h>
20469int main ()
20470{
20471    wchar_t dst[4], *src = L" ";
20472    errno = 0;
20473    return (wcsxfrm (dst, src, 1) ? errno ? errno : 0 : 1);
20474    }
20475EOCP
20476set try
20477val="$undef"
20478if eval $compile; then
20479    `$run ./try`
20480    case "$?" in
20481	0)  echo "A working wcsxfrm() found." >&4
20482	    val="$define" ;;
20483	*)  echo "wcsxfrm() found, but it doesn't work" >&4
20484	    ;;
20485	esac
20486else
20487    echo "wcsxfrm() NOT found." >&4
20488    fi
20489set d_wcsxfrm
20490eval $setvar
20491$rm_try
20492
20493: see if wctomb exists
20494set wctomb d_wctomb
20495eval $inlibc
20496
20497: see if writev exists
20498set writev d_writev
20499eval $inlibc
20500
20501: check for alignment requirements
20502echo " "
20503case "$alignbytes" in
20504    '') echo "Checking alignment constraints..." >&4
20505	$cat >try.c <<EOCP
20506#include <stdio.h>
20507struct foobar {
20508    char foo;
20509    $nvtype bar;
20510} try_algn;
20511int main()
20512{
20513    printf("%d\n", (int)((char *)&try_algn.bar - (char *)&try_algn.foo));
20514    return(0);
20515}
20516EOCP
20517	set try
20518	if eval $compile_ok; then
20519	    dflt=`$run ./try`
20520	else
20521	    dflt='8'
20522	    echo "(I can't seem to compile the test program...)"
20523	fi
20524	case "$multiarch" in
20525	    *$define*)
20526		: The usual safe value is 8, but Darwin with -Duselongdouble
20527		: needs 16.  Hence, we will take 8 as a minimum, but allow
20528		: Configure to pick a larger value if needed.
20529		if $test "$dflt" -lt 8; then
20530		    dflt='8'
20531		    echo "Setting alignment to 8 for multiarch support.">&4
20532		fi
20533		;;
20534	esac
20535	;;
20536    *) dflt="$alignbytes"
20537	;;
20538esac
20539rp="Doubles must be aligned on a how-many-byte boundary?"
20540. ./myread
20541alignbytes="$ans"
20542$rm_try
20543
20544: set the base revision
20545baserev=5.0
20546
20547: length of character in bytes. Is always 1, otherwise it is not C
20548: This used to be a test using sizeof
20549charsize=1
20550
20551: Check for the number of bits in a character
20552case "$charbits" in
20553'')	echo "Checking how long a character is (in bits)..." >&4
20554	$cat >try.c <<EOCP
20555#include <stdio.h>
20556int main ()
20557{
20558    int n;
20559    unsigned char c;
20560    for (c = 1, n = 0; c; c <<= 1, n++) ;
20561    printf ("%d\n", n);
20562    return (0);
20563    }
20564EOCP
20565	set try
20566	if eval $compile_ok; then
20567		dflt=`$run ./try`
20568	else
20569		dflt='8'
20570		echo "(I can't seem to compile the test program.  Guessing...)"
20571	fi
20572	;;
20573*)
20574	dflt="$charbits"
20575	;;
20576esac
20577rp="What is the length of a character (in bits)?"
20578. ./myread
20579charbits="$ans"
20580$rm_try
20581case "$charbits" in
205828)	;;
20583*)	cat >&4 << EOM
20584Your system has an unsigned character size of $charbits bits, which
20585is rather unusual (normally it is 8 bits).  Perl likely will not work
20586correctly on your system, with subtle bugs in various places.
20587EOM
20588	rp='Do you really want to continue?'
20589	dflt='n'
20590	. ./myread
20591	case "$ans" in
20592		[yY])	echo >&4 "Okay, continuing."	;;
20593		*)	exit 1				;;
20594	esac
20595esac
20596
20597: how do we concatenate cpp tokens here?
20598echo " "
20599echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
20600$cat >cpp_stuff.c <<'EOCP'
20601#define RCAT(a,b)a/**/b
20602#define ACAT(a,b)a ## b
20603RCAT(Rei,ser)
20604ACAT(Cir,cus)
20605EOCP
20606$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
20607if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
20608	echo "Oh!  Smells like ANSI's been here." >&4
20609	echo "We can catify or stringify, separately or together!"
20610	cpp_stuff=42
20611elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
20612	echo "Ah, yes!  The good old days!" >&4
20613	echo "However, in the good old days we don't know how to stringify and"
20614	echo "catify at the same time."
20615	cpp_stuff=1
20616else
20617	$cat >&4 <<EOM
20618Hmm, I don't seem to be able to concatenate tokens with your cpp.
20619You're going to have to edit the values of CAT[2-5] in config.h...
20620EOM
20621	cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
20622fi
20623$rm -f cpp_stuff.*
20624
20625: see if this is a db.h system
20626set db.h i_db
20627eval $inhdr
20628
20629case "$i_db" in
20630$define)
20631	: Check db version.
20632	echo " "
20633	echo "Checking Berkeley DB version ..." >&4
20634	$cat >try.c <<EOCP
20635#include <sys/types.h>
20636#include <stdio.h>
20637#$i_stdlib I_STDLIB
20638#ifdef I_STDLIB
20639#include <stdlib.h>
20640#endif
20641#include <db.h>
20642int main(int argc, char *argv[])
20643{
20644#ifdef DB_VERSION_MAJOR	/* DB version >= 2 */
20645    int Major, Minor, Patch ;
20646    unsigned long Version ;
20647    (void)db_version(&Major, &Minor, &Patch) ;
20648    if (argc == 2) {
20649        printf("%d %d %d %d %d %d\n",
20650               DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
20651               Major, Minor, Patch);
20652        exit(0);
20653    }
20654    printf("You have Berkeley DB Version 2 or greater.\n");
20655
20656    printf("db.h is from Berkeley DB Version %d.%d.%d\n",
20657		DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
20658    printf("libdb is from Berkeley DB Version %d.%d.%d\n",
20659		Major, Minor, Patch) ;
20660
20661    /* check that db.h & libdb are compatible */
20662    if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
20663	printf("db.h and libdb are incompatible.\n") ;
20664        exit(3);
20665    }
20666
20667    printf("db.h and libdb are compatible.\n") ;
20668
20669    Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
20670		+ DB_VERSION_PATCH ;
20671
20672    /* needs to be >= 2.3.4 */
20673    if (Version < 2003004) {
20674    /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
20675	printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
20676        exit(2);
20677    }
20678
20679    exit(0);
20680#else
20681#if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
20682    if (argc == 2) {
20683        printf("1 0 0\n");
20684        exit(0);
20685    }
20686    printf("You have Berkeley DB Version 1.\n");
20687    exit(0);	/* DB version < 2: the coast is clear. */
20688#else
20689    exit(1);	/* <db.h> not Berkeley DB? */
20690#endif
20691#endif
20692}
20693EOCP
20694	set try
20695	if eval $compile_ok && $run ./try; then
20696		echo 'Looks OK.' >&4
20697		set `$run ./try 1`
20698		db_version_major=$1
20699		db_version_minor=$2
20700		db_version_patch=$3
20701	else
20702		echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
20703		i_db=$undef
20704		case " $libs " in
20705		*"-ldb "*)
20706			: Remove db from list of libraries to use
20707			echo "Removing unusable -ldb from library list" >&4
20708			set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
20709			shift
20710			libs="$*"
20711			echo "libs = $libs" >&4
20712			;;
20713		esac
20714	fi
20715	$rm_try
20716	;;
20717esac
20718
20719case "$i_db" in
20720define)
20721	: Check the return type needed for hash
20722	echo " "
20723	echo "Checking return type needed for hash for Berkeley DB ..." >&4
20724	$cat >try.c <<EOCP
20725#include <sys/types.h>
20726#include <db.h>
20727
20728#ifndef DB_VERSION_MAJOR
20729u_int32_t hash_cb (const void* ptr, size_t size)
20730{
20731	return 0;
20732}
20733HASHINFO info;
20734int main()
20735{
20736	info.hash = hash_cb;
20737}
20738#endif
20739EOCP
20740	if $cc $ccflags -c try.c >try.out 2>&1 ; then
20741		if $compiler_warning try.out >>/dev/null 2>&1 ; then
20742			db_hashtype='int'
20743		else
20744			db_hashtype='u_int32_t'
20745		fi
20746	else
20747		: XXX Maybe we should just give up here.
20748		db_hashtype=u_int32_t
20749		$cat try.out >&4
20750		echo "Help:  I can't seem to compile the db test program." >&4
20751		echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
20752	fi
20753	$rm_try
20754	echo "Your version of Berkeley DB uses $db_hashtype for hash."
20755	;;
20756*)	db_hashtype=u_int32_t
20757	;;
20758esac
20759case "$i_db" in
20760define)
20761	: Check the return type needed for prefix
20762	echo " "
20763	echo "Checking return type needed for prefix for Berkeley DB ..." >&4
20764	cat >try.c <<EOCP
20765#include <sys/types.h>
20766#include <db.h>
20767
20768#ifndef DB_VERSION_MAJOR
20769size_t prefix_cb (const DBT *key1, const DBT *key2)
20770{
20771	return 0;
20772}
20773BTREEINFO info;
20774int main()
20775{
20776	info.prefix = prefix_cb;
20777}
20778#endif
20779EOCP
20780	if $cc $ccflags -c try.c  >try.out 2>&1 ; then
20781		if $compiler_warning try.out >>/dev/null 2>&1 ; then
20782			db_prefixtype='int'
20783		else
20784			db_prefixtype='size_t'
20785		fi
20786	else
20787		db_prefixtype='size_t'
20788		: XXX Maybe we should just give up here.
20789		$cat try.out >&4
20790		echo "Help:  I can't seem to compile the db test program." >&4
20791		echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
20792	fi
20793	$rm_try
20794	echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
20795	;;
20796*)	db_prefixtype='size_t'
20797	;;
20798esac
20799
20800: Include . in @INC
20801$cat <<EOM
20802
20803Historically Perl has provided a final fallback of the current working
20804directory '.' when searching for a library. This, however, can lead to
20805problems when a Perl program which loads optional modules is called from
20806a shared directory. This can lead to executing unexpected code.
20807
20808EOM
20809
20810# When changing to exclude by default:
20811case "$default_inc_excludes_dot" in
20812    $undef|false|[nN]*) dflt="n" ;;
20813    *)                  dflt="y" ;;
20814esac
20815# To turn exclude off by default:
20816#case "$default_inc_excludes_dot" in
20817#    $define|true|[yY]*) dflt="y" ;;
20818#    *)                  dflt="n" ;;
20819#esac
20820
20821rp='Exclude '.' from @INC by default? '
20822. ./myread
20823case "$ans" in
20824    [nN]|undef) default_inc_excludes_dot="$undef"  ;;
20825    *)          default_inc_excludes_dot="$define" ;;
20826esac
20827
20828: Check what kind of inf/nan your system has
20829$echo "Checking the kind of infinities and nans you have..." >&4
20830$echo "(The following tests may crash.  That's okay.)" >&4
20831$cat >try.c <<EOP
20832#define DOUBLESIZE $doublesize
20833#$d_longdbl HAS_LONG_DOUBLE
20834#ifdef HAS_LONG_DOUBLE
20835#define LONG_DOUBLESIZE $longdblsize
20836#define LONG_DOUBLEKIND $longdblkind
20837#endif
20838#include <math.h>
20839#include <string.h>
20840#include <stdio.h>
20841/* Note that whether the sign bit is on or off
20842 * for NaN depends on the CPU/FPU, and possibly
20843 * can be affected by the build toolchain.
20844 *
20845 * For example for older MIPS and HP-PA 2.0 the quiet NaN is:
20846 * 0x7f, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
20847 * 0x7f, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20848 * (respectively) as opposed to the more usual
20849 * 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20850 *
20851 * Pre-IEEE-754 floating point format do not even have inf/nan support
20852 * at all.  They might have a "max" value (DBL_MAX), which may be deadly
20853 * to even mention, causing immediate SIGFPE or equivalent: this is
20854 * the case with VAX floating point, for example.
20855 */
20856static void bytes(void *v, unsigned int n) {
20857  unsigned char *p = (unsigned char *)v;
20858  int i;
20859  for (i = 0; i < n; i++) {
20860    printf("0x%02x%s", p[i], i < n - 1 ? ", " : "\n");
20861  }
20862}
20863int main(int argc, char *argv[]) {
20864   /* We cannot use 1.0/0.0 and 0.0/0.0 (with L suffixes for long double)
20865    * because some compilers are 'smart' and not only warn but refuse to
20866    * compile such 'illegal' values. */
20867   double dinf = exp(1e9);
20868   double dnan = sqrt(-1.0);
20869#ifdef HAS_LONG_DOUBLE
20870   long double ldinf = (long double)exp(1e9);
20871   long double ldnan = (long double)sqrt(-1.0);
20872# if LONG_DOUBLEKIND == 3 || LONG_DOUBLEKIND == 4
20873/* the 80-bit long doubles might have garbage in their excess bytes */
20874    memset((char *)&ldinf + 10, '\0', LONG_DOUBLESIZE - 10);
20875    memset((char *)&ldnan + 10, '\0', LONG_DOUBLESIZE - 10);
20876# endif
20877#endif
20878  if (argc == 2) {
20879    switch (argv[1][0]) {
20880    case '1': bytes(&dinf, sizeof(dinf)); break;
20881    case '2': bytes(&dnan, sizeof(dnan)); break;
20882#ifdef HAS_LONG_DOUBLE
20883    case '3': bytes(&ldinf, sizeof(ldinf)); break;
20884    case '4': bytes(&ldnan, sizeof(ldnan)); break;
20885#endif
20886    }
20887  }
20888  return 0;
20889}
20890EOP
20891set try
20892if eval $compile; then
20893    doubleinfbytes=`$run ./try 1`
20894    doublenanbytes=`$run ./try 2`
20895    case "$d_longdbl" in
20896    $define)
20897      longdblinfbytes=`$run ./try 3`
20898      longdblnanbytes=`$run ./try 4`
20899      ;;
20900    esac
20901else
20902    # Defaults in case the above test program failed.
20903    case "$doublekind" in
20904    1) # IEEE 754 32-bit LE
20905       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f'
20906       doublenanbytes='0x00, 0x00, 0xf8, 0x7f'
20907       ;;
20908    2) # IEEE 754 32-bit BE
20909       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00'
20910       doublenanbytes='0x7f, 0xf8, 0x00, 0x00'
20911       ;;
20912    3) # IEEE 754 64-bit LE
20913       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20914       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20915       ;;
20916    4) # IEEE 754 64-bit BE
20917       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20918       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20919       ;;
20920    5) # IEEE 754 128-bit LE
20921       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20922       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20923       ;;
20924    6) # IEEE 754 128-bit BE
20925       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20926       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20927       ;;
20928    7) # IEEE 754 64-bit mixed: 32-bit LEs in BE
20929       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00'
20930       doublenanbytes='0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00'
20931       ;;
20932    8) # IEEE 754 64-bit mixed: 32-bit BEs in LE
20933       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00'
20934       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00'
20935       ;;
20936    9|10|11|12|13|14) # VAX/Cray/IBM floating point formats, no inf/nan.
20937       doubleinfbytes=$undef
20938       doublenanbytes=$undef
20939       ;;
20940    *) # No idea.
20941       doubleinfbytes=$undef
20942       doublenanbytes=$undef
20943       ;;
20944    esac
20945    case "$longdblkind" in
20946    1) # IEEE 754 128-bit LE
20947       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f'
20948       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f'
20949       ;;
20950    2) # IEEE 754 128-bit BE
20951       longdblinfbytes='0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20952       longdblnanbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20953       ;;
20954    3) # IEEE 754 80-bit LE, 12 or 16 bytes (x86)
20955       case "$longdblsize" in
20956       12) # x86 32-bit (96 bits, or 4 x 32, or 12 x 8)
20957           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00'
20958           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00'
20959           ;;
20960       16) # x86_64
20961           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20962           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20963           ;;
20964       *)  # No idea.
20965           longdblinfbytes=$undef
20966           longdblnanbytes=$undef
20967       ;;
20968       esac
20969       ;;
20970    4) # IEEE 754 80-bit BE, 12 or 16 bytes
20971       case "$longdblsize" in
20972       12) # 32-bit system
20973           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20974           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20975           ;;
20976       16) # 64-bit system
20977           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20978           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20979           ;;
20980       *)  # No idea.
20981           longdblinfbytes=$undef
20982           longdblnanbytes=$undef
20983       ;;
20984       esac
20985       ;;
20986    5) # 128-bit LE-LE "double double"
20987       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20988       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20989       ;;
20990    6) # 128-bit BE-BE "double double"
20991       longdblinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20992       longdblnanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20993       ;;
20994    7) # 128-bit LE-BE "double double"
20995       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20996       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20997       ;;
20998    8) # 128-bit BE-LE "double double"
20999       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
21000       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
21001       ;;
21002    9|10|11|12|13|14) # VAX/Cray/IBM floating point formats, no inf/nan.
21003       longdblinfbytes=$undef
21004       longdblnanbytes=$undef
21005       ;;
21006    *) # No idea.
21007       longdblinfbytes=$undef
21008       longdblnanbytes=$undef
21009       ;;
21010    esac
21011fi
21012# In case the program crashed the values are empty, turn them undef.
21013case "$doubleinfbytes" in
21014'') doubleinfbytes=$undef ;;
21015esac
21016case "$doublenanbytes" in
21017'') doublenanbytes=$undef ;;
21018esac
21019case "$longdblinfbytes" in
21020'') longdblinfbytes=$undef ;;
21021esac
21022case "$longdblnanbytes" in
21023'') longdblnanbytes=$undef ;;
21024esac
21025$rm_try
21026
21027: Check the length of the double mantissa
21028$echo "Checking how many mantissa bits your doubles have..." >&4
21029$cat >try.c <<EOP
21030#$i_sunmath I_SUNMATH
21031#include <float.h>
21032#ifdef I_SUNMATH
21033# include <sunmath.h>
21034#endif
21035#ifdef DBL_MANT_DIG
21036# define BITS (DBL_MANT_DIG - 1) /* the implicit bit does not count */
21037#endif
21038#include <stdio.h>
21039int main(int argc, char *argv[]) {
21040#ifdef BITS
21041  printf("%d\n", BITS);
21042#endif
21043  return 0;
21044}
21045EOP
21046set try
21047if eval $compile; then
21048    doublemantbits=`$run ./try`
21049else
21050    doublemantbits="$undef"
21051fi
21052$rm_try
21053
21054: Check the length of the longdouble mantissa
21055$echo "Checking how many mantissa bits your long doubles have..." >&4
21056$cat >try.c <<EOP
21057#$i_sunmath I_SUNMATH
21058#include <float.h>
21059#ifdef I_SUNMATH
21060# include <sunmath.h>
21061#endif
21062#$d_longdbl HAS_LONG_DOUBLE
21063#if defined(HAS_LONG_DOUBLE) && defined(LDBL_MANT_DIG)
21064# if ($longdblkind == 3) || ($longdblkind == 4) /* 80-bit extended precision */
21065/* This format has no implicit bit.  Beware, however, that for
21066 * this format the bare LDBL_MANT_DIG is misleading for inf/nan:
21067 * the top three bits are used for inf (100) / qnan (11x) / snan (101),
21068 * and the top bit must have been one since 387, zero is plain invalid.
21069 * For normal fp values, the LDBL_MANT_DIG is fine, though. */
21070#  define BITS LDBL_MANT_DIG
21071# elif ($longdblkind == 5 || $longdblkind == 6 || $longdblkind == 7 || $longdblkind == 8) /* double double */
21072/* LDBL_MANT_DIG of 106 (twice 53) would be logical, but for some
21073 * reason e.g. Irix thinks 107.  But in any case, we want only
21074 * the number of real bits, the implicit bits are of no interest.  */
21075#  define BITS 2 * (DBL_MANT_DIG - 1)
21076# else
21077#  define BITS (LDBL_MANT_DIG - 1) /* the implicit bit does not count */
21078# endif
21079#endif
21080#include <stdio.h>
21081int main(int argc, char *argv[]) {
21082#ifdef BITS
21083  printf("%d\n", BITS);
21084#endif
21085  return 0;
21086}
21087EOP
21088set try
21089if eval $compile; then
21090    longdblmantbits=`$run ./try`
21091else
21092    longdblmantbits="$undef"
21093fi
21094$rm_try
21095
21096: Check the length of the NV mantissa
21097$echo "Checking how many mantissa bits your NVs have..." >&4
21098if test "X$usequadmath" = "X$define"; then
21099  nvmantbits=112 # 128-1-15
21100else
21101  if test "X$nvsize" = "X$doublesize"; then
21102    nvmantbits="$doublemantbits"
21103  else
21104     if test "X$nvsize" = "X$longdblsize"; then
21105       nvmantbits="$longdblmantbits"
21106     else
21107       nvmantbits="$undef"
21108     fi
21109  fi
21110fi
21111
21112: How can we generate normalized random numbers ?
21113echo " "
21114echo "Using our internal random number implementation..." >&4
21115
21116case "$ccflags" in
21117*-Dmy_rand=*|*-Dmy_srand=*)
21118	echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
21119	ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
21120	ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
21121	ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
21122	;;
21123esac
21124
21125randfunc=drand48
21126drand01="drand48()"
21127seedfunc="srand48"
21128randbits=48
21129randseedtype=U32
21130
21131: Probe whether dtrace builds an object, as newer Illumos requires an input
21132: object file that uses at least one of the probes defined in the .d file
21133case "$usedtrace" in
21134$define)
21135    case "$dtracexnolibs" in
21136    $define|true|[yY]*)
21137        dtracexnolibs=$define
21138	$dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h
21139	;;
21140    ' '|'')
21141        if $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
21142	     dtracexnolibs=$define
21143	     echo "Your dtrace accepts -xnolibs"
21144	elif $dtrace -h -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
21145	     dtracexnolibs=$undef
21146	     echo "Your dtrace doesn't accept -xnolibs"
21147	else
21148             echo "Your dtrace doesn't work at all, try building without dtrace support" >&4
21149	     exit 1
21150	fi
21151	;;
21152    *)
21153        dtracexnolibs=$undef
21154	$dtrace -h -s ../perldtrace.d -o perldtrace.h
21155	;;
21156    esac
21157    case $dtracexnolibs in
21158    $define) xnolibs=-xnolibs ;;
21159    *) xnolibs= ;;
21160    esac
21161
21162    case "$dtraceobject" in
21163    $define|true|[yY]*)
21164        dtraceobject=$define
21165        ;;
21166    ' '|'')
21167        $cat >try.c <<EOM
21168#include "perldtrace.h"
21169int main(void) {
21170    PERL_LOADED_FILE("dummy");
21171    return 0;
21172}
21173EOM
21174        dtraceobject=$undef
21175        if $cc -c -o try.o $optimize $ccflags try.c \
21176                    && $dtrace -G $xnolibs -s ../perldtrace.d try.o >/dev/null 2>&1; then
21177                dtraceobject=$define
21178            echo "Your dtrace builds an object file"
21179        fi
21180        ;;
21181    *) dtraceobject=$undef ;;
21182    esac
21183    $rm_try perldtrace.o perldtrace.h
21184esac
21185
21186: Determine if this is an EBCDIC system
21187echo " "
21188echo "Determining whether or not we are on an EBCDIC system..." >&4
21189$cat >try.c <<'EOM'
21190int main()
21191{
21192  if ('M'==0xd4) return 0;
21193  return 1;
21194}
21195EOM
21196
21197val=$undef
21198set try
21199if eval $compile_ok; then
21200	if $run ./try; then
21201		echo "You seem to speak EBCDIC." >&4
21202		val="$define"
21203	else
21204		echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF-8." >&4
21205	fi
21206else
21207	echo "I'm unable to compile the test program." >&4
21208	echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
21209fi
21210$rm_try
21211set ebcdic
21212eval $setvar
21213
21214: Check how to flush
21215echo " "
21216$cat >&4 <<EOM
21217Checking how to flush all pending stdio output...
21218EOM
21219# I only know how to find the first 32 possibly open files on SunOS.
21220# See also hints/sunos_4_1.sh and util.c  --AD
21221case "$osname" in
21222sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
21223esac
21224$cat >>try.c <<EOCP
21225#include <stdio.h>
21226#$i_stdlib I_STDLIB
21227#ifdef I_STDLIB
21228#include <stdlib.h>
21229#endif
21230#$i_unistd I_UNISTD
21231#ifdef I_UNISTD
21232# include <unistd.h>
21233#endif
21234#$d_sysconf HAS_SYSCONF
21235#$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
21236#ifdef HAS_STDIO_STREAM_ARRAY
21237# define STDIO_STREAM_ARRAY $stdio_stream_array
21238#endif
21239int main() {
21240  FILE* p;
21241  unlink("try.out");
21242  p = fopen("try.out", "w");
21243#ifdef TRY_FPUTC
21244  fputc('x', p);
21245#else
21246# ifdef TRY_FPRINTF
21247  fprintf(p, "x");
21248# endif
21249#endif
21250#ifdef TRY_FFLUSH_NULL
21251  fflush(NULL);
21252#endif
21253#ifdef TRY_FFLUSH_ALL
21254  {
21255    long open_max = -1;
21256# ifdef PERL_FFLUSH_ALL_FOPEN_MAX
21257    open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
21258# else
21259#  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
21260    open_max = sysconf(_SC_OPEN_MAX);
21261#  else
21262#   ifdef FOPEN_MAX
21263    open_max = FOPEN_MAX;
21264#   else
21265#    ifdef OPEN_MAX
21266    open_max = OPEN_MAX;
21267#    else
21268#     ifdef _NFILE
21269    open_max = _NFILE;
21270#     endif
21271#    endif
21272#   endif
21273#  endif
21274# endif
21275# ifdef HAS_STDIO_STREAM_ARRAY
21276    if (open_max > 0) {
21277      long i;
21278      for (i = 0; i < open_max; i++)
21279	    if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
21280		STDIO_STREAM_ARRAY[i]._file < open_max &&
21281		STDIO_STREAM_ARRAY[i]._flag)
21282		fflush(&STDIO_STREAM_ARRAY[i]);
21283    }
21284  }
21285# endif
21286#endif
21287  _exit(42);
21288}
21289EOCP
21290: first we have to find out how _not_ to flush
21291$to try.c
21292if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
21293    output=''
21294    set try -DTRY_FPUTC
21295    if eval $compile; then
21296	    $run ./try 2>/dev/null
21297	    code="$?"
21298	    $from try.out
21299	    if $test ! -s try.out -a "X$code" = X42; then
21300		output=-DTRY_FPUTC
21301	    fi
21302    fi
21303    case "$output" in
21304    '')
21305	    set try -DTRY_FPRINTF
21306	    if eval $compile; then
21307		    $run ./try 2>/dev/null
21308		    code="$?"
21309		    $from try.out
21310		    if $test ! -s try.out -a "X$code" = X42; then
21311			output=-DTRY_FPRINTF
21312		    fi
21313	    fi
21314	;;
21315    esac
21316fi
21317: check for fflush NULL behavior
21318case "$fflushNULL" in
21319'')	set try -DTRY_FFLUSH_NULL $output
21320	if eval $compile; then
21321		$run ./try 2>/dev/null
21322		code="$?"
21323		$from try.out
21324		if $test -s try.out -a "X$code" = X42; then
21325			fflushNULL="`$cat try.out`"
21326		else
21327			if $test "X$code" != X42; then
21328				$cat >&4 <<EOM
21329(If this test failed, don't worry, we'll try another method shortly.)
21330EOM
21331			fi
21332		fi
21333	fi
21334	$rm -f core try.core core.try.*
21335	case "$fflushNULL" in
21336	x)	$cat >&4 <<EOM
21337Your fflush(NULL) works okay for output streams.
21338Let's see if it clobbers input pipes...
21339EOM
21340# As of mid-March 2000 all versions of Solaris appear to have a stdio
21341# bug that improperly flushes the input end of pipes.  So we avoid the
21342# autoflush on fork/system/exec support for now. :-(
21343$cat >tryp.c <<EOCP
21344#include <stdio.h>
21345int
21346main(int argc, char **argv)
21347{
21348    char buf[1024];
21349    int i;
21350    char *bp = buf;
21351    while (1) {
21352	while ((i = getc(stdin)) != -1
21353	       && (*bp++ = i) != '\n'
21354	       && bp < &buf[1024])
21355	/* DO NOTHING */ ;
21356	*bp = '\0';
21357	fprintf(stdout, "%s", buf);
21358	fflush(NULL);
21359	if (i == -1)
21360	    return 0;
21361	bp = buf;
21362    }
21363}
21364EOCP
21365		fflushNULL="$define"
21366		set tryp
21367		if eval $compile; then
21368		    $rm -f tryp.out
21369		    # Copy the .c file to the remote host ($to is an ssh-alike if targethost is set)
21370		    if $test "X$targethost" != X; then
21371			$to tryp.c
21372			$to tryp
21373			$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
21374		    else
21375			$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
21376		    fi
21377		    if cmp tryp.c tryp.out >/dev/null 2>&1; then
21378		       $cat >&4 <<EOM
21379fflush(NULL) seems to behave okay with input streams.
21380EOM
21381			fflushNULL="$define"
21382		    else
21383			$cat >&4 <<EOM
21384Ouch, fflush(NULL) clobbers input pipes!  We will not use it.
21385EOM
21386			fflushNULL="$undef"
21387		    fi
21388		fi
21389		$rm -f core tryp.c tryp.core core.tryp.*
21390		;;
21391	'')	$cat >&4 <<EOM
21392Your fflush(NULL) isn't working (contrary to ANSI C).
21393EOM
21394		fflushNULL="$undef"
21395		;;
21396	*)	$cat >&4 <<EOM
21397Cannot figure out whether your fflush(NULL) works or not.
21398I'm assuming it doesn't (contrary to ANSI C).
21399EOM
21400		fflushNULL="$undef"
21401		;;
21402	esac
21403	;;
21404$define|true|[yY]*)
21405	fflushNULL="$define"
21406	;;
21407*)
21408	fflushNULL="$undef"
21409	;;
21410esac
21411: check explicit looping only if NULL did not work, and if the pipe
21412: bug does not show up on an explicit flush too
21413case "$fflushNULL" in
21414"$undef")
21415	$cat >tryp.c <<EOCP
21416#include <stdio.h>
21417int
21418main(int argc, char **argv)
21419{
21420    char buf[1024];
21421    int i;
21422    char *bp = buf;
21423    while (1) {
21424	while ((i = getc(stdin)) != -1
21425	       && (*bp++ = i) != '\n'
21426	       && bp < &buf[1024])
21427	/* DO NOTHING */ ;
21428	*bp = '\0';
21429	fprintf(stdout, "%s", buf);
21430	fflush(stdin);
21431	if (i == -1)
21432	    return 0;
21433	bp = buf;
21434    }
21435}
21436EOCP
21437	set tryp
21438	if eval $compile; then
21439	    $rm -f tryp.out
21440	    if $test "X$targethost" != X; then
21441		$to tryp.c
21442		$to tryp
21443		$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
21444	    else
21445		$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
21446	    fi
21447	    if cmp tryp.c tryp.out >/dev/null 2>&1; then
21448	       $cat >&4 <<EOM
21449Good, at least fflush(stdin) seems to behave okay when stdin is a pipe.
21450EOM
21451		: now check for fflushall behaviour
21452		case "$fflushall" in
21453		'')	set try -DTRY_FFLUSH_ALL $output
21454			if eval $compile; then
21455				$cat >&4 <<EOM
21456(Now testing the other method--but note that this also may fail.)
21457EOM
21458				$run ./try 2>/dev/null
21459				code=$?
21460				$from try.out
21461				if $test -s try.out -a "X$code" = X42; then
21462					fflushall="`$cat try.out`"
21463				fi
21464			fi
21465			$rm_try
21466			case "$fflushall" in
21467			x)	$cat >&4 <<EOM
21468Whew. Flushing explicitly all the stdio streams works.
21469EOM
21470				fflushall="$define"
21471				;;
21472			'')	$cat >&4 <<EOM
21473Sigh. Flushing explicitly all the stdio streams doesn't work.
21474EOM
21475				fflushall="$undef"
21476				;;
21477			*)	$cat >&4 <<EOM
21478Cannot figure out whether flushing stdio streams explicitly works or not.
21479I'm assuming it doesn't.
21480EOM
21481				fflushall="$undef"
21482				;;
21483			esac
21484			;;
21485		"$define"|true|[yY]*)
21486			fflushall="$define"
21487			;;
21488		*)
21489			fflushall="$undef"
21490			;;
21491		esac
21492	    else
21493		$cat >&4 <<EOM
21494All is futile.  Even fflush(stdin) clobbers input pipes!
21495EOM
21496		fflushall="$undef"
21497	    fi
21498	else
21499	    fflushall="$undef"
21500	fi
21501	$rm -f core tryp.c tryp.core core.tryp.*
21502	;;
21503*)	fflushall="$undef"
21504	;;
21505esac
21506
21507case "$fflushNULL$fflushall" in
21508undefundef)
21509	$cat <<EOM
21510OK, I give up.  I cannot figure out how to flush pending stdio output.
21511We won't be flushing handles at all before fork/exec/popen.
21512EOM
21513	;;
21514esac
21515$rm_try tryp
21516
21517: Store the full pathname to the ar program for use in the C program
21518: Respect a hint or command line value for full_ar.
21519case "$full_ar" in
21520'') full_ar=$ar ;;
21521esac
21522
21523: Store the full pathname to the sed program for use in the C program
21524full_sed=$sed
21525
21526: see what type gids are declared as in the kernel
21527echo " "
21528echo "Looking for the type for group ids returned by getgid()."
21529set gid_t gidtype xxx stdio.h sys/types.h
21530eval $typedef
21531case "$gidtype" in
21532xxx)
21533	xxx=`./findhdr sys/user.h`
21534	set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
21535	case $1 in
21536	unsigned) dflt="$1 $2" ;;
21537	*) dflt="$1" ;;
21538	esac
21539	;;
21540*) dflt="$gidtype";;
21541esac
21542case "$gidtype" in
21543gid_t) echo "gid_t found." ;;
21544*)	rp="What is the type for group ids returned by getgid()?"
21545	. ./myread
21546	gidtype="$ans"
21547	;;
21548esac
21549
21550: Check the size of GID
21551echo " "
21552case "$gidtype" in
21553*_t) zzz="$gidtype"	;;
21554*)   zzz="gid"		;;
21555esac
21556echo "Checking the size of $zzz..." >&4
21557cat > try.c <<EOCP
21558#include <sys/types.h>
21559#include <stdio.h>
21560#$i_stdlib I_STDLIB
21561#ifdef I_STDLIB
21562#include <stdlib.h>
21563#endif
21564int main() {
21565    printf("%d\n", (int)sizeof($gidtype));
21566    exit(0);
21567}
21568EOCP
21569set try
21570if eval $compile_ok; then
21571	yyy=`$run ./try`
21572	case "$yyy" in
21573	'')	gidsize=4
21574		echo "(I can't execute the test program--guessing $gidsize.)" >&4
21575		;;
21576	*)	gidsize=$yyy
21577		echo "Your $zzz is $gidsize bytes long."
21578		;;
21579	esac
21580else
21581	gidsize=4
21582	echo "(I can't compile the test program--guessing $gidsize.)" >&4
21583fi
21584
21585: Check if GID is signed
21586echo " "
21587case "$gidtype" in
21588*_t) zzz="$gidtype"	;;
21589*)   zzz="gid"		;;
21590esac
21591echo "Checking the sign of $zzz..." >&4
21592cat > try.c <<EOCP
21593#include <sys/types.h>
21594#include <stdio.h>
21595int main() {
21596	$gidtype foo = -1;
21597	if (foo < 0)
21598		printf("-1\n");
21599	else
21600		printf("1\n");
21601}
21602EOCP
21603set try
21604if eval $compile; then
21605	yyy=`$run ./try`
21606	case "$yyy" in
21607	'')	gidsign=1
21608		echo "(I can't execute the test program--guessing unsigned.)" >&4
21609		;;
21610	*)	gidsign=$yyy
21611		case "$gidsign" in
21612		 1) echo "Your $zzz is unsigned." ;;
21613		-1) echo "Your $zzz is signed."   ;;
21614		esac
21615		;;
21616	esac
21617else
21618	gidsign=1
21619	echo "(I can't compile the test program--guessing unsigned.)" >&4
21620fi
21621
21622: Check 64bit sizes
21623echo " "
21624
21625if $test X"$quadtype" != X; then
21626
21627echo "Checking how to print 64-bit integers..." >&4
21628
21629if $test X"$sPRId64" = X -a X"$quadtype" = Xint; then
21630	$cat >try.c <<'EOCP'
21631#include <sys/types.h>
21632#include <stdio.h>
21633int main() {
21634  int q = 12345678901;
21635  printf("%ld\n", q);
21636}
21637EOCP
21638	set try
21639	if eval $compile; then
21640		yyy=`$run ./try`
21641		case "$yyy" in
21642		12345678901)
21643			sPRId64='"d"'; sPRIi64='"i"'; sPRIu64='"u"';
21644			sPRIo64='"o"'; sPRIx64='"x"'; sPRIXU64='"X"';
21645			echo "We will use %d."
21646			;;
21647		esac
21648	fi
21649fi
21650
21651if $test X"$sPRId64" = X -a X"$quadtype" = Xlong; then
21652	$cat >try.c <<'EOCP'
21653#include <sys/types.h>
21654#include <stdio.h>
21655int main() {
21656  long q = 12345678901;
21657  printf("%ld\n", q);
21658}
21659EOCP
21660	set try
21661	if eval $compile; then
21662		yyy=`$run ./try`
21663		case "$yyy" in
21664		12345678901)
21665			sPRId64='"ld"'; sPRIi64='"li"'; sPRIu64='"lu"';
21666			sPRIo64='"lo"'; sPRIx64='"lx"'; sPRIXU64='"lX"';
21667			echo "We will use %ld."
21668			;;
21669		esac
21670	fi
21671fi
21672
21673if $test X"$sPRId64" = X -a X"$i_inttypes" = X"$define" -a X"$quadtype" = Xint64_t; then
21674	$cat >try.c <<'EOCP'
21675#include <sys/types.h>
21676#include <inttypes.h>
21677#include <stdio.h>
21678int main() {
21679  int64_t q = 12345678901;
21680  printf("%" PRId64 "\n", q);
21681}
21682EOCP
21683	set try
21684	if eval $compile; then
21685		yyy=`$run ./try`
21686		case "$yyy" in
21687		12345678901)
21688			sPRId64=PRId64; sPRIi64=PRIi64; sPRIu64=PRIu64;
21689			sPRIo64=PRIo64; sPRIx64=PRIx64; sPRIXU64=PRIX64;
21690			echo "We will use the C9X style."
21691			;;
21692		esac
21693	fi
21694fi
21695
21696if $test X"$sPRId64" = X -a X"$quadtype" != X; then
21697	$cat >try.c <<EOCP
21698#include <sys/types.h>
21699#include <stdio.h>
21700int main() {
21701  $quadtype q = 12345678901;
21702  printf("%Ld\n", q);
21703}
21704EOCP
21705	set try
21706	if eval $compile; then
21707		yyy=`$run ./try`
21708		case "$yyy" in
21709		12345678901)
21710			sPRId64='"Ld"'; sPRIi64='"Li"'; sPRIu64='"Lu"';
21711			sPRIo64='"Lo"'; sPRIx64='"Lx"'; sPRIXU64='"LX"';
21712			echo "We will use %Ld."
21713			;;
21714		esac
21715	fi
21716fi
21717
21718if $test X"$sPRId64" = X -a X"$quadtype" = X"long long"; then
21719	$cat >try.c <<'EOCP'
21720#include <sys/types.h>
21721#include <stdio.h>
21722int main() {
21723  long long q = 12345678901LL; /* AIX cc requires the LL suffix. */
21724  printf("%lld\n", q);
21725}
21726EOCP
21727	set try
21728	if eval $compile; then
21729		yyy=`$run ./try`
21730		case "$yyy" in
21731		12345678901)
21732			sPRId64='"lld"'; sPRIi64='"lli"'; sPRIu64='"llu"';
21733			sPRIo64='"llo"'; sPRIx64='"llx"'; sPRIXU64='"llX"';
21734			echo "We will use the %lld style."
21735			;;
21736		esac
21737	fi
21738fi
21739
21740if $test X"$sPRId64" = X -a X"$quadtype" != X; then
21741	$cat >try.c <<EOCP
21742#include <sys/types.h>
21743#include <stdio.h>
21744int main() {
21745  $quadtype q = 12345678901;
21746  printf("%qd\n", q);
21747}
21748EOCP
21749	set try
21750	if eval $compile; then
21751		yyy=`$run ./try`
21752		case "$yyy" in
21753		12345678901)
21754			sPRId64='"qd"'; sPRIi64='"qi"'; sPRIu64='"qu"';
21755			sPRIo64='"qo"'; sPRIx64='"qx"'; sPRIXU64='"qX"';
21756			echo "We will use %qd."
21757			;;
21758		esac
21759	fi
21760fi
21761
21762if $test X"$sPRId64" = X; then
21763	echo "Cannot figure out how to print 64-bit integers." >&4
21764fi
21765$rm_try
21766
21767fi
21768
21769case "$sPRId64" in
21770'')	d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef";
21771	d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef";
21772	;;
21773*)	d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define";
21774	d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define";
21775	;;
21776esac
21777
21778: Check format strings for internal types
21779echo " "
21780$echo "Checking the format strings to be used for Perl's internal types..." >&4
21781
21782if $test X"$ivsize" = X8; then
21783	ivdformat="$sPRId64"
21784	uvuformat="$sPRIu64"
21785	uvoformat="$sPRIo64"
21786	uvxformat="$sPRIx64"
21787	uvXUformat="$sPRIXU64"
21788else
21789	if $test X"$ivsize" = X"$longsize"; then
21790		ivdformat='"ld"'
21791		uvuformat='"lu"'
21792		uvoformat='"lo"'
21793		uvxformat='"lx"'
21794		uvXUformat='"lX"'
21795	else
21796		if $test X"$ivsize" = X"$intsize"; then
21797			ivdformat='"d"'
21798			uvuformat='"u"'
21799			uvoformat='"o"'
21800			uvxformat='"x"'
21801			uvXUformat='"X"'
21802		else
21803			: far out
21804			if $test X"$ivsize" = X"$shortsize"; then
21805				ivdformat='"hd"'
21806				uvuformat='"hu"'
21807				uvoformat='"ho"'
21808				uvxformat='"hx"'
21809				uvXUformat='"hX"'
21810			fi
21811		fi
21812	fi
21813fi
21814
21815if $test X"$usequadmath" = X"$define"; then
21816    nveformat='"Qe"'
21817    nvfformat='"Qf"'
21818    nvgformat='"Qg"'
21819    nvEUformat='"QE"'
21820    nvFUformat='"QF"'
21821    nvGUformat='"QG"'
21822else
21823    if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
21824	nveformat="$sPRIeldbl"
21825	nvfformat="$sPRIfldbl"
21826	nvgformat="$sPRIgldbl"
21827	nvEUformat="$sPRIEUldbl"
21828	nvFUformat="$sPRIFUldbl"
21829	nvGUformat="$sPRIGUldbl"
21830    else
21831	nveformat='"e"'
21832	nvfformat='"f"'
21833	nvgformat='"g"'
21834	nvEUformat='"E"'
21835	nvFUformat='"F"'
21836	nvGUformat='"G"'
21837    fi
21838fi
21839
21840case "$ivdformat" in
21841'') echo "$0: Fatal: failed to find format strings, cannot continue." >&4
21842    exit 1
21843    ;;
21844esac
21845
21846: Check format string for GID
21847
21848echo " "
21849$echo "Checking the format string to be used for gids..." >&4
21850
21851case "$gidsign" in
21852-1)	if $test X"$gidsize" = X"$ivsize"; then
21853		gidformat="$ivdformat"
21854	else
21855		if $test X"$gidsize" = X"$longsize"; then
21856			gidformat='"ld"'
21857		else
21858			if $test X"$gidsize" = X"$intsize"; then
21859				gidformat='"d"'
21860			else
21861				if $test X"$gidsize" = X"$shortsize"; then
21862					gidformat='"hd"'
21863				fi
21864			fi
21865		fi
21866	fi
21867	;;
21868*)	if $test X"$gidsize" = X"$uvsize"; then
21869		gidformat="$uvuformat"
21870	else
21871		if $test X"$gidsize" = X"$longsize"; then
21872			gidformat='"lu"'
21873		else
21874			if $test X"$gidsize" = X"$intsize"; then
21875				gidformat='"u"'
21876			else
21877				if $test X"$gidsize" = X"$shortsize"; then
21878					gidformat='"hu"'
21879				fi
21880			fi
21881		fi
21882	fi
21883	;;
21884esac
21885
21886: see if getgroups exists
21887set getgroups d_getgrps
21888eval $inlibc
21889
21890: see if setgroups exists
21891set setgroups d_setgrps
21892eval $inlibc
21893
21894: Find type of 2nd arg to 'getgroups()' and 'setgroups()'
21895echo " "
21896case "$d_getgrps$d_setgrps" in
21897*define*)
21898	case "$groupstype" in
21899	'') dflt="$gidtype" ;;
21900	*)  dflt="$groupstype" ;;
21901	esac
21902	$cat <<EOM
21903What type of pointer is the second argument to getgroups() and setgroups()?
21904Usually this is the same as group ids, $gidtype, but not always.
21905
21906EOM
21907	rp='What type pointer is the second argument to getgroups() and setgroups()?'
21908	. ./myread
21909	groupstype="$ans"
21910	;;
21911*)  groupstype="$gidtype";;
21912esac
21913
21914: Check format strings for internal 32bit types
21915echo " "
21916$echo "Checking the format strings to be used for Perl's internal 32bit-types..." >&4
21917
21918case "$i32dformat" in
21919'')	case "$i32type" in
21920	int)
21921		i32dformat='"d"'
21922		u32uformat='"u"'
21923		u32oformat='"o"'
21924		u32xformat='"x"'
21925		u32XUformat='"X"'
21926		;;
21927	long)
21928		i32dformat='"ld"'
21929		u32uformat='"lu"'
21930		u32oformat='"lo"'
21931		u32xformat='"lx"'
21932		u32XUformat='"lX"'
21933		;;
21934	int_least32_t)		: will not happen currently
21935		i32dformat=PRIdLEAST32
21936		u32uformat=PRIuLEAST32
21937		u32oformat=PRIoLEAST32
21938		u32xformat=PRIxLEAST32
21939		u32XUformat=PRIXLEAST32
21940		;;
21941	int32_t)
21942		i32dformat=PRId32
21943		u32uformat=PRIu32
21944		u32oformat=PRIo32
21945		u32xformat=PRIx32
21946		u32XUformat=PRIX32
21947		;;
21948	esac ;;
21949esac
21950
21951case "$i32dformat" in
21952'') echo "$0: Fatal: failed to find format strings for 32-bit integers, cannot continue." >&4
21953    exit 1
21954    ;;
21955esac
21956
21957: check whether make sets MAKE
21958echo " "
21959echo "Checking if your $make program sets \$(MAKE)..." >&4
21960case "$make_set_make" in
21961'')
21962	$sed 's/^X //' > testmake.mak << 'EOF'
21963Xall:
21964X 	@echo 'maketemp="$(MAKE)"'
21965EOF
21966	case "`$make -f testmake.mak 2>/dev/null`" in
21967	*maketemp=*) make_set_make='#' ;;
21968	*)	make_set_make="MAKE=$make" ;;
21969	esac
21970	$rm -f testmake.mak
21971	;;
21972esac
21973case "$make_set_make" in
21974'#') echo "Yup, it does.";;
21975*) echo "Nope, it doesn't.";;
21976esac
21977
21978: see what type is used for mode_t
21979rp="What is the type used for file modes for system calls (e.g. fchmod())?"
21980set mode_t modetype int stdio.h sys/types.h
21981eval $typedef_ask
21982
21983: see if we need va_copy
21984echo " "
21985$cat >try.c <<EOCP
21986#include <stdarg.h>
21987#include <stdio.h>
21988#include <stdlib.h>
21989#include <signal.h>
21990
21991int
21992ivfprintf(FILE *f, const char *fmt, va_list *valp)
21993{
21994  return vfprintf(f, fmt, *valp);
21995}
21996
21997int
21998myvfprintf(FILE *f, const  char *fmt, va_list val)
21999{
22000  return ivfprintf(f, fmt, &val);
22001}
22002
22003int
22004myprintf(char *fmt, ...)
22005{
22006  va_list val;
22007  va_start(val, fmt);
22008  return myvfprintf(stdout, fmt, val);
22009}
22010
22011int
22012main(int ac, char **av)
22013{
22014  signal(SIGSEGV, exit);
22015#ifdef SIGBUS
22016  signal(SIGBUS,  exit);
22017#endif
22018
22019  myprintf("%s%cs all right, then\n", "that", '\'');
22020  exit(0);
22021}
22022EOCP
22023set try
22024if eval $compile && $run ./try 2>&1 >/dev/null; then
22025	case "`$run ./try`" in
22026	"that's all right, then")
22027		okay=yes
22028		;;
22029	esac
22030fi
22031case "$okay" in
22032yes)	echo "It seems that you don't need va_copy()." >&4
22033	need_va_copy="$undef"
22034	;;
22035*)	echo "It seems that va_copy() or similar will be needed." >&4
22036	need_va_copy="$define"
22037	;;
22038esac
22039$rm_try
22040
22041: see what type is used for size_t
22042rp="What is the type used for the length parameter for string functions?"
22043set size_t sizetype 'unsigned int' stdio.h sys/types.h
22044eval $typedef_ask
22045
22046: check for type of arguments to gethostbyaddr.
22047if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
22048	case "$d_gethbyaddr" in
22049	$define)
22050		$cat <<EOM
22051
22052Checking to see what type of arguments are accepted by gethostbyaddr().
22053EOM
22054		hdrs="$define sys/types.h
22055			$d_socket sys/socket.h
22056			$i_niin netinet/in.h
22057			$i_netdb netdb.h
22058			$i_unistd unistd.h"
22059		: The first arg can 'char *' or 'void *'
22060		: The second arg is some of integral type
22061		for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
22062			for yyy in size_t long int; do
22063				case "$netdb_host_type" in
22064				'')	try="$extern_C struct hostent *gethostbyaddr($xxx, $yyy, int);"
22065					if ./protochk "$try" $hdrs; then
22066						echo "Your system accepts $xxx for the first arg."
22067						echo "...and $yyy for the second arg."
22068						netdb_host_type="$xxx"
22069						netdb_hlen_type="$yyy"
22070					fi
22071					;;
22072				esac
22073			done
22074		done
22075		: In case none of those worked, prompt the user.
22076		case "$netdb_host_type" in
22077		'')	rp='What is the type for the 1st argument to gethostbyaddr?'
22078			dflt='char *'
22079			. ./myread
22080			netdb_host_type=$ans
22081			rp='What is the type for the 2nd argument to gethostbyaddr?'
22082			dflt="$sizetype"
22083			. ./myread
22084			netdb_hlen_type=$ans
22085			;;
22086		esac
22087		;;
22088	*)	: no gethostbyaddr, so pick harmless defaults
22089		netdb_host_type='char *'
22090		netdb_hlen_type="$sizetype"
22091		;;
22092	esac
22093	# Remove the "const" if needed. -- but then we'll have a
22094	# prototype clash!
22095	# netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
22096fi
22097
22098: check for type of argument to gethostbyname.
22099if test "X$netdb_name_type" = X ; then
22100	case "$d_gethbyname" in
22101	$define)
22102		$cat <<EOM
22103
22104Checking to see what type of argument is accepted by gethostbyname().
22105EOM
22106		hdrs="$define sys/types.h
22107			$d_socket sys/socket.h
22108			$i_niin netinet/in.h
22109			$i_netdb netdb.h
22110			$i_unistd unistd.h"
22111		for xxx in "const char *" "char *"; do
22112			case "$netdb_name_type" in
22113			'')	try="$extern_C struct hostent *gethostbyname($xxx);"
22114				if ./protochk "$try" $hdrs; then
22115					echo "Your system accepts $xxx."
22116					netdb_name_type="$xxx"
22117				fi
22118				;;
22119			esac
22120		done
22121		: In case none of those worked, prompt the user.
22122		case "$netdb_name_type" in
22123		'')	rp='What is the type for the 1st argument to gethostbyname?'
22124			dflt='char *'
22125			. ./myread
22126			netdb_name_type=$ans
22127			;;
22128		esac
22129		;;
22130	*)	: no gethostbyname, so pick harmless default
22131		netdb_name_type='char *'
22132		;;
22133	esac
22134fi
22135
22136: check for type of 1st argument to getnetbyaddr.
22137if test "X$netdb_net_type" = X ; then
22138	case "$d_getnbyaddr" in
22139	$define)
22140		$cat <<EOM
22141
22142Checking to see what type of 1st argument is accepted by getnetbyaddr().
22143EOM
22144		hdrs="$define sys/types.h
22145			$d_socket sys/socket.h
22146			$i_niin netinet/in.h
22147			$i_netdb netdb.h
22148			$i_unistd unistd.h"
22149		for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
22150			case "$netdb_net_type" in
22151			'')	try="$extern_C struct netent *getnetbyaddr($xxx, int);"
22152				if ./protochk "$try" $hdrs; then
22153					echo "Your system accepts $xxx."
22154					netdb_net_type="$xxx"
22155				fi
22156				;;
22157			esac
22158		done
22159		: In case none of those worked, prompt the user.
22160		case "$netdb_net_type" in
22161		'')	rp='What is the type for the 1st argument to getnetbyaddr?'
22162			dflt='long'
22163			. ./myread
22164			netdb_net_type=$ans
22165			;;
22166		esac
22167		;;
22168	*)	: no getnetbyaddr, so pick harmless default
22169		netdb_net_type='long'
22170		;;
22171	esac
22172fi
22173: locate the preferred pager for this system
22174fn=f/
22175case "$pager" in
22176'')
22177	dflt=''
22178	case "$pg" in
22179	/*) dflt=$pg;;
22180	[a-zA-Z]:/*) dflt=$pg;;
22181	esac
22182	case "$more" in
22183	/*) dflt=$more;;
22184	[a-zA-Z]:/*) dflt=$more;;
22185	esac
22186	case "$less" in
22187	/*) dflt=$less;;
22188	[a-zA-Z]:/*) dflt=$less;;
22189	esac
22190	case "$dflt" in
22191	'') dflt=/usr/ucb/more;;
22192	esac
22193	;;
22194*)	dflt="$pager"
22195	;;
22196esac
22197fn="f/($dflt)"
22198echo " "
22199rp='What pager is used on your system?'
22200. ./getfile
22201pager="$ans"
22202
22203: see if ar generates random libraries by itself
22204echo " "
22205echo "Checking how to generate random libraries on your machine..." >&4
22206echo 'extern int bar2(); int bar1() { return bar2(); }' > bar1.c
22207echo 'int bar2() { return 2; }' > bar2.c
22208$cat > foo.c <<EOP
22209#$i_stdlib I_STDLIB
22210#ifdef I_STDLIB
22211#include <stdlib.h>
22212#endif
22213#include <stdio.h>
22214extern int bar1();
22215int main() { printf("%d\n", bar1()); exit(0); }
22216EOP
22217$cc $ccflags -c bar1.c >/dev/null 2>&1
22218$cc $ccflags -c bar2.c >/dev/null 2>&1
22219$cc $ccflags -c foo.c >/dev/null 2>&1
22220$ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
22221if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
22222	$run ./foobar >/dev/null 2>&1; then
22223	echo "$ar appears to generate random libraries itself."
22224	orderlib=false
22225	if [ "X$ranlib" = "X" ]; then
22226	    ranlib=":"
22227	fi
22228elif $ar s bar$_a >/dev/null 2>&1 &&
22229	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
22230	$run ./foobar >/dev/null 2>&1; then
22231		echo "a table of contents needs to be added with '$ar s'."
22232		orderlib=false
22233		ranlib="$ar s"
22234elif $ar ts bar$_a >/dev/null 2>&1 &&
22235	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
22236	$run ./foobar >/dev/null 2>&1; then
22237		echo "a table of contents needs to be added with '$ar ts'."
22238		orderlib=false
22239		ranlib="$ar ts"
22240else
22241	case "$ranlib" in
22242	:) ranlib='';;
22243	'')
22244		ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
22245		$test -f $ranlib || ranlib=''
22246		;;
22247	esac
22248	if $test -n "$ranlib"; then
22249		echo "your system has '$ranlib'; we'll use that."
22250		orderlib=false
22251	else
22252		echo "your system doesn't seem to support random libraries"
22253		echo "so we'll use lorder and tsort to order the libraries."
22254		orderlib=true
22255		ranlib=":"
22256	fi
22257fi
22258$rm -f foo* bar*
22259
22260: Check the max offset that gmtime and localtime accept
22261echo "Checking max offsets that gmtime () accepts"
22262
22263case "$sGMTIME_min/$sGMTIME_max" in
22264    0/0|/)
22265	$cat >try.c <<EOCP
22266#include <sys/types.h>
22267#include <stdio.h>
22268#include <time.h>
22269
22270int i;
22271struct tm *tmp;
22272time_t pt;
22273
22274void gm_check (time_t t, int min_year, int max_year)
22275{
22276    tmp = gmtime (&t);
22277    if ( tmp == NULL ||
22278	/* Check tm_year overflow */
22279	 tmp->tm_year < min_year || tmp->tm_year > max_year)
22280	tmp = NULL;
22281    else
22282	pt = t;
22283    } /* gm_check */
22284
22285int check_max ()
22286{
22287    tmp = NULL;
22288    pt  = 0;
22289#ifdef MAXLONG
22290    gm_check (MAXLONG, 69, 0x7fffffff);
22291#endif
22292    if (tmp == NULL || tmp->tm_year < 0) {
22293	for (i = 63; i >= 0; i--) {
22294	    time_t x = pt | ((time_t)1 << i);
22295	    if (x < 0 || x < pt) continue;
22296	    gm_check (x, 69, 0x7fffffff);
22297	    }
22298	}
22299    printf ("sGMTIME_max=%ld\n", pt);
22300    return (0);
22301    } /* check_max */
22302
22303int check_min ()
22304{
22305    tmp = NULL;
22306    pt  = 0;
22307#ifdef MINLONG
22308    gm_check (MINLONG, -1900, 70);
22309#endif
22310    if (tmp == NULL) {
22311	for (i = 36; i >= 0; i--) {
22312	    time_t x = pt - ((time_t)1 << i);
22313	    if (x > 0) continue;
22314	    gm_check (x, -1900, 70);
22315	    }
22316	}
22317    printf ("sGMTIME_min=%ld\n", pt);
22318    return (0);
22319    } /* check_min */
22320
22321int main (int argc, char *argv[])
22322{
22323    /* fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t)); */
22324    check_max ();
22325    check_min ();
22326    return (0);
22327    } /* main */
22328EOCP
22329	set try
22330	if eval $compile; then
22331	    eval `$run ./try 2>/dev/null`
22332	else
22333	    echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
22334	    fi
22335	$rm_try
22336	;;
22337    esac
22338
22339echo "Checking max offsets that localtime () accepts"
22340
22341case "$sLOCALTIME_min/$sLOCALTIME_max" in
22342    0/0|/)
22343	$cat >try.c <<EOCP
22344#include <sys/types.h>
22345#include <stdio.h>
22346#include <time.h>
22347
22348int i;
22349struct tm *tmp;
22350time_t pt;
22351
22352void local_check (time_t t, int min_year, int max_year)
22353{
22354    if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
22355	tmp = NULL;
22356    else
22357	tmp = localtime (&t);
22358    if ( tmp == NULL ||
22359	/* Check tm_year overflow */
22360	 tmp->tm_year < min_year || tmp->tm_year > max_year)
22361	tmp = NULL;
22362    else
22363	pt = t;
22364    } /* local_check */
22365
22366int check_max ()
22367{
22368    tmp = NULL;
22369    pt  = 0;
22370#ifdef MAXLONG
22371    local_check (MAXLONG, 69, 0x7fffffff);
22372#endif
22373    if (tmp == NULL || tmp->tm_year < 0) {
22374	for (i = 63; i >= 0; i--) {
22375	    time_t x = pt | ((time_t)1 << i);
22376	    if (x < 0 || x < pt) continue;
22377	    local_check (x, 69, 0x7fffffff);
22378	    }
22379	}
22380    printf ("sLOCALTIME_max=%ld\n", pt);
22381    return (0);
22382   } /* check_max */
22383
22384int check_min ()
22385{
22386    tmp = NULL;
22387    pt  = 0;
22388#ifdef MINLONG
22389    local_check (MINLONG, -1900, 70);
22390#endif
22391    if (tmp == NULL) {
22392	for (i = 36; i >= 0; i--) {
22393	    time_t x = pt - ((time_t)1 << i);
22394	    if (x > 0) continue;
22395	    local_check (x, -1900, 70);
22396	    }
22397	}
22398    printf ("sLOCALTIME_min=%ld\n", pt);
22399    return (0);
22400    } /* check_min */
22401
22402int main (int argc, char *argv[])
22403{
22404    check_max ();
22405    check_min ();
22406    return (0);
22407    } /* main */
22408EOCP
22409	set try
22410	if eval $compile; then
22411	    eval `$run ./try 2>/dev/null`
22412	else
22413	    echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
22414	    fi
22415	$rm_try
22416	;;
22417    esac
22418
22419: check for type of arguments to select.
22420case "$selecttype" in
22421'') case "$d_select" in
22422	$define)
22423		echo " "
22424		$cat <<EOM
22425Checking to see what type of arguments are accepted by select().
22426EOM
22427		hdrs="$define sys/types.h
22428			$i_systime sys/time.h
22429			$i_sysselct sys/select.h
22430			$d_socket sys/socket.h"
22431		: The first arg can be int, unsigned, or size_t
22432		: The last arg may or may not be 'const'
22433		val=''
22434		: void pointer has been seen but using that
22435		: breaks the selectminbits test
22436		for xxx in 'fd_set *' 'int *'; do
22437			for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
22438				for tmo in 'struct timeval *' 'const struct timeval *'; do
22439					case "$val" in
22440					'')	try="$extern_C int select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
22441						if ./protochk "$try" $hdrs; then
22442							echo "Your system accepts $xxx."
22443							val="$xxx"
22444						fi
22445						;;
22446					esac
22447				done
22448			done
22449		done
22450		case "$val" in
22451		'')	rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
22452			case "$d_fd_set" in
22453				$define) dflt="fd_set *" ;;
22454				*)		dflt="int *" ;;
22455			esac
22456			. ./myread
22457			val=$ans
22458			;;
22459		esac
22460		selecttype="$val"
22461		;;
22462	*)	: no select, so pick a harmless default
22463		selecttype='int *'
22464		;;
22465	esac
22466	;;
22467esac
22468
22469: check for the select 'width'
22470case "$selectminbits" in
22471'') safebits=`expr $ptrsize \* 8`
22472    case "$d_select" in
22473	$define)
22474		$cat <<EOM
22475
22476Checking to see on how many bits at a time your select() operates...
22477EOM
22478		$cat >try.c <<EOCP
22479#include <sys/types.h>
22480#$i_time I_TIME
22481#$i_systime I_SYS_TIME
22482#$i_systimek I_SYS_TIME_KERNEL
22483#ifdef I_TIME
22484#   include <time.h>
22485#endif
22486#ifdef I_SYS_TIME
22487#   ifdef I_SYS_TIME_KERNEL
22488#	define KERNEL
22489#   endif
22490#   include <sys/time.h>
22491#   ifdef I_SYS_TIME_KERNEL
22492#	undef KERNEL
22493#   endif
22494#endif
22495#$i_sysselct I_SYS_SELECT
22496#ifdef I_SYS_SELECT
22497#include <sys/select.h>
22498#endif
22499#$d_socket HAS_SOCKET
22500#ifdef HAS_SOCKET
22501#   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
22502#endif
22503#include <stdio.h>
22504#$i_stdlib I_STDLIB
22505#ifdef I_STDLIB
22506#include <stdlib.h>
22507#endif
22508$selecttype b;
22509#define S sizeof(*(b))
22510#define MINBITS	64
22511#define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
22512#define NBITS  (NBYTES * 8)
22513int main() {
22514    char *s = (char *)malloc(NBYTES);
22515    struct timeval t;
22516    int i;
22517    FILE* fp;
22518    int fd;
22519
22520    if (!s)
22521	exit(1);
22522    fclose(stdin);
22523    fp = fopen("try.c", "r");
22524    if (fp == 0)
22525      exit(2);
22526    fd = fileno(fp);
22527    if (fd < 0)
22528      exit(3);
22529    b = ($selecttype)s;
22530    for (i = 0; i < NBITS; i++)
22531	FD_SET(i, b);
22532    t.tv_sec  = 0;
22533    t.tv_usec = 0;
22534    select(fd + 1, b, 0, 0, &t);
22535    for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
22536    free(s);
22537    printf("%d\n", i + 1);
22538    return 0;
22539}
22540EOCP
22541		set try
22542		if eval $compile_ok; then
22543			selectminbits=`$run ./try 2>/dev/null`
22544			case "$selectminbits" in
22545			'')	cat >&4 <<EOM
22546Cannot figure out on how many bits at a time your select() operates.
22547I'll play safe and guess it is $safebits bits.
22548EOM
22549				selectminbits=$safebits
22550				bits="$safebits bits"
22551				;;
22552			1)	bits="1 bit" ;;
22553			*)	bits="$selectminbits bits" ;;
22554			esac
22555			echo "Your select() operates on $bits at a time." >&4
22556		else
22557			rp='What is the minimum number of bits your select() operates on?'
22558			case "$byteorder" in
22559			12345678)	dflt=64 ;;
22560			1234)		dflt=32 ;;
22561			*)		dflt=1	;;
22562			esac
22563			. ./myread
22564			val=$ans
22565			selectminbits="$val"
22566		fi
22567		$rm_try
22568		;;
22569	*)	: no select, so pick a harmless default
22570		selectminbits=$safebits
22571		;;
22572	esac
22573	;;
22574esac
22575
22576: Trace out the files included by signal.h, then look for SIGxxx names.
22577case "$sig_num_init" in
22578'')
22579if [ "X$fieldn" = X ]; then
22580	: Just make some guesses.  We check them later.
22581	xxx="$sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h"
22582else
22583	xxx=`echo '#include <signal.h>' |
22584	$cppstdin $cppminus $cppflags 2>/dev/null |
22585	$grep '^[ 	]*#.*include' |
22586	$awk "{print \\$$fieldn}" | $sed 's!"!!g' |\
22587		$sed 's!\\\\\\\\!/!g' | $sort | $uniq`
22588fi
22589xxxfiles=''
22590for xx in $xxx /dev/null ; do
22591	$test -f "$xx" && xxxfiles="$xxxfiles $xx"
22592done
22593case "$xxxfiles" in
22594'')	xxxfiles=`./findhdr signal.h` ;;
22595esac
22596xxx=`awk '
22597$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
22598	print substr($2, 4, 20)
22599}
22600$1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
22601	print substr($3, 4, 20)
22602}' $xxxfiles`
22603: Append some common names just in case the awk scan failed.
22604xxx="$xxx ABRT ALRM BUS CANCEL CHLD CLD CONT DIL EMT FPE"
22605xxx="$xxx FREEZE HUP ILL INT IO IOT KILL LOST LWP PHONE"
22606xxx="$xxx PIPE POLL PROF PWR QUIT RTMAX RTMIN SEGV STKFLT STOP"
22607xxx="$xxx SYS TERM THAW TRAP TSTP TTIN TTOU URG USR1 USR2"
22608xxx="$xxx USR3 USR4 VTALRM WAITING WINCH WIND WINDOW XCPU XFSZ"
22609
22610: generate a few handy files for later
22611$cat > signal.c <<EOCP
22612#include <sys/types.h>
22613#include <signal.h>
22614#$i_stdlib I_STDLIB
22615#ifdef I_STDLIB
22616#include <stdlib.h>
22617#endif
22618#include <stdio.h>
22619int main() {
22620
22621/* Strange style to avoid deeply-nested #if/#else/#endif */
22622#ifndef NSIG
22623#  ifdef _NSIG
22624#    define NSIG (_NSIG)
22625#  endif
22626#endif
22627
22628#ifndef NSIG
22629#  ifdef SIGMAX
22630#    define NSIG (SIGMAX+1)
22631#  endif
22632#endif
22633
22634#ifndef NSIG
22635#  ifdef SIG_MAX
22636#    define NSIG (SIG_MAX+1)
22637#  endif
22638#endif
22639
22640#ifndef NSIG
22641#  ifdef _SIG_MAX
22642#    define NSIG (_SIG_MAX+1)
22643#  endif
22644#endif
22645
22646#ifndef NSIG
22647#  ifdef MAXSIG
22648#    define NSIG (MAXSIG+1)
22649#  endif
22650#endif
22651
22652#ifndef NSIG
22653#  ifdef MAX_SIG
22654#    define NSIG (MAX_SIG+1)
22655#  endif
22656#endif
22657
22658#ifndef NSIG
22659#  ifdef SIGARRAYSIZE
22660#    define NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */
22661#  endif
22662#endif
22663
22664#ifndef NSIG
22665#  ifdef _sys_nsig
22666#    define NSIG (_sys_nsig) /* Solaris 2.5 */
22667#  endif
22668#endif
22669
22670/* Default to some arbitrary number that's big enough to get most
22671   of the common signals.
22672*/
22673#ifndef NSIG
22674#    define NSIG 50
22675#endif
22676
22677printf("NSIG %d\n", NSIG);
22678
22679#ifndef JUST_NSIG
22680
22681EOCP
22682
22683echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
22684{
22685	printf "#ifdef SIG"; printf $1; printf "\n"
22686	printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
22687	printf $1; printf ");\n"
22688	printf "#endif\n"
22689}
22690END {
22691	printf "#endif /* JUST_NSIG */\n";
22692	printf "exit(0);\n}\n";
22693}
22694' >>signal.c
22695$cat >signal.awk <<'EOP'
22696BEGIN { ndups = 0 }
22697$1 ~ /^NSIG$/ { nsig = $2 }
22698($1 !~ /^NSIG$/) && (NF == 2) && ($2 ~ /^[0-9][0-9]*$/) {
22699    if ($2 > maxsig) { maxsig = $2 }
22700    if (sig_name[$2]) {
22701	dup_name[ndups] = $1
22702	dup_num[ndups] = $2
22703	ndups++
22704    }
22705    else {
22706	sig_name[$2] = $1
22707	sig_num[$2] = $2
22708    }
22709}
22710END {
22711    if (nsig == 0) {
22712    	nsig = maxsig + 1
22713    }
22714    printf("NSIG %d\n", nsig);
22715    for (n = 1; n < nsig; n++) {
22716 	if (sig_name[n]) {
22717 	    printf("%s %d\n", sig_name[n], sig_num[n])
22718	}
22719 	else {
22720 	    printf("NUM%d %d\n", n, n)
22721 	}
22722    }
22723    for (n = 0; n < ndups; n++) {
22724 	printf("%s %d\n", dup_name[n], dup_num[n])
22725    }
22726}
22727EOP
22728$cat >signal_cmd <<EOS
22729$startsh
22730if $test -s signal.lst; then
22731    echo "Using your existing signal.lst file"
22732	exit 0
22733fi
22734xxx="$xxx"
22735EOS
22736$cat >>signal_cmd <<'EOS'
22737
22738set signal
22739if eval $compile_ok; then
22740	$run ./signal$_exe | ($sort -n -k 2 2>/dev/null || $sort -n +1) |\
22741		$uniq | $awk -f signal.awk >signal.lst
22742else
22743	echo "(I can't seem be able to compile the whole test program)" >&4
22744	echo "(I'll try it in little pieces.)" >&4
22745	set signal -DJUST_NSIG
22746	if eval $compile_ok; then
22747		$run ./signal$_exe > signal.nsg
22748		$cat signal.nsg
22749	else
22750		echo "I can't seem to figure out how many signals you have." >&4
22751		echo "Guessing 50." >&4
22752		echo 'NSIG 50' > signal.nsg
22753	fi
22754	: Now look at all the signal names, one at a time.
22755	for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
22756		$cat > signal.c <<EOCP
22757#include <sys/types.h>
22758#include <signal.h>
22759#include <stdio.h>
22760int main() {
22761printf("$xx %d\n", SIG${xx});
22762return 0;
22763}
22764EOCP
22765		set signal
22766		if eval $compile; then
22767			echo "SIG${xx} found."
22768			$run ./signal$_exe  >> signal.ls1
22769		else
22770			echo "SIG${xx} NOT found."
22771		fi
22772	done
22773	if $test -s signal.ls1; then
22774		$cat signal.nsg signal.ls1 |
22775			$sort -n | $uniq | $awk -f signal.awk >signal.lst
22776	fi
22777
22778fi
22779if $test -s signal.lst; then
22780	:
22781else
22782	echo "(AAK! I can't compile the test programs -- Guessing)" >&4
22783	echo 'kill -l' >signal
22784	set X `csh -f <signal`
22785	$rm -f signal
22786	shift
22787	case $# in
22788	0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
22789	esac
22790	echo $@ | $tr ' ' $trnl | \
22791 	    $awk '{ printf "%s %d\n", $1, ++s; }
22792 		  END { printf "NSIG %d\n", ++s }' >signal.lst
22793fi
22794$rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
22795EOS
22796chmod a+x signal_cmd
22797$eunicefix signal_cmd
22798;;
22799esac
22800
22801: generate list of signal names
22802case "$sig_num_init" in
22803'')
22804echo " "
22805case "$sig_name_init" in
22806'') doinit=yes ;;
22807*)  case "$sig_num_init" in
22808    ''|*,*) doinit=yes ;;
22809    esac ;;
22810esac
22811case "$doinit" in
22812yes)
22813	echo "Generating a list of signal names and numbers..." >&4
22814	. ./signal_cmd
22815	sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
22816	sig_name=`$awk 'BEGIN { printf "ZERO " }
22817			!/^NSIG/ { printf "%s ", $1 }' signal.lst`
22818	sig_num=`$awk  'BEGIN { printf "0 " }
22819			!/^NSIG/ { printf "%d ", $2 }' signal.lst`
22820	sig_name_init=`$awk 'BEGIN	{ printf "\"ZERO\", " }
22821			     !/^NSIG/	{ printf "\"%s\", ", $1 }
22822			     END	{ printf "0\n" }' signal.lst`
22823	sig_num_init=`$awk  'BEGIN	{ printf "0, " }
22824			     !/^NSIG/	{ printf "%d, ", $2}
22825			     END	{ printf "0\n"}' signal.lst`
22826	;;
22827esac
22828echo "The following $sig_count signals are available:"
22829echo " "
22830echo $sig_name | $awk \
22831'BEGIN { linelen = 0 }
22832{
22833	for (i = 1; i <= NF; i++) {
22834		name = "SIG" $i " "
22835		linelen = linelen + length(name)
22836		if (linelen > 70) {
22837			printf "\n"
22838			linelen = length(name)
22839		}
22840		printf "%s", name
22841	}
22842	printf "\n"
22843}'
22844sig_size=`echo $sig_name | awk '{print NF}'`
22845$rm -f signal signal.c signal.awk signal.lst signal_cmd
22846;;
22847esac
22848
22849: Check size of size
22850echo " "
22851case "$sizetype" in
22852*_t) zzz="$sizetype"	;;
22853*)   zzz="filesize"	;;
22854esac
22855echo "Checking the size of $zzz..." >&4
22856cat > try.c <<EOCP
22857#include <sys/types.h>
22858#include <stdio.h>
22859#$i_stdlib I_STDLIB
22860#ifdef I_STDLIB
22861#include <stdlib.h>
22862#endif
22863int main() {
22864    printf("%d\n", (int)sizeof($sizetype));
22865    exit(0);
22866}
22867EOCP
22868set try
22869if eval $compile_ok; then
22870	yyy=`$run ./try`
22871	case "$yyy" in
22872	'')	sizesize=4
22873		echo "(I can't execute the test program--guessing $sizesize.)" >&4
22874		;;
22875	*)	sizesize=$yyy
22876		echo "Your $zzz size is $sizesize bytes."
22877		;;
22878	esac
22879else
22880	sizesize=4
22881	echo "(I can't compile the test program--guessing $sizesize.)" >&4
22882fi
22883
22884: check for socklen_t
22885echo " "
22886echo "Checking to see if you have socklen_t..." >&4
22887$cat >try.c <<EOCP
22888#include <sys/types.h>
22889#$d_socket HAS_SOCKET
22890#ifdef HAS_SOCKET
22891#include <sys/socket.h>
22892#endif
22893int main() { socklen_t x = 16; }
22894EOCP
22895set try
22896if eval $compile; then
22897	val="$define"
22898	echo "You have socklen_t."
22899else
22900	val="$undef"
22901	echo "You do not have socklen_t."
22902	case "$sizetype" in
22903	size_t) echo "(You do have size_t, that might work. Some people are happy with just an int.)" ;;
22904	esac
22905fi
22906$rm_try
22907set d_socklen_t
22908eval $setvar
22909
22910: see if this is a socks.h system
22911set socks.h i_socks
22912eval $inhdr
22913
22914: check for type of the size argument to socket calls
22915case "$d_socket" in
22916"$define")
22917	$cat <<EOM
22918
22919Checking to see what type is the last argument of accept().
22920EOM
22921	yyy=''
22922	case "$d_socklen_t" in
22923	"$define") yyy="$yyy socklen_t"
22924	esac
22925	yyy="$yyy $sizetype int long unsigned"
22926	for xxx in $yyy; do
22927		case "$socksizetype" in
22928		'')	try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
22929			case "$usesocks" in
22930			"$define")
22931				if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
22932					echo "Your system accepts '$xxx *' for the last argument of accept()."
22933					socksizetype="$xxx"
22934				fi
22935				;;
22936			*)	if ./protochk "$try"  $i_systypes sys/types.h $d_socket sys/socket.h; then
22937					echo "Your system accepts '$xxx *' for the last argument of accept()."
22938					socksizetype="$xxx"
22939				fi
22940				;;
22941			esac
22942			;;
22943		esac
22944	done
22945: In case none of those worked, prompt the user.
22946	case "$socksizetype" in
22947	'')	rp='What is the type for socket address structure sizes?'
22948		dflt='int'
22949		. ./myread
22950		socksizetype=$ans
22951		;;
22952	esac
22953	;;
22954*)	: no sockets, so pick relatively harmless default
22955	socksizetype='int'
22956	;;
22957esac
22958
22959: see what type is used for signed size_t
22960set ssize_t ssizetype int stdio.h sys/types.h
22961eval $typedef
22962dflt="$ssizetype"
22963$cat > try.c <<EOM
22964#include <stdio.h>
22965#$i_stdlib I_STDLIB
22966#ifdef I_STDLIB
22967#include <stdlib.h>
22968#endif
22969#include <sys/types.h>
22970#define Size_t $sizetype
22971#define SSize_t $dflt
22972int main()
22973{
22974	if (sizeof(Size_t) == sizeof(SSize_t))
22975		printf("$dflt\n");
22976	else if (sizeof(Size_t) == sizeof(int))
22977		printf("int\n");
22978	else
22979		printf("long\n");
22980	exit(0);
22981}
22982EOM
22983echo " "
22984set try
22985if eval $compile_ok && $run ./try > /dev/null; then
22986	ssizetype=`$run ./try`
22987	echo "I'll be using $ssizetype for functions returning a byte count." >&4
22988else
22989	$cat >&4 <<EOM
22990Help! I can't compile and run the ssize_t test program: please enlighten me!
22991(This is probably a misconfiguration in your system or libraries, and
22992you really ought to fix it.  Still, I'll try anyway.)
22993
22994I need a type that is the same size as $sizetype, but is guaranteed to
22995be signed.  Common values are ssize_t, int and long.
22996
22997EOM
22998	rp="What signed type is the same size as $sizetype?"
22999	. ./myread
23000	ssizetype="$ans"
23001fi
23002$rm_try
23003
23004: Check the size of st_dev
23005$echo " "
23006$echo "Checking the size of st_dev..." >&4
23007$cat > try.c <<EOCP
23008#include <sys/stat.h>
23009#include <stdio.h>
23010#$i_stdlib I_STDLIB
23011#ifdef I_STDLIB
23012#include <stdlib.h>
23013#endif
23014int main() {
23015    struct stat st;
23016    printf("%d\n", (int)sizeof(st.st_dev));
23017    exit(0);
23018}
23019EOCP
23020set try
23021if eval $compile_ok; then
23022	val=`$run ./try`
23023	case "$val" in
23024	'')	st_dev_size=4
23025		$echo "(I can't execute the test program--guessing $st_dev_size.)" >&4
23026		;;
23027	*)	st_dev_size=$val
23028		$echo "Your st_dev is $st_dev_size bytes long."
23029		;;
23030	esac
23031else
23032	st_dev_size=4
23033	$echo "(I can't compile the test program--guessing $st_dev_size.)" >&4
23034fi
23035$rm_try
23036
23037: Check if st_dev is signed
23038$echo " "
23039$echo "Checking the sign of st_dev..." >&4
23040$cat > try.c <<EOCP
23041#include <sys/stat.h>
23042#include <stdio.h>
23043int main() {
23044	struct stat foo;
23045        foo.st_dev = -1;
23046	if (foo.st_dev < 0)
23047		printf("-1\n");
23048	else
23049		printf("1\n");
23050}
23051EOCP
23052set try
23053if eval $compile; then
23054	val=`$run ./try`
23055	case "$val" in
23056	'')	st_dev_sign=1
23057		$echo "(I can't execute the test program--guessing unsigned.)" >&4
23058		;;
23059	*)	st_dev_sign=$val
23060		case "$st_dev_sign" in
23061		 1) $echo "Your st_dev is unsigned." ;;
23062		-1) $echo "Your st_dev is signed."   ;;
23063		esac
23064		;;
23065	esac
23066else
23067	st_dev_sign=1
23068	$echo "(I can't compile the test program--guessing unsigned.)" >&4
23069fi
23070$rm_try
23071
23072: Check the size of st_ino
23073$echo " "
23074$echo "Checking the size of st_ino..." >&4
23075$cat > try.c <<EOCP
23076#include <sys/stat.h>
23077#include <stdio.h>
23078#$i_stdlib I_STDLIB
23079#ifdef I_STDLIB
23080#include <stdlib.h>
23081#endif
23082int main() {
23083    struct stat st;
23084    printf("%d\n", (int)sizeof(st.st_ino));
23085    exit(0);
23086}
23087EOCP
23088set try
23089if eval $compile_ok; then
23090	val=`$run ./try`
23091	case "$val" in
23092	'')	st_ino_size=4
23093		$echo "(I can't execute the test program--guessing $st_ino_size.)" >&4
23094		;;
23095	*)	st_ino_size=$val
23096		$echo "Your st_ino is $st_ino_size bytes long."
23097		;;
23098	esac
23099else
23100	st_ino_size=4
23101	$echo "(I can't compile the test program--guessing $st_ino_size.)" >&4
23102fi
23103$rm_try
23104
23105: Check if st_ino is signed
23106$echo " "
23107$echo "Checking the sign of st_ino..." >&4
23108$cat > try.c <<EOCP
23109#include <sys/stat.h>
23110#include <stdio.h>
23111int main() {
23112	struct stat foo;
23113        foo.st_ino = -1;
23114	if (foo.st_ino < 0)
23115		printf("-1\n");
23116	else
23117		printf("1\n");
23118}
23119EOCP
23120set try
23121if eval $compile; then
23122	val=`$run ./try`
23123	case "$val" in
23124	'')	st_ino_sign=1
23125		$echo "(I can't execute the test program--guessing unsigned.)" >&4
23126		;;
23127	*)	st_ino_sign=$val
23128		case "$st_ino_sign" in
23129		 1) $echo "Your st_ino is unsigned." ;;
23130		-1) $echo "Your st_ino is signed."   ;;
23131		esac
23132		;;
23133	esac
23134else
23135	st_ino_sign=1
23136	$echo "(I can't compile the test program--guessing unsigned.)" >&4
23137fi
23138$rm_try
23139
23140: see what type of char stdio uses.
23141echo " "
23142echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
23143if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
23144	echo "Your stdio uses unsigned chars." >&4
23145	stdchar="unsigned char"
23146else
23147	echo "Your stdio uses signed chars." >&4
23148	stdchar="char"
23149fi
23150$rm -f stdioh
23151
23152: Check size of UID
23153echo " "
23154case "$uidtype" in
23155*_t) zzz="$uidtype"	;;
23156*)   zzz="uid"		;;
23157esac
23158echo "Checking the size of $zzz..." >&4
23159cat > try.c <<EOCP
23160#include <sys/types.h>
23161#include <stdio.h>
23162#$i_stdlib I_STDLIB
23163#ifdef I_STDLIB
23164#include <stdlib.h>
23165#endif
23166int main() {
23167    printf("%d\n", (int)sizeof($uidtype));
23168    exit(0);
23169}
23170EOCP
23171set try
23172if eval $compile_ok; then
23173	yyy=`$run ./try`
23174	case "$yyy" in
23175	'')	uidsize=4
23176		echo "(I can't execute the test program--guessing $uidsize.)" >&4
23177		;;
23178	*)	uidsize=$yyy
23179		echo "Your $zzz is $uidsize bytes long."
23180		;;
23181	esac
23182else
23183	uidsize=4
23184	echo "(I can't compile the test program--guessing $uidsize.)" >&4
23185fi
23186
23187: Check if UID is signed
23188echo " "
23189case "$uidtype" in
23190*_t) zzz="$uidtype"	;;
23191*)   zzz="uid"		;;
23192esac
23193echo "Checking the sign of $zzz..." >&4
23194cat > try.c <<EOCP
23195#include <sys/types.h>
23196#include <stdio.h>
23197int main() {
23198	$uidtype foo = -1;
23199	if (foo < 0)
23200		printf("-1\n");
23201	else
23202		printf("1\n");
23203}
23204EOCP
23205set try
23206if eval $compile; then
23207	yyy=`$run ./try`
23208	case "$yyy" in
23209	'')	uidsign=1
23210		echo "(I can't execute the test program--guessing unsigned.)" >&4
23211		;;
23212	*)	uidsign=$yyy
23213		case "$uidsign" in
23214		 1) echo "Your $zzz is unsigned." ;;
23215		-1) echo "Your $zzz is signed."   ;;
23216		esac
23217		;;
23218	esac
23219else
23220	uidsign=1
23221	echo "(I can't compile the test program--guessing unsigned.)" >&4
23222fi
23223
23224: Check format string for UID
23225echo " "
23226$echo "Checking the format string to be used for uids..." >&4
23227
23228case "$uidsign" in
23229-1)	if $test X"$uidsize" = X"$ivsize"; then
23230		uidformat="$ivdformat"
23231	else
23232		if $test X"$uidsize" = X"$longsize"; then
23233			uidformat='"ld"'
23234		else
23235			if $test X"$uidsize" = X"$intsize"; then
23236				uidformat='"d"'
23237			else
23238				if $test X"$uidsize" = X"$shortsize"; then
23239					uidformat='"hd"'
23240				fi
23241			fi
23242		fi
23243	fi
23244	;;
23245*)	if $test X"$uidsize" = X"$uvsize"; then
23246		uidformat="$uvuformat"
23247	else
23248		if $test X"$uidsize" = X"$longsize"; then
23249			uidformat='"lu"'
23250		else
23251			if $test X"$uidsize" = X"$intsize"; then
23252				uidformat='"u"'
23253			else
23254				if $test X"$uidsize" = X"$shortsize"; then
23255					uidformat='"hu"'
23256				fi
23257			fi
23258		fi
23259	fi
23260	;;
23261esac
23262
23263: Ask about strict by default.
23264case "$usedefaultstrict" in
23265    $define|true|[Yy]*)
23266       dflt="y"
23267       ;;
23268    *)
23269       dflt="n"
23270       ;;
23271    esac
23272
23273cat <<EOM
23274
23275EXPERIMENTAL: Perl can now be built with strict on by default when not
23276invoked with -e or -E. This is a diagnostic tool for development.
23277
23278Unless you are familiar with this feature, you should probably answer 'no'.
23279
23280EOM
23281
23282rp='Would you like to build perl with strict enabled by default?'
23283. ./myread
23284case "$ans" in
23285y|Y) val="$define" ;;
23286*)   val="$undef"  ;;
23287esac
23288set usedefaultstrict
23289eval $setvar
23290
23291: Determine if we can use sysctl with KERN_PROC_PATHNAME to find executing program
23292echo " "
23293echo "Determining whether we can use sysctl with KERN_PROC_PATHNAME to find executing program..." >&4
23294$cat >try.c <<'EOM'
23295/* Intentionally a long probe as I'd like to sanity check that the exact
23296   approach is going to work, as thinking it will work, but only having it
23297   part working at runtime is worse than not having it.  */
23298
23299#include <sys/types.h>
23300#include <sys/sysctl.h>
23301#include <sys/param.h>
23302#include <stdio.h>
23303#include <string.h>
23304#include <stdlib.h>
23305#include <unistd.h>
23306
23307int
23308main(int argc, char **argv) {
23309    char *buffer;
23310    char *argv_leaf = strrchr(argv[0], '/');
23311    char *buffer_leaf;
23312    size_t size = 0;
23313    int mib[4];
23314
23315    mib[0] = CTL_KERN;
23316    mib[1] = KERN_PROC;
23317    mib[2] = KERN_PROC_PATHNAME;
23318    mib[3] = -1;
23319
23320    if (!argv_leaf) {
23321	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
23322	return 1;
23323    }
23324
23325    if (sysctl(mib, 4, NULL, &size, NULL, 0)) {
23326	perror("sysctl");
23327	return 2;
23328    }
23329
23330    if (size < strlen(argv_leaf) + 1) {
23331	fprintf(stderr, "size %lu is too short for a path\n",
23332		(unsigned long) size);
23333	return 3;
23334    }
23335
23336    if (size > MAXPATHLEN * MAXPATHLEN) {
23337	fprintf(stderr, "size %lu is too long for a path\n",
23338		(unsigned long) size);
23339	return 4;
23340    }
23341
23342    buffer = (char *)malloc(size);
23343    if (!buffer) {
23344	perror("malloc");
23345	return 5;
23346    }
23347
23348    if (sysctl(mib, 4, buffer, &size, NULL, 0)) {
23349	perror("sysctl");
23350	return 6;
23351    }
23352
23353    if (strlen(buffer) + 1 != size) {
23354	fprintf(stderr, "size != strlen(buffer) + 1 (%lu != %lu)\n",
23355		(unsigned long)size, (unsigned long)strlen(buffer) + 1);
23356        return 7;
23357    }
23358
23359
23360    if (*buffer != '/') {
23361	fprintf(stderr, "Not an absolute path: '%s'\n", buffer);
23362	return 8;
23363    }
23364
23365    if (strstr(buffer, "/./")) {
23366	fprintf(stderr, "Contains /./: '%s'\n", buffer);
23367	return 9;
23368    }
23369
23370    if (strstr(buffer, "/../")) {
23371	fprintf(stderr, "Contains /../: '%s'\n", buffer);
23372	return 10;
23373    }
23374
23375    buffer_leaf = strrchr(buffer, '/');
23376    if (strcmp(buffer_leaf, argv_leaf) != 0) {
23377	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], buffer);
23378	return 11;
23379    }
23380
23381    free(buffer);
23382
23383    return 0;
23384}
23385EOM
23386
23387val=$undef
23388set try
23389if eval $compile; then
23390	if $run ./try; then
23391		echo "You can use sysctl with KERN_PROC_PATHNAME to find the executing program." >&4
23392		val="$define"
23393	else
23394		echo "Nope, sysctl with KERN_PROC_PATHNAME doesn't work here." >&4
23395		val="$undef"
23396	fi
23397else
23398	echo "I'm unable to compile the test program." >&4
23399	echo "I'll assume no sysctl with KERN_PROC_PATHNAME here." >&4
23400	val="$undef"
23401fi
23402$rm_try
23403set usekernprocpathname
23404eval $setvar
23405
23406: Determine if we can use _NSGetExecutablePath to find executing program
23407echo " "
23408echo "Determining whether we can use _NSGetExecutablePath to find executing program..." >&4
23409$cat >try.c <<'EOM'
23410/* Intentionally a long probe as I'd like to sanity check that the exact
23411   approach is going to work, as thinking it will work, but only having it
23412   part working at runtime is worse than not having it.  */
23413#include <mach-o/dyld.h>
23414#include <stdio.h>
23415#include <stdlib.h>
23416#include <sys/param.h>
23417#include <string.h>
23418
23419int
23420main(int argc, char **argv) {
23421    char buf[1];
23422    uint32_t size = sizeof(buf);
23423    int result;
23424    char *buffer;
23425    char *tidied;
23426    char *argv_leaf = strrchr(argv[0], '/');
23427    char *tidied_leaf;
23428
23429    if (!argv_leaf) {
23430	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
23431	return 1;
23432    }
23433
23434    _NSGetExecutablePath(buf, &size);
23435    if (size > MAXPATHLEN * MAXPATHLEN) {
23436	fprintf(stderr, "_NSGetExecutablePath size %u is too long for a path\n",
23437		(unsigned int) size);
23438	return 2;
23439    }
23440
23441    buffer = (char *)malloc(size);
23442    if (!buffer) {
23443	perror("malloc");
23444	return 3;
23445    }
23446
23447    result = _NSGetExecutablePath(buffer, &size);
23448    if (result != 0) {
23449	fprintf(stderr, "_NSGetExecutablePath returned %i for a size of %u\n",
23450		result, (unsigned int) size);
23451	return 4;
23452    }
23453
23454    tidied = realpath(buffer, NULL);
23455    if (!tidied) {
23456	perror("realpath");
23457	return 5;
23458    }
23459
23460    free(buffer);
23461
23462    if (*tidied != '/') {
23463	fprintf(stderr, "Not an absolute path: '%s'\n", tidied);
23464	return 6;
23465    }
23466
23467    if (strstr(tidied, "/./")) {
23468	fprintf(stderr, "Contains /./: '%s'\n", tidied);
23469	return 7;
23470    }
23471
23472    if (strstr(tidied, "/../")) {
23473	fprintf(stderr, "Contains /../: '%s'\n", tidied);
23474	return 8;
23475    }
23476
23477    tidied_leaf = strrchr(tidied, '/');
23478    if (strcmp(tidied_leaf, argv_leaf) != 0) {
23479	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], tidied);
23480	return 9;
23481    }
23482
23483    free(tidied);
23484
23485    return 0;
23486}
23487EOM
23488
23489val=$undef
23490set try
23491if eval $compile; then
23492	if $run ./try; then
23493		echo "You can use _NSGetExecutablePath to find the executing program." >&4
23494		val="$define"
23495	else
23496		echo "Nope, _NSGetExecutablePath doesn't work here." >&4
23497	fi
23498else
23499	echo "I'm unable to compile the test program." >&4
23500	echo "I'll assume no _NSGetExecutablePath here." >&4
23501fi
23502$rm_try
23503set usensgetexecutablepath
23504eval $setvar
23505
23506: Check if site customization support was requested
23507case "$usesitecustomize" in
23508    $define|true|[Yy]*)
23509	usesitecustomize="$define"
23510	;;
23511    *)
23512	usesitecustomize="$undef"
23513	;;
23514    esac
23515
23516: determine compiler compiler
23517case "$yacc" in
23518'')
23519	dflt=yacc;;
23520*)
23521	dflt="$yacc";;
23522esac
23523echo " "
23524comp='yacc'
23525if $test -f "$byacc$_exe"; then
23526	dflt="$byacc"
23527	comp="byacc or $comp"
23528fi
23529if $test -f "$bison$_exe"; then
23530	comp="$comp or bison -y"
23531fi
23532rp="Which compiler compiler ($comp) shall I use?"
23533. ./myread
23534yacc="$ans"
23535case "$yacc" in
23536*bis*)
23537	case "$yacc" in
23538	*-y*) ;;
23539	*)
23540		yacc="$yacc -y"
23541		echo "(Adding -y option to bison to get yacc-compatible behavior.)"
23542		;;
23543	esac
23544	;;
23545esac
23546
23547: see if this is a bfd.h system
23548set bfd.h i_bfd
23549eval $inhdr
23550
23551: see if this is an execinfo.h system
23552set execinfo.h i_execinfo
23553eval $inhdr
23554
23555: see if this is a fenv.h system
23556set fenv.h i_fenv
23557eval $inhdr
23558
23559: see if this is a fp.h system
23560set fp.h i_fp
23561eval $inhdr
23562
23563: see if this is a fp_class.h system
23564set fp_class.h i_fp_class
23565eval $inhdr
23566
23567: see if gdbm.h is available
23568set gdbm.h t_gdbm
23569eval $inhdr
23570case "$t_gdbm" in
23571$define)
23572	: see if gdbm_open exists
23573	set gdbm_open d_gdbm_open
23574	eval $inlibc
23575	case "$d_gdbm_open" in
23576	$undef)
23577		t_gdbm="$undef"
23578		echo "We won't be including <gdbm.h>"
23579		;;
23580	esac
23581	;;
23582esac
23583val="$t_gdbm"
23584set i_gdbm
23585eval $setvar
23586
23587: see if this is a ieeefp.h system
23588case "$i_ieeefp" in
23589'' ) set ieeefp.h i_ieeefp
23590     eval $inhdr
23591     ;;
23592esac
23593
23594: see if this is a libutil.h system
23595set libutil.h i_libutil
23596eval $inhdr
23597
23598: see if mach cthreads are available
23599if test "X$usethreads" = "X$define"; then
23600	set mach/cthreads.h i_machcthr
23601	eval $inhdr
23602else
23603	i_machcthr="$undef"
23604fi
23605
23606: see if this is a mntent.h system
23607set mntent.h i_mntent
23608eval $inhdr
23609
23610: see if net/errno.h is available
23611val=''
23612set net/errno.h val
23613eval $inhdr
23614
23615: Unfortunately, it causes problems on some systems.  Arrgh.
23616case "$val" in
23617$define)
23618	cat > try.c <<'EOM'
23619#include <stdio.h>
23620#include <errno.h>
23621#include <net/errno.h>
23622int func()
23623{
23624	return ENOTSOCK;
23625}
23626EOM
23627	if $cc $ccflags -c try.c >/dev/null 2>&1; then
23628		echo "We'll be including <net/errno.h>." >&4
23629	else
23630		echo "We won't be including <net/errno.h>." >&4
23631		val="$undef"
23632	fi
23633	$rm_try
23634	;;
23635esac
23636set i_neterrno
23637eval $setvar
23638
23639: see if netinet/tcp.h is available
23640set netinet/tcp.h i_netinettcp
23641eval $inhdr
23642
23643: see if this is a poll.h system
23644set poll.h i_poll
23645eval $inhdr
23646
23647: see if this is a prot.h system
23648set prot.h i_prot
23649eval $inhdr
23650
23651: Preprocessor symbols
23652echo " "
23653$echo "Guessing which symbols your C compiler and preprocessor define..." >&4
23654$cat <<'EOSH' > Cppsym.know
23655a29k aarch64 ABI64 aegis AES_SOURCE AIX AIX32 AIX370 AIX41 AIX42
23656AIX43 aixpc AIX_SOURCE alliant ALL_SOURCE alpha AM29000 am29000
23657AMD64 amd64 amiga AMIGAOS AMIX ansi ANSI_C_SOURCE apollo arch_ppc
23658arch_pwr ardent ARM ARM32 atarist att386 att3b
23659BeOS BIG_ENDIAN BIT_MSF BSD bsd bsd43 bsd4_2 BSD4_3 bsd4_3 bsd4_4
23660BSDCOMPAT bsdi BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES bull
23661byteorder byte_order
23662c cadmus clang clipper CMU COFF COMPILER_VERSION concurrent
23663convex cpu CRAY cray CRAYMPP ctix CX_UX CYGWIN
23664DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO Dynix DynixPTX
23665ELF encore EPI EXTENSIONS
23666FAVOR_BSD FILE_OFFSET_BITS FORTIFY_SOURCE FreeBSD
23667GCC_NEW_VARARGS gcos gcx gimpel GLIBC GLIBC_MINOR GNUC GNUC_MINOR
23668GNU_LIBRARY GNU_SOURCE GO32 gould GOULD_PN
23669H3050R H3050RX hbullx20 hcx host_mips hp200 hp300 HP700 hp700
23670hp800 hp9000 hp9000s200 hp9000s300 hp9000s400
23671hp9000s700 hp9000s800 hp9k8 hppa hpux HPUX_SOURCE hp_osf
23672i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960 IA32 IA64
23673iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
23674INLINE_INTRINSICS INT64 INTEL interdata INTRINSICS is68k itanium
23675ksr1
23676LANGUAGE_C LARGEFILE64_SOURCE LARGEFILE_SOURCE LARGE_FILE_API
23677LFS64_LARGEFILE LFS_LARGEFILE LIBCATAMOUNT Linux LITTLE_ENDIAN
23678LONG64 LONGDOUBLE LONGLONG LONG_DOUBLE LONG_LONG LP64 luna
23679luna88k Lynx
23680M68000 m68k m88100 m88k M88KBCS_TARGET MACH machine MachTen
23681MATH_HAS_NO_SIDE_EFFECTS mc300 mc500 mc68000 mc68010 mc68020
23682mc68030 mc68040 mc68060 mc68k mc68k32 mc700 mc88000 mc88100
23683merlin mert MiNT mips MIPSEB MIPSEL MIPS_FPSET MIPS_ISA MIPS_SIM
23684MIPS_SZINT MIPS_SZLONG MIPS_SZPTR MODERN_C motorola MSDOS
23685MTXINU MULTIMAX MVS mvs M_AMD64 M_ARM M_ARMT M_COFF M_I186 M_I286
23686M_I386 M_I8086 M_I86 M_I86SM M_IA64 M_IX86 M_PPC M_SYS3 M_SYS5
23687M_SYSIII M_SYSV M_UNIX M_X86 M_XENIX
23688n16 ncl_el ncl_mr NetBSD news1500 news1700 news1800 news1900
23689news3700 news700 news800 news900 NeXT NLS nonstopux ns16000
23690ns32000 ns32016 ns32332 ns32k nsc32000
23691OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
23692PARAGON parisc pa_risc PA_RISC1_1 PA_RISC2_0 pc532 pdp11 PGC PIC
23693plexus PORTAR posix POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
23694POSIX_C_SOURCE POSIX_SOURCE POWER powerpc ppc PROTOTYPES PWB pyr
23695QK_USER QNX
23696R3000 REENTRANT RES Rhapsody RISC6000 riscix riscos RT
23697S390 S390x SA110 SCO scs sequent sgi SGI_SOURCE SH SH3 sinix
23698SIZE_INT SIZE_LONG SIZE_PTR SOCKETS_SOURCE SOCKET_SOURCE sony
23699sonyrisc sony_news sparc sparclite sparcv8 sparcv9 spectrum
23700stardent stdc STDC_EXT stratos sun sun3 sun386 Sun386i svr3 svr4
23701SVR4_2 SVR4_SOURCE svr5 SX system SYSTYPE_BSD SYSTYPE_BSD43
23702SYSTYPE_BSD44 SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3
23703SYSV4 SYSV5 sysV68 sysV88
23704Tek4132 Tek4300 thumb thw_370 thw_intel thw_rs6000 titan TM3200
23705TM5400 TM5600 tower tower32 tower32_200 tower32_600 tower32_700
23706tower32_800 tower32_850 tss
23707u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5 ultrix UMAXV UnicomPBB
23708UnicomPBD UNICOS UNICOSMK unix UNIX95 UNIX99 unixpc unos USE_BSD
23709USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE
23710USE_LARGEFILE64 USE_MISC USE_POSIX USE_POSIX199309
23711USE_POSIX199506 USE_POSIX2 USE_REENTRANT USE_SVID USE_UNIX98
23712USE_XOPEN USE_XOPEN_EXTENDED USGr4 USGr4_2 UTek Utek UTS UWIN
23713uxpm uxps
23714vax venix VMESA vms
23715x86_64 xenix Xenix286 XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2
23716XPG2_EXTENDED XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
23717z8000 zarch
23718EOSH
23719# Maybe put other stuff here too.
23720./tr '-' '_' <<EOSH >>Cppsym.know
23721$osname
23722EOSH
23723./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
23724./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b
23725$cat Cppsym.know > Cppsym.c
23726$cat Cppsym.a Cppsym.b Cppsym.c | $tr ' ' $trnl | $sort | $uniq > Cppsym.know
23727$rm -f Cppsym.a Cppsym.b Cppsym.c
23728cat <<EOSH > Cppsym
23729$startsh
23730if $test \$# -gt 0; then
23731    echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
23732    if $test -s Cppsym.got; then
23733	$rm -f Cppsym.got
23734	exit 0
23735    fi
23736    $rm -f Cppsym.got
23737    exit 1
23738else
23739    $tr " " "$trnl" | ./Cppsym.try
23740    exit 0
23741fi
23742EOSH
23743chmod +x Cppsym
23744$eunicefix Cppsym
23745cat <<EOSH > Cppsym.try
23746$startsh
23747cat <<'EOCP' > try.c
23748#include <stdio.h>
23749#if cpp_stuff == 1
23750#define STRINGIFY(a)    "a"
23751#endif
23752#if cpp_stuff == 42
23753#define StGiFy(a)  #a
23754#define STRINGIFY(a)    StGiFy(a)
23755#endif
23756#if $cpp_stuff != 1 && $cpp_stuff != 42
23757#   include "Bletch: How does this C preprocessor stringify macros?"
23758#endif
23759int main() {
23760EOCP
23761$awk \\
23762EOSH
23763cat <<'EOSH' >> Cppsym.try
23764'length($1) > 0 {
23765    printf "#ifdef %s\nprintf(\"%s=%%s\\n\", STRINGIFY(%s));\n#endif\n", $1, $1, $1
23766    printf "#ifdef _%s\nprintf(\"_%s=%%s\\n\", STRINGIFY(_%s));\n#endif\n", $1, $1, $1
23767    printf "#ifdef __%s\nprintf(\"__%s=%%s\\n\", STRINGIFY(__%s));\n#endif\n", $1, $1, $1
23768    printf "#ifdef __%s__\nprintf(\"__%s__=%%s\\n\", STRINGIFY(__%s__));\n#endif\n", $1, $1, $1
23769}' >> try.c
23770echo 'return 0;}' >> try.c
23771EOSH
23772cat <<EOSH >> Cppsym.try
23773ccflags="$ccflags"
23774case "$osname-$gccversion" in
23775irix-) ccflags="\$ccflags -woff 1178" ;;
23776os2-*) ccflags="\$ccflags -Zlinker /PM:VIO" ;;
23777esac
23778$cc -o try -Dcpp_stuff=$cpp_stuff $optimize \$ccflags $ldflags try.c $libs 2>/dev/null && $run ./try | $sed 's/ /\\\\ /g'
23779EOSH
23780chmod +x Cppsym.try
23781$eunicefix Cppsym.try
23782./Cppsym < Cppsym.know | $sort | $uniq > Cppsym.true
23783: Add in any Linux cpp "predefined macros":
23784case "$osname::$gccversion" in
23785  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
23786    tHdrH=_tmpHdr
23787    rm -f $tHdrH'.h' $tHdrH
23788    touch $tHdrH'.h'
23789    # Filter out macro arguments, such as Linux's __INT8_C(c)
23790    if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
23791       sed -e 's/#define[\ \  ]*//;s/[\ \     ].*$//' -e 's/(.*//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
23792       if [ -s $tHdrH'_cppsym.real' ]; then
23793	  cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
23794       fi
23795    fi
23796    rm -f $tHdrH'.h' $tHdrH'_cppsym.h' $tHdrH'_cppsym.real'
23797  ;;
23798esac
23799: now check the C compiler for additional symbols
23800postprocess_cc_v=''
23801case "$osname" in
23802aix) postprocess_cc_v="|$tr , ' '" ;;
23803esac
23804$cat >ccsym <<EOS
23805$startsh
23806$cat >tmp.c <<EOF
23807extern int foo;
23808EOF
23809for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
23810do
23811	case "\$i" in
23812	-D*) echo "\$i" | $sed 's/^-D//;s/['\''\"]//g';;
23813	-A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A//' | $sed 's/\(.*\)(\(.*\))/\1=\2/';;
23814	esac
23815done
23816$rm_try
23817EOS
23818postprocess_cc_v=''
23819chmod +x ccsym
23820$eunicefix ccsym
23821./ccsym > ccsym1.raw
23822if $test -s ccsym1.raw; then
23823    $sort ccsym1.raw | $uniq >ccsym.raw
23824else
23825    mv ccsym1.raw ccsym.raw
23826fi
23827
23828$awk '/\=/ { print $0; next }
23829	{ print $0"=1" }' ccsym.raw >ccsym.list
23830$comm -13 Cppsym.true ccsym.list >ccsym.own
23831$comm -12 Cppsym.true ccsym.list >ccsym.com
23832$comm -23 Cppsym.true ccsym.list >ccsym.cpp
23833also=''
23834if $test -z ccsym.raw; then
23835	echo "Your C compiler doesn't seem to define any symbols!" >&4
23836	echo " "
23837	echo "However, your C preprocessor defines the following symbols:"
23838	$cat Cppsym.true
23839	ccsymbols=''
23840	cppsymbols=`$cat Cppsym.true`
23841	cppsymbols=`echo $cppsymbols`
23842	cppccsymbols="$cppsymbols"
23843else
23844	if $test -s ccsym.com; then
23845		echo "Your C compiler and pre-processor define these symbols:"
23846		$sed -e 's/\(..*\)=.*/\1/' ccsym.com
23847		also='also '
23848		symbols='ones'
23849		cppccsymbols=`$cat ccsym.com`
23850		cppccsymbols=`echo $cppccsymbols`
23851		$test "$silent" || sleep 1
23852	fi
23853	if $test -s ccsym.cpp; then
23854		$test "$also" && echo " "
23855		echo "Your C pre-processor ${also}defines the following symbols:"
23856		$sed -e 's/\(..*\)=.*/\1/' ccsym.cpp
23857		also='further '
23858		cppsymbols=`$cat ccsym.cpp`
23859		cppsymbols=`echo $cppsymbols`
23860		$test "$silent" || sleep 1
23861	fi
23862	if $test -s ccsym.own; then
23863		$test "$also" && echo " "
23864		echo "Your C compiler ${also}defines the following cpp symbols:"
23865		$sed -e 's/\(..*\)=1/\1/' ccsym.own
23866		$sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
23867		ccsymbols=`$cat ccsym.own`
23868		ccsymbols=`echo $ccsymbols`
23869		$test "$silent" || sleep 1
23870	fi
23871fi
23872
23873: add -D_FORTIFY_SOURCE if feasible and not already there
23874case "$gccversion" in
23875[456789].*|[1-9][0-9]*)	case "$optimize$ccflags" in
23876	*-O*)	case "$ccflags$cppsymbols" in
23877		*_FORTIFY_SOURCE=*) # Don't add it again.
23878			echo "You seem to have -D_FORTIFY_SOURCE already, not adding it." >&4
23879			;;
23880		*)	echo "Adding -D_FORTIFY_SOURCE=2 to ccflags..." >&4
23881			ccflags="$ccflags -D_FORTIFY_SOURCE=2"
23882			;;
23883		esac
23884		;;
23885	*)	echo "You have gcc 4.* or later but not optimizing, not adding -D_FORTIFY_SOURCE." >&4
23886		;;
23887	esac
23888	;;
23889*)	echo "You seem not to have gcc 4.* or later, not adding -D_FORTIFY_SOURCE." >&4
23890	;;
23891esac
23892
23893: script used to emit important warnings
23894cat >warn <<EOS
23895$startsh
23896if test \$# -gt 0; then
23897	echo "\$@" >msg
23898else
23899	cat >msg
23900fi
23901echo "*** WARNING:" >&4
23902sed -e 's/^/*** /' <msg >&4
23903echo "*** " >&4
23904cat msg >>config.msg
23905echo " " >>config.msg
23906rm -f msg
23907EOS
23908chmod +x warn
23909$eunicefix warn
23910
23911: see if this is a termio system
23912val="$undef"
23913val2="$undef"
23914val3="$undef"
23915if $test `./findhdr termios.h`; then
23916    set tcsetattr i_termios
23917    eval $inlibc
23918    val3="$i_termios"
23919fi
23920echo " "
23921case "$val3" in
23922    "$define") echo "You have POSIX termios.h... good!" >&4;;
23923    *)  if ./Cppsym pyr; then
23924	    case "`$run /bin/universe`" in
23925		ucb) if $test `./findhdr sgtty.h`; then
23926			val2="$define"
23927			echo "<sgtty.h> found." >&4
23928		    else
23929			echo "System is pyramid with BSD universe."
23930			./warn "<sgtty.h> not found--you could have problems."
23931		    fi;;
23932		*)  if $test `./findhdr termio.h`; then
23933			val="$define"
23934			echo "<termio.h> found." >&4
23935		    else
23936			echo "System is pyramid with USG universe."
23937			./warn "<termio.h> not found--you could have problems."
23938		    fi;;
23939	    esac
23940	elif ./usg; then
23941	    if $test `./findhdr termio.h`; then
23942		echo "<termio.h> found." >&4
23943		val="$define"
23944	    elif $test `./findhdr sgtty.h`; then
23945		echo "<sgtty.h> found." >&4
23946		val2="$define"
23947	    else
23948		./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
23949	    fi
23950	else
23951	    if $test `./findhdr sgtty.h`; then
23952		echo "<sgtty.h> found." >&4
23953		val2="$define"
23954	    elif $test `./findhdr termio.h`; then
23955		echo "<termio.h> found." >&4
23956		val="$define"
23957	    else
23958		./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
23959	    fi
23960	fi;;
23961esac
23962set i_termio; eval $setvar
23963val=$val2; set i_sgtty; eval $setvar
23964val=$val3; set i_termios; eval $setvar
23965
23966: see if stdbool is available
23967: we want a real compile instead of Inhdr because some Solaris systems
23968: have stdbool.h, but it can only be used if the compiler indicates it
23969: is sufficiently c99-compliant.
23970echo " "
23971$cat >try.c <<EOCP
23972#include <stdio.h>
23973#include <stdbool.h>
23974int func(bool x)
23975{
23976    return x ? 1 : 0;
23977}
23978int main(int argc, char **argv)
23979{
23980    return func(0);
23981}
23982EOCP
23983set try
23984if eval $compile; then
23985	echo "<stdbool.h> found." >&4
23986	val="$define"
23987else
23988	echo "<stdbool.h> NOT found." >&4
23989	val="$undef"
23990fi
23991$rm_try
23992set i_stdbool
23993eval $setvar
23994
23995: see if stdint is available
23996set stdint.h i_stdint
23997eval $inhdr
23998
23999: see if sys/access.h is available
24000set sys/access.h i_sysaccess
24001eval $inhdr
24002
24003: see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
24004set sys/filio.h i_sysfilio
24005eval $inhdr
24006echo " "
24007if $test `./findhdr sys/ioctl.h`; then
24008	val="$define"
24009	echo '<sys/ioctl.h> found.' >&4
24010else
24011	val="$undef"
24012	if $test $i_sysfilio = "$define"; then
24013	    echo '<sys/ioctl.h> NOT found.' >&4
24014	else
24015		$test $i_sgtty = "$define" && xxx="sgtty.h"
24016		$test $i_termio = "$define" && xxx="termio.h"
24017		$test $i_termios = "$define" && xxx="termios.h"
24018echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
24019	fi
24020fi
24021set i_sysioctl
24022eval $setvar
24023
24024: see if socket ioctl defs are in sys/sockio.h
24025echo " "
24026xxx=`./findhdr sys/sockio.h`
24027if $test "$xxx"; then
24028	if $contains SIOCATMARK $xxx >/dev/null 2>&1; then
24029		val="$define"
24030		echo "You have socket ioctls defined in <sys/sockio.h>." >&4
24031	else
24032		val="$undef"
24033		echo "No socket ioctls found in <sys/sockio.h>." >&4
24034	fi
24035else
24036	val="$undef"
24037	$cat <<EOM
24038<sys/sockio.h> not found, assuming socket ioctls are in <sys/ioctl.h>.
24039EOM
24040fi
24041set i_syssockio
24042eval $setvar
24043
24044: see if this is a syslog.h system
24045set syslog.h i_syslog
24046eval $inhdr
24047
24048: see if this is a sys/mode.h system
24049set sys/mode.h i_sysmode
24050eval $inhdr
24051
24052: see if there is a sys/poll.h file
24053set sys/poll.h i_syspoll
24054eval $inhdr
24055
24056: see if sys/resource.h has to be included
24057set sys/resource.h i_sysresrc
24058eval $inhdr
24059
24060: see if sys/security.h is available
24061set sys/security.h i_syssecrt
24062eval $inhdr
24063
24064: see if this is a sys/statvfs.h system
24065set sys/statvfs.h i_sysstatvfs
24066eval $inhdr
24067
24068: see if this is a sys/un.h system
24069set sys/un.h i_sysun
24070eval $inhdr
24071
24072: see if this is a sys/utsname.h system
24073set sys/utsname.h i_sysutsname
24074eval $inhdr
24075
24076: see if this is a syswait system
24077set sys/wait.h i_syswait
24078eval $inhdr
24079
24080: see if this is a ustat.h system
24081set ustat.h i_ustat
24082eval $inhdr
24083
24084: see if this is an utime system
24085set utime.h i_utime
24086eval $inhdr
24087
24088: see if this is a vfork system
24089case "$d_vfork" in
24090"$define")
24091	set vfork.h i_vfork
24092	eval $inhdr
24093	;;
24094*)
24095	i_vfork="$undef"
24096	;;
24097esac
24098
24099: see if wchar.h is present
24100set wchar.h i_wchar
24101eval $inhdr
24102
24103: Check extensions
24104echo " "
24105echo "Looking for extensions..." >&4
24106: If we are using the old config.sh, nonxs_extensions and xs_extensions may
24107: contain old or inaccurate or duplicate values.
24108nonxs_extensions=''
24109xs_extensions=''
24110: We do not use find because it might not be available.
24111: We do not just use MANIFEST because the user may have dropped
24112: some additional extensions into the source tree and expect them
24113: to be built.
24114
24115: Function to recursively find available extensions, ignoring DynaLoader
24116: NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
24117: In 5.10.1 and later, extensions are stored in directories
24118: like File-Glob instead of the older File/Glob/.
24119find_extensions='
24120    for xxx in *; do
24121	case "$xxx" in
24122	    CVS) ;;
24123	    DynaLoader|dynaload) ;;
24124	    *)
24125	    this_ext=`echo "$xxx" | $sed -e s/-/\\\//g`;
24126	    case "$this_ext" in
24127		Scalar/List/Utils) this_ext="List/Util"	;;
24128		PathTools)         this_ext="Cwd"	;;
24129	    esac;
24130	    echo " $xs_extensions $nonxs_extensions" > "$tdir/$$.tmp";
24131	    if $contains " $this_ext " "$tdir/$$.tmp"; then
24132		echo >&4;
24133		echo "Duplicate directories detected for extension $xxx" >&4;
24134		echo "Configure cannot correctly recover from this - shall I abort?" >&4;
24135		case "$knowitall" in
24136		"") dflt=y;;
24137		*) dflt=n;;
24138		esac;
24139		. ../UU/myread;
24140		case "$ans" in
24141		n*|N*) ;;
24142		*) echo >&4;
24143		    echo "Ok.  Stopping Configure." >&4;
24144		    echo "Please remove the duplicate directory (e.g. using git clean) and then re-run Configure" >&4;
24145		    exit 1;;
24146		esac;
24147		echo "Ok.  You will need to correct config.sh before running make." >&4;
24148	    fi;
24149	    $ls -1 "$xxx" > "$tdir/$$.tmp";
24150	    if   $contains "\.xs$" "$tdir/$$.tmp" > /dev/null 2>&1; then
24151		xs_extensions="$xs_extensions $this_ext";
24152	    elif $contains "\.c$"  "$tdir/$$.tmp" > /dev/null 2>&1; then
24153		xs_extensions="$xs_extensions $this_ext";
24154	    elif $test -d "$xxx"; then
24155		nonxs_extensions="$nonxs_extensions $this_ext";
24156	    fi;
24157	    $rm -f "$tdir/$$.tmp";
24158	    ;;
24159	esac;
24160    done'
24161tdir=`pwd`
24162cd "$rsrc/cpan"
24163set X
24164shift
24165eval $find_extensions
24166cd "$rsrc/dist"
24167set X
24168shift
24169eval $find_extensions
24170cd "$rsrc/ext"
24171set X
24172shift
24173eval $find_extensions
24174set X $xs_extensions
24175shift
24176xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
24177set X $nonxs_extensions
24178shift
24179nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
24180cd "$tdir"
24181known_extensions=`echo $nonxs_extensions $xs_extensions  | tr ' ' $trnl | $sort | tr $trnl ' '`
24182
24183: Now see which are supported on this system.
24184avail_ext=''
24185for xxx in $xs_extensions ; do
24186	case "$xxx" in
24187	Amiga*)
24188		case "$osname" in
24189		amigaos) avail_ext="$avail_ext $xxx" ;;
24190		esac
24191		;;
24192	DB_File|db_file)
24193		case "$i_db" in
24194		$define) avail_ext="$avail_ext $xxx" ;;
24195		esac
24196		;;
24197	GDBM_File|gdbm_fil)
24198		case "$i_gdbm" in
24199		$define) avail_ext="$avail_ext $xxx" ;;
24200		esac
24201		;;
24202	IPC/SysV|ipc/sysv)
24203		: XXX Do we need a useipcsysv variable here
24204		case "${d_msg}${d_sem}${d_shm}" in
24205		*"${define}"*) avail_ext="$avail_ext $xxx" ;;
24206		esac
24207		;;
24208	NDBM_File|ndbm_fil)
24209		case "$d_ndbm" in
24210		$define)
24211		    case "$osname-$use64bitint" in
24212		    hpux-define)
24213			case "$libs" in
24214			*-lndbm*) avail_ext="$avail_ext $xxx" ;;
24215			esac
24216			;;
24217		    *) avail_ext="$avail_ext $xxx" ;;
24218		    esac
24219		    ;;
24220		esac
24221		;;
24222	ODBM_File|odbm_fil)
24223		case "${i_dbm}${i_rpcsvcdbm}" in
24224		*"${define}"*)
24225		    case "$d_cplusplus" in
24226		    define) ;; # delete as a function name will not work
24227		    *)  case "$osname-$use64bitint" in
24228			hpux-define)
24229			    case "$libs" in
24230			    *-ldbm*) avail_ext="$avail_ext $xxx" ;;
24231			    esac
24232			    ;;
24233			*) avail_ext="$avail_ext $xxx" ;;
24234			esac
24235			;;
24236		    esac
24237		    ;;
24238		esac
24239		;;
24240	Opcode|opcode)
24241		case "$useopcode" in
24242		true|define|y) avail_ext="$avail_ext $xxx" ;;
24243		esac
24244		;;
24245	POSIX|posix)
24246		case "$useposix" in
24247		true|define|y) avail_ext="$avail_ext $xxx" ;;
24248		esac
24249		;;
24250	Socket|socket)
24251		case "$d_socket" in
24252		true|$define|y) avail_ext="$avail_ext $xxx" ;;
24253		esac
24254		;;
24255	I18N/Langinfo|langinfo)
24256		case "$uselanginfo" in
24257		true|define|y) avail_ext="$avail_ext $xxx" ;;
24258		esac
24259		;;
24260	Sys/Syslog|sys/syslog)
24261		case $osname in
24262			amigaos) ;; # not really very useful on AmigaOS
24263			*)
24264			: XXX syslog requires socket
24265			case "$d_socket" in
24266			true|$define|y) avail_ext="$avail_ext $xxx" ;;
24267			esac
24268			;;
24269		esac
24270		;;
24271	threads|threads/shared)
24272		# threads and threads::shared are special cases.
24273		# To stop people from asking "Perl 5.8.0 was supposed
24274		# to have this new fancy threads implementation but my
24275		# perl doesn't have it" and from people trying to
24276		# (re)install the threads module using CPAN.pm and
24277		# CPAN.pm then offering to reinstall Perl 5.8.0,
24278		# the threads.pm and threads/shared.pm will always be
24279		# there, croaking informatively ("you need to rebuild
24280		# all of Perl with threads, sorry") when threads haven't
24281		# been compiled in.
24282		# --jhi
24283		avail_ext="$avail_ext $xxx"
24284		;;
24285	VMS*)
24286		;;
24287	Win32*)
24288		case "$osname" in
24289		cygwin) avail_ext="$avail_ext $xxx" ;;
24290		esac
24291		;;
24292	XS/APItest|xs/apitest)
24293		# This is just for testing.  Skip it unless we have dynamic loading.
24294
24295		case "$usedl" in
24296		$define) avail_ext="$avail_ext $xxx" ;;
24297		esac
24298		;;
24299	XS/Typemap|xs/typemap)
24300		# This is just for testing.  Skip it unless we have dynamic loading.
24301		case "$usedl" in
24302		$define) avail_ext="$avail_ext $xxx" ;;
24303		esac
24304		;;
24305	*)	avail_ext="$avail_ext $xxx"
24306		;;
24307	esac
24308done
24309
24310set X $avail_ext
24311shift
24312avail_ext="$*"
24313
24314case "$onlyextensions" in
24315'') ;;
24316*)  keepextensions=''
24317    echo "You have requested that only certain extensions be included..." >&4
24318    for i in $onlyextensions; do
24319        case " $avail_ext " in
24320        *" $i "*)
24321            echo "Keeping extension $i."
24322            keepextensions="$keepextensions $i"
24323            ;;
24324        *) echo "Ignoring extension $i." ;;
24325        esac
24326    done
24327    avail_ext="$keepextensions"
24328    ;;
24329esac
24330
24331case "$noextensions" in
24332'') ;;
24333*)  keepextensions=''
24334    echo "You have requested that certain extensions be ignored..." >&4
24335    for i in $avail_ext; do
24336        case " $noextensions " in
24337        *" $i "*) echo "Ignoring extension $i." ;;
24338        *) echo "Keeping extension $i.";
24339           keepextensions="$keepextensions $i"
24340           ;;
24341        esac
24342    done
24343    avail_ext="$keepextensions"
24344    ;;
24345esac
24346
24347: Now see which nonxs extensions are supported on this system.
24348: For now assume all are.
24349nonxs_ext=''
24350for xxx in $nonxs_extensions ; do
24351	case "$xxx" in
24352	CVS|RCS|SCCS|.svn)
24353		;;
24354	VMS*)
24355		;;
24356	*)	nonxs_ext="$nonxs_ext $xxx"
24357		;;
24358	esac
24359done
24360
24361set X $nonxs_ext
24362shift
24363nonxs_ext="$*"
24364
24365case $usedl in
24366$define)
24367	$cat <<EOM
24368A number of extensions are supplied with $package.  You may choose to
24369compile these extensions for dynamic loading (the default), compile
24370them into the $package executable (static loading), or not include
24371them at all.  Answer "none" to include no extensions.
24372Note that DynaLoader is always built and need not be mentioned here.
24373
24374EOM
24375	case "$dynamic_ext" in
24376	'')
24377		: Exclude those listed in static_ext
24378		dflt=''
24379		for xxx in $avail_ext; do
24380			case " $static_ext " in
24381			*" $xxx "*) ;;
24382			*) dflt="$dflt $xxx" ;;
24383			esac
24384		done
24385		set X $dflt
24386		shift
24387		dflt="$*"
24388		;;
24389	*)	dflt="$dynamic_ext"
24390		# Perhaps we are reusing an old out-of-date config.sh.
24391		case "$hint" in
24392		previous)
24393			if test X"$dynamic_ext" != X"$avail_ext"; then
24394				$cat <<EOM
24395NOTICE:  Your previous config.sh list may be incorrect.
24396The extensions now available to you are
24397	${avail_ext}
24398but the default list from your previous config.sh is
24399	${dynamic_ext}
24400
24401EOM
24402			fi
24403			;;
24404		esac
24405		;;
24406	esac
24407	case "$dflt" in
24408	'')	dflt=none;;
24409	esac
24410	rp="What extensions do you wish to load dynamically?"
24411	. ./myread
24412	case "$ans" in
24413	none) dynamic_ext=' ' ;;
24414	*) dynamic_ext="$ans" ;;
24415	esac
24416
24417	case "$static_ext" in
24418	'')
24419		: Exclude those already listed in dynamic linking
24420		dflt=''
24421		for xxx in $avail_ext; do
24422			case " $dynamic_ext " in
24423			*" $xxx "*) ;;
24424			*) dflt="$dflt $xxx" ;;
24425			esac
24426		done
24427		set X $dflt
24428		shift
24429		dflt="$*"
24430		;;
24431	*)  dflt="$static_ext"
24432		;;
24433	esac
24434
24435	case "$dflt" in
24436	'')	dflt=none;;
24437	esac
24438	rp="What extensions do you wish to load statically?"
24439	. ./myread
24440	case "$ans" in
24441	none) static_ext=' ' ;;
24442	*) static_ext="$ans" ;;
24443	esac
24444	;;
24445*)
24446	$cat <<EOM
24447A number of extensions are supplied with $package.  Answer "none"
24448to include no extensions.
24449Note that DynaLoader is always built and need not be mentioned here.
24450
24451EOM
24452	case "$static_ext" in
24453	'') dflt="$avail_ext" ;;
24454	*)	dflt="$static_ext"
24455		# Perhaps we are reusing an old out-of-date config.sh.
24456		case "$hint" in
24457		previous)
24458			if test X"$static_ext" != X"$avail_ext"; then
24459				$cat <<EOM
24460NOTICE:  Your previous config.sh list may be incorrect.
24461The extensions now available to you are
24462	${avail_ext}
24463but the default list from your previous config.sh is
24464	${static_ext}
24465
24466EOM
24467			fi
24468			;;
24469		esac
24470		;;
24471	esac
24472	: Exclude those that are not xs extensions
24473	case "$dflt" in
24474	'')	dflt=none;;
24475	esac
24476	rp="What extensions do you wish to include?"
24477	. ./myread
24478	case "$ans" in
24479	none) static_ext=' ' ;;
24480	*) static_ext="$ans" ;;
24481	esac
24482	;;
24483esac
24484#
24485# Encode is a special case.  If we are building Encode as a static
24486# extension, we need to explicitly list its subextensions as well.
24487# For other nested extensions, this is handled automatically by
24488# the appropriate Makefile.PL.
24489case " $static_ext " in
24490	*" Encode "*) # Add the subextensions of Encode
24491	cd "$rsrc/cpan"
24492	for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
24493		static_ext="$static_ext Encode/$xxx"
24494		known_extensions="$known_extensions Encode/$xxx"
24495	done
24496	cd "$tdir"
24497	;;
24498esac
24499
24500set X $dynamic_ext $static_ext $nonxs_ext
24501shift
24502extensions="$*"
24503
24504# Sanity check:  We require an extension suitable for use with
24505# AnyDBM_File, as well as Fcntl and IO.  (Failure to have these
24506# should show up as failures in the test suite, but it's helpful to
24507# catch them now.) The 'extensions' list is normally sorted
24508# alphabetically, so we need to accept either
24509#    DB_File ... Fcntl ... IO  ....
24510# or something like
24511#    Fcntl ... NDBM_File ... IO  ....
24512case " $extensions"  in
24513*"_File "*" Fcntl "*" IO "*) ;; # DB_File
24514*" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
24515*" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
24516*) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
24517   echo "WARNING: The Perl you are building will be quite crippled." >&4
24518   ;;
24519esac
24520
24521: Remove libraries needed only for extensions
24522: The appropriate ext/Foo/Makefile.PL will add them back in, if necessary.
24523: The exception is SunOS 4.x, which needs them.
24524case "${osname}X${osvers}" in
24525sunos*X4*)
24526    perllibs="$libs"
24527    ;;
24528*) case "$usedl" in
24529    $define|true|[yY]*)
24530	    set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
24531	    shift
24532	    perllibs="$*"
24533	    ;;
24534    *)	perllibs="$libs"
24535	    ;;
24536    esac
24537    ;;
24538esac
24539
24540: Remove build directory name from cppstdin so it can be used from
24541: either the present location or the final installed location.
24542echo " "
24543: Get out of the UU directory to get correct path name.
24544cd ..
24545case "$cppstdin" in
24546`pwd`/cppstdin)
24547	echo "Stripping down cppstdin path name"
24548	cppstdin=cppstdin
24549	;;
24550esac
24551cd UU
24552
24553: end of configuration questions
24554echo " "
24555echo "End of configuration questions."
24556echo " "
24557
24558: back to where it started
24559if test -d ../UU; then
24560	cd ..
24561fi
24562
24563: configuration may be unconditionally patched via a 'config.arch' file
24564if $test -f config.arch; then
24565	echo "I see a config.arch file, loading it." >&4
24566	. ./config.arch
24567fi
24568
24569: configuration may be patched via a 'config.over' file
24570if $test -f config.over; then
24571	echo " "
24572	dflt=y
24573	rp='I see a config.over file.  Do you wish to load it?'
24574	. UU/myread
24575	case "$ans" in
24576	n*) echo "OK, I'll ignore it.";;
24577	*)	. ./config.over
24578		echo "Configuration override changes have been loaded."
24579		;;
24580	esac
24581fi
24582
24583: in case they want portability, strip down executable paths
24584case "$d_portable" in
24585"$define")
24586	echo " "
24587	echo "Stripping down executable paths..." >&4
24588	for file in $loclist $trylist; do
24589		eval temp=\$$file
24590		eval $file=`basename $temp`
24591	done
24592	;;
24593esac
24594
24595: create config.sh file
24596echo " "
24597echo "Creating config.sh..." >&4
24598$spitshell <<EOT >config.sh
24599$startsh
24600#
24601# This file was produced by running the Configure script. It holds all the
24602# definitions figured out by Configure. Should you modify one of these values,
24603# do not forget to propagate your changes by running "Configure -der". You may
24604# instead choose to run each of the .SH files by yourself, or "Configure -S".
24605#
24606
24607# Package name      : $package
24608# Source directory  : $src
24609# Configuration time: $cf_time
24610# Configured by     : $cf_by
24611# Target system     : $myuname
24612
24613EOT
24614: Add in command line options if available
24615$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
24616
24617$spitshell <<EOT >>config.sh
24618
24619Author='$Author'
24620Date='$Date'
24621Header='$Header'
24622Id='$Id'
24623Locker='$Locker'
24624Log='$Log'
24625RCSfile='$RCSfile'
24626Revision='$Revision'
24627Source='$Source'
24628State='$State'
24629_a='$_a'
24630_exe='$_exe'
24631_o='$_o'
24632afs='$afs'
24633afsroot='$afsroot'
24634alignbytes='$alignbytes'
24635aphostname='$aphostname'
24636api_revision='$api_revision'
24637api_subversion='$api_subversion'
24638api_version='$api_version'
24639api_versionstring='$api_versionstring'
24640ar='$ar'
24641archlib='$archlib'
24642archlibexp='$archlibexp'
24643archname64='$archname64'
24644archname='$archname'
24645archobjs='$archobjs'
24646asctime_r_proto='$asctime_r_proto'
24647awk='$awk'
24648baserev='$baserev'
24649bash='$bash'
24650bin='$bin'
24651bin_ELF='$bin_ELF'
24652binexp='$binexp'
24653bison='$bison'
24654byacc='$byacc'
24655byteorder='$byteorder'
24656c='$c'
24657castflags='$castflags'
24658cat='$cat'
24659cc='$cc'
24660cccdlflags='$cccdlflags'
24661ccdlflags='$ccdlflags'
24662ccflags='$ccflags'
24663ccflags_uselargefiles='$ccflags_uselargefiles'
24664ccname='$ccname'
24665ccsymbols='$ccsymbols'
24666ccversion='$ccversion'
24667cf_by='$cf_by'
24668cf_email='$cf_email'
24669cf_time='$cf_time'
24670charbits='$charbits'
24671charsize='$charsize'
24672chgrp='$chgrp'
24673chmod='$chmod'
24674chown='$chown'
24675clocktype='$clocktype'
24676comm='$comm'
24677compiler_warning='$compiler_warning'
24678compress='$compress'
24679contains='$contains'
24680cp='$cp'
24681cpio='$cpio'
24682cpp='$cpp'
24683cpp_stuff='$cpp_stuff'
24684cppccsymbols='$cppccsymbols'
24685cppflags='$cppflags'
24686cpplast='$cpplast'
24687cppminus='$cppminus'
24688cpprun='$cpprun'
24689cppstdin='$cppstdin'
24690cppsymbols='$cppsymbols'
24691crypt_r_proto='$crypt_r_proto'
24692cryptlib='$cryptlib'
24693csh='$csh'
24694ctermid_r_proto='$ctermid_r_proto'
24695ctime_r_proto='$ctime_r_proto'
24696d_Gconvert='$d_Gconvert'
24697d_PRIEUldbl='$d_PRIEUldbl'
24698d_PRIFUldbl='$d_PRIFUldbl'
24699d_PRIGUldbl='$d_PRIGUldbl'
24700d_PRIXU64='$d_PRIXU64'
24701d_PRId64='$d_PRId64'
24702d_PRIeldbl='$d_PRIeldbl'
24703d_PRIfldbl='$d_PRIfldbl'
24704d_PRIgldbl='$d_PRIgldbl'
24705d_PRIi64='$d_PRIi64'
24706d_PRIo64='$d_PRIo64'
24707d_PRIu64='$d_PRIu64'
24708d_PRIx64='$d_PRIx64'
24709d_SCNfldbl='$d_SCNfldbl'
24710d__fwalk='$d__fwalk'
24711d_accept4='$d_accept4'
24712d_access='$d_access'
24713d_accessx='$d_accessx'
24714d_acosh='$d_acosh'
24715d_aintl='$d_aintl'
24716d_alarm='$d_alarm'
24717d_archlib='$d_archlib'
24718d_asctime64='$d_asctime64'
24719d_asctime_r='$d_asctime_r'
24720d_asinh='$d_asinh'
24721d_atanh='$d_atanh'
24722d_atolf='$d_atolf'
24723d_atoll='$d_atoll'
24724d_attribute_always_inline='$d_attribute_always_inline'
24725d_attribute_deprecated='$d_attribute_deprecated'
24726d_attribute_format='$d_attribute_format'
24727d_attribute_malloc='$d_attribute_malloc'
24728d_attribute_nonnull='$d_attribute_nonnull'
24729d_attribute_noreturn='$d_attribute_noreturn'
24730d_attribute_pure='$d_attribute_pure'
24731d_attribute_unused='$d_attribute_unused'
24732d_attribute_visibility='$d_attribute_visibility'
24733d_attribute_warn_unused_result='$d_attribute_warn_unused_result'
24734d_backtrace='$d_backtrace'
24735d_bsd='$d_bsd'
24736d_bsdgetpgrp='$d_bsdgetpgrp'
24737d_bsdsetpgrp='$d_bsdsetpgrp'
24738d_builtin_add_overflow='$d_builtin_add_overflow'
24739d_builtin_choose_expr='$d_builtin_choose_expr'
24740d_builtin_expect='$d_builtin_expect'
24741d_builtin_mul_overflow='$d_builtin_mul_overflow'
24742d_builtin_sub_overflow='$d_builtin_sub_overflow'
24743d_c99_variadic_macros='$d_c99_variadic_macros'
24744d_casti32='$d_casti32'
24745d_castneg='$d_castneg'
24746d_cbrt='$d_cbrt'
24747d_chown='$d_chown'
24748d_chroot='$d_chroot'
24749d_chsize='$d_chsize'
24750d_class='$d_class'
24751d_clearenv='$d_clearenv'
24752d_closedir='$d_closedir'
24753d_cmsghdr_s='$d_cmsghdr_s'
24754d_copysign='$d_copysign'
24755d_copysignl='$d_copysignl'
24756d_cplusplus='$d_cplusplus'
24757d_crypt='$d_crypt'
24758d_crypt_r='$d_crypt_r'
24759d_csh='$d_csh'
24760d_ctermid='$d_ctermid'
24761d_ctermid_r='$d_ctermid_r'
24762d_ctime64='$d_ctime64'
24763d_ctime_r='$d_ctime_r'
24764d_cuserid='$d_cuserid'
24765d_dbminitproto='$d_dbminitproto'
24766d_difftime64='$d_difftime64'
24767d_difftime='$d_difftime'
24768d_dir_dd_fd='$d_dir_dd_fd'
24769d_dirfd='$d_dirfd'
24770d_dirnamlen='$d_dirnamlen'
24771d_dladdr='$d_dladdr'
24772d_dlerror='$d_dlerror'
24773d_dlopen='$d_dlopen'
24774d_dlsymun='$d_dlsymun'
24775d_dosuid='$d_dosuid'
24776d_double_has_inf='$d_double_has_inf'
24777d_double_has_nan='$d_double_has_nan'
24778d_double_has_negative_zero='$d_double_has_negative_zero'
24779d_double_has_subnormals='$d_double_has_subnormals'
24780d_double_style_cray='$d_double_style_cray'
24781d_double_style_ibm='$d_double_style_ibm'
24782d_double_style_ieee='$d_double_style_ieee'
24783d_double_style_vax='$d_double_style_vax'
24784d_drand48_r='$d_drand48_r'
24785d_drand48proto='$d_drand48proto'
24786d_dup2='$d_dup2'
24787d_dup3='$d_dup3'
24788d_duplocale='$d_duplocale'
24789d_eaccess='$d_eaccess'
24790d_endgrent='$d_endgrent'
24791d_endgrent_r='$d_endgrent_r'
24792d_endhent='$d_endhent'
24793d_endhostent_r='$d_endhostent_r'
24794d_endnent='$d_endnent'
24795d_endnetent_r='$d_endnetent_r'
24796d_endpent='$d_endpent'
24797d_endprotoent_r='$d_endprotoent_r'
24798d_endpwent='$d_endpwent'
24799d_endpwent_r='$d_endpwent_r'
24800d_endsent='$d_endsent'
24801d_endservent_r='$d_endservent_r'
24802d_eofnblk='$d_eofnblk'
24803d_erf='$d_erf'
24804d_erfc='$d_erfc'
24805d_eunice='$d_eunice'
24806d_exp2='$d_exp2'
24807d_expm1='$d_expm1'
24808d_faststdio='$d_faststdio'
24809d_fchdir='$d_fchdir'
24810d_fchmod='$d_fchmod'
24811d_fchmodat='$d_fchmodat'
24812d_fchown='$d_fchown'
24813d_fcntl='$d_fcntl'
24814d_fcntl_can_lock='$d_fcntl_can_lock'
24815d_fd_macros='$d_fd_macros'
24816d_fd_set='$d_fd_set'
24817d_fdclose='$d_fdclose'
24818d_fdim='$d_fdim'
24819d_fds_bits='$d_fds_bits'
24820d_fegetround='$d_fegetround'
24821d_ffs='$d_ffs'
24822d_ffsl='$d_ffsl'
24823d_fgetpos='$d_fgetpos'
24824d_finite='$d_finite'
24825d_finitel='$d_finitel'
24826d_flexfnam='$d_flexfnam'
24827d_flock='$d_flock'
24828d_flockproto='$d_flockproto'
24829d_fma='$d_fma'
24830d_fmax='$d_fmax'
24831d_fmin='$d_fmin'
24832d_fork='$d_fork'
24833d_fp_class='$d_fp_class'
24834d_fp_classify='$d_fp_classify'
24835d_fp_classl='$d_fp_classl'
24836d_fpathconf='$d_fpathconf'
24837d_fpclass='$d_fpclass'
24838d_fpclassify='$d_fpclassify'
24839d_fpclassl='$d_fpclassl'
24840d_fpgetround='$d_fpgetround'
24841d_fpos64_t='$d_fpos64_t'
24842d_freelocale='$d_freelocale'
24843d_frexpl='$d_frexpl'
24844d_fs_data_s='$d_fs_data_s'
24845d_fseeko='$d_fseeko'
24846d_fsetpos='$d_fsetpos'
24847d_fstatfs='$d_fstatfs'
24848d_fstatvfs='$d_fstatvfs'
24849d_fsync='$d_fsync'
24850d_ftello='$d_ftello'
24851d_ftime='$d_ftime'
24852d_futimes='$d_futimes'
24853d_gai_strerror='$d_gai_strerror'
24854d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
24855d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
24856d_getaddrinfo='$d_getaddrinfo'
24857d_getcwd='$d_getcwd'
24858d_getenv_preserves_other_thread='$d_getenv_preserves_other_thread'
24859d_getespwnam='$d_getespwnam'
24860d_getfsstat='$d_getfsstat'
24861d_getgrent='$d_getgrent'
24862d_getgrent_r='$d_getgrent_r'
24863d_getgrgid_r='$d_getgrgid_r'
24864d_getgrnam_r='$d_getgrnam_r'
24865d_getgrps='$d_getgrps'
24866d_gethbyaddr='$d_gethbyaddr'
24867d_gethbyname='$d_gethbyname'
24868d_gethent='$d_gethent'
24869d_gethname='$d_gethname'
24870d_gethostbyaddr_r='$d_gethostbyaddr_r'
24871d_gethostbyname_r='$d_gethostbyname_r'
24872d_gethostent_r='$d_gethostent_r'
24873d_gethostprotos='$d_gethostprotos'
24874d_getitimer='$d_getitimer'
24875d_getlogin='$d_getlogin'
24876d_getlogin_r='$d_getlogin_r'
24877d_getmnt='$d_getmnt'
24878d_getmntent='$d_getmntent'
24879d_getnameinfo='$d_getnameinfo'
24880d_getnbyaddr='$d_getnbyaddr'
24881d_getnbyname='$d_getnbyname'
24882d_getnent='$d_getnent'
24883d_getnetbyaddr_r='$d_getnetbyaddr_r'
24884d_getnetbyname_r='$d_getnetbyname_r'
24885d_getnetent_r='$d_getnetent_r'
24886d_getnetprotos='$d_getnetprotos'
24887d_getpagsz='$d_getpagsz'
24888d_getpbyname='$d_getpbyname'
24889d_getpbynumber='$d_getpbynumber'
24890d_getpent='$d_getpent'
24891d_getpgid='$d_getpgid'
24892d_getpgrp2='$d_getpgrp2'
24893d_getpgrp='$d_getpgrp'
24894d_getppid='$d_getppid'
24895d_getprior='$d_getprior'
24896d_getprotobyname_r='$d_getprotobyname_r'
24897d_getprotobynumber_r='$d_getprotobynumber_r'
24898d_getprotoent_r='$d_getprotoent_r'
24899d_getprotoprotos='$d_getprotoprotos'
24900d_getprpwnam='$d_getprpwnam'
24901d_getpwent='$d_getpwent'
24902d_getpwent_r='$d_getpwent_r'
24903d_getpwnam_r='$d_getpwnam_r'
24904d_getpwuid_r='$d_getpwuid_r'
24905d_getsbyname='$d_getsbyname'
24906d_getsbyport='$d_getsbyport'
24907d_getsent='$d_getsent'
24908d_getservbyname_r='$d_getservbyname_r'
24909d_getservbyport_r='$d_getservbyport_r'
24910d_getservent_r='$d_getservent_r'
24911d_getservprotos='$d_getservprotos'
24912d_getspnam='$d_getspnam'
24913d_getspnam_r='$d_getspnam_r'
24914d_gettimeod='$d_gettimeod'
24915d_gmtime64='$d_gmtime64'
24916d_gmtime_r='$d_gmtime_r'
24917d_gnulibc='$d_gnulibc'
24918d_grpasswd='$d_grpasswd'
24919d_has_C_UTF8='$d_has_C_UTF8'
24920d_hasmntopt='$d_hasmntopt'
24921d_htonl='$d_htonl'
24922d_hypot='$d_hypot'
24923d_ilogb='$d_ilogb'
24924d_ilogbl='$d_ilogbl'
24925d_inc_version_list='$d_inc_version_list'
24926d_inetaton='$d_inetaton'
24927d_inetntop='$d_inetntop'
24928d_inetpton='$d_inetpton'
24929d_int64_t='$d_int64_t'
24930d_ip_mreq='$d_ip_mreq'
24931d_ip_mreq_source='$d_ip_mreq_source'
24932d_ipv6_mreq='$d_ipv6_mreq'
24933d_ipv6_mreq_source='$d_ipv6_mreq_source'
24934d_isascii='$d_isascii'
24935d_isblank='$d_isblank'
24936d_isfinite='$d_isfinite'
24937d_isfinitel='$d_isfinitel'
24938d_isinf='$d_isinf'
24939d_isinfl='$d_isinfl'
24940d_isless='$d_isless'
24941d_isnan='$d_isnan'
24942d_isnanl='$d_isnanl'
24943d_isnormal='$d_isnormal'
24944d_j0='$d_j0'
24945d_j0l='$d_j0l'
24946d_killpg='$d_killpg'
24947d_lc_monetary_2008='$d_lc_monetary_2008'
24948d_lchown='$d_lchown'
24949d_ldbl_dig='$d_ldbl_dig'
24950d_ldexpl='$d_ldexpl'
24951d_lgamma='$d_lgamma'
24952d_lgamma_r='$d_lgamma_r'
24953d_libm_lib_version='$d_libm_lib_version'
24954d_libname_unique='$d_libname_unique'
24955d_link='$d_link'
24956d_linkat='$d_linkat'
24957d_llrint='$d_llrint'
24958d_llrintl='$d_llrintl'
24959d_llround='$d_llround'
24960d_llroundl='$d_llroundl'
24961d_localeconv_l='$d_localeconv_l'
24962d_localtime64='$d_localtime64'
24963d_localtime_r='$d_localtime_r'
24964d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
24965d_locconv='$d_locconv'
24966d_lockf='$d_lockf'
24967d_log1p='$d_log1p'
24968d_log2='$d_log2'
24969d_logb='$d_logb'
24970d_long_double_style_ieee='$d_long_double_style_ieee'
24971d_long_double_style_ieee_doubledouble='$d_long_double_style_ieee_doubledouble'
24972d_long_double_style_ieee_extended='$d_long_double_style_ieee_extended'
24973d_long_double_style_ieee_std='$d_long_double_style_ieee_std'
24974d_long_double_style_vax='$d_long_double_style_vax'
24975d_longdbl='$d_longdbl'
24976d_longlong='$d_longlong'
24977d_lrint='$d_lrint'
24978d_lrintl='$d_lrintl'
24979d_lround='$d_lround'
24980d_lroundl='$d_lroundl'
24981d_lseekproto='$d_lseekproto'
24982d_lstat='$d_lstat'
24983d_madvise='$d_madvise'
24984d_malloc_good_size='$d_malloc_good_size'
24985d_malloc_size='$d_malloc_size'
24986d_malloc_usable_size='$d_malloc_usable_size'
24987d_mblen='$d_mblen'
24988d_mbrlen='$d_mbrlen'
24989d_mbrtowc='$d_mbrtowc'
24990d_mbstowcs='$d_mbstowcs'
24991d_mbtowc='$d_mbtowc'
24992d_memmem='$d_memmem'
24993d_memrchr='$d_memrchr'
24994d_mkdir='$d_mkdir'
24995d_mkdtemp='$d_mkdtemp'
24996d_mkfifo='$d_mkfifo'
24997d_mkostemp='$d_mkostemp'
24998d_mkstemp='$d_mkstemp'
24999d_mkstemps='$d_mkstemps'
25000d_mktime64='$d_mktime64'
25001d_mktime='$d_mktime'
25002d_mmap='$d_mmap'
25003d_modfl='$d_modfl'
25004d_modflproto='$d_modflproto'
25005d_mprotect='$d_mprotect'
25006d_msg='$d_msg'
25007d_msg_ctrunc='$d_msg_ctrunc'
25008d_msg_dontroute='$d_msg_dontroute'
25009d_msg_oob='$d_msg_oob'
25010d_msg_peek='$d_msg_peek'
25011d_msg_proxy='$d_msg_proxy'
25012d_msgctl='$d_msgctl'
25013d_msgget='$d_msgget'
25014d_msghdr_s='$d_msghdr_s'
25015d_msgrcv='$d_msgrcv'
25016d_msgsnd='$d_msgsnd'
25017d_msync='$d_msync'
25018d_munmap='$d_munmap'
25019d_mymalloc='$d_mymalloc'
25020d_nan='$d_nan'
25021d_nanosleep='$d_nanosleep'
25022d_ndbm='$d_ndbm'
25023d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
25024d_nearbyint='$d_nearbyint'
25025d_newlocale='$d_newlocale'
25026d_nextafter='$d_nextafter'
25027d_nexttoward='$d_nexttoward'
25028d_nice='$d_nice'
25029d_nl_langinfo='$d_nl_langinfo'
25030d_nl_langinfo_l='$d_nl_langinfo_l'
25031d_non_int_bitfields='$d_non_int_bitfields'
25032d_nv_preserves_uv='$d_nv_preserves_uv'
25033d_nv_zero_is_allbits_zero='$d_nv_zero_is_allbits_zero'
25034d_off64_t='$d_off64_t'
25035d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
25036d_oldpthreads='$d_oldpthreads'
25037d_oldsock='$d_oldsock'
25038d_open3='$d_open3'
25039d_openat='$d_openat'
25040d_pathconf='$d_pathconf'
25041d_pause='$d_pause'
25042d_perl_otherlibdirs='$d_perl_otherlibdirs'
25043d_phostname='$d_phostname'
25044d_pipe2='$d_pipe2'
25045d_pipe='$d_pipe'
25046d_poll='$d_poll'
25047d_portable='$d_portable'
25048d_prctl='$d_prctl'
25049d_prctl_set_name='$d_prctl_set_name'
25050d_printf_format_null='$d_printf_format_null'
25051d_procselfexe='$d_procselfexe'
25052d_pseudofork='$d_pseudofork'
25053d_pthread_atfork='$d_pthread_atfork'
25054d_pthread_attr_setscope='$d_pthread_attr_setscope'
25055d_pthread_yield='$d_pthread_yield'
25056d_ptrdiff_t='$d_ptrdiff_t'
25057d_pwage='$d_pwage'
25058d_pwchange='$d_pwchange'
25059d_pwclass='$d_pwclass'
25060d_pwcomment='$d_pwcomment'
25061d_pwexpire='$d_pwexpire'
25062d_pwgecos='$d_pwgecos'
25063d_pwpasswd='$d_pwpasswd'
25064d_pwquota='$d_pwquota'
25065d_qgcvt='$d_qgcvt'
25066d_quad='$d_quad'
25067d_querylocale='$d_querylocale'
25068d_random_r='$d_random_r'
25069d_re_comp='$d_re_comp'
25070d_readdir64_r='$d_readdir64_r'
25071d_readdir='$d_readdir'
25072d_readdir_r='$d_readdir_r'
25073d_readlink='$d_readlink'
25074d_readv='$d_readv'
25075d_recvmsg='$d_recvmsg'
25076d_regcmp='$d_regcmp'
25077d_regcomp='$d_regcomp'
25078d_remainder='$d_remainder'
25079d_remquo='$d_remquo'
25080d_rename='$d_rename'
25081d_renameat='$d_renameat'
25082d_rewinddir='$d_rewinddir'
25083d_rint='$d_rint'
25084d_rmdir='$d_rmdir'
25085d_round='$d_round'
25086d_sbrkproto='$d_sbrkproto'
25087d_scalbn='$d_scalbn'
25088d_scalbnl='$d_scalbnl'
25089d_sched_yield='$d_sched_yield'
25090d_scm_rights='$d_scm_rights'
25091d_seekdir='$d_seekdir'
25092d_select='$d_select'
25093d_sem='$d_sem'
25094d_semctl='$d_semctl'
25095d_semctl_semid_ds='$d_semctl_semid_ds'
25096d_semctl_semun='$d_semctl_semun'
25097d_semget='$d_semget'
25098d_semop='$d_semop'
25099d_sendmsg='$d_sendmsg'
25100d_setegid='$d_setegid'
25101d_setenv='$d_setenv'
25102d_seteuid='$d_seteuid'
25103d_setgrent='$d_setgrent'
25104d_setgrent_r='$d_setgrent_r'
25105d_setgrps='$d_setgrps'
25106d_sethent='$d_sethent'
25107d_sethostent_r='$d_sethostent_r'
25108d_setitimer='$d_setitimer'
25109d_setlinebuf='$d_setlinebuf'
25110d_setlocale='$d_setlocale'
25111d_setlocale_accepts_any_locale_name='$d_setlocale_accepts_any_locale_name'
25112d_setlocale_r='$d_setlocale_r'
25113d_setnent='$d_setnent'
25114d_setnetent_r='$d_setnetent_r'
25115d_setpent='$d_setpent'
25116d_setpgid='$d_setpgid'
25117d_setpgrp2='$d_setpgrp2'
25118d_setpgrp='$d_setpgrp'
25119d_setprior='$d_setprior'
25120d_setproctitle='$d_setproctitle'
25121d_setprotoent_r='$d_setprotoent_r'
25122d_setpwent='$d_setpwent'
25123d_setpwent_r='$d_setpwent_r'
25124d_setregid='$d_setregid'
25125d_setresgid='$d_setresgid'
25126d_setresuid='$d_setresuid'
25127d_setreuid='$d_setreuid'
25128d_setrgid='$d_setrgid'
25129d_setruid='$d_setruid'
25130d_setsent='$d_setsent'
25131d_setservent_r='$d_setservent_r'
25132d_setsid='$d_setsid'
25133d_setvbuf='$d_setvbuf'
25134d_shm='$d_shm'
25135d_shmat='$d_shmat'
25136d_shmatprototype='$d_shmatprototype'
25137d_shmctl='$d_shmctl'
25138d_shmdt='$d_shmdt'
25139d_shmget='$d_shmget'
25140d_sigaction='$d_sigaction'
25141d_siginfo_si_addr='$d_siginfo_si_addr'
25142d_siginfo_si_band='$d_siginfo_si_band'
25143d_siginfo_si_errno='$d_siginfo_si_errno'
25144d_siginfo_si_fd='$d_siginfo_si_fd'
25145d_siginfo_si_pid='$d_siginfo_si_pid'
25146d_siginfo_si_status='$d_siginfo_si_status'
25147d_siginfo_si_uid='$d_siginfo_si_uid'
25148d_siginfo_si_value='$d_siginfo_si_value'
25149d_signbit='$d_signbit'
25150d_sigprocmask='$d_sigprocmask'
25151d_sigsetjmp='$d_sigsetjmp'
25152d_sin6_scope_id='$d_sin6_scope_id'
25153d_sitearch='$d_sitearch'
25154d_snprintf='$d_snprintf'
25155d_sockaddr_in6='$d_sockaddr_in6'
25156d_sockaddr_sa_len='$d_sockaddr_sa_len'
25157d_sockaddr_storage='$d_sockaddr_storage'
25158d_sockatmark='$d_sockatmark'
25159d_sockatmarkproto='$d_sockatmarkproto'
25160d_socket='$d_socket'
25161d_socklen_t='$d_socklen_t'
25162d_sockpair='$d_sockpair'
25163d_socks5_init='$d_socks5_init'
25164d_sqrtl='$d_sqrtl'
25165d_srand48_r='$d_srand48_r'
25166d_srandom_r='$d_srandom_r'
25167d_sresgproto='$d_sresgproto'
25168d_sresuproto='$d_sresuproto'
25169d_stat='$d_stat'
25170d_statblks='$d_statblks'
25171d_statfs_f_flags='$d_statfs_f_flags'
25172d_statfs_s='$d_statfs_s'
25173d_static_inline='$d_static_inline'
25174d_statvfs='$d_statvfs'
25175d_stdio_cnt_lval='$d_stdio_cnt_lval'
25176d_stdio_ptr_lval='$d_stdio_ptr_lval'
25177d_stdio_ptr_lval_nochange_cnt='$d_stdio_ptr_lval_nochange_cnt'
25178d_stdio_ptr_lval_sets_cnt='$d_stdio_ptr_lval_sets_cnt'
25179d_stdio_stream_array='$d_stdio_stream_array'
25180d_stdiobase='$d_stdiobase'
25181d_stdstdio='$d_stdstdio'
25182d_strcoll='$d_strcoll'
25183d_strerror_l='$d_strerror_l'
25184d_strerror_r='$d_strerror_r'
25185d_strftime='$d_strftime'
25186d_strlcat='$d_strlcat'
25187d_strlcpy='$d_strlcpy'
25188d_strnlen='$d_strnlen'
25189d_strtod='$d_strtod'
25190d_strtod_l='$d_strtod_l'
25191d_strtol='$d_strtol'
25192d_strtold='$d_strtold'
25193d_strtold_l='$d_strtold_l'
25194d_strtoll='$d_strtoll'
25195d_strtoq='$d_strtoq'
25196d_strtoul='$d_strtoul'
25197d_strtoull='$d_strtoull'
25198d_strtouq='$d_strtouq'
25199d_strxfrm='$d_strxfrm'
25200d_strxfrm_l='$d_strxfrm_l'
25201d_suidsafe='$d_suidsafe'
25202d_symlink='$d_symlink'
25203d_syscall='$d_syscall'
25204d_syscallproto='$d_syscallproto'
25205d_sysconf='$d_sysconf'
25206d_sysernlst='$d_sysernlst'
25207d_syserrlst='$d_syserrlst'
25208d_system='$d_system'
25209d_tcgetpgrp='$d_tcgetpgrp'
25210d_tcsetpgrp='$d_tcsetpgrp'
25211d_telldir='$d_telldir'
25212d_telldirproto='$d_telldirproto'
25213d_tgamma='$d_tgamma'
25214d_thread_local='$d_thread_local'
25215d_thread_safe_nl_langinfo_l='$d_thread_safe_nl_langinfo_l'
25216d_time='$d_time'
25217d_timegm='$d_timegm'
25218d_times='$d_times'
25219d_tm_tm_gmtoff='$d_tm_tm_gmtoff'
25220d_tm_tm_zone='$d_tm_tm_zone'
25221d_tmpnam_r='$d_tmpnam_r'
25222d_towlower='$d_towlower'
25223d_towupper='$d_towupper'
25224d_trunc='$d_trunc'
25225d_truncate='$d_truncate'
25226d_truncl='$d_truncl'
25227d_ttyname_r='$d_ttyname_r'
25228d_tzname='$d_tzname'
25229d_u32align='$d_u32align'
25230d_ualarm='$d_ualarm'
25231d_umask='$d_umask'
25232d_uname='$d_uname'
25233d_union_semun='$d_union_semun'
25234d_unlinkat='$d_unlinkat'
25235d_unordered='$d_unordered'
25236d_unsetenv='$d_unsetenv'
25237d_uselocale='$d_uselocale'
25238d_usleep='$d_usleep'
25239d_usleepproto='$d_usleepproto'
25240d_ustat='$d_ustat'
25241d_vendorarch='$d_vendorarch'
25242d_vendorbin='$d_vendorbin'
25243d_vendorlib='$d_vendorlib'
25244d_vendorscript='$d_vendorscript'
25245d_vfork='$d_vfork'
25246d_void_closedir='$d_void_closedir'
25247d_voidsig='$d_voidsig'
25248d_voidtty='$d_voidtty'
25249d_vsnprintf='$d_vsnprintf'
25250d_wait4='$d_wait4'
25251d_waitpid='$d_waitpid'
25252d_wcrtomb='$d_wcrtomb'
25253d_wcscmp='$d_wcscmp'
25254d_wcstombs='$d_wcstombs'
25255d_wcsxfrm='$d_wcsxfrm'
25256d_wctomb='$d_wctomb'
25257d_writev='$d_writev'
25258d_xenix='$d_xenix'
25259date='$date'
25260db_hashtype='$db_hashtype'
25261db_prefixtype='$db_prefixtype'
25262db_version_major='$db_version_major'
25263db_version_minor='$db_version_minor'
25264db_version_patch='$db_version_patch'
25265default_inc_excludes_dot='$default_inc_excludes_dot'
25266direntrytype='$direntrytype'
25267dlext='$dlext'
25268dlsrc='$dlsrc'
25269doubleinfbytes='$doubleinfbytes'
25270doublekind='$doublekind'
25271doublemantbits='$doublemantbits'
25272doublenanbytes='$doublenanbytes'
25273doublesize='$doublesize'
25274drand01='$drand01'
25275drand48_r_proto='$drand48_r_proto'
25276dtrace='$dtrace'
25277dtraceobject='$dtraceobject'
25278dtracexnolibs='$dtracexnolibs'
25279dynamic_ext='$dynamic_ext'
25280eagain='$eagain'
25281ebcdic='$ebcdic'
25282echo='$echo'
25283egrep='$egrep'
25284emacs='$emacs'
25285endgrent_r_proto='$endgrent_r_proto'
25286endhostent_r_proto='$endhostent_r_proto'
25287endnetent_r_proto='$endnetent_r_proto'
25288endprotoent_r_proto='$endprotoent_r_proto'
25289endpwent_r_proto='$endpwent_r_proto'
25290endservent_r_proto='$endservent_r_proto'
25291eunicefix='$eunicefix'
25292exe_ext='$exe_ext'
25293expr='$expr'
25294extensions='$extensions'
25295extern_C='$extern_C'
25296extras='$extras'
25297fflushNULL='$fflushNULL'
25298fflushall='$fflushall'
25299find='$find'
25300firstmakefile='$firstmakefile'
25301flex='$flex'
25302fpossize='$fpossize'
25303fpostype='$fpostype'
25304freetype='$freetype'
25305from='$from'
25306full_ar='$full_ar'
25307full_csh='$full_csh'
25308full_sed='$full_sed'
25309gccansipedantic='$gccansipedantic'
25310gccosandvers='$gccosandvers'
25311gccversion='$gccversion'
25312getgrent_r_proto='$getgrent_r_proto'
25313getgrgid_r_proto='$getgrgid_r_proto'
25314getgrnam_r_proto='$getgrnam_r_proto'
25315gethostbyaddr_r_proto='$gethostbyaddr_r_proto'
25316gethostbyname_r_proto='$gethostbyname_r_proto'
25317gethostent_r_proto='$gethostent_r_proto'
25318getlogin_r_proto='$getlogin_r_proto'
25319getnetbyaddr_r_proto='$getnetbyaddr_r_proto'
25320getnetbyname_r_proto='$getnetbyname_r_proto'
25321getnetent_r_proto='$getnetent_r_proto'
25322getprotobyname_r_proto='$getprotobyname_r_proto'
25323getprotobynumber_r_proto='$getprotobynumber_r_proto'
25324getprotoent_r_proto='$getprotoent_r_proto'
25325getpwent_r_proto='$getpwent_r_proto'
25326getpwnam_r_proto='$getpwnam_r_proto'
25327getpwuid_r_proto='$getpwuid_r_proto'
25328getservbyname_r_proto='$getservbyname_r_proto'
25329getservbyport_r_proto='$getservbyport_r_proto'
25330getservent_r_proto='$getservent_r_proto'
25331getspnam_r_proto='$getspnam_r_proto'
25332gidformat='$gidformat'
25333gidsign='$gidsign'
25334gidsize='$gidsize'
25335gidtype='$gidtype'
25336glibpth='$glibpth'
25337gmake='$gmake'
25338gmtime_r_proto='$gmtime_r_proto'
25339gnulibc_version='$gnulibc_version'
25340grep='$grep'
25341groupcat='$groupcat'
25342groupstype='$groupstype'
25343gzip='$gzip'
25344h_fcntl='$h_fcntl'
25345h_sysfile='$h_sysfile'
25346hint='$hint'
25347hostcat='$hostcat'
25348hostgenerate='$hostgenerate'
25349hostosname='$hostosname'
25350hostperl='$hostperl'
25351html1dir='$html1dir'
25352html1direxp='$html1direxp'
25353html3dir='$html3dir'
25354html3direxp='$html3direxp'
25355i16size='$i16size'
25356i16type='$i16type'
25357i32dformat='$i32dformat'
25358i32size='$i32size'
25359i32type='$i32type'
25360i64size='$i64size'
25361i64type='$i64type'
25362i8size='$i8size'
25363i8type='$i8type'
25364i_arpainet='$i_arpainet'
25365i_bfd='$i_bfd'
25366i_bsdioctl='$i_bsdioctl'
25367i_crypt='$i_crypt'
25368i_db='$i_db'
25369i_dbm='$i_dbm'
25370i_dirent='$i_dirent'
25371i_dlfcn='$i_dlfcn'
25372i_execinfo='$i_execinfo'
25373i_fcntl='$i_fcntl'
25374i_fenv='$i_fenv'
25375i_fp='$i_fp'
25376i_fp_class='$i_fp_class'
25377i_gdbm='$i_gdbm'
25378i_gdbm_ndbm='$i_gdbm_ndbm'
25379i_gdbmndbm='$i_gdbmndbm'
25380i_grp='$i_grp'
25381i_ieeefp='$i_ieeefp'
25382i_inttypes='$i_inttypes'
25383i_langinfo='$i_langinfo'
25384i_libutil='$i_libutil'
25385i_locale='$i_locale'
25386i_machcthr='$i_machcthr'
25387i_malloc='$i_malloc'
25388i_mallocmalloc='$i_mallocmalloc'
25389i_mntent='$i_mntent'
25390i_ndbm='$i_ndbm'
25391i_netdb='$i_netdb'
25392i_neterrno='$i_neterrno'
25393i_netinettcp='$i_netinettcp'
25394i_niin='$i_niin'
25395i_poll='$i_poll'
25396i_prot='$i_prot'
25397i_pthread='$i_pthread'
25398i_pwd='$i_pwd'
25399i_quadmath='$i_quadmath'
25400i_rpcsvcdbm='$i_rpcsvcdbm'
25401i_sgtty='$i_sgtty'
25402i_shadow='$i_shadow'
25403i_socks='$i_socks'
25404i_stdbool='$i_stdbool'
25405i_stdint='$i_stdint'
25406i_stdlib='$i_stdlib'
25407i_sunmath='$i_sunmath'
25408i_sysaccess='$i_sysaccess'
25409i_sysdir='$i_sysdir'
25410i_sysfile='$i_sysfile'
25411i_sysfilio='$i_sysfilio'
25412i_sysin='$i_sysin'
25413i_sysioctl='$i_sysioctl'
25414i_syslog='$i_syslog'
25415i_sysmman='$i_sysmman'
25416i_sysmode='$i_sysmode'
25417i_sysmount='$i_sysmount'
25418i_sysndir='$i_sysndir'
25419i_sysparam='$i_sysparam'
25420i_syspoll='$i_syspoll'
25421i_sysresrc='$i_sysresrc'
25422i_syssecrt='$i_syssecrt'
25423i_sysselct='$i_sysselct'
25424i_syssockio='$i_syssockio'
25425i_sysstat='$i_sysstat'
25426i_sysstatfs='$i_sysstatfs'
25427i_sysstatvfs='$i_sysstatvfs'
25428i_syssyscall='$i_syssyscall'
25429i_systime='$i_systime'
25430i_systimek='$i_systimek'
25431i_systimes='$i_systimes'
25432i_systypes='$i_systypes'
25433i_sysuio='$i_sysuio'
25434i_sysun='$i_sysun'
25435i_sysutsname='$i_sysutsname'
25436i_sysvfs='$i_sysvfs'
25437i_syswait='$i_syswait'
25438i_termio='$i_termio'
25439i_termios='$i_termios'
25440i_time='$i_time'
25441i_unistd='$i_unistd'
25442i_ustat='$i_ustat'
25443i_utime='$i_utime'
25444i_vfork='$i_vfork'
25445i_wchar='$i_wchar'
25446i_wctype='$i_wctype'
25447i_xlocale='$i_xlocale'
25448ignore_versioned_solibs='$ignore_versioned_solibs'
25449inc_version_list='$inc_version_list'
25450inc_version_list_init='$inc_version_list_init'
25451incpath='$incpath'
25452incpth='$incpth'
25453inews='$inews'
25454initialinstalllocation='$initialinstalllocation'
25455installarchlib='$installarchlib'
25456installbin='$installbin'
25457installhtml1dir='$installhtml1dir'
25458installhtml3dir='$installhtml3dir'
25459installman1dir='$installman1dir'
25460installman3dir='$installman3dir'
25461installprefix='$installprefix'
25462installprefixexp='$installprefixexp'
25463installprivlib='$installprivlib'
25464installscript='$installscript'
25465installsitearch='$installsitearch'
25466installsitebin='$installsitebin'
25467installsitehtml1dir='$installsitehtml1dir'
25468installsitehtml3dir='$installsitehtml3dir'
25469installsitelib='$installsitelib'
25470installsiteman1dir='$installsiteman1dir'
25471installsiteman3dir='$installsiteman3dir'
25472installsitescript='$installsitescript'
25473installstyle='$installstyle'
25474installusrbinperl='$installusrbinperl'
25475installvendorarch='$installvendorarch'
25476installvendorbin='$installvendorbin'
25477installvendorhtml1dir='$installvendorhtml1dir'
25478installvendorhtml3dir='$installvendorhtml3dir'
25479installvendorlib='$installvendorlib'
25480installvendorman1dir='$installvendorman1dir'
25481installvendorman3dir='$installvendorman3dir'
25482installvendorscript='$installvendorscript'
25483intsize='$intsize'
25484issymlink='$issymlink'
25485ivdformat='$ivdformat'
25486ivsize='$ivsize'
25487ivtype='$ivtype'
25488known_extensions='$known_extensions'
25489ksh='$ksh'
25490ld='$ld'
25491ld_can_script='$ld_can_script'
25492lddlflags='$lddlflags'
25493ldflags='$ldflags'
25494ldflags_uselargefiles='$ldflags_uselargefiles'
25495ldlibpthname='$ldlibpthname'
25496less='$less'
25497lib_ext='$lib_ext'
25498libc='$libc'
25499libperl='$libperl'
25500libpth='$libpth'
25501libs='$libs'
25502libsdirs='$libsdirs'
25503libsfiles='$libsfiles'
25504libsfound='$libsfound'
25505libspath='$libspath'
25506libswanted='$libswanted'
25507libswanted_uselargefiles='$libswanted_uselargefiles'
25508line='$line'
25509lint='$lint'
25510lkflags='$lkflags'
25511ln='$ln'
25512lns='$lns'
25513localtime_r_proto='$localtime_r_proto'
25514locincpth='$locincpth'
25515loclibpth='$loclibpth'
25516longdblinfbytes='$longdblinfbytes'
25517longdblkind='$longdblkind'
25518longdblmantbits='$longdblmantbits'
25519longdblnanbytes='$longdblnanbytes'
25520longdblsize='$longdblsize'
25521longlongsize='$longlongsize'
25522longsize='$longsize'
25523lp='$lp'
25524lpr='$lpr'
25525ls='$ls'
25526lseeksize='$lseeksize'
25527lseektype='$lseektype'
25528mail='$mail'
25529mailx='$mailx'
25530make='$make'
25531make_set_make='$make_set_make'
25532mallocobj='$mallocobj'
25533mallocsrc='$mallocsrc'
25534malloctype='$malloctype'
25535man1dir='$man1dir'
25536man1direxp='$man1direxp'
25537man1ext='$man1ext'
25538man3dir='$man3dir'
25539man3direxp='$man3direxp'
25540man3ext='$man3ext'
25541mips_type='$mips_type'
25542mistrustnm='$mistrustnm'
25543mkdir='$mkdir'
25544mmaptype='$mmaptype'
25545modetype='$modetype'
25546more='$more'
25547multiarch='$multiarch'
25548mv='$mv'
25549myarchname='$myarchname'
25550mydomain='$mydomain'
25551myhostname='$myhostname'
25552myuname='$myuname'
25553n='$n'
25554need_va_copy='$need_va_copy'
25555netdb_hlen_type='$netdb_hlen_type'
25556netdb_host_type='$netdb_host_type'
25557netdb_name_type='$netdb_name_type'
25558netdb_net_type='$netdb_net_type'
25559nm='$nm'
25560nm_opt='$nm_opt'
25561nm_so_opt='$nm_so_opt'
25562nonxs_ext='$nonxs_ext'
25563nroff='$nroff'
25564nvEUformat='$nvEUformat'
25565nvFUformat='$nvFUformat'
25566nvGUformat='$nvGUformat'
25567nv_overflows_integers_at='$nv_overflows_integers_at'
25568nv_preserves_uv_bits='$nv_preserves_uv_bits'
25569nveformat='$nveformat'
25570nvfformat='$nvfformat'
25571nvgformat='$nvgformat'
25572nvmantbits='$nvmantbits'
25573nvsize='$nvsize'
25574nvtype='$nvtype'
25575o_nonblock='$o_nonblock'
25576obj_ext='$obj_ext'
25577old_pthread_create_joinable='$old_pthread_create_joinable'
25578optimize='$optimize'
25579orderlib='$orderlib'
25580osname='$osname'
25581osvers='$osvers'
25582otherlibdirs='$otherlibdirs'
25583package='$package'
25584pager='$pager'
25585passcat='$passcat'
25586patchlevel='$patchlevel'
25587path_sep='$path_sep'
25588perl5='$perl5'
25589perl='$perl'
25590perl_patchlevel='$perl_patchlevel'
25591perl_static_inline='$perl_static_inline'
25592perl_thread_local='$perl_thread_local'
25593perladmin='$perladmin'
25594perllibs='$perllibs'
25595perlpath='$perlpath'
25596pg='$pg'
25597phostname='$phostname'
25598pidtype='$pidtype'
25599plibpth='$plibpth'
25600pmake='$pmake'
25601pr='$pr'
25602prefix='$prefix'
25603prefixexp='$prefixexp'
25604privlib='$privlib'
25605privlibexp='$privlibexp'
25606procselfexe='$procselfexe'
25607ptrsize='$ptrsize'
25608quadkind='$quadkind'
25609quadtype='$quadtype'
25610randbits='$randbits'
25611randfunc='$randfunc'
25612random_r_proto='$random_r_proto'
25613randseedtype='$randseedtype'
25614ranlib='$ranlib'
25615rd_nodata='$rd_nodata'
25616readdir64_r_proto='$readdir64_r_proto'
25617readdir_r_proto='$readdir_r_proto'
25618revision='$revision'
25619rm='$rm'
25620rm_try='$rm_try'
25621rmail='$rmail'
25622run='$run'
25623runnm='$runnm'
25624sGMTIME_max='$sGMTIME_max'
25625sGMTIME_min='$sGMTIME_min'
25626sLOCALTIME_max='$sLOCALTIME_max'
25627sLOCALTIME_min='$sLOCALTIME_min'
25628sPRIEUldbl='$sPRIEUldbl'
25629sPRIFUldbl='$sPRIFUldbl'
25630sPRIGUldbl='$sPRIGUldbl'
25631sPRIXU64='$sPRIXU64'
25632sPRId64='$sPRId64'
25633sPRIeldbl='$sPRIeldbl'
25634sPRIfldbl='$sPRIfldbl'
25635sPRIgldbl='$sPRIgldbl'
25636sPRIi64='$sPRIi64'
25637sPRIo64='$sPRIo64'
25638sPRIu64='$sPRIu64'
25639sPRIx64='$sPRIx64'
25640sSCNfldbl='$sSCNfldbl'
25641sched_yield='$sched_yield'
25642scriptdir='$scriptdir'
25643scriptdirexp='$scriptdirexp'
25644sed='$sed'
25645seedfunc='$seedfunc'
25646selectminbits='$selectminbits'
25647selecttype='$selecttype'
25648sendmail='$sendmail'
25649setgrent_r_proto='$setgrent_r_proto'
25650sethostent_r_proto='$sethostent_r_proto'
25651setlocale_r_proto='$setlocale_r_proto'
25652setnetent_r_proto='$setnetent_r_proto'
25653setprotoent_r_proto='$setprotoent_r_proto'
25654setpwent_r_proto='$setpwent_r_proto'
25655setservent_r_proto='$setservent_r_proto'
25656sh='$sh'
25657shar='$shar'
25658sharpbang='$sharpbang'
25659shmattype='$shmattype'
25660shortsize='$shortsize'
25661shrpenv='$shrpenv'
25662shsharp='$shsharp'
25663sig_count='$sig_count'
25664sig_name='$sig_name'
25665sig_name_init='$sig_name_init'
25666sig_num='$sig_num'
25667sig_num_init='$sig_num_init'
25668sig_size='$sig_size'
25669signal_t='$signal_t'
25670sitearch='$sitearch'
25671sitearchexp='$sitearchexp'
25672sitebin='$sitebin'
25673sitebinexp='$sitebinexp'
25674sitehtml1dir='$sitehtml1dir'
25675sitehtml1direxp='$sitehtml1direxp'
25676sitehtml3dir='$sitehtml3dir'
25677sitehtml3direxp='$sitehtml3direxp'
25678sitelib='$sitelib'
25679sitelib_stem='$sitelib_stem'
25680sitelibexp='$sitelibexp'
25681siteman1dir='$siteman1dir'
25682siteman1direxp='$siteman1direxp'
25683siteman3dir='$siteman3dir'
25684siteman3direxp='$siteman3direxp'
25685siteprefix='$siteprefix'
25686siteprefixexp='$siteprefixexp'
25687sitescript='$sitescript'
25688sitescriptexp='$sitescriptexp'
25689sizesize='$sizesize'
25690sizetype='$sizetype'
25691sleep='$sleep'
25692smail='$smail'
25693so='$so'
25694sockethdr='$sockethdr'
25695socketlib='$socketlib'
25696socksizetype='$socksizetype'
25697sort='$sort'
25698spackage='$spackage'
25699spitshell='$spitshell'
25700srand48_r_proto='$srand48_r_proto'
25701srandom_r_proto='$srandom_r_proto'
25702src='$src'
25703ssizetype='$ssizetype'
25704st_dev_sign='$st_dev_sign'
25705st_dev_size='$st_dev_size'
25706st_ino_sign='$st_ino_sign'
25707st_ino_size='$st_ino_size'
25708startperl='$startperl'
25709startsh='$startsh'
25710static_ext='$static_ext'
25711stdchar='$stdchar'
25712stdio_base='$stdio_base'
25713stdio_bufsiz='$stdio_bufsiz'
25714stdio_cnt='$stdio_cnt'
25715stdio_filbuf='$stdio_filbuf'
25716stdio_ptr='$stdio_ptr'
25717stdio_stream_array='$stdio_stream_array'
25718strerror_r_proto='$strerror_r_proto'
25719submit='$submit'
25720subversion='$subversion'
25721sysman='$sysman'
25722sysroot='$sysroot'
25723tail='$tail'
25724tar='$tar'
25725targetarch='$targetarch'
25726targetdir='$targetdir'
25727targetenv='$targetenv'
25728targethost='$targethost'
25729targetmkdir='$targetmkdir'
25730targetport='$targetport'
25731targetsh='$targetsh'
25732tbl='$tbl'
25733tee='$tee'
25734test='$test'
25735timeincl='$timeincl'
25736timetype='$timetype'
25737tmpnam_r_proto='$tmpnam_r_proto'
25738to='$to'
25739touch='$touch'
25740tr='$tr'
25741trnl='$trnl'
25742troff='$troff'
25743ttyname_r_proto='$ttyname_r_proto'
25744u16size='$u16size'
25745u16type='$u16type'
25746u32XUformat='$u32XUformat'
25747u32oformat='$u32oformat'
25748u32size='$u32size'
25749u32type='$u32type'
25750u32uformat='$u32uformat'
25751u32xformat='$u32xformat'
25752u64size='$u64size'
25753u64type='$u64type'
25754u8size='$u8size'
25755u8type='$u8type'
25756uidformat='$uidformat'
25757uidsign='$uidsign'
25758uidsize='$uidsize'
25759uidtype='$uidtype'
25760uname='$uname'
25761uniq='$uniq'
25762uquadtype='$uquadtype'
25763use64bitall='$use64bitall'
25764use64bitint='$use64bitint'
25765usecbacktrace='$usecbacktrace'
25766usecrosscompile='$usecrosscompile'
25767usedefaultstrict='$usedefaultstrict'
25768usedevel='$usedevel'
25769usedl='$usedl'
25770usedtrace='$usedtrace'
25771usefaststdio='$usefaststdio'
25772useithreads='$useithreads'
25773usekernprocpathname='$usekernprocpathname'
25774uselanginfo='$uselanginfo'
25775uselargefiles='$uselargefiles'
25776uselongdouble='$uselongdouble'
25777usemallocwrap='$usemallocwrap'
25778usemorebits='$usemorebits'
25779usemultiplicity='$usemultiplicity'
25780usemymalloc='$usemymalloc'
25781usenm='$usenm'
25782usensgetexecutablepath='$usensgetexecutablepath'
25783useopcode='$useopcode'
25784useperlio='$useperlio'
25785useposix='$useposix'
25786usequadmath='$usequadmath'
25787usereentrant='$usereentrant'
25788userelocatableinc='$userelocatableinc'
25789useshrplib='$useshrplib'
25790usesitecustomize='$usesitecustomize'
25791usesocks='$usesocks'
25792usethreads='$usethreads'
25793usevendorprefix='$usevendorprefix'
25794useversionedarchname='$useversionedarchname'
25795usevfork='$usevfork'
25796usrinc='$usrinc'
25797uuname='$uuname'
25798uvXUformat='$uvXUformat'
25799uvoformat='$uvoformat'
25800uvsize='$uvsize'
25801uvtype='$uvtype'
25802uvuformat='$uvuformat'
25803uvxformat='$uvxformat'
25804vendorarch='$vendorarch'
25805vendorarchexp='$vendorarchexp'
25806vendorbin='$vendorbin'
25807vendorbinexp='$vendorbinexp'
25808vendorhtml1dir='$vendorhtml1dir'
25809vendorhtml1direxp='$vendorhtml1direxp'
25810vendorhtml3dir='$vendorhtml3dir'
25811vendorhtml3direxp='$vendorhtml3direxp'
25812vendorlib='$vendorlib'
25813vendorlib_stem='$vendorlib_stem'
25814vendorlibexp='$vendorlibexp'
25815vendorman1dir='$vendorman1dir'
25816vendorman1direxp='$vendorman1direxp'
25817vendorman3dir='$vendorman3dir'
25818vendorman3direxp='$vendorman3direxp'
25819vendorprefix='$vendorprefix'
25820vendorprefixexp='$vendorprefixexp'
25821vendorscript='$vendorscript'
25822vendorscriptexp='$vendorscriptexp'
25823version='$version'
25824version_patchlevel_string='$version_patchlevel_string'
25825versiononly='$versiononly'
25826vi='$vi'
25827xlibpth='$xlibpth'
25828xlocale_needed='$xlocale_needed'
25829yacc='$yacc'
25830yaccflags='$yaccflags'
25831zcat='$zcat'
25832zip='$zip'
25833EOT
25834
25835: add special variables
25836$test -f $src/patchlevel.h && \
25837awk '/^#define[ 	]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
25838echo "PERL_PATCHLEVEL='$perl_patchlevel'" >>config.sh
25839echo "PERL_CONFIG_SH=true" >>config.sh
25840
25841: propagate old symbols
25842if $test -f UU/config.sh; then
25843	<UU/config.sh $sort | $uniq >UU/oldconfig.sh
25844	$sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' \
25845		config.sh config.sh UU/oldconfig.sh |\
25846		$sort | $uniq -u >UU/oldsyms
25847	set X `$cat UU/oldsyms`
25848	shift
25849	case $# in
25850	0) ;;
25851	*)
25852		$cat <<EOM
25853Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
25854EOM
25855		echo ": Variables propagated from previous config.sh file." >>config.sh
25856		for sym in `$cat UU/oldsyms`; do
25857			echo "    Propagating $hint variable "'$'"$sym..."
25858			eval 'tmp="$'"${sym}"'"'
25859			echo "$tmp" | \
25860				sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
25861		done
25862		;;
25863	esac
25864fi
25865
25866: preserve RCS keywords in files with variable substitution, grrr
25867Id='$Id'
25868
25869: Finish up by extracting the .SH files
25870case "$alldone" in
25871exit)
25872	echo "Stopping at your request, leaving temporary files around."
25873	exit 0
25874	;;
25875cont)
25876	;;
25877'')
25878	dflt=''
25879	nostick=true
25880	$cat <<EOM
25881
25882If you'd like to make any changes to the config.sh file before I begin
25883to configure things, do it as a shell escape now (e.g. !vi config.sh).
25884
25885EOM
25886	rp="Press return or use a shell escape to edit config.sh:"
25887	. UU/myread
25888	nostick=''
25889	case "$ans" in
25890	'') ;;
25891	*) : in case they cannot read
25892		sh 1>&4 -c "$ans";;
25893	esac
25894	;;
25895esac
25896
25897: if this fails, just run all the .SH files by hand
25898. ./config.sh
25899
25900echo " "
25901exec 1>&4
25902pwd=`pwd`
25903. ./UU/extract
25904cd "$pwd"
25905
25906if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
25907	dflt=y
25908	case "$silent" in
25909	true) ;;
25910	*)
25911		$cat <<EOM
25912
25913Now you need to generate make dependencies by running "$make depend".
25914You might prefer to run it in background: "$make depend > makedepend.out &"
25915It can take a while, so you might not want to run it right now.
25916
25917EOM
25918		;;
25919	esac
25920	rp="Run $make depend now?"
25921	. UU/myread
25922	case "$ans" in
25923	y*)
25924		$make depend && echo "Now you must run '$make'."
25925		;;
25926	*)
25927		echo "You must run '$make depend' then '$make'."
25928		;;
25929	esac
25930elif test -f [Mm]akefile; then
25931	echo " "
25932	echo "Now you must run a $make."
25933else
25934	echo "Configure done."
25935fi
25936
25937if $test -f Policy.sh; then
25938    $cat <<EOM
25939
25940If you compile $package on a different machine or from a different object
25941directory, copy the Policy.sh file from this object directory to the
25942new one before you run Configure -- this will help you with most of
25943the policy defaults.
25944
25945EOM
25946fi
25947if $test -f UU/config.msg; then
25948    echo "Hmm.  I also noted the following information while running:"
25949    echo " "
25950    $cat UU/config.msg >&4
25951fi
25952$rm -f kit*isdone ark*isdone
25953$rm -rf UU
25954
25955: End of Configure
25956
25957