xref: /openbsd-src/gnu/usr.bin/perl/Configure (revision fc405d53b73a2d73393cb97f684863d17b583e38)
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_warn_unused_result=''
395d_printf_format_null=''
396d_backtrace=''
397d_non_int_bitfields=''
398d_builtin_choose_expr=''
399d_builtin_expect=''
400d_builtin_add_overflow=''
401d_builtin_mul_overflow=''
402d_builtin_sub_overflow=''
403d_c99_variadic_macros=''
404d_casti32=''
405castflags=''
406d_castneg=''
407d_cbrt=''
408d_chown=''
409d_chroot=''
410d_chsize=''
411d_class=''
412d_clearenv=''
413d_closedir=''
414d_void_closedir=''
415d_cmsghdr_s=''
416d_copysign=''
417d_copysignl=''
418d_cplusplus=''
419cryptlib=''
420d_crypt=''
421crypt_r_proto=''
422d_crypt_r=''
423d_csh=''
424full_csh=''
425d_ctermid=''
426ctermid_r_proto=''
427d_ctermid_r=''
428ctime_r_proto=''
429d_ctime_r=''
430d_cuserid=''
431d_dbminitproto=''
432d_difftime=''
433d_dir_dd_fd=''
434d_dirfd=''
435d_dladdr=''
436d_dlerror=''
437d_dlopen=''
438d_dlsymun=''
439d_dosuid=''
440d_suidsafe=''
441d_drand48_r=''
442drand48_r_proto=''
443d_drand48proto=''
444d_dup2=''
445d_dup3=''
446d_eaccess=''
447d_endgrent=''
448d_endgrent_r=''
449endgrent_r_proto=''
450d_endhent=''
451d_endhostent_r=''
452endhostent_r_proto=''
453d_endnent=''
454d_endnetent_r=''
455endnetent_r_proto=''
456d_endpent=''
457d_endprotoent_r=''
458endprotoent_r_proto=''
459d_endpwent=''
460d_endpwent_r=''
461endpwent_r_proto=''
462d_endsent=''
463d_endservent_r=''
464endservent_r_proto=''
465d_erf=''
466d_erfc=''
467d_exp2=''
468d_expm1=''
469d_faststdio=''
470d_fchdir=''
471d_fchmod=''
472d_fchown=''
473d_fcntl=''
474d_fcntl_can_lock=''
475d_fd_macros=''
476d_fd_set=''
477d_fds_bits=''
478d_fdclose=''
479d_fdim=''
480d_fegetround=''
481d_ffs=''
482d_ffsl=''
483d_fgetpos=''
484d_finite=''
485d_finitel=''
486d_flexfnam=''
487d_flock=''
488d_flockproto=''
489d_fma=''
490d_fmax=''
491d_fmin=''
492d_fork=''
493d_fp_class=''
494d_fp_classl=''
495d_fpclass=''
496d_fp_classify=''
497d_fpclassify=''
498d_fpclassl=''
499d_fpgetround=''
500d_fpos64_t=''
501d_frexpl=''
502d_fs_data_s=''
503d_fchmodat=''
504d_linkat=''
505d_openat=''
506d_renameat=''
507d_unlinkat=''
508d_fseeko=''
509d_fsetpos=''
510d_fstatfs=''
511d_fsync=''
512d_ftello=''
513d_ftime=''
514d_gettimeod=''
515d_futimes=''
516d_gai_strerror=''
517d_Gconvert=''
518d_getaddrinfo=''
519d_getcwd=''
520d_getenv_preserves_other_thread=''
521d_getespwnam=''
522d_getfsstat=''
523d_getgrent=''
524d_getgrent_r=''
525getgrent_r_proto=''
526d_getgrgid_r=''
527getgrgid_r_proto=''
528d_getgrnam_r=''
529getgrnam_r_proto=''
530d_getgrps=''
531d_gethbyaddr=''
532d_gethbyname=''
533d_gethent=''
534aphostname=''
535d_gethname=''
536d_phostname=''
537d_uname=''
538d_gethostbyaddr_r=''
539gethostbyaddr_r_proto=''
540d_gethostbyname_r=''
541gethostbyname_r_proto=''
542d_gethostent_r=''
543gethostent_r_proto=''
544d_gethostprotos=''
545d_getitimer=''
546d_getlogin=''
547d_getlogin_r=''
548getlogin_r_proto=''
549d_getmnt=''
550d_getmntent=''
551d_getnameinfo=''
552d_getnbyaddr=''
553d_getnbyname=''
554d_getnent=''
555d_getnetbyaddr_r=''
556getnetbyaddr_r_proto=''
557d_getnetbyname_r=''
558getnetbyname_r_proto=''
559d_getnetent_r=''
560getnetent_r_proto=''
561d_getnetprotos=''
562d_getpagsz=''
563d_getpent=''
564d_getpgid=''
565d_getpgrp2=''
566d_bsdgetpgrp=''
567d_getpgrp=''
568d_getppid=''
569d_getprior=''
570d_getpbyname=''
571d_getpbynumber=''
572d_getprotobyname_r=''
573getprotobyname_r_proto=''
574d_getprotobynumber_r=''
575getprotobynumber_r_proto=''
576d_getprotoent_r=''
577getprotoent_r_proto=''
578d_getprotoprotos=''
579d_getprpwnam=''
580d_getpwent=''
581d_getpwent_r=''
582getpwent_r_proto=''
583d_getpwnam_r=''
584getpwnam_r_proto=''
585d_getpwuid_r=''
586getpwuid_r_proto=''
587d_getsent=''
588d_getservbyname_r=''
589getservbyname_r_proto=''
590d_getservbyport_r=''
591getservbyport_r_proto=''
592d_getservent_r=''
593getservent_r_proto=''
594d_getservprotos=''
595d_getspnam=''
596d_getspnam_r=''
597getspnam_r_proto=''
598d_getsbyname=''
599d_getsbyport=''
600d_gmtime_r=''
601gmtime_r_proto=''
602d_gnulibc=''
603gnulibc_version=''
604d_hasmntopt=''
605d_htonl=''
606d_hypot=''
607d_ilogb=''
608d_ilogbl=''
609d_inetaton=''
610d_inetntop=''
611d_inetpton=''
612d_int64_t=''
613d_isascii=''
614d_isblank=''
615d_isfinite=''
616d_isfinitel=''
617d_isinf=''
618d_isinfl=''
619d_isless=''
620d_isnan=''
621d_isnanl=''
622d_isnormal=''
623d_j0=''
624d_j0l=''
625d_killpg=''
626d_lc_monetary_2008=''
627d_lchown=''
628d_ldbl_dig=''
629d_lgamma=''
630d_lgamma_r=''
631d_libm_lib_version=''
632d_link=''
633d_llrint=''
634d_llrintl=''
635d_llround=''
636d_llroundl=''
637d_localeconv_l=''
638d_localtime_r=''
639d_localtime_r_needs_tzset=''
640localtime_r_proto=''
641d_locconv=''
642d_lockf=''
643d_log1p=''
644d_log2=''
645d_logb=''
646d_ldexpl=''
647d_long_double_style_ieee=''
648d_long_double_style_ieee_doubledouble=''
649d_long_double_style_ieee_extended=''
650d_long_double_style_ieee_std=''
651d_long_double_style_vax=''
652d_longdbl=''
653longdblkind=''
654longdblsize=''
655d_longlong=''
656longlongsize=''
657d_lrint=''
658d_lrintl=''
659d_lround=''
660d_lroundl=''
661d_lseekproto=''
662d_lstat=''
663d_madvise=''
664d_malloc_good_size=''
665d_malloc_size=''
666d_malloc_usable_size=''
667d_mblen=''
668d_mbrlen=''
669d_mbrtowc=''
670d_mbstowcs=''
671d_mbtowc=''
672d_memmem=''
673d_memrchr=''
674d_mkdir=''
675d_mkdtemp=''
676d_mkfifo=''
677d_mkostemp=''
678d_mkstemp=''
679d_mkstemps=''
680d_mktime=''
681d_mmap=''
682mmaptype=''
683d_modfl=''
684d_modflproto=''
685d_mprotect=''
686d_msg=''
687d_msgctl=''
688d_msgget=''
689d_msghdr_s=''
690d_msgrcv=''
691d_msgsnd=''
692d_msync=''
693d_munmap=''
694d_nan=''
695d_nanosleep=''
696d_nearbyint=''
697d_duplocale=''
698d_freelocale=''
699d_newlocale=''
700d_querylocale=''
701d_uselocale=''
702i_xlocale=''
703xlocale_needed=''
704d_nextafter=''
705d_nexttoward=''
706d_nice=''
707d_nl_langinfo=''
708d_nl_langinfo_l=''
709d_thread_safe_nl_langinfo_l=''
710d_off64_t=''
711d_open3=''
712d_fpathconf=''
713d_pathconf=''
714d_pause=''
715d_pipe2=''
716d_pipe=''
717d_poll=''
718d_portable=''
719d_prctl=''
720d_prctl_set_name=''
721d_procselfexe=''
722procselfexe=''
723d_old_pthread_create_joinable=''
724old_pthread_create_joinable=''
725d_pthread_atfork=''
726d_pthread_attr_setscope=''
727d_pthread_yield=''
728d_sched_yield=''
729sched_yield=''
730d_ptrdiff_t=''
731d_qgcvt=''
732d_random_r=''
733random_r_proto=''
734d_readdir64_r=''
735readdir64_r_proto=''
736d_readdir=''
737d_rewinddir=''
738d_seekdir=''
739d_telldir=''
740d_readdir_r=''
741readdir_r_proto=''
742d_readlink=''
743d_readv=''
744d_recvmsg=''
745d_re_comp=''
746d_regcmp=''
747d_regcomp=''
748d_remainder=''
749d_remquo=''
750d_rename=''
751d_rint=''
752d_rmdir=''
753d_round=''
754d_sbrkproto=''
755d_scalbn=''
756d_scalbnl=''
757d_select=''
758d_sem=''
759d_semctl=''
760d_semget=''
761d_semop=''
762d_sendmsg=''
763d_setegid=''
764d_seteuid=''
765d_setgrent=''
766d_setgrent_r=''
767setgrent_r_proto=''
768d_setgrps=''
769d_sethent=''
770d_sethostent_r=''
771sethostent_r_proto=''
772d_setitimer=''
773d_setlinebuf=''
774d_has_C_UTF8=''
775d_setlocale=''
776d_setlocale_accepts_any_locale_name=''
777d_setlocale_r=''
778setlocale_r_proto=''
779d_setnent=''
780d_setnetent_r=''
781setnetent_r_proto=''
782d_setpent=''
783d_setpgid=''
784d_setpgrp2=''
785d_bsdsetpgrp=''
786d_setpgrp=''
787d_setprior=''
788d_setproctitle=''
789d_setprotoent_r=''
790setprotoent_r_proto=''
791d_setpwent=''
792d_setpwent_r=''
793setpwent_r_proto=''
794d_setregid=''
795d_setresgid=''
796d_setresuid=''
797d_setreuid=''
798d_setrgid=''
799d_setruid=''
800d_setsent=''
801d_setservent_r=''
802setservent_r_proto=''
803d_setsid=''
804d_setvbuf=''
805d_shm=''
806d_shmat=''
807d_shmatprototype=''
808shmattype=''
809d_shmctl=''
810d_shmdt=''
811d_shmget=''
812d_sigaction=''
813d_siginfo_si_addr=''
814d_siginfo_si_band=''
815d_siginfo_si_errno=''
816d_siginfo_si_fd=''
817d_siginfo_si_pid=''
818d_siginfo_si_status=''
819d_siginfo_si_uid=''
820d_siginfo_si_value=''
821d_signbit=''
822d_sigprocmask=''
823d_sigsetjmp=''
824usesitecustomize=''
825d_snprintf=''
826d_vsnprintf=''
827d_sockatmark=''
828d_sockatmarkproto=''
829d_ip_mreq=''
830d_ip_mreq_source=''
831d_ipv6_mreq=''
832d_ipv6_mreq_source=''
833d_msg_ctrunc=''
834d_msg_dontroute=''
835d_msg_oob=''
836d_msg_peek=''
837d_msg_proxy=''
838d_oldsock=''
839d_scm_rights=''
840d_sin6_scope_id=''
841d_sockaddr_in6=''
842d_sockaddr_sa_len=''
843d_sockaddr_storage=''
844d_socket=''
845d_sockpair=''
846sockethdr=''
847socketlib=''
848d_socklen_t=''
849d_socks5_init=''
850d_sqrtl=''
851d_srand48_r=''
852srand48_r_proto=''
853d_srandom_r=''
854srandom_r_proto=''
855d_sresgproto=''
856d_sresuproto=''
857d_stat=''
858d_statblks=''
859d_statfs_f_flags=''
860d_statfs_s=''
861d_static_inline=''
862perl_static_inline=''
863d_fstatvfs=''
864d_statvfs=''
865d_stdio_cnt_lval=''
866d_stdio_ptr_lval=''
867d_stdio_ptr_lval_nochange_cnt=''
868d_stdio_ptr_lval_sets_cnt=''
869d_stdiobase=''
870d_stdstdio=''
871stdio_base=''
872stdio_bufsiz=''
873stdio_cnt=''
874stdio_filbuf=''
875stdio_ptr=''
876d_strcoll=''
877d_sysernlst=''
878d_syserrlst=''
879d_strerror_l=''
880d_strerror_r=''
881strerror_r_proto=''
882d_strftime=''
883d_strlcat=''
884d_strlcpy=''
885d_strnlen=''
886d_strtod=''
887d_strtod_l=''
888d_strtol=''
889d_strtold=''
890d_strtold_l=''
891d_strtoll=''
892d_strtoq=''
893d_strtoul=''
894d_strtoull=''
895d_strtouq=''
896d_strxfrm=''
897d_strxfrm_l=''
898d_symlink=''
899d_syscall=''
900d_syscallproto=''
901d_sysconf=''
902d_system=''
903d_tcgetpgrp=''
904d_tcsetpgrp=''
905d_telldirproto=''
906d_tgamma=''
907d_thread_local=''
908perl_thread_local=''
909d_time=''
910timetype=''
911d_asctime64=''
912d_ctime64=''
913d_difftime64=''
914d_gmtime64=''
915d_localtime64=''
916d_mktime64=''
917d_timegm=''
918clocktype=''
919d_times=''
920d_tmpnam_r=''
921tmpnam_r_proto=''
922d_towlower=''
923d_towupper=''
924d_trunc=''
925d_truncate=''
926d_truncl=''
927d_ttyname_r=''
928ttyname_r_proto=''
929d_tzname=''
930d_u32align=''
931d_ualarm=''
932d_umask=''
933d_semctl_semid_ds=''
934d_semctl_semun=''
935d_union_semun=''
936d_unordered=''
937d_unsetenv=''
938d_usleep=''
939d_usleepproto=''
940d_ustat=''
941d_pseudofork=''
942d_vfork=''
943usevfork=''
944d_voidsig=''
945signal_t=''
946d_wait4=''
947d_waitpid=''
948d_wcrtomb=''
949d_wcscmp=''
950d_wcstombs=''
951d_wcsxfrm=''
952d_wctomb=''
953d_writev=''
954default_inc_excludes_dot=''
955dlext=''
956bin_ELF=''
957cccdlflags=''
958ccdlflags=''
959dlsrc=''
960ld=''
961ld_can_script=''
962lddlflags=''
963usedl=''
964doublesize=''
965dtraceobject=''
966dtracexnolibs=''
967ebcdic=''
968fflushNULL=''
969fflushall=''
970fpossize=''
971fpostype=''
972gccansipedantic=''
973gccosandvers=''
974gccversion=''
975gidformat=''
976gidsign=''
977gidsize=''
978gidtype=''
979groupstype=''
980h_fcntl=''
981h_sysfile=''
982html1dir=''
983html1direxp=''
984installhtml1dir=''
985html3dir=''
986html3direxp=''
987installhtml3dir=''
988i_arpainet=''
989i_bfd=''
990i_crypt=''
991db_hashtype=''
992db_prefixtype=''
993db_version_major=''
994db_version_minor=''
995db_version_patch=''
996i_db=''
997i_dbm=''
998i_rpcsvcdbm=''
999d_dirnamlen=''
1000direntrytype=''
1001i_dirent=''
1002i_dlfcn=''
1003i_execinfo=''
1004i_fcntl=''
1005i_fenv=''
1006i_fp=''
1007i_fp_class=''
1008i_gdbm=''
1009d_grpasswd=''
1010i_grp=''
1011i_ieeefp=''
1012i_inttypes=''
1013i_langinfo=''
1014i_libutil=''
1015i_locale=''
1016i_machcthr=''
1017i_malloc=''
1018i_mallocmalloc=''
1019i_mntent=''
1020d_gdbm_ndbm_h_uses_prototypes=''
1021d_gdbmndbm_h_uses_prototypes=''
1022d_ndbm=''
1023d_ndbm_h_uses_prototypes=''
1024i_gdbm_ndbm=''
1025i_gdbmndbm=''
1026i_ndbm=''
1027i_netdb=''
1028i_neterrno=''
1029i_netinettcp=''
1030i_niin=''
1031i_sysin=''
1032i_poll=''
1033i_prot=''
1034i_pthread=''
1035d_pwage=''
1036d_pwchange=''
1037d_pwclass=''
1038d_pwcomment=''
1039d_pwexpire=''
1040d_pwgecos=''
1041d_pwpasswd=''
1042d_pwquota=''
1043i_pwd=''
1044i_quadmath=''
1045i_shadow=''
1046i_socks=''
1047i_stdbool=''
1048i_stdint=''
1049i_stdlib=''
1050i_sunmath=''
1051i_sysaccess=''
1052i_sysdir=''
1053i_sysfile=''
1054d_voidtty=''
1055i_bsdioctl=''
1056i_sysfilio=''
1057i_sysioctl=''
1058i_syssockio=''
1059i_syslog=''
1060i_sysmman=''
1061i_sysmode=''
1062i_sysmount=''
1063i_sysndir=''
1064i_sysparam=''
1065i_syspoll=''
1066i_sysresrc=''
1067i_syssecrt=''
1068i_sysselct=''
1069i_sysstat=''
1070i_sysstatfs=''
1071i_sysstatvfs=''
1072i_systimes=''
1073i_systypes=''
1074i_sysuio=''
1075i_sysun=''
1076i_sysutsname=''
1077i_sysvfs=''
1078i_syswait=''
1079i_sgtty=''
1080i_termio=''
1081i_termios=''
1082d_tm_tm_gmtoff=''
1083d_tm_tm_zone=''
1084i_systime=''
1085i_systimek=''
1086i_time=''
1087timeincl=''
1088i_unistd=''
1089i_ustat=''
1090i_utime=''
1091i_vfork=''
1092i_wchar=''
1093i_wctype=''
1094d_inc_version_list=''
1095inc_version_list=''
1096inc_version_list_init=''
1097doubleinfbytes=''
1098doublenanbytes=''
1099longdblinfbytes=''
1100longdblnanbytes=''
1101installprefix=''
1102installprefixexp=''
1103installstyle=''
1104installusrbinperl=''
1105intsize=''
1106longsize=''
1107shortsize=''
1108issymlink=''
1109libc=''
1110ldlibpthname=''
1111libperl=''
1112shrpenv=''
1113useshrplib=''
1114glibpth=''
1115incpth=''
1116libpth=''
1117loclibpth=''
1118plibpth=''
1119xlibpth=''
1120ignore_versioned_solibs=''
1121libs=''
1122libsdirs=''
1123libsfiles=''
1124libsfound=''
1125libspath=''
1126lns=''
1127d_PRIEUldbl=''
1128d_PRIFUldbl=''
1129d_PRIGUldbl=''
1130d_PRIeldbl=''
1131d_PRIfldbl=''
1132d_PRIgldbl=''
1133d_SCNfldbl=''
1134d_double_has_inf=''
1135d_double_has_nan=''
1136d_double_has_negative_zero=''
1137d_double_has_subnormals=''
1138d_double_style_cray=''
1139d_double_style_ibm=''
1140d_double_style_ieee=''
1141d_double_style_vax=''
1142doublekind=''
1143sPRIEUldbl=''
1144sPRIFUldbl=''
1145sPRIGUldbl=''
1146sPRIeldbl=''
1147sPRIfldbl=''
1148sPRIgldbl=''
1149sSCNfldbl=''
1150lseeksize=''
1151lseektype=''
1152make_set_make=''
1153d_mymalloc=''
1154freetype=''
1155mallocobj=''
1156mallocsrc=''
1157malloctype=''
1158usemallocwrap=''
1159usemymalloc=''
1160installman1dir=''
1161man1dir=''
1162man1direxp=''
1163man1ext=''
1164installman3dir=''
1165man3dir=''
1166man3direxp=''
1167man3ext=''
1168doublemantbits=''
1169longdblmantbits=''
1170nvmantbits=''
1171modetype=''
1172multiarch=''
1173mydomain=''
1174myhostname=''
1175phostname=''
1176c=''
1177n=''
1178d_eofnblk=''
1179eagain=''
1180o_nonblock=''
1181rd_nodata=''
1182need_va_copy=''
1183netdb_hlen_type=''
1184netdb_host_type=''
1185netdb_name_type=''
1186netdb_net_type=''
1187groupcat=''
1188hostcat=''
1189passcat=''
1190orderlib=''
1191ranlib=''
1192d_perl_otherlibdirs=''
1193otherlibdirs=''
1194package=''
1195spackage=''
1196pager=''
1197api_revision=''
1198api_subversion=''
1199api_version=''
1200api_versionstring=''
1201patchlevel=''
1202perl_patchlevel=''
1203revision=''
1204subversion=''
1205version=''
1206version_patchlevel_string=''
1207perl5=''
1208perladmin=''
1209perlpath=''
1210d_nv_preserves_uv=''
1211d_nv_zero_is_allbits_zero=''
1212i16size=''
1213i16type=''
1214i32size=''
1215i32type=''
1216i64size=''
1217i64type=''
1218i8size=''
1219i8type=''
1220ivsize=''
1221ivtype=''
1222nv_overflows_integers_at=''
1223nv_preserves_uv_bits=''
1224nvsize=''
1225nvtype=''
1226u16size=''
1227u16type=''
1228u32size=''
1229u32type=''
1230u64size=''
1231u64type=''
1232u8size=''
1233u8type=''
1234uvsize=''
1235uvtype=''
1236ivdformat=''
1237nvEUformat=''
1238nvFUformat=''
1239nvGUformat=''
1240nveformat=''
1241nvfformat=''
1242nvgformat=''
1243uvXUformat=''
1244uvoformat=''
1245uvuformat=''
1246uvxformat=''
1247pidtype=''
1248prefix=''
1249prefixexp=''
1250installprivlib=''
1251privlib=''
1252privlibexp=''
1253ptrsize=''
1254d_PRIXU64=''
1255d_PRId64=''
1256d_PRIi64=''
1257d_PRIo64=''
1258d_PRIu64=''
1259d_PRIx64=''
1260sPRIXU64=''
1261sPRId64=''
1262sPRIi64=''
1263sPRIo64=''
1264sPRIu64=''
1265sPRIx64=''
1266d_quad=''
1267quadkind=''
1268quadtype=''
1269uquadtype=''
1270drand01=''
1271randbits=''
1272randfunc=''
1273randseedtype=''
1274seedfunc=''
1275installscript=''
1276scriptdir=''
1277scriptdirexp=''
1278selectminbits=''
1279selecttype=''
1280sh=''
1281targetsh=''
1282sig_count=''
1283sig_name=''
1284sig_name_init=''
1285sig_num=''
1286sig_num_init=''
1287sig_size=''
1288d_sitearch=''
1289installsitearch=''
1290sitearch=''
1291sitearchexp=''
1292installsitebin=''
1293sitebin=''
1294sitebinexp=''
1295installsitehtml1dir=''
1296sitehtml1dir=''
1297sitehtml1direxp=''
1298installsitehtml3dir=''
1299sitehtml3dir=''
1300sitehtml3direxp=''
1301installsitelib=''
1302sitelib=''
1303sitelib_stem=''
1304sitelibexp=''
1305installsiteman1dir=''
1306siteman1dir=''
1307siteman1direxp=''
1308installsiteman3dir=''
1309siteman3dir=''
1310siteman3direxp=''
1311siteprefix=''
1312siteprefixexp=''
1313installsitescript=''
1314sitescript=''
1315sitescriptexp=''
1316sizesize=''
1317sizetype=''
1318d_libname_unique=''
1319so=''
1320socksizetype=''
1321sharpbang=''
1322shsharp=''
1323spitshell=''
1324src=''
1325ssizetype=''
1326st_dev_sign=''
1327st_dev_size=''
1328st_ino_sign=''
1329st_ino_size=''
1330startperl=''
1331startsh=''
1332stdchar=''
1333d_stdio_stream_array=''
1334stdio_stream_array=''
1335sysman=''
1336sGMTIME_max=''
1337sGMTIME_min=''
1338sLOCALTIME_max=''
1339sLOCALTIME_min=''
1340trnl=''
1341uidformat=''
1342uidsign=''
1343uidsize=''
1344uidtype=''
1345archname64=''
1346use64bitall=''
1347use64bitint=''
1348usecbacktrace=''
1349usedefaultstrict=''
1350dtrace=''
1351usedtrace=''
1352usefaststdio=''
1353usekernprocpathname=''
1354ccflags_uselargefiles=''
1355ldflags_uselargefiles=''
1356libswanted_uselargefiles=''
1357uselargefiles=''
1358uselongdouble=''
1359usemorebits=''
1360usemultiplicity=''
1361nm_opt=''
1362nm_so_opt=''
1363runnm=''
1364usenm=''
1365usensgetexecutablepath=''
1366useperlio=''
1367usequadmath=''
1368usesocks=''
1369d_oldpthreads=''
1370useithreads=''
1371usereentrant=''
1372usethreads=''
1373incpath=''
1374mips_type=''
1375usrinc=''
1376d_vendorarch=''
1377installvendorarch=''
1378vendorarch=''
1379vendorarchexp=''
1380d_vendorbin=''
1381installvendorbin=''
1382vendorbin=''
1383vendorbinexp=''
1384installvendorhtml1dir=''
1385vendorhtml1dir=''
1386vendorhtml1direxp=''
1387installvendorhtml3dir=''
1388vendorhtml3dir=''
1389vendorhtml3direxp=''
1390d_vendorlib=''
1391installvendorlib=''
1392vendorlib=''
1393vendorlib_stem=''
1394vendorlibexp=''
1395installvendorman1dir=''
1396vendorman1dir=''
1397vendorman1direxp=''
1398installvendorman3dir=''
1399vendorman3dir=''
1400vendorman3direxp=''
1401usevendorprefix=''
1402vendorprefix=''
1403vendorprefixexp=''
1404d_vendorscript=''
1405installvendorscript=''
1406vendorscript=''
1407vendorscriptexp=''
1408versiononly=''
1409yacc=''
1410yaccflags=''
1411CONFIG=''
1412
1413: Detect odd OSs
1414define='define'
1415undef='undef'
1416smallmach='pdp11 i8086 z8000 i80286 iAPX286'
1417rmlist=''
1418
1419: We must find out about Eunice early
1420eunicefix=':'
1421if test -f /etc/unixtovms; then
1422	eunicefix=/etc/unixtovms
1423fi
1424if test -f /etc/unixtovms.exe; then
1425	eunicefix=/etc/unixtovms.exe
1426fi
1427
1428: Set executable suffix now -- needed before hints available
1429if test -f "/libs/version.library"; then
1430: Amiga OS
1431    _exe=""
1432elif test -f "/system/gnu_library/bin/ar.pm"; then
1433: Stratus VOS
1434    _exe=".pm"
1435elif test -n "$DJGPP"; then
1436: DOS DJGPP
1437    _exe=".exe"
1438elif test -f /kern/cookiejar; then
1439: MiNT
1440    _exe=""
1441elif test -d c:/. -o -n "$is_os2" ; then
1442: OS/2 or cygwin
1443    _exe=".exe"
1444fi
1445
1446groupstype=''
1447i_whoami=''
1448: Possible local include directories to search.
1449: Set locincpth to "" in a hint file to defeat local include searches.
1450locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
1451locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
1452:
1453: no include file wanted by default
1454inclwanted=''
1455
1456: Enable -DEBUGGING and -DDEBUGGING from the command line
1457EBUGGING=''
1458DEBUGGING=''
1459
1460: Trailing extension.  Override this in a hint file, if needed.
1461: Extra object files, if any, needed on this platform.
1462archobjs=''
1463libnames=''
1464: change the next line if compiling for Xenix/286 on Xenix/386
1465xlibpth='/usr/lib/386 /lib/386'
1466: Possible local library directories to search.
1467loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1468loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1469
1470: general looking path for locating libraries
1471glibpth="/lib /usr/lib $xlibpth"
1472glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
1473test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
1474test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
1475test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
1476
1477: Private path used by Configure to find libraries.  Its value
1478: is prepended to libpth. This variable takes care of special
1479: machines, like the mips.  Usually, it should be empty.
1480plibpth=''
1481
1482: default library list
1483libswanted=''
1484: some systems want to use only the non-versioned libso:s
1485ignore_versioned_solibs=''
1486ccname=''
1487ccversion=''
1488perllibs=''
1489: set useposix=false in your hint file to disable the POSIX extension.
1490useposix=true
1491: set useopcode=false in your hint file to disable the Opcode extension.
1492useopcode=true
1493: set uselanginfo=false in your hint file to disable the I18N::Langinfo extension.
1494uselanginfo=true
1495archname64=''
1496ccflags_uselargefiles=''
1497ldflags_uselargefiles=''
1498libswanted_uselargefiles=''
1499: set usemultiplicity on the Configure command line to enable multiplicity.
1500: set usesocks on the Configure command line to enable socks.
1501archname=''
1502: set usethreads on the Configure command line to enable threads.
1503usereentrant='undef'
1504: List of libraries we want.
1505: If anyone needs extra -lxxx, put those in a hint file.
1506libswanted="cl pthread socket bind inet nsl ndbm gdbm dbm db malloc dl ld"
1507libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
1508: We probably want to search /usr/shlib before most other libraries.
1509: This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
1510glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
1511glibpth="/usr/shlib $glibpth"
1512: Do not use vfork unless overridden by a hint file.
1513usevfork=false
1514
1515: Find the basic shell for Bourne shell scripts
1516case "$sh" in
1517'')
1518	case "$SYSTYPE" in
1519	*bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
1520	*) xxx='/bin/sh';;
1521	esac
1522	if test -f "$xxx"; then
1523		sh="$xxx"
1524	else
1525		: Build up a list and do a single loop so we can 'break' out.
1526		pth=`echo $PATH | sed -e "s/$p_/ /g"`
1527		for xxx in sh bash ksh pdksh ash; do
1528			for p in $pth; do
1529				try="$try ${p}/${xxx}"
1530			done
1531		done
1532		for xxx in $try; do
1533			if test -f "$xxx"; then
1534				sh="$xxx";
1535				break
1536			elif test "X$_exe" != X -a -f "$xxx$_exe"; then
1537				sh="$xxx";
1538				break
1539			elif test -f "$xxx.exe"; then
1540				sh="$xxx";
1541				break
1542			fi
1543		done
1544	fi
1545	;;
1546esac
1547
1548case "$sh" in
1549'')	cat >&2 <<EOM
1550$me:  Fatal Error:  I can't find a Bourne Shell anywhere.
1551
1552Usually it's in /bin/sh.  How did you even get this far?
1553Please report this issue at https://github.com/Perl/perl5/issues
1554and we'll try to straighten this all out.
1555EOM
1556	exit 1
1557	;;
1558esac
1559
1560: When cross-compiling we need to separate the sh-to-run-Configure-with from the sh-to-use-in-Perl
1561: default both to the same thing, cross-compilers can then set targetsh differently if they like
1562targetsh=$sh
1563
1564: see if sh knows # comments
1565if `$sh -c '#' >/dev/null 2>&1`; then
1566	shsharp=true
1567	spitshell=cat
1568	xcat=/bin/cat
1569	test -f $xcat$_exe || xcat=/usr/bin/cat
1570	if test ! -f $xcat$_exe; then
1571		for p in `echo $PATH | sed -e "s/$p_/ /g"` $paths; do
1572			if test -f $p/cat$_exe; then
1573				xcat=$p/cat
1574				break
1575			fi
1576		done
1577		if test ! -f $xcat$_exe; then
1578			echo "Can't find cat anywhere!"
1579			exit 1
1580		fi
1581	fi
1582	echo "#!$xcat" >sharp
1583	$eunicefix sharp
1584	chmod +x sharp
1585	./sharp > today 2>/dev/null
1586	if test -s today; then
1587		sharpbang='#!'
1588	else
1589		echo "#! $xcat" > sharp
1590		$eunicefix sharp
1591		chmod +x sharp
1592		./sharp > today 2>/dev/null
1593		if test -s today; then
1594			sharpbang='#! '
1595		else
1596			sharpbang=': use '
1597		fi
1598	fi
1599else
1600	echo " "
1601	echo "Your $sh doesn't grok # comments--I will strip them later on."
1602	shsharp=false
1603	cd ..
1604	echo "exec grep -v '^[ 	]*#'" >spitshell
1605	chmod +x spitshell
1606	$eunicefix spitshell
1607	spitshell=`pwd`/spitshell
1608	cd UU
1609	echo "I presume that if # doesn't work, #! won't work either!"
1610	sharpbang=': use '
1611fi
1612rm -f sharp today
1613
1614: figure out how to guarantee sh startup
1615case "$startsh" in
1616'') startsh=${sharpbang}${sh} ;;
1617*)
1618esac
1619cat >sharp <<EOSS
1620$startsh
1621set abc
1622test "$?abc" != 1
1623EOSS
1624
1625chmod +x sharp
1626$eunicefix sharp
1627if ./sharp; then
1628	: echo "Yup, it does."
1629else
1630	echo "Hmm... '$startsh' does not guarantee sh startup..."
1631	echo "You may have to fix up the shell scripts to make sure $sh runs them."
1632fi
1633rm -f sharp
1634
1635: Save command line options in file UU/cmdline.opt for later use in
1636: generating config.sh.
1637cat > cmdline.opt <<EOSH
1638: Configure command line arguments.
1639config_arg0='$0'
1640config_args='$*'
1641config_argc=$#
1642EOSH
1643argn=1
1644args_exp=''
1645args_sep=''
1646for arg in "$@"; do
1647	cat >>cmdline.opt <<EOSH
1648config_arg$argn='$arg'
1649EOSH
1650	cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
1651$arg
1652EOC
1653	arg_exp=`cat cmdl.opt`
1654	args_exp="$args_exp$args_sep'$arg_exp'"
1655	argn=`expr $argn + 1`
1656	args_sep=' '
1657done
1658rm -f cmdl.opt
1659
1660: produce awk script to parse command line options
1661cat >options.awk <<'EOF'
1662BEGIN {
1663	optstr = "A:dD:eEf:hKOrsSU:V";	# getopt-style specification
1664
1665	len = length(optstr);
1666	for (i = 1; i <= len; i++) {
1667		c = substr(optstr, i, 1);
1668		if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1669		if (a == ":") {
1670			arg[c] = 1;
1671			i++;
1672		}
1673		opt[c] = 1;
1674	}
1675}
1676{
1677	expect = 0;
1678	str = $0;
1679	if (substr(str, 1, 1) != "-") {
1680		printf("'%s'\n", str);
1681		next;
1682	}
1683	len = length($0);
1684	for (i = 2; i <= len; i++) {
1685		c = substr(str, i, 1);
1686		if (!opt[c]) {
1687			printf("-%s\n", substr(str, i));
1688			next;
1689		}
1690		printf("-%s\n", c);
1691		if (arg[c]) {
1692			if (i < len)
1693				printf("'%s'\n", substr(str, i + 1));
1694			else
1695				expect = 1;
1696			next;
1697		}
1698	}
1699}
1700END {
1701	if (expect)
1702		print "?";
1703}
1704EOF
1705
1706: process the command line options
1707set X `for arg in "$@"; do echo "X$arg"; done |
1708	sed -e s/X// | awk -f options.awk`
1709eval "set $*"
1710shift
1711rm -f options.awk
1712
1713: set up default values
1714fastread=''
1715reuseval=false
1716config_sh=''
1717alldone=''
1718error=''
1719silent=''
1720extractsh=''
1721knowitall=''
1722rm -f optdef.sh posthint.sh
1723cat >optdef.sh <<EOS
1724$startsh
1725EOS
1726
1727
1728: option parsing
1729while test $# -gt 0; do
1730	case "$1" in
1731	-d) shift; fastread=yes;;
1732	-e) shift; alldone=cont;;
1733	-f)
1734		shift
1735		cd ..
1736		if test -r "$1"; then
1737			config_sh="$1"
1738		else
1739			echo "$me: cannot read config file $1." >&2
1740			error=true
1741		fi
1742		cd UU
1743		shift;;
1744	--help|\
1745	-h) shift; error=true;;
1746	-r) shift; reuseval=true;;
1747	-s) shift; silent=true; realsilent=true;;
1748	-E) shift; alldone=exit;;
1749	-K) shift; knowitall=true;;
1750	-O) shift;;
1751	-S) shift; silent=true; extractsh=true;;
1752	-D)
1753		shift
1754		case "$1" in
1755		*=)
1756			echo "$me: use '-U symbol=', not '-D symbol='." >&2
1757			echo "$me: ignoring -D $1" >&2
1758			;;
1759		*=*) echo "$1" | \
1760				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1761		*) echo "$1='define'" >> optdef.sh;;
1762		esac
1763		shift
1764		;;
1765	-U)
1766		shift
1767		case "$1" in
1768		*=) echo "$1" >> optdef.sh;;
1769		*=*)
1770			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1771			echo "$me: ignoring -U $1" >&2
1772			;;
1773		*) echo "$1='undef'" >> optdef.sh;;
1774		esac
1775		shift
1776		;;
1777	-A)
1778	    shift
1779	    xxx=''
1780	    yyy="$1"
1781	    zzz=''
1782	    uuu=undef
1783	    case "$yyy" in
1784            *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1785                 case "$zzz" in
1786                 *:*) zzz='' ;;
1787                 *)   xxx=append
1788                      zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1789                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1790                 esac
1791                 ;;
1792            esac
1793            case "$xxx" in
1794            '')  case "$yyy" in
1795                 *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1796                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1797                      zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1798                      yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1799                 *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
1800                      yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1801                 esac
1802                 ;;
1803            esac
1804	    case "$xxx" in
1805	    append)
1806		echo "$yyy=\"\${$yyy}$zzz\""	>> posthint.sh ;;
1807	    clear)
1808		echo "$yyy=''"			>> posthint.sh ;;
1809	    define)
1810	        case "$zzz" in
1811		'') zzz=define ;;
1812		esac
1813		echo "$yyy='$zzz'"		>> posthint.sh ;;
1814	    eval)
1815		echo "eval \"$yyy=$zzz\""	>> posthint.sh ;;
1816	    prepend)
1817		echo "$yyy=\"$zzz\${$yyy}\""	>> posthint.sh ;;
1818	    undef)
1819	        case "$zzz" in
1820		'') zzz="$uuu" ;;
1821		esac
1822		echo "$yyy=$zzz"		>> posthint.sh ;;
1823            *)  echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1824	    esac
1825	    shift
1826	    ;;
1827	-V) echo "$me generated by metaconfig 3.5 PL0." >&2
1828	    exit 0;;
1829	--) break;;
1830	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
1831	*) break;;
1832	esac
1833done
1834
1835case "$error" in
1836true)
1837	cat >&2 <<EOM
1838Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1839                 [-U symbol] [-U symbol=] [-A command:symbol...]
1840  -d : use defaults for all answers.
1841  -e : go on without questioning past the production of config.sh.
1842  -f : specify an alternate default configuration file.
1843  -h : print this help message and exit (with an error status).
1844  -r : reuse C symbols value if possible (skips costly nm extraction).
1845  -s : silent mode, only echoes questions and essential information.
1846  -D : define symbol to have some value:
1847         -D symbol                symbol gets the value 'define'
1848         -D symbol='some value'   symbol is set to 'some value'
1849       common used examples (see INSTALL for more info):
1850         -Duse64bitint            use 64bit integers
1851         -Duse64bitall            use 64bit integers and pointers
1852         -Dusethreads             use thread support
1853         -Dinc_version_list=none  do not include older perl trees in @INC
1854         -DEBUGGING=none          DEBUGGING options
1855         -Dcc=gcc                 choose your compiler
1856         -Dprefix=/opt/perl5      choose your destination
1857  -E : stop at the end of questions, after having produced config.sh.
1858  -K : do not use unless you know what you are doing.
1859  -O : ignored for backward compatibility
1860  -S : perform variable substitutions on all .SH files (can mix with -f)
1861  -U : undefine symbol:
1862         -U symbol    symbol gets the value 'undef'
1863         -U symbol=   symbol gets completely empty
1864       e.g.:  -Uversiononly
1865  -A : manipulate symbol after the platform specific hints have been applied:
1866         -A append:symbol=value   append value to symbol
1867         -A symbol=value          like append:, but with a separating space
1868         -A define:symbol=value   define symbol to have value
1869         -A clear:symbol          define symbol to be ''
1870         -A define:symbol         define symbol to be 'define'
1871         -A eval:symbol=value     define symbol to be eval of value
1872         -A prepend:symbol=value  prepend value to symbol
1873         -A undef:symbol          define symbol to be 'undef'
1874         -A undef:symbol=         define symbol to be ''
1875       e.g.:  -A prepend:libswanted='cl pthread '
1876              -A ccflags=-DSOME_MACRO
1877  -V : print version number and exit (with a zero status).
1878EOM
1879	exit 1
1880	;;
1881esac
1882
1883: Sanity checks
1884case "$fastread$alldone" in
1885yescont|yesexit) ;;
1886*)
1887	case "$extractsh" in
1888	true) ;;
1889	*)
1890		if test ! -t 0; then
1891			echo "Say 'sh Configure', not 'sh <Configure'"
1892			exit 1
1893		fi
1894		;;
1895	esac
1896	;;
1897esac
1898
1899exec 4>&1
1900case "$silent" in
1901true) exec 1>/dev/null;;
1902esac
1903
1904: run the defines and the undefines, if any, but leave the file out there...
1905touch optdef.sh
1906grep '\\' optdef.sh >/dev/null 2>&1
1907if test $? = 0; then
1908    echo "Configure does not support \\ in -D arguments"
1909    exit 1
1910fi
1911. ./optdef.sh
1912: create the posthint manipulation script and leave the file out there...
1913touch posthint.sh
1914
1915: set package name
1916package='perl5'
1917first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1918last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1919case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
1920ABYZ-abyz) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1921*) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1922esac
1923
1924: Some greps do not return status, grrr.
1925echo "grimblepritz" >grimble
1926if grep blurfldyick grimble >/dev/null 2>&1 ; then
1927	contains=contains
1928elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1929	contains=grep
1930else
1931	contains=contains
1932fi
1933rm -f grimble
1934: the following should work in any shell
1935case "$contains" in
1936contains*)
1937	echo " " >&4
1938	echo "AGH!  Grep doesn't return a status.  Attempting remedial action." >&4
1939	cat >contains <<'EOSS'
1940grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1941EOSS
1942contains=./contains
1943chmod +x $contains
1944esac
1945
1946: Find the path to the source tree
1947case "$src" in
1948'') case "$0" in
1949    */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
1950         case "$src" in
1951	 /*)	;;
1952	 .)	;;
1953         *)	src=`cd ../$src && pwd` ;;
1954	 esac
1955         ;;
1956    *)   src='.';;
1957    esac;;
1958esac
1959case "$src" in
1960'')	src=/
1961	rsrc=/
1962	;;
1963/*)	rsrc="$src";;
1964*)	rsrc="../$src";;
1965esac
1966if test -f $rsrc/Configure && \
1967	$contains "^package='$package'\$" $rsrc/Configure >/dev/null 2>&1
1968then
1969   : found it, so we are ok.
1970else
1971	rsrc=''
1972	for src in . .. ../.. ../../.. ../../../..; do
1973		if test -f ../$src/Configure && \
1974			$contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1975		then
1976			rsrc=../$src
1977			break
1978		fi
1979	done
1980fi
1981case "$rsrc" in
1982'')
1983	cat <<EOM >&4
1984
1985Sorry, I can't seem to locate the source dir for $package.  Please start
1986Configure with an explicit path -- i.e. /some/path/Configure.
1987
1988EOM
1989	exit 1
1990	;;
1991../.)	rsrc='..';;
1992*)
1993	echo " "
1994	echo "Sources for $package found in \"$src\"." >&4
1995	;;
1996esac
1997
1998: script used to extract .SH files with variable substitutions
1999cat >extract <<'EOS'
2000PERL_CONFIG_SH=true
2001echo "Doing variable substitutions on .SH files..."
2002if test -f MANIFEST; then
2003	set x `awk '{print $1}' < MANIFEST | grep '\.SH$'`
2004else
2005	echo "(Looking for .SH files under the source directory.)"
2006	set x `(cd "$src"; find . -name "*.SH" -print)`
2007fi
2008shift
2009case $# in
20100) set x `(cd "$src"; echo *.SH)`; shift;;
2011esac
2012if test ! -f "$src/$1"; then
2013	shift
2014fi
2015mkdir_p='
2016name=$1;
2017create="";
2018while test $name; do
2019	if test ! -d "$name"; then
2020		create="$name $create";
2021		name=`echo $name | sed -e "s|^[^/]*$||"`;
2022		name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
2023	else
2024		name="";
2025	fi;
2026done;
2027for file in $create; do
2028	mkdir $file;
2029done
2030'
2031for file in $*; do
2032	case "$src" in
2033	".")
2034		case "$file" in
2035		*/*)
2036			dir=`expr X$file : 'X\(.*\)/'`
2037			file=`expr X$file : 'X.*/\(.*\)'`
2038			(cd "$dir" && . ./$file)
2039			;;
2040		*)
2041			. ./$file
2042			;;
2043		esac
2044		;;
2045	*)
2046		case "$file" in
2047		*/*)
2048			dir=`expr X$file : 'X\(.*\)/'`
2049			file=`expr X$file : 'X.*/\(.*\)'`
2050			(set x $dir; shift; eval $mkdir_p)
2051			sh <"$src/$dir/$file"
2052			;;
2053		*)
2054			sh <"$src/$file"
2055			;;
2056		esac
2057		;;
2058	esac
2059done
2060if test -f "$src/config_h.SH"; then
2061	if test ! -f config.h; then
2062	: oops, they left it out of MANIFEST, probably, so do it anyway.
2063	. "$src/config_h.SH"
2064	fi
2065fi
2066EOS
2067
2068: extract files and exit if asked to do so
2069case "$extractsh" in
2070true)
2071	case "$realsilent" in
2072	true) ;;
2073	*) exec 1>&4;;
2074	esac
2075	case "$config_sh" in
2076	'') config_sh='config.sh';;
2077	esac
2078	echo " "
2079	echo "Fetching answers from $config_sh..."
2080	cd ..
2081	. $config_sh
2082	. UU/optdef.sh
2083	echo " "
2084	. UU/extract
2085	rm -rf UU
2086	echo "Extraction done."
2087	exit 0
2088	;;
2089esac
2090
2091: Eunice requires " " instead of "", can you believe it
2092echo " "
2093: Here we go...
2094echo "Beginning of configuration questions for $package."
2095
2096trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
2097
2098: first determine how to suppress newline on echo command
2099echo " "
2100echo "Checking echo to see how to suppress newlines..."
2101(echo "hi there\c" ; echo " ") >.echotmp
2102if $contains c .echotmp >/dev/null 2>&1 ; then
2103	echo "...using -n."
2104	n='-n'
2105	c=''
2106else
2107	cat <<'EOM'
2108...using \c
2109EOM
2110	n=''
2111	c='\c'
2112fi
2113echo $n "The star should be here-->$c"
2114echo '*'
2115rm -f .echotmp
2116
2117: Now test for existence of everything in MANIFEST
2118echo " "
2119if test -f "$rsrc/MANIFEST"; then
2120	echo "First let's make sure your kit is complete.  Checking..." >&4
2121	awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
2122		(split -l 50 2>/dev/null || split -50)
2123	rm -f missing
2124	tmppwd=`pwd`
2125	for filelist in x??; do
2126		(cd "$rsrc"; ls `cat "$tmppwd/$filelist"` \
2127			>/dev/null 2>>"$tmppwd/missing")
2128	done
2129	if test -s missing; then
2130		cat missing >&4
2131		cat >&4 <<'EOM'
2132
2133THIS PACKAGE SEEMS TO BE INCOMPLETE.
2134
2135You have the option of continuing the configuration process, despite the
2136distinct possibility that your kit is damaged, by typing 'y'es.  If you
2137do, don't blame me if something goes wrong.  I advise you to type 'n'o
2138and contact the author (https://github.com/Perl/perl5/issues).
2139
2140EOM
2141		echo $n "Continue? [n] $c" >&4
2142		read ans
2143		case "$ans" in
2144		y*)
2145			echo "Continuing..." >&4
2146			rm -f missing
2147			;;
2148		*)
2149			echo "ABORTING..." >&4
2150			kill $$
2151			;;
2152		esac
2153	else
2154		echo "Looks good..."
2155	fi
2156else
2157	echo "There is no MANIFEST file.  I hope your kit is complete !"
2158fi
2159rm -f missing x??
2160
2161: Find the appropriate value for a newline for tr
2162if test -n "$DJGPP"; then
2163       trnl='\012'
2164fi
2165if test X"$trnl" = X; then
2166	case "`echo foo | tr '\n' x 2>/dev/null`" in
2167	foox) trnl='\n' ;;
2168	esac
2169fi
2170if test X"$trnl" = X; then
2171	case "`echo foo | tr '\012' x 2>/dev/null`" in
2172	foox) trnl='\012' ;;
2173	esac
2174fi
2175if test X"$trnl" = X; then
2176       case "`echo foo | tr '\r\n' xy 2>/dev/null`" in
2177       fooxy) trnl='\n\r' ;;
2178       esac
2179fi
2180if test X"$trnl" = X; then
2181	cat <<EOM >&2
2182
2183$me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
2184
2185EOM
2186	exit 1
2187fi
2188
2189: compute the number of columns on the terminal for proper question formatting
2190case "$COLUMNS" in
2191'') COLUMNS='80';;
2192esac
2193
2194: set up the echo used in my read
2195myecho="case \"\$xxxm\" in
2196'') echo $n \"\$rp $c\" >&4;;
2197*) case \"\$rp\" in
2198	'') echo $n \"[\$xxxm] $c\";;
2199	*)
2200		if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
2201			echo \"\$rp\" >&4
2202			echo $n \"[\$xxxm] $c\" >&4
2203		else
2204			echo $n \"\$rp [\$xxxm] $c\" >&4
2205		fi
2206		;;
2207	esac;;
2208esac"
2209
2210: now set up to do reads with possible shell escape and default assignment
2211cat <<EOSC >myread
2212$startsh
2213xxxm=\$dflt
2214$myecho
2215ans='!'
2216case "\$fastread" in
2217yes) case "\$dflt" in
2218	'') ;;
2219	*) ans='';
2220		case "\$silent-\$rp" in
2221		true-) ;;
2222		*) echo " " >&4;;
2223		esac;;
2224	esac;;
2225*) case "\$silent" in
2226	true) case "\$rp" in
2227		'') ans='';;
2228		esac;;
2229	esac;;
2230esac
2231while expr "X\$ans" : "X!" >/dev/null; do
2232	read answ
2233	set x \$xxxm
2234	shift
2235	aok=''; eval "ans=\\"\$answ\\"" && aok=y
2236	case  "\$answ" in
2237	"!")
2238		sh 1>&4
2239		echo " "
2240		$myecho
2241		;;
2242	!*)
2243		set x \`expr "X\$ans" : "X!\(.*\)\$"\`
2244		shift
2245		sh 1>&4 -c "\$*"
2246		echo " "
2247		$myecho
2248		;;
2249	"\$ans")
2250		case "\$ans" in
2251		\\&*)
2252			set x \`expr "X\$ans" : "X&\(.*\)\$"\`
2253			shift
2254			case "\$1" in
2255			-d)
2256				fastread=yes
2257				echo "(OK, I'll run with -d after this question.)" >&4
2258				;;
2259			-*)
2260				echo "*** Sorry, \$1 not supported yet." >&4
2261				;;
2262			esac
2263			$myecho
2264			ans=!
2265			;;
2266		esac;;
2267	*)
2268		case "\$aok" in
2269		y)
2270			echo "*** Substitution done -- please confirm."
2271			xxxm="\$ans"
2272			ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
2273			xxxm="\$ans"
2274			ans=!
2275			;;
2276		*)
2277			echo "*** Error -- try again."
2278			ans=!
2279			;;
2280		esac
2281		$myecho
2282		;;
2283	esac
2284	case "\$ans\$xxxm\$nostick" in
2285	'')
2286		ans=!
2287		$myecho
2288		;;
2289	esac
2290done
2291case "\$ans" in
2292'') ans="\$xxxm";;
2293esac
2294EOSC
2295
2296: create .config dir to save info across Configure sessions
2297test -d ../.config || mkdir ../.config
2298cat >../.config/README <<EOF
2299This directory created by Configure to save information that should
2300persist across sessions for $package.
2301
2302You may safely delete it if you wish.
2303EOF
2304
2305: See if we are using a devel version and want that
2306xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
2307case "$usedevel" in
2308$define|true|[yY]*)
2309    usedevel="$define" ;;
2310*) case "$xversion" in
2311   *[13579])
2312	cat >&4 <<EOH
2313*** WHOA THERE!!! ***
2314
2315    This is an UNSTABLE DEVELOPMENT release.
2316    The version of this $package distribution is $xversion, that is, odd,
2317    (as opposed to even) and that signifies a development release.
2318    If you want a maintenance release, you want an even-numbered version.
2319
2320    Do ***NOT*** install this into production use.
2321    Data corruption and crashes are possible.
2322
2323    It is most seriously suggested that you do not continue any further
2324    unless you want to help in developing and debugging Perl.
2325
2326    If you *still* want to build perl, you can answer 'y' now,
2327    or pass -Dusedevel to Configure.
2328
2329EOH
2330	rp='Do you really want to continue?'
2331	dflt='n'
2332	. ./myread
2333	case "$ans" in
2334	[yY]) echo >&4 "Okay, continuing."
2335	      usedevel="$define" ;;
2336	*) echo >&4 "Okay, bye."
2337	   exit 1
2338	   ;;
2339	esac
2340	;;
2341    esac
2342    usedevel="$undef"
2343    ;;
2344esac
2345case "$usedevel" in
2346$define|true|[yY]*)
2347	case "$versiononly" in
2348	'') versiononly="$define" ;;
2349	esac
2350	case "$installusrbinperl" in
2351	'') installusrbinperl="$undef" ;;
2352	esac
2353	;;
2354esac
2355
2356: general instructions
2357needman=true
2358firsttime=true
2359user=`(logname) 2>/dev/null`
2360case "$user" in
2361'') user=`whoami 2>&1`;;
2362esac
2363if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
2364	firsttime=false
2365	echo " "
2366	rp='Would you like to see the instructions?'
2367	dflt=n
2368	. ./myread
2369	case "$ans" in
2370	[yY]*) ;;
2371	*) needman=false;;
2372	esac
2373fi
2374if $needman; then
2375	cat <<EOH
2376
2377This installation shell script will examine your system and ask you questions
2378to determine how the perl5 package should be installed. If you get
2379stuck on a question, you may use a ! shell escape to start a subshell or
2380execute a command.  Many of the questions will have default answers in square
2381brackets; typing carriage return will give you the default.
2382
2383On some of the questions which ask for file or directory names you are allowed
2384to use the ~name construct to specify the login directory belonging to "name",
2385even if you don't have a shell which knows about that.  Questions where this is
2386allowed will be marked "(~name ok)".
2387
2388EOH
2389	rp=''
2390	dflt='Type carriage return to continue'
2391	. ./myread
2392	cat <<'EOH'
2393
2394The prompter used in this script allows you to use shell variables and
2395backticks in your answers.  You may use $1, $2, etc...  to refer to the words
2396in the default answer, as if the default line was a set of arguments given to a
2397script shell.  This means you may also use $* to repeat the whole default line,
2398so you do not have to re-type everything to add something to the default.
2399
2400Every time there is a substitution, you will have to confirm.  If there is an
2401error (e.g. an unmatched backtick), the default answer will remain unchanged
2402and you will be prompted again.
2403
2404If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
2405the questions and use the computed defaults (or the previous answers if there
2406was already a config.sh file). Type 'Configure -h' for a list of options.
2407You may also start interactively and then answer '& -d' at any prompt to turn
2408on the non-interactive behaviour for the remainder of the execution.
2409
2410EOH
2411	. ./myread
2412	cat <<EOH
2413
2414Much effort has been expended to ensure that this shell script will run on any
2415Unix system.  If despite that it blows up on yours, your best bet is to edit
2416Configure and run it again.  If you can't run Configure for some reason,
2417you'll have to generate a config.sh file by hand.  Whatever problems you
2418have, let me (https://github.com/Perl/perl5/issues) know how I blew it.
2419
2420This installation script affects things in two ways:
2421
24221) it may do direct variable substitutions on some of the files included
2423   in this kit.
24242) it builds a config.h file for inclusion in C programs.  You may edit
2425   any of these files as the need arises after running this script.
2426
2427If you make a mistake on a question, there is no easy way to back up to it
2428currently.  The easiest thing to do is to edit config.sh and rerun all the SH
2429files.  Configure will offer to let you do this before it runs the SH files.
2430
2431EOH
2432	dflt='Type carriage return to continue'
2433	. ./myread
2434	case "$firsttime" in
2435	true) echo $user >>../.config/instruct;;
2436	esac
2437fi
2438
2439: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
2440: This is primarily meant for cross-compile environments, and may fail to be useful in other cases
2441if test "X$sysroot" = X; then
2442    sysroot=""
2443else
2444    case "$cc" in
2445	*gcc*|*g++*)
2446	    echo "Using $sysroot to find your headers and libraries, adding to ccflags"
2447	    # _sysroot is used in places where we need --sysroot=foo
2448	    # but using the rest of the flags could cause issues.
2449	    _sysroot="--sysroot=$sysroot";
2450	    case "$ccflags" in
2451		*sysroot*) ;;
2452		'undef'|*)
2453		ccflags="$ccflags $_sysroot"
2454	    esac
2455	    case "$ldflags" in
2456		*sysroot*) ;;
2457		'undef'|*)
2458		ldflags="$ldflags $_sysroot"
2459	    esac
2460	    case "$cppflags" in
2461		*sysroot*) ;;
2462		'undef'|*)
2463		cppflags="$cppflags $_sysroot"
2464	    esac
2465	    # lddlflags updated below in lddlflags section;
2466	    # same with cccdlflags
2467	    ;;
2468    esac
2469
2470    # Adjust some defaults to also use $sysroot
2471    for var in xlibpth loclibpth locincpth glibpth; do
2472	eval xxx=\$$var
2473	eval $var=''
2474	for path in $xxx; do
2475	    eval $var=\"\$$var $sysroot$path\"
2476	done
2477    done
2478
2479fi
2480
2481: find out where common programs are
2482echo " "
2483echo "Locating common programs..." >&4
2484cat <<EOSC >loc
2485$startsh
2486case \$# in
24870) exit 1;;
2488esac
2489thing=\$1
2490shift
2491dflt=\$1
2492shift
2493for dir in \$*; do
2494	case "\$thing" in
2495	.)
2496	if test -d \$dir/\$thing; then
2497		echo \$dir
2498		exit 0
2499	fi
2500	;;
2501	*)
2502	for thisthing in \$dir/\$thing; do
2503		: just loop through to pick last item
2504	done
2505	if test -f \$thisthing; then
2506		echo \$thisthing
2507		exit 0
2508	elif test "X$_exe" != X -a -f \$thisthing$_exe; then
2509		echo \$thisthing
2510		exit 0
2511	elif test -f \$dir/\$thing.exe; then
2512		if test -n "$DJGPP"; then
2513			echo \$dir/\$thing.exe
2514		elif test "$eunicefix" != ":"; then
2515			: on Eunice apparently
2516			echo \$dir/\$thing
2517		fi
2518		exit 0
2519	fi
2520	;;
2521	esac
2522done
2523echo \$dflt
2524exit 1
2525EOSC
2526chmod +x loc
2527$eunicefix loc
2528loclist="
2529awk
2530cat
2531chmod
2532comm
2533cp
2534echo
2535expr
2536grep
2537ls
2538mkdir
2539rm
2540sed
2541sort
2542touch
2543tr
2544uniq
2545"
2546trylist="
2547ar
2548bison
2549byacc
2550cpp
2551csh
2552date
2553egrep
2554gmake
2555gzip
2556less
2557ln
2558make
2559more
2560nm
2561nroff
2562perl
2563pg
2564test
2565uname
2566zip
2567"
2568pth=`echo $PATH | sed -e "s/$p_/ /g"`
2569pth="$pth $sysroot/lib $sysroot/usr/lib"
2570for file in $loclist; do
2571	eval xxx=\$$file
2572	case "$xxx" in
2573	/*|?:[\\/]*)
2574		if test -f "$xxx"; then
2575			: ok
2576		else
2577			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2578			xxx=`./loc $file $file $pth`
2579		fi
2580		;;
2581	'') xxx=`./loc $file $file $pth`;;
2582	*) xxx=`./loc $xxx $xxx $pth`;;
2583	esac
2584	eval $file=$xxx$_exe
2585	eval _$file=$xxx
2586	case "$xxx" in
2587	/*)
2588		echo $file is in $xxx.
2589		;;
2590	?:[\\/]*)
2591		echo $file is in $xxx.
2592		;;
2593	*)
2594		echo "I don't know where '$file' is, and my life depends on it." >&4
2595		echo "Go find a public domain implementation or fix your PATH setting!" >&4
2596		exit 1
2597		;;
2598	esac
2599done
2600echo " "
2601echo "Don't worry if any of the following aren't found..."
2602say=offhand
2603for file in $trylist; do
2604	eval xxx=\$$file
2605	case "$xxx" in
2606	/*|?:[\\/]*)
2607		if test -f "$xxx"; then
2608			: ok
2609		else
2610			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2611			xxx=`./loc $file $file $pth`
2612		fi
2613		;;
2614	'') xxx=`./loc $file $file $pth`;;
2615	*) xxx=`./loc $xxx $xxx $pth`;;
2616	esac
2617	eval $file=$xxx$_exe
2618	eval _$file=$xxx
2619	case "$xxx" in
2620	/*)
2621		echo $file is in $xxx.
2622		;;
2623	?:[\\/]*)
2624		echo $file is in $xxx.
2625		;;
2626	*)
2627		echo "I don't see $file out there, $say."
2628		say=either
2629		;;
2630	esac
2631done
2632case "$egrep" in
2633egrep)
2634	echo "Substituting grep for egrep."
2635	egrep=$grep
2636	_egrep=$grep
2637	;;
2638esac
2639case "$less" in
2640'')	;;
2641*)	if $less -R </dev/null >/dev/null 2>&1; then
2642	       echo "Substituting less -R for less."
2643	       less="$less -R"
2644	       _less=$less
2645	fi
2646	;;
2647esac
2648case "$ln" in
2649ln)
2650	echo "Substituting cp for ln."
2651	ln=$cp
2652	_ln=$cp
2653	;;
2654esac
2655case "$make" in
2656make)
2657	case "$gmake" in
2658	gmake)
2659	echo "I can't find make or gmake, and my life depends on it." >&4
2660	echo "Go find a public domain implementation or fix your PATH setting!" >&4
2661	exit 1
2662	;;
2663	esac
2664	;;
2665esac
2666case "$gmake" in
2667gmake)	;;
2668*)	# We can't have osname yet.
2669	if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
2670		# Assume that gmake, if found, is definitely GNU make
2671		# and prefer it over the system make.
2672		echo "Substituting gmake for make."
2673		make=$gmake
2674		_make=$gmake
2675	fi
2676	;;
2677esac
2678case "$test" in
2679test)
2680	echo "Hopefully test is built into your sh."
2681	;;
2682*)
2683	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
2684		echo "Using the test built into your sh."
2685		test=test
2686		_test=test
2687	fi
2688	;;
2689esac
2690case "$echo" in
2691echo)
2692	echo "Hopefully echo is built into your sh."
2693	;;
2694'') ;;
2695*)
2696	echo " "
2697echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
2698	$echo $n "hi there$c" >foo1
2699	echo $n "hi there$c" >foo2
2700	if cmp foo1 foo2 >/dev/null 2>&1; then
2701		echo "They are compatible.  In fact, they may be identical."
2702	else
2703		case "$n" in
2704		'-n') n='' c='\c';;
2705		*) n='-n' c='';;
2706		esac
2707		cat <<FOO
2708They are not compatible!  You are probably running ksh on a non-USG system.
2709I'll have to use $echo instead of the builtin, since Bourne shell doesn't
2710have echo built in and we may have to run some Bourne shell scripts.  That
2711means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
2712
2713FOO
2714		$echo $n "The star should be here-->$c"
2715		$echo "*"
2716	fi
2717	$rm -f foo1 foo2
2718	;;
2719esac
2720
2721# This question was auctioned at YAPC::Europe-2007 in Vienna
2722# I never promised you could answer it. I only auctioned the question.
2723cat <<FOO
2724The following message is sponsored by
2725
2726  Dresden.pm<--The stars should be here.
2727
2728Dear Perl user, system administrator or package
2729maintainer, the Perl community sends greetings to
2730you. Do you (emblematical) greet back [Y/n]? n
2731
2732FOO
2733
2734: Check what type of C compiler we use
2735cat <<EOS >trygcc
2736$startsh
2737EOS
2738cat <<'EOSC' >>trygcc
2739case "$cc" in
2740'') ;;
2741*)  $rm -f try try.*
2742    $cat >try.c <<EOM
2743int main(int argc, char *argv[]) {
2744  return 0;
2745}
2746EOM
2747    if $cc -o try $ccflags $ldflags try.c; then
2748       :
2749    else
2750        echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2751        despair=yes
2752        trygcc=yes
2753        case "$cc" in
2754        *gcc*) trygcc=no ;;
2755        esac
2756	# Skip this test because it gives a false match on output like:
2757	#    ./trygcc: line 23: cc: command not found
2758        # case "`$cc -v -c try.c 2>&1`" in
2759        # *gcc*) trygcc=no ;;
2760        # esac
2761        if $test X"$trygcc" = Xyes; then
2762            if gcc -o try -c try.c; then
2763                echo " "
2764                echo "You seem to have a working gcc, though." >&4
2765		# Switching compilers may undo the work of hints files.
2766		# The most common problem is -D_REENTRANT for threads.
2767		# This heuristic catches that case, but gets false positives
2768		# if -Dusethreads was not actually specified.  Better to
2769		# bail out here with a useful message than fail
2770		# mysteriously later. Should we perhaps just try to
2771		# re-invoke Configure -Dcc=gcc config_args ?
2772		if $test -f usethreads.cbu; then
2773			$cat >&4 <<EOM
2774
2775*** However, any setting of the C compiler flags (e.g. for thread support)
2776*** will be lost.  It may be necessary for you to restart Configure and
2777*** add -Dcc=gcc to your Configure command line.
2778
2779EOM
2780			rp="Would you like to go ahead and try gcc anyway?"
2781			dflt=n
2782		else
2783			rp="Would you like to use it?"
2784			dflt=y
2785		fi
2786                if $test -f myread; then
2787                    . ./myread
2788                else
2789                    if $test -f UU/myread; then
2790                        . ./UU/myread
2791                    else
2792                        echo "Cannot find myread, sorry.  Aborting." >&4
2793                        exit 1
2794                    fi
2795                fi
2796                case "$ans" in
2797                [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
2798                esac
2799            fi
2800        fi
2801    fi
2802    $rm -f try try.*
2803    ;;
2804esac
2805EOSC
2806
2807cat <<EOS >checkcc
2808$startsh
2809EOS
2810cat <<'EOSC' >>checkcc
2811case "$cc" in
2812'') ;;
2813*)  $rm -f try try.*
2814    $cat >try.c <<EOM
2815int main(int argc, char *argv[]) {
2816  return 0;
2817}
2818EOM
2819    if $cc -o try $ccflags $ldflags try.c; then
2820       :
2821    else
2822        if $test X"$despair" = Xyes; then
2823           echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2824        fi
2825        $cat >&4 <<EOM
2826You need to find a working C compiler.
2827Either (purchase and) install the C compiler supplied by your OS vendor,
2828or for a free C compiler try http://gcc.gnu.org/
2829I cannot continue any further, aborting.
2830EOM
2831        exit 1
2832    fi
2833    $rm -f try try.*
2834    ;;
2835esac
2836EOSC
2837
2838: determine whether symbolic links are supported
2839echo " "
2840$touch blurfl
2841if $ln -s blurfl sym > /dev/null 2>&1 ; then
2842	echo "Symbolic links are supported." >&4
2843	lns="$ln -s"
2844else
2845	echo "Symbolic links are NOT supported." >&4
2846	lns="$ln"
2847fi
2848$rm -f blurfl sym
2849
2850: determine whether symbolic links are supported
2851echo " "
2852case "$lns" in
2853*"ln"*" -s")
2854	echo "Checking how to test for symbolic links..." >&4
2855	$lns blurfl sym
2856	if $test "X$issymlink" = X; then
2857		case "$newsh" in
2858		'') sh     -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2859		*)  $newsh -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2860		esac
2861		if test $? = 0; then
2862			issymlink="test -h"
2863		else
2864			echo "Your builtin 'test -h' may be broken." >&4
2865			case "$test" in
2866			/*)	;;
2867			*)	pth=`echo $PATH | sed -e "s/$p_/ /g"`
2868				for p in $pth
2869				do
2870					if test -f "$p/$test"; then
2871						test="$p/$test"
2872						break
2873					fi
2874				done
2875				;;
2876			esac
2877			case "$test" in
2878			/*)
2879				echo "Trying external '$test -h'." >&4
2880				issymlink="$test -h"
2881				if $test ! -h sym >/dev/null 2>&1; then
2882					echo "External '$test -h' is broken, too." >&4
2883					issymlink=''
2884				fi
2885				;;
2886			*)	issymlink='' ;;
2887			esac
2888		fi
2889	fi
2890	if $test "X$issymlink" = X; then
2891		if $test -L sym 2>/dev/null; then
2892			issymlink="$test -L"
2893			echo "The builtin '$test -L' worked." >&4
2894		fi
2895	fi
2896	if $test "X$issymlink" != X; then
2897		echo "You can test for symbolic links with '$issymlink'." >&4
2898	else
2899		echo "I do not know how you can test for symbolic links." >&4
2900	fi
2901	$rm -f blurfl sym
2902	;;
2903*)	echo "No symbolic links, so not testing for their testing..." >&4
2904	;;
2905esac
2906
2907: Make symlinks util
2908case "$mksymlinks" in
2909$define|true|[yY]*)
2910	case "$src" in
2911	''|'.')	echo "Cannot create symlinks in the original directory." >&4
2912		exit 1
2913		;;
2914	*)	case "$lns:$issymlink" in
2915		*"ln"*" -s:"*"test -"?)
2916			echo "Creating the symbolic links..." >&4
2917			cd ..
2918			awk '{print $1}' $src/MANIFEST | sed -e 's:/\([^/]*\)$: \1:' |
2919			awk 'NF == 1 {
2920				dir=".";
2921				file=$1 "";
2922			     }
2923			     NF == 2 {
2924				dir=$1 "";
2925				file=$2 "";
2926			     }
2927			     {
2928				 print "# dir = ", dir, "file = ", file
2929				 mf[dir] = mf[dir]" "source"/"dir"/"file;
2930			     } END {
2931				 for (d in mf) {
2932				     if (d != ".") { print("mkdir -p "d) }
2933				     print("ln -sf "mf[d]" "d);
2934				 }
2935			     }' source="$src" > UU/mksymlinks.$$
2936			sh UU/mksymlinks.$$
2937			rm UU/mksymlinks.$$
2938			# Sanity check 1.
2939			if test ! -d t/base; then
2940				echo "Failed to create the subdirectories.  Aborting." >&4
2941				exit 1
2942			fi
2943			# Sanity check 2.
2944			if test ! -f t/base/lex.t; then
2945				echo "Failed to create the symlinks (t/base/lex.t missing).  Aborting." >&4
2946				exit 1
2947			fi
2948			if test ! -f win32/win32.c; then
2949				echo "Failed to create the symlinks (win32/win32.c missing).  Aborting." >&4
2950				exit 1
2951			fi
2952			cd UU
2953			;;
2954		*)	echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
2955			;;
2956		esac
2957		;;
2958	esac
2959	;;
2960esac
2961
2962: Check for Cross-Compilation
2963if $test "X$targethost" = "X"; then
2964    targethost=""
2965fi
2966if $test "X$targetenv" = "X"; then
2967    targetenv=""
2968fi
2969case "$usecrosscompile" in
2970$define|true|[yY]*)
2971	$echo "Cross-compiling..."
2972	croak=''
2973	case "$cc" in
2974	*-gcc*|*-g++*) # A cross-compiling gcc, probably.
2975	    # arm-linux-androideabi-gcc  -> arm-linux-androideabi
2976	    # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
2977	    targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
2978	    ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
2979	    # leave out ld, choosing it is more complex
2980	    nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
2981	    ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
2982	    # We are in a weird spot. Just before us, some values
2983	    # were 'saved', to be restored after the hints are
2984	    # run.  This means that the changes we made to ar,
2985	    # nm and ranlib will get reverted.
2986	    # To avoid that, we hijack the saving mechanism and
2987	    # have it save our new values.
2988	    for file in ar nm ranlib; do
2989		eval xxx=\$$file
2990		eval $file=$xxx$_exe
2991		eval _$file=$xxx
2992	    done
2993	;;
2994	esac
2995	case "$targetarch" in
2996	'') echo "Targetarch not defined." >&4; croak=y ;;
2997	*)  echo "Using targetarch $targetarch." >&4 ;;
2998	esac
2999	case "$targethost" in
3000	'') echo "Targethost not defined." >&4; croak=n ;;
3001	*)  echo "Using targethost $targethost." >&4
3002	esac
3003	locincpth=' '
3004	loclibpth=' '
3005	case "$croak" in
3006	y) echo "Cannot continue, aborting." >&4; exit 1 ;;
3007	esac
3008    : compile a host miniperl and generate_uudmap, unless we got passed them
3009    if $test "X$hostperl" = X; then
3010      echo "Building host miniperl and generate_uudmap binaries" >&4
3011      before_host=`pwd`
3012      cd ..
3013      cd $src
3014      src=`pwd`
3015      rm -rf $src/host
3016      mkdir $src/host
3017      cd $src/host
3018      $src/Configure -des -Dusedevel -Dmksymlinks
3019      $make miniperl
3020      case "$hostgenerate" in
3021      '') $make generate_uudmap
3022          hostgenerate=$src/host/generate_uudmap
3023          ;;
3024       "$undef") hostgenerate=''
3025          ;;
3026      esac
3027      hostperl=$src/host/miniperl
3028      cd $before_host
3029    fi
3030    hostosname=`$hostperl -le 'print $^O'`
3031    ;;
3032*)
3033    usecrosscompile="$undef"
3034    ;;
3035esac
3036
3037: Define -Dtargethost=somecomputer to run compiled tests on another machine
3038case "$targethost" in
3039    '') echo "Checking for cross-compile" >&4
3040    case "$usecrosscompile$multiarch" in
3041       *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
3042         if [ -f Makefile ]; then
3043           echo " "
3044           echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
3045         else
3046           echo "Configure done."
3047         fi
3048       exit 0
3049       ;;
3050     *) echo "No targethost for running compiler tests against defined, running locally" >&4
3051        run=''
3052        to=:
3053        from=:
3054        ;;
3055    esac
3056    ;;
3057    *) echo "Using targethost $targethost." >&4
3058	case "$src" in
3059	/*) run=$src/Cross/run
3060	    targetmkdir=$src/Cross/mkdir
3061	    to=$src/Cross/to
3062	    from=$src/Cross/from
3063	    ;;
3064	*)  pwd=`$test -f ../Configure & cd ..; pwd`
3065	    run=$pwd/Cross/run
3066	    targetmkdir=$pwd/Cross/mkdir
3067	    to=$pwd/Cross/to
3068	    from=$pwd/Cross/from
3069	    ;;
3070	esac
3071	case "$targetrun" in
3072	'') targetrun=ssh ;;
3073	esac
3074	case "$targetto" in
3075	'') targetto=scp ;;
3076	esac
3077	case "$targetfrom" in
3078	'') targetfrom=scp ;;
3079	esac
3080	run=$run-$targetrun
3081	to=$to-$targetto
3082	from=$from-$targetfrom
3083	case "$targetdir" in
3084	'')  targetdir=/tmp
3085	     echo "Guessing targetdir $targetdir." >&4
3086	     ;;
3087	esac
3088	case "$targetuser" in
3089	'')  targetuser=root
3090	     echo "Guessing targetuser $targetuser." >&4
3091	     ;;
3092	esac
3093	case "$targetport" in
3094	'')  targetport=22
3095	     echo "Guessing targetport $targetport." >&4
3096	     ;;
3097	esac
3098	case "$targetfrom" in
3099	scp)	q=-q ;;
3100	*)	q='' ;;
3101	esac
3102	case "$targetrun" in
3103	ssh|rsh)
3104	    cat >$run <<EOF
3105#!/bin/sh
3106env=''
3107case "\$1" in
3108-cwd)
3109  shift
3110  cwd=\$1
3111  shift
3112  ;;
3113esac
3114case "\$1" in
3115-env)
3116  shift
3117  env=\$1
3118  shift
3119  ;;
3120esac
3121case "\$cwd" in
3122'') cwd=$targetdir ;;
3123esac
3124exe=\$1
3125shift
3126$to \$exe
3127$targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
3128EOF
3129	    ;;
3130	adb)
3131	    $touch $run
3132	    ;;
3133	*)  echo "Unknown targetrun '$targetrun'" >&4
3134	    exit 1
3135	    ;;
3136	esac
3137	case "$targetmkdir" in
3138	*/Cross/mkdir)
3139	    cat >$targetmkdir <<EOF
3140#!/bin/sh
3141$targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
3142EOF
3143	    $chmod a+rx $targetmkdir
3144	    ;;
3145	*)  echo "Unknown targetmkdir '$targetmkdir'" >&4
3146	    exit 1
3147	    ;;
3148	esac
3149	case "$targetto" in
3150	scp|rcp)
3151	    cat >$to <<EOF
3152#!/bin/sh
3153for f in \$@
3154do
3155  case "\$f" in
3156  /*)
3157    $targetmkdir \`dirname \$f\`
3158    $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f           2>/dev/null  || exit 1
3159    ;;
3160  *)
3161    $targetmkdir $targetdir/\`dirname \$f\`
3162    $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
3163    ;;
3164  esac
3165done
3166exit 0
3167EOF
3168	    ;;
3169	cp) cat >$to <<EOF
3170#!/bin/sh
3171for f in \$@
3172do
3173  case "\$f" in
3174  /*)
3175    $mkdir -p $targetdir/\`dirname \$f\`
3176    $cp \$f $targetdir/\$f || exit 1
3177    ;;
3178  *)
3179    $targetmkdir $targetdir/\`dirname \$f\`
3180    $cp \$f $targetdir/\$f || exit 1
3181    ;;
3182  esac
3183done
3184exit 0
3185EOF
3186	    ;;
3187	*)  echo "Unknown targetto '$targetto'" >&4
3188	    exit 1
3189	    ;;
3190	esac
3191	case "$targetfrom" in
3192	scp|rcp)
3193	  cat >$from <<EOF
3194#!/bin/sh
3195for f in \$@
3196do
3197  $rm -f \$f
3198  $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
3199done
3200exit 0
3201EOF
3202	    ;;
3203	cp) cat >$from <<EOF
3204#!/bin/sh
3205for f in \$@
3206do
3207  $rm -f \$f
3208  cp $targetdir/\$f . || exit 1
3209done
3210exit 0
3211EOF
3212	    ;;
3213	*)  echo "Unknown targetfrom '$targetfrom'" >&4
3214	    exit 1
3215	    ;;
3216	esac
3217	if $test ! -f $run; then
3218	    echo "Target 'run' script '$run' not found." >&4
3219	else
3220	    $chmod a+rx $run
3221	fi
3222	if $test ! -f $to; then
3223	    echo "Target 'to' script '$to' not found." >&4
3224	else
3225	    $chmod a+rx $to
3226	fi
3227	if $test ! -f $from; then
3228	    echo "Target 'from' script '$from' not found." >&4
3229	else
3230	    $chmod a+rx $from
3231	fi
3232	if $test ! -f $run -o ! -f $to -o ! -f $from; then
3233	    exit 1
3234	fi
3235	cat >&4 <<EOF
3236Using '$run' for remote execution,
3237and '$from' and '$to'
3238for remote file transfer.
3239EOF
3240	;;
3241*)	run=''
3242	to=:
3243	from=:
3244	usecrosscompile="$undef"
3245	targetarch=''
3246	;;
3247esac
3248
3249: see whether [:lower:] and [:upper:] are supported character classes
3250echo " "
3251case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | $tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
3252ABYZ-abyz)
3253	echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
3254	up='[:upper:]'
3255	low='[:lower:]'
3256	;;
3257*)	# There is a discontinuity in EBCDIC between 'R' and 'S'
3258	# (0xd9 and 0xe2), therefore that is a nice testing point.
3259	if test "X$up" = X -o "X$low" = X; then
3260	    case "`echo RS | $tr '[R-S]' '[r-s]' 2>/dev/null`" in
3261	    rs) up='[A-Z]'
3262		low='[a-z]'
3263		;;
3264	    esac
3265	fi
3266	if test "X$up" = X -o "X$low" = X; then
3267	    case "`echo RS | $tr R-S r-s 2>/dev/null`" in
3268	    rs) up='A-Z'
3269		low='a-z'
3270		;;
3271	    esac
3272	fi
3273	if test "X$up" = X -o "X$low" = X; then
3274	    case "`echo RS | od -x 2>/dev/null`" in
3275	    *D9E2*|*d9e2*)
3276		echo "Hey, this might be EBCDIC." >&4
3277		if test "X$up" = X -o "X$low" = X; then
3278		    case "`echo RS | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
3279		    rs) up='[A-IJ-RS-Z]'
3280			low='[a-ij-rs-z]'
3281			;;
3282		    esac
3283		fi
3284		if test "X$up" = X -o "X$low" = X; then
3285		    case "`echo RS | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
3286		    rs) up='A-IJ-RS-Z'
3287			low='a-ij-rs-z'
3288			;;
3289		    esac
3290		fi
3291		;;
3292	    esac
3293	fi
3294esac
3295case "`echo RS | $tr \"$up\" \"$low\" 2>/dev/null`" in
3296rs)
3297    echo "Using $up and $low to convert case." >&4
3298    ;;
3299*)
3300    echo "I don't know how to translate letters from upper to lower case." >&4
3301    echo "Your tr is not acting any way I know of." >&4
3302    exit 1
3303    ;;
3304esac
3305: set up the translation script tr, must be called with ./tr of course
3306cat >tr <<EOSC
3307$startsh
3308case "\$1\$2" in
3309'[A-Z][a-z]') exec $tr '$up' '$low';;
3310'[a-z][A-Z]') exec $tr '$low' '$up';;
3311esac
3312exec $tr "\$@"
3313EOSC
3314chmod +x tr
3315$eunicefix tr
3316
3317: Try to determine whether config.sh was made on this system
3318case "$config_sh" in
3319'')
3320myuname=`$uname -a 2>/dev/null`
3321$test -z "$myuname" && myuname=`hostname 2>/dev/null`
3322# Downcase everything to avoid ambiguity.
3323# Remove slashes and single quotes so we can use parts of this in
3324# directory and file names.
3325# Remove newlines so myuname is sane to use elsewhere.
3326# tr '[A-Z]' '[a-z]' would not work in EBCDIC
3327# because the A-Z/a-z are not consecutive.
3328myuname=`echo $myuname | $sed -e "s,['/],,g" | \
3329	./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
3330newmyuname="$myuname"
3331dflt=n
3332case "$knowitall" in
3333'')
3334	if test -f ../config.sh; then
3335		if $contains myuname= ../config.sh >/dev/null 2>&1; then
3336			eval "`grep myuname= ../config.sh`"
3337		fi
3338		if test "X$myuname" = "X$newmyuname"; then
3339			dflt=y
3340		fi
3341	fi
3342	;;
3343*) dflt=y;;
3344esac
3345
3346: Get old answers from old config file if Configure was run on the
3347: same system, otherwise use the hints.
3348hint=default
3349cd ..
3350if test -f config.sh; then
3351	echo " "
3352	rp="I see a config.sh file.  Shall I use it to set the defaults?"
3353	. UU/myread
3354	case "$ans" in
3355	n*|N*) echo "OK, I'll ignore it."
3356		mv config.sh config.sh.old
3357		myuname="$newmyuname"
3358		;;
3359	*)  echo "Fetching default answers from your old config.sh file..." >&4
3360		tmp_n="$n"
3361		tmp_c="$c"
3362		tmp_sh="$sh"
3363		. ./config.sh
3364		cp config.sh UU
3365		n="$tmp_n"
3366		c="$tmp_c"
3367		: Older versions did not always set $sh.  Catch re-use of such
3368		: an old config.sh.
3369		case "$sh" in
3370		'') sh="$tmp_sh" ;;
3371		esac
3372		hint=previous
3373		;;
3374	esac
3375fi
3376. ./UU/checkcc
3377if test ! -f config.sh; then
3378	$cat <<EOM
3379
3380First time through, eh?  I have some defaults handy for some systems
3381that need some extra help getting the Configure answers right:
3382
3383EOM
3384	(cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
3385	dflt=''
3386	: Half the following guesses are probably wrong... If you have better
3387	: tests or hints, please send them to https://github.com/Perl/perl5/issues
3388	: The metaconfig authors would also appreciate a copy...
3389	$test -f /irix && osname=irix
3390	$test -f /xenix && osname=sco_xenix
3391	$test -f /dynix && osname=dynix
3392	$test -f /dnix && osname=dnix
3393	$test -f /lynx.os && osname=lynxos
3394	$test -f /unicos && osname=unicos && osvers=`$uname -r`
3395	$test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
3396	$test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
3397	$test -f /bin/mips && /bin/mips && osname=mips
3398	$test -d /usr/apollo/bin && osname=apollo
3399	$test -f /etc/saf/_sactab && osname=svr4
3400	$test -d /usr/include/minix && osname=minix && osvers=`$uname -r`
3401	$test -f /system/gnu_library/bin/ar.pm && osname=vos
3402	$test -f /sys/utilities/MultiView && osname=amigaos
3403	if $test -d /MachTen -o -d /MachTen_Folder; then
3404		osname=machten
3405		if $test -x /sbin/version; then
3406			osvers=`/sbin/version | $awk '{print $2}' |
3407			$sed -e 's/[A-Za-z]$//'`
3408		elif $test -x /usr/etc/version; then
3409			osvers=`/usr/etc/version | $awk '{print $2}' |
3410			$sed -e 's/[A-Za-z]$//'`
3411		else
3412			osvers="$2.$3"
3413		fi
3414	fi
3415
3416	$test -f /sys/posix.dll &&
3417		$test -f /usr/bin/what &&
3418		set X `/usr/bin/what /sys/posix.dll` &&
3419		$test "$3" = UWIN &&
3420		osname=uwin &&
3421		osvers="$5"
3422
3423	if $test -f $uname; then
3424		set X $myuname
3425		shift
3426
3427		case "$5" in
3428		fps*) osname=fps ;;
3429		mips*)
3430			case "$4" in
3431			umips) osname=umips ;;
3432			*) osname=mips ;;
3433			esac;;
3434		[23]100) osname=mips ;;
3435		i386*)
3436			tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
3437			if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
3438				osname='sco'
3439				osvers=$tmp
3440			elif $test -f /etc/kconfig; then
3441				osname=isc
3442				if test "$lns" = "$ln -s"; then
3443					osvers=4
3444				elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
3445					osvers=3
3446				elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
3447					osvers=2
3448				fi
3449			fi
3450			tmp=''
3451			;;
3452		pc*)
3453			if test -n "$DJGPP"; then
3454				osname=dos
3455				osvers=djgpp
3456			fi
3457			;;
3458		esac
3459
3460		case "$1" in
3461		aix) osname=aix
3462			tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
3463			case "$tmp" in
3464			# oslevel can fail with:
3465			# oslevel: Unable to acquire lock.
3466			*not\ found) osvers="$4"."$3" ;;
3467			'<3240'|'<>3240') osvers=3.2.0 ;;
3468			'=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
3469			'=3250'|'>3250') osvers=3.2.5 ;;
3470			*) osvers=$tmp;;
3471			esac
3472			;;
3473		bitrig) osname=bitrig
3474			osvers="$3"
3475			;;
3476		bsd386) osname=bsd386
3477			osvers=`$uname -r`
3478			;;
3479		cygwin*) osname=cygwin
3480			osvers="$3"
3481			;;
3482		*dc.osx) osname=dcosx
3483			osvers="$3"
3484			;;
3485		dnix) osname=dnix
3486			osvers="$3"
3487			;;
3488		domainos) osname=apollo
3489			osvers="$3"
3490			;;
3491		dgux)	osname=dgux
3492			osvers="$3"
3493			;;
3494		dragonfly) osname=dragonfly
3495			osvers="$3"
3496			;;
3497		dynixptx*) osname=dynixptx
3498			osvers=`echo "$4"|sed 's/^v//'`
3499			;;
3500		freebsd) osname=freebsd
3501			osvers="$3" ;;
3502		genix)	osname=genix ;;
3503		gnu)	osname=gnu
3504			osvers="$3" ;;
3505		hp*)	osname=hpux
3506			osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
3507			;;
3508		irix*)	osname=irix
3509			case "$3" in
3510			4*) osvers=4 ;;
3511			5*) osvers=5 ;;
3512			*)	osvers="$3" ;;
3513			esac
3514			;;
3515		linux)	osname=linux
3516			case "$3" in
3517			*)	osvers="$3" ;;
3518			esac
3519			$test -f /system/lib/libandroid.so && osname=linux-android
3520			;;
3521		MiNT)	osname=mint
3522			;;
3523		minix)	osname=minix
3524			osvers=`$uname -r`
3525			;;
3526		netbsd*) osname=netbsd
3527			osvers="$3"
3528			;;
3529		news-os) osvers="$3"
3530			case "$3" in
3531			4*) osname=newsos4 ;;
3532			*) osname=newsos ;;
3533			esac
3534			;;
3535		nonstop-ux) osname=nonstopux ;;
3536		openbsd) osname=openbsd
3537			osvers="$3"
3538			;;
3539		os2)	osname=os2
3540			osvers="$4"
3541			;;
3542		POSIX-BC | posix-bc ) osname=posix-bc
3543			osvers="$3"
3544			;;
3545		powerux | power_ux | powermax_os | powermaxos | \
3546		powerunix | power_unix) osname=powerux
3547			osvers="$3"
3548			;;
3549		qnx) osname=qnx
3550			osvers="$4"
3551			;;
3552		solaris) osname=solaris
3553			case "$3" in
3554			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3555			*)	osvers="$3" ;;
3556			esac
3557			;;
3558		sunos) osname=sunos
3559			case "$3" in
3560			5*) osname=solaris
3561				osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3562			*)	osvers="$3" ;;
3563			esac
3564			;;
3565		titanos) osname=titanos
3566			case "$3" in
3567			1*) osvers=1 ;;
3568			2*) osvers=2 ;;
3569			3*) osvers=3 ;;
3570			4*) osvers=4 ;;
3571			*)	osvers="$3" ;;
3572			esac
3573			;;
3574		ultrix) osname=ultrix
3575			osvers="$3"
3576			;;
3577		osf1|mls+)	case "$5" in
3578				alpha)
3579					osname=dec_osf
3580					osvers=`sizer -v | awk -FUNIX '{print $2}' | awk '{print $1}' |  tr '[A-Z]' '[a-z]' | sed 's/^[xvt]//'`
3581					case "$osvers" in
3582					[1-9].[0-9]*) ;;
3583					*) osvers=`echo "$3" | sed 's/^[xvt]//'` ;;
3584					esac
3585					;;
3586			hp*)	osname=hp_osf1	;;
3587			mips)	osname=mips_osf1 ;;
3588			esac
3589			;;
3590		# UnixWare 7.1.2 is known as Open UNIX 8
3591		openunix|unixware) osname=svr5
3592			osvers="$4"
3593			;;
3594		uts)	osname=uts
3595			osvers="$3"
3596			;;
3597		vos) osvers="$3"
3598			;;
3599		$2) case "$osname" in
3600			*isc*) ;;
3601			*freebsd*) ;;
3602			svr*)
3603				: svr4.x or possibly later
3604				case "svr$3" in
3605				${osname}*)
3606					osname=svr$3
3607					osvers=$4
3608					;;
3609				esac
3610				case "$osname" in
3611				svr4.0)
3612					: Check for ESIX
3613					if test -f /stand/boot ; then
3614						eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
3615						if test -n "$INITPROG" -a -f "$INITPROG"; then
3616			isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
3617							if test -n "$isesix"; then
3618								osname=esix4
3619							fi
3620						fi
3621					fi
3622					;;
3623				esac
3624				;;
3625			*)	if test -f /etc/systemid; then
3626					osname=sco
3627					set `echo $3 | $sed 's/\./ /g'` $4
3628					if $test -f $src/hints/sco_$1_$2_$3.sh; then
3629						osvers=$1.$2.$3
3630					elif $test -f $src/hints/sco_$1_$2.sh; then
3631						osvers=$1.$2
3632					elif $test -f $src/hints/sco_$1.sh; then
3633						osvers=$1
3634					fi
3635				else
3636					case "$osname" in
3637					'') : Still unknown.  Probably a generic Sys V.
3638						osname="sysv"
3639						osvers="$3"
3640						;;
3641					esac
3642				fi
3643				;;
3644			esac
3645			;;
3646		*)	case "$osname" in
3647			'') : Still unknown.  Probably a generic BSD.
3648				osname="$1"
3649				osvers="$3"
3650				;;
3651			esac
3652			;;
3653		esac
3654	else
3655		if test -f /vmunix -a -f $src/hints/news_os.sh; then
3656			(what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
3657			if $contains news-os UU/kernel.what >/dev/null 2>&1; then
3658				osname=news_os
3659			fi
3660			$rm -f UU/kernel.what
3661		elif test -d c:/. -o -n "$is_os2" ; then
3662			set X $myuname
3663			osname=os2
3664			osvers="$5"
3665		fi
3666	fi
3667
3668        case "$targetarch" in
3669        '') ;;
3670        *)  hostarch=$osname
3671            case "$targetarch" in
3672                nto*|*-nto-*)
3673                    # Will load qnx.sh, which should change osname to nto
3674                    osname=qnx
3675                    osvers=''
3676                    ;;
3677                *linux-android*)
3678                    # Catch arm-linux-androideabi, mipsel-linux-android,
3679                    # and i686-linux-android
3680                    osname=linux-android
3681                    osvers=''
3682                    ;;
3683                *linux*)
3684                    # Something like arm-linux-gnueabihf is really just
3685                    # plain linux.
3686                    osname=linux
3687                    osvers=''
3688                    ;;
3689                *solaris*|*sunos*)
3690                    osname=solaris
3691                    # XXX perhaps we should just assume
3692                    # osvers to be 2, or maybe take the value
3693                    # from targetarch. Using $run before the
3694                    # hints are run is somewhat icky.
3695                    set X `$run $uname -a 2>/dev/null`
3696                    shift
3697                    case "$3" in
3698                        5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3699                        *)  osvers="$3" ;;
3700                    esac
3701                    ;;
3702                *)
3703		    osname=`echo $targetarch|sed 's,^[^-]*-,,'`
3704		    osvers=''
3705                ;;
3706            esac
3707            ;;
3708        esac
3709
3710	: Now look for a hint file osname_osvers, unless one has been
3711	: specified already.
3712	case "$hintfile" in
3713	''|' ')
3714		file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'`
3715		: Also try without trailing minor version numbers.
3716		xfile=`echo $file | $sed -e 's%_[^_]*$%%'`
3717		xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'`
3718		xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'`
3719		xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'`
3720		case "$file" in
3721		'') dflt=none ;;
3722		*)  case "$osvers" in
3723			'') dflt=$file
3724				;;
3725			*)  if $test -f $src/hints/$file.sh ; then
3726					dflt=$file
3727				elif $test -f $src/hints/$xfile.sh ; then
3728					dflt=$xfile
3729				elif $test -f $src/hints/$xxfile.sh ; then
3730					dflt=$xxfile
3731				elif $test -f $src/hints/$xxxfile.sh ; then
3732					dflt=$xxxfile
3733				elif $test -f $src/hints/$xxxxfile.sh ; then
3734					dflt=$xxxxfile
3735				elif $test -f "$src/hints/${osname}.sh" ; then
3736					dflt="${osname}"
3737				else
3738					dflt=none
3739				fi
3740				;;
3741			esac
3742			;;
3743		esac
3744		if $test -f Policy.sh ; then
3745			case "$dflt" in
3746			*Policy*) ;;
3747			none) dflt="Policy" ;;
3748			*) dflt="Policy $dflt" ;;
3749			esac
3750		fi
3751		;;
3752	*)
3753		dflt=`echo $hintfile | $sed 's/\.sh$//'`
3754		;;
3755	esac
3756
3757	if $test -f Policy.sh ; then
3758		$cat <<EOM
3759
3760There's also a Policy hint file available, which should make the
3761site-specific (policy) questions easier to answer.
3762EOM
3763
3764	fi
3765
3766	$cat <<EOM
3767
3768You may give one or more space-separated answers, or "none" if appropriate.
3769If you have a handcrafted Policy.sh file or a Policy.sh file generated by a
3770previous run of Configure, you may specify it as well as or instead of
3771OS-specific hints.  If hints are provided for your OS, you should use them:
3772although Perl can probably be built without hints on many platforms, using
3773hints often improve performance and may enable features that Configure can't
3774set up on its own. If there are no hints that match your OS, specify "none";
3775DO NOT give a wrong version or a wrong OS.
3776
3777EOM
3778
3779	rp="Which of these apply, if any?"
3780	. UU/myread
3781	tans=$ans
3782	for file in $tans; do
3783		if $test X$file = XPolicy -a -f Policy.sh; then
3784			. Policy.sh
3785			$cat Policy.sh >> UU/config.sh
3786		elif $test -f $src/hints/$file.sh; then
3787			. $src/hints/$file.sh
3788			$cat $src/hints/$file.sh >> UU/config.sh
3789		elif $test X"$tans" = X -o X"$tans" = Xnone ; then
3790			: nothing
3791		else
3792			: Give one chance to correct a possible typo.
3793			echo "$file.sh does not exist"
3794			dflt=$file
3795			rp="hint to use instead?"
3796			. UU/myread
3797			for file in $ans; do
3798				if $test -f "$src/hints/$file.sh"; then
3799					. $src/hints/$file.sh
3800					$cat $src/hints/$file.sh >> UU/config.sh
3801				elif $test X$ans = X -o X$ans = Xnone ; then
3802					: nothing
3803				else
3804					echo "$file.sh does not exist -- ignored."
3805				fi
3806			done
3807		fi
3808	done
3809
3810	hint=recommended
3811	: Remember our hint file for later.
3812	if $test -f "$src/hints/$file.sh" ; then
3813		hintfile="$file"
3814	else
3815		hintfile=''
3816	fi
3817fi
3818cd UU
3819;;
3820*)
3821	echo " "
3822	echo "Fetching default answers from $config_sh..." >&4
3823	tmp_n="$n"
3824	tmp_c="$c"
3825	cd ..
3826	cp $config_sh config.sh 2>/dev/null
3827	chmod +w config.sh
3828	. ./config.sh
3829	cd UU
3830	cp ../config.sh .
3831	n="$tmp_n"
3832	c="$tmp_c"
3833	hint=previous
3834	;;
3835esac
3836. ./optdef.sh
3837
3838: Restore computed paths
3839for file in $loclist $trylist; do
3840	eval $file="\$_$file"
3841done
3842
3843cat << EOM
3844
3845Configure uses the operating system name and version to set some defaults.
3846The default value is probably right if the name rings a bell. Otherwise,
3847since spelling matters for me, either accept the default or answer "none"
3848to leave it blank.
3849
3850EOM
3851case "$osname" in
3852	''|' ')
3853		case "$hintfile" in
3854		''|' '|none) dflt=none ;;
3855		*)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
3856		esac
3857		;;
3858	*) dflt="$osname" ;;
3859esac
3860rp="Operating system name?"
3861. ./myread
3862case "$ans" in
3863none)  osname='' ;;
3864*) osname=`echo "$ans" | $sed -e 's/[ 	][	]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
3865esac
3866echo " "
3867case "$osvers" in
3868	''|' ')
3869		case "$hintfile" in
3870		''|' '|none) dflt=none ;;
3871		*)	dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
3872			dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
3873			case "$dflt" in
3874			''|' ') dflt=none ;;
3875			esac
3876			;;
3877		esac
3878		;;
3879	*) dflt="$osvers" ;;
3880esac
3881rp="Operating system version?"
3882. ./myread
3883case "$ans" in
3884none)  osvers='' ;;
3885*) osvers="$ans" ;;
3886esac
3887
3888
3889. ./posthint.sh
3890
3891: who configured the system
3892cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
3893case "$cf_by" in
3894"")
3895	cf_by=`(logname) 2>/dev/null`
3896	case "$cf_by" in
3897	"")
3898		cf_by=`(whoami) 2>/dev/null`
3899		case "$cf_by" in
3900		"") cf_by=unknown ;;
3901		esac ;;
3902	esac ;;
3903esac
3904
3905: decide how portable to be.  Allow command line overrides.
3906case "$d_portable" in
3907"$undef") ;;
3908*)	d_portable="$define" ;;
3909esac
3910
3911: set up shell script to do ~ expansion
3912cat >filexp <<EOSS
3913$startsh
3914: expand filename
3915case "\$1" in
3916 \~/*|\~)
3917	echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
3918	;;
3919 \~*)
3920	if $test -f /bin/csh; then
3921		/bin/csh -f -c "glob \$1"
3922		failed=\$?
3923		echo ""
3924		exit \$failed
3925	else
3926		name=\`$expr x\$1 : '..\([^/]*\)'\`
3927		dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
3928		if $test ! -d "\$dir"; then
3929			me=\`basename \$0\`
3930			echo "\$me: can't locate home directory for: \$name" >&2
3931			exit 1
3932		fi
3933		case "\$1" in
3934		*/*)
3935			echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
3936			;;
3937		*)
3938			echo \$dir
3939			;;
3940		esac
3941	fi
3942	;;
3943*)
3944	echo \$1
3945	;;
3946esac
3947EOSS
3948chmod +x filexp
3949$eunicefix filexp
3950
3951: now set up to get a file name
3952cat <<EOS >getfile
3953$startsh
3954EOS
3955cat <<'EOSC' >>getfile
3956tilde=''
3957fullpath=''
3958already=''
3959skip=''
3960none_ok=''
3961exp_file=''
3962nopath_ok=''
3963orig_rp="$rp"
3964orig_dflt="$dflt"
3965case "$gfpth" in
3966'') gfpth='.' ;;
3967esac
3968
3969case "$fn" in
3970*\(*)
3971	: getfile will accept an answer from the comma-separated list
3972	: enclosed in parentheses even if it does not meet other criteria.
3973	expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
3974	fn=`echo $fn | sed 's/(.*)//'`
3975	;;
3976esac
3977
3978case "$fn" in
3979*:*)
3980	loc_file=`expr $fn : '.*:\(.*\)'`
3981	fn=`expr $fn : '\(.*\):.*'`
3982	;;
3983esac
3984
3985case "$fn" in
3986*~*) tilde=true;;
3987esac
3988case "$fn" in
3989*/*) fullpath=true;;
3990esac
3991case "$fn" in
3992*+*) skip=true;;
3993esac
3994case "$fn" in
3995*n*) none_ok=true;;
3996esac
3997case "$fn" in
3998*e*) exp_file=true;;
3999esac
4000case "$fn" in
4001*p*) nopath_ok=true;;
4002esac
4003
4004case "$fn" in
4005*f*) type='File';;
4006*d*) type='Directory';;
4007*l*) type='Locate';;
4008esac
4009
4010what="$type"
4011case "$what" in
4012Locate) what='File';;
4013esac
4014
4015case "$exp_file" in
4016'')
4017	case "$d_portable" in
4018	"$define") ;;
4019	*) exp_file=true;;
4020	esac
4021	;;
4022esac
4023
4024cd ..
4025while test "$type"; do
4026	redo=''
4027	rp="$orig_rp"
4028	dflt="$orig_dflt"
4029	case "$tilde" in
4030	true) rp="$rp (~name ok)";;
4031	esac
4032	. UU/myread
4033	if test -f UU/getfile.ok && \
4034		$contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
4035	then
4036		value="$ans"
4037		ansexp="$ans"
4038		break
4039	fi
4040	case "$ans" in
4041	none)
4042		value=''
4043		ansexp=''
4044		case "$none_ok" in
4045		true) type='';;
4046		esac
4047		;;
4048	*)
4049		case "$tilde" in
4050		'') value="$ans"
4051			ansexp="$ans";;
4052		*)
4053			value=`UU/filexp $ans`
4054			case $? in
4055			0)
4056				if test "$ans" != "$value"; then
4057					echo "(That expands to $value on this system.)"
4058				fi
4059				;;
4060			*) value="$ans";;
4061			esac
4062			ansexp="$value"
4063			case "$exp_file" in
4064			'') value="$ans";;
4065			esac
4066			;;
4067		esac
4068		case "$fullpath" in
4069		true)
4070			case "$ansexp" in
4071			/*) value="$ansexp" ;;
4072			[a-zA-Z]:/*) value="$ansexp" ;;
4073			*)
4074				redo=true
4075				case "$already" in
4076				true)
4077				echo "I shall only accept a full path name, as in /bin/ls." >&4
4078				echo "Use a ! shell escape if you wish to check pathnames." >&4
4079					;;
4080				*)
4081				echo "Please give a full path name, starting with slash." >&4
4082					case "$tilde" in
4083					true)
4084				echo "Note that using ~name is ok provided it expands well." >&4
4085						already=true
4086						;;
4087					esac
4088				esac
4089				;;
4090			esac
4091			;;
4092		esac
4093		case "$redo" in
4094		'')
4095			case "$type" in
4096			File)
4097				for fp in $gfpth; do
4098					if test "X$fp" = X.; then
4099					    pf="$ansexp"
4100					else
4101					    pf="$fp/$ansexp"
4102					fi
4103					if test -f "$pf"; then
4104						type=''
4105					elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
4106					then
4107						echo "($value is not a plain file, but that's ok.)"
4108						type=''
4109					fi
4110					if test X"$type" = X; then
4111					    value="$pf"
4112					    break
4113					fi
4114				done
4115				;;
4116			Directory)
4117				for fp in $gfpth; do
4118					if test "X$fp" = X.; then
4119					    dir="$ans"
4120					    direxp="$ansexp"
4121					else
4122					    dir="$fp/$ansexp"
4123					    direxp="$fp/$ansexp"
4124					fi
4125					if test -d "$direxp"; then
4126						type=''
4127						value="$dir"
4128						break
4129					fi
4130				done
4131				;;
4132			Locate)
4133				if test -d "$ansexp"; then
4134					echo "(Looking for $loc_file in directory $value.)"
4135					value="$value/$loc_file"
4136					ansexp="$ansexp/$loc_file"
4137				fi
4138				if test -f "$ansexp"; then
4139					type=''
4140				fi
4141				case "$nopath_ok" in
4142				true)	case "$value" in
4143					*/*) ;;
4144					*)	echo "Assuming $value will be in people's path."
4145						type=''
4146						;;
4147					esac
4148					;;
4149				esac
4150				;;
4151			esac
4152
4153			case "$skip" in
4154			true) type='';
4155			esac
4156
4157			case "$type" in
4158			'') ;;
4159			*)
4160				if test "$fastread" = yes; then
4161					dflt=y
4162				else
4163					dflt=n
4164				fi
4165				rp="$what $value doesn't exist.  Use that name anyway?"
4166				. UU/myread
4167				dflt=''
4168				case "$ans" in
4169				y*) type='';;
4170				*) echo " ";;
4171				esac
4172				;;
4173			esac
4174			;;
4175		esac
4176		;;
4177	esac
4178done
4179cd UU
4180ans="$value"
4181rp="$orig_rp"
4182dflt="$orig_dflt"
4183rm -f getfile.ok
4184test "X$gfpthkeep" != Xy && gfpth=""
4185EOSC
4186
4187: determine root of directory hierarchy where package will be installed.
4188case "$prefix" in
4189'')	dflt=`./loc . /usr/local /usr/local /local /opt /usr`
4190	;;
4191*)	dflt="$prefix"
4192	;;
4193esac
4194$cat <<EOM
4195
4196By default, $package will be installed in $dflt/bin, manual pages
4197under $dflt/man, etc..., i.e. with $dflt as prefix for all
4198installation directories. Typically this is something like /usr/local.
4199If you wish to have binaries under /usr/bin but other parts of the
4200installation under /usr/local, that's ok: you will be prompted
4201separately for each of the installation directories, the prefix being
4202only used to set the defaults.
4203
4204EOM
4205fn=d~
4206rp='Installation prefix to use?'
4207. ./getfile
4208oldprefix=''
4209case "$prefix" in
4210'')	;;
4211*)	case "$ans" in
4212	"$prefix") ;;
4213	*) oldprefix="$prefix";;
4214	esac
4215	;;
4216esac
4217
4218case "$ans" in
4219*?/)	prefix=`echo "$ans" | sed 's/.$//'`
4220	;;
4221*)	prefix="$ans"
4222esac
4223
4224case "$ansexp" in
4225*?/)	prefixexp=`echo "$ansexp" | sed 's/.$//'`
4226	;;
4227*)	prefixexp="$ansexp"
4228esac
4229
4230: allow them to override the AFS root
4231case "$afsroot" in
4232'')	afsroot=/afs ;;
4233*)	afsroot=$afsroot ;;
4234esac
4235
4236: is AFS running?
4237echo " "
4238case "$afs" in
4239$define|true)	afs=true ;;
4240$undef|false)	afs=false ;;
4241*)	if $test -d $afsroot; then
4242		afs=true
4243	else
4244		afs=false
4245	fi
4246	;;
4247esac
4248if $afs; then
4249	echo "AFS may be running... I'll be extra cautious then..." >&4
4250else
4251	echo "AFS does not seem to be running..." >&4
4252fi
4253
4254: determine installation prefix for where package is to be installed.
4255if $afs; then
4256$cat <<EOM
4257
4258Since you are running AFS, I need to distinguish the directory in which
4259files will reside from the directory in which they are installed (and from
4260which they are presumably copied to the former directory by occult means).
4261
4262EOM
4263	case "$installprefix" in
4264	'') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
4265	*) dflt="$installprefix";;
4266	esac
4267else
4268$cat <<EOM
4269
4270In some special cases, particularly when building $package for distribution,
4271it is convenient to distinguish the directory in which files should be
4272installed from the directory ($prefix) in which they will
4273eventually reside.  For most users, these two directories are the same.
4274
4275EOM
4276	case "$installprefix" in
4277	'') dflt=$prefix ;;
4278	*) dflt=$installprefix;;
4279	esac
4280fi
4281fn=d~
4282rp='What installation prefix should I use for installing files?'
4283. ./getfile
4284installprefix="$ans"
4285installprefixexp="$ansexp"
4286
4287: Perform the prefixexp/installprefixexp correction if necessary
4288cat <<EOS >installprefix
4289$startsh
4290EOS
4291cat <<'EOSC' >>installprefix
4292: Change installation prefix, if necessary.
4293if $test X"$prefix" != X"$installprefix"; then
4294    eval "install${prefixvar}=\`echo \$${prefixvar}exp | sed \"s#^\$prefixexp#\$installprefixexp#\"\`"
4295else
4296    eval "install${prefixvar}=\"\$${prefixvar}exp\""
4297fi
4298EOSC
4299chmod +x installprefix
4300$eunicefix installprefix
4301
4302: Set variables such as privlib and privlibexp from the output of ./getfile
4303: performing the prefixexp/installprefixexp correction if necessary.
4304cat <<EOS >setprefixvar
4305$startsh
4306EOS
4307cat <<'EOSC' >>setprefixvar
4308eval "${prefixvar}=\"\$ans\""
4309eval "${prefixvar}exp=\"\$ansexp\""
4310. ./installprefix
4311EOSC
4312chmod +x setprefixvar
4313$eunicefix setprefixvar
4314
4315: set up the script used to warn in case of inconsistency
4316cat <<EOS >whoa
4317$startsh
4318EOS
4319cat <<'EOSC' >>whoa
4320dflt=y
4321case "$hint" in
4322    recommended)
4323	case "$hintfile" in
4324	'')	echo "The $hint value for \$$var on this machine was \"$was\"!" >&4
4325		;;
4326	*)	echo "Hmm.  Based on the hints in hints/$hintfile.sh, " >&4
4327		echo "the $hint value for \$$var on this machine was \"$was\"!" >&4
4328		;;
4329	esac
4330	;;
4331    *)	echo " "
4332	echo "*** WHOA THERE!!! ***" >&4
4333	echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
4334	;;
4335esac
4336rp="    Keep the $hint value?"
4337. ./myread
4338case "$ans" in
4339y) td=$was; tu=$was;;
4340esac
4341EOSC
4342
4343: function used to set '$1' to '$val'
4344setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
4345case "$val$was" in
4346$define$undef) . ./whoa; eval "$var=\$td";;
4347$undef$define) . ./whoa; eval "$var=\$tu";;
4348*) eval "$var=$val";;
4349esac'
4350
4351: Do we want threads support and if so, what type
4352case "$usethreads" in
4353$define|true|[yY]*)     dflt='y';;
4354*)     # Catch case where user specified ithreads but
4355       # forgot -Dusethreads (A.D. 4/2002)
4356       case "$useithreads" in
4357       *$define*)	dflt='y';;
4358       *)		dflt='n';;
4359       esac
4360       ;;
4361esac
4362cat <<EOM
4363
4364Perl can be built to offer a form of threading support on some systems
4365To do so, Configure can be run with -Dusethreads.
4366
4367Note that Perl built with threading support runs slightly slower
4368and uses slightly more memory than plain Perl.
4369
4370If this doesn't make any sense to you, just accept the default '$dflt'.
4371EOM
4372rp='Build a threading Perl?'
4373. ./myread
4374case "$ans" in
4375y|Y)    val="$define" ;;
4376*)      val="$undef" ;;
4377esac
4378set usethreads
4379eval $setvar
4380
4381useithreads="$usethreads"
4382
4383case "$d_oldpthreads" in
4384'')	: Configure tests would be welcome here.  For now, assume undef.
4385	val="$undef" ;;
4386*)	val="$d_oldpthreads" ;;
4387esac
4388set d_oldpthreads
4389eval $setvar
4390
4391
4392: Look for a hint-file generated 'call-back-unit'.  If the
4393: user has specified that a threading perl is to be built,
4394: we may need to set or change some other defaults.
4395if $test -f usethreads.cbu; then
4396    echo "Your platform has some specific hints regarding threaded builds, using them..."
4397    . ./usethreads.cbu
4398else
4399    case "$usethreads" in
4400	"$define"|true|[yY]*)
4401		$cat <<EOM
4402(Your platform does not have any specific hints for threaded builds.
4403 Assuming POSIX threads, then.)
4404EOM
4405	;;
4406    esac
4407fi
4408
4409: Check if multiplicity is required
4410cat <<EOM
4411
4412Perl can be built so that multiple Perl interpreters can coexist
4413within the same Perl executable.
4414EOM
4415
4416case "$useithreads" in
4417$define)
4418	cat <<EOM
4419This multiple interpreter support is required for interpreter-based threads.
4420EOM
4421	val="$define"
4422	;;
4423*)	case "$usemultiplicity" in
4424	$define|true|[yY]*)	dflt='y';;
4425	*) dflt='n';;
4426	esac
4427	echo " "
4428	echo "If this doesn't make any sense to you, just accept the default '$dflt'."
4429	rp='Build Perl for multiplicity?'
4430	. ./myread
4431	case "$ans" in
4432	y|Y)	val="$define" ;;
4433	*)      val="$undef" ;;
4434	esac
4435	;;
4436esac
4437set usemultiplicity
4438eval $setvar
4439
4440: Check if morebits is requested
4441case "$usemorebits" in
4442"$define"|true|[yY]*)
4443	use64bitint="$define"
4444	uselongdouble="$define"
4445	usemorebits="$define"
4446	;;
4447*)	usemorebits="$undef"
4448	;;
4449esac
4450
4451: Determine the C compiler to be used
4452echo " "
4453case "$cc" in
4454'') dflt=cc;;
4455*) dflt="$cc";;
4456esac
4457rp="Use which C compiler?"
4458. ./myread
4459cc="$ans"
4460
4461: See whether they have no cc but they do have gcc
4462. ./trygcc
4463if $test -f cc.cbu; then
4464    . ./cc.cbu
4465fi
4466. ./checkcc
4467
4468: make some quick guesses about what we are up against
4469echo " "
4470$echo $n "Hmm...  $c"
4471echo exit 1 >bsd
4472echo exit 1 >usg
4473echo exit 1 >v7
4474echo exit 1 >osf1
4475echo exit 1 >eunice
4476echo exit 1 >xenix
4477echo exit 1 >venix
4478echo exit 1 >os2
4479d_bsd="$undef"
4480$cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null
4481if test -f /osf_boot || $contains 'OSF/1' $sysroot/usr/include/ctype.h >/dev/null 2>&1
4482then
4483	echo "Looks kind of like an OSF/1 system, but we'll see..."
4484	echo exit 0 >osf1
4485elif test `echo abc | $tr a-z A-Z` = Abc ; then
4486	xxx=`./loc addbib blurfl $pth`
4487	if $test -f $xxx; then
4488	echo "Looks kind of like a USG system with BSD features, but we'll see..."
4489		echo exit 0 >bsd
4490		echo exit 0 >usg
4491	else
4492		if $contains SIGTSTP foo >/dev/null 2>&1 ; then
4493			echo "Looks kind of like an extended USG system, but we'll see..."
4494		else
4495			echo "Looks kind of like a USG system, but we'll see..."
4496		fi
4497		echo exit 0 >usg
4498	fi
4499elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
4500	echo "Looks kind of like a BSD system, but we'll see..."
4501	d_bsd="$define"
4502	echo exit 0 >bsd
4503else
4504	echo "Looks kind of like a Version 7 system, but we'll see..."
4505	echo exit 0 >v7
4506fi
4507case "$eunicefix" in
4508*unixtovms*)
4509	$cat <<'EOI'
4510There is, however, a strange, musty smell in the air that reminds me of
4511something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
4512EOI
4513	echo exit 0 >eunice
4514	d_eunice="$define"
4515: it so happens the Eunice I know will not run shell scripts in Unix format
4516	;;
4517*)
4518	echo " "
4519	echo "Congratulations.  You aren't running Eunice."
4520	d_eunice="$undef"
4521	;;
4522esac
4523: Detect OS2.  The p_ variable is set above in the Head.U unit.
4524: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
4525: semicolon as a patch separator
4526case "$p_" in
4527:) ;;
4528*)
4529	$cat <<'EOI'
4530I have the feeling something is not exactly right, however...don't tell me...
4531lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
4532(Or you may be running DOS with DJGPP.)
4533EOI
4534	echo exit 0 >os2
4535	;;
4536esac
4537if test -f /xenix; then
4538	echo "Actually, this looks more like a XENIX system..."
4539	echo exit 0 >xenix
4540	d_xenix="$define"
4541else
4542	echo " "
4543	echo "It's not Xenix..."
4544	d_xenix="$undef"
4545fi
4546chmod +x xenix
4547$eunicefix xenix
4548if test -f /venix; then
4549	echo "Actually, this looks more like a VENIX system..."
4550	echo exit 0 >venix
4551else
4552	echo " "
4553	if ./xenix; then
4554		: null
4555	else
4556		echo "Nor is it Venix..."
4557	fi
4558fi
4559chmod +x bsd usg v7 osf1 eunice xenix venix os2
4560$eunicefix bsd usg v7 osf1 eunice xenix venix os2
4561$rm -f foo
4562
4563: Check if we are using GNU gcc and what its version is
4564echo " "
4565echo "Checking for GNU cc in disguise and/or its version number..." >&4
4566$cat >try.c <<EOM
4567#include <stdio.h>
4568int main() {
4569#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
4570#ifdef __VERSION__
4571	printf("%s\n", __VERSION__);
4572#else
4573	printf("%s\n", "1");
4574#endif
4575#endif
4576	return(0);
4577}
4578EOM
4579if $cc -o try $ccflags $ldflags try.c; then
4580	gccversion=`$run ./try`
4581	case "$gccversion" in
4582	'') echo "You are not using GNU cc." ;;
4583	*)  echo "You are using GNU cc $gccversion."
4584	    ccname=gcc
4585	    ;;
4586	esac
4587else
4588	echo " "
4589	echo "*** WHOA THERE!!! ***" >&4
4590	echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
4591	case "$knowitall" in
4592	'')
4593	echo "    You'd better start hunting for one and let me know about it." >&4
4594		exit 1
4595		;;
4596	esac
4597fi
4598$rm -f try try.*
4599case "$gccversion" in
46001.*) cpp=`./loc gcc-cpp $cpp $pth` ;;
4601esac
4602case "$gccversion" in
4603'') gccosandvers='' ;;
4604*) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
4605   gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
4606   gccshortvers=''
4607   case "$gccosandvers" in
4608   $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
4609   $osname$osvers) ;; # looking good
4610   $osname*) cat <<EOM >&4
4611
4612*** WHOA THERE!!! ***
4613
4614    Your gcc has not been compiled for the exact release of
4615    your operating system ($gccosandvers versus $osname$osvers).
4616
4617    In general it is a good idea to keep gcc synchronized with
4618    the operating system because otherwise serious problems
4619    may ensue when trying to compile software, like Perl.
4620
4621    I'm trying to be optimistic here, though, and will continue.
4622    If later during the configuration and build icky compilation
4623    problems appear (headerfile conflicts being the most common
4624    manifestation), I suggest reinstalling the gcc to match
4625    your operating system release.
4626
4627EOM
4628      ;;
4629   *) gccosandvers='' ;; # failed to parse, better be silent
4630   esac
4631   ;;
4632esac
4633case "$ccname" in
4634'') ccname="$cc" ;;
4635esac
4636
4637# gcc 3.* complain about adding -Idirectories that they already know about,
4638# so we will take those off from locincpth.
4639case "$gccversion" in
46403.*)
4641    echo "main(){}">try.c
4642    for incdir in $locincpth; do
4643       warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
4644	     grep '^c[cp]p*[01]: warning: changing search order '`
4645       if test "X$warn" != X; then
4646	   locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
4647       fi
4648    done
4649    $rm -f try try.*
4650esac
4651
4652# gcc 4.9 by default does some optimizations that break perl.
4653# see ticket 121505.
4654#
4655# The -fwrapv disables those optimizations (and probably others,) so
4656# for gcc 4.9 (and later, since the optimizations probably won't go
4657# away), add -fwrapv unless the user requests -fno-wrapv, which
4658# disables -fwrapv, or if the user requests -fsanitize=undefined,
4659# which turns the overflows -fwrapv ignores into runtime errors.
4660case "$gccversion" in
46614.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*)
4662    case "$ccflags" in
4663    *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
4664    *) ccflags="$ccflags -fwrapv" ;;
4665    esac
4666esac
4667
4668# Really old versions of gcc default to C89 and will error for this code.
4669# See if the compiler (gcc or otherwise) needs a flag to compile C99 code
4670# Initialisations in for loops seem to be the particular problem
4671# (Does this syntax conflict with something else that was valid C89?)
4672# We also add a declaration after a statement to detect whether the compiler
4673# (or the user supplied -Accflags) consider such declarations to be errors.
4674# This causes 'Configure with -Accflags="-Werror=declaration-after-statement"'
4675# to fail hard and early.
4676#
4677# Annoyingly -std=c99 will cause gcc to tell glibc not to define prototypes for
4678# syscall, drand48 etc when including <unistd.h>, which messes up our build.
4679# I guess we *could* loop round trying -std=c99 first with checks both for the
4680# prototype found and the code compiling (because -std=gnu99 might do other
4681# things we don't want, particularly on non-GCC compilers) but
4682# 1) We would need to check for the prototype first (without any flags)
4683# 2) We would still end up with most Linux systems either being -std=gnu99
4684#    or "" (no flag), and so both common options would not rigorously check our
4685#    portability to other platforms.
4686# So it doesn't seem worth the complexity and chance of different failure.
4687$cat >try.c <<'EOCP'
4688int main(int argc, char **argv) {
4689    argc = argc + 1;
4690    /* This is deliberately a declaration after a statement. */
4691    unsigned long long count = 0;
4692    for (char **p = argv; *p; ++p) {
4693        ++count;
4694    }
4695    return count == 1 ? 0 : argc;
4696}
4697EOCP
4698c99_for=no
4699for flag in '' '-std=gnu99' '-std=c99'; do
4700    if $cc -o try $flag $ccflags $ldflags try.c 2>/dev/null && ./try; then
4701        c99_for="$flag"
4702        break;
4703    fi
4704done
4705case "$c99_for" in
4706'') echo "Your C compiler doesn't need any special flags to compile C99 code"
4707    ;;
4708no) echo >&4 "Your C compiler doesn't seem to be able to compile C99 code"
4709    rp='Do you really want to continue?'
4710    dflt='n'
4711    . ./myread
4712    case "$ans" in
4713	[yY])	echo >&4 "Okay, continuing."	;;
4714	*)	exit 1				;;
4715    esac
4716    ;;
4717*)  echo "Your C compiler needs $c99_for to compile C99 code"
4718    ccflags="$c99_for $ccflags"
4719    ;;
4720esac
4721$rm -f try try.*
4722
4723: What should the include directory be ?
4724: Use sysroot if set, so findhdr looks in the right place.
4725echo " "
4726$echo $n "Hmm...  $c"
4727dflt="$sysroot/usr/include"
4728incpath=''
4729mips_type=''
4730if $test -f /bin/mips && /bin/mips; then
4731	echo "Looks like a MIPS system..."
4732	$cat >usr.c <<'EOCP'
4733#ifdef SYSTYPE_BSD43
4734/bsd43
4735#endif
4736EOCP
4737	if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
4738		dflt='/bsd43/usr/include'
4739		incpath='/bsd43'
4740		mips_type='BSD 4.3'
4741	else
4742		mips_type='System V'
4743	fi
4744	$rm -f usr.c usr.out
4745	echo "and you're compiling with the $mips_type compiler and libraries."
4746	xxx_prompt=y
4747	echo "exit 0" >mips
4748else
4749	echo "Doesn't look like a MIPS system."
4750	xxx_prompt=n
4751	echo "exit 1" >mips
4752fi
4753chmod +x mips
4754$eunicefix mips
4755case "$usrinc" in
4756'') ;;
4757*) dflt="$usrinc";;
4758esac
4759case "$xxx_prompt" in
4760y)	fn=d/
4761	echo " "
4762	rp='Where are the include files you want to use?'
4763	. ./getfile
4764	usrinc="$ans"
4765	;;
4766*)	usrinc="$dflt"
4767	;;
4768esac
4769
4770: see how we invoke the C preprocessor
4771echo " "
4772echo "Now, how can we feed standard input to your C preprocessor..." >&4
4773cat <<'EOT' >testcpp.c
4774#define ABC abc
4775#define XYZ xyz
4776ABC.XYZ
4777EOT
4778cd ..
4779if test ! -f cppstdin; then
4780	if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
4781		# AIX cc -E doesn't show the absolute headerfile
4782		# locations but we'll cheat by using the -M flag.
4783		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
4784	else
4785		echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
4786	fi
4787else
4788	echo "Keeping your $hint cppstdin wrapper."
4789fi
4790chmod 755 cppstdin
4791wrapper=`pwd`/cppstdin
4792ok='false'
4793cd UU
4794
4795if $test "X$cppstdin" != "X" && \
4796	$cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
4797	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4798then
4799	echo "You used to use $cppstdin $cppminus so we'll use that again."
4800	case "$cpprun" in
4801	'') echo "But let's see if we can live without a wrapper..." ;;
4802	*)
4803		if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
4804			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4805		then
4806			echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
4807			ok='true'
4808		else
4809			echo "(However, $cpprun $cpplast does not work, let's see...)"
4810		fi
4811		;;
4812	esac
4813else
4814	case "$cppstdin" in
4815	'') ;;
4816	*)
4817		echo "Good old $cppstdin $cppminus does not seem to be of any help..."
4818		;;
4819	esac
4820fi
4821
4822if $ok; then
4823	: nothing
4824elif echo 'Maybe "'"$cc"' -E" will work...'; \
4825	$cc -E <testcpp.c >testcpp.out 2>&1; \
4826	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4827	echo "Yup, it does."
4828	x_cpp="$cc $cppflags -E"
4829	x_minus='';
4830elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
4831	$cc -E - <testcpp.c >testcpp.out 2>&1; \
4832	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4833	echo "Yup, it does."
4834	x_cpp="$cc $cppflags -E"
4835	x_minus='-';
4836elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
4837	$cc -P <testcpp.c >testcpp.out 2>&1; \
4838	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4839	echo "Yipee, that works!"
4840	x_cpp="$cc $cppflags -P"
4841	x_minus='';
4842elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
4843	$cc -P - <testcpp.c >testcpp.out 2>&1; \
4844	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4845	echo "At long last!"
4846	x_cpp="$cc $cppflags -P"
4847	x_minus='-';
4848elif echo 'No such luck, maybe "'$cpp'" will work...'; \
4849	$cpp <testcpp.c >testcpp.out 2>&1; \
4850	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4851	echo "It works!"
4852	x_cpp="$cpp $cppflags"
4853	x_minus='';
4854elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
4855	$cpp - <testcpp.c >testcpp.out 2>&1; \
4856	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4857	echo "Hooray, it works!  I was beginning to wonder."
4858	x_cpp="$cpp $cppflags"
4859	x_minus='-';
4860elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
4861	$wrapper <testcpp.c >testcpp.out 2>&1; \
4862	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4863	x_cpp="$wrapper"
4864	x_minus=''
4865	echo "Eureka!"
4866else
4867	dflt=''
4868	rp="No dice.  I can't find a C preprocessor.  Name one:"
4869	. ./myread
4870	x_cpp="$ans"
4871	x_minus=''
4872	$x_cpp <testcpp.c >testcpp.out 2>&1
4873	if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
4874		echo "OK, that will do." >&4
4875	else
4876echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
4877		exit 1
4878	fi
4879fi
4880
4881case "$ok" in
4882false)
4883	cppstdin="$x_cpp"
4884	cppminus="$x_minus"
4885	cpprun="$x_cpp"
4886	cpplast="$x_minus"
4887	set X $x_cpp
4888	shift
4889	case "$1" in
4890	"$cpp")
4891		echo "Perhaps can we force $cc -E using a wrapper..."
4892		if $wrapper <testcpp.c >testcpp.out 2>&1; \
4893			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4894		then
4895			echo "Yup, we can."
4896			cppstdin="$wrapper"
4897			cppminus='';
4898		else
4899			echo "Nope, we'll have to live without it..."
4900		fi
4901		;;
4902	esac
4903	case "$cpprun" in
4904	"$wrapper")
4905		cpprun=''
4906		cpplast=''
4907		;;
4908	esac
4909	;;
4910esac
4911
4912case "$cppstdin" in
4913"$wrapper"|'cppstdin') ;;
4914*) $rm -f $wrapper;;
4915esac
4916$rm -f testcpp.c testcpp.out
4917
4918: Adjust cppfilter for path component separator
4919case "$osname" in
4920vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
4921os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
4922*)   cppfilter='' ;;
4923esac
4924
4925: Use gcc to determine libpth and incpth
4926# If using gcc or clang, we can get better values for libpth, incpth
4927# and usrinc directly from the compiler.
4928# Note that ccname for clang is also gcc.
4929case "$ccname" in
4930    gcc)
4931	realpath=`which realpath 2>/dev/null | sed 's/no realpath in.*//'`
4932	$echo 'extern int foo;' > try.c
4933	set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
4934	shift
4935	inclibpth=""
4936	if $test $# -gt 0; then
4937	    for i in $*; do
4938		case $realpath in
4939		    */realpath) i=`$realpath $i` ;;
4940		esac
4941		incpth="$incpth $i"
4942		j="`$echo $i | $sed 's,/include[^/]*,/lib,'`"
4943		if $test -d $j; then
4944		    inclibpth="$inclibpth $j"
4945		fi
4946	    done
4947	    incpth="`$echo $incpth | $sed 's/^ //'`"
4948	    for xxx in $inclibpth $loclibpth $plibpth $glibpth; do
4949		if $test -d $xxx; then
4950		    case $realpath in
4951			*/realpath) xxx=`$realpath $xxx` ;;
4952		    esac
4953		    case " $libpth " in
4954		    *" $xxx "*) ;;
4955		    *) libpth="$libpth $xxx";;
4956		    esac
4957		fi
4958	    done
4959	    libpth="`$echo $libpth | $sed 's/^ //'`"
4960	fi
4961	$rm -f try.c
4962	case "$usrinc" in
4963	'') for i in $incpth; do
4964		if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
4965		    usrinc="$i"
4966		    break
4967		fi
4968	    done
4969	    ;;
4970	esac
4971
4972	case "$usecrosscompile" in
4973	$define|true|[yY]*)
4974	    case "$incpth" in
4975		'') echo "Incpth not defined." >&4; croak=y ;;
4976		*)  echo "Using incpth '$incpth'." >&4 ;;
4977	    esac
4978	    case "$libpth" in
4979		'') echo "Libpth not defined." >&4; croak=y ;;
4980		*)  echo "Using libpth '$libpth'." >&4 ;;
4981	    esac
4982	    case "$usrinc" in
4983		'') echo "Usrinc not defined." >&4; croak=y ;;
4984		*)  echo "Using usrinc $usrinc." >&4 ;;
4985	    esac
4986	    case "$croak" in
4987		y)
4988		if test "X$sysroot" = X; then
4989		    echo "Cannot continue, aborting." >&4; exit 1
4990		else
4991		    echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
4992		fi
4993		;;
4994	    esac
4995	    ;;
4996	esac
4997    ;;
4998esac
4999
5000: Default value for incpth is just usrinc
5001case "$incpth" in
5002'') incpth="$usrinc";;
5003esac
5004
5005: Set private lib path
5006case "$plibpth" in
5007'') if ./mips; then
5008	plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
5009    fi;;
5010esac
5011case "$libpth" in
5012' ') dlist='';;
5013'') dlist="$loclibpth $plibpth $glibpth";;
5014*) dlist="$libpth";;
5015esac
5016
5017: Now check and see which directories actually exist, avoiding duplicates
5018for xxx in $dlist
5019do
5020    if $test -d $xxx; then
5021		case " $libpth " in
5022		*" $xxx "*) ;;
5023		*) libpth="$libpth $xxx";;
5024		esac
5025    fi
5026done
5027$cat <<'EOM'
5028
5029Some systems have incompatible or broken versions of libraries.  Among
5030the directories listed in the question below, please remove any you
5031know not to be holding relevant libraries, and add any that are needed.
5032Say "none" for none.
5033
5034EOM
5035
5036if test "X$sysroot" != X; then
5037    $cat <<EOM
5038You have set sysroot to $sysroot, please supply the directories excluding sysroot
5039
5040EOM
5041fi
5042
5043case "$libpth" in
5044'') dflt='none';;
5045*)
5046	set X $libpth
5047	shift
5048	dflt=${1+"$@"}
5049	;;
5050esac
5051rp="Directories to use for library searches?"
5052. ./myread
5053case "$ans" in
5054none) libpth=' ';;
5055*) libpth="$ans";;
5056esac
5057
5058: compute shared library extension
5059case "$so" in
5060'')
5061	if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
5062		dflt='sl'
5063	else
5064		dflt='so'
5065	fi
5066	;;
5067*) dflt="$so";;
5068esac
5069$cat <<EOM
5070
5071On some systems, shared libraries may be available.  Answer 'none' if
5072you want to suppress searching of shared libraries for the remainder
5073of this configuration.
5074
5075EOM
5076rp='What is the file extension used for shared libraries?'
5077. ./myread
5078so="$ans"
5079
5080: Does target system insist that shared library basenames are unique
5081$cat << EOM
5082
5083Some dynamic loaders assume that the *basename* of shared library filenames
5084are globally unique.  We'll default this to undef as we assume your system
5085is not this weird. Set to defined if you're on one of them.
5086
5087EOM
5088
5089dflt='n'
5090rp='Make shared library basenames unique?'
5091. ./myread
5092case "$ans" in
5093y|Y) val="$define" ;;
5094*)   val="$undef"  ;;
5095esac
5096set d_libname_unique
5097eval $setvar
5098
5099: Define several unixisms.
5100: Hints files or command line option can be used to override them.
5101: The convoluted testing is in case hints files set either the old
5102: or the new name.
5103case "$_exe" in
5104'')	case "$exe_ext" in
5105	'')	;;
5106	*)	_exe="$exe_ext" ;;
5107	esac
5108	;;
5109esac
5110case "$_a" in
5111'')	case "$lib_ext" in
5112    '')	_a='.a';;
5113	*)	_a="$lib_ext" ;;
5114	esac
5115	;;
5116esac
5117case "$_o" in
5118'') case "$obj_ext" in
5119	'')	_o='.o';;
5120	*)	_o="$obj_ext";;
5121	esac
5122	;;
5123esac
5124case "$p_" in
5125'') case "$path_sep" in
5126	'')	p_=':';;
5127	*)	p_="$path_sep";;
5128	esac
5129	;;
5130esac
5131exe_ext=$_exe
5132lib_ext=$_a
5133obj_ext=$_o
5134path_sep=$p_
5135
5136rm_try="$rm -f try try$_exe a.out .out try.[cho] try.$_o core core.try* try.core*"
5137
5138: Which makefile gets called first.  This is used by make depend.
5139case "$firstmakefile" in
5140'') firstmakefile='makefile';;
5141esac
5142
5143: Check is we will use socks
5144case "$usesocks" in
5145$define|true|[yY]*)	dflt='y';;
5146*) dflt='n';;
5147esac
5148cat <<EOM
5149
5150Perl can be built to use the SOCKS proxy protocol library.  To do so,
5151Configure must be run with -Dusesocks.  If you use SOCKS you also need
5152to use the PerlIO abstraction layer, this will be implicitly selected.
5153
5154If this doesn't make any sense to you, just accept the default '$dflt'.
5155EOM
5156rp='Build Perl for SOCKS?'
5157. ./myread
5158case "$ans" in
5159y|Y)	val="$define" ;;
5160*)      val="$undef" ;;
5161esac
5162set usesocks
5163eval $setvar
5164
5165: Check for uselongdouble support
5166case "$ccflags" in
5167*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
5168esac
5169
5170case "$uselongdouble" in
5171$define|true|[yY]*)	dflt='y';;
5172*) dflt='n';;
5173esac
5174cat <<EOM
5175
5176Perl can be built to take advantage of long doubles which
5177(if available) may give more accuracy and range for floating point numbers.
5178
5179If this doesn't make any sense to you, just accept the default '$dflt'.
5180EOM
5181rp='Try to use long doubles if available?'
5182. ./myread
5183case "$ans" in
5184y|Y)	val="$define"	;;
5185*)      val="$undef"	;;
5186esac
5187set uselongdouble
5188eval $setvar
5189
5190case "$uselongdouble" in
5191true|[yY]*) uselongdouble="$define" ;;
5192esac
5193
5194: Look for a hint-file generated 'call-back-unit'.  If the
5195: user has specified that long doubles should be used,
5196: we may need to set or change some other defaults.
5197if $test -f uselongdouble.cbu; then
5198    echo "Your platform has some specific hints regarding long doubles, using them..."
5199    . ./uselongdouble.cbu
5200else
5201    case "$uselongdouble" in
5202	$define)
5203		$cat <<EOM
5204(Your platform does not have any specific hints for long doubles.)
5205EOM
5206	;;
5207    esac
5208fi
5209
5210: Check if quadmath is requested
5211case "$usequadmath" in
5212"$define"|true|[yY]*) usequadmath="$define" ;;
5213*)                    usequadmath="$undef"  ;;
5214esac
5215
5216: Fail if both uselongdouble and usequadmath are requested
5217case "$usequadmath:$uselongdouble" in
5218define:define)
5219	$cat <<EOM >&4
5220
5221*** You requested the use of the quadmath library and use
5222*** of long doubles.
5223***
5224*** Please select one or the other.
5225EOM
5226	exit 1
5227	;;
5228esac
5229
5230: Looking for optional libraries
5231echo " "
5232echo "Checking for optional libraries..." >&4
5233case "$libs" in
5234' '|'') dflt='';;
5235*) dflt="$libs";;
5236esac
5237case "$libswanted" in
5238'') libswanted='c_s';;
5239esac
5240case "$usesocks" in
5241"$define") libswanted="$libswanted socks5 socks5_sh" ;;
5242esac
5243case "$usecbacktrace" in
5244"$define") libswanted="$libswanted bfd" ;;
5245esac
5246case "$usequadmath" in
5247"$define") libswanted="$libswanted quadmath" ;;
5248esac
5249libsfound=''
5250libsfiles=''
5251libsdirs=''
5252libspath=''
5253for thisdir in $libpth $xlibpth; do
5254  test -d $thisdir && libspath="$libspath $thisdir"
5255done
5256for thislib in $libswanted; do
5257	for thisdir in $libspath; do
5258	    xxx=''
5259	    if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
5260		xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|sed -n '$p'`
5261	        $test -f "$xxx" && eval $libscheck
5262		$test -f "$xxx" && libstyle=shared
5263		xxx=`ls $thisdir/lib$thislib.[0-9].$so 2>/dev/null|sed -n '$p'`
5264	        $test -f "$xxx" && eval $libscheck
5265		$test -f "$xxx" && libstyle=shared
5266	    fi
5267	    if test ! -f "$xxx"; then
5268		xxx=$thisdir/lib$thislib.$so
5269	        $test -f "$xxx" && eval $libscheck
5270		$test -f "$xxx" && libstyle=shared
5271	    fi
5272	    if test ! -f "$xxx"; then
5273		xxx=$thisdir/lib$thislib$_a
5274	        $test -f "$xxx" && eval $libscheck
5275		$test -f "$xxx" && libstyle=static
5276	    fi
5277	    if test ! -f "$xxx"; then
5278		xxx=$thisdir/$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/lib${thislib}_s$_a
5284	        $test -f "$xxx" && eval $libscheck
5285		$test -f "$xxx" && libstyle=static
5286		$test -f "$xxx" && thislib=${thislib}_s
5287	    fi
5288	    if test ! -f "$xxx"; then
5289		xxx=$thisdir/Slib$thislib$_a
5290	        $test -f "$xxx" && eval $libscheck
5291		$test -f "$xxx" && libstyle=static
5292	    fi
5293	    if $test -f "$xxx"; then
5294		case "$libstyle" in
5295		shared) echo "Found -l$thislib (shared)." ;;
5296		static) echo "Found -l$thislib." ;;
5297		*)      echo "Found -l$thislib ($libstyle)." ;;
5298		esac
5299		case " $dflt " in
5300		*"-l$thislib "*);;
5301		*) dflt="$dflt -l$thislib"
5302                   libsfound="$libsfound $xxx"
5303                   yyy=`basename $xxx`
5304                   libsfiles="$libsfiles $yyy"
5305                   yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"`
5306                   case " $libsdirs " in
5307                   *" $yyy "*) ;;
5308                   *) libsdirs="$libsdirs $yyy" ;;
5309                   esac
5310		   ;;
5311		esac
5312		break
5313	    fi
5314	done
5315	if $test ! -f "$xxx"; then
5316	    echo "No -l$thislib."
5317	fi
5318done
5319set X $dflt
5320shift
5321dflt="$*"
5322case "$libs" in
5323'') dflt="$dflt";;
5324*) dflt="$libs";;
5325esac
5326case "$dflt" in
5327' '|'') dflt='none';;
5328esac
5329
5330$cat <<EOM
5331
5332In order to compile $package on your machine, a number of libraries
5333are usually needed.  Include any other special libraries here as well.
5334Say "none" for none.  The default list is almost always right.
5335EOM
5336
5337echo " "
5338rp="What libraries to use?"
5339. ./myread
5340case "$ans" in
5341none) libs=' ';;
5342*) libs="$ans";;
5343esac
5344
5345: determine optimization, if desired, or use for debug flag also
5346case "$optimize" in
5347' '|$undef) dflt='none';;
5348'') dflt='-O';;
5349*) dflt="$optimize";;
5350esac
5351$cat <<EOH
5352
5353By default, $package compiles with the -O flag to use the optimizer.
5354Alternately, you might want to use the symbolic debugger, which uses
5355the -g flag (on traditional Unix systems).  Either flag can be
5356specified here.  To use neither flag, specify the word "none".
5357
5358EOH
5359rp="What optimizer/debugger flag should be used?"
5360. ./myread
5361optimize="$ans"
5362case "$optimize" in
5363'none') optimize=" ";;
5364esac
5365
5366: Check what DEBUGGING is required from the command line
5367: -DEBUGGING      or -DDEBUGGING or
5368: -DEBUGGING=both			= -g + -DDEBUGGING
5369: -DEBUGGING=-g   or -Doptimize=-g	= -g
5370: -DEBUGGING=none or -UDEBUGGING	=
5371: -DEBUGGING=old  or -DEBUGGING=default	= ? $optimize
5372case "$EBUGGING" in
5373'')	;;
5374*)	DEBUGGING=$EBUGGING ;;
5375esac
5376
5377case "$DEBUGGING" in
5378-g|both|$define)
5379    case "$optimize" in
5380	*-g*) ;;
5381	*)    optimize="$optimize -g" ;;
5382    esac ;;
5383none|$undef)
5384    case "$optimize" in
5385	*-g*)	set `echo "X $optimize " | sed 's/ -g / /'`
5386		shift
5387		optimize="$*"
5388		;;
5389    esac ;;
5390esac
5391
5392dflt=''
5393case "$DEBUGGING" in
5394both|$define) dflt='-DDEBUGGING'
5395esac
5396
5397: argument order is deliberate, as the flag will start with - which set could
5398: think is an option
5399checkccflag='check=$1; flag=$2; callback=$3;
5400echo " ";
5401echo "Checking if your compiler accepts $flag" >&4;
5402[ "X$sysroot" != "X" ] && echo "For sysroot = $sysroot";
5403echo "int main(void) { return 0; }" > gcctest.c;
5404if $cc $_sysroot -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
5405    echo "Yes, it does." >&4;
5406    if $test -s gcctest.out ; then
5407        echo "But your platform does not like it:";
5408        cat gcctest.out;
5409    else
5410	case "$ccflags" in
5411	*$check*)
5412	    echo "Leaving current flags $ccflags alone." >&4
5413	    ;;
5414	*) dflt="$dflt $flag";
5415	    eval $callback
5416	    ;;
5417	esac
5418    fi
5419else
5420    echo "Nope, it does not, but that is ok." >&4;
5421fi
5422'
5423
5424: We will not override a previous value, but we might want to
5425: augment a hint file
5426case "$hint" in
5427default|recommended)
5428	case "$gccversion" in
5429	1.*) dflt="$dflt -fpcc-struct-return" ;;
5430	esac
5431	case "$optimize:$DEBUGGING" in
5432	*-g*:old) dflt="$dflt -DDEBUGGING";;
5433	esac
5434	case "$gccversion" in
5435	2.*) if $test -d /etc/conf/kconfig.d &&
5436			$contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
5437		then
5438			# Interactive Systems (ISC) POSIX mode.
5439			dflt="$dflt -posix"
5440		fi
5441		;;
5442	esac
5443	case "$gccversion" in
5444	1.*) ;;
5445	2.[0-8]*) ;;
5446	?*)	set strict-aliasing -fno-strict-aliasing
5447		eval $checkccflag
5448		;;
5449	esac
5450	case "$gccversion" in
5451	1*) ;;
5452	2*) ;;
5453	?*) 	echo " "
5454		echo "Checking if your compiler accepts -fno-delete-null-pointer-checks" 2>&1
5455		echo 'int main(void) { return 0; }' > gcctest.c
5456		if $cc -O2 -fno-delete-null-pointer-checks -o gcctest gcctest.c; then
5457			echo "Yes, it does." 2>&1
5458			case "$ccflags" in
5459			*delete-null-pointer-checks*)
5460				echo "Leaving current flags $ccflags alone." 2>&1
5461				;;
5462			*) dflt="$dflt -fno-delete-null-pointer-checks" ;;
5463			esac
5464		else
5465			echo "Nope, it doesn't, but that's ok." 2>&1
5466		fi
5467		;;
5468	esac
5469	# For gcc, adding -pipe speeds up compilations for some, but apparently
5470	# some assemblers can't read from stdin.  (It also slows down compilations
5471	# in other cases, but those are apparently rarer these days.)  AD 5/2004.
5472	case "$gccversion" in
5473	?*)	set pipe -pipe
5474		eval $checkccflag
5475		;;
5476	esac
5477
5478	# on x86_64 (at least) we require an extra library (libssp) in the
5479	# link command line. This library is not named, so I infer that it is
5480	# an implementation detail that may change. Hence the safest approach
5481	# is to add the flag to the flags passed to the compiler at link time,
5482	# as that way the compiler can do the right implementation dependant
5483	# thing. (NWC)
5484	case "$ccflags" in
5485	*-fno-stack-protector*)
5486	    echo "Do not add -fstack-protector nor -fstack-protector-strong" 2>&1
5487	    ;;
5488	*) case "$gccversion" in
5489	   ?*)	set stack-protector-strong -fstack-protector-strong
5490		eval $checkccflag
5491		case "$dflt" in
5492		*-fstack-protector-strong*) ;; # It got added.
5493		*) # Try the plain/older -fstack-protector.
5494		   set stack-protector -fstack-protector
5495		   eval $checkccflag
5496		   ;;
5497		esac
5498		;;
5499	    esac
5500	    ;;
5501	esac
5502esac
5503
5504case "$mips_type" in
5505*BSD*|'') inclwanted="$locincpth $usrinc";;
5506*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
5507esac
5508for thisincl in $inclwanted; do
5509	if $test -d $thisincl; then
5510		if $test x$thisincl != x$usrinc; then
5511			case "$dflt" in
5512			*" -I$thisincl "*);;
5513			*) dflt="$dflt -I$thisincl ";;
5514			esac
5515		fi
5516	fi
5517done
5518
5519inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
5520	xxx=true;
5521elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
5522	xxx=true;
5523else
5524	xxx=false;
5525fi;
5526if $xxx; then
5527	case "$dflt" in
5528	*$2*);;
5529	*) dflt="$dflt -D$2";;
5530	esac;
5531fi'
5532
5533set signal.h LANGUAGE_C; eval $inctest
5534
5535case "$usesocks" in
5536$define)
5537	ccflags="$ccflags -DSOCKS"
5538	;;
5539esac
5540
5541case "$hint" in
5542default|recommended) dflt="$ccflags $dflt" ;;
5543*) dflt="$ccflags";;
5544esac
5545
5546case "$dflt" in
5547''|' ') dflt=none;;
5548esac
5549
5550$cat <<EOH
5551
5552Your C compiler may want other flags.  For this question you should include
5553-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
5554but you should NOT include libraries or ld flags like -lwhatever.  If you
5555want $package to honor its debug switch, you should include -DDEBUGGING here.
5556Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
5557
5558To use no flags, specify the word "none".
5559
5560EOH
5561set X $dflt
5562shift
5563dflt=${1+"$@"}
5564rp="Any additional cc flags?"
5565. ./myread
5566case "$ans" in
5567none) ccflags='';;
5568*) ccflags="$ans";;
5569esac
5570
5571: the following weeds options from ccflags that are of no interest to cpp
5572case "$cppflags" in
5573'') cppflags="$ccflags" ;;
5574*)  set X $ccflags; shift
5575    case " $cppflags " in
5576    *" $1 "*) ;;  # Try to avoid doubling the cppflags.
5577    *) cppflags="$cppflags $ccflags" ;;
5578    esac
5579    ;;
5580esac
5581case "$gccversion" in
55821.*) cppflags="$cppflags -D__GNUC__"
5583esac
5584case "$mips_type" in
5585'');;
5586*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
5587esac
5588case "$cppflags" in
5589'');;
5590*)
5591	echo " "
5592	echo "Let me guess what the preprocessor flags are..." >&4
5593	set X $cppflags
5594	shift
5595	cppflags=''
5596	$cat >cpp.c <<'EOM'
5597#define BLURFL foo
5598
5599BLURFL xx LFRULB
5600EOM
5601	previous=''
5602	for flag in $*
5603	do
5604		case "$flag" in
5605		-*) ftry="$flag";;
5606		*) ftry="$previous $flag";;
5607		esac
5608		if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
5609			>cpp1.out 2>/dev/null && \
5610			$cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
5611			>cpp2.out 2>/dev/null && \
5612			$contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
5613			$contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
5614		then
5615			cppflags="$cppflags $ftry"
5616			previous=''
5617		else
5618			previous="$flag"
5619		fi
5620	done
5621	set X $cppflags
5622	shift
5623	cppflags=${1+"$@"}
5624	case "$cppflags" in
5625	*-*)  echo "They appear to be: $cppflags";;
5626	esac
5627	$rm -f cpp.c cpp?.out
5628	;;
5629esac
5630
5631: flags used in final linking phase
5632case "$ldflags" in
5633'') if ./venix; then
5634		dflt='-i -z'
5635	else
5636		dflt=''
5637	fi
5638	case "$ccflags" in
5639	*-posix*) dflt="$dflt -posix" ;;
5640	esac
5641	;;
5642*) dflt="$ldflags";;
5643esac
5644# See note above about -fstack-protector
5645case "$ccflags" in
5646*-fstack-protector-strong*)
5647	case "$dflt" in
5648	*-fstack-protector-strong*) ;; # Don't add it again
5649	*) dflt="$dflt -fstack-protector-strong" ;;
5650	esac
5651	;;
5652*-fstack-protector*)
5653	case "$dflt" in
5654	*-fstack-protector*) ;; # Don't add it again
5655	*) dflt="$dflt -fstack-protector" ;;
5656	esac
5657	;;
5658esac
5659
5660: Try to guess additional flags to pick up local libraries.
5661for thislibdir in $libpth; do
5662	case " $loclibpth " in
5663	*" $thislibdir "*)
5664		case "$dflt " in
5665		*"-L$thislibdir "*) ;;
5666		*)  dflt="$dflt -L$thislibdir" ;;
5667		esac
5668		;;
5669	esac
5670done
5671
5672case "$dflt" in
5673'') dflt='none' ;;
5674esac
5675
5676$cat <<EOH
5677
5678Your C linker may need flags.  For this question you should
5679include -L/whatever and any other flags used by the C linker, but you
5680should NOT include libraries like -lwhatever.
5681
5682Make sure you include the appropriate -L/path flags if your C linker
5683does not normally search all of the directories you specified above,
5684namely
5685	$libpth
5686To use no flags, specify the word "none".
5687
5688EOH
5689
5690rp="Any additional ld flags (NOT including libraries)?"
5691. ./myread
5692case "$ans" in
5693none) ldflags='';;
5694*) ldflags="$ans";;
5695esac
5696rmlist="$rmlist pdp11"
5697
5698: coherency check
5699echo " "
5700echo "Checking your choice of C compiler and flags for coherency..." >&4
5701$cat > try.c <<'EOF'
5702#include <stdio.h>
5703int main() { printf("Ok\n"); return(0); }
5704EOF
5705set X $cc -o try $optimize $ccflags $ldflags try.c $libs
5706shift
5707$cat >try.msg <<'EOM'
5708I've tried to compile and run the following simple program:
5709
5710EOM
5711$cat try.c >> try.msg
5712
5713$cat >> try.msg <<EOM
5714
5715I used the command:
5716
5717	$*
5718	$run ./try
5719
5720and I got the following output:
5721
5722EOM
5723dflt=y
5724if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; then
5725	if $sh -c "$run ./try " >>try.msg 2>&1; then
5726		xxx=`$run ./try`
5727		case "$xxx" in
5728		"Ok") dflt=n ;;
5729		*)    echo 'The program compiled OK, but produced no output.' >> try.msg ;;
5730		esac
5731	else
5732		echo "The program compiled OK, but exited with status $?." >>try.msg
5733		rp="You have a problem.  Shall I abort Configure"
5734		dflt=y
5735	fi
5736else
5737	echo "I can't compile the test program." >>try.msg
5738	rp="You have a BIG problem.  Shall I abort Configure"
5739	dflt=y
5740fi
5741case "$dflt" in
5742y)
5743	$cat try.msg >&4
5744	case "$knowitall" in
5745	'')
5746		echo "(The supplied flags or libraries might be incorrect.)"
5747		;;
5748	*) dflt=n;;
5749	esac
5750	echo " "
5751	. ./myread
5752	case "$ans" in
5753	n*|N*) ;;
5754	*)	echo "Ok.  Stopping Configure." >&4
5755		exit 1
5756		;;
5757	esac
5758	;;
5759n) echo "OK, that should do.";;
5760esac
5761$rm_try gcctest gcctest.out
5762
5763: define a shorthand compile call
5764compile='
5765mc_file=$1;
5766shift;
5767case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
5768echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to https://github.com/Perl/perl5/issues" >&4;
5769exit 1;
5770fi;
5771esac;
5772$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5773: define a shorthand compile call for compilations that should be ok.
5774compile_ok='
5775mc_file=$1;
5776shift;
5777$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
5778
5779: stub, used only to satisfy other units
5780i_stdlib='define'
5781
5782: check for lengths of integral types
5783echo " "
5784case "$intsize" in
5785'')
5786	echo "Checking to see how big your integers are..." >&4
5787	$cat >try.c <<EOCP
5788#include <stdio.h>
5789#$i_stdlib I_STDLIB
5790#ifdef I_STDLIB
5791#include <stdlib.h>
5792#endif
5793int main()
5794{
5795	printf("intsize=%d;\n", (int)sizeof(int));
5796	printf("longsize=%d;\n", (int)sizeof(long));
5797	printf("shortsize=%d;\n", (int)sizeof(short));
5798	exit(0);
5799}
5800EOCP
5801	set try
5802	if eval $compile_ok && $run ./try > /dev/null; then
5803		eval `$run ./try`
5804		echo "Your integers are $intsize bytes long."
5805		echo "Your long integers are $longsize bytes long."
5806		echo "Your short integers are $shortsize bytes long."
5807	else
5808		$cat >&4 <<EOM
5809!
5810Help! I can't compile and run the intsize test program: please enlighten me!
5811(This is probably a misconfiguration in your system or libraries, and
5812you really ought to fix it.  Still, I'll try anyway.)
5813!
5814EOM
5815		dflt=4
5816		rp="What is the size of an integer (in bytes)?"
5817		. ./myread
5818		intsize="$ans"
5819		dflt=$intsize
5820		rp="What is the size of a long integer (in bytes)?"
5821		. ./myread
5822		longsize="$ans"
5823		dflt=2
5824		rp="What is the size of a short integer (in bytes)?"
5825		. ./myread
5826		shortsize="$ans"
5827	fi
5828	;;
5829esac
5830$rm_try
5831
5832: check for long long
5833echo " "
5834echo "Checking to see if you have long long..." >&4
5835echo 'int main() { long long x = 7; return 0; }' > try.c
5836set try
5837if eval $compile; then
5838	val="$define"
5839	echo "You have long long."
5840else
5841	val="$undef"
5842	echo "You do not have long long."
5843fi
5844$rm_try
5845set d_longlong
5846eval $setvar
5847
5848: check for length of long long
5849case "${d_longlong}${longlongsize}" in
5850$define)
5851	echo " "
5852	echo "Checking to see how big your long longs are..." >&4
5853	$cat >try.c <<'EOCP'
5854#include <stdio.h>
5855int main()
5856{
5857    printf("%d\n", (int)sizeof(long long));
5858    return(0);
5859}
5860EOCP
5861	set try
5862	if eval $compile_ok; then
5863		longlongsize=`$run ./try`
5864		echo "Your long longs are $longlongsize bytes long."
5865	else
5866		dflt='8'
5867		echo " "
5868		echo "(I can't seem to compile the test program.  Guessing...)"
5869		rp="What is the size of a long long (in bytes)?"
5870		. ./myread
5871		longlongsize="$ans"
5872	fi
5873	if $test "X$longsize" = "X$longlongsize"; then
5874		echo "(That isn't any different from an ordinary long.)"
5875	fi
5876	;;
5877esac
5878$rm_try
5879
5880: determine filename position in cpp output
5881echo " "
5882echo "Computing filename position in cpp output for #include directives..." >&4
5883case "$osname" in
5884amigaos) fieldn=3 ;;  # Workaround for a bug in abc (pdksh).
5885esac
5886case "$fieldn" in
5887'')
5888case "$osname" in
5889vos) testaccess=-e ;;
5890*)   testaccess=-r ;;
5891esac
5892echo '#include <stdio.h>' > foo.c
5893$cat >fieldn <<EOF
5894$startsh
5895$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
5896$grep '^[ 	]*#.*stdio\.h' | \
5897while read cline; do
5898	pos=1
5899	set \$cline
5900	while $test \$# -gt 0; do
5901		if $test $testaccess \`echo \$1 | $tr -d '"'\`; then
5902			echo "\$pos"
5903			exit 0
5904		fi
5905		shift
5906		pos=\`expr \$pos + 1\`
5907	done
5908done
5909EOF
5910chmod +x fieldn
5911fieldn=`./fieldn`
5912$rm -f foo.c fieldn
5913;;
5914esac
5915case $fieldn in
5916'') pos='???';;
59171) pos=first;;
59182) pos=second;;
59193) pos=third;;
5920*) pos="${fieldn}th";;
5921esac
5922echo "Your cpp writes the filename in the $pos field of the line."
5923
5924: locate header file
5925$cat >findhdr <<EOF
5926$startsh
5927wanted=\$1
5928name=''
5929for usrincdir in $incpth
5930do
5931	if test -f \$usrincdir/\$wanted; then
5932		echo "\$usrincdir/\$wanted"
5933		exit 0
5934	fi
5935done
5936awkprg='{ print \$$fieldn }'
5937echo "#include <\$wanted>" > foo\$\$.c
5938$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
5939$cppfilter $grep "^[ 	]*#.*\$wanted" | \
5940while read cline; do
5941	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
5942	case "\$name" in
5943	*[/\\\\]\$wanted) echo "\$name"; exit 1;;
5944	*[\\\\/]\$wanted) echo "\$name"; exit 1;;
5945	*) exit 2;;
5946	esac;
5947done;
5948#
5949# status = 0: grep returned 0 lines, case statement not executed
5950# status = 1: headerfile found
5951# status = 2: while loop executed, no headerfile found
5952#
5953status=\$?
5954$rm -f foo\$\$.c;
5955if test \$status -eq 1; then
5956	exit 0;
5957fi
5958exit 1
5959EOF
5960chmod +x findhdr
5961
5962: define an alternate in-header-list? function
5963inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
5964cont=true; xxf="echo \"<\$1> found.\" >&4";
5965case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
5966*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
5967esac;
5968case $# in 4) instead=instead;; *) instead="at last";; esac;
5969while $test "$cont"; do
5970	xxx=`./findhdr $1`
5971	var=$2; eval "was=\$$2";
5972	if $test "$xxx" && $test -r "$xxx";
5973	then eval $xxf;
5974	eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
5975		cont="";
5976	else eval $xxnf;
5977	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
5978	set $yyy; shift; shift; yyy=$@;
5979	case $# in 0) cont="";;
5980	2) xxf="echo \"but I found <\$1> $instead.\" >&4";
5981		xxnf="echo \"and I did not find <\$1> either.\" >&4";;
5982	*) xxf="echo \"but I found <\$1\> instead.\" >&4";
5983		xxnf="echo \"there is no <\$1>, ...\" >&4";;
5984	esac;
5985done;
5986while $test "$yyy";
5987do set $yyy; var=$2; eval "was=\$$2";
5988	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
5989	set $yyy; shift; shift; yyy=$@;
5990done'
5991
5992: see if inttypes.h is available
5993: we want a real compile instead of Inhdr because some systems
5994: have an inttypes.h which includes non-existent headers
5995echo " "
5996$cat >try.c <<EOCP
5997#include <inttypes.h>
5998int main() {
5999	static int32_t foo32 = 0x12345678;
6000}
6001EOCP
6002set try
6003if eval $compile; then
6004	echo "<inttypes.h> found." >&4
6005	val="$define"
6006else
6007	echo "<inttypes.h> NOT found." >&4
6008	val="$undef"
6009fi
6010$rm_try
6011set i_inttypes
6012eval $setvar
6013
6014: check for int64_t
6015echo " "
6016echo "Checking to see if you have int64_t..." >&4
6017$cat >try.c <<EOCP
6018#include <sys/types.h>
6019#$i_inttypes I_INTTYPES
6020#ifdef I_INTTYPES
6021#include <inttypes.h>
6022#endif
6023int main() { int64_t x = 7; }
6024EOCP
6025set try
6026if eval $compile; then
6027	val="$define"
6028	echo "You have int64_t."
6029else
6030	val="$undef"
6031	echo "You do not have int64_t."
6032fi
6033$rm_try
6034set d_int64_t
6035eval $setvar
6036
6037: Check if 64bit ints have a quad type
6038echo " "
6039echo "Checking which 64-bit integer type we could use..." >&4
6040
6041case "$intsize" in
60428) val=int
6043   set quadtype
6044   eval $setvar
6045   val='"unsigned int"'
6046   set uquadtype
6047   eval $setvar
6048   quadkind=1
6049   ;;
6050*) case "$longsize" in
6051   8) val=long
6052      set quadtype
6053      eval $setvar
6054      val='"unsigned long"'
6055      set uquadtype
6056      eval $setvar
6057      quadkind=2
6058      ;;
6059   *) case "$d_longlong:$longlongsize" in
6060      define:8)
6061        val='"long long"'
6062        set quadtype
6063        eval $setvar
6064        val='"unsigned long long"'
6065        set uquadtype
6066        eval $setvar
6067        quadkind=3
6068        ;;
6069      *) case "$d_int64_t" in
6070         define)
6071           val=int64_t
6072           set quadtype
6073           eval $setvar
6074           val=uint64_t
6075           set uquadtype
6076           eval $setvar
6077           quadkind=4
6078           ;;
6079         esac
6080         ;;
6081      esac
6082      ;;
6083   esac
6084   ;;
6085esac
6086
6087case "$quadtype" in
6088'')	echo "Alas, no 64-bit integer types in sight." >&4
6089	d_quad="$undef"
6090	;;
6091*)	echo "We could use '$quadtype' for 64-bit integers." >&4
6092	d_quad="$define"
6093	;;
6094esac
6095
6096: Do we want 64bit support
6097case "$uselonglong" in
6098"$define"|true|[yY]*)
6099	cat <<EOM >&4
6100
6101*** Configure -Duselonglong is deprecated, using -Duse64bitint instead.
6102EOM
6103	use64bitint="$define"
6104	;;
6105esac
6106case "$use64bits" in
6107"$define"|true|[yY]*)
6108	cat <<EOM >&4
6109
6110*** Configure -Duse64bits is deprecated, using -Duse64bitint instead.
6111EOM
6112	use64bitint="$define"
6113	;;
6114esac
6115case "$use64bitints" in
6116"$define"|true|[yY]*)
6117	cat <<EOM >&4
6118
6119*** There is no Configure -Duse64bitints, using -Duse64bitint instead.
6120EOM
6121	use64bitint="$define"
6122	;;
6123esac
6124case "$use64bitsint" in
6125"$define"|true|[yY]*)
6126	cat <<EOM >&4
6127
6128*** There is no Configure -Duse64bitsint, using -Duse64bitint instead.
6129EOM
6130	use64bitint="$define"
6131	;;
6132esac
6133case "$uselonglongs" in
6134"$define"|true|[yY]*)
6135	cat <<EOM >&4
6136
6137*** There is no Configure -Duselonglongs, using -Duse64bitint instead.
6138EOM
6139	use64bitint="$define"
6140	;;
6141esac
6142case "$use64bitsall" in
6143"$define"|true|[yY]*)
6144	cat <<EOM >&4
6145
6146*** There is no Configure -Duse64bitsall, using -Duse64bitall instead.
6147EOM
6148	use64bitall="$define"
6149	;;
6150esac
6151
6152case "$ccflags" in
6153*-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
6154esac
6155case "$use64bitall" in
6156"$define"|true|[yY]*) use64bitint="$define" ;;
6157esac
6158
6159case "$longsize" in
61608) cat <<EOM
6161
6162You have natively 64-bit long integers.
6163EOM
6164   val="$define"
6165   ;;
6166*) case "$use64bitint" in
6167   "$define"|true|[yY]*) dflt='y';;
6168   *) dflt='n';;
6169   esac
6170   case "$d_quad" in
6171   "$define") ;;
6172   *) dflt='n' ;;
6173   esac
6174   cat <<EOM
6175
6176Perl can be built to take advantage of 64-bit integer types
6177on some systems.  To do so, Configure can be run with -Duse64bitint.
6178Choosing this option will most probably introduce binary incompatibilities.
6179
6180If this doesn't make any sense to you, just accept the default '$dflt'.
6181(The default has been chosen based on your configuration.)
6182EOM
6183   rp='Try to use 64-bit integers, if available?'
6184   . ./myread
6185   case "$ans" in
6186   [yY]*) val="$define" ;;
6187   *)     val="$undef"  ;;
6188   esac
6189   ;;
6190esac
6191set use64bitint
6192eval $setvar
6193
6194case "$use64bitall" in
6195"$define"|true|[yY]*) dflt='y' ;;
6196*) case "$longsize" in
6197   8) dflt='y' ;;
6198   *) dflt='n' ;;
6199   esac
6200   ;;
6201esac
6202cat <<EOM
6203
6204You may also choose to try maximal 64-bitness.  It means using as much
620564-bitness as possible on the platform.  This in turn means even more
6206binary incompatibilities.  On the other hand, your platform may not
6207have any more 64-bitness available than what you already have chosen.
6208
6209If this doesn't make any sense to you, just accept the default '$dflt'.
6210(The default has been chosen based on your configuration.)
6211EOM
6212rp='Try to use maximal 64-bit support, if available?'
6213. ./myread
6214case "$ans" in
6215[yY]*) val="$define" ;;
6216*)     val="$undef"  ;;
6217esac
6218set use64bitall
6219eval $setvar
6220case "$use64bitall" in
6221"$define")
6222	case "$use64bitint" in
6223	"$undef")
6224		cat <<EOM
6225
6226Since you have chosen a maximally 64-bit build, I'm also turning on
6227the use of 64-bit integers.
6228EOM
6229		use64bitint="$define" ;;
6230	esac
6231	;;
6232esac
6233
6234: Look for a hint-file generated 'call-back-unit'.  If the
6235: user has specified that a 64-bit perl is to be built,
6236: we may need to set or change some other defaults.
6237if $test -f use64bitint.cbu; then
6238	echo "Your platform has some specific hints regarding 64-bit integers, using them..."
6239	. ./use64bitint.cbu
6240fi
6241case "$use64bitint" in
6242"$define"|true|[yY]*)
6243	: This test was common to all the OpenBSD forks, and seems harmless for
6244	: other platforms:
6245	echo " "
6246	echo "Checking if your C library has broken 64-bit functions..." >&4
6247	cat >try.c <<EOCP
6248#include <stdio.h>
6249typedef $uquadtype myULL;
6250int main (void)
6251{
6252    struct {
6253	double d;
6254	myULL  u;
6255    } *p, test[] = {
6256	{4294967303.15, 4294967303ULL},
6257	{4294967294.2,  4294967294ULL},
6258	{4294967295.7,  4294967295ULL},
6259	{0.0, 0ULL}
6260    };
6261    for (p = test; p->u; p++) {
6262	myULL x = (myULL)p->d;
6263	if (x != p->u) {
6264	    printf("buggy\n");
6265	    return 0;
6266	}
6267    }
6268    printf("ok\n");
6269    return 0;
6270}
6271EOCP
6272	set try
6273	if eval $compile_ok; then
6274	    libcquad=`$run ./try`
6275	    echo "Your C library's 64-bit functions are $libcquad."
6276	else
6277	    echo "(I can't seem to compile the test program.)"
6278	    echo "Assuming that your C library's 64-bit functions are ok."
6279	    libcquad="ok"
6280	fi
6281	$rm_try
6282
6283	case "$libcquad" in
6284	    buggy*)
6285		cat >&4 <<EOM
6286
6287*** You have a C library with broken 64-bit functions.
6288*** 64-bit support does not work reliably in this configuration.
6289*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6290*** Cannot continue, aborting.
6291
6292EOM
6293		exit 1
6294		;;
6295	esac
6296	case "$longsize" in
6297	4) case "$archname64" in
6298	   '') archname64=64int ;;
6299	   esac
6300	   ;;
6301	esac
6302	;;
6303esac
6304
6305: Look for a hint-file generated 'call-back-unit'.  If the
6306: user has specified that a maximally 64-bit perl is to be built,
6307: we may need to set or change some other defaults.
6308if $test -f use64bitall.cbu; then
6309	echo "Your platform has some specific hints regarding 64-bit builds, using them..."
6310	. ./use64bitall.cbu
6311fi
6312case "$use64bitall" in
6313"$define"|true|[yY]*)
6314	case "$longsize" in
6315	4) case "$archname64" in
6316	   ''|64int) archname64=64all ;;
6317	   esac
6318	   ;;
6319	esac
6320	;;
6321esac
6322
6323case "$d_quad:$use64bitint" in
6324$undef:$define)
6325	cat >&4 <<EOF
6326
6327*** You have chosen to use 64-bit integers,
6328*** but none can be found.
6329*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
6330*** Cannot continue, aborting.
6331
6332EOF
6333	exit 1
6334	;;
6335esac
6336
6337: Check if we are using the GNU C library
6338echo " "
6339echo "Checking for GNU C Library..." >&4
6340cat >try.c <<'EOCP'
6341/* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
6342   alone are insufficient to distinguish different versions, such as
6343   2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
6344   libc version 2.1.0.      A. Dougherty,  June 3, 2002.
6345*/
6346#include <stdio.h>
6347int main(void)
6348{
6349#ifdef __GLIBC__
6350#   ifdef __GLIBC_MINOR__
6351#       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__cplusplus)
6352#           include <gnu/libc-version.h>
6353	    printf("%s\n",  gnu_get_libc_version());
6354#       else
6355	    printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
6356#       endif
6357#   else
6358	printf("%d\n",  __GLIBC__);
6359#   endif
6360    return 0;
6361#else
6362    return 1;
6363#endif
6364}
6365EOCP
6366set try
6367if eval $compile_ok && $run ./try > glibc.ver; then
6368	val="$define"
6369	gnulibc_version=`$cat glibc.ver`
6370	echo "You are using the GNU C Library version $gnulibc_version"
6371else
6372	val="$undef"
6373	gnulibc_version=''
6374	echo "You are not using the GNU C Library"
6375fi
6376$rm_try glibc.ver
6377set d_gnulibc
6378eval $setvar
6379
6380: see if nm is to be used to determine whether a symbol is defined or not
6381case "$usenm" in
6382'')
6383	dflt=''
6384	case "$d_gnulibc" in
6385	"$define")
6386		echo " "
6387		echo "nm probably won't work on the GNU C Library." >&4
6388		dflt=n
6389		;;
6390	esac
6391	case "$dflt" in
6392	'')
6393		if $test "$osname" = aix -a "X$PASE" != "Xdefine" -a ! -f /lib/syscalls.exp; then
6394			echo " "
6395			echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
6396			echo "'nm' won't be sufficient on this system." >&4
6397			dflt=n
6398		fi
6399		;;
6400	esac
6401	case "$dflt" in
6402	'') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
6403		if $test $dflt -gt 20; then
6404			dflt=y
6405		else
6406			dflt=n
6407		fi
6408		;;
6409	esac
6410	;;
6411*)
6412	case "$usenm" in
6413	true|$define) dflt=y;;
6414	*) dflt=n;;
6415	esac
6416	;;
6417esac
6418$cat <<EOM
6419
6420I can use $nm to extract the symbols from your C libraries. This
6421is a time consuming task which may generate huge output on the disk (up
6422to 3 megabytes) but that should make the symbols extraction faster. The
6423alternative is to skip the 'nm' extraction part and to compile a small
6424test program instead to determine whether each symbol is present. If
6425you have a fast C compiler and/or if your 'nm' output cannot be parsed,
6426this may be the best solution.
6427
6428You probably shouldn't let me use 'nm' if you are using the GNU C Library.
6429
6430EOM
6431rp="Shall I use $nm to extract C symbols from the libraries?"
6432. ./myread
6433case "$ans" in
6434[Nn]*) usenm=false;;
6435*) usenm=true;;
6436esac
6437
6438runnm=$usenm
6439case "$reuseval" in
6440true) runnm=false;;
6441esac
6442
6443: nm options which may be necessary
6444case "$nm_opt" in
6445'') if $test -f /mach_boot; then
6446		nm_opt=''	# Mach
6447	elif $test -d /usr/ccs/lib; then
6448		nm_opt='-p'	# Solaris (and SunOS?)
6449	elif $test -f /dgux; then
6450		nm_opt='-p'	# DG-UX
6451	elif $test -f /lib64/rld; then
6452		nm_opt='-p'	# 64-bit Irix
6453	else
6454		nm_opt=''
6455	fi;;
6456esac
6457
6458: nm options which may be necessary for shared libraries but illegal
6459: for archive libraries.  Thank you, Linux.
6460case "$nm_so_opt" in
6461'')	case "$myuname" in
6462	*linux*|gnu*)
6463		if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
6464			nm_so_opt='--dynamic'
6465		fi
6466		;;
6467	esac
6468	;;
6469esac
6470
6471: Figure out where the libc is located
6472case "$runnm" in
6473true)
6474: get list of predefined functions in a handy place
6475echo " "
6476case "$libc" in
6477'') libc=unknown
6478	case "$libs" in
6479	*-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
6480	esac
6481	;;
6482esac
6483case "$libs" in
6484'') ;;
6485*)  for thislib in $libs; do
6486	case "$thislib" in
6487	-lc|-lc_s)
6488		: Handle C library specially below.
6489		;;
6490	-l*)
6491		thislib=`echo $thislib | $sed -e 's/^-l//'`
6492		if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
6493			:
6494		elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
6495			:
6496		elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
6497			:
6498		elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
6499			:
6500		elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
6501			:
6502		elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
6503			:
6504		elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
6505			:
6506		else
6507			try=''
6508		fi
6509		libnames="$libnames $try"
6510		;;
6511	*) libnames="$libnames $thislib" ;;
6512	esac
6513	done
6514	;;
6515esac
6516xxx=normal
6517case "$libc" in
6518unknown)
6519	set /lib/libc.$so
6520	for xxx in $libpth; do
6521		$test -r $1 || set $xxx/libc.$so
6522		: The messy sed command sorts on library version numbers.
6523		$test -r $1 || \
6524			set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
6525			tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
6526				h
6527				s/[0-9][0-9]*/0000&/g
6528				s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
6529				G
6530				s/\n/ /' | \
6531			 $sort | $sed -e 's/^.* //'`
6532		eval set \$$#
6533	done
6534	$test -r $1 || set $sysroot/usr/ccs/lib/libc.$so
6535	$test -r $1 || set $sysroot/lib/libsys_s$_a
6536	;;
6537*)
6538	set blurfl
6539	;;
6540esac
6541if $test -r "$1"; then
6542	echo "Your (shared) C library seems to be in $1."
6543	libc="$1"
6544elif $test -r /lib/libc && $test -r /lib/clib; then
6545	echo "Your C library seems to be in both /lib/clib and /lib/libc."
6546	xxx=apollo
6547	libc='/lib/clib /lib/libc'
6548	if $test -r /lib/syslib; then
6549		echo "(Your math library is in /lib/syslib.)"
6550		libc="$libc /lib/syslib"
6551	fi
6552elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
6553	echo "Your C library seems to be in $libc, as you said before."
6554elif $test -r $incpath/usr/lib/libc$_a; then
6555	libc=$incpath/usr/lib/libc$_a;
6556	echo "Your C library seems to be in $libc.  That's fine."
6557elif $test -r /lib/libc$_a; then
6558	libc=/lib/libc$_a;
6559	echo "Your C library seems to be in $libc.  You're normal."
6560else
6561	if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
6562		:
6563	elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
6564		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
6565	elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
6566		:
6567	elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
6568		:
6569	elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
6570		:
6571	else
6572		tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
6573	fi
6574	if $test -r "$tans"; then
6575		echo "Your C library seems to be in $tans, of all places."
6576		libc=$tans
6577	else
6578		libc='blurfl'
6579	fi
6580fi
6581if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
6582	dflt="$libc"
6583	cat <<EOM
6584
6585If the guess above is wrong (which it might be if you're using a strange
6586compiler, or your machine supports multiple models), you can override it here.
6587
6588EOM
6589else
6590	dflt=''
6591	echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
6592	cat >&4 <<EOM
6593I can't seem to find your C library.  I've looked in the following places:
6594
6595EOM
6596	$sed 's/^/	/' libpath
6597	cat <<EOM
6598
6599None of these seems to contain your C library. I need to get its name...
6600
6601EOM
6602fi
6603fn=f
6604rp='Where is your C library?'
6605. ./getfile
6606libc="$ans"
6607
6608echo " "
6609echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
6610set X `cat libnames`
6611shift
6612xxx=files
6613case $# in 1) xxx=file; esac
6614echo "Extracting names from the following $xxx for later perusal:" >&4
6615echo " "
6616$sed 's/^/	/' libnames >&4
6617echo " "
6618$echo $n "This may take a while...$c" >&4
6619
6620for file in $*; do
6621	case $file in
6622	*$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
6623	*) $nm $nm_opt $file 2>/dev/null;;
6624	esac
6625done >libc.tmp
6626
6627$echo $n ".$c"
6628$grep fprintf libc.tmp > libc.ptf
6629xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
6630xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
6631xxx='[ADTSIWi]'
6632if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *//p'";\
6633	eval $xscan;\
6634	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6635		eval $xrun
6636elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
6637	eval $xscan;\
6638	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6639		eval $xrun
6640elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
6641	eval $xscan;\
6642	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6643		eval $xrun
6644elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
6645	eval $xscan;\
6646	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6647		eval $xrun
6648elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
6649	eval $xscan;\
6650	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6651		eval $xrun
6652elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
6653	eval $xscan;\
6654	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6655		eval $xrun
6656elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
6657				-e '/ file/d' -e 's/^\([^ 	]*\).*/\1/p'";\
6658	eval $xscan;\
6659	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6660		eval $xrun
6661elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
6662	eval $xscan;\
6663	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6664		eval $xrun
6665elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
6666	eval $xscan;\
6667	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6668		eval $xrun
6669elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
6670	eval $xscan;\
6671	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6672		eval $xrun
6673elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
6674	eval $xscan;\
6675	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6676		eval $xrun
6677elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
6678	eval $xscan;\
6679	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6680		eval $xrun
6681elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
6682	eval $xscan;\
6683	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6684		eval $xrun
6685elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
6686	eval $xscan;\
6687	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
6688		eval $xrun
6689else
6690	$nm -p $* 2>/dev/null >libc.tmp
6691	$grep fprintf libc.tmp > libc.ptf
6692	if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
6693		eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
6694	then
6695		nm_opt='-p'
6696		eval $xrun
6697	else
6698		echo " "
6699		echo "$nm didn't seem to work right. Trying $ar instead..." >&4
6700		com=''
6701		if $ar t $libc > libc.tmp && \
6702			$contains '^fprintf$' libc.tmp >/dev/null 2>&1
6703		then
6704			for thisname in $libnames $libc; do
6705				$ar t $thisname >>libc.tmp
6706			done
6707			$sed -e "s/\\$_o\$//" < libc.tmp > libc.list
6708			echo "Ok." >&4
6709		elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
6710			for thisname in $libnames $libc; do
6711				$ar tv $thisname >>libc.tmp
6712				emximp -o tmp.imp $thisname \
6713				    2>/dev/null && \
6714				    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
6715				    < tmp.imp >>libc.tmp
6716				$rm -f tmp.imp
6717			done
6718			$sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
6719			echo "Ok." >&4
6720		else
6721			echo "$ar didn't seem to work right." >&4
6722			echo "Maybe this is a Cray...trying bld instead..." >&4
6723			if  bld t $libc | \
6724				$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list &&
6725				$test -s libc.list
6726			then
6727				for thisname in $libnames; do
6728					bld t $libnames | \
6729					$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
6730					$ar t $thisname >>libc.tmp
6731				done
6732				echo "Ok." >&4
6733			else
6734				echo "That didn't work either.  Giving up." >&4
6735				exit 1
6736			fi
6737		fi
6738	fi
6739fi
6740nm_extract="$com"
6741case "$PASE" in
6742define)
6743    echo " "
6744    echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
6745    dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
6746    ;;
6747*)  if $test -f /lib/syscalls.exp; then
6748	echo " "
6749	echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
6750	$sed -n 's/^\([^ 	]*\)[ 	]*syscall[0-9]*[ 	]*$/\1/p' \
6751		/lib/syscalls.exp >>libc.list
6752    fi
6753    ;;
6754esac
6755;;
6756esac
6757$rm -f libnames libpath
6758
6759: Check if we are using C++
6760echo " "
6761echo "Checking for C++..." >&4
6762$cat >try.c <<'EOCP'
6763#include <stdio.h>
6764int main(void)
6765{
6766#ifdef __cplusplus
6767    return 0;
6768#else
6769    return 1;
6770#endif
6771}
6772EOCP
6773set try
6774if eval $compile_ok && $run ./try; then
6775	val="$define"
6776	echo "You are using a C++ compiler."
6777else
6778	val="$undef"
6779	echo "You are not using a C++ compiler."
6780fi
6781$rm_try cplusplus$$
6782set d_cplusplus
6783eval $setvar
6784
6785: is a C symbol defined?
6786csym='tlook=$1;
6787case "$3" in
6788-v) tf=libc.tmp; tdc="";;
6789-a) tf=libc.tmp; tdc="[]";;
6790*) tlook="^$1\$"; tf=libc.list; tdc="()";;
6791esac;
6792case "$d_cplusplus" in
6793    $define)	extern_C="extern \"C\""	;;
6794    *)		extern_C="extern"	;;
6795esac;
6796tx=yes;
6797case "$reuseval-$4" in
6798true-) ;;
6799true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
6800esac;
6801case "$tx" in
6802yes)
6803	tval=false;
6804	if $test "$runnm" = true; then
6805		if $contains $tlook $tf >/dev/null 2>&1; then
6806			tval=true;
6807		elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
6808			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;
6809			$cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
6810			$test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
6811			$rm_try;
6812		fi;
6813	else
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 $libs >/dev/null 2>&1 && tval=true;
6816		$rm_try;
6817	fi;
6818	;;
6819*)
6820	case "$tval" in
6821	$define) tval=true;;
6822	*) tval=false;;
6823	esac;
6824	;;
6825esac;
6826eval "$2=$tval"'
6827
6828: define an is-in-libc? function
6829inlibc='echo " "; td=$define; tu=$undef;
6830sym=$1; var=$2; eval "was=\$$2";
6831tx=yes;
6832case "$reuseval$was" in
6833true) ;;
6834true*) tx=no;;
6835esac;
6836case "$tx" in
6837yes)
6838	set $sym tres -f;
6839	eval $csym;
6840	case "$tres" in
6841	true)
6842		echo "$sym() found." >&4;
6843		case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
6844	*)
6845		echo "$sym() NOT found." >&4;
6846		case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
6847	esac;;
6848*)
6849	case "$was" in
6850	$define) echo "$sym() found." >&4;;
6851	*) echo "$sym() NOT found." >&4;;
6852	esac;;
6853esac'
6854
6855: check for length of double
6856echo " "
6857case "$doublesize" in
6858'')
6859	echo "Checking to see how big your double precision numbers are..." >&4
6860	$cat >try.c <<EOCP
6861#include <stdio.h>
6862#$i_stdlib I_STDLIB
6863#ifdef I_STDLIB
6864#include <stdlib.h>
6865#endif
6866int main()
6867{
6868    printf("%d\n", (int)sizeof(double));
6869    exit(0);
6870}
6871EOCP
6872	set try
6873	if eval $compile_ok; then
6874		doublesize=`$run ./try`
6875		echo "Your double is $doublesize bytes long."
6876	else
6877		dflt='8'
6878		echo "(I can't seem to compile the test program.  Guessing...)"
6879		rp="What is the size of a double precision number (in bytes)?"
6880		. ./myread
6881		doublesize="$ans"
6882	fi
6883	;;
6884esac
6885$rm_try
6886
6887: check for long doubles
6888echo " " >&4
6889echo "Checking to see if you have long double..." >&4
6890echo 'int main() { long double x = 7.0; }' > try.c
6891set try
6892if eval $compile; then
6893	val="$define"
6894	echo "You have long double." >&4
6895else
6896	val="$undef"
6897	echo "You do not have long double." >&4
6898fi
6899$rm_try
6900set d_longdbl
6901eval $setvar
6902
6903: see if ldexpl exists
6904set ldexpl d_ldexpl
6905eval $inlibc
6906
6907: check for length of long double
6908case "${d_longdbl}${longdblsize}" in
6909$define)
6910	echo " " >&4
6911	echo "Checking to see how big your long doubles are..." >&4
6912	$cat >try.c <<'EOCP'
6913#include <stdio.h>
6914int main()
6915{
6916	printf("%d\n", sizeof(long double));
6917}
6918EOCP
6919	set try
6920	set try
6921	if eval $compile; then
6922		longdblsize=`$run ./try`
6923		echo "Your long doubles are $longdblsize bytes long." >&4
6924	else
6925		dflt='8'
6926		echo " " >&4
6927		echo "(I can't seem to compile the test program.  Guessing...)" >&4
6928		rp="What is the size of a long double (in bytes)?"
6929		. ./myread
6930		longdblsize="$ans"
6931	fi
6932	if $test "X$doublesize" = "X$longdblsize"; then
6933		echo "That isn't any different from an ordinary double." >&4
6934		echo "I'll keep your setting anyway, but you may see some" >&4
6935		echo "harmless compilation warnings." >&4
6936	fi
6937	;;
6938esac
6939$rm_try
6940
6941$echo "Checking the kind of long doubles you have..." >&4
6942case "$d_longdbl" in
6943define)
6944$cat <<EOP >try.c
6945#$i_stdlib I_STDLIB
6946#define LONGDBLSIZE $longdblsize
6947#define DOUBLESIZE $doublesize
6948#include <float.h>
6949#ifdef I_STDLIB
6950#include <stdlib.h>
6951#endif
6952#include <stdio.h>
6953static const long double d = -0.1L;
6954int main() {
6955  unsigned const char* b = (unsigned const char*)(&d);
6956#if DOUBLESIZE == LONGDBLSIZE
6957  printf("0\n"); /* if it floats like double */
6958  exit(0);
6959#endif
6960#if (LDBL_MANT_DIG == 113 || FLT128_MANT_DIG == 113) && LONGDBLSIZE == 16
6961  if (b[0] == 0x9A && b[1] == 0x99 && b[15] == 0xBF) {
6962    /* IEEE 754 128-bit little-endian */
6963    printf("1\n");
6964    exit(0);
6965  }
6966  if (b[0] == 0xBF && b[14] == 0x99 && b[15] == 0x9A) {
6967    /* IEEE 128-bit big-endian, e.g. solaris sparc */
6968    printf("2\n");
6969    exit(0);
6970  }
6971#endif
6972/* For alignment 32-bit platforms have the 80 bits in 12 bytes,
6973 * while 64-bits platforms have it in 16 bytes.  The trailing bytes
6974 * cannot be trusted. */
6975#if LDBL_MANT_DIG == 64 && (LONGDBLSIZE == 16 || LONGDBLSIZE == 12)
6976  if (b[0] == 0xCD && b[9] == 0xBF) {
6977    /* x86 80-bit little-endian, sizeof 12 (ILP32, Solaris x86)
6978     * or 16 (LP64, Linux and OS X), 4 or 6 bytes of padding.
6979     * Also known as "extended precision". */
6980    printf("3\n");
6981    exit(0);
6982  }
6983  if (b[0] == 0xBF && b[9] == 0xCD) {
6984    /* Is there ever big-endian 80-bit, really?
6985     *
6986     * The Motorola 68881 had another "extended precision" format:
6987     * sign:1 exp:15 zero:16 integer:1 mantissa:63
6988     * for total of 96 bits of bytes.  The zero bits were unused.
6989     * See "M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL" for more details.
6990     * If it ever becomes relevant, this format should be allocated a
6991     * new doublekind code since it is quite different from the Intel x87.
6992     */
6993    printf("4\n");
6994    exit(0);
6995  }
6996#endif
6997#if (LDBL_MANT_DIG == 106 || LDBL_MANT_DIG == 107) && LONGDBLSIZE == 16
6998  /* software "double double", the 106 is 53+53.
6999   * but irix thinks it is 107. */
7000  if (b[0] == 0x9A && b[7] == 0x3C && b[8] == 0x9A && b[15] == 0xBF) {
7001    /* double double 128-bit fully little-endian,
7002     * little-endian doubles in little-endian order,
7003     * 9a 99 99 99 99 99 59 3c 9a 99 99 99 99 99 b9 bf */
7004    printf("5\n");
7005    exit(0);
7006  }
7007  if (b[0] == 0xBF && b[7] == 0x9A && b[8] == 0x3C && b[15] == 0x9A) {
7008    /* double double 128-bit fully big-endian,
7009     * big-endian doubles in big-endian order,
7010     * e.g. PPC/Power and MIPS:
7011     * bf b9 99 99 99 99 99 9a 3c 59 99 99 99 99 99 9a */
7012    printf("6\n");
7013    exit(0);
7014  }
7015  if (b[0] == 0x9A && b[7] == 0xBF && b[8] == 0x9A && b[15] == 0x3C) {
7016    /* double double 128-bit mixed endian.
7017     * little-endian doubles in big-endian order,
7018     * e.g. ppc64el,
7019     * 9a 99 99 99 99 99 b9 bf 9a 99 99 99 99 99 59 3c */
7020    printf("7\n");
7021    exit(0);
7022  }
7023  if (b[0] == 0x3C && b[7] == 0x9A && b[8] == 0xBF && b[15] == 0x9A) {
7024    /* double double 128-bit mixed endian,
7025     * big-endian doubles in little-endian order,
7026     * 3c 59 99 99 99 99 99 9a bf b9 99 99 99 99 99 9a */
7027    printf("8\n");
7028    exit(0);
7029  }
7030#endif
7031/* We are largely making this up because it may well be
7032 * that the VAX format H was never made available to C,
7033 * only to Fortran. */
7034#if LONGDBLSIZE == 16 && defined(__vax__)
7035  if (b[0] == 0xFD && b[15] == 0x99) {
7036    /* VAX format H, PDP-11 mixed endian. */
7037    printf("9\n");
7038    exit(0);
7039  }
7040#endif
7041  printf("-1\n"); /* unknown */
7042  exit(0);
7043}
7044EOP
7045set try
7046if eval $compile; then
7047    longdblkind=`$run ./try`
7048else
7049    longdblkind=-1
7050fi
7051;;
7052*) longdblkind=0 ;;
7053esac
7054case "$longdblkind" in
70550) echo "Your long doubles are doubles." >&4 ;;
70561) echo "You have IEEE 754 128-bit little endian long doubles." >&4 ;;
70572) echo "You have IEEE 754 128-bit big endian long doubles." >&4 ;;
70583) echo "You have x86 80-bit little endian long doubles." >&4 ;;
70594) echo "You have x86 80-bit big endian long doubles." >&4 ;;
70605) echo "You have 128-bit fully little-endian double-double long doubles (64-bit LEs in LE)." >&4 ;;
70616) echo "You have 128-bit fully big-endian double-double long doubles (64-bit BEs in BE)." >&4 ;;
70627) echo "You have 128-bit mixed-endian double-double long doubles (64-bit LEs in BE)." >&4 ;;
70638) echo "You have 128-bit mixed-endian double-double long doubles (64-bit BEs in LE)." >&4 ;;
70649) echo "You have 128-bit PDP-style mixed-endian long doubles (VAX format H)." >&4 ;;
7065*) echo "Cannot figure out your long double." >&4 ;;
7066esac
7067d_long_double_style_ieee=$undef
7068d_long_double_style_ieee_std=$undef
7069d_long_double_style_ieee_extended=$undef
7070d_long_double_style_ieee_doubledouble=$undef
7071d_long_double_style_vax=$undef
7072case "$longdblkind" in
70731|2|3|4|5|6|7|8) d_long_double_style_ieee=$define ;;
7074esac
7075case "$longdblkind" in
70761|2) d_long_double_style_ieee_std=$define ;;
7077esac
7078case "$longdblkind" in
70793|4) d_long_double_style_ieee_extended=$define ;;
7080esac
7081case "$longdblkind" in
70825|6|7|8) d_long_double_style_ieee_doubledouble=$define ;;
7083esac
7084case "$longdblkind" in
70859) d_long_double_style_vax=$define ;;
7086esac
7087$rm_try
7088
7089: get the patchlevel
7090echo " "
7091echo "Getting the current patchlevel..." >&4
7092if $test -r $rsrc/patchlevel.h;then
7093	revision=`awk '/define[ 	]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
7094	patchlevel=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
7095	subversion=`awk '/define[ 	]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
7096	api_revision=`awk '/define[ 	]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
7097	api_version=`awk '/define[ 	]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
7098	api_subversion=`awk '/define[ 	]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
7099	perl_patchlevel=`egrep ',"(MAINT|SMOKE)[0-9][0-9]*"' $rsrc/patchlevel.h|tail -1|sed 's/[^0-9]//g'`
7100else
7101	revision=0
7102	patchlevel=0
7103	subversion=0
7104	api_revision=0
7105	api_version=0
7106	api_subversion=0
7107	perl_patchlevel=0
7108	$echo "(You do not have patchlevel.h.  Eek.)"
7109fi
7110: Define a handy string here to avoid duplication in myconfig.SH and configpm.
7111version_patchlevel_string="version $patchlevel subversion $subversion"
7112case "$perl_patchlevel" in
71130|'') ;;
7114*)  perl_patchlevel=`echo $perl_patchlevel | sed 's/.* //'`
7115    version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel"
7116    ;;
7117esac
7118
7119$echo "(You have $package $version_patchlevel_string.)"
7120
7121case "$osname" in
7122dos|vms)
7123	: XXX Should be a Configure test for double-dots in filenames.
7124	version=`echo $revision $patchlevel $subversion | \
7125		 $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
7126	api_versionstring=`echo $api_revision $api_version $api_subversion | \
7127		 $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
7128	;;
7129*)
7130	version=`echo $revision $patchlevel $subversion | \
7131		 $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
7132	api_versionstring=`echo $api_revision $api_version $api_subversion | \
7133		 $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
7134	;;
7135esac
7136: Special case the 5.005_xx maintenance series, which used 5.005
7137: without any subversion label as a subdirectory in $sitelib
7138if test "${api_revision}${api_version}${api_subversion}" = "550"; then
7139	api_versionstring='5.005'
7140fi
7141
7142: determine the architecture name
7143echo " "
7144if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
7145	tarch=`arch`"-$osname"
7146elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
7147	if uname -m > tmparch 2>&1 ; then
7148		tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
7149			-e 's/$/'"-$osname/" tmparch`
7150	else
7151		tarch="$osname"
7152	fi
7153	$rm -f tmparch
7154else
7155	tarch="$osname"
7156fi
7157case "$myarchname" in
7158''|"$tarch") ;;
7159*)
7160	echo "(Your architecture name used to be $myarchname.)"
7161	archname=''
7162	;;
7163esac
7164case "$targetarch" in
7165'') ;;
7166*)  archname=`echo $targetarch|sed 's,^[^-]*-,,'` ;;
7167esac
7168myarchname="$tarch"
7169case "$archname" in
7170'') dflt="$tarch";;
7171*) dflt="$archname";;
7172esac
7173rp='What is your architecture name'
7174. ./myread
7175archname="$ans"
7176
7177: optionally add API version to the architecture for versioned archlibs
7178case "$useversionedarchname" in
7179$define|true|[yY]*) dflt='y';;
7180*)                  dflt='n';;
7181esac
7182rp='Add the Perl API version to your archname?'
7183. ./myread
7184case "$ans" in
7185y|Y)	useversionedarchname="$define" ;;
7186*)      useversionedarchname="$undef" ;;
7187esac
7188case "$useversionedarchname" in
7189$define)
7190	case "$archname" in
7191	*-$api_versionstring)
7192		echo "...and architecture name already has -$api_versionstring" >&4
7193		;;
7194	*)
7195		archname="$archname-$api_versionstring"
7196		echo "...setting architecture name to $archname." >&4
7197		;;
7198	esac
7199	;;
7200esac
7201
7202case "$usethreads" in
7203$define)
7204	echo "Threads selected." >&4
7205	case "$archname" in
7206	*-thread*) echo "...and architecture name already has -thread." >&4
7207		;;
7208	*)      archname="$archname-thread"
7209		echo "...setting architecture name to $archname." >&4
7210		;;
7211	esac
7212	;;
7213esac
7214case "$usemultiplicity" in
7215$define)
7216	echo "Multiplicity selected." >&4
7217	case "$archname" in
7218	*-multi*) echo "...and architecture name already has -multi." >&4
7219		;;
7220	*)      archname="$archname-multi"
7221		echo "...setting architecture name to $archname." >&4
7222		;;
7223	esac
7224	;;
7225esac
7226case "$use64bitint$use64bitall" in
7227*"$define"*)
7228	case "$archname64" in
7229	'')
7230		echo "This architecture is naturally 64-bit, not changing architecture name." >&4
7231		;;
7232	*)
7233		case "$use64bitint" in
7234		"$define") echo "64 bit integers selected." >&4 ;;
7235		esac
7236		case "$use64bitall" in
7237		"$define") echo "Maximal 64 bitness selected." >&4 ;;
7238		esac
7239		case "$archname" in
7240		*-$archname64*) echo "...and architecture name already has $archname64." >&4
7241			;;
7242		*)      archname="$archname-$archname64"
7243			echo "...setting architecture name to $archname." >&4
7244			;;
7245		esac
7246		;;
7247	esac
7248esac
7249case "$uselongdouble" in
7250$define)
7251	echo "Long doubles selected." >&4
7252	case "$longdblsize" in
7253	$doublesize)
7254		echo "...but long doubles are equal to doubles, not changing architecture name." >&4
7255		;;
7256	*)
7257		case "$archname" in
7258		*-ld*) echo "...and architecture name already has -ld." >&4
7259			;;
7260		*)      archname="$archname-ld"
7261			echo "...setting architecture name to $archname." >&4
7262			;;
7263		esac
7264		;;
7265	esac
7266	;;
7267esac
7268case "$usequadmath" in
7269$define)
7270	echo "quadmath selected." >&4
7271	case "$archname" in
7272	*-quadmath*) echo "...and architecture name already has -quadmath." >&4
7273		;;
7274	*)      archname="$archname-quadmath"
7275		echo "...setting architecture name to $archname." >&4
7276		;;
7277	esac
7278	;;
7279esac
7280if $test -f archname.cbu; then
7281	echo "Your platform has some specific hints for architecture name, using them..."
7282	. ./archname.cbu
7283fi
7284
7285: set the prefixit variable, to compute a suitable default value
7286prefixit='case "$3" in
7287""|none)
7288	case "$oldprefix" in
7289	"") eval "$1=\"\$$2\"";;
7290	*)
7291		case "$3" in
7292		"") eval "$1=";;
7293		none)
7294			eval "tp=\"\$$2\"";
7295			case "$tp" in
7296			""|" "|none) eval "$1=\"\$$2\"";;
7297			*) eval "$1=";;
7298			esac;;
7299		esac;;
7300	esac;;
7301*)
7302	eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
7303	case "$tp" in
7304	--|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
7305	/*-$oldprefix/*|\~*-$oldprefix/*)
7306		eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
7307	*) eval "$1=\"\$$2\"";;
7308	esac;;
7309esac'
7310
7311: determine installation style
7312: For now, try to deduce it from prefix unless it is already set.
7313: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
7314case "$installstyle" in
7315'')	case "$prefix" in
7316		*perl*) dflt='lib';;
7317		*) dflt='lib/perl5' ;;
7318	esac
7319	;;
7320*)	dflt="$installstyle" ;;
7321esac
7322: Probably not worth prompting for this since we prompt for all
7323: the directories individually, and the prompt would be too long and
7324: confusing anyway.
7325installstyle=$dflt
7326
7327: determine where public executables go
7328echo " "
7329set dflt bin bin
7330eval $prefixit
7331fn=d~
7332rp='Pathname where the public executables will reside?'
7333. ./getfile
7334if $test "X$ansexp" != "X$binexp"; then
7335	installbin=''
7336fi
7337prefixvar=bin
7338: XXX Bug? -- ignores Configure -Dinstallprefix setting.
7339: XXX If this is fixed, also fix the "start perl" hunk below, which relies on
7340:     this via initialinstalllocation
7341. ./setprefixvar
7342
7343case "$userelocatableinc" in
7344$define|true|[yY]*)	dflt='y' ;;
7345*)			dflt='n' ;;
7346esac
7347cat <<EOM
7348
7349Would you like to build Perl so that the installation is relocatable, so that
7350library paths in @INC are determined relative to the path of the perl binary?
7351This is not advised for system Perl installs, or if you need to run setid
7352scripts or scripts under taint mode.
7353
7354If this doesn't make any sense to you, just accept the default '$dflt'.
7355EOM
7356rp='Use relocatable @INC?'
7357. ./myread
7358case "$ans" in
7359y|Y)	val="$define" ;;
7360*)	val="$undef"  ;;
7361esac
7362set userelocatableinc
7363eval $setvar
7364
7365initialinstalllocation="$binexp"
7366: Default prefix is now "up one level from where the binaries are"
7367case "$userelocatableinc" in
7368$define|true|[yY]*)
7369    bin=".../"
7370    binexp=".../"
7371    prefix=".../.."
7372    prefixexp=".../.."
7373    installprefixexp=".../.."
7374    ;;
7375esac
7376
7377: determine where private library files go
7378: Usual default is /usr/local/lib/perl5/$version.
7379: Also allow things like /opt/perl/lib/$version, since
7380: /opt/perl/lib/perl5... would be redundant.
7381: The default "style" setting is made in installstyle.U
7382case "$installstyle" in
7383*lib/perl5*) set dflt privlib lib/$package/$version ;;
7384*)	 set dflt privlib lib/$version ;;
7385esac
7386eval $prefixit
7387$cat <<EOM
7388
7389There are some auxiliary files for $package that need to be put into a
7390private library directory that is accessible by everyone.
7391
7392EOM
7393fn=$binexp
7394fn=d~+
7395rp='Pathname where the private library files will reside?'
7396. ./getfile
7397prefixvar=privlib
7398. ./setprefixvar
7399
7400: set the prefixup variable, to restore leading tilda escape
7401prefixup='case "$prefixexp" in
7402"$prefix") ;;
7403*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
7404esac'
7405
7406: determine where public architecture dependent libraries go
7407set archlib archlib
7408eval $prefixit
7409: privlib default is /usr/local/lib/$package/$version
7410: archlib default is /usr/local/lib/$package/$version/$archname
7411: privlib may have an optional trailing /share.
7412tdflt=`echo $privlib | $sed 's,/share$,,'`
7413tdflt=$tdflt/$archname
7414case "$archlib" in
7415'')	dflt=$tdflt
7416	;;
7417*)	dflt="$archlib"
7418    ;;
7419esac
7420$cat <<EOM
7421
7422$spackage contains architecture-dependent library files.  If you are
7423sharing libraries in a heterogeneous environment, you might store
7424these files in a separate location.  Otherwise, you can just include
7425them with the rest of the public library files.
7426
7427EOM
7428fn=$binexp
7429fn=d+~
7430rp='Where do you want to put the public architecture-dependent libraries?'
7431. ./getfile
7432prefixvar=archlib
7433. ./setprefixvar
7434if $test X"$archlib" = X"$privlib"; then
7435	d_archlib="$undef"
7436else
7437	d_archlib="$define"
7438fi
7439
7440: see if setuid scripts can be secure
7441$cat <<EOM
7442
7443Some kernels have a bug that prevents setuid #! scripts from being
7444secure.  Some sites have disabled setuid #! scripts because of this.
7445
7446First let's decide if your kernel supports secure setuid #! scripts.
7447(If setuid #! scripts would be secure but have been disabled anyway,
7448don't say that they are secure if asked.)
7449
7450EOM
7451
7452val="$undef"
7453if $test -d /dev/fd; then
7454	echo "#!$ls" >reflect
7455	chmod +x,u+s reflect
7456	./reflect >flect 2>&1
7457	if $contains "/dev/fd" flect >/dev/null; then
7458		echo "Congratulations, your kernel has secure setuid scripts!" >&4
7459		val="$define"
7460	else
7461		$cat <<EOM
7462If you are not sure if they are secure, I can check but I'll need a
7463username and password different from the one you are using right now.
7464If you don't have such a username or don't want me to test, simply
7465enter 'none'.
7466
7467EOM
7468		rp='Other username to test security of setuid scripts with?'
7469		dflt='none'
7470		. ./myread
7471		case "$ans" in
7472		n|none)
7473			case "$d_suidsafe" in
7474			'')	echo "I'll assume setuid scripts are *not* secure." >&4
7475				dflt=n;;
7476			"$undef")
7477				echo "Well, the $hint value is *not* secure." >&4
7478				dflt=n;;
7479			*)	echo "Well, the $hint value *is* secure." >&4
7480				dflt=y;;
7481			esac
7482			;;
7483		*)
7484			$rm -f reflect flect
7485			echo "#!$ls" >reflect
7486			chmod +x,u+s reflect
7487			echo >flect
7488			chmod a+w flect
7489			echo '"su" will (probably) prompt you for '"$ans's password."
7490			su $ans -c './reflect >flect'
7491			if $contains "/dev/fd" flect >/dev/null; then
7492				echo "Okay, it looks like setuid scripts are secure." >&4
7493				dflt=y
7494			else
7495				echo "I don't think setuid scripts are secure." >&4
7496				dflt=n
7497			fi
7498			;;
7499		esac
7500		rp='Does your kernel have *secure* setuid scripts?'
7501		. ./myread
7502		case "$ans" in
7503		[yY]*)	val="$define";;
7504		*)	val="$undef";;
7505		esac
7506	fi
7507else
7508	echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
7509	echo "(That's for file descriptors, not floppy disks.)"
7510	val="$undef"
7511fi
7512set d_suidsafe
7513eval $setvar
7514
7515$rm -f reflect flect
7516
7517: now see if they want to do setuid emulation
7518if $test $patchlevel -lt 11; then
7519echo " "
7520val="$undef"
7521case "$d_suidsafe" in
7522"$define")
7523	val="$undef"
7524	echo "No need to emulate SUID scripts since they are secure here." >&4
7525	;;
7526*)
7527	$cat <<EOM
7528Some systems have disabled setuid scripts, especially systems where
7529setuid scripts cannot be secure.  On systems where setuid scripts have
7530been disabled, the setuid/setgid bits on scripts are currently
7531useless.  It is possible for $package to detect those bits and emulate
7532setuid/setgid in a secure fashion.  This emulation will only work if
7533setuid scripts have been disabled in your kernel.
7534
7535EOM
7536	case "$d_dosuid" in
7537	"$define") dflt=y ;;
7538	*) dflt=n ;;
7539	esac
7540	rp="Do you want to do setuid/setgid emulation?"
7541	. ./myread
7542	case "$ans" in
7543	[yY]*)	val="$define";;
7544	*)	val="$undef";;
7545	esac
7546	;;
7547esac
7548set d_dosuid
7549eval $setvar
7550else
7551    case "$d_dosuid" in
7552	"$define")
7553	cat >&4 <<EOH
7554
7555SUID emulation has been removed for 5.12
7556Please re-run Configure without -Dd_dosuid
7557
7558EOH
7559	exit 1;
7560	;;
7561    esac
7562    d_dosuid=undef
7563fi
7564
7565: Find perl5.005 or later.
7566echo "Looking for a previously installed perl5.005 or later... "
7567case "$perl5" in
7568'')	for tdir in `echo "$binexp$path_sep$PATH" | $sed "s/$path_sep/ /g"`; do
7569		: Check if this perl is recent and can load a simple module
7570		if $test -x $tdir/perl$exe_ext && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
7571			perl5=$tdir/perl
7572			break;
7573		elif $test -x $tdir/perl5$exe_ext && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
7574			perl5=$tdir/perl5
7575			break;
7576		fi
7577	done
7578	;;
7579*)	perl5="$perl5"
7580	;;
7581esac
7582case "$perl5" in
7583'')	echo "None found.  That's ok.";;
7584*)	echo "Using $perl5." ;;
7585esac
7586
7587: Set the siteprefix variables
7588$cat <<EOM
7589
7590After $package is installed, you may wish to install various
7591add-on modules and utilities.  Typically, these add-ons will
7592be installed under $prefix with the rest
7593of this package.  However, you may wish to install such add-ons
7594elsewhere under a different prefix.
7595
7596If you do not wish to put everything under a single prefix, that's
7597ok.  You will be prompted for the individual locations; this siteprefix
7598is only used to suggest the defaults.
7599
7600The default should be fine for most people.
7601
7602EOM
7603fn=d~+
7604rp='Installation prefix to use for add-on modules and utilities?'
7605: XXX Here might be another good place for an installstyle setting.
7606case "$siteprefix" in
7607'') dflt=$prefix ;;
7608*)  dflt=$siteprefix ;;
7609esac
7610. ./getfile
7611: XXX Prefixit unit does not yet support siteprefix and vendorprefix
7612oldsiteprefix=''
7613case "$siteprefix" in
7614'') ;;
7615*)	case "$ans" in
7616	"$prefix") ;;
7617	*) oldsiteprefix="$prefix";;
7618	esac
7619	;;
7620esac
7621siteprefix="$ans"
7622siteprefixexp="$ansexp"
7623
7624: determine where site specific libraries go.
7625: Usual default is /usr/local/lib/perl5/site_perl/$version
7626: The default "style" setting is made in installstyle.U
7627: XXX No longer works with Prefixit stuff.
7628prog=`echo $package | $sed 's/-*[0-9.]*$//'`
7629case "$sitelib" in
7630'') case "$installstyle" in
7631	*lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
7632	*)	 dflt=$siteprefix/lib/site_$prog/$version ;;
7633	esac
7634	;;
7635*)	dflt="$sitelib"
7636	;;
7637esac
7638$cat <<EOM
7639
7640The installation process will create a directory for
7641site-specific extensions and modules.  Most users find it convenient
7642to place all site-specific files in this directory rather than in the
7643main distribution directory.
7644
7645EOM
7646fn=d~+
7647rp='Pathname for the site-specific library files?'
7648. ./getfile
7649prefixvar=sitelib
7650. ./setprefixvar
7651sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
7652
7653: Determine list of previous versions to include in @INC
7654$cat > getverlist <<EOPL
7655#!$perl5
7656use strict;
7657use warnings;
7658use File::Basename;
7659my \$api_versionstring = "$api_versionstring";
7660my \$version = "$version";
7661my \$stem = "$sitelib_stem";
7662my \$archname = "$archname";
7663EOPL
7664	$cat >> getverlist <<'EOPL'
7665# The list found is stored twice for each entry: the original name, and
7666# the binary broken down version into pack "s>s>s>", so sorting is easy
7667# and unambiguous.  This will work for all versions that have a maximum
7668# of three digit per group separate by '.'s or '_'s. Names are extended
7669# with ".0.0" to ensure at least three elements for the pack.
7670#                                   -- H.Merijn Brand (m)'06 23-10-2006
7671
7672my @inc_version_list;
7673my @candidates;
7674# XXX Redo to do opendir/readdir?
7675if (-d $stem) {
7676    chdir($stem);
7677    ;@candidates = map {
7678	[ $_, pack "s>s>s>", split m/[._]/, "$_.0.0" ] } glob("5.*");
7679    ;@candidates = sort { $a->[1] cmp $b->[1]} @candidates;
7680}
7681else {
7682    ;@candidates = ();
7683}
7684
7685my ($pversion, $aversion, $vsn5005) = map {
7686    pack "s>s>s>", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005";
7687foreach my $d (@candidates) {
7688    if ($d->[1] lt $pversion) {
7689	if ($d->[1] ge $aversion) {
7690	    unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);
7691	}
7692	elsif ($d->[1] ge $vsn5005) {
7693	    unshift(@inc_version_list, grep { -d } $d->[0]);
7694	}
7695    }
7696    else {
7697	# Skip newer version.  I.e. don't look in
7698	# 5.7.0 if we're installing 5.6.1.
7699    }
7700}
7701
7702if (@inc_version_list) {
7703    print join(' ', @inc_version_list);
7704}
7705else {
7706    # Blank space to preserve value for next Configure run.
7707    print " ";
7708}
7709EOPL
7710chmod +x getverlist
7711case "$inc_version_list" in
7712'')	if test -x "$perl5$exe_ext"; then
7713		dflt=`$perl5 getverlist`
7714	else
7715		dflt='none'
7716	fi
7717	;;
7718$undef) dflt='none' ;;
7719*)  eval dflt=\"$inc_version_list\" ;;
7720esac
7721case "$dflt" in
7722''|' ') dflt=none ;;
7723esac
7724case "$dflt" in
77255.005) dflt=none ;;
7726esac
7727$cat <<EOM
7728
7729In order to ease the process of upgrading, this version of perl
7730can be configured to use modules built and installed with earlier
7731versions of perl that were installed under $prefix.  Specify here
7732the list of earlier versions that this version of perl should check.
7733If Configure detected no earlier versions of perl installed under
7734$prefix, then the list will be empty.  Answer 'none' to tell perl
7735to not search earlier versions.
7736
7737The default should almost always be sensible, so if you're not sure,
7738just accept the default.
7739EOM
7740
7741rp='List of earlier versions to include in @INC?'
7742. ./myread
7743case "$ans" in
7744[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
7745*) inc_version_list="$ans" ;;
7746esac
7747case "$inc_version_list" in
7748''|' ')
7749	inc_version_list_init='0'
7750	d_inc_version_list="$undef"
7751	;;
7752*)	inc_version_list_init=`echo $inc_version_list |
7753		$sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
7754	d_inc_version_list="$define"
7755	;;
7756esac
7757$rm -f getverlist
7758
7759: see if malloc/malloc.h has to be included
7760set malloc/malloc.h i_mallocmalloc
7761eval $inhdr
7762
7763: see if this is a malloc.h system
7764: we want a real compile instead of Inhdr because some systems have a
7765: malloc.h that just gives a compile error saying to use stdlib.h instead
7766echo " "
7767$cat >try.c <<EOCP
7768#include <stdlib.h>
7769#include <malloc.h>
7770#$i_mallocmalloc I_MALLOCMALLOC
7771#ifdef I_MALLOCMALLOC
7772# include <malloc/malloc.h>
7773#endif
7774
7775int main () { return 0; }
7776EOCP
7777set try
7778if eval $compile; then
7779    echo "<malloc.h> found." >&4
7780    val="$define"
7781else
7782    echo "<malloc.h> NOT found." >&4
7783    val="$undef"
7784fi
7785$rm_try
7786set i_malloc
7787eval $setvar
7788
7789: check for length of pointer
7790echo " "
7791case "$ptrsize" in
7792'')
7793	echo "Checking to see how big your pointers are..." >&4
7794	$cat >try.c <<EOCP
7795#include <stdio.h>
7796#$i_stdlib I_STDLIB
7797#ifdef I_STDLIB
7798#include <stdlib.h>
7799#endif
7800int main()
7801{
7802    printf("%d\n", (int)sizeof(void *));
7803    exit(0);
7804}
7805EOCP
7806	set try
7807	if eval $compile_ok; then
7808		ptrsize=`$run ./try`
7809		echo "Your pointers are $ptrsize bytes long."
7810	else
7811		dflt='4'
7812		echo "(I can't seem to compile the test program.  Guessing...)" >&4
7813		rp="What is the size of a pointer (in bytes)?"
7814		. ./myread
7815		ptrsize="$ans"
7816	fi
7817	;;
7818esac
7819$rm_try
7820case "$use64bitall" in
7821"$define"|true|[yY]*)
7822	case "$ptrsize" in
7823	4)	cat <<EOM >&4
7824
7825*** You have chosen a maximally 64-bit build,
7826*** but your pointers are only 4 bytes wide.
7827*** Please rerun Configure without -Duse64bitall.
7828EOM
7829		case "$d_quad" in
7830		define)
7831			cat <<EOM >&4
7832*** Since you have quads, you could possibly try with -Duse64bitint.
7833EOM
7834			;;
7835		esac
7836		cat <<EOM >&4
7837*** Cannot continue, aborting.
7838
7839EOM
7840
7841		exit 1
7842		;;
7843	esac
7844	;;
7845esac
7846
7847: determine whether to use malloc wrapping
7848echo " "
7849case "$usemallocwrap" in
7850[yY]*|true|$define)	dflt='y' ;;
7851[nN]*|false|$undef)	dflt='n' ;;
7852*)	case "$usedevel" in
7853	[yY]*|true|$define)	dflt='y' ;;
7854	*) dflt='n' ;;
7855	esac
7856	;;
7857esac
7858rp="Do you wish to wrap malloc calls to protect against potential overflows?"
7859. ./myread
7860usemallocwrap="$ans"
7861case "$ans" in
7862y*|true)
7863	usemallocwrap="$define" ;;
7864*)
7865	usemallocwrap="$undef" ;;
7866esac
7867
7868: determine which malloc to compile in
7869echo " "
7870case "$usemymalloc" in
7871[yY]*|true|$define)	dflt='y' ;;
7872[nN]*|false|$undef)	dflt='n' ;;
7873*)	case "$ptrsize" in
7874	4) dflt='y' ;;
7875	*) dflt='n' ;;
7876	esac
7877	if test "$useithreads" = "$define"; then dflt='n'; fi
7878	;;
7879esac
7880rp="Do you wish to attempt to use the malloc that comes with $package?"
7881. ./myread
7882usemymalloc="$ans"
7883case "$ans" in
7884y*|true)
7885	usemymalloc='y'
7886	mallocsrc='malloc.c'
7887	mallocobj="malloc$_o"
7888	d_mymalloc="$define"
7889	case "$libs" in
7890	*-lmalloc*)
7891		: Remove malloc from list of libraries to use
7892		echo "Removing unneeded -lmalloc from library list" >&4
7893		set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
7894		shift
7895		libs="$*"
7896		echo "libs = $libs" >&4
7897		;;
7898	esac
7899	;;
7900*)
7901	usemymalloc='n'
7902	mallocsrc=''
7903	mallocobj=''
7904	d_mymalloc="$undef"
7905	;;
7906esac
7907
7908: compute the return types of malloc and free
7909echo " "
7910$cat >malloc.c <<END
7911#$i_malloc I_MALLOC
7912#$i_stdlib I_STDLIB
7913#include <stdio.h>
7914#include <sys/types.h>
7915#ifdef I_MALLOC
7916#include <malloc.h>
7917#endif
7918#ifdef I_STDLIB
7919#include <stdlib.h>
7920#endif
7921#ifdef TRY_MALLOC
7922void *malloc();
7923#endif
7924#ifdef TRY_FREE
7925void free();
7926#endif
7927END
7928case "$malloctype" in
7929'')
7930	if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
7931		malloctype='void *'
7932	else
7933		malloctype='char *'
7934	fi
7935	;;
7936esac
7937echo "Your system wants malloc to return '$malloctype', it would seem." >&4
7938
7939case "$freetype" in
7940'')
7941	if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
7942		freetype='void'
7943	else
7944		freetype='int'
7945	fi
7946	;;
7947esac
7948echo "Your system uses $freetype free(), it would seem." >&4
7949$rm -f malloc.[co]
7950: determine where site specific architecture-dependent libraries go.
7951: sitelib  default is /usr/local/lib/perl5/site_perl/$version
7952: sitearch default is /usr/local/lib/perl5/site_perl/$version/$archname
7953: sitelib may have an optional trailing /share.
7954case "$sitearch" in
7955'')	dflt=`echo $sitelib | $sed 's,/share$,,'`
7956	dflt="$dflt/$archname"
7957	;;
7958*)	dflt="$sitearch"
7959	;;
7960esac
7961set sitearch sitearch none
7962eval $prefixit
7963$cat <<EOM
7964
7965The installation process will also create a directory for
7966architecture-dependent site-specific extensions and modules.
7967
7968EOM
7969fn=d~+
7970rp='Pathname for the site-specific architecture-dependent library files?'
7971. ./getfile
7972prefixvar=sitearch
7973. ./setprefixvar
7974if $test X"$sitearch" = X"$sitelib"; then
7975	d_sitearch="$undef"
7976else
7977	d_sitearch="$define"
7978fi
7979
7980: Set the vendorprefix variables
7981$cat <<EOM
7982
7983The installation process will also create a directory for
7984vendor-supplied add-ons.  Vendors who supply perl with their system
7985may find it convenient to place all vendor-supplied files in this
7986directory rather than in the main distribution directory.  This will
7987ease upgrades between binary-compatible maintenance versions of perl.
7988
7989Of course you may also use these directories in whatever way you see
7990fit.  For example, you might use them to access modules shared over a
7991company-wide network.
7992
7993The default answer should be fine for most people.
7994This causes further questions about vendor add-ons to be skipped
7995and no vendor-specific directories will be configured for perl.
7996
7997EOM
7998rp='Do you want to configure vendor-specific add-on directories?'
7999case "$usevendorprefix" in
8000define|true|[yY]*) dflt=y ;;
8001*)	: User may have set vendorprefix directly on Configure command line.
8002	case "$vendorprefix" in
8003	''|' ') dflt=n ;;
8004	*)	dflt=y ;;
8005	esac
8006	;;
8007esac
8008. ./myread
8009case "$ans" in
8010[yY]*)	fn=d~+
8011	rp='Installation prefix to use for vendor-supplied add-ons?'
8012	case "$vendorprefix" in
8013	'') dflt="$prefix" ;;
8014	*)  dflt=$vendorprefix ;;
8015	esac
8016	. ./getfile
8017	: XXX Prefixit unit does not yet support siteprefix and vendorprefix
8018	oldvendorprefix=''
8019	case "$vendorprefix" in
8020	'') ;;
8021	*)	case "$ans" in
8022		"$prefix") ;;
8023		*) oldvendorprefix="$prefix";;
8024		esac
8025		;;
8026	esac
8027	usevendorprefix="$define"
8028	vendorprefix="$ans"
8029	vendorprefixexp="$ansexp"
8030	;;
8031*)	usevendorprefix="$undef"
8032	vendorprefix=''
8033	vendorprefixexp=''
8034	;;
8035esac
8036
8037: Set the vendorlib variables
8038case "$vendorprefix" in
8039'')	d_vendorlib="$undef"
8040	vendorlib=''
8041	vendorlibexp=''
8042	;;
8043*)	d_vendorlib="$define"
8044	: determine where vendor-supplied modules go.
8045	: Usual default is /usr/local/lib/perl5/vendor_perl/$version
8046	case "$vendorlib" in
8047	'')
8048		prog=`echo $package | $sed 's/-*[0-9.]*$//'`
8049		case "$installstyle" in
8050		*lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
8051		*)	     dflt=$vendorprefix/lib/vendor_$prog/$version ;;
8052		esac
8053		;;
8054	*)	dflt="$vendorlib"
8055		;;
8056	esac
8057	fn=d~+
8058	rp='Pathname for the vendor-supplied library files?'
8059	. ./getfile
8060	vendorlib="$ans"
8061	vendorlibexp="$ansexp"
8062	;;
8063esac
8064vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
8065prefixvar=vendorlib
8066. ./installprefix
8067
8068: Set the vendorarch variables
8069case "$vendorprefix" in
8070'')	d_vendorarch="$undef"
8071	vendorarch=''
8072	vendorarchexp=''
8073	;;
8074*)	d_vendorarch="$define"
8075	: determine where vendor-supplied architecture-dependent libraries go.
8076	: vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
8077	: vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
8078	: vendorlib may have an optional trailing /share.
8079	case "$vendorarch" in
8080	'')	dflt=`echo $vendorlib | $sed 's,/share$,,'`
8081		dflt="$dflt/$archname"
8082		;;
8083	*)	dflt="$vendorarch" ;;
8084	esac
8085	fn=d~+
8086	rp='Pathname for vendor-supplied architecture-dependent files?'
8087	. ./getfile
8088	vendorarch="$ans"
8089	vendorarchexp="$ansexp"
8090	;;
8091esac
8092prefixvar=vendorarch
8093. ./installprefix
8094if $test X"$vendorarch" = X"$vendorlib"; then
8095	d_vendorarch="$undef"
8096else
8097	d_vendorarch="$define"
8098fi
8099
8100: Final catch-all directories to search
8101$cat <<EOM
8102
8103Lastly, you can have perl look in other directories for extensions and
8104modules in addition to those already specified.
8105These directories will be searched after
8106	$sitearch
8107	$sitelib
8108EOM
8109test X"$vendorlib" != "X" && echo '	' $vendorlib
8110test X"$vendorarch" != "X" && echo '	' $vendorarch
8111echo ' '
8112case "$otherlibdirs" in
8113''|' ') dflt='none' ;;
8114*)	dflt="$otherlibdirs" ;;
8115esac
8116$cat <<EOM
8117Enter a colon-separated set of extra paths to include in perl's @INC
8118search path, or enter 'none' for no extra paths.
8119
8120EOM
8121
8122rp='Colon-separated list of additional directories for perl to search?'
8123. ./myread
8124case "$ans" in
8125' '|''|none)	otherlibdirs=' ' ;;
8126*)	otherlibdirs="$ans" ;;
8127esac
8128case "$otherlibdirs" in
8129' ') val=$undef ;;
8130*)	val=$define ;;
8131esac
8132set d_perl_otherlibdirs
8133eval $setvar
8134
8135: DTrace support
8136dflt_dtrace='/usr/sbin/dtrace'
8137$test -x /usr/bin/dtrace && dflt_dtrace='/usr/bin/dtrace'
8138
8139cat <<EOM
8140
8141Perl can be built to support DTrace on platforms that support it.
8142DTrace is a diagnosis and performance analysis tool from Sun.
8143
8144If this doesn't make any sense to you, just accept the default.
8145EOM
8146
8147while $test 1 ; do
8148	case "$usedtrace" in
8149	$define|true|[yY]*)
8150		dflt='y'
8151		;;
8152	$undef|false|[nN]*)
8153		dflt='n'
8154		dflt_dtrace=""
8155		;;
8156	?*)
8157		dflt='y'
8158		dflt_dtrace=$usedtrace
8159		;;
8160	*)
8161		dflt='n'
8162		;;
8163	esac
8164
8165	rp='Support DTrace if available?'
8166	. ./myread
8167	case "$ans" in
8168	y|Y)	val="$define" ;;
8169	*)      val="$undef" ;;
8170	esac
8171	set usedtrace
8172	eval $setvar
8173
8174	test "X$usedtrace" != "X$define" && break
8175
8176	echo " "
8177	rp='Where is the dtrace executable?'
8178	dflt=$dflt_dtrace
8179	. ./getfile
8180	val="$ans"
8181	set dtrace
8182	eval $setvar
8183
8184	if $test -f $dtrace
8185	then
8186		if $dtrace -h -s ../perldtrace.d \
8187			-o perldtrace.tmp >/dev/null 2>&1 \
8188			&& rm -f perldtrace.tmp
8189		then
8190			echo " "
8191			echo "Good: your $dtrace knows about the -h flag."
8192		else
8193			cat >&2 <<EOM
8194
8195*** $me:  Fatal Error:  $dtrace doesn't support -h flag
8196***
8197*** Your installed dtrace doesn't support the -h switch to compile a D
8198*** program into a C header. Can't continue.
8199
8200EOM
8201			exit 1
8202		fi
8203		break;
8204	fi
8205
8206	case "$fastread" in
8207	yes)
8208		cat >&2 <<EOM
8209
8210*** $me:  Fatal Error:  $dtrace not found.
8211*** Can't continue.
8212
8213EOM
8214		exit 1
8215		;;
8216	*)
8217		echo "*** $dtrace was not found."
8218		echo " "
8219		;;
8220	esac
8221done
8222
8223: See if we want extra modules installed
8224echo " "
8225case "$extras" in
8226'') dflt='n';;
8227*) dflt='y';;
8228esac
8229cat <<EOM
8230Perl can be built with extra modules or bundles of modules which
8231will be fetched from the CPAN and installed alongside Perl.
8232
8233Notice that you will need access to the CPAN; either via the Internet,
8234or a local copy, for example a CD-ROM or a local CPAN mirror.  (You will
8235be asked later to configure the CPAN.pm module which will in turn do
8236the installation of the rest of the extra modules or bundles.)
8237
8238Notice also that if the modules require any external software such as
8239libraries and headers (the libz library and the zlib.h header for the
8240Compress::Zlib module, for example) you MUST have any such software
8241already installed, this configuration process will NOT install such
8242things for you.
8243
8244If this doesn't make any sense to you, just accept the default '$dflt'.
8245EOM
8246rp='Install any extra modules (y or n)?'
8247. ./myread
8248case "$ans" in
8249y|Y)
8250	cat <<EOM
8251
8252Please list any extra modules or bundles to be installed from CPAN,
8253with spaces between the names.  The names can be in any format the
8254'install' command of CPAN.pm will understand.  (Answer 'none',
8255without the quotes, to install no extra modules or bundles.)
8256EOM
8257	rp='Extras?'
8258	dflt="$extras"
8259	. ./myread
8260	extras="$ans"
8261esac
8262case "$extras" in
8263''|'none')
8264	val=''
8265	$rm -f ../extras.lst
8266	;;
8267*)	echo "(Saving the list of extras for later...)"
8268	echo "$extras" > ../extras.lst
8269	val="'$extras'"
8270	;;
8271esac
8272set extras
8273eval $setvar
8274echo " "
8275
8276: determine where html pages for programs go
8277set html1dir html1dir none
8278eval $prefixit
8279$cat <<EOM
8280
8281If you wish to install html files for programs in $spackage, indicate
8282the appropriate directory here.  To skip installing html files,
8283answer "none".
8284EOM
8285case "$html1dir" in
8286''|none|$undef|' ') dflt=none ;;
8287*) dflt=$html1dir ;;
8288esac
8289fn=dn+~
8290rp="Directory for the main $spackage html pages?"
8291. ./getfile
8292prefixvar=html1dir
8293. ./setprefixvar
8294: Use ' ' for none so value is preserved next time through Configure
8295$test X"$html1dir" = "X" && html1dir=' '
8296
8297: determine where html pages for libraries and modules go
8298set html3dir html3dir none
8299eval $prefixit
8300$cat <<EOM
8301
8302If you wish to install html files for modules associated with $spackage,
8303indicate the appropriate directory here.  To skip installing html files,
8304answer "none".
8305EOM
8306: There is no obvious default.  If they have specified html1dir, then
8307: try to key off that, possibly changing .../html1 into .../html3.
8308case "$html3dir" in
8309'') html3dir=`echo "$html1dir" | $sed 's/1$/3$/'` ;;
8310*) dflt=$html3dir ;;
8311esac
8312fn=dn+~
8313rp="Directory for the $spackage module html pages?"
8314. ./getfile
8315prefixvar=html3dir
8316. ./setprefixvar
8317: Use ' ' for none so value is preserved next time through Configure
8318$test X"$html3dir" = "X" && html3dir=' '
8319
8320: determine whether to install perl also as /usr/bin/perl
8321
8322echo " "
8323if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
8324	$cat <<EOM
8325Many scripts expect perl to be installed as /usr/bin/perl.
8326
8327If you want to, I can install the perl you are about to compile
8328as /usr/bin/perl (in addition to $bin/perl).
8329EOM
8330	if test -f /usr/bin/perl; then
8331	    $cat <<EOM
8332
8333However, please note that because you already have a /usr/bin/perl,
8334overwriting that with a new Perl would very probably cause problems.
8335Therefore I'm assuming you don't want to do that (unless you insist).
8336
8337EOM
8338	    case "$installusrbinperl" in
8339	    "$define"|[yY]*)	dflt='y';;
8340	    *)			dflt='n';;
8341	    esac
8342	else
8343	    $cat <<EOM
8344
8345Since you don't have a /usr/bin/perl I'm assuming creating one is okay.
8346
8347EOM
8348	    case "$installusrbinperl" in
8349	    "$undef"|[nN]*)	dflt='n';;
8350	    *)			dflt='y';;
8351	    esac
8352	fi
8353	rp="Do you want to install perl as /usr/bin/perl?"
8354	. ./myread
8355	case "$ans" in
8356	[yY]*)	val="$define";;
8357	*)	val="$undef" ;;
8358	esac
8359else
8360	val="$undef"
8361fi
8362set installusrbinperl
8363eval $setvar
8364
8365: see if dlopen exists
8366xxx_runnm="$runnm"
8367xxx_ccflags="$ccflags"
8368runnm=false
8369: with g++ one needs -shared to get is-in-libc to work for dlopen
8370case "$gccversion" in
8371'')	;;
8372*Clang*)	;;
8373*)	case "$d_cplusplus" in
8374	"$define") ccflags="$ccflags -shared" ;;
8375	esac
8376	;;
8377esac
8378set dlopen d_dlopen
8379eval $inlibc
8380runnm="$xxx_runnm"
8381ccflags="$xxx_ccflags"
8382
8383: see if this is a unistd.h system
8384set unistd.h i_unistd
8385eval $inhdr
8386
8387: determine which dynamic loading, if any, to compile in
8388echo " "
8389dldir="ext/DynaLoader"
8390case "$usedl" in
8391    $define|y|true)
8392	dflt='y'
8393	usedl="$define"
8394	;;
8395    $undef|n|false)
8396	dflt='n'
8397	usedl="$undef"
8398	;;
8399    *)
8400	dflt='n'
8401	case "$d_dlopen" in
8402	    $define) dflt='y' ;;
8403	esac
8404	: Does a dl_xxx.xs file exist for this operating system
8405	$test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
8406	;;
8407esac
8408rp="Do you wish to use dynamic loading?"
8409. ./myread
8410usedl="$ans"
8411bin_ELF="$undef"
8412case "$ans" in
8413    y*) usedl="$define"
8414	case "$dlsrc" in
8415	    '') if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
8416		    dflt="$dldir/dl_${osname}.xs"
8417		elif $test "$d_dlopen" = "$define" ; then
8418		    dflt="$dldir/dl_dlopen.xs"
8419		else
8420		    dflt=''
8421		fi
8422		;;
8423	    *)  dflt="$dldir/$dlsrc"
8424		;;
8425	esac
8426	echo "The following dynamic loading files are available:"
8427	: Can not go over to $dldir because getfile has path hard-coded in.
8428	tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir"
8429	rp="Source file to use for dynamic loading"
8430	fn="fne"
8431	gfpth="$src"
8432	. ./getfile
8433	usedl="$define"
8434	: emulate basename
8435	dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'`
8436
8437	$cat << EOM
8438
8439Some systems may require passing special flags to $cc -c to
8440compile modules that will be used to create a shared library.
8441To use no flags, say "none".
8442
8443EOM
8444	case "$cccdlflags" in
8445	    '') case "$gccversion" in
8446		'') case "$osname" in
8447			hpux)	dflt='+z' ;;
8448			irix*)	dflt='-KPIC' ;;
8449			svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
8450			sunos)	dflt='-pic' ;;
8451			*)	dflt='none' ;;
8452		    esac
8453		    ;;
8454		*)  case "$osname" in
8455			darwin) dflt='none' ;;
8456			*linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
8457			*)	dflt='-fpic' ;;
8458		    esac ;;
8459		esac ;;
8460	    ' ') dflt='none' ;;
8461	    *)   dflt="$cccdlflags" ;;
8462	esac
8463
8464	case "$dflt" in
8465	    none) dflt='' ;;
8466	esac
8467
8468	# If -Dsysroot was specified, now's the time to add it
8469	# to cccdlflags
8470	if test "X$sysroot" != X; then
8471	    case "$gccversion" in
8472		'') ;;
8473		*)  case "$dflt" in
8474			*sysroot*) ;;
8475			'undef'|*)
8476			    dflt="$dflt --sysroot=$sysroot" ;;
8477		    esac
8478		    ;;
8479	    esac
8480	fi
8481
8482	case "$dflt" in
8483	    '') dflt='none';;
8484	esac
8485
8486	rp="Any special flags to pass to $cc -c to compile shared library modules?"
8487	. ./myread
8488	case "$ans" in
8489	    none) cccdlflags=' ' ;;
8490	    *)    cccdlflags="$ans" ;;
8491	esac
8492
8493	cat << EOM
8494
8495Some systems use ld to create libraries that can be dynamically loaded,
8496while other systems (such as those using ELF) use $cc.
8497
8498EOM
8499
8500: Determine if this is ELF
8501	$cat >try.c <<EOM
8502/* Test for whether ELF binaries are produced */
8503#include <fcntl.h>
8504#$i_stdlib I_STDLIB
8505#ifdef I_STDLIB
8506#include <stdlib.h>
8507#endif
8508#$i_unistd I_UNISTD
8509#ifdef I_UNISTD
8510#include <unistd.h>
8511#endif
8512int main() {
8513    char b[4];
8514    int i = open("a.out",O_RDONLY);
8515    if(i == -1)
8516	exit(1); /* fail */
8517    if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
8518	exit(0); /* succeed (yes, it is ELF) */
8519    exit(1); /* fail */
8520}
8521EOM
8522	if $cc $ccflags $ldflags -o a.out try.c >/dev/null 2>&1 && $run ./a.out; then
8523	    bin_ELF="$define"
8524	fi
8525	$rm_try
8526
8527	case "$ld" in
8528	    '') if $test $bin_ELF = "$define"; then
8529		    cat <<EOM
8530You appear to have ELF support.  I'll use $cc to build dynamic libraries.
8531EOM
8532		    dflt="$cc"
8533		else
8534		    echo "I'll use ld to build dynamic libraries."
8535		    dflt='ld'
8536		fi
8537		;;
8538	    *)  dflt="$ld"
8539		;;
8540	esac
8541
8542	rp="What command should be used to create dynamic libraries?"
8543	. ./myread
8544	ld="$ans"
8545
8546	cat << EOM
8547
8548Some systems may require passing special flags to $ld to create a
8549library that can be dynamically loaded.  If your ld flags include
8550-L/other/path options to locate libraries outside your loader's normal
8551search path, you may need to specify those -L options here as well.  To
8552use no flags, say "none".
8553
8554EOM
8555	case "$lddlflags" in
8556	    '') case "$osname" in
8557		    haiku) dflt='-shared' ;;
8558		    hpux) dflt='-b';
8559			  case "$gccversion" in
8560			      '') dflt="$dflt +vnocompatwarnings" ;;
8561			  esac
8562			  ;;
8563		    *linux*|irix*|gnu*)  dflt="-shared $optimize" ;;
8564		    solaris) # See [perl #66604].
8565			    # On Solaris 11, gcc -m64 on amd64
8566			    # appears not to understand -G.  gcc versions at
8567			    # least as old as 3.4.3 support -shared, so just
8568			    # use that with Solaris 11 and later, but keep
8569			    # the old behavior for older Solaris versions.
8570			    case "$gccversion" in
8571				'') dflt='-G' ;;
8572				*)  case "$osvers" in
8573					2.?|2.10) dflt='-G' ;;
8574					*) dflt='-shared' ;;
8575				    esac
8576				    ;;
8577			    esac
8578			    ;;
8579		    sunos) dflt='-assert nodefinitions' ;;
8580		    svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
8581		    *)     dflt='none' ;;
8582		esac
8583		;;
8584	    *) dflt="$lddlflags" ;;
8585	esac
8586
8587	: Only do this for gcc, since, for example, qcc has no concept
8588	: of --sysroot.
8589	if $test "X$sysroot" != X; then
8590	    case "$gccversion" in
8591		'') ;;
8592		*)  dflt="$dflt --sysroot=$sysroot" ;;
8593	    esac
8594	fi
8595
8596	: Try to guess additional flags to pick up local libraries.
8597	: Be careful not to append to a plain 'none'
8598	case "$dflt" in
8599	    none) dflt='' ;;
8600	esac
8601	for thisflag in $ldflags; do
8602	    case "$thisflag" in
8603		-L*|-R*|-Wl,-R*)
8604		    case " $dflt " in
8605			*" $thisflag "*) ;;
8606			*) dflt="$dflt $thisflag" ;;
8607		    esac
8608		    ;;
8609	    esac
8610	done
8611
8612	case "$dflt" in
8613	    ''|' ') dflt='none' ;;
8614	esac
8615
8616	case "$ldflags" in
8617	    *-fstack-protector-strong*)
8618		case "$dflt" in
8619		    *-fstack-protector-strong*) ;; # Don't add it again
8620		    *) dflt="$dflt -fstack-protector-strong" ;;
8621		esac
8622		;;
8623	    *-fstack-protector*)
8624		case "$dflt" in
8625		    *-fstack-protector*) ;; # Don't add it again
8626		    *) dflt="$dflt -fstack-protector" ;;
8627		esac
8628		;;
8629	esac
8630
8631	rp="Any special flags to pass to $ld to create a dynamically loaded library?"
8632	. ./myread
8633	case "$ans" in
8634	    none) lddlflags=' ' ;;
8635	    *) lddlflags="$ans" ;;
8636	esac
8637
8638	cat <<EOM
8639
8640Some systems may require passing special flags to $cc to indicate that
8641the resulting executable will use dynamic linking.  To use no flags,
8642say "none".
8643
8644EOM
8645	case "$ccdlflags" in
8646	    '') case "$osname" in
8647		    *linux*|hpux|gnu*) dflt='-Wl,-E' ;;
8648		    sunos)             dflt='none'   ;;
8649		    *)                 dflt='none'   ;;
8650		esac ;;
8651	    ' ') dflt='none' ;;
8652	    *)   dflt="$ccdlflags" ;;
8653	esac
8654	rp="Any special flags to pass to $cc to use dynamic linking?"
8655	. ./myread
8656	case "$ans" in
8657	    none) ccdlflags=' ' ;;
8658	    *)    ccdlflags="$ans" ;;
8659	esac
8660	;;
8661
8662    *)  usedl="$undef"
8663	ld='ld'
8664	dlsrc='dl_none.xs'
8665	lddlflags=''
8666	ccdlflags=''
8667	;;
8668esac
8669
8670ld_can_script="$undef"
8671case "$bin_ELF$usedl" in
8672    $define$define)
8673	# Abuse try.h and a.out names for neat cleanup
8674	$cat >try.c <<EOM
8675void foo() {}
8676void bar() {}
8677EOM
8678	$cat >try.h <<EOM
8679LIBTEST_42 {
8680 global:
8681  foo;
8682 local: *;
8683 };
8684EOM
8685	if $cc $cccdlflags $ccdlflags $ccflags \
8686	       $ldflags $lddlflags -o a.out try.c \
8687	       -Wl,--version-script=try.h >/dev/null 2>&1 \
8688	   &&  $test -s a.out ; then
8689	    echo "ld supports scripting" >&4
8690	    ld_can_script="$define"
8691	else
8692	    echo "ld does not support scripting" >&4
8693	fi
8694	$rm_try
8695	;;
8696esac
8697
8698: Do we want a shared libperl?
8699also=''
8700case "$usedl" in
8701$undef)
8702	# No dynamic loading being used, so don't bother even to prompt.
8703	useshrplib='false'
8704	;;
8705*)	case "$useshrplib" in
8706	'')	case "$osname" in
8707		svr4*|nonstopux|dgux|dynixptx|esix|powerux|haiku|cygwin*)
8708			dflt=y
8709			also='Building a shared libperl is required for dynamic loading to work on your system.'
8710			;;
8711		*)	dflt=n
8712			;;
8713		esac
8714		;;
8715	$define|true|[Yy]*)
8716		dflt=y
8717		;;
8718	*)	dflt=n
8719		;;
8720	esac
8721	$cat << EOM
8722
8723The perl executable is normally obtained by linking perlmain.c with
8724libperl${_a}, any static extensions (usually just DynaLoader), and
8725any other libraries needed on this system (such as -lm, etc.).  Since
8726your system supports dynamic loading, it is probably possible to build
8727a shared libperl.$so.  If you will have more than one executable linked
8728to libperl.$so, this will significantly reduce the size of each
8729executable, but it may have a noticeable effect on performance.  The
8730default is probably sensible for your system.
8731$also
8732
8733EOM
8734	rp="Build a shared libperl.$so (y/n)"
8735	. ./myread
8736	case "$ans" in
8737	true|$define|[Yy]*)
8738		useshrplib='true'  ;;
8739	*)	useshrplib='false' ;;
8740	esac
8741	;;
8742esac
8743
8744case "$useshrplib" in
8745true)
8746	case "$userelocatableinc" in
8747	true|define)
8748		echo "Cannot build with both -Duserelocatableinc and -Duseshrplib" >&4
8749		echo "See INSTALL for an explanation why that won't work." >&4
8750		exit 4
8751		;;
8752	esac
8753	case "$libperl" in
8754	'')
8755		# Figure out a good name for libperl.so.  Since it gets stored in
8756		# a version-specific architecture-dependent library, the version
8757		# number isn't really that important, except for making cc/ld happy.
8758		#
8759		# A name such as libperl.so.10.1
8760		majmin="libperl.$so.$patchlevel.$subversion"
8761		# A name such as libperl.so.100
8762		majonly=`echo $patchlevel $subversion |
8763			$awk '{printf "%d%02d", $1, $2}'`
8764		majonly=libperl.$so.$majonly
8765		# I'd prefer to keep the os-specific stuff here to a minimum, and
8766		# rely on figuring it out from the naming of libc.
8767		case "${osname}${osvers}" in
8768		*linux*|gnu*)  # ld won't link with a bare -lperl otherwise.
8769			dflt=libperl.$so
8770			;;
8771		cygwin*) # ld links now against the dll directly
8772			majmin="cygperl5_${patchlevel}_${subversion}.${so}"
8773			majonly=`echo $patchlevel $subversion |
8774				$awk '{printf "%03d%03d", $1, $2}'`
8775			majonly=cygperl5.$majonly.$so
8776			dflt=$majmin
8777			;;
8778		*)	# Try to guess based on whether libc has major.minor.
8779			case "$libc" in
8780			*libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
8781			*libc.$so.[0-9]*) dflt=$majonly ;;
8782			*)	dflt=libperl.$so ;;
8783			esac
8784			;;
8785		esac
8786		;;
8787	*)	dflt=$libperl
8788		;;
8789	esac
8790	cat << EOM
8791
8792I need to select a good name for the shared libperl.  If your system uses
8793library names with major and minor numbers, then you might want something
8794like $majmin.  Alternatively, if your system uses a single version
8795number for shared libraries, then you might want to use $majonly.
8796Or, your system might be quite happy with a simple libperl.$so.
8797
8798Since the shared libperl will get installed into a version-specific
8799architecture-dependent directory, the version number of the shared perl
8800library probably isn't important, so the default should be o.k.
8801
8802EOM
8803	rp='What name do you want to give to the shared libperl?'
8804	. ./myread
8805	libperl=$ans
8806	echo "Ok, I'll use $libperl"
8807	;;
8808*)
8809	libperl="libperl${_a}"
8810	;;
8811esac
8812
8813# Detect old use of shrpdir via undocumented Configure -Dshrpdir
8814case "$shrpdir" in
8815'') ;;
8816*)	$cat >&4 <<EOM
8817WARNING:  Use of the shrpdir variable for the installation location of
8818the shared $libperl is not supported.  It was never documented and
8819will not work in this version.  Let me (https://github.com/Perl/perl5/issues)
8820know of any problems this may cause.
8821
8822EOM
8823	case "$shrpdir" in
8824	"$archlibexp/CORE")
8825		$cat >&4 <<EOM
8826But your current setting of $shrpdir is
8827the default anyway, so it's harmless.
8828EOM
8829		;;
8830	*)
8831		$cat >&4 <<EOM
8832Further, your current attempted setting of $shrpdir
8833conflicts with the value of $archlibexp/CORE
8834that installperl will use.
8835EOM
8836		;;
8837	esac
8838	;;
8839esac
8840
8841# How will the perl executable find the installed shared $libperl?
8842# Add $xxx to ccdlflags.
8843# If we can't figure out a command-line option, use $shrpenv to
8844# set env LD_RUN_PATH.  The main perl makefile uses this.
8845shrpdir=$archlibexp/CORE
8846xxx=''
8847tmp_shrpenv=''
8848if "$useshrplib"; then
8849    case "$osname" in
8850	aix)
8851		# We'll set it in Makefile.SH...
8852		;;
8853	solaris)
8854		xxx="-R $shrpdir"
8855		;;
8856	freebsd|minix|mirbsd|netbsd|openbsd|interix|dragonfly|bitrig)
8857		xxx="-Wl,-R$shrpdir"
8858		;;
8859	bsdos|linux|irix*|dec_osf|gnu*|haiku)
8860		xxx="-Wl,-rpath,$shrpdir"
8861		;;
8862	hpux*)
8863		# hpux doesn't like the default, either.
8864		tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
8865		;;
8866	cygwin)
8867		# cygwin needs only ldlibpth
8868		;;
8869	*)
8870		tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
8871		;;
8872	esac
8873	case "$xxx" in
8874	'') ;;
8875	*)
8876		# Only add $xxx if it isn't already in ccdlflags.
8877		case " $ccdlflags " in
8878		*" $xxx "*)	;;
8879		*)	ccdlflags="$ccdlflags $xxx"
8880			cat <<EOM >&4
8881
8882Adding $xxx to the flags
8883passed to $ld so that the perl executable will find the
8884installed shared $libperl.
8885
8886EOM
8887			;;
8888		esac
8889		;;
8890	esac
8891fi
8892# Fix ccdlflags in AIX for building external extensions.
8893# (For building Perl itself bare -bE:perl.exp is needed,
8894#  Makefile.SH takes care of this.)
8895case "$osname" in
8896aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
8897esac
8898# Respect a hint or command-line value.
8899case "$shrpenv" in
8900'') shrpenv="$tmp_shrpenv" ;;
8901esac
8902case "$ldlibpthname" in
8903'')	ldlibpthname=LD_LIBRARY_PATH ;;
8904none)	ldlibpthname='' ;;
8905esac
8906
8907: determine where manual pages are on this system
8908echo " "
8909case "$sysman" in
8910'')
8911	syspath='/usr/share/man/man1 /usr/man/man1'
8912	syspath="$syspath /usr/man/mann /usr/man/manl /usr/man/local/man1"
8913	syspath="$syspath /usr/man/u_man/man1"
8914	syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
8915	syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
8916	syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
8917	sysman=`./loc . /usr/man/man1 $syspath`
8918	;;
8919esac
8920if $test -d "$sysman"; then
8921	echo "System manual is in $sysman." >&4
8922else
8923	echo "Could not find manual pages in source form." >&4
8924fi
8925
8926: determine where manual pages go
8927set man1dir man1dir none
8928eval $prefixit
8929$cat <<EOM
8930
8931$spackage has manual pages available in source form.
8932EOM
8933case "$nroff" in
8934nroff)
8935	echo "However, you don't have nroff, so they're probably useless to you."
8936	case "$man1dir" in
8937	'') man1dir="none";;
8938	esac;;
8939esac
8940echo "If you don't want the manual sources installed, answer 'none'."
8941case "$man1dir" in
8942' ') dflt=none
8943	;;
8944'')
8945	lookpath="$prefixexp/share/man/man1"
8946	lookpath="$lookpath $prefixexp/man/man1 $prefixexp/man/l_man/man1"
8947	lookpath="$lookpath $prefixexp/man/p_man/man1"
8948	lookpath="$lookpath $prefixexp/man/u_man/man1"
8949	lookpath="$lookpath $prefixexp/man/man.1"
8950	case "$sysman" in
8951	*/?_man*)	dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
8952	*)	dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
8953	esac
8954	set dflt
8955	eval $prefixup
8956	;;
8957*)  dflt="$man1dir"
8958	;;
8959esac
8960echo " "
8961fn=dn+~
8962rp="Where do the main $spackage manual pages (source) go?"
8963. ./getfile
8964if $test "X$man1direxp" != "X$ansexp"; then
8965	installman1dir=''
8966fi
8967prefixvar=man1dir
8968. ./setprefixvar
8969
8970case "$man1dir" in
8971'')	man1dir=' '
8972	installman1dir='';;
8973esac
8974
8975: What suffix to use on installed man pages
8976
8977case "$man1dir" in
8978' ')
8979	man1ext='0'
8980	;;
8981*)
8982	rp="What suffix should be used for the main $spackage man pages?"
8983	case "$man1ext" in
8984	'')	case "$man1dir" in
8985		*1)  dflt=1 ;;
8986		*1p) dflt=1p ;;
8987		*1pm) dflt=1pm ;;
8988		*l) dflt=l;;
8989		*n) dflt=n;;
8990		*o) dflt=o;;
8991		*p) dflt=p;;
8992		*C) dflt=C;;
8993		*L) dflt=L;;
8994		*L1) dflt=L1;;
8995		*) dflt=1;;
8996		esac
8997		;;
8998	*)	dflt="$man1ext";;
8999	esac
9000	. ./myread
9001	man1ext="$ans"
9002	;;
9003esac
9004
9005: see if we can have long filenames
9006echo " "
9007first=123456789abcdef
9008$rm -f $first
9009if (echo hi >$first) 2>/dev/null; then
9010	if $test -f 123456789abcde; then
9011		echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
9012		val="$undef"
9013	else
9014		echo 'You can have filenames longer than 14 characters.'>&4
9015		val="$define"
9016	fi
9017else
9018	$cat <<'EOM'
9019You can't have filenames longer than 14 chars.
9020You can't even think about them!
9021EOM
9022	val="$undef"
9023fi
9024set d_flexfnam
9025eval $setvar
9026$rm -rf 123456789abcde*
9027
9028: determine where library module manual pages go
9029set man3dir man3dir none
9030eval $prefixit
9031$cat <<EOM
9032
9033$spackage has manual pages for many of the library modules.
9034EOM
9035
9036case "$nroff" in
9037nroff)
9038	$cat <<'EOM'
9039However, you don't have nroff, so they're probably useless to you.
9040EOM
9041	case "$man3dir" in
9042	'') man3dir="none";;
9043	esac;;
9044esac
9045
9046case "$d_flexfnam" in
9047undef)
9048	$cat <<'EOM'
9049However, your system can't handle the long file names like File::Basename.3.
9050EOM
9051	case "$man3dir" in
9052	'') man3dir="none";;
9053	esac;;
9054esac
9055
9056echo "If you don't want the manual sources installed, answer 'none'."
9057prog=`echo $package | $sed 's/-*[0-9.]*$//'`
9058case "$man3dir" in
9059'')	dflt=`echo "$man1dir" | $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'`
9060	if $test -d "$privlib/man/man3"; then
9061		cat <<EOM >&4
9062
9063WARNING:  Previous versions of perl installed man3 pages into
9064$privlib/man/man3.  This version will suggest a
9065new default of $dflt.
9066EOM
9067		tdflt=$dflt
9068		dflt='n'
9069		rp='Do you wish to preserve the old behavior?(y/n)'
9070		. ./myread
9071		case "$ans" in
9072		y*) dflt="$privlib/man/man3" ;;
9073		*)  dflt=$tdflt ;;
9074		esac
9075    fi
9076	;;
9077*)	dflt="$man3dir" ;;
9078esac
9079case "$dflt" in
9080' ') dflt=none ;;
9081esac
9082echo " "
9083fn=dn+~
9084rp="Where do the $package library man pages (source) go?"
9085. ./getfile
9086prefixvar=man3dir
9087. ./setprefixvar
9088
9089case "$man3dir" in
9090'')	man3dir=' '
9091	installman3dir='';;
9092esac
9093
9094: What suffix to use on installed man pages
9095case "$man3dir" in
9096' ')
9097	man3ext='0'
9098	;;
9099*)
9100	rp="What suffix should be used for the $package library man pages?"
9101	case "$man3ext" in
9102	'')	case "$man3dir" in
9103		*3)  dflt=3 ;;
9104		*3p) dflt=3p ;;
9105		*3pm) dflt=3pm ;;
9106		*l) dflt=l;;
9107		*n) dflt=n;;
9108		*o) dflt=o;;
9109		*p) dflt=p;;
9110		*C) dflt=C;;
9111		*L) dflt=L;;
9112		*L3) dflt=L3;;
9113		*) dflt=3;;
9114		esac
9115		;;
9116	*)	dflt="$man3ext";;
9117	esac
9118	. ./myread
9119	man3ext="$ans"
9120	;;
9121esac
9122
9123: see if we have to deal with yellow pages, now NIS.
9124if $test -d /usr/etc/yp || $test -d /etc/yp || $test -d /usr/lib/yp; then
9125	case "$hostcat" in
9126	nidump*) ;;
9127	*)
9128		case "$hostcat" in
9129		*ypcat*) dflt=y;;
9130		'') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
9131				dflt=y
9132			else
9133				dflt=n
9134			fi;;
9135		*) dflt=n;;
9136		esac
9137		echo " "
9138		rp='Are you getting the hosts file via yellow pages?'
9139		. ./myread
9140		case "$ans" in
9141		y*) hostcat='ypcat hosts';;
9142		*) hostcat='cat /etc/hosts';;
9143		esac
9144		;;
9145	esac
9146fi
9147case "$hostcat" in
9148'') test -f /etc/hosts && hostcat='cat /etc/hosts';;
9149esac
9150case "$groupcat" in
9151'') test -f /etc/group && groupcat='cat /etc/group';;
9152esac
9153case "$passcat" in
9154'') test -f /etc/passwd && passcat='cat /etc/passwd';;
9155esac
9156
9157: now get the host name
9158echo " "
9159echo "Figuring out host name..." >&4
9160case "$myhostname" in
9161'') cont=true
9162	echo 'Maybe "hostname" will work...'
9163	if tans=`sh -c hostname 2>&1` ; then
9164		myhostname=$tans
9165		phostname=hostname
9166		cont=''
9167	fi
9168	;;
9169*) cont='';;
9170esac
9171if $test "$cont"; then
9172	if ./xenix; then
9173		echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
9174		if tans=`cat /etc/systemid 2>&1` ; then
9175			myhostname=$tans
9176			phostname='cat /etc/systemid'
9177			echo "Whadyaknow.  Xenix always was a bit strange..."
9178			cont=''
9179		fi
9180	elif $test -r /etc/systemid; then
9181		echo "(What is a non-Xenix system doing with /etc/systemid?)"
9182	fi
9183fi
9184if $test "$cont"; then
9185	echo 'No, maybe "uuname -l" will work...'
9186	if tans=`sh -c 'uuname -l' 2>&1` ; then
9187		myhostname=$tans
9188		phostname='uuname -l'
9189	else
9190		echo 'Strange.  Maybe "uname -n" will work...'
9191		if tans=`sh -c 'uname -n' 2>&1` ; then
9192			myhostname=$tans
9193			phostname='uname -n'
9194		else
9195			echo 'Oh well, maybe I can mine it out of whoami.h...'
9196			if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
9197				myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
9198				phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
9199			else
9200				case "$myhostname" in
9201				'') echo "Does this machine have an identity crisis or something?"
9202					phostname='';;
9203				*)
9204					echo "Well, you said $myhostname before..."
9205					phostname='echo $myhostname';;
9206				esac
9207			fi
9208		fi
9209	fi
9210fi
9211case "$myhostname" in
9212'') myhostname=noname ;;
9213esac
9214: you do not want to know about this
9215set $myhostname
9216myhostname=$1
9217
9218: verify guess
9219if $test "$myhostname" ; then
9220	dflt=y
9221	rp='Your host name appears to be "'$myhostname'".'" Right?"
9222	. ./myread
9223	case "$ans" in
9224	y*) ;;
9225	*) myhostname='';;
9226	esac
9227fi
9228
9229: bad guess or no guess
9230while $test "X$myhostname" = X ; do
9231	dflt=''
9232	rp="Please type the (one word) name of your host:"
9233	. ./myread
9234	myhostname="$ans"
9235done
9236
9237: translate upper to lower if necessary
9238case "$myhostname" in
9239*[A-Z]*)
9240	echo "(Normalizing case in your host name)"
9241	myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
9242	;;
9243esac
9244
9245case "$myhostname" in
9246*.*)
9247	dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
9248	myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
9249	echo "(Trimming domain name from host name--host name is now $myhostname)"
9250	;;
9251*) case "$mydomain" in
9252	'')
9253		{
9254			test "X$hostcat" = "Xypcat hosts" &&
9255			ypmatch "$myhostname" hosts 2>/dev/null |\
9256				$sed -e 's/[	 ]*#.*//; s/$/ /' > hosts && \
9257			$test -s hosts
9258		} || {
9259			test "X$hostcat" != "X" &&
9260			$hostcat | $sed -n -e "s/[	 ]*#.*//; s/\$/ /
9261					/[	 ]$myhostname[	. ]/p" > hosts
9262		}
9263		tmp_re="[	. ]"
9264		if $test -f hosts; then
9265			$test x`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ { sum++ }
9266			     END { print sum }" hosts` = x1 || tmp_re="[	 ]"
9267			dflt=.`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
9268				hosts | $sort | $uniq | \
9269				$sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
9270			case `$echo X$dflt` in
9271			X*\ *)	echo "(Several hosts in the database matched hostname)"
9272				dflt=.
9273				;;
9274			X.) echo "(You do not have fully-qualified names in the hosts database)"
9275				;;
9276			esac
9277		else
9278			echo "(I cannot locate a hosts database anywhere)"
9279			dflt=.
9280		fi
9281		case "$dflt" in
9282		.)
9283			tans=`./loc resolv.conf X /etc /usr/etc`
9284			if $test -f "$tans"; then
9285				echo "(Attempting domain name extraction from $tans)"
9286				dflt=.`$sed -n -e 's/	/ /g' \
9287				  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
9288				  -e 1q 2>/dev/null`
9289				case "$dflt" in
9290				.) dflt=.`$sed -n -e 's/	/ /g' \
9291				     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
9292				     -e 1q 2>/dev/null`
9293					;;
9294				esac
9295			fi
9296			;;
9297		esac
9298		case "$dflt" in
9299		.) echo "(No help from resolv.conf either -- attempting clever guess)"
9300			dflt=.`sh -c domainname 2>/dev/null`
9301			case "$dflt" in
9302			'') dflt='.';;
9303			.nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
9304			esac
9305			;;
9306		esac
9307		case "$dflt$osname" in
9308		.os390) echo "(Attempting domain name extraction from //'SYS1.TCPPARMS(TCPDATA)')"
9309			dflt=.`awk '/^DOMAINORIGIN/ {print $2}' "//'SYS1.TCPPARMS(TCPDATA)'" 2>/dev/null`
9310			;;
9311		esac
9312		case "$dflt" in
9313		.) echo "(Lost all hope -- silly guess then)"
9314			dflt='.nonet'
9315			;;
9316		esac
9317		$rm -f hosts
9318		;;
9319	*) dflt="$mydomain";;
9320	esac;;
9321esac
9322echo " "
9323rp="What is your domain name?"
9324. ./myread
9325tans="$ans"
9326case "$ans" in
9327'') ;;
9328.*) ;;
9329*) tans=".$tans";;
9330esac
9331mydomain="$tans"
9332
9333: translate upper to lower if necessary
9334case "$mydomain" in
9335*[A-Z]*)
9336	echo "(Normalizing case in your domain name)"
9337	mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
9338	;;
9339esac
9340
9341: a little sanity check here
9342case "$phostname" in
9343'') ;;
9344*)
9345	case `$phostname | ./tr '[A-Z]' '[a-z]'` in
9346	$myhostname$mydomain|$myhostname) ;;
9347	*)
9348		case "$phostname" in
9349		sed*)
9350			echo "(That doesn't agree with your whoami.h file, by the way.)"
9351			;;
9352		*)
9353			echo "(That doesn't agree with your $phostname command, by the way.)"
9354			;;
9355		esac
9356	;;
9357	esac
9358	;;
9359esac
9360
9361: determine the e-mail address of the user who is running us
9362$cat <<EOM
9363
9364I need to get your e-mail address in Internet format if possible, i.e.
9365something like user@host.domain. Please answer accurately since I have
9366no easy means to double check it. The default value provided below
9367is most probably close to reality but may not be valid from outside
9368your organization...
9369
9370EOM
9371cont=x
9372while test "$cont"; do
9373	case "$MAILDOMAIN" in
9374	'')
9375		if $test -s /etc/mailname; then
9376			maildomain=`$cat /etc/mailname`
9377		else
9378			maildomain="$myhostname$mydomain"
9379		fi
9380		;;
9381	*)  maildomain="$MAILDOMAIN";;
9382	esac
9383	case "$cf_email" in
9384	'') dflt="$cf_by@$maildomain";;
9385	*)  dflt="$cf_email";;
9386	esac
9387	rp='What is your e-mail address?'
9388	. ./myread
9389	cf_email="$ans"
9390	case "$cf_email" in
9391	*@*.*) cont='' ;;
9392	*)
9393		rp='Address does not look like an Internet one.  Use it anyway?'
9394		case "$fastread" in
9395		yes) dflt=y ;;
9396		*) dflt=n ;;
9397		esac
9398		. ./myread
9399		case "$ans" in
9400		y*) cont='' ;;
9401		*) echo " " ;;
9402		esac
9403		;;
9404	esac
9405done
9406
9407: Ask e-mail of administrator
9408$cat <<EOM
9409
9410If you or somebody else will be maintaining perl at your site, please
9411fill in the correct e-mail address here so that they may be contacted
9412if necessary. You may enter "none" for no administrator.
9413
9414EOM
9415case "$perladmin" in
9416'') dflt="$cf_email";;
9417*) dflt="$perladmin";;
9418esac
9419rp='Perl administrator e-mail address'
9420. ./myread
9421perladmin="$ans"
9422
9423: determine whether to use a version number suffix for installed binaries
9424echo " "
9425$cat <<EOM
9426Do you want to use a version number suffix for installed binaries? This
9427will install 'perl$version' instead of 'perl', and likewise for other
9428binaries like 'perldoc' and 'cpan'. This allows many versions of perl
9429to be installed side-by-side. Unless you are a developer, you probably
9430do *not* want to do this.
9431EOM
9432case "$versiononly" in
9433"$define"|[Yy]*|true) dflt='y' ;;
9434*) dflt='n';
9435esac
9436rp="Do you want to use a version number suffix for installed binaries?"
9437. ./myread
9438case "$ans" in
9439[yY]*)	val="$define";;
9440*)	val="$undef" ;;
9441esac
9442set versiononly
9443eval $setvar
9444
9445case "$versiononly" in
9446"$define") inc_version_list=''
9447           inc_version_list_init=0
9448           ;;
9449esac
9450
9451: figure out how to guarantee perl startup
9452: XXX Note that this currently takes advantage of the bug that binexp ignores
9453:     the Configure -Dinstallprefix setting, which in turn means that under
9454:     relocatable @INC, initialinstalllocation is what binexp started as.
9455case "$startperl" in
9456'')
9457	case "$sharpbang" in
9458	*!)
9459		$cat <<EOH
9460
9461I can use the #! construct to start perl on your system. This will
9462make startup of perl scripts faster, but may cause problems if you
9463want to share those scripts and perl is not in a standard place
9464($initialinstalllocation/perl) on all your platforms. The alternative
9465is to force a shell by starting the script with a single ':' character.
9466
9467EOH
9468		case "$versiononly" in
9469		"$define")      dflt="$initialinstalllocation/perl$version";;
9470		*)              dflt="$initialinstalllocation/perl";;
9471		esac
9472		rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
9473		. ./myread
9474		case "$ans" in
9475		none)	startperl=": # use perl";;
9476		*)	startperl="#!$ans"
9477			if $test 30 -lt `echo "$ans" | wc -c`; then
9478				$cat >&4 <<EOM
9479
9480WARNING:  Some systems limit the #! command to 32 characters.
9481If you experience difficulty running Perl scripts with #!, try
9482installing Perl in a directory with a shorter pathname.
9483
9484EOM
9485			fi ;;
9486		esac
9487		;;
9488	*) startperl=": # use perl"
9489		;;
9490	esac
9491	;;
9492esac
9493echo "I'll use $startperl to start perl scripts."
9494
9495: figure best path for perl in scripts
9496case "$perlpath" in
9497'')
9498	case "$versiononly" in
9499	"$define")	perlpath="$initialinstalllocation/perl$version";;
9500	*)		perlpath="$initialinstalllocation/perl";;
9501	esac
9502	case "$startperl" in
9503	*!*) ;;
9504	*)
9505		$cat <<EOH
9506
9507I will use the "eval 'exec'" idiom to start Perl on your system.
9508I can use the full path of your Perl binary for this purpose, but
9509doing so may cause problems if you want to share those scripts and
9510Perl is not always in a standard place ($initialinstalllocation/perl).
9511
9512EOH
9513		dflt="$initialinstalllocation/perl"
9514		rp="What path shall I use in \"eval 'exec'\"?"
9515		. ./myread
9516		perlpath="$ans"
9517		;;
9518	esac
9519	;;
9520esac
9521case "$startperl" in
9522*!*)	;;
9523*)	echo "I'll use $perlpath in \"eval 'exec'\"" ;;
9524esac
9525
9526: determine where public executable scripts go
9527set scriptdir scriptdir
9528eval $prefixit
9529case "$scriptdir" in
9530'')
9531	dflt="$bin"
9532	: guess some guesses
9533	$test -d /usr/share/scripts && dflt=/usr/share/scripts
9534	$test -d /usr/share/bin     && dflt=/usr/share/bin
9535	$test -d /usr/local/script  && dflt=/usr/local/script
9536	$test -d /usr/local/scripts && dflt=/usr/local/scripts
9537	$test -d $prefixexp/script  && dflt=$prefixexp/script
9538	set dflt
9539	eval $prefixup
9540	;;
9541*)  dflt="$scriptdir"
9542	;;
9543esac
9544$cat <<EOM
9545
9546Some installations have a separate directory just for executable scripts so
9547that they can mount it across multiple architectures but keep the scripts in
9548one spot.  You might, for example, have a subdirectory of /usr/share for this.
9549Or you might just lump your scripts in with all your other executables.
9550
9551EOM
9552fn=d~
9553rp='Where do you keep publicly executable scripts?'
9554. ./getfile
9555if $test "X$ansexp" != "X$scriptdirexp"; then
9556	installscript=''
9557fi
9558installscriptdir=''
9559prefixvar=scriptdir
9560. ./setprefixvar
9561: A little fix up for an irregularly named variable.
9562installscript="$installscriptdir"
9563
9564: determine where add-on public executables go
9565case "$sitebin" in
9566'')	dflt=$siteprefix/bin ;;
9567*)	dflt=$sitebin ;;
9568esac
9569fn=d~
9570rp='Pathname where the add-on public executables should be installed?'
9571. ./getfile
9572prefixvar=sitebin
9573. ./setprefixvar
9574
9575: determine where add-on html pages go
9576: There is no standard location, so try to copy the previously-selected
9577: directory structure for the core html pages.
9578case "$sitehtml1dir" in
9579'')    dflt=`echo "$html1dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9580*)     dflt=$sitehtml1dir ;;
9581esac
9582case "$dflt" in
9583''|' ') dflt=none ;;
9584esac
9585fn=dn+~
9586rp='Pathname where the site-specific html pages should be installed?'
9587. ./getfile
9588prefixvar=sitehtml1dir
9589. ./setprefixvar
9590
9591: determine where add-on library html pages go
9592: There is no standard location, so try to copy the previously-selected
9593: directory structure for the core html pages.
9594case "$sitehtml3dir" in
9595'')    dflt=`echo "$html3dir" | $sed "s#^$prefix#$siteprefix#"` ;;
9596*)     dflt=$sitehtml3dir ;;
9597esac
9598case "$dflt" in
9599''|' ') dflt=none ;;
9600esac
9601fn=dn+~
9602rp='Pathname where the site-specific library html pages should be installed?'
9603. ./getfile
9604prefixvar=sitehtml3dir
9605. ./setprefixvar
9606
9607: determine where add-on manual pages go
9608case "$siteman1dir" in
9609'')	dflt=`echo $man1dir | $sed "s#^$prefix#$siteprefix#"` ;;
9610*)	dflt=$siteman1dir ;;
9611esac
9612case "$dflt" in
9613''|' ') dflt=none ;;
9614esac
9615fn=dn+~
9616rp='Pathname where the site-specific manual pages should be installed?'
9617. ./getfile
9618prefixvar=siteman1dir
9619. ./setprefixvar
9620
9621: determine where add-on library man pages go
9622case "$siteman3dir" in
9623'')	dflt=`echo $man3dir | $sed "s#^$prefix#$siteprefix#"` ;;
9624*)	dflt=$siteman3dir ;;
9625esac
9626case "$dflt" in
9627''|' ') dflt=none ;;
9628esac
9629fn=dn+~
9630rp='Pathname where the site-specific library manual pages should be installed?'
9631. ./getfile
9632prefixvar=siteman3dir
9633. ./setprefixvar
9634
9635: determine where add-on public executable scripts go
9636case "$sitescript" in
9637'')	dflt=$siteprefix/script
9638	$test -d $dflt || dflt=$sitebin ;;
9639*)  dflt="$sitescript" ;;
9640esac
9641fn=d~+
9642rp='Pathname where add-on public executable scripts should be installed?'
9643. ./getfile
9644prefixvar=sitescript
9645. ./setprefixvar
9646
9647: see if backtrace exists
9648set backtrace d_backtrace
9649eval $inlibc
9650
9651: Check if C backtrace is actually supported.
9652case "$usecbacktrace" in
9653  "") usecbacktrace=$undef ;;
9654  [yY]*|true|$define)
9655    case "$d_backtrace" in
9656      [yY]*|true|$define)
9657        ;;
9658      *)
9659        echo "This system does not support backtrace" >&4
9660        usecbacktrace=$undef
9661        ;;
9662      esac
9663    ;;
9664  esac
9665
9666: Check if faststdio is requested and available
9667case "$usefaststdio" in
9668$define|true|[yY]*|'')
9669	xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
9670	case "$xversion" in
9671	[68])	dflt='y' ;;
9672	*)	dflt='n' ;;
9673	esac
9674	;;
9675*) dflt='n';;
9676esac
9677cat <<EOM
9678
9679Perl can be built to use 'fast stdio', which means using the stdio
9680library but also directly manipulating the stdio buffers to enable
9681faster I/O.  Using stdio is better for backward compatibility (especially
9682for Perl extensions), but on the other hand since Perl 5.8 the 'perlio'
9683interface has been preferred instead of stdio.
9684
9685If this doesn't make any sense to you, just accept the default '$dflt'.
9686EOM
9687rp='Use the "fast stdio" if available?'
9688. ./myread
9689case "$ans" in
9690y|Y)	val="$define" ;;
9691*)      val="$undef" ;;
9692esac
9693set usefaststdio
9694eval $setvar
9695
9696: define an is-a-typedef? function
9697typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9698case "$inclist" in
9699"") inclist="sys/types.h";;
9700esac;
9701eval "varval=\$$var";
9702case "$varval" in
9703"")
9704	$rm -f temp.c;
9705	for inc in $inclist; do
9706		echo "#include <$inc>" >>temp.c;
9707	done;
9708	echo "#ifdef $type" >> temp.c;
9709	echo "printf(\"We have $type\");" >> temp.c;
9710	echo "#endif" >> temp.c;
9711	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9712	if $contains $type temp.E >/dev/null 2>&1; then
9713		eval "$var=\$type";
9714	else
9715		eval "$var=\$def";
9716	fi;
9717	$rm -f temp.?;;
9718*) eval "$var=\$varval";;
9719esac'
9720
9721: define an is-a-typedef? function that prompts if the type is not available.
9722typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9723case "$inclist" in
9724"") inclist="sys/types.h";;
9725esac;
9726eval "varval=\$$var";
9727case "$varval" in
9728"")
9729	$rm -f temp.c;
9730	for inc in $inclist; do
9731		echo "#include <$inc>" >>temp.c;
9732	done;
9733	echo "#ifdef $type" >> temp.c;
9734	echo "printf(\"We have $type\");" >> temp.c;
9735	echo "#endif" >> temp.c;
9736	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9737	echo " " ;
9738	echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
9739	if $contains $type temp.E >/dev/null 2>&1; then
9740		echo "$type found." >&4;
9741		eval "$var=\$type";
9742	else
9743		echo "$type NOT found." >&4;
9744		dflt="$def";
9745		. ./myread ;
9746		eval "$var=\$ans";
9747	fi;
9748	$rm -f temp.?;;
9749*) eval "$var=\$varval";;
9750esac'
9751
9752: see what type lseek is declared as in the kernel
9753rp="What is the type used for lseek's offset on this system?"
9754set off_t lseektype long stdio.h sys/types.h
9755eval $typedef_ask
9756
9757echo " "
9758echo "Checking to see how big your file offsets are..." >&4
9759$cat >try.c <<EOCP
9760#include <sys/types.h>
9761#include <stdio.h>
9762int main()
9763{
9764    printf("%d\n", (int)sizeof($lseektype));
9765    return(0);
9766}
9767EOCP
9768set try
9769if eval $compile_ok; then
9770	lseeksize=`$run ./try`
9771	echo "Your file offsets are $lseeksize bytes long."
9772else
9773	dflt=$longsize
9774	echo " "
9775	echo "(I can't seem to compile the test program.  Guessing...)"
9776	rp="What is the size of your file offsets (in bytes)?"
9777	. ./myread
9778	lseeksize="$ans"
9779fi
9780$rm_try
9781
9782: see what type file positions are declared as in the library
9783rp="What is the type for file position used by fsetpos()?"
9784set fpos_t fpostype long stdio.h sys/types.h
9785eval $typedef_ask
9786
9787: Check size for Fpos_t
9788echo " "
9789case "$fpostype" in
9790*_t) zzz="$fpostype"	;;
9791*)   zzz="fpos_t"	;;
9792esac
9793echo "Checking the size of $zzz..." >&4
9794cat > try.c <<EOCP
9795#include <sys/types.h>
9796#include <stdio.h>
9797#$i_stdlib I_STDLIB
9798#ifdef I_STDLIB
9799#include <stdlib.h>
9800#endif
9801int main() {
9802    printf("%d\n", (int)sizeof($fpostype));
9803    exit(0);
9804}
9805EOCP
9806set try
9807if eval $compile_ok; then
9808	yyy=`$run ./try`
9809	case "$yyy" in
9810	'')	fpossize=4
9811		echo "(I can't execute the test program--guessing $fpossize.)" >&4
9812		;;
9813	*)	fpossize=$yyy
9814		echo "Your $zzz is $fpossize bytes long."
9815		;;
9816	esac
9817else
9818	dflt="$longsize"
9819	echo " " >&4
9820	echo "(I can't compile the test program.  Guessing...)" >&4
9821	rp="What is the size of your file positions (in bytes)?"
9822	. ./myread
9823	fpossize="$ans"
9824fi
9825
9826: Check for large file support
9827# Backward compatibility (uselfs is deprecated).
9828case "$uselfs" in
9829"$define"|true|[yY]*)
9830	cat <<EOM >&4
9831
9832*** Configure -Duselfs is deprecated, using -Duselargefiles instead.
9833EOM
9834	uselargefiles="$define"
9835	;;
9836esac
9837
9838case "$lseeksize:$fpossize" in
98398:8) cat <<EOM
9840
9841You can have files larger than 2 gigabytes.
9842EOM
9843   val="$define" ;;
9844*)    case "$uselargefiles" in
9845   "$undef"|false|[nN]*) dflt='n' ;;
9846   *)	dflt='y' ;;
9847   esac
9848   cat <<EOM
9849
9850Perl can be built to understand large files (files larger than 2 gigabytes)
9851on some systems.  To do so, Configure can be run with -Duselargefiles.
9852
9853If this doesn't make any sense to you, just accept the default '$dflt'.
9854EOM
9855   rp='Try to understand large files, if available?'
9856   . ./myread
9857   case "$ans" in
9858   y|Y)	val="$define" ;;
9859   *)	val="$undef"  ;;
9860   esac
9861   ;;
9862esac
9863set uselargefiles
9864eval $setvar
9865: Look for a hint-file generated 'call-back-unit'.  If the
9866: user has specified that a large files perl is to be built,
9867: we may need to set or change some other defaults.
9868if $test -f uselargefiles.cbu; then
9869	echo "Your platform has some specific hints regarding large file builds, using them..."
9870	. ./uselargefiles.cbu
9871fi
9872case "$uselargefiles" in
9873"$define")
9874	if $test -f uselargefiles.cbu; then
9875		echo " "
9876		echo "Rechecking to see how big your file offsets are..." >&4
9877		$cat >try.c <<EOCP
9878#include <sys/types.h>
9879#include <stdio.h>
9880int main()
9881{
9882    printf("%d\n", (int)sizeof($lseektype));
9883    return(0);
9884}
9885EOCP
9886		set try
9887		if eval $compile_ok; then
9888			lseeksize=`$run ./try`
9889			$echo "Your file offsets are now $lseeksize bytes long."
9890		else
9891			dflt="$lseeksize"
9892			echo " "
9893			echo "(I can't seem to compile the test program.  Guessing...)"
9894			rp="What is the size of your file offsets (in bytes)?"
9895			. ./myread
9896			lseeksize="$ans"
9897		fi
9898		case "$fpostype" in
9899		*_t) zzz="$fpostype"	;;
9900		*)   zzz="fpos_t"	;;
9901		esac
9902		$echo $n "Rechecking the size of $zzz...$c" >&4
9903		$cat > try.c <<EOCP
9904#include <sys/types.h>
9905#include <stdio.h>
9906#$i_stdlib I_STDLIB
9907#ifdef I_STDLIB
9908#include <stdlib.h>
9909#endif
9910int main() {
9911    printf("%d\n", (int)sizeof($fpostype));
9912    return(0);
9913}
9914EOCP
9915		set try
9916		if eval $compile_ok; then
9917			yyy=`$run ./try`
9918			dflt="$lseeksize"
9919			case "$yyy" in
9920			'')	echo " "
9921				echo "(I can't execute the test program--guessing $fpossize.)" >&4
9922				;;
9923			*)	fpossize=$yyy
9924				echo " $fpossize bytes." >&4
9925				;;
9926			esac
9927		else
9928			dflt="$fpossize"
9929			echo " "
9930			echo "(I can't compile the test program.  Guessing...)" >&4
9931			rp="What is the size of your file positions (in bytes)?"
9932			. ./myread
9933			fpossize="$ans"
9934		fi
9935		$rm_try
9936	fi
9937	;;
9938esac
9939
9940: Check if we want perlio
9941useperlio="$define"
9942
9943: Set the vendorbin variables
9944case "$vendorprefix" in
9945'')	d_vendorbin="$undef"
9946	vendorbin=''
9947	vendorbinexp=''
9948	;;
9949*)	d_vendorbin="$define"
9950	: determine where vendor-supplied executables go.
9951	case "$vendorbin" in
9952	'') dflt=$vendorprefix/bin ;;
9953	*)	dflt="$vendorbin" ;;
9954	esac
9955	fn=d~+
9956	rp='Pathname for the vendor-supplied executables directory?'
9957	. ./getfile
9958	vendorbin="$ans"
9959	vendorbinexp="$ansexp"
9960	;;
9961esac
9962prefixvar=vendorbin
9963. ./installprefix
9964
9965: Set the vendorhtml1dir variables
9966case "$vendorprefix" in
9967'')	vendorhtml1dir=''
9968	vendorhtml1direxp=''
9969	;;
9970*)	: determine where vendor-supplied html pages go.
9971	: There is no standard location, so try to copy the previously-selected
9972	: directory structure for the core html pages.
9973	: XXX Better default suggestions would be welcome.
9974	case "$vendorhtml1dir" in
9975	'')	dflt=`echo "$html1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
9976	*)	dflt=$vendorhtml1dir ;;
9977	esac
9978	case "$dflt" in
9979	''|' ') dflt=none ;;
9980	esac
9981	fn=dn+~
9982	rp='Pathname for the vendor-supplied html pages?'
9983	. ./getfile
9984	vendorhtml1dir="$ans"
9985	vendorhtml1direxp="$ansexp"
9986	;;
9987esac
9988: Use ' ' for none so value is preserved next time through Configure
9989$test X"$vendorhtml1dir" = "X" && vendorhtml1dir=' '
9990prefixvar=vendorhtml1dir
9991. ./installprefix
9992
9993: Set the vendorhtml3dir variables
9994case "$vendorprefix" in
9995'')	vendorhtml3dir=''
9996	vendorhtml3direxp=''
9997	;;
9998*)	: determine where vendor-supplied module html pages go.
9999	: There is no standard location, so try to copy the previously-selected
10000	: directory structure for the core html pages.
10001	: XXX Better default suggestions would be welcome.
10002	case "$vendorhtml3dir" in
10003	'')	dflt=`echo "$html3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10004	*)	dflt=$vendorhtml3dir ;;
10005	esac
10006	case "$dflt" in
10007	''|' ') dflt=none ;;
10008	esac
10009	fn=dn+~
10010	rp='Pathname for the vendor-supplied html pages?'
10011	. ./getfile
10012	vendorhtml3dir="$ans"
10013	vendorhtml3direxp="$ansexp"
10014	;;
10015esac
10016: Use ' ' for none so value is preserved next time through Configure
10017$test X"$vendorhtml3dir" = "X" && vendorhtml3dir=' '
10018prefixvar=vendorhtml3dir
10019. ./installprefix
10020
10021: Set the vendorman1dir variables
10022case "$vendorprefix" in
10023'')	vendorman1dir=''
10024	vendorman1direxp=''
10025	;;
10026*)	: determine where vendor-supplied manual pages go.
10027	case "$vendorman1dir" in
10028	'') dflt=`echo "$man1dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10029	*)	dflt=$vendorman1dir ;;
10030	esac
10031	case "$dflt" in
10032	''|' ') dflt=none ;;
10033	esac
10034	fn=nd~+
10035	rp='Pathname for the vendor-supplied manual section 1 pages?'
10036	. ./getfile
10037	vendorman1dir="$ans"
10038	vendorman1direxp="$ansexp"
10039	;;
10040esac
10041: Use ' ' for none so value is preserved next time through Configure
10042$test X"$vendorman1dir" = "X" && vendorman1dir=' '
10043prefixvar=vendorman1dir
10044. ./installprefix
10045
10046: Set the vendorman3dir variables
10047case "$vendorprefix" in
10048'')	vendorman3dir=''
10049	vendorman3direxp=''
10050	;;
10051*)	: determine where vendor-supplied module manual pages go.
10052	case "$vendorman3dir" in
10053	'') dflt=`echo "$man3dir" | $sed "s#^$prefix#$vendorprefix#"` ;;
10054	*)	dflt=$vendorman3dir ;;
10055	esac
10056	case "$dflt" in
10057	''|' ') dflt=none ;;
10058	esac
10059	fn=nd~+
10060	rp='Pathname for the vendor-supplied manual section 3 pages?'
10061	. ./getfile
10062	vendorman3dir="$ans"
10063	vendorman3direxp="$ansexp"
10064	;;
10065esac
10066: Use ' ' for none so value is preserved next time through Configure
10067$test X"$vendorman3dir" = "X" && vendorman3dir=' '
10068prefixvar=vendorman3dir
10069. ./installprefix
10070
10071: Set the vendorscript variables
10072case "$vendorprefix" in
10073'')	d_vendorscript="$undef"
10074	vendorscript=''
10075	vendorscriptexp=''
10076	;;
10077*)	d_vendorscript="$define"
10078	: determine where vendor-supplied scripts go.
10079	case "$vendorscript" in
10080	'')	dflt=$vendorprefix/script
10081		$test -d $dflt || dflt=$vendorbin ;;
10082	*)  dflt="$vendorscript" ;;
10083	esac
10084	$cat <<EOM
10085
10086The installation process will create a directory for
10087vendor-supplied scripts.
10088
10089EOM
10090	fn=d~+
10091	rp='Pathname for the vendor-supplied scripts directory?'
10092	. ./getfile
10093	vendorscript="$ans"
10094	vendorscriptexp="$ansexp"
10095	;;
10096esac
10097prefixvar=vendorscript
10098. ./installprefix
10099
10100: see if qgcvt exists
10101set qgcvt d_qgcvt
10102eval $inlibc
10103
10104: Check what kind of doubles your system has
10105$echo "Checking the kind of doubles you have..." >&4
10106$cat >try.c <<EOP
10107#$i_stdlib I_STDLIB
10108#define DOUBLESIZE $doublesize
10109#ifdef I_STDLIB
10110#include <stdlib.h>
10111#endif
10112#include <stdio.h>
10113static const double d = -0.1;
10114int main() {
10115  unsigned const char* b = (unsigned const char*)(&d);
10116#if DOUBLESIZE == 4
10117  if (b[0] == 0xCD && b[3] == 0xBD) {
10118    /* IEEE 754 32-bit little-endian */
10119    printf("1\n");
10120    exit(0);
10121  }
10122  if (b[0] == 0xBD && b[3] == 0xCD) {
10123    /* IEEE 754 32-bit big-endian */
10124    printf("2\n");
10125    exit(0);
10126  }
10127  if (b[0] == 0xCC && b[3] == 0xCC) {
10128    /* VAX format F, 32-bit PDP-style mixed endian. */
10129    printf("9\n");
10130    exit(0);
10131  }
10132  if (b[0] == 0xC0 && b[3] == 0x9A) {
10133    /* IBM single 32-bit */
10134    printf("12\n");
10135    exit(0);
10136  }
10137#endif
10138#if DOUBLESIZE == 8
10139  if (b[0] == 0x9A && b[7] == 0xBF) {
10140    /* IEEE 754 64-bit little-endian */
10141    printf("3\n");
10142    exit(0);
10143  }
10144  if (b[0] == 0xBF && b[7] == 0x9A) {
10145    /* IEEE 754 64-bit big-endian */
10146    printf("4\n");
10147    exit(0);
10148  }
10149  if (b[0] == 0x99 && b[3] == 0xBF && b[4] == 0x9A && b[7] == 0x99) {
10150   /* ARM mixed endian: two little-endian 32-bit floats, in big endian order:
10151    * 4 5 6 7 0 1 2 3 (MSB = 7, LSB = 0)
10152    * 99 99 b9 bf 9a 99 99 99 */
10153    printf("7\n");
10154    exit(0);
10155  }
10156  if (b[0] == 0x99 && b[3] == 0x9A && b[4] == 0xBF && b[7] == 0x99) {
10157   /* The opposite of case 7, mixed endian: two big-endian 32-bit floats,
10158    * in little endian order: 3 2 1 0 7 6 5 4 (MSB = 7, LSB = 0)
10159    * 99 99 99 9a bf b9 99 99 */
10160    printf("8\n");
10161    exit(0);
10162  }
10163  if (b[0] == 0xCC && b[7] == 0xCC) {
10164   /* VAX format D, 64-bit PDP-style mixed endian. */
10165    printf("10\n");
10166    exit(0);
10167  }
10168  if (b[0] == 0xD9 && b[7] == 0x99) {
10169   /* VAX format G, 64-bit PDP-style mixed endian. */
10170    printf("11\n");
10171    exit(0);
10172  }
10173  if (b[0] == 0xC0 && b[7] == 0x9A) {
10174    /* IBM double 64-bit */
10175    printf("13\n");
10176    exit(0);
10177  }
10178  if (b[0] == 0xBF && b[7] == 0xCD) {
10179    /* CRAY single 64-bit */
10180    printf("14\n");
10181    exit(0);
10182  }
10183#endif
10184#if DOUBLESIZE == 16
10185  if (b[0] == 0x9A && b[15] == 0xBF) {
10186    /* IEEE 754 128-bit little-endian */
10187    printf("5\n");
10188    exit(0);
10189  }
10190  if (b[0] == 0xBF && b[15] == 0x9A) {
10191    /* IEEE 754 128-bit big-endian */
10192    printf("6\n");
10193    exit(0);
10194  }
10195#endif
10196  /* Then there are old mainframe/miniframe formats like IBM and CRAY.
10197   * Whether those environments can still build Perl is debatable. */
10198  printf("-1\n"); /* unknown */
10199  exit(0);
10200}
10201EOP
10202set try
10203if eval $compile; then
10204    doublekind=`$run ./try`
10205else
10206    doublekind=-1
10207fi
10208case "$doublekind" in
102091) echo "You have IEEE 754 32-bit little endian doubles." >&4 ;;
102102) echo "You have IEEE 754 32-bit big endian doubles." >&4 ;;
102113) echo "You have IEEE 754 64-bit little endian doubles." >&4 ;;
102124) echo "You have IEEE 754 64-bit big endian doubles." >&4 ;;
102135) echo "You have IEEE 754 128-bit little endian doubles." >&4 ;;
102146) echo "You have IEEE 754 128-bit big endian doubles." >&4 ;;
102157) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit LEs in BE)." >&4 ;;
102168) echo "You have IEEE 754 64-bit mixed endian doubles (32-bit BEs in LE)." >&4 ;;
102179) echo "You have VAX format F 32-bit PDP-style mixed endian doubles." >&4 ;;
1021810) echo "You have VAX format D 64-bit PDP-style mixed endian doubles." >&4 ;;
1021911) echo "You have VAX format G 64-bit PDP-style mixed endian doubles." >&4 ;;
1022012) echo "You have IBM short 32-bit doubles." >&4 ;;
1022113) echo "You have IBM long 64-bit doubles." >&4 ;;
1022214) echo "You have Cray single 64-bit doubles." >&4 ;;
10223*) echo "Cannot figure out your double.  You Cyber, or something?" >&4 ;;
10224esac
10225d_double_style_ieee=$undef
10226d_double_style_vax=$undef
10227d_double_style_ibm=$undef
10228d_double_style_cray=$undef
10229case "$doublekind" in
102301|2|3|4|5|6|7|8) d_double_style_ieee=$define ;;
102319|10|11) d_double_style_vax=$define ;;
1023212|13) d_double_style_ibm=$define ;;
1023314) d_double_style_cray=$define ;;
10234esac
10235case "$d_double_style_ieee" in
10236$define)
10237    d_double_has_inf=$define
10238    d_double_has_nan=$define
10239    d_double_has_negative_zero=$define
10240    d_double_has_subnormals=$define
10241    ;;
10242*)
10243    d_double_has_inf=$undef
10244    d_double_has_nan=$undef
10245    d_double_has_negative_zero=$undef
10246    d_double_has_subnormals=$undef
10247    ;;
10248esac
10249$rm_try
10250
10251: Check print/scan long double stuff
10252echo " "
10253
10254if $test X"$d_longdbl" = X"$define"; then
10255
10256echo "Checking how to print long doubles..." >&4
10257
10258if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
10259	$cat >try.c <<'EOCP'
10260#include <sys/types.h>
10261#include <stdio.h>
10262int main() {
10263  double d = 123.456;
10264  printf("%.3f\n", d);
10265}
10266EOCP
10267	set try
10268	if eval $compile; then
10269		yyy=`$run ./try`
10270		case "$yyy" in
10271		123.456)
10272			sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
10273			sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
10274			echo "We will use %f."
10275			;;
10276		esac
10277	fi
10278fi
10279
10280if $test X"$sPRIfldbl" = X; then
10281	$cat >try.c <<'EOCP'
10282#include <sys/types.h>
10283#include <stdio.h>
10284int main() {
10285  long double d = 123.456;
10286  printf("%.3Lf\n", d);
10287}
10288EOCP
10289	set try
10290	if eval $compile; then
10291		yyy=`$run ./try`
10292		case "$yyy" in
10293		123.456)
10294			sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
10295			sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
10296			echo "We will use %Lf."
10297			;;
10298		esac
10299	fi
10300fi
10301
10302if $test X"$sPRIfldbl" = X; then
10303	$cat >try.c <<'EOCP'
10304#include <sys/types.h>
10305#include <stdio.h>
10306int main() {
10307  long double d = 123.456;
10308  printf("%.3llf\n", d);
10309}
10310EOCP
10311	set try
10312	if eval $compile; then
10313		yyy=`$run ./try`
10314		case "$yyy" in
10315		123.456)
10316			sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
10317			sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
10318			echo "We will use %llf."
10319			;;
10320		esac
10321	fi
10322fi
10323
10324if $test X"$sPRIfldbl" = X; then
10325	$cat >try.c <<'EOCP'
10326#include <sys/types.h>
10327#include <stdio.h>
10328int main() {
10329  long double d = 123.456;
10330  printf("%.3lf\n", d);
10331}
10332EOCP
10333	set try
10334	if eval $compile; then
10335		yyy=`$run ./try`
10336		case "$yyy" in
10337		123.456)
10338			sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
10339			sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
10340			echo "We will use %lf."
10341			;;
10342		esac
10343	fi
10344fi
10345
10346if $test X"$sPRIfldbl" = X; then
10347	echo "Cannot figure out how to print long doubles." >&4
10348else
10349	sSCNfldbl=$sPRIfldbl	# expect consistency
10350fi
10351
10352$rm_try
10353
10354fi # d_longdbl
10355
10356case "$sPRIfldbl" in
10357'')	d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
10358	d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
10359	d_SCNfldbl="$undef";
10360	;;
10361*)	d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
10362	d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
10363	d_SCNfldbl="$define";
10364	;;
10365esac
10366
10367: Before committing on uselongdouble, see whether that looks sane.
10368if $test "$uselongdouble" = "$define"; then
10369    message=""
10370    echo " "
10371    echo "Checking if your long double math functions work right..." >&4
10372    $cat > try.c <<EOF
10373#include <math.h>
10374#include <stdio.h>
10375int main() {
10376  printf("%"$sPRIgldbl"\n", sqrtl(logl(expl(cosl(sinl(0.0L))))+powl(2.0L, 3.0L)));
10377}
10378EOF
10379    case "$osname:$gccversion" in
10380    aix:)	saveccflags="$ccflags"
10381		ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
10382    esac
10383    set try
10384    if eval $compile_ok; then
10385      yyy=`$run ./try`
10386    fi
10387    case "$yyy" in
10388    3) echo "Your long double math functions are working correctly." >&4 ;;
10389    *) echo "Your long double math functions are broken, not using long doubles." >&4
10390       uselongdouble=$undef
10391       ;;
10392    esac
10393    $rm_try
10394    case "$osname:$gccversion" in
10395    aix:)	ccflags="$saveccflags" ;; # restore
10396    esac
10397fi
10398
10399: Check how to convert floats to strings.
10400
10401if test "X$d_Gconvert" = X; then
10402
10403echo " "
10404echo "Checking for an efficient way to convert floats to strings."
10405echo " " > try.c
10406case "$uselongdouble" in
10407"$define") echo "#define USE_LONG_DOUBLE" >>try.c ;;
10408esac
10409case "$d_longdbl" in
10410"$define") echo "#define HAS_LONG_DOUBLE" >>try.c ;;
10411esac
10412case "$d_PRIgldbl" in
10413"$define") echo "#define HAS_PRIgldbl"    >>try.c ;;
10414esac
10415$cat >>try.c <<EOP
10416#ifdef TRY_gconvert
10417#define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
10418const char *myname = "gconvert";
10419#endif
10420#ifdef TRY_gcvt
10421#define Gconvert(x,n,t,b) gcvt((x),(n),(b))
10422const char *myname = "gcvt";
10423#endif
10424#ifdef TRY_qgcvt
10425#define Gconvert(x,n,t,b) qgcvt((x),(n),(b))
10426const char *myname = "qgcvt";
10427#define DOUBLETYPE long double
10428#endif
10429#ifdef TRY_sprintf
10430#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10431#ifdef HAS_PRIgldbl
10432#define Gconvert(x,n,t,b) sprintf((b),"%.*"$sPRIgldbl,(n),(x))
10433#else
10434#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(double)(x))
10435#endif
10436#else
10437#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
10438#endif
10439const char *myname = "sprintf";
10440#endif
10441
10442#ifndef DOUBLETYPE
10443#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
10444#define DOUBLETYPE long double
10445#else
10446#define DOUBLETYPE double
10447#endif
10448#endif
10449
10450#include <stdio.h>
10451
10452#$i_stdlib I_STDLIB
10453#ifdef I_STDLIB
10454#include <stdlib.h>
10455#endif
10456#include <string.h>
10457
10458void checkit(const char *expect, char *got)
10459{
10460    if (strcmp(expect, got)) {
10461		printf("%s oddity:  Expected %s, got %s\n",
10462			myname, expect, got);
10463		exit(1);
10464	}
10465}
10466
10467void lencheck(int expect, int got)
10468{
10469    if (expect != got) {
10470		printf("%s length mismatch:  Expected %d, got %d\n",
10471			myname, expect, got);
10472		exit(1);
10473	}
10474}
10475
10476int main()
10477{
10478	char buf[64];
10479	buf[63] = '\0';
10480
10481	/* This must be 1st test on (which?) platform */
10482	/* Alan Burlison <AlanBurlsin@unn.unisys.com> */
10483	Gconvert((DOUBLETYPE)0.1, 8, 0, buf);
10484	checkit("0.1", buf);
10485
10486	Gconvert((DOUBLETYPE)0.01, 8, 0, buf);
10487	checkit("0.01", buf);
10488
10489	Gconvert((DOUBLETYPE)0.001, 8, 0, buf);
10490	checkit("0.001", buf);
10491
10492	Gconvert((DOUBLETYPE)0.0001, 8, 0, buf);
10493	checkit("0.0001", buf);
10494
10495	Gconvert((DOUBLETYPE)0.00009, 8, 0, buf);
10496	if (strlen(buf) > 5)
10497	    checkit("9e-005", buf); /* for Microsoft ?? */
10498	else
10499	    checkit("9e-05", buf);
10500
10501	Gconvert((DOUBLETYPE)1.0, 8, 0, buf);
10502	checkit("1", buf);
10503
10504	Gconvert((DOUBLETYPE)1.1, 8, 0, buf);
10505	checkit("1.1", buf);
10506
10507	Gconvert((DOUBLETYPE)1.01, 8, 0, buf);
10508	checkit("1.01", buf);
10509
10510	Gconvert((DOUBLETYPE)1.001, 8, 0, buf);
10511	checkit("1.001", buf);
10512
10513	Gconvert((DOUBLETYPE)1.0001, 8, 0, buf);
10514	checkit("1.0001", buf);
10515
10516	Gconvert((DOUBLETYPE)1.00001, 8, 0, buf);
10517	checkit("1.00001", buf);
10518
10519	Gconvert((DOUBLETYPE)1.000001, 8, 0, buf);
10520	checkit("1.000001", buf);
10521
10522	Gconvert((DOUBLETYPE)0.0, 8, 0, buf);
10523	checkit("0", buf);
10524
10525	Gconvert((DOUBLETYPE)-1.0, 8, 0, buf);
10526	checkit("-1", buf);
10527
10528	/* Some Linux gcvt's give 1.e+5 here. */
10529	Gconvert((DOUBLETYPE)100000.0, 8, 0, buf);
10530	checkit("100000", buf);
10531
10532	/* Some Linux gcvt's give -1.e+5 here. */
10533	Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf);
10534	checkit("-100000", buf);
10535
10536	Gconvert((DOUBLETYPE)123.456, 8, 0, buf);
10537	checkit("123.456", buf);
10538
10539	/* Testing of 1e+129 in bigintpm.t must not get extra '.' here. */
10540	Gconvert((DOUBLETYPE)1e34, 8, 0, buf);
10541	/* 34 should be enough to scare even long double
10542	 * places into using the e notation. */
10543	if (strlen(buf) > 5)
10544	    checkit("1e+034", buf); /* for Microsoft */
10545	else
10546	    checkit("1e+34", buf);
10547
10548	/* Test for an Ubuntu/Debian bug in gcvt and qgcvt. See:        *
10549	 * https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1899553 */
10550
10551	Gconvert((DOUBLETYPE)0.4, 53, 0, buf);
10552	lencheck(55, (int)strlen(buf));
10553
10554	/* For Perl, if you add additional tests here, also add them to
10555	 * t/base/num.t for benefit of platforms not using Configure or
10556	 * overriding d_Gconvert */
10557
10558	exit(0);
10559}
10560EOP
10561: first add preferred functions to our list
10562xxx_list=""
10563for xxx_convert in $gconvert_preference; do
10564    case $xxx_convert in
10565    gcvt|gconvert|sprintf) xxx_list="$xxx_list $xxx_convert" ;;
10566    *) echo "Discarding unrecognized gconvert_preference $xxx_convert" >&4 ;;
10567    esac
10568done
10569: then add any others
10570for xxx_convert in gconvert gcvt sprintf; do
10571    case "$xxx_list" in
10572    *$xxx_convert*) ;;
10573    *) xxx_list="$xxx_list $xxx_convert" ;;
10574    esac
10575done
10576
10577case "$d_longdbl$uselongdouble" in
10578"$define$define")
10579    : again, add preferred functions to our list first
10580    xxx_ld_list=""
10581    for xxx_convert in $gconvert_ld_preference; do
10582        case $xxx_convert in
10583        qgcvt|gcvt|gconvert|sprintf) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10584        *) echo "Discarding unrecognized gconvert_ld_preference $xxx_convert" ;;
10585        esac
10586    done
10587    : then add qgcvt, sprintf--then, in xxx_list order, gconvert and gcvt
10588    for xxx_convert in qgcvt sprintf $xxx_list; do
10589        case "$xxx_ld_list" in
10590        $xxx_convert*|*" $xxx_convert"*) ;;
10591        *) xxx_ld_list="$xxx_ld_list $xxx_convert" ;;
10592        esac
10593    done
10594    : if sprintf cannot do long doubles, move it to the end
10595    if test "$d_PRIgldbl" != "$define"; then
10596        xxx_ld_list="`echo $xxx_ld_list|sed s/sprintf//` sprintf"
10597    fi
10598    : if no qgcvt, remove it
10599    if test "$d_qgcvt" != "$define"; then
10600        xxx_ld_list="`echo $xxx_ld_list|sed s/qgcvt//`"
10601    fi
10602    : use the ld_list
10603    xxx_list="$xxx_ld_list"
10604    ;;
10605esac
10606
10607for xxx_convert in $xxx_list; do
10608	echo "Trying $xxx_convert..."
10609	$rm -f try try$_o core
10610	set try -DTRY_$xxx_convert
10611	if eval $compile; then
10612		echo "$xxx_convert() found." >&4
10613		if $run ./try; then
10614			echo "I'll use $xxx_convert to convert floats into a string." >&4
10615			break;
10616		else
10617			echo "...But $xxx_convert didn't work as I expected."
10618			xxx_convert=''
10619		fi
10620	else
10621		echo "$xxx_convert NOT found." >&4
10622		xxx_convert=''
10623	fi
10624done
10625
10626if test X$xxx_convert = X; then
10627    echo "*** WHOA THERE!!! ***" >&4
10628    echo "None of ($xxx_list)  seemed to work properly.  I'll use sprintf." >&4
10629    xxx_convert=sprintf
10630fi
10631
10632case "$xxx_convert" in
10633gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
10634gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
10635qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;;
10636*) case "$uselongdouble$d_longdbl$d_PRIgldbl" in
10637   "$define$define$define")
10638      d_Gconvert="sprintf((b),\"%.*\"$sPRIgldbl,(n),(x))" ;;
10639   "$define$define$undef")
10640      d_Gconvert='sprintf((b),"%.*g",(n),(double)(x))' ;;
10641   *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
10642   esac
10643   ;;
10644esac
10645
10646fi
10647$rm_try
10648
10649: see if _fwalk exists
10650set fwalk d__fwalk
10651eval $inlibc
10652
10653: see if accept4 exists
10654set accept4 d_accept4
10655eval $inlibc
10656
10657: Initialize h_fcntl
10658h_fcntl=false
10659
10660: Initialize h_sysfile
10661h_sysfile=false
10662
10663: access call always available on UNIX
10664set access d_access
10665eval $inlibc
10666
10667: locate the flags for 'access()'
10668case "$d_access" in
10669"$define")
10670	echo " "
10671	$cat >access.c <<EOCP
10672#include <sys/types.h>
10673#ifdef I_FCNTL
10674#include <fcntl.h>
10675#endif
10676#ifdef I_SYS_FILE
10677#include <sys/file.h>
10678#endif
10679#ifdef I_UNISTD
10680#include <unistd.h>
10681#endif
10682#$i_stdlib I_STDLIB
10683#ifdef I_STDLIB
10684#include <stdlib.h>
10685#endif
10686int main() {
10687	exit(R_OK);
10688}
10689EOCP
10690	: check sys/file.h first, no particular reason here
10691	if $test `./findhdr sys/file.h` && \
10692		$cc -o access $cppflags -DI_SYS_FILE access.c >/dev/null 2>&1 ; then
10693		h_sysfile=true;
10694		echo "<sys/file.h> defines the *_OK access constants." >&4
10695	elif $test `./findhdr fcntl.h` && \
10696		$cc -o access $cppflags -DI_FCNTL access.c >/dev/null 2>&1 ; then
10697		h_fcntl=true;
10698		echo "<fcntl.h> defines the *_OK access constants." >&4
10699	elif $test `./findhdr unistd.h` && \
10700		$cc -o access $cppflags -DI_UNISTD access.c >/dev/null 2>&1 ; then
10701		echo "<unistd.h> defines the *_OK access constants." >&4
10702	else
10703		echo "I can't find the four *_OK access constants--I'll use mine." >&4
10704	fi
10705	;;
10706esac
10707$rm -f access*
10708
10709: see if accessx exists
10710set accessx d_accessx
10711eval $inlibc
10712
10713: see if acosh exists
10714set acosh d_acosh
10715eval $inlibc
10716
10717: see if aintl exists
10718set aintl d_aintl
10719eval $inlibc
10720
10721: see if alarm exists
10722set alarm d_alarm
10723eval $inlibc
10724
10725: see if 64bit time functions exists
10726
10727set ctime64 d_ctime64
10728eval $inlibc
10729
10730set localtime64 d_localtime64
10731eval $inlibc
10732
10733set gmtime64 d_gmtime64
10734eval $inlibc
10735
10736set mktime64 d_mktime64
10737eval $inlibc
10738
10739set difftime64 d_difftime64
10740eval $inlibc
10741
10742set asctime64 d_asctime64
10743eval $inlibc
10744
10745: see if POSIX threads are available
10746set pthread.h i_pthread
10747eval $inhdr
10748
10749: define a function to check prototypes
10750$cat > protochk <<EOSH
10751$startsh
10752cc="$cc"
10753optimize="$optimize"
10754ccflags="$ccflags"
10755define="$define"
10756rm_try="$rm_try"
10757usethreads=$usethreads
10758i_pthread=$i_pthread
10759pthread_h_first=$pthread_h_first
10760EOSH
10761
10762$cat >> protochk <<'EOSH'
10763
10764$rm_try
10765foo="$1"
10766shift
10767while test $# -ge 2; do
10768	case "$1" in
10769		$define) echo "#include <$2>" >> try.c ;;
10770		literal) echo "$2" >> try.c ;;
10771	esac
10772    # Extra magic for the benefit of systems that need pthread.h
10773    # to be included early to correctly detect threadsafe functions.
10774    # Such functions must guarantee themselves, though, that the usethreads
10775    # and i_pthread have been defined, before calling protochk.
10776    if test "$usethreads" = "$define" -a "$i_pthread" = "$define" -a "$pthread_h_first" = "$define" -a "$pthread_h_done" = ""; then
10777	echo "#include <pthread.h>" >> try.c
10778	pthread_h_done=yes
10779    fi
10780    shift 2
10781done
10782cat >> try.c <<'EOCP'
10783#define	_(args) args
10784EOCP
10785echo "$foo" >> try.c
10786echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
10787$cc $optimize $ccflags -c try.c > /dev/null 2>&1
10788status=$?
10789$rm_try
10790exit $status
10791EOSH
10792chmod +x protochk
10793$eunicefix protochk
10794
10795: Define hasproto macro for Configure internal use
10796hasproto='varname=$1; func=$2; shift; shift;
10797while $test $# -ge 2; do
10798	case "$1" in
10799	$define) echo "#include <$2>";;
10800	literal) echo "$2" ;;
10801	esac ;
10802    shift 2;
10803done > try.c;
10804$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
10805if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
10806	echo "$func() prototype found.";
10807	val="$define";
10808else
10809	echo "$func() prototype NOT found.";
10810	val="$undef";
10811fi;
10812set $varname;
10813eval $setvar;
10814$rm_try tryout.c'
10815
10816: see if sys/types.h has to be included
10817set sys/types.h i_systypes
10818eval $inhdr
10819
10820: see if sys/select.h has to be included
10821set sys/select.h i_sysselct
10822eval $inhdr
10823
10824: Define hasfield macro for Configure internal use
10825hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
10826while $test $# -ge 2; do
10827	case "$1" in
10828	$define) echo "#include <$2>";;
10829	esac ;
10830    shift 2;
10831done > try.c;
10832echo "int main () { struct $struct foo; char* bar; bar = (char*)foo.$field; }" >> try.c;
10833set try;
10834if eval $compile; then
10835	val="$define";
10836else
10837	val="$undef";
10838fi;
10839set $varname;
10840eval $setvar;
10841$rm_try'
10842
10843: see if we should include sys/time.h
10844echo " "
10845i_time='define'
10846if test "X$timeincl" = X; then
10847	echo "Testing to see if we should include <sys/time.h>." >&4
10848	$echo $n "I'm now running the test program...$c"
10849	$cat >try.c <<EOCP
10850#include <sys/types.h>
10851#include <time.h>
10852#ifdef I_SYSTIME
10853#ifdef SYSTIMEKERNEL
10854#define KERNEL
10855#endif
10856#include <sys/time.h>
10857#endif
10858#ifdef I_SYSSELECT
10859#include <sys/select.h>
10860#endif
10861#$i_stdlib I_STDLIB
10862#ifdef I_STDLIB
10863#include <stdlib.h>
10864#endif
10865int main()
10866{
10867	struct tm foo;
10868#ifdef S_TIMEVAL
10869	struct timeval bar;
10870#endif
10871#ifdef S_TIMEZONE
10872	struct timezone tzp;
10873#endif
10874	if (foo.tm_sec == foo.tm_sec)
10875		exit(0);
10876#ifdef S_TIMEVAL
10877	if (bar.tv_sec == bar.tv_sec)
10878		exit(0);
10879#endif
10880	exit(1);
10881}
10882EOCP
10883	flags=''
10884	for s_timezone in '-DS_TIMEZONE' ''; do
10885	sysselect=''
10886	for s_timeval in '-DS_TIMEVAL' ''; do
10887	for i_systimek in '' '-DSYSTIMEKERNEL'; do
10888	for i_systime in '-DI_SYSTIME' ''; do
10889		case "$flags" in
10890		'') $echo $n ".$c"
10891			set try $i_systime $i_systimek $sysselect $s_timeval $s_timezone
10892			if eval $compile; then
10893				set X $i_systime $i_systimek $sysselect $s_timeval
10894				shift
10895				flags="$*"
10896				echo " "
10897				$echo $n "Succeeded with $flags$c"
10898			fi
10899			;;
10900		esac
10901	done
10902	done
10903	done
10904	done
10905	timeincl=''
10906	echo " "
10907	case "$flags" in
10908	*SYSTIMEKERNEL*) i_systimek="$define"
10909		timeincl=`./findhdr sys/time.h`
10910		echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
10911	*) i_systimek="$undef";;
10912	esac
10913	case "$flags" in
10914	*I_SYSTIME*) i_systime="$define"
10915		timeincl=`./findhdr sys/time.h`" $timeincl"
10916		echo "We'll include <sys/time.h>." >&4;;
10917	*) i_systime="$undef";;
10918	esac
10919	$rm_try
10920fi
10921: see if struct tm knows about tm_zone
10922case "$i_systime$i_time" in
10923*$define*)
10924        echo " "
10925        echo "Checking to see if your struct tm has tm_zone field..." >&4
10926        set d_tm_tm_zone tm tm_zone $i_systime sys/time.h $i_time time.h
10927        eval $hasfield
10928        ;;
10929*)      val="$undef"
10930        set d_tm_tm_zone
10931        eval $setvar
10932        ;;
10933esac
10934case "$d_tm_tm_zone" in
10935"$define")      echo "Yes, it does."   ;;
10936*)              echo "No, it doesn't." ;;
10937esac
10938: see if struct tm knows about tm_gmtoff
10939case "$i_systime$i_time" in
10940*$define*)
10941        echo " "
10942        echo "Checking to see if your struct tm has tm_gmtoff field..." >&4
10943        set d_tm_tm_gmtoff tm tm_gmtoff $i_systime sys/time.h $i_time time.h
10944        eval $hasfield
10945        ;;
10946*)      val="$undef"
10947        set d_tm_tm_gmtoff
10948        eval $setvar
10949        ;;
10950esac
10951case "$d_tm_tm_gmtoff" in
10952"$define")      echo "Yes, it does."   ;;
10953*)              echo "No, it doesn't." ;;
10954esac
10955
10956: see if asctime_r exists
10957set asctime_r d_asctime_r
10958eval $inlibc
10959case "$d_asctime_r" in
10960"$define")
10961	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
10962	case "$d_asctime_r_proto:$usethreads" in
10963	":define")	d_asctime_r_proto=define
10964		set d_asctime_r_proto asctime_r $hdrs
10965		eval $hasproto ;;
10966	*)	;;
10967	esac
10968	case "$d_asctime_r_proto" in
10969	define)
10970	case "$asctime_r_proto" in
10971	''|0) try='char* asctime_r(const struct tm*, char*);'
10972	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SB ;;
10973	esac
10974	case "$asctime_r_proto" in
10975	''|0) try='char* asctime_r(const struct tm*, char*, int);'
10976	./protochk "$extern_C $try" $hdrs && asctime_r_proto=B_SBI ;;
10977	esac
10978	case "$asctime_r_proto" in
10979	''|0) try='int asctime_r(const struct tm*, char*);'
10980	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SB ;;
10981	esac
10982	case "$asctime_r_proto" in
10983	''|0) try='int asctime_r(const struct tm*, char*, int);'
10984	./protochk "$extern_C $try" $hdrs && asctime_r_proto=I_SBI ;;
10985	esac
10986	case "$asctime_r_proto" in
10987	''|0)	d_asctime_r=undef
10988		asctime_r_proto=0
10989		echo "Disabling asctime_r, cannot determine prototype." >&4 ;;
10990	* )	case "$asctime_r_proto" in
10991		REENTRANT_PROTO*) ;;
10992		*) asctime_r_proto="REENTRANT_PROTO_$asctime_r_proto" ;;
10993		esac
10994		echo "Prototype: $try" ;;
10995	esac
10996	;;
10997	*)	case "$usethreads" in
10998		define) echo "asctime_r has no prototype, not using it." >&4 ;;
10999		esac
11000		d_asctime_r=undef
11001		asctime_r_proto=0
11002		;;
11003	esac
11004	;;
11005*)	asctime_r_proto=0
11006	;;
11007esac
11008
11009: see if asinh exists
11010set asinh d_asinh
11011eval $inlibc
11012
11013: see if atanh exists
11014set atanh d_atanh
11015eval $inlibc
11016
11017: see if atolf exists
11018set atolf d_atolf
11019eval $inlibc
11020
11021: see if atoll exists
11022set atoll d_atoll
11023eval $inlibc
11024
11025: See if a file contains compiler warnings
11026: See if a file contains compiler warnings
11027case "$osname" in
11028  'aix')
11029	cat >compiler_warning <<EOSS
11030# Sample for aix ('.5' indicates the column number in the line):
11031#    "op.h", line 203.5: 1506-159 (E) Bit field type specified for op_type
11032# Since the word 'warning' isn't present, use a fairly rigorous match of what
11033# warning messages look like
11034#            "    o        p        .  h   ", line    203      .   5        :   1506     -    159      (  E  )
11035$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"
11036EOSS
11037        compiler_warning=./compiler_warning
11038        chmod +x $compiler_warning
11039    ;;
11040     # Maybe a colon after the 'warning' would be appropriate
11041  *) compiler_warning="$contains -i warning"
11042    ;;
11043esac
11044
11045: Look for GCC-style attribute format
11046case "$d_attribute_format" in
11047'')
11048echo " "
11049echo "Checking whether your compiler can handle __attribute__((format)) ..." >&4
11050$cat >attrib.c <<'EOCP'
11051#include <stdio.h>
11052void my_special_printf(char* pat,...) __attribute__((__format__(__printf__,1,2)));
11053EOCP
11054if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11055	if $compiler_warning attrib.out >/dev/null 2>&1; then
11056		echo "Your C compiler doesn't support __attribute__((format))."
11057		val="$undef"
11058	else
11059		echo "Your C compiler supports __attribute__((format))."
11060		val="$define"
11061	fi
11062else
11063	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11064	val="$undef"
11065fi
11066;;
11067*) val="$d_attribute_format" ;;
11068esac
11069set d_attribute_format
11070eval $setvar
11071$rm -f attrib*
11072
11073: Look for GCC-style attribute format with null format allowed
11074case "$d_printf_format_null" in
11075'') case "$d_attribute_format" in
11076    $define)
11077	echo " "
11078	echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
11079$cat >attrib.c <<EOCP
11080#include <stdio.h>
11081#$i_stdlib I_STDLIB
11082#ifdef I_STDLIB
11083#include <stdlib.h>
11084#endif
11085#$i_inttypes I_INTTYPES
11086#ifdef I_INTTYPES
11087#include <inttypes.h>
11088#endif
11089#ifndef INTPTR_MAX
11090#define intptr_t int
11091#endif
11092int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
11093int null_printf (char* pat,...) { return (int)(intptr_t)pat; }
11094int main () { exit(null_printf(NULL)); }
11095EOCP
11096	if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
11097	    : run the executable in case it produces a run-time warning
11098	    if $run ./attrib >>attrib.out 2>&1; then
11099		if $compiler_warning attrib.out >/dev/null 2>&1; then
11100		    echo "Your C compiler doesn't allow __printf__ format to be null."
11101		    val="$undef"
11102		else
11103		    echo "Your C compiler allows __printf__ format to be null."
11104		    val="$define"
11105		fi
11106	    else
11107	    echo "Your C compiler executable failed with __printf__ format null."
11108	    val="$undef"
11109	fi
11110    else
11111	echo "Your C compiler fails with __printf__ format null."
11112	val="$undef"
11113    fi
11114    ;;
11115    *)  val="$undef" ;;
11116    esac
11117;;
11118*)  val="$d_printf_format_null" ;;
11119esac
11120set d_printf_format_null
11121eval $setvar
11122$rm -f attrib*
11123
11124: Look for GCC-style attribute malloc
11125case "$d_attribute_malloc" in
11126'')
11127echo " "
11128echo "Checking whether your compiler can handle __attribute__((malloc)) ..." >&4
11129$cat >attrib.c <<'EOCP'
11130#include <stdio.h>
11131char *go_get_some_memory( int how_many_bytes ) __attribute__((malloc));
11132EOCP
11133if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11134	if $compiler_warning attrib.out >/dev/null 2>&1; then
11135		echo "Your C compiler doesn't support __attribute__((malloc))."
11136		val="$undef"
11137	else
11138		echo "Your C compiler supports __attribute__((malloc))."
11139		val="$define"
11140	fi
11141else
11142	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11143	val="$undef"
11144fi
11145;;
11146*) val="$d_attribute_malloc" ;;
11147esac
11148set d_attribute_malloc
11149eval $setvar
11150$rm -f attrib*
11151
11152: Look for GCC-style attribute nonnull
11153case "$d_attribute_nonnull" in
11154'')
11155echo " "
11156echo "Checking whether your compiler can handle __attribute__((nonnull(1))) ..." >&4
11157$cat >attrib.c <<'EOCP'
11158#include <stdio.h>
11159void do_something (char *some_pointer,...) __attribute__((nonnull(1)));
11160EOCP
11161if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11162	if $compiler_warning attrib.out >/dev/null 2>&1; then
11163		echo "Your C compiler doesn't support __attribute__((nonnull))."
11164		val="$undef"
11165	else
11166		echo "Your C compiler supports __attribute__((nonnull))."
11167		val="$define"
11168	fi
11169else
11170	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11171	val="$undef"
11172fi
11173;;
11174*) val="$d_attribute_nonnull" ;;
11175esac
11176set d_attribute_nonnull
11177eval $setvar
11178$rm -f attrib*
11179
11180: Look for GCC-style attribute noreturn
11181case "$d_attribute_noreturn" in
11182'')
11183echo " "
11184echo "Checking whether your compiler can handle __attribute__((noreturn)) ..." >&4
11185$cat >attrib.c <<'EOCP'
11186#include <stdio.h>
11187void fall_over_dead( void ) __attribute__((noreturn));
11188EOCP
11189if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11190	if $compiler_warning attrib.out >/dev/null 2>&1; then
11191		echo "Your C compiler doesn't support __attribute__((noreturn))."
11192		val="$undef"
11193	else
11194		echo "Your C compiler supports __attribute__((noreturn))."
11195		val="$define"
11196	fi
11197else
11198	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11199	val="$undef"
11200fi
11201;;
11202*) val="$d_attribute_noreturn" ;;
11203esac
11204set d_attribute_noreturn
11205eval $setvar
11206$rm -f attrib*
11207
11208: Look for GCC-style attribute pure
11209case "$d_attribute_pure" in
11210'')
11211echo " "
11212echo "Checking whether your compiler can handle __attribute__((pure)) ..." >&4
11213$cat >attrib.c <<'EOCP'
11214#include <stdio.h>
11215int square( int n ) __attribute__((pure));
11216EOCP
11217if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11218	if $compiler_warning attrib.out >/dev/null 2>&1; then
11219		echo "Your C compiler doesn't support __attribute__((pure))."
11220		val="$undef"
11221	else
11222		echo "Your C compiler supports __attribute__((pure))."
11223		val="$define"
11224	fi
11225else
11226	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11227	val="$undef"
11228fi
11229;;
11230*) val="$d_attribute_pure" ;;
11231esac
11232set d_attribute_pure
11233eval $setvar
11234$rm -f attrib*
11235
11236: Look for GCC-style attribute unused
11237case "$d_attribute_unused" in
11238'')
11239echo " "
11240echo "Checking whether your compiler can handle __attribute__((unused)) ..." >&4
11241$cat >attrib.c <<'EOCP'
11242#include <stdio.h>
11243int do_something( int dummy __attribute__((unused)), int n );
11244EOCP
11245if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11246	if $compiler_warning attrib.out >/dev/null 2>&1; then
11247		echo "Your C compiler doesn't support __attribute__((unused))."
11248		val="$undef"
11249	else
11250		echo "Your C compiler supports __attribute__((unused))."
11251		val="$define"
11252	fi
11253else
11254	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11255	val="$undef"
11256fi
11257;;
11258*) val="$d_attribute_unused" ;;
11259esac
11260set d_attribute_unused
11261eval $setvar
11262$rm -f attrib*
11263
11264: Look for GCC-style attribute deprecated
11265case "$d_attribute_deprecated" in
11266'')
11267echo " "
11268echo "Checking whether your compiler can handle __attribute__((deprecated)) ..." >&4
11269$cat >attrib.c <<'EOCP'
11270#include <stdio.h>
11271int I_am_deprecated(void) __attribute__((deprecated));
11272EOCP
11273if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11274	if $compiler_warning attrib.out >/dev/null 2>&1; then
11275		echo "Your C compiler doesn't support __attribute__((deprecated))."
11276		val="$undef"
11277	else
11278		echo "Your C compiler supports __attribute__((deprecated))."
11279		val="$define"
11280	fi
11281else
11282	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11283	val="$undef"
11284fi
11285;;
11286*) val="$d_attribute_deprecated" ;;
11287esac
11288set d_attribute_deprecated
11289eval $setvar
11290$rm -f attrib*
11291
11292: Look for GCC-style attribute warn_unused_result
11293case "$d_attribute_warn_unused_result" in
11294'')
11295echo " "
11296echo "Checking whether your compiler can handle __attribute__((warn_unused_result)) ..." >&4
11297$cat >attrib.c <<'EOCP'
11298#include <stdio.h>
11299int I_will_not_be_ignored(void) __attribute__((warn_unused_result));
11300EOCP
11301if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11302	if $compiler_warning attrib.out >/dev/null 2>&1; then
11303		echo "Your C compiler doesn't support __attribute__((warn_unused_result))."
11304		val="$undef"
11305	else
11306		echo "Your C compiler supports __attribute__((warn_unused_result))."
11307		val="$define"
11308	fi
11309else
11310	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11311	val="$undef"
11312fi
11313;;
11314*) val="$d_attribute_warn_unused_result" ;;
11315esac
11316set d_attribute_warn_unused_result
11317eval $setvar
11318$rm -f attrib*
11319
11320: Look for GCC-style attribute always_inline
11321case "$d_attribute_always_inline" in
11322'')
11323echo " "
11324echo "Checking whether your compiler can handle __attribute__((always_inline)) ..." >&4
11325$cat >attrib.c <<'EOCP'
11326#include <stdio.h>
11327static __inline__ __attribute__((always_inline)) int I_will_always_be_inlined(void);
11328EOCP
11329if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
11330	if $compiler_warning attrib.out >/dev/null 2>&1; then
11331		echo "Your C compiler doesn't support __attribute__((always_inline))."
11332		val="$undef"
11333	else
11334		echo "Your C compiler supports __attribute__((always_inline))."
11335		val="$define"
11336	fi
11337else
11338	echo "Your C compiler doesn't seem to understand __attribute__ at all."
11339	val="$undef"
11340fi
11341;;
11342*) val="$d_attribute_always_inline" ;;
11343esac
11344set d_attribute_always_inline
11345eval $setvar
11346$rm -f attrib*
11347
11348: see if getpgrp exists
11349set getpgrp d_getpgrp
11350eval $inlibc
11351
11352case "$d_getpgrp" in
11353"$define")
11354	echo " "
11355	echo "Checking to see which flavor of getpgrp is in use..."
11356	$cat >try.c <<EOP
11357#include <stdio.h>
11358#$i_unistd I_UNISTD
11359#include <sys/types.h>
11360#ifdef I_UNISTD
11361#  include <unistd.h>
11362#endif
11363#$i_stdlib I_STDLIB
11364#ifdef I_STDLIB
11365#include <stdlib.h>
11366#endif
11367int main()
11368{
11369	if (getuid() == 0) {
11370		printf("(I see you are running Configure as super-user...)\n");
11371		setuid(1);
11372	}
11373#ifdef TRY_BSD_PGRP
11374	if (getpgrp(1) == 0)
11375		exit(0);
11376#else
11377	if (getpgrp() > 0)
11378		exit(0);
11379#endif
11380	exit(1);
11381}
11382EOP
11383	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11384		echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
11385		val="$define"
11386	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11387		echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
11388		val="$undef"
11389	else
11390		echo "I can't seem to compile and run the test program."
11391		if ./usg; then
11392			xxx="a USG one, i.e. you use getpgrp()."
11393		else
11394			# SVR4 systems can appear rather BSD-ish.
11395			case "$i_unistd" in
11396			$undef)
11397				xxx="a BSD one, i.e. you use getpgrp(pid)."
11398				val="$define"
11399				;;
11400			$define)
11401				xxx="probably a USG one, i.e. you use getpgrp()."
11402				val="$undef"
11403				;;
11404			esac
11405		fi
11406		echo "Assuming your getpgrp is $xxx" >&4
11407	fi
11408	;;
11409*) val="$undef";;
11410esac
11411set d_bsdgetpgrp
11412eval $setvar
11413$rm_try
11414
11415: see if setpgrp exists
11416set setpgrp d_setpgrp
11417eval $inlibc
11418
11419case "$d_setpgrp" in
11420"$define")
11421	echo " "
11422	echo "Checking to see which flavor of setpgrp is in use..."
11423	$cat >try.c <<EOP
11424#include <stdio.h>
11425#$i_unistd I_UNISTD
11426#include <sys/types.h>
11427#ifdef I_UNISTD
11428#  include <unistd.h>
11429#endif
11430#$i_stdlib I_STDLIB
11431#ifdef I_STDLIB
11432#include <stdlib.h>
11433#endif
11434int main()
11435{
11436	if (getuid() == 0) {
11437		printf("(I see you are running Configure as super-user...)\n");
11438		setuid(1);
11439	}
11440#ifdef TRY_BSD_PGRP
11441	if (-1 == setpgrp(1, 1))
11442		exit(0);
11443#else
11444	if (setpgrp() != -1)
11445		exit(0);
11446#endif
11447	exit(1);
11448}
11449EOP
11450	if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11451		echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
11452		val="$define"
11453	elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
11454		echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
11455		val="$undef"
11456	else
11457		echo "(I can't seem to compile and run the test program.)"
11458		if ./usg; then
11459			xxx="a USG one, i.e. you use setpgrp()."
11460		else
11461			# SVR4 systems can appear rather BSD-ish.
11462			case "$i_unistd" in
11463			$undef)
11464				xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
11465				val="$define"
11466				;;
11467			$define)
11468				xxx="probably a USG one, i.e. you use setpgrp()."
11469				val="$undef"
11470				;;
11471			esac
11472		fi
11473		echo "Assuming your setpgrp is $xxx" >&4
11474	fi
11475	;;
11476*) val="$undef";;
11477esac
11478set d_bsdsetpgrp
11479eval $setvar
11480$rm_try
11481
11482: Look for GCC-style __builtin_add_overflow
11483case "$d_builtin_add_overflow" in
11484'')
11485    echo " "
11486    echo "Checking whether your compiler can handle __builtin_add_overflow ..." >&4
11487    $cat >try.c <<'EOCP'
11488int main(void) {
11489    const unsigned int uint_max = ~0u;
11490    int target_int = 0;
11491    if (__builtin_add_overflow(1, 2, &target_int) || target_int != 3) {
11492        return 1;
11493    }
11494    if (!__builtin_add_overflow((int)(uint_max >> 1), 1, &target_int)) {
11495        return 1;
11496    }
11497    if (!__builtin_add_overflow(uint_max, -1, &target_int)) {
11498        return 1;
11499    }
11500    return 0;
11501}
11502EOCP
11503    set try
11504    if eval $compile && $run ./try; then
11505        echo "Your C compiler supports __builtin_add_overflow."
11506        val="$define"
11507    else
11508        echo "Your C compiler doesn't seem to understand __builtin_add_overflow."
11509        val="$undef"
11510    fi
11511    ;;
11512*) val="$d_builtin_add_overflow" ;;
11513esac
11514
11515set d_builtin_add_overflow
11516eval $setvar
11517$rm_try
11518
11519: Look for GCC-style __builtin_sub_overflow
11520case "$d_builtin_sub_overflow" in
11521'')
11522    echo " "
11523    echo "Checking whether your compiler can handle __builtin_sub_overflow ..." >&4
11524    $cat >try.c <<'EOCP'
11525int main(void) {
11526    const unsigned int uint_max = ~0u;
11527    int target_int = 0;
11528    if (__builtin_sub_overflow(1, -2, &target_int) || target_int != 3) {
11529        return 1;
11530    }
11531    if (!__builtin_sub_overflow(-(int)(uint_max >> 1), 2, &target_int)) {
11532        return 1;
11533    }
11534    if (!__builtin_sub_overflow(uint_max, 1, &target_int)) {
11535        return 1;
11536    }
11537    return 0;
11538}
11539EOCP
11540    set try
11541    if eval $compile && $run ./try; then
11542        echo "Your C compiler supports __builtin_sub_overflow."
11543        val="$define"
11544    else
11545        echo "Your C compiler doesn't seem to understand __builtin_sub_overflow."
11546        val="$undef"
11547    fi
11548    ;;
11549*) val="$d_builtin_sub_overflow" ;;
11550esac
11551
11552set d_builtin_sub_overflow
11553eval $setvar
11554$rm_try
11555
11556: Look for GCC-style __builtin_mul_overflow
11557case "$d_builtin_mul_overflow" in
11558'')
11559    echo " "
11560    echo "Checking whether your compiler can handle __builtin_mul_overflow ..." >&4
11561    $cat >try.c <<'EOCP'
11562int main(void) {
11563    const unsigned int uint_max = ~0u;
11564    int target_int = 0;
11565    if (__builtin_mul_overflow(2, 3, &target_int) || target_int != 6) {
11566        return 1;
11567    }
11568    if (!__builtin_mul_overflow((int)(uint_max >> 1), 2, &target_int)) {
11569        return 1;
11570    }
11571    if (!__builtin_mul_overflow(uint_max, 1, &target_int)) {
11572        return 1;
11573    }
11574    return 0;
11575}
11576EOCP
11577    set try
11578    if eval $compile && $run ./try; then
11579        echo "Your C compiler supports __builtin_mul_overflow."
11580        val="$define"
11581    else
11582        echo "Your C compiler doesn't seem to understand __builtin_mul_overflow."
11583        val="$undef"
11584    fi
11585    ;;
11586*) val="$d_builtin_mul_overflow" ;;
11587esac
11588
11589set d_builtin_mul_overflow
11590eval $setvar
11591$rm_try
11592
11593: Look for GCC-style __builtin_choose_expr
11594case "$d_builtin_choose_expr" in
11595'')
11596    echo " "
11597    echo "Checking whether your compiler can handle __builtin_choose_expr ..." >&4
11598    $cat >try.c <<'EOCP'
11599#include <assert.h>
11600#include <stdlib.h>
11601#include <stdio.h>
11602
11603#define SYRINX(x) __builtin_choose_expr( x, (1056*2), (103*50) )
11604
11605int main(void) {
11606    assert( SYRINX(1) == 2112 );
11607    assert( SYRINX(1) != 5150 );
11608    assert( SYRINX(0) == 5150 );
11609    assert( SYRINX(0) != 2112 );
11610    puts( "All good!" );
11611    exit(0);
11612}
11613
11614EOCP
11615    set try
11616    if eval $compile && $run ./try; then
11617	echo "Your C compiler supports __builtin_choose_expr."
11618	val="$define"
11619    else
11620	echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
11621	val="$undef"
11622    fi
11623;;
11624*) val="$d_builtin_choose_expr" ;;
11625esac
11626
11627set d_builtin_choose_expr
11628eval $setvar
11629$rm_try
11630
11631: Look for GCC-style __builtin_expect
11632case "$d_builtin_expect" in
11633'')
11634    echo " "
11635    echo "Checking whether your compiler can handle __builtin_expect ..." >&4
11636    $cat >try.c <<'EOCP'
11637int main(void) {
11638    int n = 50;
11639    if ( __builtin_expect(n, 0) ) n = 1;
11640    /* Remember shell exit code truth is 0, C truth is non-zero */
11641    return !(n == 1);
11642}
11643EOCP
11644    set try
11645    if eval $compile && $run ./try; then
11646	echo "Your C compiler supports __builtin_expect."
11647	val="$define"
11648    else
11649	echo "Your C compiler doesn't seem to understand __builtin_expect."
11650	val="$undef"
11651    fi
11652    ;;
11653*) val="$d_builtin_expect" ;;
11654esac
11655
11656set d_builtin_expect
11657eval $setvar
11658$rm_try
11659
11660: see if the Compiler supports C99 variadic macros
11661echo "Checking for C99 variadic macros." >&4
11662$cat >try.c <<EOCP
11663#include <stdio.h>
11664#include <stdarg.h>
11665
11666#define foo(buffer, format, ...) sprintf(buffer, format, __VA_ARGS__)
11667
11668int main() {
11669  char buf[20];
11670  foo(buf, "%d %g %.*s", 123, 456.0, (int)3, "789fail");
11671  puts(buf);
11672  return 0;
11673}
11674EOCP
11675set try
11676if eval $compile && $run ./try 2>&1 >/dev/null; then
11677    case "`$run ./try`" in
11678	"123 456 789")
11679	echo "You have C99 variadic macros." >&4
11680	d_c99_variadic_macros="$define"
11681	;;
11682	*)
11683	echo "You don't have functional C99 variadic macros." >&4
11684	d_c99_variadic_macros="$undef"
11685	;;
11686    esac
11687else
11688    echo "I couldn't compile and run the test program, so I assume that you don't have functional C99 variadic macros." >&4
11689    d_c99_variadic_macros="$undef"
11690fi
11691$rm_try
11692
11693: see if signal is declared as pointer to function returning int or void
11694echo " "
11695xxx=`./findhdr signal.h`
11696$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
11697if $contains 'int.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11698	echo "You have int (*signal())() instead of void." >&4
11699	val="$undef"
11700elif $contains 'void.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
11701	echo "You have void (*signal())()." >&4
11702	val="$define"
11703elif $contains 'extern[ 	]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
11704	echo "You have int (*signal())() instead of void." >&4
11705	val="$undef"
11706elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
11707	echo "You have void (*signal())()." >&4
11708	val="$define"
11709else
11710	case "$d_voidsig" in
11711	'')
11712	echo "I can't determine whether signal handler returns void or int..." >&4
11713		dflt=void
11714		rp="What type does your signal handler return?"
11715		. ./myread
11716		case "$ans" in
11717		v*) val="$define";;
11718		*) val="$undef";;
11719		esac;;
11720	"$define")
11721		echo "As you already told me, signal handler returns void." >&4
11722		val="$define"
11723		;;
11724	*)	echo "As you already told me, signal handler returns int." >&4
11725		val="$undef"
11726		;;
11727	esac
11728fi
11729set d_voidsig
11730eval $setvar
11731case "$d_voidsig" in
11732"$define") signal_t="void";;
11733*) signal_t="int";;
11734esac
11735$rm -f $$.tmp
11736
11737: check for ability to cast large floats to 32-bit ints.
11738echo " "
11739echo 'Checking whether your C compiler can cast large floats to int32.' >&4
11740if $test "$intsize" -ge 4; then
11741	xxx=int
11742else
11743	xxx=long
11744fi
11745$cat >try.c <<EOCP
11746#include <stdio.h>
11747#$i_stdlib I_STDLIB
11748#ifdef I_STDLIB
11749#include <stdlib.h>
11750#endif
11751#include <sys/types.h>
11752#include <signal.h>
11753$signal_t blech(int s) { exit(3); }
11754int main()
11755{
11756	$xxx i32;
11757	double f, g;
11758	int result = 0;
11759	char str[16];
11760	signal(SIGFPE, blech);
11761
11762	/* Don't let compiler optimize the test away.  Store the number
11763	   in a writable string for gcc to pass to sscanf under HP-UX.
11764	*/
11765	sprintf(str, "2147483647");
11766	sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
11767	g = 10 * f;
11768	i32  = ($xxx) g;
11769
11770	/* x86 processors will probably give 0x8000 0000, which is a
11771	   sign change.  We don't want that.  We want to mimic SPARC
11772	   behavior here, which is to preserve the sign and give
11773	   back 0x7fff ffff.
11774	*/
11775	if (i32 != ($xxx) f)
11776		result |= 1;
11777	exit(result);
11778}
11779EOCP
11780set try
11781if eval $compile_ok; then
11782	$run ./try 2>/dev/null
11783	yyy=$?
11784else
11785	echo "(I can't seem to compile the test program--assuming it can't)"
11786	yyy=1
11787fi
11788case "$yyy" in
117890)	val="$define"
11790	echo "Yup, it can."
11791	;;
11792*)	val="$undef"
11793	echo "Nope, it can't."
11794	;;
11795esac
11796set d_casti32
11797eval $setvar
11798$rm_try
11799
11800: check for ability to cast negative floats to unsigned
11801echo " "
11802echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
11803$cat >try.c <<EOCP
11804#include <stdio.h>
11805#$i_stdlib I_STDLIB
11806#ifdef I_STDLIB
11807#include <stdlib.h>
11808#endif
11809#include <sys/types.h>
11810#include <signal.h>
11811$signal_t blech(int s) { exit(7); }
11812$signal_t blech_in_list(int s) { exit(4); }
11813unsigned long dummy_long(unsigned long p) { return p; }
11814unsigned int dummy_int(unsigned int p) { return p; }
11815unsigned short dummy_short(unsigned short p) { return p; }
11816int main()
11817{
11818	double f;
11819	unsigned long along;
11820	unsigned int aint;
11821	unsigned short ashort;
11822	int result = 0;
11823	char str[16];
11824
11825	/* Frustrate gcc-2.7.2's optimizer which failed this test with
11826	   a direct f = -123. assignment.  gcc-2.8.0 reportedly
11827	   optimized the whole file away
11828	*/
11829	/* Store the number in a writable string for gcc to pass to
11830	   sscanf under HP-UX.
11831	*/
11832	sprintf(str, "-123");
11833	sscanf(str, "%lf", &f);  /* f = -123.; */
11834
11835	signal(SIGFPE, blech);
11836	along = (unsigned long)f;
11837	aint = (unsigned int)f;
11838	ashort = (unsigned short)f;
11839	if (along != (unsigned long)-123)
11840		result |= 1;
11841	if (aint != (unsigned int)-123)
11842		result |= 1;
11843	if (ashort != (unsigned short)-123)
11844		result |= 1;
11845	sprintf(str, "1073741824.");
11846	sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
11847	f = f + f;
11848	along = 0;
11849	along = (unsigned long)f;
11850	if (along != 0x80000000)
11851		result |= 2;
11852	f -= 1.;
11853	along = 0;
11854	along = (unsigned long)f;
11855	if (along != 0x7fffffff)
11856		result |= 1;
11857	f += 2.;
11858	along = 0;
11859	along = (unsigned long)f;
11860	if (along != 0x80000001)
11861		result |= 2;
11862	if (result)
11863		exit(result);
11864	signal(SIGFPE, blech_in_list);
11865	sprintf(str, "123.");
11866	sscanf(str, "%lf", &f);  /* f = 123.; */
11867	along = dummy_long((unsigned long)f);
11868	aint = dummy_int((unsigned int)f);
11869	ashort = dummy_short((unsigned short)f);
11870	if (along != (unsigned long)123)
11871		result |= 4;
11872	if (aint != (unsigned int)123)
11873		result |= 4;
11874	if (ashort != (unsigned short)123)
11875		result |= 4;
11876	exit(result);
11877
11878}
11879EOCP
11880set try
11881if eval $compile_ok; then
11882	$run ./try 2>/dev/null
11883	castflags=$?
11884else
11885	echo "(I can't seem to compile the test program--assuming it can't)"
11886	castflags=7
11887fi
11888case "$castflags" in
118890)	val="$define"
11890	echo "Yup, it can."
11891	;;
11892*)	val="$undef"
11893	echo "Nope, it can't."
11894	;;
11895esac
11896set d_castneg
11897eval $setvar
11898$rm_try
11899
11900: see if cbrt exists
11901set cbrt d_cbrt
11902eval $inlibc
11903
11904: see if chown exists
11905set chown d_chown
11906eval $inlibc
11907
11908: see if chroot exists
11909set chroot d_chroot
11910eval $inlibc
11911
11912: see if chsize exists
11913set chsize d_chsize
11914eval $inlibc
11915
11916: see if class exists
11917set class d_class
11918eval $inlibc
11919
11920: see if clearenv exists
11921set clearenv d_clearenv
11922eval $inlibc
11923
11924: Define hasstruct macro for Configure internal use
11925hasstruct='varname=$1; struct=$2; shift; shift;
11926while $test $# -ge 2; do
11927	case "$1" in
11928	$define) echo "#include <$2>";;
11929	esac ;
11930    shift 2;
11931done > try.c;
11932echo "int main () { struct $struct foo; }" >> try.c;
11933set try;
11934if eval $compile; then
11935	val="$define";
11936else
11937	val="$undef";
11938fi;
11939set $varname;
11940eval $setvar;
11941$rm_try'
11942
11943: see whether socket exists
11944socketlib=''
11945sockethdr=''
11946echo " "
11947$echo $n "Hmm... $c" >&4
11948if set socket val -f d_socket; eval $csym; $val; then
11949    echo "Looks like you have Berkeley networking support." >&4
11950    d_socket="$define"
11951    if set setsockopt val -f; eval $csym; $val; then
11952	d_oldsock="$undef"
11953    else
11954	echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
11955	d_oldsock="$define"
11956    fi
11957else
11958    if $contains socklib libc.list >/dev/null 2>&1; then
11959	echo "Looks like you have Berkeley networking support." >&4
11960	d_socket="$define"
11961	: we will have to assume that it supports the 4.2 BSD interface
11962	d_oldsock="$undef"
11963    else
11964	echo "You don't have Berkeley networking in libc$_a..." >&4
11965	if test "X$d_socket" = "X$define"; then
11966	    echo "...but you seem to believe that you have sockets." >&4
11967	else
11968	    for net in net socket
11969	    do
11970		if test -f $sysroot/usr/lib/lib$net$_a; then
11971		    ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) ||  \
11972		    $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list
11973		    if $contains socket libc.list >/dev/null 2>&1; then
11974			d_socket="$define"
11975			socketlib="-l$net"
11976			case "$net" in
11977			net)
11978			    echo "...but the Wollongong group seems to have hacked it in." >&4
11979			    sockethdr="-I$sysroot/usr/netinclude"
11980			    ;;
11981			esac
11982			echo "Found Berkeley sockets interface in lib$net." >&4
11983			if $contains setsockopt libc.list >/dev/null 2>&1; then
11984			    d_oldsock="$undef"
11985			else
11986			    echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
11987			    d_oldsock="$define"
11988			fi
11989			break
11990		    fi
11991		fi
11992	    done
11993	    if test "X$d_socket" != "X$define"; then
11994	       echo "or anywhere else I see." >&4
11995	       d_socket="$undef"
11996	       d_oldsock="$undef"
11997	    fi
11998	fi
11999    fi
12000fi
12001
12002: see if socketpair exists
12003set socketpair d_sockpair
12004eval $inlibc
12005
12006
12007echo "Checking the availability sa_len in the sock struct ..." >&4
12008$cat >try.c <<EOF
12009#include <sys/types.h>
12010#include <sys/socket.h>
12011int main() {
12012struct sockaddr sa;
12013return (sa.sa_len);
12014}
12015EOF
12016val="$undef"
12017set try; if eval $compile; then
12018    val="$define"
12019fi
12020set d_sockaddr_sa_len; eval $setvar
12021$rm_try
12022
12023echo "Checking the availability struct sockaddr_in6 ..." >&4
12024$cat >try.c <<EOF
12025#include <sys/types.h>
12026#include <sys/socket.h>
12027#include <netinet/in.h>
12028int main() {
12029struct sockaddr_in6 sin6;
12030return (sin6.sin6_family);
12031}
12032EOF
12033val="$undef"
12034set try; if eval $compile; then
12035    val="$define"
12036fi
12037set d_sockaddr_in6; eval $setvar
12038$rm_try
12039
12040echo "Checking the availability struct sockaddr_storage ..." >&4
12041$cat >try.c <<EOF
12042#include <sys/types.h>
12043#include <sys/socket.h>
12044#include <netinet/in.h>
12045int main() {
12046struct sockaddr_storage sastor;
12047return (sastor.ss_family);
12048}
12049EOF
12050val="$undef"
12051set try; if eval $compile; then
12052    val="$define"
12053fi
12054set d_sockaddr_storage; eval $setvar
12055$rm_try
12056
12057echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
12058$cat >try.c <<EOF
12059#include <sys/types.h>
12060#include <sys/socket.h>
12061#include <netinet/in.h>
12062int main() {
12063struct sockaddr_in6 sin6;
12064return (sin6.sin6_scope_id);
12065}
12066EOF
12067val="$undef"
12068set try; if eval $compile; then
12069    val="$define"
12070fi
12071set d_sin6_scope_id; eval $setvar
12072$rm_try
12073
12074echo "Checking the availability struct ip_mreq ..." >&4
12075$cat >try.c <<EOF
12076#include <sys/types.h>
12077#include <sys/socket.h>
12078#include <netinet/in.h>
12079int main() {
12080struct ip_mreq mreq;
12081return (mreq.imr_multiaddr.s_addr);
12082}
12083EOF
12084val="$undef"
12085set try; if eval $compile; then
12086       val="$define"
12087fi
12088set d_ip_mreq; eval $setvar
12089$rm_try
12090
12091echo "Checking the availability struct ip_mreq_source ..." >&4
12092$cat >try.c <<EOF
12093#include <sys/types.h>
12094#include <sys/socket.h>
12095#include <netinet/in.h>
12096int main() {
12097struct ip_mreq_source mreq;
12098return (mreq.imr_multiaddr.s_addr);
12099}
12100EOF
12101val="$undef"
12102set try; if eval $compile; then
12103       val="$define"
12104fi
12105set d_ip_mreq_source; eval $setvar
12106$rm_try
12107
12108echo "Checking the availability struct ipv6_mreq ..." >&4
12109$cat >try.c <<EOF
12110#include <sys/types.h>
12111#include <sys/socket.h>
12112#include <netinet/in.h>
12113int main() {
12114struct ipv6_mreq mreq;
12115return (mreq.ipv6mr_interface);
12116}
12117EOF
12118val="$undef"
12119set try; if eval $compile; then
12120    val="$define"
12121fi
12122set d_ipv6_mreq; eval $setvar
12123$rm_try
12124
12125echo "Checking the availability struct ipv6_mreq_source ..." >&4
12126$cat >try.c <<EOF
12127#include <sys/types.h>
12128#include <sys/socket.h>
12129#include <netinet/in.h>
12130int main() {
12131struct ipv6_mreq_source mreq;
12132return (mreq.imr_multiaddr.s_addr);
12133}
12134EOF
12135val="$undef"
12136set try; if eval $compile; then
12137       val="$define"
12138fi
12139set d_ipv6_mreq_source; eval $setvar
12140$rm_try
12141
12142echo "Checking the availability of certain socket constants..." >&4
12143for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
12144    enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
12145    $cat >try.c <<EOF
12146#include <sys/types.h>
12147#include <sys/socket.h>
12148int main() {
12149    int i = $ENUM;
12150}
12151EOF
12152    val="$undef"
12153    set try; if eval $compile; then
12154	val="$define"
12155    fi
12156    set d_${enum}; eval $setvar
12157    $rm_try
12158done
12159
12160: see if this is a sys/uio.h system
12161set sys/uio.h i_sysuio
12162eval $inhdr
12163
12164: Check for cmsghdr support
12165echo " "
12166echo "Checking to see if your system supports struct cmsghdr..." >&4
12167set d_cmsghdr_s cmsghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
12168eval $hasstruct
12169case "$d_cmsghdr_s" in
12170"$define")      echo "Yes, it does."   ;;
12171*)              echo "No, it doesn't." ;;
12172esac
12173
12174: see if copysign exists
12175set copysign d_copysign
12176eval $inlibc
12177
12178: see if copysignl exists
12179set copysignl d_copysignl
12180eval $inlibc
12181
12182: see if crypt exists
12183echo " "
12184set crypt d_crypt
12185eval $inlibc
12186case "$d_crypt" in
12187$define) cryptlib='' ;;
12188*)	if set crypt val -f d_crypt; eval $csym; $val; then
12189		echo 'crypt() found.' >&4
12190		val="$define"
12191		cryptlib=''
12192	else
12193		cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
12194		if $test -z "$cryptlib"; then
12195			cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
12196		else
12197			cryptlib=-lcrypt
12198		fi
12199		if $test -z "$cryptlib"; then
12200			cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
12201		else
12202			cryptlib=-lcrypt
12203		fi
12204		if $test -z "$cryptlib"; then
12205			cryptlib=`./loc libcrypt$_a "" $libpth`
12206		else
12207			cryptlib=-lcrypt
12208		fi
12209		if $test -z "$cryptlib"; then
12210			echo 'crypt() NOT found.' >&4
12211			val="$undef"
12212		else
12213			val="$define"
12214		fi
12215	fi
12216	set d_crypt
12217	eval $setvar
12218	;;
12219esac
12220
12221: see if this is a crypt.h system
12222set crypt.h i_crypt
12223eval $inhdr
12224
12225: see if crypt_r exists
12226set crypt_r d_crypt_r
12227eval $inlibc
12228case "$d_crypt_r" in
12229"$define")
12230	hdrs="$i_systypes sys/types.h define stdio.h $i_crypt crypt.h"
12231	case "$d_crypt_r_proto:$usethreads" in
12232	":define")	d_crypt_r_proto=define
12233		set d_crypt_r_proto crypt_r $hdrs
12234		eval $hasproto ;;
12235	*)	;;
12236	esac
12237	case "$d_crypt_r_proto" in
12238	define)
12239	case "$crypt_r_proto" in
12240	''|0) try='char* crypt_r(const char*, const char*, struct crypt_data*);'
12241	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCS ;;
12242	esac
12243	case "$crypt_r_proto" in
12244	''|0) try='char* crypt_r(const char*, const char*, CRYPTD*);'
12245	./protochk "$extern_C $try" $hdrs && crypt_r_proto=B_CCD ;;
12246	esac
12247	case "$crypt_r_proto" in
12248	''|0)	d_crypt_r=undef
12249		crypt_r_proto=0
12250		echo "Disabling crypt_r, cannot determine prototype." >&4 ;;
12251	* )	case "$crypt_r_proto" in
12252		REENTRANT_PROTO*) ;;
12253		*) crypt_r_proto="REENTRANT_PROTO_$crypt_r_proto" ;;
12254		esac
12255		echo "Prototype: $try" ;;
12256	esac
12257	;;
12258	*)	case "$usethreads" in
12259		define) echo "crypt_r has no prototype, not using it." >&4 ;;
12260		esac
12261		d_crypt_r=undef
12262		crypt_r_proto=0
12263		;;
12264	esac
12265	;;
12266*)	crypt_r_proto=0
12267	;;
12268esac
12269
12270: get csh whereabouts
12271case "$csh" in
12272'csh') val="$undef" ;;
12273*) val="$define" ;;
12274esac
12275set d_csh
12276eval $setvar
12277: Respect a hint or command line value for full_csh.
12278case "$full_csh" in
12279'') full_csh=$csh ;;
12280esac
12281
12282: see if ctermid exists
12283set ctermid d_ctermid
12284eval $inlibc
12285
12286: see if ctermid_r exists
12287set ctermid_r d_ctermid_r
12288eval $inlibc
12289case "$d_ctermid_r" in
12290"$define")
12291	hdrs="$i_systypes sys/types.h define stdio.h "
12292	case "$d_ctermid_r_proto:$usethreads" in
12293	":define")	d_ctermid_r_proto=define
12294		set d_ctermid_r_proto ctermid_r $hdrs
12295		eval $hasproto ;;
12296	*)	;;
12297	esac
12298	case "$d_ctermid_r_proto" in
12299	define)
12300	case "$ctermid_r_proto" in
12301	''|0) try='char* ctermid_r(char*);'
12302	./protochk "$extern_C $try" $hdrs && ctermid_r_proto=B_B ;;
12303	esac
12304	case "$ctermid_r_proto" in
12305	''|0)	d_ctermid_r=undef
12306		ctermid_r_proto=0
12307		echo "Disabling ctermid_r, cannot determine prototype." >&4 ;;
12308	* )	case "$ctermid_r_proto" in
12309		REENTRANT_PROTO*) ;;
12310		*) ctermid_r_proto="REENTRANT_PROTO_$ctermid_r_proto" ;;
12311		esac
12312		echo "Prototype: $try" ;;
12313	esac
12314	;;
12315	*)	case "$usethreads" in
12316		define) echo "ctermid_r has no prototype, not using it." >&4 ;;
12317		esac
12318		d_ctermid_r=undef
12319		ctermid_r_proto=0
12320		;;
12321	esac
12322	;;
12323*)	ctermid_r_proto=0
12324	;;
12325esac
12326
12327: see if ctime_r exists
12328set ctime_r d_ctime_r
12329eval $inlibc
12330case "$d_ctime_r" in
12331"$define")
12332	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
12333	case "$d_ctime_r_proto:$usethreads" in
12334	":define")	d_ctime_r_proto=define
12335		set d_ctime_r_proto ctime_r $hdrs
12336		eval $hasproto ;;
12337	*)	;;
12338	esac
12339	case "$d_ctime_r_proto" in
12340	define)
12341	case "$ctime_r_proto" in
12342	''|0) try='char* ctime_r(const time_t*, char*);'
12343	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SB ;;
12344	esac
12345	case "$ctime_r_proto" in
12346	''|0) try='char* ctime_r(const time_t*, char*, int);'
12347	./protochk "$extern_C $try" $hdrs && ctime_r_proto=B_SBI ;;
12348	esac
12349	case "$ctime_r_proto" in
12350	''|0) try='int ctime_r(const time_t*, char*);'
12351	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SB ;;
12352	esac
12353	case "$ctime_r_proto" in
12354	''|0) try='int ctime_r(const time_t*, char*, int);'
12355	./protochk "$extern_C $try" $hdrs && ctime_r_proto=I_SBI ;;
12356	esac
12357	case "$ctime_r_proto" in
12358	''|0)	d_ctime_r=undef
12359		ctime_r_proto=0
12360		echo "Disabling ctime_r, cannot determine prototype." >&4 ;;
12361	* )	case "$ctime_r_proto" in
12362		REENTRANT_PROTO*) ;;
12363		*) ctime_r_proto="REENTRANT_PROTO_$ctime_r_proto" ;;
12364		esac
12365		echo "Prototype: $try" ;;
12366	esac
12367	;;
12368	*)	case "$usethreads" in
12369		define) echo "ctime_r has no prototype, not using it." >&4 ;;
12370		esac
12371		d_ctime_r=undef
12372		ctime_r_proto=0
12373		;;
12374	esac
12375	;;
12376*)	ctime_r_proto=0
12377	;;
12378esac
12379
12380: see if cuserid exists
12381set cuserid d_cuserid
12382eval $inlibc
12383
12384: see if dbm.h is available
12385: see if dbmclose exists
12386set dbmclose d_dbmclose
12387eval $inlibc
12388
12389case "$d_dbmclose" in
12390$define)
12391	set dbm.h i_dbm
12392	eval $inhdr
12393	case "$i_dbm" in
12394	$define)
12395		val="$undef"
12396		set i_rpcsvcdbm
12397		eval $setvar
12398		;;
12399	*)	set rpcsvc/dbm.h i_rpcsvcdbm
12400		eval $inhdr
12401		;;
12402	esac
12403	;;
12404*)	echo "We won't be including <dbm.h>"
12405	val="$undef"
12406	set i_dbm
12407	eval $setvar
12408	val="$undef"
12409	set i_rpcsvcdbm
12410	eval $setvar
12411	;;
12412esac
12413
12414: see if prototype for dbminit is available
12415echo " "
12416set d_dbminitproto dbminit $i_dbm dbm.h
12417eval $hasproto
12418
12419: see if difftime exists
12420set difftime d_difftime
12421eval $inlibc
12422
12423: see if this is a dirent system
12424echo " "
12425if xinc=`./findhdr dirent.h`; $test "$xinc"; then
12426	val="$define"
12427	echo "<dirent.h> found." >&4
12428else
12429	val="$undef"
12430	if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
12431		echo "<sys/dir.h> found." >&4
12432		echo " "
12433	else
12434		xinc=`./findhdr sys/ndir.h`
12435	fi
12436	echo "<dirent.h> NOT found." >&4
12437fi
12438set i_dirent
12439eval $setvar
12440
12441: Look for type of directory structure.
12442echo " "
12443$cppstdin $cppflags $cppminus < "$xinc" > try.c
12444
12445case "$direntrytype" in
12446''|' ')
12447	case "$i_dirent" in
12448	$define) guess1='struct dirent' ;;
12449	*) guess1='struct direct'  ;;
12450	esac
12451	;;
12452*)	guess1="$direntrytype"
12453	;;
12454esac
12455
12456case "$guess1" in
12457'struct dirent') guess2='struct direct' ;;
12458*) guess2='struct dirent' ;;
12459esac
12460
12461if $contains "$guess1" try.c >/dev/null 2>&1; then
12462	direntrytype="$guess1"
12463	echo "Your directory entries are $direntrytype." >&4
12464elif $contains "$guess2" try.c >/dev/null 2>&1; then
12465	direntrytype="$guess2"
12466	echo "Your directory entries seem to be $direntrytype." >&4
12467else
12468	echo "I don't recognize your system's directory entries." >&4
12469	rp="What type is used for directory entries on this system?"
12470	dflt="$guess1"
12471	. ./myread
12472	direntrytype="$ans"
12473fi
12474$rm_try
12475
12476: see if the directory entry stores field length
12477echo " "
12478$cppstdin $cppflags $cppminus < "$xinc" > try.c
12479if $contains 'd_namlen' try.c >/dev/null 2>&1; then
12480	echo "Good, your directory entry keeps length information in d_namlen." >&4
12481	val="$define"
12482else
12483	echo "Your directory entry does not know about the d_namlen field." >&4
12484	val="$undef"
12485fi
12486set d_dirnamlen
12487eval $setvar
12488$rm_try
12489
12490: Look for DIR.dd_fd
12491case "$i_dirent" in
12492"$define")
12493    echo "Checking to see if DIR has a dd_fd member variable" >&4
12494    $cat >try.c <<EOCP
12495#$i_stdlib I_STDLIB
12496#ifdef I_STDLIB
12497#include <stdlib.h>
12498#endif
12499#include <dirent.h>
12500
12501int main() {
12502    DIR dir;
12503    dir.dd_fd = 1;
12504    return 0;
12505}
12506EOCP
12507    val=$undef
12508    set try
12509    if eval $compile; then
12510        echo "Yes, it does."
12511        val="$define"
12512    else
12513        echo "No, it does not."
12514        val="$undef"
12515    fi
12516    ;;
12517*)
12518    echo "You don't have a <dirent.h>, so not checking for dd_fd." >&4
12519    val="$undef"
12520    ;;
12521esac
12522set d_dir_dd_fd
12523eval $setvar
12524$rm_try
12525
12526: see if this is an sysdir system
12527set sys/dir.h i_sysdir
12528eval $inhdr
12529
12530: see if this is an sysndir system
12531set sys/ndir.h i_sysndir
12532eval $inhdr
12533
12534: Look for dirfd
12535echo " "
12536$cat >dirfd.c <<EOM
12537#include <stdio.h>
12538#$i_stdlib I_STDLIB
12539#ifdef I_STDLIB
12540#include <stdlib.h>
12541#endif
12542#$i_dirent I_DIRENT		/**/
12543#$i_sysdir I_SYS_DIR		/**/
12544#$i_sysndir I_SYS_NDIR		/**/
12545#$i_systypes I_SYS_TYPES	/**/
12546#if defined(I_SYS_TYPES)
12547#include <sys/types.h>
12548#endif
12549#if defined(I_DIRENT)
12550#include <dirent.h>
12551#else
12552#ifdef I_SYS_NDIR
12553#include <sys/ndir.h>
12554#else
12555#ifdef I_SYS_DIR
12556#include <sys/dir.h>
12557#endif
12558#endif
12559#endif
12560int main() {
12561	DIR *dirp = opendir(".");
12562	if (dirfd(dirp) >= 0)
12563		exit(0);
12564	else
12565		exit(1);
12566}
12567EOM
12568val=$undef
12569set dirfd
12570if eval $compile; then
12571	val="$define"
12572fi
12573case "$val" in
12574$define)	echo "dirfd() found." >&4	;;
12575*)		echo "dirfd() NOT found." >&4	;;
12576esac
12577set d_dirfd
12578eval $setvar
12579$rm -f dirfd*
12580
12581: see if dladdr exists
12582set dladdr d_dladdr
12583eval $inlibc
12584
12585: see if dlerror exists
12586xxx_runnm="$runnm"
12587runnm=false
12588set dlerror d_dlerror
12589eval $inlibc
12590runnm="$xxx_runnm"
12591
12592: see if dlfcn is available
12593set dlfcn.h i_dlfcn
12594eval $inhdr
12595
12596: Check what extension to use for shared libs
12597case "$usedl" in
12598$define|y|true)
12599	$cat << EOM
12600
12601On a few systems, the dynamically loaded modules that perl generates and uses
12602will need a different extension than shared libs. The default will probably
12603be appropriate.
12604
12605EOM
12606	case "$dlext" in
12607	'')	dflt="$so" ;;
12608	*)	dflt="$dlext" ;;
12609	esac
12610	rp='What is the extension of dynamically loaded modules'
12611	. ./myread
12612	dlext="$ans"
12613	;;
12614*)
12615	dlext="none"
12616	;;
12617esac
12618
12619: Check if dlsym need a leading underscore
12620echo " "
12621val="$undef"
12622
12623case "$dlsrc" in
12624dl_dlopen.xs)
12625	echo "Checking whether your dlsym() needs a leading underscore ..." >&4
12626	$cat >dyna.c <<'EOM'
12627fred () { }
12628EOM
12629
12630$cat >fred.c<<EOM
12631
12632#include <stdio.h>
12633#$i_stdlib I_STDLIB
12634#ifdef I_STDLIB
12635#include <stdlib.h>
12636#endif
12637#$i_dlfcn I_DLFCN
12638#ifdef I_DLFCN
12639#include <dlfcn.h>      /* the dynamic linker include file for SunOS/Solaris */
12640#else
12641#include <sys/types.h>
12642#include <nlist.h>
12643#include <link.h>
12644#endif
12645
12646extern int fred() ;
12647
12648int main()
12649{
12650    void * handle ;
12651    void * symbol ;
12652#ifndef RTLD_LAZY
12653    int mode = 1 ;
12654#else
12655    int mode = RTLD_LAZY ;
12656#endif
12657    handle = dlopen("./dyna.$dlext", mode) ;
12658    if (handle == NULL) {
12659	printf ("1\n") ;
12660	fflush (stdout) ;
12661	exit(0);
12662    }
12663    symbol = dlsym(handle, "fred") ;
12664    if (symbol == NULL) {
12665	/* try putting a leading underscore */
12666	symbol = dlsym(handle, "_fred") ;
12667	if (symbol == NULL) {
12668	    printf ("2\n") ;
12669	    fflush (stdout) ;
12670	    exit(0);
12671	}
12672	printf ("3\n") ;
12673    }
12674    else
12675	printf ("4\n") ;
12676    fflush (stdout) ;
12677    exit(0);
12678}
12679EOM
12680	: Call the object file tmp-dyna.o in case dlext=o.
12681	if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 &&
12682		mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 &&
12683		$ld -o dyna.$dlext $ldflags $lddlflags tmp-dyna${_o} > /dev/null 2>&1 &&
12684		$cc -o fred $ccflags $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1 && $to dyna.$dlext; then
12685		xxx=`$run ./fred`
12686		case $xxx in
12687		1)	echo "Test program failed using dlopen." >&4
12688			echo "Perhaps you should not use dynamic loading." >&4;;
12689		2)	echo "Test program failed using dlsym." >&4
12690			echo "Perhaps you should not use dynamic loading." >&4;;
12691		3)	echo "dlsym needs a leading underscore" >&4
12692			val="$define" ;;
12693		4)	echo "dlsym doesn't need a leading underscore." >&4;;
12694		esac
12695	else
12696		echo "I can't compile and run the test program." >&4
12697                echo "I'm guessing that dlsym doesn't need a leading underscore." >&4
12698	fi
12699	;;
12700esac
12701
12702$rm -f fred fred.* dyna.$dlext dyna.* tmp-dyna.*
12703
12704set d_dlsymun
12705eval $setvar
12706
12707: see if drand48_r exists
12708set drand48_r d_drand48_r
12709eval $inlibc
12710case "$d_drand48_r" in
12711"$define")
12712	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
12713	case "$d_drand48_r_proto:$usethreads" in
12714	":define")	d_drand48_r_proto=define
12715		set d_drand48_r_proto drand48_r $hdrs
12716		eval $hasproto ;;
12717	*)	;;
12718	esac
12719	case "$d_drand48_r_proto" in
12720	define)
12721	case "$drand48_r_proto" in
12722	''|0) try='int drand48_r(struct drand48_data*, double*);'
12723	./protochk "$extern_C $try" $hdrs && drand48_r_proto=I_ST ;;
12724	esac
12725	case "$drand48_r_proto" in
12726	''|0)	d_drand48_r=undef
12727		drand48_r_proto=0
12728		echo "Disabling drand48_r, cannot determine prototype." >&4 ;;
12729	* )	case "$drand48_r_proto" in
12730		REENTRANT_PROTO*) ;;
12731		*) drand48_r_proto="REENTRANT_PROTO_$drand48_r_proto" ;;
12732		esac
12733		echo "Prototype: $try" ;;
12734	esac
12735	;;
12736	*)	case "$usethreads" in
12737		define) echo "drand48_r has no prototype, not using it." >&4 ;;
12738		esac
12739		d_drand48_r=undef
12740		drand48_r_proto=0
12741		;;
12742	esac
12743	;;
12744*)	drand48_r_proto=0
12745	;;
12746esac
12747
12748: see if prototype for drand48 is available
12749echo " "
12750set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
12751eval $hasproto
12752
12753: see if dup2 exists
12754set dup2 d_dup2
12755eval $inlibc
12756
12757: see if dup3 exists
12758set dup3 d_dup3
12759eval $inlibc
12760
12761: see if localeconv_l exists
12762set localeconv_l d_localeconv_l
12763eval $inlibc
12764
12765: see if this is an xlocale.h system
12766set xlocale.h i_xlocale
12767eval $inhdr
12768
12769: see if newlocale exists
12770set newlocale d_newlocale
12771eval $inlibc
12772
12773: see if freelocale exists
12774set freelocale d_freelocale
12775eval $inlibc
12776
12777: see if uselocale exists
12778set uselocale d_uselocale
12779eval $inlibc
12780
12781: see if duplocale exists
12782set duplocale d_duplocale
12783eval $inlibc
12784
12785: see if querylocale exists
12786set querylocale d_querylocale
12787eval $inlibc
12788
12789: if we have xlocale.h, check whether it is needed
12790case "$i_xlocale$d_newlocale$xlocale_needed" in
12791"$define$define")
12792	echo "Checking if xlocale.h is needed..." >&4
12793	$cat >try.c <<EOF
12794#include <locale.h>
12795#include <stdio.h>
12796#ifdef TRY_XLOCALE
12797#include <xlocale.h>
12798#endif
12799#$d_localeconv_l HAVE_LOCALECONV_L
12800
12801#ifdef HAVE_LOCALECONV_L
12802struct lconv *(*lcptr)(locale_t) = localeconv_l;
12803#endif
12804
12805int main(void) {
12806  locale_t lc = newlocale(LC_ALL_MASK, "C", (locale_t)0);
12807
12808#ifdef HAVE_LOCALECONV_L
12809  /* FreeBSD hides only localeconv_l() in xlocale.h */
12810  struct lconv *lcbuf = localeconv_l(lc);
12811  printf("decimal: %s\n", lcbuf->decimal_point);
12812#endif
12813
12814  freelocale(lc);
12815  return 0;
12816}
12817EOF
12818	set try
12819	if eval $compile && $run ./try > /dev/null 2>&1 ; then
12820		echo "xlocale.h isn't needed" >&4
12821		xlocale_needed=$undef
12822	else
12823		set try -DTRY_XLOCALE
12824		if eval $compile && $run ./try > /dev/null 2>&1 ; then
12825			xlocale_needed=$define
12826			echo "xlocale.h is needed" >&4
12827		else
12828			echo "I can't build my test either way" >&4
12829			xlocale_needed=$undef
12830		fi
12831	fi
12832	$rm_try
12833	;;
12834*) xlocale_needed=$undef ;;
12835esac
12836
12837: see if eaccess exists
12838set eaccess d_eaccess
12839eval $inlibc
12840
12841: see if endgrent exists
12842set endgrent d_endgrent
12843eval $inlibc
12844
12845: see if this is an grp system
12846set grp.h i_grp
12847eval $inhdr
12848
12849case "$i_grp" in
12850$define)
12851	xxx=`./findhdr grp.h`
12852	$cppstdin $cppflags $cppminus < $xxx >$$.h
12853
12854	if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
12855		val="$define"
12856	else
12857		val="$undef"
12858	fi
12859	set d_grpasswd
12860	eval $setvar
12861
12862	$rm -f $$.h
12863	;;
12864*)
12865	val="$undef";
12866	set d_grpasswd; eval $setvar
12867	;;
12868esac
12869
12870: see if endgrent_r exists
12871set endgrent_r d_endgrent_r
12872eval $inlibc
12873case "$d_endgrent_r" in
12874"$define")
12875	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
12876	case "$d_endgrent_r_proto:$usethreads" in
12877	":define")	d_endgrent_r_proto=define
12878		set d_endgrent_r_proto endgrent_r $hdrs
12879		eval $hasproto ;;
12880	*)	;;
12881	esac
12882	case "$d_endgrent_r_proto" in
12883	define)
12884	case "$endgrent_r_proto" in
12885	''|0) try='int endgrent_r(FILE**);'
12886	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=I_H ;;
12887	esac
12888	case "$endgrent_r_proto" in
12889	''|0) try='void endgrent_r(FILE**);'
12890	./protochk "$extern_C $try" $hdrs && endgrent_r_proto=V_H ;;
12891	esac
12892	case "$endgrent_r_proto" in
12893	''|0)	d_endgrent_r=undef
12894		endgrent_r_proto=0
12895		echo "Disabling endgrent_r, cannot determine prototype." >&4 ;;
12896	* )	case "$endgrent_r_proto" in
12897		REENTRANT_PROTO*) ;;
12898		*) endgrent_r_proto="REENTRANT_PROTO_$endgrent_r_proto" ;;
12899		esac
12900		echo "Prototype: $try" ;;
12901	esac
12902	;;
12903	*)	case "$usethreads" in
12904		define) echo "endgrent_r has no prototype, not using it." >&4 ;;
12905		esac
12906		d_endgrent_r=undef
12907		endgrent_r_proto=0
12908		;;
12909	esac
12910	;;
12911*)	endgrent_r_proto=0
12912	;;
12913esac
12914
12915: see if endhostent exists
12916set endhostent d_endhent
12917eval $inlibc
12918
12919: see if this is a netdb.h system
12920set netdb.h i_netdb
12921eval $inhdr
12922
12923: see if endhostent_r exists
12924set endhostent_r d_endhostent_r
12925eval $inlibc
12926case "$d_endhostent_r" in
12927"$define")
12928	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12929	case "$d_endhostent_r_proto:$usethreads" in
12930	":define")	d_endhostent_r_proto=define
12931		set d_endhostent_r_proto endhostent_r $hdrs
12932		eval $hasproto ;;
12933	*)	;;
12934	esac
12935	case "$d_endhostent_r_proto" in
12936	define)
12937	case "$endhostent_r_proto" in
12938	''|0) try='int endhostent_r(struct hostent_data*);'
12939	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=I_D ;;
12940	esac
12941	case "$endhostent_r_proto" in
12942	''|0) try='void endhostent_r(struct hostent_data*);'
12943	./protochk "$extern_C $try" $hdrs && endhostent_r_proto=V_D ;;
12944	esac
12945	case "$endhostent_r_proto" in
12946	''|0)	d_endhostent_r=undef
12947		endhostent_r_proto=0
12948		echo "Disabling endhostent_r, cannot determine prototype." >&4 ;;
12949	* )	case "$endhostent_r_proto" in
12950		REENTRANT_PROTO*) ;;
12951		*) endhostent_r_proto="REENTRANT_PROTO_$endhostent_r_proto" ;;
12952		esac
12953		echo "Prototype: $try" ;;
12954	esac
12955	;;
12956	*)	case "$usethreads" in
12957		define) echo "endhostent_r has no prototype, not using it." >&4 ;;
12958		esac
12959		d_endhostent_r=undef
12960		endhostent_r_proto=0
12961		;;
12962	esac
12963	;;
12964*)	endhostent_r_proto=0
12965	;;
12966esac
12967
12968: see if endnetent exists
12969set endnetent d_endnent
12970eval $inlibc
12971
12972: see if endnetent_r exists
12973set endnetent_r d_endnetent_r
12974eval $inlibc
12975case "$d_endnetent_r" in
12976"$define")
12977	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
12978	case "$d_endnetent_r_proto:$usethreads" in
12979	":define")	d_endnetent_r_proto=define
12980		set d_endnetent_r_proto endnetent_r $hdrs
12981		eval $hasproto ;;
12982	*)	;;
12983	esac
12984	case "$d_endnetent_r_proto" in
12985	define)
12986	case "$endnetent_r_proto" in
12987	''|0) try='int endnetent_r(struct netent_data*);'
12988	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=I_D ;;
12989	esac
12990	case "$endnetent_r_proto" in
12991	''|0) try='void endnetent_r(struct netent_data*);'
12992	./protochk "$extern_C $try" $hdrs && endnetent_r_proto=V_D ;;
12993	esac
12994	case "$endnetent_r_proto" in
12995	''|0)	d_endnetent_r=undef
12996		endnetent_r_proto=0
12997		echo "Disabling endnetent_r, cannot determine prototype." >&4 ;;
12998	* )	case "$endnetent_r_proto" in
12999		REENTRANT_PROTO*) ;;
13000		*) endnetent_r_proto="REENTRANT_PROTO_$endnetent_r_proto" ;;
13001		esac
13002		echo "Prototype: $try" ;;
13003	esac
13004	;;
13005	*)	case "$usethreads" in
13006		define) echo "endnetent_r has no prototype, not using it." >&4 ;;
13007		esac
13008		d_endnetent_r=undef
13009		endnetent_r_proto=0
13010		;;
13011	esac
13012	;;
13013*)	endnetent_r_proto=0
13014	;;
13015esac
13016
13017: see if endprotoent exists
13018set endprotoent d_endpent
13019eval $inlibc
13020
13021: see if endprotoent_r exists
13022set endprotoent_r d_endprotoent_r
13023eval $inlibc
13024case "$d_endprotoent_r" in
13025"$define")
13026	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
13027	case "$d_endprotoent_r_proto:$usethreads" in
13028	":define")	d_endprotoent_r_proto=define
13029		set d_endprotoent_r_proto endprotoent_r $hdrs
13030		eval $hasproto ;;
13031	*)	;;
13032	esac
13033	case "$d_endprotoent_r_proto" in
13034	define)
13035	case "$endprotoent_r_proto" in
13036	''|0) try='int endprotoent_r(struct protoent_data*);'
13037	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=I_D ;;
13038	esac
13039	case "$endprotoent_r_proto" in
13040	''|0) try='void endprotoent_r(struct protoent_data*);'
13041	./protochk "$extern_C $try" $hdrs && endprotoent_r_proto=V_D ;;
13042	esac
13043	case "$endprotoent_r_proto" in
13044	''|0)	d_endprotoent_r=undef
13045		endprotoent_r_proto=0
13046		echo "Disabling endprotoent_r, cannot determine prototype." >&4 ;;
13047	* )	case "$endprotoent_r_proto" in
13048		REENTRANT_PROTO*) ;;
13049		*) endprotoent_r_proto="REENTRANT_PROTO_$endprotoent_r_proto" ;;
13050		esac
13051		echo "Prototype: $try" ;;
13052	esac
13053	;;
13054	*)	case "$usethreads" in
13055		define) echo "endprotoent_r has no prototype, not using it." >&4 ;;
13056		esac
13057		d_endprotoent_r=undef
13058		endprotoent_r_proto=0
13059		;;
13060	esac
13061	;;
13062*)	endprotoent_r_proto=0
13063	;;
13064esac
13065
13066: see if endpwent exists
13067set endpwent d_endpwent
13068eval $inlibc
13069
13070: see if this is a pwd.h system
13071set pwd.h i_pwd
13072eval $inhdr
13073
13074case "$i_pwd" in
13075$define)
13076	xxx=`./findhdr pwd.h`
13077	$cppstdin $cppflags $cppminus < $xxx >$$.h
13078
13079	if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
13080		val="$define"
13081	else
13082		val="$undef"
13083	fi
13084	set d_pwquota
13085	eval $setvar
13086
13087	if $contains 'pw_age' $$.h >/dev/null 2>&1; then
13088		val="$define"
13089	else
13090		val="$undef"
13091	fi
13092	set d_pwage
13093	eval $setvar
13094
13095	if $contains 'pw_change' $$.h >/dev/null 2>&1; then
13096		val="$define"
13097	else
13098		val="$undef"
13099	fi
13100	set d_pwchange
13101	eval $setvar
13102
13103	if $contains 'pw_class' $$.h >/dev/null 2>&1; then
13104		val="$define"
13105	else
13106		val="$undef"
13107	fi
13108	set d_pwclass
13109	eval $setvar
13110
13111	if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
13112		val="$define"
13113	else
13114		val="$undef"
13115	fi
13116	set d_pwexpire
13117	eval $setvar
13118
13119	if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
13120		val="$define"
13121	else
13122		val="$undef"
13123	fi
13124	set d_pwcomment
13125	eval $setvar
13126
13127	if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
13128		val="$define"
13129	else
13130		val="$undef"
13131	fi
13132	set d_pwgecos
13133	eval $setvar
13134
13135	if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
13136		val="$define"
13137	else
13138		val="$undef"
13139	fi
13140	set d_pwpasswd
13141	eval $setvar
13142
13143	$rm -f $$.h
13144	;;
13145*)
13146	val="$undef";
13147	set d_pwquota; eval $setvar
13148	set d_pwage; eval $setvar
13149	set d_pwchange; eval $setvar
13150	set d_pwclass; eval $setvar
13151	set d_pwexpire; eval $setvar
13152	set d_pwcomment; eval $setvar
13153	set d_pwgecos; eval $setvar
13154	set d_pwpasswd; eval $setvar
13155	;;
13156esac
13157
13158: see if endpwent_r exists
13159set endpwent_r d_endpwent_r
13160eval $inlibc
13161case "$d_endpwent_r" in
13162"$define")
13163	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
13164	case "$d_endpwent_r_proto:$usethreads" in
13165	":define")	d_endpwent_r_proto=define
13166		set d_endpwent_r_proto endpwent_r $hdrs
13167		eval $hasproto ;;
13168	*)	;;
13169	esac
13170	case "$d_endpwent_r_proto" in
13171	define)
13172	case "$endpwent_r_proto" in
13173	''|0) try='int endpwent_r(FILE**);'
13174	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=I_H ;;
13175	esac
13176	case "$endpwent_r_proto" in
13177	''|0) try='void endpwent_r(FILE**);'
13178	./protochk "$extern_C $try" $hdrs && endpwent_r_proto=V_H ;;
13179	esac
13180	case "$endpwent_r_proto" in
13181	''|0)	d_endpwent_r=undef
13182		endpwent_r_proto=0
13183		echo "Disabling endpwent_r, cannot determine prototype." >&4 ;;
13184	* )	case "$endpwent_r_proto" in
13185		REENTRANT_PROTO*) ;;
13186		*) endpwent_r_proto="REENTRANT_PROTO_$endpwent_r_proto" ;;
13187		esac
13188		echo "Prototype: $try" ;;
13189	esac
13190	;;
13191	*)	case "$usethreads" in
13192		define) echo "endpwent_r has no prototype, not using it." >&4 ;;
13193		esac
13194		d_endpwent_r=undef
13195		endpwent_r_proto=0
13196		;;
13197	esac
13198	;;
13199*)	endpwent_r_proto=0
13200	;;
13201esac
13202
13203: see if endservent exists
13204set endservent d_endsent
13205eval $inlibc
13206
13207: see if endservent_r exists
13208set endservent_r d_endservent_r
13209eval $inlibc
13210case "$d_endservent_r" in
13211"$define")
13212	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
13213	case "$d_endservent_r_proto:$usethreads" in
13214	":define")	d_endservent_r_proto=define
13215		set d_endservent_r_proto endservent_r $hdrs
13216		eval $hasproto ;;
13217	*)	;;
13218	esac
13219	case "$d_endservent_r_proto" in
13220	define)
13221	case "$endservent_r_proto" in
13222	''|0) try='int endservent_r(struct servent_data*);'
13223	./protochk "$extern_C $try" $hdrs && endservent_r_proto=I_D ;;
13224	esac
13225	case "$endservent_r_proto" in
13226	''|0) try='void endservent_r(struct servent_data*);'
13227	./protochk "$extern_C $try" $hdrs && endservent_r_proto=V_D ;;
13228	esac
13229	case "$endservent_r_proto" in
13230	''|0)	d_endservent_r=undef
13231		endservent_r_proto=0
13232		echo "Disabling endservent_r, cannot determine prototype." >&4 ;;
13233	* )	case "$endservent_r_proto" in
13234		REENTRANT_PROTO*) ;;
13235		*) endservent_r_proto="REENTRANT_PROTO_$endservent_r_proto" ;;
13236		esac
13237		echo "Prototype: $try" ;;
13238	esac
13239	;;
13240	*)	case "$usethreads" in
13241		define) echo "endservent_r has no prototype, not using it." >&4 ;;
13242		esac
13243		d_endservent_r=undef
13244		endservent_r_proto=0
13245		;;
13246	esac
13247	;;
13248*)	endservent_r_proto=0
13249	;;
13250esac
13251
13252: Locate the flags for 'open()'
13253echo " "
13254$cat >try.c <<EOCP
13255#include <sys/types.h>
13256#ifdef I_FCNTL
13257#include <fcntl.h>
13258#endif
13259#ifdef I_SYS_FILE
13260#include <sys/file.h>
13261#endif
13262#$i_stdlib I_STDLIB
13263#ifdef I_STDLIB
13264#include <stdlib.h>
13265#endif
13266int main() {
13267	if(O_RDONLY);
13268#ifdef O_TRUNC
13269	exit(0);
13270#else
13271	exit(1);
13272#endif
13273}
13274EOCP
13275: check sys/file.h first to get FREAD on Sun
13276if $test `./findhdr sys/file.h` && \
13277		set try -DI_SYS_FILE && eval $compile; then
13278	h_sysfile=true;
13279	echo "<sys/file.h> defines the O_* constants..." >&4
13280	if $run ./try; then
13281		echo "and you have the 3 argument form of open()." >&4
13282		val="$define"
13283	else
13284		echo "but not the 3 argument form of open().  Oh, well." >&4
13285		val="$undef"
13286	fi
13287elif $test `./findhdr fcntl.h` && \
13288		set try -DI_FCNTL && eval $compile; then
13289	h_fcntl=true;
13290	echo "<fcntl.h> defines the O_* constants..." >&4
13291	if $run ./try; then
13292		echo "and you have the 3 argument form of open()." >&4
13293		val="$define"
13294	else
13295		echo "but not the 3 argument form of open().  Oh, well." >&4
13296		val="$undef"
13297	fi
13298else
13299	val="$undef"
13300	echo "I can't find the O_* constant definitions!  You got problems." >&4
13301fi
13302set d_open3
13303eval $setvar
13304$rm_try
13305
13306: see if this is a sys/file.h system
13307val=''
13308set sys/file.h val
13309eval $inhdr
13310
13311: do we need to include sys/file.h ?
13312case "$val" in
13313"$define")
13314	echo " "
13315	if $h_sysfile; then
13316		val="$define"
13317		echo "We'll be including <sys/file.h>." >&4
13318	else
13319		val="$undef"
13320		echo "We won't be including <sys/file.h>." >&4
13321	fi
13322	;;
13323*)
13324	h_sysfile=false
13325	;;
13326esac
13327set i_sysfile
13328eval $setvar
13329
13330: see if fcntl.h is there
13331val=''
13332set fcntl.h val
13333eval $inhdr
13334
13335: see if we can include fcntl.h
13336case "$val" in
13337"$define")
13338	echo " "
13339	if $h_fcntl; then
13340		val="$define"
13341		echo "We'll be including <fcntl.h>." >&4
13342	else
13343		val="$undef"
13344		if $h_sysfile; then
13345	echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
13346		else
13347			echo "We won't be including <fcntl.h>." >&4
13348		fi
13349	fi
13350	;;
13351*)
13352	h_fcntl=false
13353	val="$undef"
13354	;;
13355esac
13356set i_fcntl
13357eval $setvar
13358
13359: see if fork exists
13360set fork d_fork
13361eval $inlibc
13362
13363: see if pipe exists
13364set pipe d_pipe
13365eval $inlibc
13366
13367: check for non-blocking I/O stuff
13368case "$h_sysfile" in
13369true) echo "#include <sys/file.h>" > head.c;;
13370*)
13371       case "$h_fcntl" in
13372       true) echo "#include <fcntl.h>" > head.c;;
13373       *) echo "#include <sys/fcntl.h>" > head.c;;
13374       esac
13375       ;;
13376esac
13377echo " "
13378echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
13379case "$o_nonblock" in
13380'')
13381	$cat head.c > try.c
13382	$cat >>try.c <<EOCP
13383#include <stdio.h>
13384#$i_stdlib I_STDLIB
13385#ifdef I_STDLIB
13386#include <stdlib.h>
13387#endif
13388#$i_fcntl I_FCNTL
13389#ifdef I_FCNTL
13390#include <fcntl.h>
13391#endif
13392int main() {
13393#ifdef O_NONBLOCK
13394	printf("O_NONBLOCK\n");
13395	exit(0);
13396#endif
13397#ifdef O_NDELAY
13398	printf("O_NDELAY\n");
13399	exit(0);
13400#endif
13401#ifdef FNDELAY
13402	printf("FNDELAY\n");
13403	exit(0);
13404#endif
13405	exit(0);
13406}
13407EOCP
13408	set try
13409	if eval $compile_ok; then
13410		o_nonblock=`$run ./try`
13411		case "$o_nonblock" in
13412		'') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
13413		*) echo "Seems like we can use $o_nonblock.";;
13414		esac
13415	else
13416		echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
13417	fi
13418	;;
13419*) echo "Using $hint value $o_nonblock.";;
13420esac
13421$rm_try
13422
13423echo " "
13424echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
13425case "$eagain" in
13426'')
13427	case "$d_fork:$d_pipe:$d_alarm" in
13428	define:define:define)
13429	$cat head.c > try.c
13430	$cat >>try.c <<EOCP
13431#include <errno.h>
13432#include <sys/types.h>
13433#include <signal.h>
13434#include <stdio.h>
13435#$i_stdlib I_STDLIB
13436#ifdef I_STDLIB
13437#include <stdlib.h>
13438#endif
13439#$i_fcntl I_FCNTL
13440#ifdef I_FCNTL
13441#include <fcntl.h>
13442#endif
13443#define MY_O_NONBLOCK $o_nonblock
13444#ifndef errno  /* XXX need better Configure test */
13445extern int errno;
13446#endif
13447#$i_unistd I_UNISTD
13448#ifdef I_UNISTD
13449#include <unistd.h>
13450#endif
13451#include <string.h>
13452$signal_t blech(int x) { exit(3); }
13453EOCP
13454	$cat >> try.c <<'EOCP'
13455int main()
13456{
13457	int pd[2];
13458	int pu[2];
13459	char buf[1];
13460	char string[100];
13461	int ret;
13462
13463	ret = pipe(pd);	/* Down: child -> parent */
13464	if (ret != 0)
13465		exit(3);
13466	ret = pipe(pu);	/* Up: parent -> child */
13467	if (ret != 0)
13468		exit(3);
13469	if (0 != fork()) {
13470		close(pd[1]);	/* Parent reads from pd[0] */
13471		close(pu[0]);	/* Parent writes (blocking) to pu[1] */
13472#ifdef F_SETFL
13473		if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
13474			exit(1);
13475#else
13476		exit(4);
13477#endif
13478		signal(SIGALRM, blech);
13479		alarm(5);
13480		if ((ret = read(pd[0], buf, 1)) > 0)	/* Nothing to read! */
13481			exit(2);
13482		sprintf(string, "%d\n", ret);
13483		ret = write(2, string, strlen(string));
13484		if (ret != strlen(string))
13485			exit(3);
13486		alarm(0);
13487#ifdef EAGAIN
13488		if (errno == EAGAIN) {
13489			printf("EAGAIN\n");
13490			goto ok;
13491		}
13492#endif
13493#ifdef EWOULDBLOCK
13494		if (errno == EWOULDBLOCK)
13495			printf("EWOULDBLOCK\n");
13496#endif
13497	ok:
13498		ret = write(pu[1], buf, 1);	/* Unblocks child, tell it to close our pipe */
13499		if (ret != 1)
13500			exit(3);
13501		sleep(2);				/* Give it time to close our pipe */
13502		alarm(5);
13503		ret = read(pd[0], buf, 1);	/* Should read EOF */
13504		alarm(0);
13505		sprintf(string, "%d\n", ret);
13506		ret = write(4, string, strlen(string));
13507		if (ret != strlen(string))
13508			exit(3);
13509		exit(0);
13510	}
13511
13512	close(pd[0]);			/* We write to pd[1] */
13513	close(pu[1]);			/* We read from pu[0] */
13514	ret = read(pu[0], buf, 1);	/* Wait for parent to signal us we may continue */
13515	if (ret != 1)
13516		exit(3);
13517	close(pd[1]);			/* Pipe pd is now fully closed! */
13518	exit(0);				/* Bye bye, thank you for playing! */
13519}
13520EOCP
13521	set try
13522	if eval $compile_ok; then
13523		echo "$startsh" >mtry
13524		echo "$run ./try >try.out 2>try.ret 4>try.err || exit 4" >>mtry
13525		chmod +x mtry
13526		$run ./mtry >/dev/null 2>&1
13527		case $? in
13528		0) eagain=`$cat try.out`;;
13529		1) echo "Could not perform non-blocking setting!";;
13530		2) echo "I did a successful read() for something that was not there!";;
13531		3) echo "Hmm... non-blocking I/O does not seem to be working!";;
13532		4) echo "Could not find F_SETFL!";;
13533		*) echo "Something terribly wrong happened during testing.";;
13534		esac
13535		rd_nodata=`$cat try.ret`
13536		echo "A read() system call with no data present returns $rd_nodata."
13537		case "$rd_nodata" in
13538		0|-1) ;;
13539		*)
13540			echo "(That's peculiar, fixing that to be -1.)"
13541			rd_nodata=-1
13542			;;
13543		esac
13544		case "$eagain" in
13545		'')
13546			echo "Forcing errno EAGAIN on read() with no data available."
13547			eagain=EAGAIN
13548			;;
13549		*)
13550			echo "Your read() sets errno to $eagain when no data is available."
13551			;;
13552		esac
13553		status=`$cat try.err`
13554		case "$status" in
13555		0) echo "And it correctly returns 0 to signal EOF.";;
13556		-1) echo "But it also returns -1 to signal EOF, so be careful!";;
13557		*) echo "However, your read() returns '$status' on EOF??";;
13558		esac
13559		val="$define"
13560		if test "$status" = "$rd_nodata"; then
13561			echo "WARNING: you can't distinguish between EOF and no data!"
13562			val="$undef"
13563		fi
13564	else
13565		echo "I can't compile the test program--assuming errno EAGAIN will do."
13566		eagain=EAGAIN
13567	fi
13568	;;
13569	*)	echo "Can't figure out how to test this--assuming errno EAGAIN will do."
13570		eagain=EAGAIN
13571		val="$define"
13572		;;
13573	esac
13574	set d_eofnblk
13575	eval $setvar
13576	;;
13577*)
13578	echo "Using $hint value $eagain."
13579	echo "Your read() returns $rd_nodata when no data is present."
13580	case "$d_eofnblk" in
13581	"$define") echo "And you can see EOF because read() returns 0.";;
13582	"$undef") echo "But you can't see EOF status from read() returned value.";;
13583	*)
13584		echo "(Assuming you can't see EOF status from read anyway.)"
13585		d_eofnblk=$undef
13586		;;
13587	esac
13588	;;
13589esac
13590$rm_try head.c mtry
13591
13592: see if erf exists
13593set erf d_erf
13594eval $inlibc
13595
13596: see if erfc exists
13597set erfc d_erfc
13598eval $inlibc
13599
13600: see if exp2 exists
13601set exp2 d_exp2
13602eval $inlibc
13603
13604: see if expm1 exists
13605set expm1 d_expm1
13606eval $inlibc
13607
13608: see if _ptr and _cnt from stdio act std
13609echo " "
13610
13611if $contains '_lbfsize' `./findhdr stdio.h` >/dev/null 2>&1 ; then
13612	echo "(Looks like you have stdio.h from BSD.)"
13613	case "$stdio_ptr" in
13614	'') stdio_ptr='((fp)->_p)'
13615		ptr_lval=$define
13616		;;
13617	*)	ptr_lval=$d_stdio_ptr_lval;;
13618	esac
13619	case "$stdio_cnt" in
13620	'') stdio_cnt='((fp)->_r)'
13621		cnt_lval=$define
13622		;;
13623	*)	cnt_lval=$d_stdio_cnt_lval;;
13624	esac
13625	case "$stdio_base" in
13626	'') stdio_base='((fp)->_ub._base ? (fp)->_ub._base : (fp)->_bf._base)';;
13627	esac
13628	case "$stdio_bufsiz" in
13629	'') stdio_bufsiz='((fp)->_ub._base ? (fp)->_ub._size : (fp)->_bf._size)';;
13630	esac
13631elif $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
13632	echo "(Looks like you have stdio.h from Linux.)"
13633	case "$stdio_ptr" in
13634	'') stdio_ptr='((fp)->_IO_read_ptr)'
13635		ptr_lval=$define
13636		;;
13637	*)	ptr_lval=$d_stdio_ptr_lval;;
13638	esac
13639	case "$stdio_cnt" in
13640	'') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
13641		cnt_lval=$undef
13642		;;
13643	*)	cnt_lval=$d_stdio_cnt_lval;;
13644	esac
13645	case "$stdio_base" in
13646	'') stdio_base='((fp)->_IO_read_base)';;
13647	esac
13648	case "$stdio_bufsiz" in
13649	'') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
13650	esac
13651else
13652	case "$stdio_ptr" in
13653	'') stdio_ptr='((fp)->_ptr)'
13654		ptr_lval=$define
13655		;;
13656	*)	ptr_lval=$d_stdio_ptr_lval;;
13657	esac
13658	case "$stdio_cnt" in
13659	'') stdio_cnt='((fp)->_cnt)'
13660		cnt_lval=$define
13661		;;
13662	*)	cnt_lval=$d_stdio_cnt_lval;;
13663	esac
13664	case "$stdio_base" in
13665	'') stdio_base='((fp)->_base)';;
13666	esac
13667	case "$stdio_bufsiz" in
13668	'') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
13669	esac
13670fi
13671
13672: test whether _ptr and _cnt really work
13673echo "Checking how std your stdio is..." >&4
13674$cat >try.c <<EOP
13675#include <stdio.h>
13676#$i_stdlib I_STDLIB
13677#ifdef I_STDLIB
13678#include <stdlib.h>
13679#endif
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>
16187int main (int argc, char *argv[])
16188{
16189    printf ("%d\n", _LIB_VERSION);
16190    return (0);
16191    } /* main */
16192EOCP
16193set try
16194if eval $compile; then
16195    foo=`$run ./try`
16196    echo "Yes, it does ($foo)" >&4
16197    d_libm_lib_version="$define"
16198else
16199    echo "No, it does not (probably harmless)" >&4
16200    fi
16201$rm_try
16202
16203: see if link exists
16204set link d_link
16205eval $inlibc
16206
16207: see if llrint exists
16208set llrint d_llrint
16209eval $inlibc
16210
16211: see if llrintl exists
16212set llrintl d_llrintl
16213eval $inlibc
16214
16215: see if llround exists
16216set llround d_llround
16217eval $inlibc
16218
16219: see if llroundl exists
16220set llroundl d_llroundl
16221eval $inlibc
16222
16223: see if localtime_r exists
16224set localtime_r d_localtime_r
16225eval $inlibc
16226case "$d_localtime_r" in
16227"$define")
16228	hdrs="$i_systypes sys/types.h define stdio.h $i_time time.h $i_systime sys/time.h"
16229	case "$d_localtime_r_proto:$usethreads" in
16230	":define")	d_localtime_r_proto=define
16231		set d_localtime_r_proto localtime_r $hdrs
16232		eval $hasproto ;;
16233	*)	;;
16234	esac
16235	case "$d_localtime_r_proto" in
16236	define)
16237	case "$localtime_r_proto" in
16238	''|0) try='struct tm* localtime_r(const time_t*, struct tm*);'
16239	./protochk "$extern_C $try" $hdrs && localtime_r_proto=S_TS ;;
16240	esac
16241	case "$localtime_r_proto" in
16242	''|0) try='int localtime_r(const time_t*, struct tm*);'
16243	./protochk "$extern_C $try" $hdrs && localtime_r_proto=I_TS ;;
16244	esac
16245	case "$localtime_r_proto" in
16246	''|0)	d_localtime_r=undef
16247		localtime_r_proto=0
16248		echo "Disabling localtime_r, cannot determine prototype." >&4 ;;
16249	* )	case "$localtime_r_proto" in
16250		REENTRANT_PROTO*) ;;
16251		*) localtime_r_proto="REENTRANT_PROTO_$localtime_r_proto" ;;
16252		esac
16253		echo "Prototype: $try" ;;
16254	esac
16255	;;
16256	*)	case "$usethreads" in
16257		define) echo "localtime_r has no prototype, not using it." >&4 ;;
16258		esac
16259		d_localtime_r=undef
16260		localtime_r_proto=0
16261		;;
16262	esac
16263	;;
16264*)	localtime_r_proto=0
16265	;;
16266esac
16267
16268: see if localtime_r calls tzset
16269case "$localtime_r_proto" in
16270REENTRANT_PROTO*)
16271	$cat >try.c <<EOCP
16272/*  Does our libc's localtime_r call tzset ?
16273 *  return 0 if so, 1 otherwise.
16274 */
16275#$i_systypes	I_SYS_TYPES
16276#$i_unistd	I_UNISTD
16277#$i_time	I_TIME
16278#$i_stdlib	I_STDLIB
16279#$i_malloc	I_MALLOC
16280#ifdef I_SYS_TYPES
16281#  include <sys/types.h>
16282#endif
16283#ifdef I_UNISTD
16284#  include <unistd.h>
16285#endif
16286#ifdef I_TIME
16287#  include <time.h>
16288#endif
16289#ifdef I_STDLIB
16290#include <stdlib.h>
16291#endif
16292#include <string.h>
16293#ifdef I_MALLOC
16294#  include <malloc.h>
16295#endif
16296int main()
16297{
16298    int result = 0;
16299    time_t t = time(0L);
16300    char w_tz[]="TZ" "=GMT+5",
16301	 e_tz[]="TZ" "=GMT-5",
16302	*tz_e = (char*)malloc(16),
16303	*tz_w = (char*)malloc(16);
16304    struct tm tm_e, tm_w;
16305    memset(&tm_e,'\0',sizeof(struct tm));
16306    memset(&tm_w,'\0',sizeof(struct tm));
16307    strcpy(tz_e,e_tz);
16308    strcpy(tz_w,w_tz);
16309
16310    putenv(tz_e);
16311    localtime_r(&t, &tm_e);
16312
16313    putenv(tz_w);
16314    localtime_r(&t, &tm_w);
16315
16316    if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
16317	result = 1;
16318
16319    free(tz_e);free(tz_w);
16320    return result;
16321}
16322EOCP
16323	set try
16324	if eval $compile; then
16325	    if $run ./try; then
16326		d_localtime_r_needs_tzset=undef;
16327	    else
16328		d_localtime_r_needs_tzset=define;
16329	    fi;
16330	else
16331	    d_localtime_r_needs_tzset=undef;
16332	fi;
16333     ;;
16334  *)
16335     d_localtime_r_needs_tzset=undef;
16336     ;;
16337esac
16338$rm_try
16339
16340: see if lockf exists
16341set lockf d_lockf
16342eval $inlibc
16343
16344: see if log1p exists
16345set log1p d_log1p
16346eval $inlibc
16347
16348: see if log2 exists
16349set log2 d_log2
16350eval $inlibc
16351
16352: see if logb exists
16353set logb d_logb
16354eval $inlibc
16355
16356: see if lrint exists
16357set lrint d_lrint
16358eval $inlibc
16359
16360: see if lrintl exists
16361set lrintl d_lrintl
16362eval $inlibc
16363
16364: see if lround exists
16365set lround d_lround
16366eval $inlibc
16367
16368: see if lroundl exists
16369set lroundl d_lroundl
16370eval $inlibc
16371
16372: see if prototype for lseek is available
16373echo " "
16374set d_lseekproto lseek $i_systypes sys/types.h $i_unistd unistd.h
16375eval $hasproto
16376
16377: see if lstat exists
16378set lstat d_lstat
16379eval $inlibc
16380
16381: see if madvise exists
16382set madvise d_madvise
16383eval $inlibc
16384
16385: see if malloc_size exists
16386set malloc_size d_malloc_size
16387eval $inlibc
16388
16389: see if malloc_size_good exists
16390set malloc_good_size d_malloc_good_size
16391eval $inlibc
16392
16393: see if malloc_usable_size exists
16394set malloc_usable_size d_malloc_usable_size
16395eval $inlibc
16396
16397: see if mblen exists
16398set mblen d_mblen
16399eval $inlibc
16400
16401: see if mbrlen exists
16402set mbrlen d_mbrlen
16403eval $inlibc
16404
16405: see if mbrtowc exists
16406set mbrtowc d_mbrtowc
16407eval $inlibc
16408
16409: see if mbstowcs exists
16410set mbstowcs d_mbstowcs
16411eval $inlibc
16412
16413: see if mbtowc exists
16414set mbtowc d_mbtowc
16415eval $inlibc
16416
16417: see if memmem exists
16418: We need both a prototype in string.h and the symbol in libc.
16419echo " "
16420d_memmem_proto=''
16421xx1="#$d_gnulibc HAS_GNULIBC"
16422xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
16423xx3='#   define _GNU_SOURCE'
16424xx4='#endif'
16425set d_memmem_proto memmem literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
16426eval $hasproto
16427case "$d_memmem_proto" in
16428    define) # see if memmem exists
16429	set memmem d_memmem
16430	eval $inlibc
16431	;;
16432    *)  val=$undef
16433	set d_memmem
16434	eval $setvar
16435	;;
16436esac
16437
16438: see if memrchr exists
16439: We need both a prototype in string.h and the symbol in libc.
16440echo " "
16441d_memrchr_proto=''
16442xx1="#$d_gnulibc HAS_GNULIBC"
16443xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
16444xx3='#   define _GNU_SOURCE'
16445xx4='#endif'
16446set d_memrchr_proto memrchr literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
16447eval $hasproto
16448case "$d_memrchr_proto" in
16449    define) # see if memrchr exists
16450	set memrchr d_memrchr
16451	eval $inlibc
16452	;;
16453    *)  val=$undef
16454	set d_memrchr
16455	eval $setvar
16456	;;
16457esac
16458
16459: see if mkdir exists
16460set mkdir d_mkdir
16461eval $inlibc
16462
16463: see if mkdtemp exists
16464set mkdtemp d_mkdtemp
16465eval $inlibc
16466
16467: see if mkfifo exists
16468set mkfifo d_mkfifo
16469eval $inlibc
16470
16471: see if mkostemp exists
16472set mkostemp d_mkostemp
16473eval $inlibc
16474
16475: see if mkstemp exists
16476set mkstemp d_mkstemp
16477eval $inlibc
16478
16479: see if mkstemps exists
16480set mkstemps d_mkstemps
16481eval $inlibc
16482
16483: see if mktime exists
16484set mktime d_mktime
16485eval $inlibc
16486
16487: see if sys/mman.h has to be included
16488set sys/mman.h i_sysmman
16489eval $inhdr
16490
16491: see if mmap exists
16492set mmap d_mmap
16493eval $inlibc
16494: see what shmat returns
16495: default to something harmless
16496mmaptype='void *'
16497case "$i_sysmman$d_mmap" in
16498"$define$define")
16499	$cat >mmap.c <<'END'
16500#include <sys/mman.h>
16501void *mmap();
16502END
16503	if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
16504		mmaptype='void *'
16505	else
16506		mmaptype='caddr_t'
16507	fi
16508	echo "and it returns ($mmaptype)." >&4
16509	;;
16510esac
16511
16512: see if sqrtl exists
16513set sqrtl d_sqrtl
16514eval $inlibc
16515
16516: see if scalbnl exists
16517set scalbnl d_scalbnl
16518eval $inlibc
16519
16520: see if truncl exists
16521set truncl d_truncl
16522eval $inlibc
16523
16524: see if modfl exists
16525set modfl d_modfl
16526eval $inlibc
16527
16528: see if prototype for modfl is available
16529echo " "
16530set d_modflproto modfl define math.h
16531eval $hasproto
16532
16533if $test "$uselongdouble" = "$define"; then
16534    message=""
16535    if $test "$d_sqrtl" != "$define"; then
16536	message="$message sqrtl"
16537    fi
16538    if $test "$d_modfl" != "$define"; then
16539	if $test "$d_truncl:$d_copysignl" = "$define:$define"; then
16540	    echo "You have both truncl and copysignl, so I can emulate modfl."
16541	else
16542	    if $test "$d_aintl:$d_copysignl" = "$define:$define"; then
16543		echo "You have both aintl and copysignl, so I can emulate modfl."
16544	    else
16545		message="$message modfl"
16546	    fi
16547	fi
16548    fi
16549    if $test "$d_frexpl" != "$define"; then
16550	if $test "$d_ilogbl:$d_scalbnl" = "$define:$define"; then
16551	    echo "You have both ilogbl and scalbnl, so I can emulate frexpl."
16552	else
16553	    message="$message frexpl"
16554	fi
16555    fi
16556    if $test "$d_ldexpl" != "$define"; then
16557	message="$message ldexpl"
16558    fi
16559
16560    if $test "$message" != ""; then
16561	$cat <<EOM >&4
16562
16563*** You requested the use of long doubles but you do not seem to have
16564*** the following mathematical functions needed for long double support:
16565***    $message
16566*** Please rerun Configure without -Duselongdouble and/or -Dusemorebits.
16567*** Cannot continue, aborting.
16568
16569EOM
16570
16571	exit 1
16572    fi
16573fi
16574
16575: see if mprotect exists
16576set mprotect d_mprotect
16577eval $inlibc
16578
16579: see if msgctl exists
16580set msgctl d_msgctl
16581eval $inlibc
16582
16583: see if msgget exists
16584set msgget d_msgget
16585eval $inlibc
16586
16587: see if msgsnd exists
16588set msgsnd d_msgsnd
16589eval $inlibc
16590
16591: see if msgrcv exists
16592set msgrcv d_msgrcv
16593eval $inlibc
16594
16595: see how much of the 'msg*(2)' library is present.
16596h_msg=true
16597echo " "
16598case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
16599*"$undef"*) h_msg=false;;
16600esac
16601case "$osname" in
16602freebsd)
16603    case "`ipcs 2>&1`" in
16604    "SVID messages"*"not configured"*)
16605	echo "Your $osname does not have the msg*(2) configured." >&4
16606        h_msg=false
16607	val="$undef"
16608	set msgctl d_msgctl
16609	eval $setvar
16610	set msgget d_msgget
16611	eval $setvar
16612	set msgsnd d_msgsnd
16613	eval $setvar
16614	set msgrcv d_msgrcv
16615	eval $setvar
16616	;;
16617    esac
16618    ;;
16619esac
16620: we could also check for sys/ipc.h ...
16621if $h_msg && $test `./findhdr sys/msg.h`; then
16622	echo "You have the full msg*(2) library." >&4
16623	val="$define"
16624else
16625	echo "You don't have the full msg*(2) library." >&4
16626	val="$undef"
16627fi
16628set d_msg
16629eval $setvar
16630
16631: Check for msghdr_s
16632echo " "
16633echo "Checking to see if your system supports struct msghdr..." >&4
16634set d_msghdr_s msghdr $i_systypes sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
16635eval $hasstruct
16636case "$d_msghdr_s" in
16637"$define")      echo "Yes, it does."   ;;
16638*)              echo "No, it doesn't." ;;
16639esac
16640
16641: see if msync exists
16642set msync d_msync
16643eval $inlibc
16644
16645: see if munmap exists
16646set munmap d_munmap
16647eval $inlibc
16648
16649: see if nan exists
16650set nan d_nan
16651eval $inlibc
16652
16653: see if nanosleep exists
16654set nanosleep d_nanosleep
16655eval $inlibc
16656
16657: see if nearbyint exists
16658set nearbyint d_nearbyint
16659eval $inlibc
16660
16661: see if nextafter exists
16662set nextafter d_nextafter
16663eval $inlibc
16664
16665: see if nexttoward exists
16666set nexttoward d_nexttoward
16667eval $inlibc
16668
16669: see if nice exists
16670set nice d_nice
16671eval $inlibc
16672
16673: see if this is a langinfo.h system
16674set langinfo.h i_langinfo
16675eval $inhdr
16676
16677: see if nl_langinfo exists
16678set nl_langinfo d_nl_langinfo
16679eval $inlibc
16680
16681: see if locale.h is available
16682set locale.h i_locale
16683eval $inhdr
16684
16685: check for nl_langinfo_l item
16686$cat <<EOM
16687
16688Checking to see if you have nl_langinfo_l(), and that it is thread-safe
16689EOM
16690$cat >try.c <<EOCP
16691#$i_stdlib I_STDLIB
16692#ifdef I_STDLIB
16693#  include <stdlib.h>
16694#endif
16695#include <string.h>
16696#$i_langinfo I_LANGINFO
16697#ifdef I_LANGINFO
16698#  include <langinfo.h>
16699#endif
16700#$i_pthread I_PTHREAD
16701#ifdef I_PTHREAD
16702#  include <pthread.h>
16703#endif
16704#$i_locale I_LOCALE
16705#ifdef I_LOCALE
16706#  include <locale.h>
16707#endif
16708
16709void *
16710thread_start(void * arg)
16711{
16712    nl_langinfo(RADIXCHAR);
16713}
16714
16715int main() {
16716    char * main_buffer;
16717    char save_main_buffer[1000];
16718    pthread_t subthread;
16719    pthread_attr_t attr;
16720
16721    main_buffer = nl_langinfo_l(CODESET, newlocale(LC_ALL_MASK, "C", 0));
16722
16723    /* If too large for our generous allowance, just assume we don't have
16724     * it. */
16725    if (strlen(main_buffer) >= sizeof(save_main_buffer)) {
16726        exit(1);
16727    }
16728
16729    strcpy(save_main_buffer, main_buffer);
16730
16731    if (pthread_attr_init(&attr) != 0) {
16732        exit(1);
16733    }
16734
16735    if (pthread_create(&subthread, &attr, thread_start, NULL) != 0) {
16736        exit(1);
16737    }
16738
16739    if (pthread_join(subthread, NULL) != 0) {
16740        exit(1);
16741    }
16742
16743    exit(! (strcmp(main_buffer, save_main_buffer) == 0));
16744}
16745EOCP
16746case "$usethreads" in
16747    define)
16748        set try
16749        if eval $compile; then
16750            echo "Your system has nl_langinfo_l()..." >&4
16751            d_nl_langinfo_l="$define"
16752            echo "$d_nl_langinfo_l" >&4
16753            if $run ./try; then
16754                echo "and it is thread-safe (just as I'd hoped)." >&4
16755                d_thread_safe_nl_langinfo_l="$define"
16756                echo "$d_thread_safe_nl_langinfo_l" >&4
16757            else
16758                echo "but it isn't thread-safe." >&4
16759            fi
16760        else
16761            echo "your system does not have nl_langinfo_l()" >&4
16762        fi
16763        ;;
16764    *) echo "Since threads aren't selected, we won't bother looking for nl_langinfo_l()" >&4
16765esac
16766if test X"$d_nl_langinfo_l" = X; then
16767	d_nl_langinfo_l="$undef"
16768fi
16769if test X"$d_thread_safe_nl_langinfo_l" = X; then
16770	d_thread_safe_nl_langinfo_l="$undef"
16771fi
16772$rm_try
16773
16774: Look for non 'int'-sized bitfields
16775case "$d_non_int_bitfields" in
16776'')
16777echo " " >&4
16778echo "Checking whether your compiler can handle struct bitfields that aren't 'int' or 'unsigned int' ..." >&4
16779$cat >try.c <<'EOCP'
16780#include <stdio.h>
16781struct foo {
16782    unsigned char byte:1;
16783    unsigned short halfword:1;
16784} bar;
16785EOCP
16786if $cc $ccflags -c try.c >try.out 2>&1 ; then
16787	if $compiler_warning try.out >/dev/null 2>&1; then
16788		echo "Your C compiler doesn't support struct bitfields that aren't 'int' or 'unsigned int'." >&4
16789		val="$undef"
16790	else
16791		echo "Your C compiler supports struct bitfields besides 'int' and 'unsigned int'." >&4
16792		val="$define"
16793	fi
16794else
16795	echo "Your C compiler doesn't seem to understand struct bitfields that aren't 'int' or 'unsigned int' at all." >&4
16796	val="$undef"
16797fi
16798;;
16799*) val="$d_non_int_bitfields" ;;
16800esac
16801set d_non_int_bitfields
16802eval $setvar
16803$rm_try
16804
16805: see if this is a quadmath.h system
16806set quadmath.h i_quadmath
16807eval $inhdr
16808
16809: Check basic sizes
16810echo " "
16811$echo "Choosing the C types to be used for Perl's internal types..." >&4
16812
16813case "$use64bitint:$d_quad:$quadtype" in
16814define:define:?*)
16815	ivtype="$quadtype"
16816	uvtype="$uquadtype"
16817	ivsize=8
16818	uvsize=8
16819	;;
16820*)	ivtype="long"
16821	uvtype="unsigned long"
16822	ivsize=$longsize
16823	uvsize=$longsize
16824	;;
16825esac
16826
16827case "$uselongdouble:$d_longdbl" in
16828define:define)
16829	nvtype="long double"
16830	nvsize=$longdblsize
16831	;;
16832*)	nvtype=double
16833	nvsize=$doublesize
16834	;;
16835esac
16836
16837case "$usequadmath:$i_quadmath" in
16838define:define)
16839  nvtype="__float128"
16840  nvsize=16
16841  case "$libs" in
16842  *quadmath*) ;;
16843  *) $cat <<EOM >&4
16844
16845*** You requested the use of the quadmath library, but you
16846*** do not seem to have the quadmath library installed.
16847*** Cannot continue, aborting.
16848EOM
16849    exit 1
16850    ;;
16851  esac
16852  ;;
16853define:*) $cat <<EOM >&4
16854
16855*** You requested the use of the quadmath library, but you
16856*** do not seem to have the required header, <quadmath.h>.
16857EOM
16858  case "$gccversion" in
16859  [23].*|4.[0-5]*)
16860   $cat <<EOM >&4
16861*** Your gcc looks a bit old:
16862*** $gccversion
16863EOM
16864    ;;
16865  '')
16866   $cat <<EOM >&4
16867*** You are not running a gcc.
16868EOM
16869    ;;
16870  esac
16871  $cat <<EOM >&4
16872*** For the quadmath library you need at least gcc 4.6.
16873*** Cannot continue, aborting.
16874EOM
16875  exit 1
16876  ;;
16877esac
16878
16879$echo "(IV will be "$ivtype", $ivsize bytes)"
16880$echo "(UV will be "$uvtype", $uvsize bytes)"
16881$echo "(NV will be "$nvtype", $nvsize bytes)"
16882
16883$cat >try.c <<EOCP
16884#$i_inttypes I_INTTYPES
16885#ifdef I_INTTYPES
16886#include <inttypes.h>
16887#endif
16888#include <stdio.h>
16889int main() {
16890#ifdef INT8
16891   int8_t i =  INT8_MAX;
16892  uint8_t u = UINT8_MAX;
16893  printf("int8_t\n");
16894#endif
16895#ifdef INT16
16896   int16_t i =  INT16_MAX;
16897  uint16_t u = UINT16_MAX;
16898  printf("int16_t\n");
16899#endif
16900#ifdef INT32
16901   int32_t i =  INT32_MAX;
16902  uint32_t u = UINT32_MAX;
16903  printf("int32_t\n");
16904#endif
16905}
16906EOCP
16907
16908i8type="signed char"
16909u8type="unsigned char"
16910i8size=1
16911u8size=1
16912
16913case "$i16type" in
16914'')	case "$shortsize" in
16915	2)	i16type=short
16916		u16type="unsigned short"
16917		i16size=$shortsize
16918		u16size=$shortsize
16919		;;
16920	esac
16921	;;
16922esac
16923case "$i16type" in
16924'')	set try -DINT16
16925	if eval $compile; then
16926		case "`$run ./try`" in
16927		int16_t)
16928			i16type=int16_t
16929			u16type=uint16_t
16930			i16size=2
16931			u16size=2
16932			;;
16933		esac
16934	fi
16935	;;
16936esac
16937case "$i16type" in
16938'')	if $test $shortsize -ge 2; then
16939		i16type=short
16940		u16type="unsigned short"
16941		i16size=$shortsize
16942		u16size=$shortsize
16943	fi
16944	;;
16945esac
16946
16947case "$i32type" in
16948'')	case "$longsize" in
16949	4)	i32type=long
16950		u32type="unsigned long"
16951		i32size=$longsize
16952		u32size=$longsize
16953		;;
16954	*)	case "$intsize" in
16955		4)	i32type=int
16956			u32type="unsigned int"
16957			i32size=$intsize
16958			u32size=$intsize
16959			;;
16960		esac
16961		;;
16962	esac
16963	;;
16964esac
16965case "$i32type" in
16966'')	set try -DINT32
16967	if eval $compile; then
16968		case "`$run ./try`" in
16969		int32_t)
16970			i32type=int32_t
16971			u32type=uint32_t
16972			i32size=4
16973			u32size=4
16974			;;
16975		esac
16976	fi
16977	;;
16978esac
16979case "$i32type" in
16980'')	if $test $intsize -ge 4; then
16981		i32type=int
16982		u32type="unsigned int"
16983		i32size=$intsize
16984		u32size=$intsize
16985	fi
16986	;;
16987esac
16988
16989case "$i64type" in
16990'')	case "$d_quad:$quadtype" in
16991	define:?*)
16992		i64type="$quadtype"
16993		u64type="$uquadtype"
16994		i64size=8
16995		u64size=8
16996		;;
16997	esac
16998	;;
16999esac
17000
17001$echo "Checking how many bits of your UVs your NVs can preserve..." >&4
17002$cat <<EOP >try.c
17003#include <stdio.h>
17004#$i_stdlib I_STDLIB
17005#ifdef I_STDLIB
17006#include <stdlib.h>
17007#endif
17008#include <sys/types.h>
17009#include <signal.h>
17010#ifdef SIGFPE
17011/* volatile so that the compiler has to store it out to memory */
17012volatile int bletched = 0;
17013$signal_t blech(int s) { bletched = 1; }
17014#endif
17015int main() {
17016    $uvtype u = 0;
17017    $nvtype d;
17018    int     n = 8 * $uvsize;
17019    int     i;
17020#ifdef SIGFPE
17021    signal(SIGFPE, blech);
17022#endif
17023
17024    for (i = 0; i < n; i++) {
17025      u = u << 1 | ($uvtype)1;
17026      d = ($nvtype)u;
17027      if (($uvtype)d != u)
17028        break;
17029      if (d <= 0)
17030	break;
17031      d = ($nvtype)(u - 1);
17032      if (($uvtype)d != (u - 1))
17033        break;
17034#ifdef SIGFPE
17035      if (bletched)
17036	break;
17037#endif
17038    }
17039    printf("%d\n", ((i == n) ? -n : i));
17040    exit(0);
17041}
17042EOP
17043set try
17044
17045d_nv_preserves_uv="$undef"
17046if eval $compile; then
17047	nv_preserves_uv_bits="`$run ./try`"
17048fi
17049case "$nv_preserves_uv_bits" in
17050\-[1-9]*)
17051	nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
17052	$echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs."  >&4
17053	d_nv_preserves_uv="$define"
17054	;;
17055[1-9]*)	$echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs."  >&4
17056	d_nv_preserves_uv="$undef" ;;
17057*)	$echo "Can't figure out how many bits your NVs preserve." >&4
17058	nv_preserves_uv_bits="0" ;;
17059esac
17060$rm_try
17061
17062$echo "Checking to find the largest integer value your NVs can hold..." >&4
17063$cat <<EOP >try.c
17064#include <stdio.h>
17065
17066typedef $nvtype NV;
17067
17068int
17069main() {
17070  NV value = 2;
17071  int count = 1;
17072
17073  while(count < 256) {
17074    /* volatile so that the compiler has to store it out to memory */
17075    volatile NV up = value + 1.0;
17076    volatile NV negated = -value;
17077    volatile NV down = negated - 1.0;
17078    volatile NV got_up = up - value;
17079    int up_good = got_up == 1.0;
17080    int got_down = down - negated;
17081    int down_good = got_down == -1.0;
17082
17083    if (down_good != up_good) {
17084      fprintf(stderr,
17085	      "Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n",
17086	      up_good, (double) got_up, down_good, (double) got_down,
17087	      count, (double) value);
17088      return 1;
17089    }
17090    if (!up_good) {
17091      while (1) {
17092	if (count > 8) {
17093	  count -= 8;
17094	  fputs("256.0", stdout);
17095	} else {
17096	  count--;
17097	  fputs("2.0", stdout);
17098	}
17099	if (!count) {
17100	  puts("");
17101	  return 0;
17102	}
17103	fputs("*", stdout);
17104      }
17105    }
17106    value *= 2;
17107    ++count;
17108  }
17109  fprintf(stderr, "Cannot overflow integer range, even at 2**%d (%.20f)\n",
17110	  count, (double) value);
17111  return 1;
17112}
17113EOP
17114set try
17115
17116nv_overflows_integers_at='0'
17117if eval $compile; then
17118    xxx="`$run ./try`"
17119    case "$?" in
17120	0)
17121	    case "$xxx" in
17122		2*)  cat >&4 <<EOM
17123The largest integer your NVs can preserve is equal to $xxx
17124EOM
17125		    nv_overflows_integers_at="$xxx"
17126		    ;;
17127		*)  cat >&4 <<EOM
17128Cannot determine the largest integer value your NVs can hold, unexpected output
17129'$xxx'
17130EOM
17131		    ;;
17132	    esac
17133	    ;;
17134	*)  cat >&4 <<EOM
17135Cannot determine the largest integer value your NVs can hold
17136EOM
17137	    ;;
17138    esac
17139fi
17140$rm_try
17141
17142$echo "Checking whether NV 0.0 is all bits zero in memory..." >&4
17143$cat <<EOP >try.c
17144#include <stdio.h>
17145#$i_stdlib I_STDLIB
17146#ifdef I_STDLIB
17147#include <stdlib.h>
17148#endif
17149#include <string.h>
17150#include <sys/types.h>
17151#include <signal.h>
17152#ifdef SIGFPE
17153/* volatile so that the compiler has to store it out to memory */
17154volatile int bletched = 0;
17155$signal_t blech(int s) { bletched = 1; }
17156#endif
17157
17158int checkit($nvtype d, const char *where) {
17159    void *v = &d;
17160    unsigned char *p = (unsigned char *)v;
17161    unsigned char *end = p + sizeof(d);
17162    int fail = 0;
17163
17164    while (p < end)
17165	fail += *p++;
17166
17167    if (!fail)
17168	return 0;
17169
17170    p = (unsigned char *)v;
17171    printf("No - %s: 0x", where);
17172    while (p < end)
17173	printf ("%02X", *p++);
17174    printf("\n");
17175    return 1;
17176}
17177
17178int main(int argc, char **argv) {
17179    $nvtype d = 0.0;
17180    int fail = 0;
17181    fail += checkit(d, "0.0");
17182
17183    /* The compiler shouldn't be assuming that bletched is 0  */
17184    d = bletched;
17185
17186    fail += checkit(d, "bleched");
17187
17188#ifdef SIGFPE
17189    signal(SIGFPE, blech);
17190#endif
17191
17192    /* Paranoia - the compiler should have no way of knowing that ANSI says
17193       that argv[argc] will always be NULL.  Actually, if it did assume this it
17194       would be buggy, as this is C and main() can be called from elsewhere in
17195       the program.  */
17196    d = argv[argc] ? 1 : 0;
17197
17198    if (d) {
17199	printf("Odd argv[argc]=%p, d=%g\n", argv[argc], d);
17200    }
17201
17202    fail += checkit(d, "ternary");
17203
17204    memset(&d, sizeof(d), argv[argc] ? 1 : 0);
17205
17206    if (d != 0.0) {
17207	printf("No - memset doesn't give 0.0\n");
17208	/* This might just blow up:  */
17209	printf("(gives %g)\n", d);
17210	return 1;
17211    }
17212
17213#ifdef SIGFPE
17214    if (bletched) {
17215	printf("No - something bleched\n");
17216	return 1;
17217    }
17218#endif
17219    if (fail) {
17220      printf("No - %d fail(s)\n", fail);
17221      return 1;
17222    }
17223    printf("Yes\n");
17224    return 0;
17225}
17226EOP
17227set try
17228
17229d_nv_zero_is_allbits_zero="$undef"
17230if eval $compile; then
17231    xxx="`$run ./try`"
17232    case "$?" in
17233	0)
17234	    case "$xxx" in
17235		Yes)  cat >&4 <<EOM
172360.0 is represented as all bits zero in memory
17237EOM
17238		    d_nv_zero_is_allbits_zero="$define"
17239		    ;;
17240		*)  cat >&4 <<EOM
172410.0 is not represented as all bits zero in memory
17242EOM
17243		    d_nv_zero_is_allbits_zero="$undef"
17244		    ;;
17245	    esac
17246	    ;;
17247	*)  cat >&4 <<EOM
172480.0 is not represented as all bits zero in memory
17249EOM
17250	    d_nv_zero_is_allbits_zero="$undef"
17251	    ;;
17252    esac
17253fi
17254$rm_try
17255
17256: check for off64_t
17257echo " "
17258echo "Checking to see if you have off64_t..." >&4
17259$cat >try.c <<EOCP
17260#include <sys/types.h>
17261#include <unistd.h>
17262int main() { off64_t x = 7; }
17263EOCP
17264set try
17265if eval $compile; then
17266	val="$define"
17267	echo "You have off64_t."
17268else
17269	val="$undef"
17270	echo "You do not have off64_t."
17271	case "$lseeksize" in
17272	8) echo "(Your off_t is 64 bits, so you could use that.)" ;;
17273	esac
17274fi
17275$rm_try
17276set d_off64_t
17277eval $setvar
17278
17279: how to create joinable pthreads
17280if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
17281	echo " "
17282	echo "Checking what constant to use for creating joinable pthreads..." >&4
17283	$cat >try.c <<'EOCP'
17284#include <pthread.h>
17285int main() {
17286    int detachstate = JOINABLE;
17287}
17288EOCP
17289	set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
17290	if eval $compile; then
17291		echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
17292		val="$undef" # Yes, undef.
17293		set d_old_pthread_create_joinable
17294		eval $setvar
17295		val=""
17296		set old_pthread_create_joinable
17297		eval $setvar
17298	else
17299		set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
17300		if eval $compile; then
17301			echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
17302			val="$define"
17303			set d_old_pthread_create_joinable
17304			eval $setvar
17305			val=PTHREAD_CREATE_UNDETACHED
17306			set old_pthread_create_joinable
17307			eval $setvar
17308		else
17309			set try -DJOINABLE=__UNDETACHED
17310			if eval $compile; then
17311				echo "You seem to use __UNDETACHED." >&4
17312				val="$define"
17313				set d_old_pthread_create_joinable
17314				eval $setvar
17315				val=__UNDETACHED
17316				set old_pthread_create_joinable
17317				eval $setvar
17318			else
17319				echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
17320				val="$define"
17321				set d_old_pthread_create_joinable
17322				eval $setvar
17323				val=0
17324				set old_pthread_create_joinable
17325				eval $setvar
17326			fi
17327		fi
17328	fi
17329	$rm_try
17330else
17331    d_old_pthread_create_joinable="$undef"
17332    old_pthread_create_joinable=""
17333fi
17334
17335: see if pause exists
17336set pause d_pause
17337eval $inlibc
17338
17339: see if pipe2 exists
17340set pipe2 d_pipe2
17341eval $inlibc
17342
17343: see if poll exists
17344set poll d_poll
17345eval $inlibc
17346
17347: see if prctl exists
17348set prctl d_prctl
17349eval $inlibc
17350
17351: see if prctl supports PR_SET_NAME
17352d_prctl_set_name=$undef
17353case $d_prctl in
17354    $define)
17355	$cat >try.c <<EOM
17356#ifdef __ANDROID__
17357#include <unistd.h>
17358#endif
17359#include <sys/prctl.h>
17360
17361int main (int argc, char *argv[])
17362{
17363    return (prctl (PR_SET_NAME, "Test"));
17364    } /* main */
17365EOM
17366	set try
17367	if eval $compile_ok && $run ./try; then
17368	    echo "Your prctl (PR_SET_NAME, ...) works"
17369	    d_prctl_set_name=$define
17370	    fi
17371	$rm_try
17372	;;
17373    esac
17374
17375: see if readlink exists
17376set readlink d_readlink
17377eval $inlibc
17378
17379: Check if there is a /proc symlink to the abs path of
17380: the executing program.  We will honor hints of d_procselfexe=$undef
17381: or procselfexe being non-empty, otherwise will try to determine both
17382: if we have readlink.
17383: AmigaOS will attempt to mount proc: aka /proc, if /proc/... is
17384: referenced, and AmigaOS does not have a proc filesystem anyway.
17385echo " "
17386val="$undef"
17387if $test "X$d_procselfexe" = Xundef; then
17388	procselfexe=''
17389elif $test "X$procselfexe" != X -a "X$procselfexe" != 'X '; then
17390	val="$define"
17391elif $test "X$d_readlink" = Xdefine; then
17392        : NetBSD first as /proc/self is a symlink to /proc/curproc,
17393        : and it feels more tidy to avoid an extra level of symlink
17394	set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
17395	while test $# -gt 0; do
17396	    type=$1; try=$2
17397	    shift; shift
17398	    if $issymlink $try; then
17399		$ls -l $try > reflect
17400		if $contains /`basename $ls` reflect >/dev/null 2>&1; then
17401		    echo "You have $type-like $try."
17402		    procselfexe='"'$try'"'
17403		    val="$define"
17404		    : This will break out of the loop
17405		    set X; shift
17406		fi
17407	    fi
17408	done
17409fi
17410$rm -f reflect
17411set d_procselfexe
17412eval $setvar
17413
17414: backward compatibility for d_hvfork
17415if test X$d_hvfork != X; then
17416	d_vfork="$d_hvfork"
17417	d_hvfork=''
17418fi
17419: see if there is a vfork
17420val=''
17421set vfork val
17422eval $inlibc
17423
17424d_pseudofork=$undef
17425
17426: Ok, but do we want to use it. vfork is reportedly unreliable in
17427: perl on Solaris 2.x, and probably elsewhere.
17428case "$val" in
17429$define)
17430	echo " "
17431	case "$usevfork" in
17432	false) dflt='n';;
17433	*) dflt='y';;
17434	esac
17435	cat <<'EOM'
17436
17437Perl can only use a vfork() that doesn't suffer from strict
17438restrictions on calling functions or modifying global data in
17439the child.  For example, glibc-2.1 contains such a vfork()
17440that is unsuitable.  If your system provides a proper fork()
17441call, chances are that you do NOT want perl to use vfork().
17442
17443EOM
17444	rp="Do you still want to use vfork()?"
17445	. ./myread
17446	case "$ans" in
17447	y|Y) ;;
17448	*)
17449		echo "Ok, we won't use vfork()."
17450		val="$undef"
17451		;;
17452	esac
17453	;;
17454esac
17455set d_vfork
17456eval $setvar
17457case "$d_vfork" in
17458$define) usevfork='true';;
17459*) usevfork='false';;
17460esac
17461
17462: see whether the pthread_atfork exists
17463$cat >try.c <<EOP
17464#include <pthread.h>
17465#include <stdio.h>
17466int main() {
17467#ifdef  PTHREAD_ATFORK
17468        pthread_atfork(NULL,NULL,NULL);
17469#endif
17470}
17471EOP
17472
17473: see if pthread_atfork exists
17474set try -DPTHREAD_ATFORK
17475if eval $compile; then
17476    val="$define"
17477else
17478    val="$undef"
17479fi
17480case "$usethreads" in
17481$define)
17482        case "$val" in
17483        $define) echo 'pthread_atfork found.' >&4        ;;
17484        *)       echo 'pthread_atfork NOT found.' >&4    ;;
17485        esac
17486esac
17487set d_pthread_atfork
17488eval $setvar
17489
17490: see if pthread_attr_setscope exists
17491set pthread_attr_setscope d_pthread_attr_setscope
17492eval $inlibc
17493
17494: see whether the various POSIXish _yields exist
17495$cat >try.c <<EOP
17496#include <pthread.h>
17497#include <stdio.h>
17498int main() {
17499#ifdef SCHED_YIELD
17500	sched_yield();
17501#else
17502#ifdef PTHREAD_YIELD
17503	pthread_yield();
17504#else
17505#ifdef PTHREAD_YIELD_NULL
17506	pthread_yield(NULL);
17507#endif
17508#endif
17509#endif
17510}
17511EOP
17512: see if sched_yield exists
17513set try -DSCHED_YIELD
17514if eval $compile; then
17515    val="$define"
17516    sched_yield='sched_yield()'
17517else
17518    val="$undef"
17519fi
17520case "$usethreads" in
17521$define)
17522	case "$val" in
17523	$define) echo 'sched_yield() found.' >&4	;;
17524	*)	 echo 'sched_yield() NOT found.' >&4	;;
17525	esac
17526esac
17527set d_sched_yield
17528eval $setvar
17529
17530: see if pthread_yield exists
17531set try -DPTHREAD_YIELD
17532if eval $compile; then
17533    val="$define"
17534    case "$sched_yield" in
17535    '') sched_yield='pthread_yield()' ;;
17536    esac
17537else
17538    set try -DPTHREAD_YIELD_NULL
17539    if eval $compile; then
17540	val="$define"
17541	case "$sched_yield" in
17542	'') sched_yield='pthread_yield(NULL)' ;;
17543	esac
17544    else
17545	val="$undef"
17546    fi
17547fi
17548case "$usethreads" in
17549$define)
17550	case "$val" in
17551	$define) echo 'pthread_yield() found.' >&4	;;
17552	*)	 echo 'pthread_yield() NOT found.' >&4	;;
17553	esac
17554	;;
17555esac
17556set d_pthread_yield
17557eval $setvar
17558case "$sched_yield" in
17559'') sched_yield=undef ;;
17560esac
17561$rm_try
17562
17563: check for ptrdiff_t
17564echo " "
17565echo "Checking to see if you have ptrdiff_t..." >&4
17566$cat >try.c <<EOCP
17567#include <stddef.h>
17568int main() { ptrdiff_t x = 7; }
17569EOCP
17570set try
17571if eval $compile; then
17572	val="$define"
17573	echo "You have ptrdiff_t."
17574else
17575	val="$undef"
17576	echo "You do not have ptrdiff_t."
17577fi
17578$rm_try
17579set d_ptrdiff_t
17580eval $setvar
17581
17582: see if random_r exists
17583set random_r d_random_r
17584eval $inlibc
17585case "$d_random_r" in
17586"$define")
17587	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
17588	case "$d_random_r_proto:$usethreads" in
17589	":define")	d_random_r_proto=define
17590		set d_random_r_proto random_r $hdrs
17591		eval $hasproto ;;
17592	*)	;;
17593	esac
17594	case "$d_random_r_proto" in
17595	define)
17596	case "$random_r_proto" in
17597	''|0) try='int random_r(int*, struct random_data*);'
17598	./protochk "$extern_C $try" $hdrs && random_r_proto=I_iS ;;
17599	esac
17600	case "$random_r_proto" in
17601	''|0) try='int random_r(long*, struct random_data*);'
17602	./protochk "$extern_C $try" $hdrs && random_r_proto=I_lS ;;
17603	esac
17604	case "$random_r_proto" in
17605	''|0) try='int random_r(struct random_data*, int32_t*);'
17606	./protochk "$extern_C $try" $hdrs && random_r_proto=I_St ;;
17607	esac
17608	case "$random_r_proto" in
17609	''|0)	d_random_r=undef
17610		random_r_proto=0
17611		echo "Disabling random_r, cannot determine prototype." >&4 ;;
17612	* )	case "$random_r_proto" in
17613		REENTRANT_PROTO*) ;;
17614		*) random_r_proto="REENTRANT_PROTO_$random_r_proto" ;;
17615		esac
17616		echo "Prototype: $try" ;;
17617	esac
17618	;;
17619	*)	case "$usethreads" in
17620		define) echo "random_r has no prototype, not using it." >&4 ;;
17621		esac
17622		d_random_r=undef
17623		random_r_proto=0
17624		;;
17625	esac
17626	;;
17627*)	random_r_proto=0
17628	;;
17629esac
17630
17631: see if readdir and friends exist
17632set readdir d_readdir
17633eval $inlibc
17634set seekdir d_seekdir
17635eval $inlibc
17636set telldir d_telldir
17637eval $inlibc
17638set rewinddir d_rewinddir
17639eval $inlibc
17640
17641: see if readdir64_r exists
17642set readdir64_r d_readdir64_r
17643eval $inlibc
17644case "$d_readdir64_r" in
17645"$define")
17646	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
17647	case "$d_readdir64_r_proto:$usethreads" in
17648	":define")	d_readdir64_r_proto=define
17649		set d_readdir64_r_proto readdir64_r $hdrs
17650		eval $hasproto ;;
17651	*)	;;
17652	esac
17653	case "$d_readdir64_r_proto" in
17654	define)
17655	case "$readdir64_r_proto" in
17656	''|0) try='int readdir64_r(DIR*, struct dirent64*, struct dirent64**);'
17657	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TSR ;;
17658	esac
17659	case "$readdir64_r_proto" in
17660	''|0) try='int readdir64_r(DIR*, struct dirent64*);'
17661	./protochk "$extern_C $try" $hdrs && readdir64_r_proto=I_TS ;;
17662	esac
17663	case "$readdir64_r_proto" in
17664	''|0)	d_readdir64_r=undef
17665		readdir64_r_proto=0
17666		echo "Disabling readdir64_r, cannot determine prototype." >&4 ;;
17667	* )	case "$readdir64_r_proto" in
17668		REENTRANT_PROTO*) ;;
17669		*) readdir64_r_proto="REENTRANT_PROTO_$readdir64_r_proto" ;;
17670		esac
17671		echo "Prototype: $try" ;;
17672	esac
17673	;;
17674	*)	case "$usethreads" in
17675		define) echo "readdir64_r has no prototype, not using it." >&4 ;;
17676		esac
17677		d_readdir64_r=undef
17678		readdir64_r_proto=0
17679		;;
17680	esac
17681	;;
17682*)	readdir64_r_proto=0
17683	;;
17684esac
17685
17686: see if readdir_r exists
17687set readdir_r d_readdir_r
17688eval $inlibc
17689case "$d_readdir_r" in
17690"$define")
17691	hdrs="$i_systypes sys/types.h define stdio.h $i_dirent dirent.h"
17692	case "$d_readdir_r_proto:$usethreads" in
17693	":define")	d_readdir_r_proto=define
17694		set d_readdir_r_proto readdir_r $hdrs
17695		eval $hasproto ;;
17696	*)	;;
17697	esac
17698	case "$d_readdir_r_proto" in
17699	define)
17700	case "$readdir_r_proto" in
17701	''|0) try='int readdir_r(DIR*, struct dirent*, struct dirent**);'
17702	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TSR ;;
17703	esac
17704	case "$readdir_r_proto" in
17705	''|0) try='int readdir_r(DIR*, struct dirent*);'
17706	./protochk "$extern_C $try" $hdrs && readdir_r_proto=I_TS ;;
17707	esac
17708	case "$readdir_r_proto" in
17709	''|0)	d_readdir_r=undef
17710		readdir_r_proto=0
17711		echo "Disabling readdir_r, cannot determine prototype." >&4 ;;
17712	* )	case "$readdir_r_proto" in
17713		REENTRANT_PROTO*) ;;
17714		*) readdir_r_proto="REENTRANT_PROTO_$readdir_r_proto" ;;
17715		esac
17716		echo "Prototype: $try" ;;
17717	esac
17718	;;
17719	*)	case "$usethreads" in
17720		define) echo "readdir_r has no prototype, not using it." >&4 ;;
17721		esac
17722		d_readdir_r=undef
17723		readdir_r_proto=0
17724		;;
17725	esac
17726	;;
17727*)	readdir_r_proto=0
17728	;;
17729esac
17730
17731: see if readv exists
17732set readv d_readv
17733eval $inlibc
17734
17735: see if recvmsg exists
17736set recvmsg d_recvmsg
17737eval $inlibc
17738
17739: see if regcomp, regcmp, or re_comp exist, for regular pattern matching
17740echo " "
17741if set regcomp val -f d_regcomp; eval $csym; $val; then
17742	echo 'regcomp() found.' >&4
17743	d_regcomp="$define"
17744	d_regcmp="$undef"
17745	d_re_comp="$undef"
17746elif set regcmp val -f d_regcmp; eval $csym; $val; then
17747	echo 'regcmp() found.' >&4
17748	d_regcmp="$define"
17749	d_regcomp="$undef"
17750	d_re_comp="$undef"
17751elif set re_comp val -f d_re_comp; eval $csym; $val; then
17752	echo 're_comp() found, assuming re_exec() also exists.' >&4
17753	d_re_comp="$define"
17754	d_regcomp="$undef"
17755	d_regcmp="$undef"
17756else
17757	$cat >&4 <<EOM
17758No regcomp(), regcmp() nor re_comp() found !! No regular pattern matching.
17759EOM
17760	d_regcmp="$undef"
17761	d_re_comp="$undef"
17762	d_regcomp="$undef"
17763fi
17764
17765: see if remainder exists
17766set remainder d_remainder
17767eval $inlibc
17768
17769: see if remquo exists
17770set remquo d_remquo
17771eval $inlibc
17772
17773: see if rename exists
17774set rename d_rename
17775eval $inlibc
17776
17777: see if rint exists
17778set rint d_rint
17779eval $inlibc
17780
17781: see if rmdir exists
17782set rmdir d_rmdir
17783eval $inlibc
17784
17785: see if round exists
17786set round d_round
17787eval $inlibc
17788
17789: see if prototype for sbrk is available
17790echo " "
17791set d_sbrkproto sbrk $i_unistd unistd.h
17792eval $hasproto
17793
17794: see if scalbn exists
17795set scalbn d_scalbn
17796eval $inlibc
17797
17798: see if select exists
17799set select d_select
17800eval $inlibc
17801
17802: see if semctl exists
17803set semctl d_semctl
17804eval $inlibc
17805
17806: see if semget exists
17807set semget d_semget
17808eval $inlibc
17809
17810: see if semop exists
17811set semop d_semop
17812eval $inlibc
17813
17814: see how much of the 'sem*(2)' library is present.
17815h_sem=true
17816echo " "
17817case "$d_semctl$d_semget$d_semop" in
17818*"$undef"*) h_sem=false;;
17819esac
17820case "$osname" in
17821freebsd)
17822    case "`ipcs 2>&1`" in
17823    "SVID messages"*"not configured"*)
17824	echo "Your $osname does not have the sem*(2) configured." >&4
17825        h_sem=false
17826	val="$undef"
17827	set semctl d_semctl
17828	eval $setvar
17829	set semget d_semget
17830	eval $setvar
17831	set semop d_semop
17832	eval $setvar
17833	;;
17834    esac
17835    ;;
17836esac
17837: we could also check for sys/ipc.h ...
17838if $h_sem && $test `./findhdr sys/sem.h`; then
17839	echo "You have the full sem*(2) library." >&4
17840	val="$define"
17841else
17842	echo "You don't have the full sem*(2) library." >&4
17843	val="$undef"
17844fi
17845set d_sem
17846eval $setvar
17847
17848: see whether sys/sem.h defines union semun
17849echo " "
17850$cat > try.c <<'END'
17851#include <sys/types.h>
17852#include <sys/ipc.h>
17853#include <sys/sem.h>
17854int main () { union semun semun; semun.buf = 0; }
17855END
17856set try
17857if eval $compile; then
17858    echo "You have union semun in <sys/sem.h>." >&4
17859    val="$define"
17860else
17861    echo "You do not have union semun in <sys/sem.h>." >&4
17862    val="$undef"
17863fi
17864$rm_try
17865set d_union_semun
17866eval $setvar
17867
17868: see how to do semctl IPC_STAT
17869case "$d_sem" in
17870$define)
17871    echo " "
17872    $cat > tryh.h <<END
17873#ifndef S_IRUSR
17874#   ifdef S_IREAD
17875#	define S_IRUSR S_IREAD
17876#	define S_IWUSR S_IWRITE
17877#	define S_IXUSR S_IEXEC
17878#   else
17879#	define S_IRUSR 0400
17880#	define S_IWUSR 0200
17881#	define S_IXUSR 0100
17882#   endif
17883#   define S_IRGRP (S_IRUSR>>3)
17884#   define S_IWGRP (S_IWUSR>>3)
17885#   define S_IXGRP (S_IXUSR>>3)
17886#   define S_IROTH (S_IRUSR>>6)
17887#   define S_IWOTH (S_IWUSR>>6)
17888#   define S_IXOTH (S_IXUSR>>6)
17889#endif
17890#ifndef S_IRWXU
17891#   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
17892#   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
17893#   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
17894#endif
17895END
17896    : see whether semctl IPC_STAT can use union semun
17897    case "$d_semctl_semun" in
17898    '')
17899      val="$undef"
17900      $cat > try.c <<END
17901#include <sys/types.h>
17902#include <sys/ipc.h>
17903#include <sys/sem.h>
17904#include <sys/stat.h>
17905#include <stdio.h>
17906#include <errno.h>
17907#include "tryh.h"
17908#ifndef errno
17909extern int errno;
17910#endif
17911#$d_union_semun HAS_UNION_SEMUN
17912int main() {
17913    union semun
17914#ifndef HAS_UNION_SEMUN
17915    {
17916	int val;
17917	struct semid_ds *buf;
17918	unsigned short *array;
17919    }
17920#endif
17921    arg;
17922    int sem, st;
17923
17924#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
17925    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17926    if (sem > -1) {
17927	struct semid_ds argbuf;
17928	arg.buf = &argbuf;
17929#	ifdef IPC_STAT
17930	st = semctl(sem, 0, IPC_STAT, arg);
17931	if (st == 0)
17932	    printf("semun\n");
17933	else
17934#	endif /* IPC_STAT */
17935	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
17936#	ifdef IPC_RMID
17937	if (semctl(sem, 0, IPC_RMID, arg) != 0)
17938#	endif /* IPC_RMID */
17939	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
17940    } else
17941#endif /* IPC_PRIVATE && ... */
17942	printf("semget failed: errno = %d\n", errno);
17943  return 0;
17944}
17945END
17946      set try
17947      if eval $compile; then
17948	  xxx=`$run ./try`
17949          case "$xxx" in
17950          semun) val="$define" ;;
17951          esac
17952      fi
17953      $rm_try
17954      set d_semctl_semun
17955      eval $setvar
17956      ;;
17957    esac
17958    case "$d_semctl_semun" in
17959    $define)
17960        echo "You can use union semun for semctl IPC_STAT." >&4
17961	also='also'
17962        ;;
17963    *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
17964	also=''
17965        ;;
17966    esac
17967
17968    : see whether semctl IPC_STAT can use struct semid_ds pointer
17969    case "$d_semctl_semid_ds" in
17970    '')
17971      val="$undef"
17972      $cat > try.c <<'END'
17973#include <sys/types.h>
17974#include <sys/ipc.h>
17975#include <sys/sem.h>
17976#include <sys/stat.h>
17977#include "tryh.h"
17978#include <stdio.h>
17979#include <errno.h>
17980#ifndef errno
17981extern int errno;
17982#endif
17983int main() {
17984    union semun
17985#ifndef HAS_UNION_SEMUN
17986    {
17987	int val;
17988	struct semid_ds *buf;
17989	unsigned short *array;
17990    }
17991#endif
17992    arg;
17993    struct semid_ds argbuf;
17994    int sem, st;
17995
17996#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
17997    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
17998    if (sem > -1) {
17999	arg.buf = &argbuf;
18000#	ifdef IPC_STAT
18001	st = semctl(sem, 0, IPC_STAT, arg);
18002	if (st == 0)
18003	    printf("semid_ds\n");
18004	else
18005#	endif /* IPC_STAT */
18006	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
18007#	ifdef IPC_RMID
18008	if (semctl(sem, 0, IPC_RMID, arg) != 0)
18009#	endif /* IPC_RMID */
18010	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
18011    } else
18012#endif /* IPC_PRIVATE && ... */
18013	printf("semget failed: errno = %d\n", errno);
18014
18015    return 0;
18016}
18017END
18018      set try
18019      if eval $compile; then
18020          xxx=`$run ./try`
18021          case "$xxx" in
18022          semid_ds) val="$define" ;;
18023          esac
18024      fi
18025      $rm_try
18026      set d_semctl_semid_ds
18027      eval $setvar
18028      ;;
18029    esac
18030    case "$d_semctl_semid_ds" in
18031    $define)
18032        echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
18033        ;;
18034    *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
18035        ;;
18036    esac
18037    ;;
18038*)  val="$undef"
18039
18040    # We do not have the full sem*(2) library, so assume we can not
18041    # use either.
18042
18043    set d_semctl_semun
18044    eval $setvar
18045
18046    set d_semctl_semid_ds
18047    eval $setvar
18048    ;;
18049esac
18050$rm_try tryh.h
18051
18052: see if sendmsg exists
18053set sendmsg d_sendmsg
18054eval $inlibc
18055
18056: see if setegid exists
18057set setegid d_setegid
18058eval $inlibc
18059
18060: see if seteuid exists
18061set seteuid d_seteuid
18062eval $inlibc
18063
18064: see if setgrent exists
18065set setgrent d_setgrent
18066eval $inlibc
18067
18068: see if setgrent_r exists
18069set setgrent_r d_setgrent_r
18070eval $inlibc
18071case "$d_setgrent_r" in
18072"$define")
18073	hdrs="$i_systypes sys/types.h define stdio.h $i_grp grp.h"
18074	case "$d_setgrent_r_proto:$usethreads" in
18075	":define")	d_setgrent_r_proto=define
18076		set d_setgrent_r_proto setgrent_r $hdrs
18077		eval $hasproto ;;
18078	*)	;;
18079	esac
18080	case "$d_setgrent_r_proto" in
18081	define)
18082	case "$setgrent_r_proto" in
18083	''|0) try='int setgrent_r(FILE**);'
18084	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=I_H ;;
18085	esac
18086	case "$setgrent_r_proto" in
18087	''|0) try='void setgrent_r(FILE**);'
18088	./protochk "$extern_C $try" $hdrs && setgrent_r_proto=V_H ;;
18089	esac
18090	case "$setgrent_r_proto" in
18091	''|0)	d_setgrent_r=undef
18092		setgrent_r_proto=0
18093		echo "Disabling setgrent_r, cannot determine prototype." >&4 ;;
18094	* )	case "$setgrent_r_proto" in
18095		REENTRANT_PROTO*) ;;
18096		*) setgrent_r_proto="REENTRANT_PROTO_$setgrent_r_proto" ;;
18097		esac
18098		echo "Prototype: $try" ;;
18099	esac
18100	;;
18101	*)	case "$usethreads" in
18102		define) echo "setgrent_r has no prototype, not using it." >&4 ;;
18103		esac
18104		d_setgrent_r=undef
18105		setgrent_r_proto=0
18106		;;
18107	esac
18108	;;
18109*)	setgrent_r_proto=0
18110	;;
18111esac
18112
18113: see if sethostent exists
18114set sethostent d_sethent
18115eval $inlibc
18116
18117: see if sethostent_r exists
18118set sethostent_r d_sethostent_r
18119eval $inlibc
18120case "$d_sethostent_r" in
18121"$define")
18122	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18123	case "$d_sethostent_r_proto:$usethreads" in
18124	":define")	d_sethostent_r_proto=define
18125		set d_sethostent_r_proto sethostent_r $hdrs
18126		eval $hasproto ;;
18127	*)	;;
18128	esac
18129	case "$d_sethostent_r_proto" in
18130	define)
18131	case "$sethostent_r_proto" in
18132	''|0) try='int sethostent_r(int, struct hostent_data*);'
18133	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=I_ID ;;
18134	esac
18135	case "$sethostent_r_proto" in
18136	''|0) try='void sethostent_r(int, struct hostent_data*);'
18137	./protochk "$extern_C $try" $hdrs && sethostent_r_proto=V_ID ;;
18138	esac
18139	case "$sethostent_r_proto" in
18140	''|0)	d_sethostent_r=undef
18141		sethostent_r_proto=0
18142		echo "Disabling sethostent_r, cannot determine prototype." >&4 ;;
18143	* )	case "$sethostent_r_proto" in
18144		REENTRANT_PROTO*) ;;
18145		*) sethostent_r_proto="REENTRANT_PROTO_$sethostent_r_proto" ;;
18146		esac
18147		echo "Prototype: $try" ;;
18148	esac
18149	;;
18150	*)	case "$usethreads" in
18151		define) echo "sethostent_r has no prototype, not using it." >&4 ;;
18152		esac
18153		d_sethostent_r=undef
18154		sethostent_r_proto=0
18155		;;
18156	esac
18157	;;
18158*)	sethostent_r_proto=0
18159	;;
18160esac
18161
18162: see if setitimer exists
18163set setitimer d_setitimer
18164eval $inlibc
18165
18166: see if setlinebuf exists
18167set setlinebuf d_setlinebuf
18168eval $inlibc
18169
18170: see if this system has wctype.h
18171set wctype.h i_wctype
18172eval $inhdr
18173
18174: see if towupper exists
18175set towupper d_towupper
18176eval $inlibc
18177
18178: check for setlocale function and behavior
18179case "$d_setlocale" in
18180'')
18181$cat >&4 <<EOM
18182
18183Checking to see if you have setlocale() and its behavior
18184EOM
18185$cat >try.c <<EOCP
18186#include <stdlib.h>
18187#include <string.h>
18188#$i_locale I_LOCALE
18189#ifdef I_LOCALE
18190#  include <locale.h>
18191#endif
18192#$i_wctype I_WCTYPE
18193#ifdef I_WCTYPE
18194#  include <wctype.h>
18195#endif
18196
18197int main() {
18198    const char * invalid_name = "\a";   /* This is really invalid! */
18199    int accepts_any_locale_name = 0;
18200    int has_C_UTF8 = 0;
18201    unsigned char bad_setlocale = 255;
18202
18203    /* If LC_CTYPE isn't defined the compilation will fail, and locales will be
18204     * disabled.  It's hard to imagine an instance where meaningful locale
18205     * handling could be done without LC_CTYPE */
18206    const char *  name = setlocale(LC_CTYPE, "C");
18207
18208    if (name == NULL || strcmp(name, "C") != 0) {
18209        exit(bad_setlocale);
18210    }
18211
18212    name = setlocale(LC_CTYPE, invalid_name);
18213    if (name != NULL) {
18214
18215        /* Let it pass if it accepts the name but gives back one of the C
18216         * locales */
18217        if (strcmp(name, "C") != 0 && strcmp(name, "C.UTF-8") != 0) {
18218            accepts_any_locale_name = 1;
18219        }
18220    }
18221
18222    name = setlocale(LC_CTYPE, "C.UTF-8");
18223    if (name != NULL) {
18224        unsigned char y_with_diaeresis = ('A' == 193) ? 0xDF : 0xFF;
18225
18226#$d_towupper HAS_TOWUPPER
18227#ifdef HAS_TOWUPPER
18228
18229        /* We assume that if the machine doesn't have the C99 towupper, it
18230         * doesn't have C.UTF-8, even if we successfully changed locales to
18231         * include it.  This seems safer even on platforms that didn't accept
18232         * the really invalid name */
18233
18234        if (towupper(y_with_diaeresis) == 0x178) {
18235            has_C_UTF8 = 1;
18236        }
18237
18238#endif
18239
18240    }
18241
18242#if 0
18243
18244    /* Currently unused code to determine if LC_ALL with disparate values uses
18245     * category = value pairs or positional, and to determine the separator
18246     * between the categories.  We could add code so that if the separator were
18247     * > '9', we subtract 10; similarly for 'Z' and 'z', and then just about
18248     * every possible ASCII separator would fit in the 5 bits available in the
18249     * exit code.  This would not be true in EBCDIC.  And then if LC_ALL is
18250     * positional, we probably would want to know the order of the categories.
18251     * Using a file between the C program and the shell script would really be
18252     * require to do that */
18253#ifdef LC_ALL
18254
18255    unsigned char min_separator = ' ' - 1;
18256    unsigned char separator = min_separator;
18257    int uses_name_value_pair_names = 0;
18258
18259    name = setlocale(LC_ALL, "C");
18260    if (name == NULL || strcmp(name, "C") != 0) {
18261        exit(bad_setlocale);
18262    }
18263
18264    if (has_C_UTF8) {
18265        char * pos;
18266
18267        name = setlocale(LC_CTYPE, "C.UTF-8");
18268        if (name == NULL) {
18269            exit(bad_setlocale);
18270        }
18271        name = setlocale(LC_ALL, NULL);
18272        if (name == NULL) {
18273            exit(bad_setlocale);
18274        }
18275
18276        pos = strstr(name, "LC_CTYPE" "=C.UTF-8");
18277        if (pos != NULL) {
18278            uses_name_value_pair_names = 1;
18279            if (pos == name) {
18280                separator = name[sizeof("LC_CTYPE=C.UTF-8") - 1];
18281            }
18282            else {
18283                separator = *(pos - 1);
18284            }
18285        }
18286        else {
18287            pos = strstr(name, "C.UTF-8");
18288            if (pos == NULL) {
18289                /* bad */
18290            }
18291            else if (pos == name) {
18292                separator = name[sizeof("C.UTF-8") - 1];
18293            }
18294            else {
18295                separator = *(pos - 1);
18296            }
18297        }
18298    }
18299
18300#endif
18301#endif
18302
18303    exit( 0 /* (separator - min_separator) << 3
18304        | uses_name_value_pair_names      << 2
18305          */
18306        | has_C_UTF8                      << 1
18307        | accepts_any_locale_name);
18308
18309}
18310EOCP
18311val=
18312set d_setlocale
18313eval $setvar
18314case $d_setlocale in
18315    $undef) d_setlocale_accepts_any_locale_name="$undef"
18316            d_has_C_UTF8="false"
18317            ;;
18318    *) set try
18319       if eval $compile; then
18320           echo "Your system has setlocale()..." >&4
18321           $run ./try
18322           case $? in
18323               0) echo "and it seems sane; you don't have a C.UTF-8 locale" >&4
18324                  d_setlocale="$define"
18325                  d_setlocale_accepts_any_locale_name="$undef"
18326                  d_has_C_UTF8="false"
18327                  ;;
18328               1) echo "and it seems sane, but accepts any locale name as valid" >&4
18329                  d_setlocale="$define"
18330                  d_setlocale_accepts_any_locale_name="$define"
18331                  d_has_C_UTF8="false"
18332                  ;;
18333               2) echo "and it seems sane; you have a C.UTF-8 locale" >&4
18334                  d_setlocale="$define"
18335                  d_setlocale_accepts_any_locale_name="$undef"
18336                  d_has_C_UTF8="true"
18337                  ;;
18338               3) echo "and it seems sane, but accepts any locale name as valid" >&4
18339                  d_setlocale="$define"
18340                  d_setlocale_accepts_any_locale_name="$define"
18341                  d_has_C_UTF8="true"
18342                  ;;
18343               *) echo "but it doesn't seem to work, so we won't use it." >&4
18344                  d_setlocale="$undef"
18345                  d_setlocale_accepts_any_locale_name="$undef"
18346                  d_has_C_UTF8="false"
18347                  ;;
18348           esac
18349       else
18350           echo "your system does not have setlocale()" >&4
18351           d_setlocale="$undef"
18352           d_setlocale_accepts_any_locale_name="$undef"
18353           d_has_C_UTF8="false"
18354       fi
18355esac
18356$rm_try
18357;;
18358*) val="$d_setlocale"
18359    set d_setlocale
18360    eval $setvar
18361    case "$d_setlocale" in
18362        $undef) echo "There may be other ways to set the locale on your system, so we need to ask:" >&4
18363        ;;
18364    esac
18365    rp="Does your system have the C.UTF-8 locale?"
18366    dflt=n
18367    . ./myread
18368    case "$ans" in
18369        [Yy]*) d_has_C_UTF8="true"
18370               c_utf8_locale=" or C.UTF-8"
18371               ;;
18372        *)     d_has_C_UTF8="false"
18373               c_utf8_locale=""
18374               ;;
18375    esac
18376    case "$d_setlocale" in
18377        $define)
18378            rp="When you set your locale to something besides C$c_utf8_locale, does it do so, or just pretend to?" >&4
18379            dflt=n
18380            . ./myread
18381            case "$ans" in
18382                true|[Yy]*)
18383		   d_setlocale_accepts_any_locale_name="$undef"
18384		   ;;
18385		*) d_setlocale_accepts_any_locale_name="$define"
18386		   ;;
18387            esac
18388            ;;
18389        *) d_setlocale_accepts_any_locale_name="$undef"
18390	   ;;
18391    esac
18392esac
18393
18394: see if setlocale_r exists
18395set setlocale_r d_setlocale_r
18396eval $inlibc
18397case "$d_setlocale_r" in
18398"$define")
18399	hdrs="$i_systypes sys/types.h define stdio.h $i_locale locale.h"
18400	case "$d_setlocale_r_proto:$usethreads" in
18401	":define")	d_setlocale_r_proto=define
18402		set d_setlocale_r_proto setlocale_r $hdrs
18403		eval $hasproto ;;
18404	*)	;;
18405	esac
18406	case "$d_setlocale_r_proto" in
18407	define)
18408	case "$setlocale_r_proto" in
18409	''|0) try='int setlocale_r(int, const char*, char*, int);'
18410	./protochk "$extern_C $try" $hdrs && setlocale_r_proto=I_ICBI ;;
18411	esac
18412	case "$setlocale_r_proto" in
18413	''|0)	d_setlocale_r=undef
18414		setlocale_r_proto=0
18415		echo "Disabling setlocale_r, cannot determine prototype." >&4 ;;
18416	* )	case "$setlocale_r_proto" in
18417		REENTRANT_PROTO*) ;;
18418		*) setlocale_r_proto="REENTRANT_PROTO_$setlocale_r_proto" ;;
18419		esac
18420		echo "Prototype: $try" ;;
18421	esac
18422	;;
18423	*)	case "$usethreads" in
18424		define) echo "setlocale_r has no prototype, not using it." >&4 ;;
18425		esac
18426		d_setlocale_r=undef
18427		setlocale_r_proto=0
18428		;;
18429	esac
18430	;;
18431*)	setlocale_r_proto=0
18432	;;
18433esac
18434
18435: see if setnetent exists
18436set setnetent d_setnent
18437eval $inlibc
18438
18439: see if setnetent_r exists
18440set setnetent_r d_setnetent_r
18441eval $inlibc
18442case "$d_setnetent_r" in
18443"$define")
18444	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18445	case "$d_setnetent_r_proto:$usethreads" in
18446	":define")	d_setnetent_r_proto=define
18447		set d_setnetent_r_proto setnetent_r $hdrs
18448		eval $hasproto ;;
18449	*)	;;
18450	esac
18451	case "$d_setnetent_r_proto" in
18452	define)
18453	case "$setnetent_r_proto" in
18454	''|0) try='int setnetent_r(int, struct netent_data*);'
18455	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=I_ID ;;
18456	esac
18457	case "$setnetent_r_proto" in
18458	''|0) try='void setnetent_r(int, struct netent_data*);'
18459	./protochk "$extern_C $try" $hdrs && setnetent_r_proto=V_ID ;;
18460	esac
18461	case "$setnetent_r_proto" in
18462	''|0)	d_setnetent_r=undef
18463		setnetent_r_proto=0
18464		echo "Disabling setnetent_r, cannot determine prototype." >&4 ;;
18465	* )	case "$setnetent_r_proto" in
18466		REENTRANT_PROTO*) ;;
18467		*) setnetent_r_proto="REENTRANT_PROTO_$setnetent_r_proto" ;;
18468		esac
18469		echo "Prototype: $try" ;;
18470	esac
18471	;;
18472	*)	case "$usethreads" in
18473		define) echo "setnetent_r has no prototype, not using it." >&4 ;;
18474		esac
18475		d_setnetent_r=undef
18476		setnetent_r_proto=0
18477		;;
18478	esac
18479	;;
18480*)	setnetent_r_proto=0
18481	;;
18482esac
18483
18484: see if setprotoent exists
18485set setprotoent d_setpent
18486eval $inlibc
18487
18488: see if setpgid exists
18489set setpgid d_setpgid
18490eval $inlibc
18491
18492: see if setpgrp2 exists
18493set setpgrp2 d_setpgrp2
18494eval $inlibc
18495
18496: see if setpriority exists
18497set setpriority d_setprior
18498eval $inlibc
18499
18500: see if setproctitle exists
18501set setproctitle d_setproctitle
18502eval $inlibc
18503
18504: see if setprotoent_r exists
18505set setprotoent_r d_setprotoent_r
18506eval $inlibc
18507case "$d_setprotoent_r" in
18508"$define")
18509	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18510	case "$d_setprotoent_r_proto:$usethreads" in
18511	":define")	d_setprotoent_r_proto=define
18512		set d_setprotoent_r_proto setprotoent_r $hdrs
18513		eval $hasproto ;;
18514	*)	;;
18515	esac
18516	case "$d_setprotoent_r_proto" in
18517	define)
18518	case "$setprotoent_r_proto" in
18519	''|0) try='int setprotoent_r(int, struct protoent_data*);'
18520	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=I_ID ;;
18521	esac
18522	case "$setprotoent_r_proto" in
18523	''|0) try='void setprotoent_r(int, struct protoent_data*);'
18524	./protochk "$extern_C $try" $hdrs && setprotoent_r_proto=V_ID ;;
18525	esac
18526	case "$setprotoent_r_proto" in
18527	''|0)	d_setprotoent_r=undef
18528		setprotoent_r_proto=0
18529		echo "Disabling setprotoent_r, cannot determine prototype." >&4 ;;
18530	* )	case "$setprotoent_r_proto" in
18531		REENTRANT_PROTO*) ;;
18532		*) setprotoent_r_proto="REENTRANT_PROTO_$setprotoent_r_proto" ;;
18533		esac
18534		echo "Prototype: $try" ;;
18535	esac
18536	;;
18537	*)	case "$usethreads" in
18538		define) echo "setprotoent_r has no prototype, not using it." >&4 ;;
18539		esac
18540		d_setprotoent_r=undef
18541		setprotoent_r_proto=0
18542		;;
18543	esac
18544	;;
18545*)	setprotoent_r_proto=0
18546	;;
18547esac
18548
18549: see if setpwent exists
18550set setpwent d_setpwent
18551eval $inlibc
18552
18553: see if setpwent_r exists
18554set setpwent_r d_setpwent_r
18555eval $inlibc
18556case "$d_setpwent_r" in
18557"$define")
18558	hdrs="$i_systypes sys/types.h define stdio.h $i_pwd pwd.h"
18559	case "$d_setpwent_r_proto:$usethreads" in
18560	":define")	d_setpwent_r_proto=define
18561		set d_setpwent_r_proto setpwent_r $hdrs
18562		eval $hasproto ;;
18563	*)	;;
18564	esac
18565	case "$d_setpwent_r_proto" in
18566	define)
18567	case "$setpwent_r_proto" in
18568	''|0) try='int setpwent_r(FILE**);'
18569	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=I_H ;;
18570	esac
18571	case "$setpwent_r_proto" in
18572	''|0) try='void setpwent_r(FILE**);'
18573	./protochk "$extern_C $try" $hdrs && setpwent_r_proto=V_H ;;
18574	esac
18575	case "$setpwent_r_proto" in
18576	''|0)	d_setpwent_r=undef
18577		setpwent_r_proto=0
18578		echo "Disabling setpwent_r, cannot determine prototype." >&4 ;;
18579	* )	case "$setpwent_r_proto" in
18580		REENTRANT_PROTO*) ;;
18581		*) setpwent_r_proto="REENTRANT_PROTO_$setpwent_r_proto" ;;
18582		esac
18583		echo "Prototype: $try" ;;
18584	esac
18585	;;
18586	*)	case "$usethreads" in
18587		define) echo "setpwent_r has no prototype, not using it." >&4 ;;
18588		esac
18589		d_setpwent_r=undef
18590		setpwent_r_proto=0
18591		;;
18592	esac
18593	;;
18594*)	setpwent_r_proto=0
18595	;;
18596esac
18597
18598: see if setregid exists
18599set setregid d_setregid
18600eval $inlibc
18601set setresgid d_setresgid
18602eval $inlibc
18603
18604: see if setreuid exists
18605set setreuid d_setreuid
18606eval $inlibc
18607set setresuid d_setresuid
18608eval $inlibc
18609
18610: see if setrgid exists
18611set setrgid d_setrgid
18612eval $inlibc
18613
18614: see if setruid exists
18615set setruid d_setruid
18616eval $inlibc
18617
18618: see if setservent exists
18619set setservent d_setsent
18620eval $inlibc
18621
18622: see if setservent_r exists
18623set setservent_r d_setservent_r
18624eval $inlibc
18625case "$d_setservent_r" in
18626"$define")
18627	hdrs="$i_systypes sys/types.h define stdio.h $i_netdb netdb.h"
18628	case "$d_setservent_r_proto:$usethreads" in
18629	":define")	d_setservent_r_proto=define
18630		set d_setservent_r_proto setservent_r $hdrs
18631		eval $hasproto ;;
18632	*)	;;
18633	esac
18634	case "$d_setservent_r_proto" in
18635	define)
18636	case "$setservent_r_proto" in
18637	''|0) try='int setservent_r(int, struct servent_data*);'
18638	./protochk "$extern_C $try" $hdrs && setservent_r_proto=I_ID ;;
18639	esac
18640	case "$setservent_r_proto" in
18641	''|0) try='void setservent_r(int, struct servent_data*);'
18642	./protochk "$extern_C $try" $hdrs && setservent_r_proto=V_ID ;;
18643	esac
18644	case "$setservent_r_proto" in
18645	''|0)	d_setservent_r=undef
18646		setservent_r_proto=0
18647		echo "Disabling setservent_r, cannot determine prototype." >&4 ;;
18648	* )	case "$setservent_r_proto" in
18649		REENTRANT_PROTO*) ;;
18650		*) setservent_r_proto="REENTRANT_PROTO_$setservent_r_proto" ;;
18651		esac
18652		echo "Prototype: $try" ;;
18653	esac
18654	;;
18655	*)	case "$usethreads" in
18656		define) echo "setservent_r has no prototype, not using it." >&4 ;;
18657		esac
18658		d_setservent_r=undef
18659		setservent_r_proto=0
18660		;;
18661	esac
18662	;;
18663*)	setservent_r_proto=0
18664	;;
18665esac
18666
18667: see if setsid exists
18668set setsid d_setsid
18669eval $inlibc
18670
18671: see if setvbuf exists
18672set setvbuf d_setvbuf
18673eval $inlibc
18674
18675: see if shmctl exists
18676set shmctl d_shmctl
18677eval $inlibc
18678
18679: see if shmget exists
18680set shmget d_shmget
18681eval $inlibc
18682
18683: see if shmat exists
18684set shmat d_shmat
18685eval $inlibc
18686: see what shmat returns
18687case "$d_shmat" in
18688"$define")
18689	$cat >shmat.c <<'END'
18690#include <sys/shm.h>
18691void *shmat();
18692END
18693	if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
18694		shmattype='void *'
18695	else
18696		shmattype='char *'
18697	fi
18698	echo "and it returns ($shmattype)." >&4
18699	: see if a prototype for shmat is available
18700	xxx=`./findhdr sys/shm.h`
18701	$cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
18702	if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
18703		val="$define"
18704	else
18705		val="$undef"
18706	fi
18707	$rm -f shmat.[co]
18708	;;
18709*)
18710	val="$undef"
18711	;;
18712esac
18713set d_shmatprototype
18714eval $setvar
18715
18716: see if shmdt exists
18717set shmdt d_shmdt
18718eval $inlibc
18719
18720: see how much of the 'shm*(2)' library is present.
18721h_shm=true
18722echo " "
18723case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
18724*"$undef"*) h_shm=false;;
18725esac
18726case "$osname" in
18727freebsd)
18728    case "`ipcs 2>&1`" in
18729    "SVID shared memory"*"not configured"*)
18730	echo "Your $osname does not have the shm*(2) configured." >&4
18731        h_shm=false
18732	val="$undef"
18733	set shmctl d_shmctl
18734	eval $setvar
18735	set shmget d_shmget
18736	eval $setvar
18737	set shmat d_shmat
18738	eval $setvar
18739	set shmdt d_shmdt
18740	eval $setvar
18741	;;
18742    esac
18743    ;;
18744esac
18745: we could also check for sys/ipc.h ...
18746if $h_shm && $test `./findhdr sys/shm.h`; then
18747	echo "You have the full shm*(2) library." >&4
18748	val="$define"
18749else
18750	echo "You don't have the full shm*(2) library." >&4
18751	val="$undef"
18752fi
18753set d_shm
18754eval $setvar
18755
18756: see if we have sigaction
18757echo " "
18758if set sigaction val -f d_sigaction; eval $csym; $val; then
18759	echo 'sigaction() found.' >&4
18760	$cat > try.c <<EOP
18761#include <stdio.h>
18762#include <sys/types.h>
18763#include <signal.h>
18764#$i_stdlib I_STDLIB
18765#ifdef I_STDLIB
18766#include <stdlib.h>
18767#endif
18768int main()
18769{
18770    struct sigaction act, oact;
18771    act.sa_flags = 0;
18772    oact.sa_handler = 0;
18773    /* so that act and oact are used */
18774    exit(act.sa_flags == 0 &&  oact.sa_handler == 0);
18775}
18776EOP
18777	set try
18778	if eval $compile_ok; then
18779		val="$define"
18780	else
18781		echo "But you don't seem to have a usable struct sigaction." >&4
18782		val="$undef"
18783	fi
18784else
18785	echo 'sigaction NOT found.' >&4
18786	val="$undef"
18787fi
18788set d_sigaction; eval $setvar
18789$rm_try
18790
18791: see what type pids are declared as in the kernel
18792rp="What is the type of process ids on this system?"
18793set pid_t pidtype int stdio.h sys/types.h
18794eval $typedef_ask
18795
18796: see what type uids are declared as in the kernel
18797echo " "
18798echo "Looking for the type for user ids returned by getuid()."
18799set uid_t uidtype xxx stdio.h sys/types.h
18800eval $typedef
18801case "$uidtype" in
18802xxx)
18803	xxx=`./findhdr sys/user.h`
18804	set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
18805	case $1 in
18806	unsigned) dflt="$1 $2" ;;
18807	*) dflt="$1" ;;
18808	esac
18809	;;
18810*) dflt="$uidtype";;
18811esac
18812case "$uidtype" in
18813uid_t)	echo "uid_t found." ;;
18814*)	rp="What is the type for user ids returned by getuid()?"
18815	. ./myread
18816	uidtype="$ans"
18817	;;
18818esac
18819
18820: Define hasfield_t macro for Configure internal use
18821hasfield_t='varname=$1; struct=$2; type=$3; field=$4; shift; shift; shift; shift;
18822while $test $# -ge 2; do
18823    case "$1" in
18824	$define) echo "#include <$2>";;
18825    esac ;
18826    shift 2;
18827done > try.c;
18828echo "int main () { $struct foo; $type bar = foo.$field; }" >> try.c;
18829set try;
18830if eval $compile; then
18831	val="$define";
18832else
18833	val="$undef";
18834fi;
18835set $varname;
18836eval $setvar;
18837$rm_try'
18838
18839: see what siginfo fields we have
18840case "$d_sigaction" in
18841"$define")
18842	echo "Checking if your siginfo_t has si_errno field...">&4
18843	set d_siginfo_si_errno siginfo_t int si_errno $d_sigaction signal.h
18844	eval $hasfield_t;
18845
18846	echo "Checking if your siginfo_t has si_pid field...">&4
18847	set d_siginfo_si_pid siginfo_t $pidtype si_pid $d_sigaction signal.h
18848	eval $hasfield_t;
18849
18850	echo "Checking if your siginfo_t has si_uid field...">&4
18851	set d_siginfo_si_uid siginfo_t $uidtype si_uid $d_sigaction signal.h
18852	eval $hasfield_t;
18853
18854	echo "Checking if your siginfo_t has si_addr field...">&4
18855	set d_siginfo_si_addr siginfo_t "void *" si_addr $d_sigaction signal.h
18856	eval $hasfield_t;
18857
18858	echo "Checking if your siginfo_t has si_status field...">&4
18859	set d_siginfo_si_status siginfo_t int si_status $d_sigaction signal.h
18860	eval $hasfield_t;
18861
18862	echo "Checking if your siginfo_t has si_band field...">&4
18863	set d_siginfo_si_band siginfo_t long si_band $d_sigaction signal.h
18864	eval $hasfield_t;
18865
18866	echo "Checking if your siginfo_t has si_value field...">&4
18867	set d_siginfo_si_value siginfo_t "union sigval" si_value $d_sigaction signal.h
18868	eval $hasfield_t;
18869
18870	echo "Checking if your siginfo_t has si_fd field...">&4
18871	set d_siginfo_si_fd siginfo_t int si_fd $d_sigaction signal.h
18872	eval $hasfield_t;
18873
18874	;;
18875*)
18876	d_siginfo_si_errno="$undef"
18877	d_siginfo_si_pid="$undef"
18878	d_siginfo_si_uid="$undef"
18879	d_siginfo_si_addr="$undef"
18880	d_siginfo_si_status="$undef"
18881	d_siginfo_si_band="$undef"
18882	d_siginfo_si_value="$undef"
18883	d_siginfo_si_fd="$undef"
18884	;;
18885esac
18886
18887: see if this is a sunmath.h system
18888set sunmath.h i_sunmath
18889eval $inhdr
18890
18891: see if signbit exists
18892$echo $n "Checking to see if you have signbit() available to work on $nvtype... $c" >&4
18893$cat >try.c <<EOCP
18894#$i_sunmath I_SUNMATH
18895#include <math.h>
18896#ifdef I_SUNMATH  /* Solaris special math library */
18897#  include <sunmath.h>
18898#endif
18899#define NV $nvtype
18900int main(int argc, char **argv)
18901{
18902    NV x = 0.0;
18903    NV y = -1.0;
18904    if ((signbit(x) == 0) && (signbit(y) != 0))
18905	return 0;
18906    else
18907	return 1;
18908}
18909EOCP
18910val="$undef"
18911set try
18912if eval $compile; then
18913    if $run ./try; then
18914        $echo "Yes." >&4
18915	val="$define"
18916    else
18917        $echo "Signbit seems to be available, but doesn't work as I expected."
18918        $echo "I won't use it." >&4
18919	val="$undef"
18920    fi
18921else
18922    $echo "Nope." >&4
18923    dflt="$undef"
18924fi
18925set d_signbit
18926eval $setvar
18927$rm_try
18928
18929: see if sigprocmask exists
18930set sigprocmask d_sigprocmask
18931eval $inlibc
18932
18933: see if sigsetjmp exists
18934echo " "
18935case "$d_sigsetjmp" in
18936'')
18937	$cat >try.c <<EOP
18938#include <setjmp.h>
18939#$i_stdlib I_STDLIB
18940#ifdef I_STDLIB
18941#include <stdlib.h>
18942#endif
18943sigjmp_buf env;
18944int set = 1;
18945int main()
18946{
18947	if (sigsetjmp(env,1))
18948		exit(set);
18949	set = 0;
18950	siglongjmp(env, 1);
18951	exit(1);
18952}
18953EOP
18954	set try
18955	if eval $compile; then
18956		if $run ./try >/dev/null 2>&1; then
18957			echo "POSIX sigsetjmp found." >&4
18958			val="$define"
18959		else
18960			$cat >&4 <<EOM
18961Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
18962I'll ignore them.
18963EOM
18964			val="$undef"
18965		fi
18966	else
18967		echo "sigsetjmp not found." >&4
18968		val="$undef"
18969	fi
18970	;;
18971*) val="$d_sigsetjmp"
18972	case "$d_sigsetjmp" in
18973	$define) echo "POSIX sigsetjmp found." >&4;;
18974	$undef) echo "sigsetjmp not found." >&4;;
18975	esac
18976	;;
18977esac
18978set d_sigsetjmp
18979eval $setvar
18980$rm_try
18981
18982: see if snprintf exists
18983set snprintf d_snprintf
18984eval $inlibc
18985
18986: see if vsnprintf exists
18987set vsnprintf d_vsnprintf
18988eval $inlibc
18989
18990case "$d_snprintf-$d_vsnprintf" in
18991"$define-$define")
18992    $cat <<EOM
18993Checking whether your snprintf() and vsnprintf() work okay...
18994EOM
18995    $cat >try.c <<'EOCP'
18996/* v?snprintf testing logic courtesy of Russ Allbery.
18997 * According to C99:
18998 * - if the buffer is too short it still must be \0-terminated
18999 * - if the buffer is too short the potentially required length
19000 *   must be returned and not -1
19001 * - if the buffer is NULL the potentially required length
19002 *   must be returned and not -1 or core dump
19003 */
19004#include <stdio.h>
19005#include <stdarg.h>
19006
19007char buf[2];
19008
19009int test (char *format, ...)
19010{
19011    va_list args;
19012    int count;
19013
19014    va_start (args, format);
19015    count = vsnprintf (buf, sizeof buf, format, args);
19016    va_end (args);
19017    return count;
19018}
19019
19020int main ()
19021{
19022    return ((test ("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0'
19023             && snprintf (NULL, 0, "%s", "abcd") == 4) ? 0 : 1);
19024}
19025EOCP
19026    set try
19027    if eval $compile; then
19028	`$run ./try`
19029	case "$?" in
19030	0) echo "Your snprintf() and vsnprintf() seem to be working okay." ;;
19031	*) cat <<EOM >&4
19032Your snprintf() and snprintf() don't seem to be working okay.
19033EOM
19034	   d_snprintf="$undef"
19035	   d_vsnprintf="$undef"
19036	   ;;
19037	esac
19038    else
19039	echo "(I can't seem to compile the test program--assuming they don't)"
19040	d_snprintf="$undef"
19041	d_vsnprintf="$undef"
19042    fi
19043    $rm_try
19044    ;;
19045esac
19046
19047: see if sockatmark exists
19048set sockatmark d_sockatmark
19049eval $inlibc
19050
19051: see if prototype for sockatmark is available
19052echo " "
19053set d_sockatmarkproto sockatmark $d_socket sys/socket.h
19054eval $hasproto
19055
19056: see if socks5_init exists
19057set socks5_init d_socks5_init
19058eval $inlibc
19059
19060: see if srand48_r exists
19061set srand48_r d_srand48_r
19062eval $inlibc
19063case "$d_srand48_r" in
19064"$define")
19065	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
19066	case "$d_srand48_r_proto:$usethreads" in
19067	":define")	d_srand48_r_proto=define
19068		set d_srand48_r_proto srand48_r $hdrs
19069		eval $hasproto ;;
19070	*)	;;
19071	esac
19072	case "$d_srand48_r_proto" in
19073	define)
19074	case "$srand48_r_proto" in
19075	''|0) try='int srand48_r(long, struct drand48_data*);'
19076	./protochk "$extern_C $try" $hdrs && srand48_r_proto=I_LS ;;
19077	esac
19078	case "$srand48_r_proto" in
19079	''|0)	d_srand48_r=undef
19080		srand48_r_proto=0
19081		echo "Disabling srand48_r, cannot determine prototype." >&4 ;;
19082	* )	case "$srand48_r_proto" in
19083		REENTRANT_PROTO*) ;;
19084		*) srand48_r_proto="REENTRANT_PROTO_$srand48_r_proto" ;;
19085		esac
19086		echo "Prototype: $try" ;;
19087	esac
19088	;;
19089	*)	case "$usethreads" in
19090		define) echo "srand48_r has no prototype, not using it." >&4 ;;
19091		esac
19092		d_srand48_r=undef
19093		srand48_r_proto=0
19094		;;
19095	esac
19096	;;
19097*)	srand48_r_proto=0
19098	;;
19099esac
19100
19101: see if srandom_r exists
19102set srandom_r d_srandom_r
19103eval $inlibc
19104case "$d_srandom_r" in
19105"$define")
19106	hdrs="$i_systypes sys/types.h define stdio.h $i_stdlib stdlib.h"
19107	case "$d_srandom_r_proto:$usethreads" in
19108	":define")	d_srandom_r_proto=define
19109		set d_srandom_r_proto srandom_r $hdrs
19110		eval $hasproto ;;
19111	*)	;;
19112	esac
19113	case "$d_srandom_r_proto" in
19114	define)
19115	case "$srandom_r_proto" in
19116	''|0) try='int srandom_r(unsigned int, struct random_data*);'
19117	./protochk "$extern_C $try" $hdrs && srandom_r_proto=I_TS ;;
19118	esac
19119	case "$srandom_r_proto" in
19120	''|0)	d_srandom_r=undef
19121		srandom_r_proto=0
19122		echo "Disabling srandom_r, cannot determine prototype." >&4 ;;
19123	* )	case "$srandom_r_proto" in
19124		REENTRANT_PROTO*) ;;
19125		*) srandom_r_proto="REENTRANT_PROTO_$srandom_r_proto" ;;
19126		esac
19127		echo "Prototype: $try" ;;
19128	esac
19129	;;
19130	*)	case "$usethreads" in
19131		define) echo "srandom_r has no prototype, not using it." >&4 ;;
19132		esac
19133		d_srandom_r=undef
19134		srandom_r_proto=0
19135		;;
19136	esac
19137	;;
19138*)	srandom_r_proto=0
19139	;;
19140esac
19141
19142: see if prototype for setresgid is available
19143echo " "
19144set d_sresgproto setresgid $i_unistd unistd.h
19145eval $hasproto
19146
19147: see if prototype for setresuid is available
19148echo " "
19149set d_sresuproto setresuid $i_unistd unistd.h
19150eval $hasproto
19151
19152: see if stat exists
19153set stat d_stat
19154eval $inlibc
19155
19156: see if sys/stat.h is available
19157set sys/stat.h i_sysstat
19158eval $inhdr
19159
19160: see if stat knows about block sizes
19161echo " "
19162echo "Checking to see if your struct stat has st_blocks field..." >&4
19163set d_statblks stat st_blocks $i_sysstat sys/stat.h
19164eval $hasfield
19165
19166: see if this is a sys/vfs.h system
19167set sys/vfs.h i_sysvfs
19168eval $inhdr
19169
19170: see if this is a sys/statfs.h system
19171set sys/statfs.h i_sysstatfs
19172eval $inhdr
19173
19174: Check for statfs_s
19175echo " "
19176echo "Checking to see if your system supports struct statfs..." >&4
19177set 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
19178eval $hasstruct
19179case "$d_statfs_s" in
19180"$define")      echo "Yes, it does."   ;;
19181*)              echo "No, it doesn't." ;;
19182esac
19183
19184: see if struct statfs knows about f_flags
19185case "$d_statfs_s" in
19186define)
19187	echo " "
19188	echo "Checking to see if your struct statfs has f_flags field..." >&4
19189	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
19190	eval $hasfield
19191	;;
19192*)	val="$undef"
19193	set d_statfs_f_flags
19194	eval $setvar
19195	;;
19196esac
19197case "$d_statfs_f_flags" in
19198"$define")      echo "Yes, it does."   ;;
19199*)              echo "No, it doesn't." ;;
19200esac
19201
19202: see what flavor, if any, of static inline is supported
19203echo " "
19204echo "Checking to see if your system supports static inline..."
19205$cat > try.c <<'EOCP'
19206#include <stdlib.h>
19207extern int f_via_a(int x);
19208extern int f_via_b(int x);
19209int main(int argc, char **argv)
19210{
19211    int y;
19212
19213    y = f_via_a(0);
19214#ifdef USE_B
19215    y = f_via_b(0);
19216#endif
19217    if (y == 42) {
19218        return EXIT_SUCCESS;
19219    }
19220    else {
19221        return EXIT_FAILURE;
19222    }
19223}
19224EOCP
19225$cat > a.c <<'EOCP'
19226static INLINE int f(int x) {
19227    int y;
19228    y = x + 42;
19229    return y;
19230}
19231
19232int f_via_a(int x)
19233{
19234    return f(x);
19235}
19236EOCP
19237$cat > b.c <<'EOCP'
19238extern int f(int x);
19239
19240int f_via_b(int x)
19241{
19242    return f(x);
19243}
19244EOCP
19245
19246# Respect a hint (or previous) value for perl_static_inline, if there is one.
19247case "$perl_static_inline" in
19248'')	# Check the various possibilities, and break out on success.
19249	# For gcc, prefer __inline__, which will still permit
19250	# cflags.SH to add in -ansi.
19251	case "$gccversion" in
19252		'') xxx="inline __inline__ __inline _inline";;
19253		*)  xxx="__inline__ inline __inline _inline";;
19254	esac
19255	for inline in $xxx; do
19256		set try -DINLINE=$inline a.c
19257		if eval $compile && $run ./try; then
19258			# Now make sure there is no external linkage of static
19259			# functions
19260			set try -DINLINE=$inline -DUSE_B a.c b.c
19261			if eval $compile && $run ./try; then
19262				$echo "Your compiler supports static $inline, " >&4
19263				$echo "but it also creates an external definition," >&4
19264				$echo "so I won't use it." >&4
19265				val=$undef
19266			else
19267				$echo "Your compiler supports static $inline." >&4
19268				val=$define
19269				perl_static_inline="static $inline";
19270				break;
19271			fi
19272		else
19273			$echo "Your compiler does NOT support static $inline." >&4
19274			val="$undef"
19275		fi
19276	done
19277	;;
19278*inline*) # Some variant of inline exists.
19279	echo "Keeping your $hint value of $perl_static_inline."
19280	val=$define
19281	;;
19282static)  # No inline capabilities
19283	echo "Keeping your $hint value of $perl_static_inline."
19284	val=$undef
19285	;;
19286*)  # Unrecognized previous value -- blindly trust the supplied
19287	# value and hope it makes sense.  Use old value for
19288	# d_static_inline, if there is one.
19289	echo "Keeping your $hint value of $perl_static_inline."
19290	case "$d_static_inline" in
19291		'') val=$define ;;
19292		*)  val=$d_static_inline ;;
19293	esac
19294	;;
19295esac
19296# Fallback to plain 'static' if nothing worked.
19297case "$perl_static_inline" in
19298'')
19299	perl_static_inline="static"
19300	val=$undef
19301	;;
19302esac
19303set d_static_inline
19304eval $setvar
19305$rm -f a.[co] b.[co]
19306$rm_try
19307
19308: Check stream access
19309$cat >&4 <<EOM
19310Checking how to access stdio streams by file descriptor number...
19311EOM
19312case "$stdio_stream_array" in
19313'')	$cat >try.c <<EOCP
19314#include <stdio.h>
19315int main() {
19316  if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
19317    printf("yes\n");
19318}
19319EOCP
19320	for s in _iob __iob __sF
19321	do
19322	        set try -DSTDIO_STREAM_ARRAY=$s
19323		if eval $compile; then
19324			case "`$run ./try`" in
19325			yes)	stdio_stream_array=$s; break ;;
19326			esac
19327		fi
19328	done
19329	$rm_try
19330esac
19331case "$stdio_stream_array" in
19332'')	$cat >&4 <<EOM
19333I can't figure out how to access stdio streams by file descriptor number.
19334EOM
19335	d_stdio_stream_array="$undef"
19336	;;
19337*)	$cat >&4 <<EOM
19338You can access stdio streams by file descriptor number by the $stdio_stream_array array.
19339EOM
19340	d_stdio_stream_array="$define"
19341	;;
19342esac
19343
19344: see if strcoll exists
19345set strcoll d_strcoll
19346eval $inlibc
19347
19348: see if strerror_l exists
19349set strerror_l d_strerror_l
19350eval $inlibc
19351
19352: see if strerror_r exists
19353set strerror_r d_strerror_r
19354eval $inlibc
19355case "$d_strerror_r" in
19356"$define")
19357	hdrs="$i_systypes sys/types.h define stdio.h define string.h"
19358	case "$d_strerror_r_proto:$usethreads" in
19359	":define")	d_strerror_r_proto=define
19360		set d_strerror_r_proto strerror_r $hdrs
19361		eval $hasproto ;;
19362	*)	;;
19363	esac
19364	case "$d_strerror_r_proto" in
19365	define)
19366	case "$strerror_r_proto" in
19367	''|0) try='int strerror_r(int, char*, size_t);'
19368	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBW ;;
19369	esac
19370	case "$strerror_r_proto" in
19371	''|0) try='int strerror_r(int, char*, int);'
19372	./protochk "$extern_C $try" $hdrs && strerror_r_proto=I_IBI ;;
19373	esac
19374	case "$strerror_r_proto" in
19375	''|0) try='char* strerror_r(int, char*, size_t);'
19376	./protochk "$extern_C $try" $hdrs && strerror_r_proto=B_IBW ;;
19377	esac
19378	case "$strerror_r_proto" in
19379	''|0)	d_strerror_r=undef
19380		strerror_r_proto=0
19381		echo "Disabling strerror_r, cannot determine prototype." >&4 ;;
19382	* )	case "$strerror_r_proto" in
19383		REENTRANT_PROTO*) ;;
19384		*) strerror_r_proto="REENTRANT_PROTO_$strerror_r_proto" ;;
19385		esac
19386		echo "Prototype: $try" ;;
19387	esac
19388	;;
19389	*)	case "$usethreads" in
19390		define) echo "strerror_r has no prototype, not using it." >&4 ;;
19391		esac
19392		d_strerror_r=undef
19393		strerror_r_proto=0
19394		;;
19395	esac
19396	;;
19397*)	strerror_r_proto=0
19398	;;
19399esac
19400
19401: see if strftime exists
19402set strftime d_strftime
19403eval $inlibc
19404
19405: see if strlcat exists
19406: We need both a prototype in string.h and the symbol in libc.
19407echo " "
19408d_strlcat_proto=''
19409xx1="#$d_gnulibc HAS_GNULIBC"
19410xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
19411xx3='#   define _GNU_SOURCE'
19412xx4='#endif'
19413set d_strlcat_proto strlcat literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
19414eval $hasproto
19415case "$d_strlcat_proto" in
19416    define) # see if strlcat exists
19417	set strlcat d_strlcat
19418	eval $inlibc
19419	;;
19420    *)  val=$undef
19421	set d_strlcat
19422	eval $setvar
19423	;;
19424esac
19425
19426: see if strlcpy exists
19427: We need both a prototype in string.h and the symbol in libc.
19428echo " "
19429d_strlcpy_proto=''
19430xx1="#$d_gnulibc HAS_GNULIBC"
19431xx2='#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)'
19432xx3='#   define _GNU_SOURCE'
19433xx4='#endif'
19434set d_strlcpy_proto strlcpy literal "$xx1" literal "$xx2" literal "$xx3" literal "$xx4" define string.h
19435eval $hasproto
19436case "$d_strlcpy_proto" in
19437    define) # see if strlcpy exists
19438	set strlcpy d_strlcpy
19439	eval $inlibc
19440	;;
19441    *)  val=$undef
19442	set d_strlcpy
19443	eval $setvar
19444	;;
19445esac
19446
19447: see if strnlen exists
19448set strnlen d_strnlen
19449eval $inlibc
19450
19451: see if strtod exists
19452set strtod d_strtod
19453eval $inlibc
19454
19455: see if strtod_l exists
19456set strtod_l d_strtod_l
19457eval $inlibc
19458
19459: see if strtol exists
19460set strtol d_strtol
19461eval $inlibc
19462
19463: see if strtold exists
19464set strtold d_strtold
19465eval $inlibc
19466
19467: see if strtold_l exists
19468set strtold_l d_strtold_l
19469eval $inlibc
19470
19471: see if strtoll exists
19472set strtoll d_strtoll
19473eval $inlibc
19474
19475case "$d_longlong-$d_strtoll" in
19476"$define-$define")
19477	$cat <<EOM
19478Checking whether your strtoll() works okay...
19479EOM
19480	$cat >try.c <<'EOCP'
19481#include <errno.h>
19482#ifdef __hpux
19483#define strtoll __strtoll
19484#endif
19485#ifdef __EMX__
19486#define strtoll _strtoll
19487#endif
19488#include <stdio.h>
19489#include <stdlib.h>
19490static int bad = 0;
19491void check(const char *s, long long ell, int een) {
19492	long long gll;
19493	errno = 0;
19494	gll = strtoll(s, 0, 10);
19495	if (!((gll == ell) && (errno == een)))
19496		bad++;
19497}
19498int main() {
19499	check(" 1",                                      1LL, 0);
19500	check(" 0",                                      0LL, 0);
19501	check("-1",                                     -1LL, 0);
19502	check("-9223372036854775808", -9223372036854775808LL, 0);
19503	check("-9223372036854775808", -9223372036854775808LL, 0);
19504	check(" 9223372036854775807",  9223372036854775807LL, 0);
19505	check("-9223372036854775808", -9223372036854775808LL, 0);
19506	check(" 9223372036854775808",  9223372036854775807LL, ERANGE);
19507	check("-9223372036854775809", -9223372036854775808LL, ERANGE);
19508	if (!bad)
19509		printf("ok\n");
19510}
19511EOCP
19512	set try
19513	if eval $compile; then
19514		yyy=`$run ./try`
19515		case "$yyy" in
19516		ok) echo "Your strtoll() seems to be working okay." ;;
19517		*) cat <<EOM >&4
19518Your strtoll() doesn't seem to be working okay.
19519EOM
19520		   d_strtoll="$undef"
19521		   ;;
19522		esac
19523	else
19524		echo "(I can't seem to compile the test program--assuming it doesn't)"
19525		d_strtoll="$undef"
19526	fi
19527	;;
19528esac
19529
19530: see if strtoq exists
19531set strtoq d_strtoq
19532eval $inlibc
19533
19534: see if strtoul exists
19535set strtoul d_strtoul
19536eval $inlibc
19537
19538case "$d_strtoul" in
19539"$define")
19540	$cat <<EOM
19541Checking whether your strtoul() works okay...
19542EOM
19543	$cat >try.c <<'EOCP'
19544#include <stdlib.h>
19545#include <errno.h>
19546#include <stdio.h>
19547static int bad = 0;
19548void check(const char *s, unsigned long eul, int een) {
19549	unsigned long gul;
19550	errno = 0;
19551	gul = strtoul(s, 0, 10);
19552	if (!((gul == eul) && (errno == een)))
19553		bad++;
19554}
19555int main() {
19556	check(" 1", 1L, 0);
19557	check(" 0", 0L, 0);
19558EOCP
19559	case "$longsize" in
19560	8)
19561	    $cat >>try.c <<'EOCP'
19562	check("18446744073709551615", 18446744073709551615UL, 0);
19563	check("18446744073709551616", 18446744073709551615UL, ERANGE);
19564#if 0 /* strtoul() for /^-/ strings is undefined. */
19565	check("-1", 18446744073709551615UL, 0);
19566	check("-18446744073709551614", 2, 0);
19567	check("-18446744073709551615", 1, 0);
19568	check("-18446744073709551616", 18446744073709551615UL, ERANGE);
19569	check("-18446744073709551617", 18446744073709551615UL, ERANGE);
19570#endif
19571EOCP
19572		;;
19573	4)
19574		    $cat >>try.c <<'EOCP'
19575	check("4294967295", 4294967295UL, 0);
19576	check("4294967296", 4294967295UL, ERANGE);
19577#if 0 /* strtoul() for /^-/ strings is undefined. */
19578	check("-1", 4294967295UL, 0);
19579	check("-4294967294", 2, 0);
19580	check("-4294967295", 1, 0);
19581	check("-4294967296", 4294967295UL, ERANGE);
19582	check("-4294967297", 4294967295UL, ERANGE);
19583#endif
19584EOCP
19585		;;
19586	*)
19587: Should we write these tests to be more portable by sprintf-ing
19588: ~0 and then manipulating that char string as input for strtol?
19589		;;
19590	esac
19591	$cat >>try.c <<'EOCP'
19592	if (!bad)
19593		printf("ok\n");
19594	return 0;
19595}
19596EOCP
19597	set try
19598	if eval $compile; then
19599		case "`$run ./try`" in
19600		ok) echo "Your strtoul() seems to be working okay." ;;
19601		*) cat <<EOM >&4
19602Your strtoul() doesn't seem to be working okay.
19603EOM
19604		   d_strtoul="$undef"
19605		   ;;
19606		esac
19607	else
19608		echo "(I can't seem to compile the test program--assuming it doesn't)"
19609		d_strtoul="$undef"
19610	fi
19611	;;
19612esac
19613
19614: see if strtoull exists
19615set strtoull d_strtoull
19616eval $inlibc
19617
19618case "$d_longlong-$d_strtoull" in
19619"$define-$define")
19620	$cat <<EOM
19621Checking whether your strtoull() works okay...
19622EOM
19623	$cat >try.c <<'EOCP'
19624#include <stdlib.h>
19625#include <errno.h>
19626#ifdef __hpux
19627#define strtoull __strtoull
19628#endif
19629#include <stdio.h>
19630static int bad = 0;
19631void check(const char *s, long long eull, int een) {
19632	long long gull;
19633	errno = 0;
19634	gull = strtoull(s, 0, 10);
19635	if (!((gull == eull) && (errno == een)))
19636		bad++;
19637}
19638int main() {
19639	check(" 1",                                        1LL, 0);
19640	check(" 0",                                        0LL, 0);
19641	check("18446744073709551615",  18446744073709551615ULL, 0);
19642	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
19643#if 0 /* strtoull() for /^-/ strings is undefined. */
19644	check("-1",                    18446744073709551615ULL, 0);
19645	check("-18446744073709551614",                     2LL, 0);
19646	check("-18446744073709551615",                     1LL, 0);
19647	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
19648	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
19649#endif
19650	if (!bad)
19651		printf("ok\n");
19652}
19653EOCP
19654	set try
19655	if eval $compile; then
19656		case "`$run ./try`" in
19657		ok) echo "Your strtoull() seems to be working okay." ;;
19658		*) cat <<EOM >&4
19659Your strtoull() doesn't seem to be working okay.
19660EOM
19661		   d_strtoull="$undef"
19662		   ;;
19663		esac
19664	else
19665		echo "(I can't seem to compile the test program--assuming it doesn't)"
19666		d_strtoull="$undef"
19667	fi
19668	;;
19669esac
19670
19671: see if strtouq exists
19672set strtouq d_strtouq
19673eval $inlibc
19674
19675case "$d_strtouq" in
19676"$define")
19677	$cat <<EOM
19678Checking whether your strtouq() works okay...
19679EOM
19680	$cat >try.c <<'EOCP'
19681#include <stdlib.h>
19682#include <errno.h>
19683#include <stdio.h>
19684static int bad = 0;
19685void check(const char *s, unsigned long long eull, int een) {
19686	unsigned long long gull;
19687	errno = 0;
19688	gull = strtouq(s, 0, 10);
19689	if (!((gull == eull) && (errno == een)))
19690		bad++;
19691}
19692int main() {
19693	check(" 1",                                        1LL, 0);
19694	check(" 0",                                        0LL, 0);
19695	check("18446744073709551615",  18446744073709551615ULL, 0);
19696	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
19697#if 0 /* strtouq() for /^-/ strings is undefined. */
19698	check("-1",                    18446744073709551615ULL, 0);
19699	check("-18446744073709551614",                     2LL, 0);
19700	check("-18446744073709551615",                     1LL, 0);
19701	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
19702	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
19703#endif
19704	if (!bad)
19705		printf("ok\n");
19706	return 0;
19707}
19708EOCP
19709	set try
19710	if eval $compile; then
19711		case "`$run ./try`" in
19712		ok) echo "Your strtouq() seems to be working okay." ;;
19713		*) cat <<EOM >&4
19714Your strtouq() doesn't seem to be working okay.
19715EOM
19716		   d_strtouq="$undef"
19717		   ;;
19718		esac
19719	else
19720		echo "(I can't seem to compile the test program--assuming it doesn't)"
19721		d_strtouq="$undef"
19722	fi
19723	;;
19724esac
19725
19726: see if strxfrm exists
19727set strxfrm d_strxfrm
19728eval $inlibc
19729
19730: see if strxfrm_l exists
19731set strxfrm_l d_strxfrm_l
19732eval $inlibc
19733
19734: see if symlink exists
19735set symlink d_symlink
19736eval $inlibc
19737
19738: see if syscall exists
19739set syscall d_syscall
19740eval $inlibc
19741
19742: see if prototype for syscall is available
19743echo " "
19744set d_syscallproto syscall $i_unistd unistd.h
19745eval $hasproto
19746
19747: see if sysconf exists
19748set sysconf d_sysconf
19749eval $inlibc
19750
19751: see if sys_errlist[] exists
19752echo " "
19753if test "X$d_syserrlst" = X; then
19754	if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
19755		echo "You have sys_errlist[], so we could roll our own strerror."
19756		d_syserrlst="$define"
19757	else
19758		echo "You don't have sys_errlist[], so strerror() is welcome."
19759		d_syserrlst="$undef"
19760	fi
19761fi
19762
19763: see if system exists
19764set system d_system
19765eval $inlibc
19766
19767: see if tcgetpgrp exists
19768set tcgetpgrp d_tcgetpgrp
19769eval $inlibc
19770
19771: see if tcsetpgrp exists
19772set tcsetpgrp d_tcsetpgrp
19773eval $inlibc
19774
19775: see if prototype for telldir is available
19776echo " "
19777set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
19778eval $hasproto
19779
19780: see if tgamma exists
19781set tgamma d_tgamma
19782eval $inlibc
19783
19784: see what flavor, if any, of thread local storage is supported
19785echo " "
19786echo "Checking to see if your system supports C11 thread local storage..."
19787$cat > try.c <<'EOCP'
19788#include <stdio.h>
19789#include <stdlib.h>
19790#include <pthread.h>
19791
19792static int plus_one = 1;
19793static int minus_one = -1;
19794
19795PROBE_MACRO int *minion;
19796
19797int callback (const void *a, const void *b) {
19798    int val_a = *minion * *(const int *)a;
19799    int val_b = *minion * *(const int *)b;
19800    return val_a < val_b ? -1 : val_a > val_b;
19801}
19802
19803#define SIZE 8
19804
19805void *thread_function(void *arg) {
19806    /* thread local variables should start zeroed in each thread. */
19807    if (minion != NULL) {
19808        fprintf(stderr, "__thread variable started with %p, should be NULL\n",
19809                minion);
19810        exit(2);
19811    }
19812    minion = &minus_one;
19813
19814    int array[SIZE];
19815    unsigned int i;
19816    for (i = 0; i < SIZE; ++i) {
19817        /* "Hash randomisation" - this array isn't in sorted order: */
19818        array[i ^ 5] = i * i;
19819    }
19820
19821    qsort(array, SIZE, sizeof(int), callback);
19822
19823    int bad = 0;
19824    for (i = 0; i < SIZE; ++i) {
19825        int want = (SIZE - 1 - i) * (SIZE - 1 - i);
19826        int have = array[i];
19827        if (want != have) {
19828            ++bad;
19829            fprintf(stderr, "array[%u] - want %i, have %i\n", i, want, have);
19830        }
19831    }
19832    if (bad)
19833        exit(3);
19834
19835    return NULL;
19836}
19837
19838int main(int argc, char **argv) {
19839    if (minion != NULL) {
19840        fprintf(stderr, "__thread variable started with %p, should be NULL\n",
19841                minion);
19842        exit(4);
19843    }
19844
19845    minion = &plus_one;
19846
19847    pthread_t tid;
19848    int result = pthread_create(&tid, NULL, thread_function, NULL);
19849    if (result) {
19850        fprintf(stderr, "pthread_create failed (%d)\n", result);
19851        exit(5);
19852    }
19853
19854    result = pthread_join(tid, NULL);
19855    if (result) {
19856        fprintf(stderr, "pthread_join failed (%d)\n", result);
19857        exit(6);
19858    }
19859
19860    if (minion == NULL) {
19861        fprintf(stderr, "__thread variable should not be NULL\n");
19862        exit(7);
19863    }
19864    if (!(minion == &plus_one && *minion == 1)) {
19865        fprintf(stderr, "__thread variable should be %d @ %p, not %d @ %p\n",
19866                1, &plus_one, *minion, minion);
19867        exit(8);
19868    }
19869
19870    return 0;
19871}
19872EOCP
19873
19874# Respect a hint (or previous) value for perl_thread_local, if there is one.
19875case "$perl_thread_local" in
19876'')	# Check the various possibilities, and break out on success.
19877	for thread_local in _Thread_local __thread; do
19878		set try -DPROBE_MACRO=$thread_local
19879		if eval $compile && $run ./try; then
19880			$echo "Your compiler supports $thread_local." >&4
19881			val=$define
19882			perl_thread_local="$thread_local";
19883			break;
19884		fi
19885		$echo "Your compiler does NOT support $thread_local." >&4
19886		val="$undef"
19887	done
19888	;;
19889*thread*|*Thread*) # Some variant of thread local exists.
19890	echo "Keeping your $hint value of $perl_thread_local."
19891	val=$define
19892	;;
19893*)  # Unrecognized previous value -- blindly trust the supplied
19894	# value and hope it makes sense.  Use old value for
19895	# d_thread_local, if there is one.
19896	echo "Keeping your $hint value of $perl_thread_local."
19897	case "$d_thread_local" in
19898		'') val=$define ;;
19899		*)  val=$d_thread_local ;;
19900	esac
19901	;;
19902esac
19903set d_thread_local
19904eval $setvar
19905$rm_try
19906
19907: see if time exists
19908echo " "
19909if test "X$d_time" = X -o X"$timetype" = X; then
19910    if set time val -f d_time; eval $csym; $val; then
19911		echo 'time() found.' >&4
19912		val="$define"
19913		rp="What is the type returned by time() on this system?"
19914		set time_t timetype long stdio.h sys/types.h
19915		eval $typedef_ask
19916    else
19917		echo 'time() not found, hope that will do.' >&4
19918		val="$undef"
19919		timetype='int';
19920    fi
19921    set d_time
19922    eval $setvar
19923fi
19924
19925: see if timegm exists
19926set timegm d_timegm
19927eval $inlibc
19928
19929: see if this is a sys/times.h system
19930set sys/times.h i_systimes
19931eval $inhdr
19932
19933: see if times exists
19934echo " "
19935if set times val -f d_times; eval $csym; $val; then
19936	echo 'times() found.' >&4
19937	d_times="$define"
19938	inc=''
19939	case "$i_systimes" in
19940	"$define") inc='sys/times.h';;
19941	esac
19942	rp="What is the type returned by times() on this system?"
19943	set clock_t clocktype long stdio.h sys/types.h $inc
19944	eval $typedef_ask
19945else
19946	echo 'times() NOT found, hope that will do.' >&4
19947	d_times="$undef"
19948	clocktype='int'
19949fi
19950
19951: see if tmpnam_r exists
19952set tmpnam_r d_tmpnam_r
19953eval $inlibc
19954case "$d_tmpnam_r" in
19955"$define")
19956	hdrs="$i_systypes sys/types.h define stdio.h "
19957	case "$d_tmpnam_r_proto:$usethreads" in
19958	":define")	d_tmpnam_r_proto=define
19959		set d_tmpnam_r_proto tmpnam_r $hdrs
19960		eval $hasproto ;;
19961	*)	;;
19962	esac
19963	case "$d_tmpnam_r_proto" in
19964	define)
19965	case "$tmpnam_r_proto" in
19966	''|0) try='char* tmpnam_r(char*);'
19967	./protochk "$extern_C $try" $hdrs && tmpnam_r_proto=B_B ;;
19968	esac
19969	case "$tmpnam_r_proto" in
19970	''|0)	d_tmpnam_r=undef
19971		tmpnam_r_proto=0
19972		echo "Disabling tmpnam_r, cannot determine prototype." >&4 ;;
19973	* )	case "$tmpnam_r_proto" in
19974		REENTRANT_PROTO*) ;;
19975		*) tmpnam_r_proto="REENTRANT_PROTO_$tmpnam_r_proto" ;;
19976		esac
19977		echo "Prototype: $try" ;;
19978	esac
19979	;;
19980	*)	case "$usethreads" in
19981		define) echo "tmpnam_r has no prototype, not using it." >&4 ;;
19982		esac
19983		d_tmpnam_r=undef
19984		tmpnam_r_proto=0
19985		;;
19986	esac
19987	;;
19988*)	tmpnam_r_proto=0
19989	;;
19990esac
19991
19992: see if towlower exists
19993set towlower d_towlower
19994eval $inlibc
19995
19996: see if trunc exists
19997set trunc d_trunc
19998eval $inlibc
19999
20000: see if truncate exists
20001set truncate d_truncate
20002eval $inlibc
20003
20004: see if ttyname_r exists
20005set ttyname_r d_ttyname_r
20006eval $inlibc
20007case "$d_ttyname_r" in
20008"$define")
20009	hdrs="$i_systypes sys/types.h define stdio.h $i_unistd unistd.h"
20010	case "$d_ttyname_r_proto:$usethreads" in
20011	":define")	d_ttyname_r_proto=define
20012		set d_ttyname_r_proto ttyname_r $hdrs
20013		eval $hasproto ;;
20014	*)	;;
20015	esac
20016	case "$d_ttyname_r_proto" in
20017	define)
20018	case "$ttyname_r_proto" in
20019	''|0) try='int ttyname_r(int, char*, size_t);'
20020	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBW ;;
20021	esac
20022	case "$ttyname_r_proto" in
20023	''|0) try='int ttyname_r(int, char*, int);'
20024	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=I_IBI ;;
20025	esac
20026	case "$ttyname_r_proto" in
20027	''|0) try='char* ttyname_r(int, char*, int);'
20028	./protochk "$extern_C $try" $hdrs && ttyname_r_proto=B_IBI ;;
20029	esac
20030	case "$ttyname_r_proto" in
20031	''|0)	d_ttyname_r=undef
20032		ttyname_r_proto=0
20033		echo "Disabling ttyname_r, cannot determine prototype." >&4 ;;
20034	* )	case "$ttyname_r_proto" in
20035		REENTRANT_PROTO*) ;;
20036		*) ttyname_r_proto="REENTRANT_PROTO_$ttyname_r_proto" ;;
20037		esac
20038		echo "Prototype: $try" ;;
20039	esac
20040	;;
20041	*)	case "$usethreads" in
20042		define) echo "ttyname_r has no prototype, not using it." >&4 ;;
20043		esac
20044		d_ttyname_r=undef
20045		ttyname_r_proto=0
20046		;;
20047	esac
20048	;;
20049*)	ttyname_r_proto=0
20050	;;
20051esac
20052
20053: see if tzname[] exists
20054echo " "
20055if set tzname val -a d_tzname; eval $csym; $val; then
20056	val="$define"
20057	echo 'tzname[] found.' >&4
20058else
20059	val="$undef"
20060	echo 'tzname[] NOT found.' >&4
20061fi
20062set d_tzname
20063eval $setvar
20064
20065: Check if is a multiplatform env
20066case "$osname" in
20067darwin) multiarch="$define" ;;
20068esac
20069case "$multiarch" in
20070''|[nN]*) multiarch="$undef" ;;
20071esac
20072
20073: check for ordering of bytes in a UV
20074echo " "
20075case "$multiarch" in
20076*$define*)
20077	$cat <<EOM
20078You seem to be doing a multiarchitecture build,
20079skipping the byteorder check.
20080
20081EOM
20082	byteorder='ffff'
20083	;;
20084*)
20085	case "$byteorder" in
20086	'')
20087		$cat <<'EOM'
20088In the following, larger digits indicate more significance.  A big-endian
20089machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
20090little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
20091machines may have weird orders like 3412.  A Cray will report 87654321,
20092an Alpha will report 12345678. If the test program works the default is
20093probably right.
20094I'm now running the test program...
20095EOM
20096		$cat >try.c <<EOCP
20097#include <stdio.h>
20098#$i_stdlib I_STDLIB
20099#ifdef I_STDLIB
20100#include <stdlib.h>
20101#endif
20102#include <sys/types.h>
20103typedef $uvtype UV;
20104int main()
20105{
20106	int i;
20107	union {
20108		UV l;
20109		char c[$uvsize];
20110	} u;
20111
20112	if ($uvsize > 4)
20113		u.l = (((UV)0x08070605) << 32) | (UV)0x04030201;
20114	else
20115		u.l = (UV)0x04030201;
20116	for (i = 0; i < $uvsize; i++)
20117		printf("%c", u.c[i]+'0');
20118	printf("\n");
20119	exit(0);
20120}
20121EOCP
20122		xxx_prompt=y
20123		set try
20124		if eval $compile && $run ./try > /dev/null; then
20125			dflt=`$run ./try`
20126			case "$dflt" in
20127			[1-4][1-4][1-4][1-4]|12345678|87654321)
20128				echo "(The test program ran ok.)"
20129				echo "byteorder=$dflt"
20130				xxx_prompt=n
20131			;;
20132			????|????????) echo "(The test program ran ok.)" ;;
20133			*) echo "(The test program didn't run right for some reason.)" ;;
20134			esac
20135		else
20136			dflt='4321'
20137			cat <<'EOM'
20138(I can't seem to compile the test program.  Guessing big-endian...)
20139EOM
20140		fi
20141		case "$xxx_prompt" in
20142		y)
20143			rp="What is the order of bytes in $uvtype?"
20144			. ./myread
20145			byteorder="$ans"
20146			;;
20147		*)	byteorder=$dflt
20148			;;
20149		esac
20150		;;
20151	esac
20152	$rm_try
20153	;;
20154esac
20155
20156: Checking 32bit alignedness
20157$cat <<EOM
20158
20159Checking to see whether you can access character data unalignedly...
20160EOM
20161case "$d_u32align" in
20162'')   $cat >try.c <<EOCP
20163#include <stdio.h>
20164#$i_stdlib I_STDLIB
20165#ifdef I_STDLIB
20166#include <stdlib.h>
20167#endif
20168#define U32 $u32type
20169#define BYTEORDER 0x$byteorder
20170#define U8 $u8type
20171#include <signal.h>
20172#ifdef SIGBUS
20173$signal_t bletch(int s) { exit(4); }
20174#endif
20175int main() {
20176#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
20177    volatile U8 buf[8];
20178    volatile U32 *up;
20179    int i;
20180
20181    if (sizeof(U32) != 4) {
20182	printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
20183	exit(1);
20184    }
20185
20186    fflush(stdout);
20187
20188#ifdef SIGBUS
20189    signal(SIGBUS, bletch);
20190#endif
20191
20192    buf[0] = 0;
20193    buf[1] = 0;
20194    buf[2] = 0;
20195    buf[3] = 1;
20196    buf[4] = 0;
20197    buf[5] = 0;
20198    buf[6] = 0;
20199    buf[7] = 1;
20200
20201    for (i = 0; i < 4; i++) {
20202	up = (U32*)(buf + i);
20203	if (! ((*up == 1 << (8*i)) ||   /* big-endian */
20204	       (*up == 1 << (8*(3-i)))  /* little-endian */
20205	      )
20206	   )
20207	{
20208	    printf("read failed (%x)\n", *up);
20209	    exit(2);
20210	}
20211    }
20212
20213    /* write test */
20214    for (i = 0; i < 4; i++) {
20215	up = (U32*)(buf + i);
20216	*up = 0xBeef;
20217	if (*up != 0xBeef) {
20218	    printf("write failed (%x)\n", *up);
20219	    exit(3);
20220	}
20221    }
20222
20223    exit(0);
20224#else
20225    printf("1\n");
20226    exit(1);
20227#endif
20228    return 0;
20229}
20230EOCP
20231set try
20232if eval $compile_ok; then
20233	echo "(Testing for character data alignment may crash the test.  That's okay.)" >&4
20234	$run ./try 2>&1 >/dev/null
20235	case "$?" in
20236	0)	cat >&4 <<EOM
20237You can access character data pretty unalignedly.
20238EOM
20239		d_u32align="$undef"
20240		;;
20241	*)	cat >&4 <<EOM
20242It seems that you must access character data in an aligned manner.
20243EOM
20244		d_u32align="$define"
20245		;;
20246	esac
20247else
20248	rp='Can you access character data at unaligned addresses?'
20249	dflt='n'
20250	. ./myread
20251	case "$ans" in
20252	[yY]*)	d_u32align="$undef"  ;;
20253	*)	d_u32align="$define" ;;
20254	esac
20255fi
20256$rm_try
20257;;
20258esac
20259
20260: see if ualarm exists
20261set ualarm d_ualarm
20262eval $inlibc
20263
20264: see if umask exists
20265set umask d_umask
20266eval $inlibc
20267
20268: see if unordered exists
20269set unordered d_unordered
20270eval $inlibc
20271
20272: see if unsetenv exists
20273set unsetenv d_unsetenv
20274eval $inlibc
20275
20276: see if usleep exists
20277set usleep d_usleep
20278eval $inlibc
20279
20280: see if prototype for usleep is available
20281echo " "
20282set d_usleepproto usleep $i_unistd unistd.h
20283eval $hasproto
20284
20285: see if ustat exists
20286set ustat d_ustat
20287eval $inlibc
20288
20289: see if closedir exists
20290set closedir d_closedir
20291eval $inlibc
20292
20293case "$d_closedir" in
20294"$define")
20295	echo " "
20296	echo "Checking whether closedir() returns a status..." >&4
20297	cat > try.c <<EOM
20298#$i_dirent I_DIRENT		/**/
20299#$i_sysdir I_SYS_DIR		/**/
20300#$i_sysndir I_SYS_NDIR		/**/
20301#$i_systypes I_SYS_TYPES	/**/
20302
20303#if defined(I_SYS_TYPES)
20304#include <sys/types.h>
20305#endif
20306#if defined(I_DIRENT)
20307#include <dirent.h>
20308#else
20309#ifdef I_SYS_NDIR
20310#include <sys/ndir.h>
20311#else
20312#ifdef I_SYS_DIR
20313#include <sys/dir.h>
20314#endif
20315#endif
20316#endif
20317int main() { return closedir(opendir(".")); }
20318EOM
20319	set try
20320	if eval $compile_ok; then
20321		if $run ./try > /dev/null 2>&1 ; then
20322			echo "Yes, it does."
20323			val="$undef"
20324		else
20325			echo "No, it doesn't."
20326			val="$define"
20327		fi
20328	else
20329		echo "(I can't seem to compile the test program--assuming it doesn't)"
20330		val="$define"
20331	fi
20332	;;
20333*)
20334	val="$undef";
20335	;;
20336esac
20337set d_void_closedir
20338eval $setvar
20339$rm_try
20340
20341: see if there is a wait4
20342set wait4 d_wait4
20343eval $inlibc
20344
20345: see if waitpid exists
20346set waitpid d_waitpid
20347eval $inlibc
20348
20349: see if wcrtomb exists
20350set wcrtomb d_wcrtomb
20351eval $inlibc
20352
20353: look for wcscmp
20354echo " "
20355$cat >try.c <<'EOCP'
20356#include <stdio.h>
20357#include <wchar.h>
20358int main ()
20359{
20360    wchar_t *s = L" ";
20361    return (wcscmp (s, s) ? 1 : 0);
20362    }
20363EOCP
20364set try
20365val="$undef"
20366if eval $compile; then
20367    `$run ./try`
20368    case "$?" in
20369	0)  echo "A working wcscmp() found." >&4
20370	    val="$define" ;;
20371	*)  echo "wcscmp() found, but it doesn't work" >&4
20372	    ;;
20373	esac
20374else
20375    echo "wcscmp() NOT found." >&4
20376    fi
20377set d_wcscmp
20378eval $setvar
20379$rm_try
20380
20381: see if wcstombs exists
20382set wcstombs d_wcstombs
20383eval $inlibc
20384
20385: look for wcsxfrm
20386echo " "
20387$cat >try.c <<'EOCP'
20388#include <errno.h>
20389#include <wchar.h>
20390int main ()
20391{
20392    wchar_t dst[4], *src = L" ";
20393    errno = 0;
20394    return (wcsxfrm (dst, src, 1) ? errno ? errno : 0 : 1);
20395    }
20396EOCP
20397set try
20398val="$undef"
20399if eval $compile; then
20400    `$run ./try`
20401    case "$?" in
20402	0)  echo "A working wcsxfrm() found." >&4
20403	    val="$define" ;;
20404	*)  echo "wcsxfrm() found, but it doesn't work" >&4
20405	    ;;
20406	esac
20407else
20408    echo "wcsxfrm() NOT found." >&4
20409    fi
20410set d_wcsxfrm
20411eval $setvar
20412$rm_try
20413
20414: see if wctomb exists
20415set wctomb d_wctomb
20416eval $inlibc
20417
20418: see if writev exists
20419set writev d_writev
20420eval $inlibc
20421
20422: check for alignment requirements
20423echo " "
20424case "$alignbytes" in
20425    '') echo "Checking alignment constraints..." >&4
20426	$cat >try.c <<EOCP
20427#include <stdio.h>
20428struct foobar {
20429    char foo;
20430    $nvtype bar;
20431} try_algn;
20432int main()
20433{
20434    printf("%d\n", (int)((char *)&try_algn.bar - (char *)&try_algn.foo));
20435    return(0);
20436}
20437EOCP
20438	set try
20439	if eval $compile_ok; then
20440	    dflt=`$run ./try`
20441	else
20442	    dflt='8'
20443	    echo "(I can't seem to compile the test program...)"
20444	fi
20445	case "$multiarch" in
20446	    *$define*)
20447		: The usual safe value is 8, but Darwin with -Duselongdouble
20448		: needs 16.  Hence, we will take 8 as a minimum, but allow
20449		: Configure to pick a larger value if needed.
20450		if $test "$dflt" -lt 8; then
20451		    dflt='8'
20452		    echo "Setting alignment to 8 for multiarch support.">&4
20453		fi
20454		;;
20455	esac
20456	;;
20457    *) dflt="$alignbytes"
20458	;;
20459esac
20460rp="Doubles must be aligned on a how-many-byte boundary?"
20461. ./myread
20462alignbytes="$ans"
20463$rm_try
20464
20465: set the base revision
20466baserev=5.0
20467
20468: length of character in bytes. Is always 1, otherwise it is not C
20469: This used to be a test using sizeof
20470charsize=1
20471
20472: Check for the number of bits in a character
20473case "$charbits" in
20474'')	echo "Checking how long a character is (in bits)..." >&4
20475	$cat >try.c <<EOCP
20476#include <stdio.h>
20477int main ()
20478{
20479    int n;
20480    unsigned char c;
20481    for (c = 1, n = 0; c; c <<= 1, n++) ;
20482    printf ("%d\n", n);
20483    return (0);
20484    }
20485EOCP
20486	set try
20487	if eval $compile_ok; then
20488		dflt=`$run ./try`
20489	else
20490		dflt='8'
20491		echo "(I can't seem to compile the test program.  Guessing...)"
20492	fi
20493	;;
20494*)
20495	dflt="$charbits"
20496	;;
20497esac
20498rp="What is the length of a character (in bits)?"
20499. ./myread
20500charbits="$ans"
20501$rm_try
20502case "$charbits" in
205038)	;;
20504*)	cat >&4 << EOM
20505Your system has an unsigned character size of $charbits bits, which
20506is rather unusual (normally it is 8 bits).  Perl likely will not work
20507correctly on your system, with subtle bugs in various places.
20508EOM
20509	rp='Do you really want to continue?'
20510	dflt='n'
20511	. ./myread
20512	case "$ans" in
20513		[yY])	echo >&4 "Okay, continuing."	;;
20514		*)	exit 1				;;
20515	esac
20516esac
20517
20518: how do we concatenate cpp tokens here?
20519echo " "
20520echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
20521$cat >cpp_stuff.c <<'EOCP'
20522#define RCAT(a,b)a/**/b
20523#define ACAT(a,b)a ## b
20524RCAT(Rei,ser)
20525ACAT(Cir,cus)
20526EOCP
20527$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
20528if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
20529	echo "Oh!  Smells like ANSI's been here." >&4
20530	echo "We can catify or stringify, separately or together!"
20531	cpp_stuff=42
20532elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
20533	echo "Ah, yes!  The good old days!" >&4
20534	echo "However, in the good old days we don't know how to stringify and"
20535	echo "catify at the same time."
20536	cpp_stuff=1
20537else
20538	$cat >&4 <<EOM
20539Hmm, I don't seem to be able to concatenate tokens with your cpp.
20540You're going to have to edit the values of CAT[2-5] in config.h...
20541EOM
20542	cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
20543fi
20544$rm -f cpp_stuff.*
20545
20546: see if this is a db.h system
20547set db.h i_db
20548eval $inhdr
20549
20550case "$i_db" in
20551$define)
20552	: Check db version.
20553	echo " "
20554	echo "Checking Berkeley DB version ..." >&4
20555	$cat >try.c <<EOCP
20556#include <sys/types.h>
20557#include <stdio.h>
20558#$i_stdlib I_STDLIB
20559#ifdef I_STDLIB
20560#include <stdlib.h>
20561#endif
20562#include <db.h>
20563int main(int argc, char *argv[])
20564{
20565#ifdef DB_VERSION_MAJOR	/* DB version >= 2 */
20566    int Major, Minor, Patch ;
20567    unsigned long Version ;
20568    (void)db_version(&Major, &Minor, &Patch) ;
20569    if (argc == 2) {
20570        printf("%d %d %d %d %d %d\n",
20571               DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
20572               Major, Minor, Patch);
20573        exit(0);
20574    }
20575    printf("You have Berkeley DB Version 2 or greater.\n");
20576
20577    printf("db.h is from Berkeley DB Version %d.%d.%d\n",
20578		DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
20579    printf("libdb is from Berkeley DB Version %d.%d.%d\n",
20580		Major, Minor, Patch) ;
20581
20582    /* check that db.h & libdb are compatible */
20583    if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
20584	printf("db.h and libdb are incompatible.\n") ;
20585        exit(3);
20586    }
20587
20588    printf("db.h and libdb are compatible.\n") ;
20589
20590    Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
20591		+ DB_VERSION_PATCH ;
20592
20593    /* needs to be >= 2.3.4 */
20594    if (Version < 2003004) {
20595    /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
20596	printf("Perl needs Berkeley DB 2.3.4 or greater.\n") ;
20597        exit(2);
20598    }
20599
20600    exit(0);
20601#else
20602#if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
20603    if (argc == 2) {
20604        printf("1 0 0\n");
20605        exit(0);
20606    }
20607    printf("You have Berkeley DB Version 1.\n");
20608    exit(0);	/* DB version < 2: the coast is clear. */
20609#else
20610    exit(1);	/* <db.h> not Berkeley DB? */
20611#endif
20612#endif
20613}
20614EOCP
20615	set try
20616	if eval $compile_ok && $run ./try; then
20617		echo 'Looks OK.' >&4
20618		set `$run ./try 1`
20619		db_version_major=$1
20620		db_version_minor=$2
20621		db_version_patch=$3
20622	else
20623		echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
20624		i_db=$undef
20625		case " $libs " in
20626		*"-ldb "*)
20627			: Remove db from list of libraries to use
20628			echo "Removing unusable -ldb from library list" >&4
20629			set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
20630			shift
20631			libs="$*"
20632			echo "libs = $libs" >&4
20633			;;
20634		esac
20635	fi
20636	$rm_try
20637	;;
20638esac
20639
20640case "$i_db" in
20641define)
20642	: Check the return type needed for hash
20643	echo " "
20644	echo "Checking return type needed for hash for Berkeley DB ..." >&4
20645	$cat >try.c <<EOCP
20646#include <sys/types.h>
20647#include <db.h>
20648
20649#ifndef DB_VERSION_MAJOR
20650u_int32_t hash_cb (const void* ptr, size_t size)
20651{
20652	return 0;
20653}
20654HASHINFO info;
20655int main()
20656{
20657	info.hash = hash_cb;
20658}
20659#endif
20660EOCP
20661	if $cc $ccflags -c try.c >try.out 2>&1 ; then
20662		if $compiler_warning try.out >>/dev/null 2>&1 ; then
20663			db_hashtype='int'
20664		else
20665			db_hashtype='u_int32_t'
20666		fi
20667	else
20668		: XXX Maybe we should just give up here.
20669		db_hashtype=u_int32_t
20670		$cat try.out >&4
20671		echo "Help:  I can't seem to compile the db test program." >&4
20672		echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
20673	fi
20674	$rm_try
20675	echo "Your version of Berkeley DB uses $db_hashtype for hash."
20676	;;
20677*)	db_hashtype=u_int32_t
20678	;;
20679esac
20680case "$i_db" in
20681define)
20682	: Check the return type needed for prefix
20683	echo " "
20684	echo "Checking return type needed for prefix for Berkeley DB ..." >&4
20685	cat >try.c <<EOCP
20686#include <sys/types.h>
20687#include <db.h>
20688
20689#ifndef DB_VERSION_MAJOR
20690size_t prefix_cb (const DBT *key1, const DBT *key2)
20691{
20692	return 0;
20693}
20694BTREEINFO info;
20695int main()
20696{
20697	info.prefix = prefix_cb;
20698}
20699#endif
20700EOCP
20701	if $cc $ccflags -c try.c  >try.out 2>&1 ; then
20702		if $compiler_warning try.out >>/dev/null 2>&1 ; then
20703			db_prefixtype='int'
20704		else
20705			db_prefixtype='size_t'
20706		fi
20707	else
20708		db_prefixtype='size_t'
20709		: XXX Maybe we should just give up here.
20710		$cat try.out >&4
20711		echo "Help:  I can't seem to compile the db test program." >&4
20712		echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
20713	fi
20714	$rm_try
20715	echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
20716	;;
20717*)	db_prefixtype='size_t'
20718	;;
20719esac
20720
20721: Include . in @INC
20722$cat <<EOM
20723
20724Historically Perl has provided a final fallback of the current working
20725directory '.' when searching for a library. This, however, can lead to
20726problems when a Perl program which loads optional modules is called from
20727a shared directory. This can lead to executing unexpected code.
20728
20729EOM
20730
20731# When changing to exclude by default:
20732case "$default_inc_excludes_dot" in
20733    $undef|false|[nN]*) dflt="n" ;;
20734    *)                  dflt="y" ;;
20735esac
20736# To turn exclude off by default:
20737#case "$default_inc_excludes_dot" in
20738#    $define|true|[yY]*) dflt="y" ;;
20739#    *)                  dflt="n" ;;
20740#esac
20741
20742rp='Exclude '.' from @INC by default? '
20743. ./myread
20744case "$ans" in
20745    [nN]|undef) default_inc_excludes_dot="$undef"  ;;
20746    *)          default_inc_excludes_dot="$define" ;;
20747esac
20748
20749: Check what kind of inf/nan your system has
20750$echo "Checking the kind of infinities and nans you have..." >&4
20751$echo "(The following tests may crash.  That's okay.)" >&4
20752$cat >try.c <<EOP
20753#define DOUBLESIZE $doublesize
20754#$d_longdbl HAS_LONG_DOUBLE
20755#ifdef HAS_LONG_DOUBLE
20756#define LONG_DOUBLESIZE $longdblsize
20757#define LONG_DOUBLEKIND $longdblkind
20758#endif
20759#include <math.h>
20760#include <string.h>
20761#include <stdio.h>
20762/* Note that whether the sign bit is on or off
20763 * for NaN depends on the CPU/FPU, and possibly
20764 * can be affected by the build toolchain.
20765 *
20766 * For example for older MIPS and HP-PA 2.0 the quiet NaN is:
20767 * 0x7f, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
20768 * 0x7f, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20769 * (respectively) as opposed to the more usual
20770 * 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
20771 *
20772 * Pre-IEEE-754 floating point format do not even have inf/nan support
20773 * at all.  They might have a "max" value (DBL_MAX), which may be deadly
20774 * to even mention, causing immediate SIGFPE or equivalent: this is
20775 * the case with VAX floating point, for example.
20776 */
20777static void bytes(void *v, unsigned int n) {
20778  unsigned char *p = (unsigned char *)v;
20779  int i;
20780  for (i = 0; i < n; i++) {
20781    printf("0x%02x%s", p[i], i < n - 1 ? ", " : "\n");
20782  }
20783}
20784int main(int argc, char *argv[]) {
20785   /* We cannot use 1.0/0.0 and 0.0/0.0 (with L suffixes for long double)
20786    * because some compilers are 'smart' and not only warn but refuse to
20787    * compile such 'illegal' values. */
20788   double dinf = exp(1e9);
20789   double dnan = sqrt(-1.0);
20790#ifdef HAS_LONG_DOUBLE
20791   long double ldinf = (long double)exp(1e9);
20792   long double ldnan = (long double)sqrt(-1.0);
20793# if LONG_DOUBLEKIND == 3 || LONG_DOUBLEKIND == 4
20794/* the 80-bit long doubles might have garbage in their excess bytes */
20795    memset((char *)&ldinf + 10, '\0', LONG_DOUBLESIZE - 10);
20796    memset((char *)&ldnan + 10, '\0', LONG_DOUBLESIZE - 10);
20797# endif
20798#endif
20799  if (argc == 2) {
20800    switch (argv[1][0]) {
20801    case '1': bytes(&dinf, sizeof(dinf)); break;
20802    case '2': bytes(&dnan, sizeof(dnan)); break;
20803#ifdef HAS_LONG_DOUBLE
20804    case '3': bytes(&ldinf, sizeof(ldinf)); break;
20805    case '4': bytes(&ldnan, sizeof(ldnan)); break;
20806#endif
20807    }
20808  }
20809  return 0;
20810}
20811EOP
20812set try
20813if eval $compile; then
20814    doubleinfbytes=`$run ./try 1`
20815    doublenanbytes=`$run ./try 2`
20816    case "$d_longdbl" in
20817    $define)
20818      longdblinfbytes=`$run ./try 3`
20819      longdblnanbytes=`$run ./try 4`
20820      ;;
20821    esac
20822else
20823    # Defaults in case the above test program failed.
20824    case "$doublekind" in
20825    1) # IEEE 754 32-bit LE
20826       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f'
20827       doublenanbytes='0x00, 0x00, 0xf8, 0x7f'
20828       ;;
20829    2) # IEEE 754 32-bit BE
20830       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00'
20831       doublenanbytes='0x7f, 0xf8, 0x00, 0x00'
20832       ;;
20833    3) # IEEE 754 64-bit LE
20834       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20835       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20836       ;;
20837    4) # IEEE 754 64-bit BE
20838       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20839       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20840       ;;
20841    5) # IEEE 754 128-bit LE
20842       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20843       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20844       ;;
20845    6) # IEEE 754 128-bit BE
20846       doubleinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20847       doublenanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20848       ;;
20849    7) # IEEE 754 64-bit mixed: 32-bit LEs in BE
20850       doubleinfbytes='0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00'
20851       doublenanbytes='0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00'
20852       ;;
20853    8) # IEEE 754 64-bit mixed: 32-bit BEs in LE
20854       doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00'
20855       doublenanbytes='0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00'
20856       ;;
20857    9|10|11|12|13|14) # VAX/Cray/IBM floating point formats, no inf/nan.
20858       doubleinfbytes=$undef
20859       doublenanbytes=$undef
20860       ;;
20861    *) # No idea.
20862       doubleinfbytes=$undef
20863       doublenanbytes=$undef
20864       ;;
20865    esac
20866    case "$longdblkind" in
20867    1) # IEEE 754 128-bit LE
20868       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f'
20869       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f'
20870       ;;
20871    2) # IEEE 754 128-bit BE
20872       longdblinfbytes='0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20873       longdblnanbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20874       ;;
20875    3) # IEEE 754 80-bit LE, 12 or 16 bytes (x86)
20876       case "$longdblsize" in
20877       12) # x86 32-bit (96 bits, or 4 x 32, or 12 x 8)
20878           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00'
20879           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00'
20880           ;;
20881       16) # x86_64
20882           longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20883           longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20884           ;;
20885       *)  # No idea.
20886           longdblinfbytes=$undef
20887           longdblnanbytes=$undef
20888       ;;
20889       esac
20890       ;;
20891    4) # IEEE 754 80-bit BE, 12 or 16 bytes
20892       case "$longdblsize" in
20893       12) # 32-bit system
20894           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20895           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20896           ;;
20897       16) # 64-bit system
20898           longdblinfbytes='0x7f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20899           longdblnanbytes='0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20900           ;;
20901       *)  # No idea.
20902           longdblinfbytes=$undef
20903           longdblnanbytes=$undef
20904       ;;
20905       esac
20906       ;;
20907    5) # 128-bit LE-LE "double double"
20908       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
20909       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f'
20910       ;;
20911    6) # 128-bit BE-BE "double double"
20912       longdblinfbytes='0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20913       longdblnanbytes='0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20914       ;;
20915    7) # 128-bit LE-BE "double double"
20916       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20917       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20918       ;;
20919    8) # 128-bit BE-LE "double double"
20920       longdblinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20921       longdblnanbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00'
20922       ;;
20923    9|10|11|12|13|14) # VAX/Cray/IBM floating point formats, no inf/nan.
20924       longdblinfbytes=$undef
20925       longdblnanbytes=$undef
20926       ;;
20927    *) # No idea.
20928       longdblinfbytes=$undef
20929       longdblnanbytes=$undef
20930       ;;
20931    esac
20932fi
20933# In case the program crashed the values are empty, turn them undef.
20934case "$doubleinfbytes" in
20935'') doubleinfbytes=$undef ;;
20936esac
20937case "$doublenanbytes" in
20938'') doublenanbytes=$undef ;;
20939esac
20940case "$longdblinfbytes" in
20941'') longdblinfbytes=$undef ;;
20942esac
20943case "$longdblnanbytes" in
20944'') longdblnanbytes=$undef ;;
20945esac
20946$rm_try
20947
20948: Check the length of the double mantissa
20949$echo "Checking how many mantissa bits your doubles have..." >&4
20950$cat >try.c <<EOP
20951#$i_sunmath I_SUNMATH
20952#include <float.h>
20953#ifdef I_SUNMATH
20954# include <sunmath.h>
20955#endif
20956#ifdef DBL_MANT_DIG
20957# define BITS (DBL_MANT_DIG - 1) /* the implicit bit does not count */
20958#endif
20959#include <stdio.h>
20960int main(int argc, char *argv[]) {
20961#ifdef BITS
20962  printf("%d\n", BITS);
20963#endif
20964  return 0;
20965}
20966EOP
20967set try
20968if eval $compile; then
20969    doublemantbits=`$run ./try`
20970else
20971    doublemantbits="$undef"
20972fi
20973$rm_try
20974
20975: Check the length of the longdouble mantissa
20976$echo "Checking how many mantissa bits your long doubles have..." >&4
20977$cat >try.c <<EOP
20978#$i_sunmath I_SUNMATH
20979#include <float.h>
20980#ifdef I_SUNMATH
20981# include <sunmath.h>
20982#endif
20983#$d_longdbl HAS_LONG_DOUBLE
20984#if defined(HAS_LONG_DOUBLE) && defined(LDBL_MANT_DIG)
20985# if ($longdblkind == 3) || ($longdblkind == 4) /* 80-bit extended precision */
20986/* This format has no implicit bit.  Beware, however, that for
20987 * this format the bare LDBL_MANT_DIG is misleading for inf/nan:
20988 * the top three bits are used for inf (100) / qnan (11x) / snan (101),
20989 * and the top bit must have been one since 387, zero is plain invalid.
20990 * For normal fp values, the LDBL_MANT_DIG is fine, though. */
20991#  define BITS LDBL_MANT_DIG
20992# elif ($longdblkind == 5 || $longdblkind == 6 || $longdblkind == 7 || $longdblkind == 8) /* double double */
20993/* LDBL_MANT_DIG of 106 (twice 53) would be logical, but for some
20994 * reason e.g. Irix thinks 107.  But in any case, we want only
20995 * the number of real bits, the implicit bits are of no interest.  */
20996#  define BITS 2 * (DBL_MANT_DIG - 1)
20997# else
20998#  define BITS (LDBL_MANT_DIG - 1) /* the implicit bit does not count */
20999# endif
21000#endif
21001#include <stdio.h>
21002int main(int argc, char *argv[]) {
21003#ifdef BITS
21004  printf("%d\n", BITS);
21005#endif
21006  return 0;
21007}
21008EOP
21009set try
21010if eval $compile; then
21011    longdblmantbits=`$run ./try`
21012else
21013    longdblmantbits="$undef"
21014fi
21015$rm_try
21016
21017: Check the length of the NV mantissa
21018$echo "Checking how many mantissa bits your NVs have..." >&4
21019if test "X$usequadmath" = "X$define"; then
21020  nvmantbits=112 # 128-1-15
21021else
21022  if test "X$nvsize" = "X$doublesize"; then
21023    nvmantbits="$doublemantbits"
21024  else
21025     if test "X$nvsize" = "X$longdblsize"; then
21026       nvmantbits="$longdblmantbits"
21027     else
21028       nvmantbits="$undef"
21029     fi
21030  fi
21031fi
21032
21033: How can we generate normalized random numbers ?
21034echo " "
21035echo "Using our internal random number implementation..." >&4
21036
21037case "$ccflags" in
21038*-Dmy_rand=*|*-Dmy_srand=*)
21039	echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
21040	ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
21041	ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
21042	ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
21043	;;
21044esac
21045
21046randfunc=drand48
21047drand01="drand48()"
21048seedfunc="srand48"
21049randbits=48
21050randseedtype=U32
21051
21052: Probe whether dtrace builds an object, as newer Illumos requires an input
21053: object file that uses at least one of the probes defined in the .d file
21054case "$usedtrace" in
21055$define)
21056    case "$dtracexnolibs" in
21057    $define|true|[yY]*)
21058        dtracexnolibs=$define
21059	$dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h
21060	;;
21061    ' '|'')
21062        if $dtrace -h -xnolibs -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
21063	     dtracexnolibs=$define
21064	     echo "Your dtrace accepts -xnolibs"
21065	elif $dtrace -h -s ../perldtrace.d -o perldtrace.h 2>&1 ; then
21066	     dtracexnolibs=$undef
21067	     echo "Your dtrace doesn't accept -xnolibs"
21068	else
21069             echo "Your dtrace doesn't work at all, try building without dtrace support" >&4
21070	     exit 1
21071	fi
21072	;;
21073    *)
21074        dtracexnolibs=$undef
21075	$dtrace -h -s ../perldtrace.d -o perldtrace.h
21076	;;
21077    esac
21078    case $dtracexnolibs in
21079    $define) xnolibs=-xnolibs ;;
21080    *) xnolibs= ;;
21081    esac
21082
21083    case "$dtraceobject" in
21084    $define|true|[yY]*)
21085        dtraceobject=$define
21086        ;;
21087    ' '|'')
21088        $cat >try.c <<EOM
21089#include "perldtrace.h"
21090int main(void) {
21091    PERL_LOADED_FILE("dummy");
21092    return 0;
21093}
21094EOM
21095        dtraceobject=$undef
21096        if $cc -c -o try.o $optimize $ccflags try.c \
21097                    && $dtrace -G $xnolibs -s ../perldtrace.d try.o >/dev/null 2>&1; then
21098                dtraceobject=$define
21099            echo "Your dtrace builds an object file"
21100        fi
21101        ;;
21102    *) dtraceobject=$undef ;;
21103    esac
21104    $rm_try perldtrace.o perldtrace.h
21105esac
21106
21107: Determine if this is an EBCDIC system
21108echo " "
21109echo "Determining whether or not we are on an EBCDIC system..." >&4
21110$cat >try.c <<'EOM'
21111int main()
21112{
21113  if ('M'==0xd4) return 0;
21114  return 1;
21115}
21116EOM
21117
21118val=$undef
21119set try
21120if eval $compile_ok; then
21121	if $run ./try; then
21122		echo "You seem to speak EBCDIC." >&4
21123		val="$define"
21124	else
21125		echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF-8." >&4
21126	fi
21127else
21128	echo "I'm unable to compile the test program." >&4
21129	echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
21130fi
21131$rm_try
21132set ebcdic
21133eval $setvar
21134
21135: Check how to flush
21136echo " "
21137$cat >&4 <<EOM
21138Checking how to flush all pending stdio output...
21139EOM
21140# I only know how to find the first 32 possibly open files on SunOS.
21141# See also hints/sunos_4_1.sh and util.c  --AD
21142case "$osname" in
21143sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
21144esac
21145$cat >>try.c <<EOCP
21146#include <stdio.h>
21147#$i_stdlib I_STDLIB
21148#ifdef I_STDLIB
21149#include <stdlib.h>
21150#endif
21151#$i_unistd I_UNISTD
21152#ifdef I_UNISTD
21153# include <unistd.h>
21154#endif
21155#$d_sysconf HAS_SYSCONF
21156#$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
21157#ifdef HAS_STDIO_STREAM_ARRAY
21158# define STDIO_STREAM_ARRAY $stdio_stream_array
21159#endif
21160int main() {
21161  FILE* p;
21162  unlink("try.out");
21163  p = fopen("try.out", "w");
21164#ifdef TRY_FPUTC
21165  fputc('x', p);
21166#else
21167# ifdef TRY_FPRINTF
21168  fprintf(p, "x");
21169# endif
21170#endif
21171#ifdef TRY_FFLUSH_NULL
21172  fflush(NULL);
21173#endif
21174#ifdef TRY_FFLUSH_ALL
21175  {
21176    long open_max = -1;
21177# ifdef PERL_FFLUSH_ALL_FOPEN_MAX
21178    open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
21179# else
21180#  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
21181    open_max = sysconf(_SC_OPEN_MAX);
21182#  else
21183#   ifdef FOPEN_MAX
21184    open_max = FOPEN_MAX;
21185#   else
21186#    ifdef OPEN_MAX
21187    open_max = OPEN_MAX;
21188#    else
21189#     ifdef _NFILE
21190    open_max = _NFILE;
21191#     endif
21192#    endif
21193#   endif
21194#  endif
21195# endif
21196# ifdef HAS_STDIO_STREAM_ARRAY
21197    if (open_max > 0) {
21198      long i;
21199      for (i = 0; i < open_max; i++)
21200	    if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
21201		STDIO_STREAM_ARRAY[i]._file < open_max &&
21202		STDIO_STREAM_ARRAY[i]._flag)
21203		fflush(&STDIO_STREAM_ARRAY[i]);
21204    }
21205  }
21206# endif
21207#endif
21208  _exit(42);
21209}
21210EOCP
21211: first we have to find out how _not_ to flush
21212$to try.c
21213if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
21214    output=''
21215    set try -DTRY_FPUTC
21216    if eval $compile; then
21217	    $run ./try 2>/dev/null
21218	    code="$?"
21219	    $from try.out
21220	    if $test ! -s try.out -a "X$code" = X42; then
21221		output=-DTRY_FPUTC
21222	    fi
21223    fi
21224    case "$output" in
21225    '')
21226	    set try -DTRY_FPRINTF
21227	    if eval $compile; then
21228		    $run ./try 2>/dev/null
21229		    code="$?"
21230		    $from try.out
21231		    if $test ! -s try.out -a "X$code" = X42; then
21232			output=-DTRY_FPRINTF
21233		    fi
21234	    fi
21235	;;
21236    esac
21237fi
21238: check for fflush NULL behavior
21239case "$fflushNULL" in
21240'')	set try -DTRY_FFLUSH_NULL $output
21241	if eval $compile; then
21242		$run ./try 2>/dev/null
21243		code="$?"
21244		$from try.out
21245		if $test -s try.out -a "X$code" = X42; then
21246			fflushNULL="`$cat try.out`"
21247		else
21248			if $test "X$code" != X42; then
21249				$cat >&4 <<EOM
21250(If this test failed, don't worry, we'll try another method shortly.)
21251EOM
21252			fi
21253		fi
21254	fi
21255	$rm -f core try.core core.try.*
21256	case "$fflushNULL" in
21257	x)	$cat >&4 <<EOM
21258Your fflush(NULL) works okay for output streams.
21259Let's see if it clobbers input pipes...
21260EOM
21261# As of mid-March 2000 all versions of Solaris appear to have a stdio
21262# bug that improperly flushes the input end of pipes.  So we avoid the
21263# autoflush on fork/system/exec support for now. :-(
21264$cat >tryp.c <<EOCP
21265#include <stdio.h>
21266int
21267main(int argc, char **argv)
21268{
21269    char buf[1024];
21270    int i;
21271    char *bp = buf;
21272    while (1) {
21273	while ((i = getc(stdin)) != -1
21274	       && (*bp++ = i) != '\n'
21275	       && bp < &buf[1024])
21276	/* DO NOTHING */ ;
21277	*bp = '\0';
21278	fprintf(stdout, "%s", buf);
21279	fflush(NULL);
21280	if (i == -1)
21281	    return 0;
21282	bp = buf;
21283    }
21284}
21285EOCP
21286		fflushNULL="$define"
21287		set tryp
21288		if eval $compile; then
21289		    $rm -f tryp.out
21290		    # Copy the .c file to the remote host ($to is an ssh-alike if targethost is set)
21291		    if $test "X$targethost" != X; then
21292			$to tryp.c
21293			$to tryp
21294			$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
21295		    else
21296			$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
21297		    fi
21298		    if cmp tryp.c tryp.out >/dev/null 2>&1; then
21299		       $cat >&4 <<EOM
21300fflush(NULL) seems to behave okay with input streams.
21301EOM
21302			fflushNULL="$define"
21303		    else
21304			$cat >&4 <<EOM
21305Ouch, fflush(NULL) clobbers input pipes!  We will not use it.
21306EOM
21307			fflushNULL="$undef"
21308		    fi
21309		fi
21310		$rm -f core tryp.c tryp.core core.tryp.*
21311		;;
21312	'')	$cat >&4 <<EOM
21313Your fflush(NULL) isn't working (contrary to ANSI C).
21314EOM
21315		fflushNULL="$undef"
21316		;;
21317	*)	$cat >&4 <<EOM
21318Cannot figure out whether your fflush(NULL) works or not.
21319I'm assuming it doesn't (contrary to ANSI C).
21320EOM
21321		fflushNULL="$undef"
21322		;;
21323	esac
21324	;;
21325$define|true|[yY]*)
21326	fflushNULL="$define"
21327	;;
21328*)
21329	fflushNULL="$undef"
21330	;;
21331esac
21332: check explicit looping only if NULL did not work, and if the pipe
21333: bug does not show up on an explicit flush too
21334case "$fflushNULL" in
21335"$undef")
21336	$cat >tryp.c <<EOCP
21337#include <stdio.h>
21338int
21339main(int argc, char **argv)
21340{
21341    char buf[1024];
21342    int i;
21343    char *bp = buf;
21344    while (1) {
21345	while ((i = getc(stdin)) != -1
21346	       && (*bp++ = i) != '\n'
21347	       && bp < &buf[1024])
21348	/* DO NOTHING */ ;
21349	*bp = '\0';
21350	fprintf(stdout, "%s", buf);
21351	fflush(stdin);
21352	if (i == -1)
21353	    return 0;
21354	bp = buf;
21355    }
21356}
21357EOCP
21358	set tryp
21359	if eval $compile; then
21360	    $rm -f tryp.out
21361	    if $test "X$targethost" != X; then
21362		$to tryp.c
21363		$to tryp
21364		$run "cat tryp.c | ./tryp " 2>/dev/null > tryp.out
21365	    else
21366		$cat tryp.c | $run ./tryp   2>/dev/null > tryp.out
21367	    fi
21368	    if cmp tryp.c tryp.out >/dev/null 2>&1; then
21369	       $cat >&4 <<EOM
21370Good, at least fflush(stdin) seems to behave okay when stdin is a pipe.
21371EOM
21372		: now check for fflushall behaviour
21373		case "$fflushall" in
21374		'')	set try -DTRY_FFLUSH_ALL $output
21375			if eval $compile; then
21376				$cat >&4 <<EOM
21377(Now testing the other method--but note that this also may fail.)
21378EOM
21379				$run ./try 2>/dev/null
21380				code=$?
21381				$from try.out
21382				if $test -s try.out -a "X$code" = X42; then
21383					fflushall="`$cat try.out`"
21384				fi
21385			fi
21386			$rm_try
21387			case "$fflushall" in
21388			x)	$cat >&4 <<EOM
21389Whew. Flushing explicitly all the stdio streams works.
21390EOM
21391				fflushall="$define"
21392				;;
21393			'')	$cat >&4 <<EOM
21394Sigh. Flushing explicitly all the stdio streams doesn't work.
21395EOM
21396				fflushall="$undef"
21397				;;
21398			*)	$cat >&4 <<EOM
21399Cannot figure out whether flushing stdio streams explicitly works or not.
21400I'm assuming it doesn't.
21401EOM
21402				fflushall="$undef"
21403				;;
21404			esac
21405			;;
21406		"$define"|true|[yY]*)
21407			fflushall="$define"
21408			;;
21409		*)
21410			fflushall="$undef"
21411			;;
21412		esac
21413	    else
21414		$cat >&4 <<EOM
21415All is futile.  Even fflush(stdin) clobbers input pipes!
21416EOM
21417		fflushall="$undef"
21418	    fi
21419	else
21420	    fflushall="$undef"
21421	fi
21422	$rm -f core tryp.c tryp.core core.tryp.*
21423	;;
21424*)	fflushall="$undef"
21425	;;
21426esac
21427
21428case "$fflushNULL$fflushall" in
21429undefundef)
21430	$cat <<EOM
21431OK, I give up.  I cannot figure out how to flush pending stdio output.
21432We won't be flushing handles at all before fork/exec/popen.
21433EOM
21434	;;
21435esac
21436$rm_try tryp
21437
21438: Store the full pathname to the ar program for use in the C program
21439: Respect a hint or command line value for full_ar.
21440case "$full_ar" in
21441'') full_ar=$ar ;;
21442esac
21443
21444: Store the full pathname to the sed program for use in the C program
21445full_sed=$sed
21446
21447: see what type gids are declared as in the kernel
21448echo " "
21449echo "Looking for the type for group ids returned by getgid()."
21450set gid_t gidtype xxx stdio.h sys/types.h
21451eval $typedef
21452case "$gidtype" in
21453xxx)
21454	xxx=`./findhdr sys/user.h`
21455	set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
21456	case $1 in
21457	unsigned) dflt="$1 $2" ;;
21458	*) dflt="$1" ;;
21459	esac
21460	;;
21461*) dflt="$gidtype";;
21462esac
21463case "$gidtype" in
21464gid_t) echo "gid_t found." ;;
21465*)	rp="What is the type for group ids returned by getgid()?"
21466	. ./myread
21467	gidtype="$ans"
21468	;;
21469esac
21470
21471: Check the size of GID
21472echo " "
21473case "$gidtype" in
21474*_t) zzz="$gidtype"	;;
21475*)   zzz="gid"		;;
21476esac
21477echo "Checking the size of $zzz..." >&4
21478cat > try.c <<EOCP
21479#include <sys/types.h>
21480#include <stdio.h>
21481#$i_stdlib I_STDLIB
21482#ifdef I_STDLIB
21483#include <stdlib.h>
21484#endif
21485int main() {
21486    printf("%d\n", (int)sizeof($gidtype));
21487    exit(0);
21488}
21489EOCP
21490set try
21491if eval $compile_ok; then
21492	yyy=`$run ./try`
21493	case "$yyy" in
21494	'')	gidsize=4
21495		echo "(I can't execute the test program--guessing $gidsize.)" >&4
21496		;;
21497	*)	gidsize=$yyy
21498		echo "Your $zzz is $gidsize bytes long."
21499		;;
21500	esac
21501else
21502	gidsize=4
21503	echo "(I can't compile the test program--guessing $gidsize.)" >&4
21504fi
21505
21506: Check if GID is signed
21507echo " "
21508case "$gidtype" in
21509*_t) zzz="$gidtype"	;;
21510*)   zzz="gid"		;;
21511esac
21512echo "Checking the sign of $zzz..." >&4
21513cat > try.c <<EOCP
21514#include <sys/types.h>
21515#include <stdio.h>
21516int main() {
21517	$gidtype foo = -1;
21518	if (foo < 0)
21519		printf("-1\n");
21520	else
21521		printf("1\n");
21522}
21523EOCP
21524set try
21525if eval $compile; then
21526	yyy=`$run ./try`
21527	case "$yyy" in
21528	'')	gidsign=1
21529		echo "(I can't execute the test program--guessing unsigned.)" >&4
21530		;;
21531	*)	gidsign=$yyy
21532		case "$gidsign" in
21533		 1) echo "Your $zzz is unsigned." ;;
21534		-1) echo "Your $zzz is signed."   ;;
21535		esac
21536		;;
21537	esac
21538else
21539	gidsign=1
21540	echo "(I can't compile the test program--guessing unsigned.)" >&4
21541fi
21542
21543: Check 64bit sizes
21544echo " "
21545
21546if $test X"$quadtype" != X; then
21547
21548echo "Checking how to print 64-bit integers..." >&4
21549
21550if $test X"$sPRId64" = X -a X"$quadtype" = Xint; then
21551	$cat >try.c <<'EOCP'
21552#include <sys/types.h>
21553#include <stdio.h>
21554int main() {
21555  int q = 12345678901;
21556  printf("%ld\n", q);
21557}
21558EOCP
21559	set try
21560	if eval $compile; then
21561		yyy=`$run ./try`
21562		case "$yyy" in
21563		12345678901)
21564			sPRId64='"d"'; sPRIi64='"i"'; sPRIu64='"u"';
21565			sPRIo64='"o"'; sPRIx64='"x"'; sPRIXU64='"X"';
21566			echo "We will use %d."
21567			;;
21568		esac
21569	fi
21570fi
21571
21572if $test X"$sPRId64" = X -a X"$quadtype" = Xlong; then
21573	$cat >try.c <<'EOCP'
21574#include <sys/types.h>
21575#include <stdio.h>
21576int main() {
21577  long q = 12345678901;
21578  printf("%ld\n", q);
21579}
21580EOCP
21581	set try
21582	if eval $compile; then
21583		yyy=`$run ./try`
21584		case "$yyy" in
21585		12345678901)
21586			sPRId64='"ld"'; sPRIi64='"li"'; sPRIu64='"lu"';
21587			sPRIo64='"lo"'; sPRIx64='"lx"'; sPRIXU64='"lX"';
21588			echo "We will use %ld."
21589			;;
21590		esac
21591	fi
21592fi
21593
21594if $test X"$sPRId64" = X -a X"$i_inttypes" = X"$define" -a X"$quadtype" = Xint64_t; then
21595	$cat >try.c <<'EOCP'
21596#include <sys/types.h>
21597#include <inttypes.h>
21598#include <stdio.h>
21599int main() {
21600  int64_t q = 12345678901;
21601  printf("%" PRId64 "\n", q);
21602}
21603EOCP
21604	set try
21605	if eval $compile; then
21606		yyy=`$run ./try`
21607		case "$yyy" in
21608		12345678901)
21609			sPRId64=PRId64; sPRIi64=PRIi64; sPRIu64=PRIu64;
21610			sPRIo64=PRIo64; sPRIx64=PRIx64; sPRIXU64=PRIXU64;
21611			echo "We will use the C9X style."
21612			;;
21613		esac
21614	fi
21615fi
21616
21617if $test X"$sPRId64" = X -a X"$quadtype" != X; then
21618	$cat >try.c <<EOCP
21619#include <sys/types.h>
21620#include <stdio.h>
21621int main() {
21622  $quadtype q = 12345678901;
21623  printf("%Ld\n", q);
21624}
21625EOCP
21626	set try
21627	if eval $compile; then
21628		yyy=`$run ./try`
21629		case "$yyy" in
21630		12345678901)
21631			sPRId64='"Ld"'; sPRIi64='"Li"'; sPRIu64='"Lu"';
21632			sPRIo64='"Lo"'; sPRIx64='"Lx"'; sPRIXU64='"LX"';
21633			echo "We will use %Ld."
21634			;;
21635		esac
21636	fi
21637fi
21638
21639if $test X"$sPRId64" = X -a X"$quadtype" = X"long long"; then
21640	$cat >try.c <<'EOCP'
21641#include <sys/types.h>
21642#include <stdio.h>
21643int main() {
21644  long long q = 12345678901LL; /* AIX cc requires the LL suffix. */
21645  printf("%lld\n", q);
21646}
21647EOCP
21648	set try
21649	if eval $compile; then
21650		yyy=`$run ./try`
21651		case "$yyy" in
21652		12345678901)
21653			sPRId64='"lld"'; sPRIi64='"lli"'; sPRIu64='"llu"';
21654			sPRIo64='"llo"'; sPRIx64='"llx"'; sPRIXU64='"llX"';
21655			echo "We will use the %lld style."
21656			;;
21657		esac
21658	fi
21659fi
21660
21661if $test X"$sPRId64" = X -a X"$quadtype" != X; then
21662	$cat >try.c <<EOCP
21663#include <sys/types.h>
21664#include <stdio.h>
21665int main() {
21666  $quadtype q = 12345678901;
21667  printf("%qd\n", q);
21668}
21669EOCP
21670	set try
21671	if eval $compile; then
21672		yyy=`$run ./try`
21673		case "$yyy" in
21674		12345678901)
21675			sPRId64='"qd"'; sPRIi64='"qi"'; sPRIu64='"qu"';
21676			sPRIo64='"qo"'; sPRIx64='"qx"'; sPRIXU64='"qX"';
21677			echo "We will use %qd."
21678			;;
21679		esac
21680	fi
21681fi
21682
21683if $test X"$sPRId64" = X; then
21684	echo "Cannot figure out how to print 64-bit integers." >&4
21685fi
21686$rm_try
21687
21688fi
21689
21690case "$sPRId64" in
21691'')	d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef";
21692	d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef";
21693	;;
21694*)	d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define";
21695	d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define";
21696	;;
21697esac
21698
21699: Check format strings for internal types
21700echo " "
21701$echo "Checking the format strings to be used for Perl's internal types..." >&4
21702
21703if $test X"$ivsize" = X8; then
21704	ivdformat="$sPRId64"
21705	uvuformat="$sPRIu64"
21706	uvoformat="$sPRIo64"
21707	uvxformat="$sPRIx64"
21708	uvXUformat="$sPRIXU64"
21709else
21710	if $test X"$ivsize" = X"$longsize"; then
21711		ivdformat='"ld"'
21712		uvuformat='"lu"'
21713		uvoformat='"lo"'
21714		uvxformat='"lx"'
21715		uvXUformat='"lX"'
21716	else
21717		if $test X"$ivsize" = X"$intsize"; then
21718			ivdformat='"d"'
21719			uvuformat='"u"'
21720			uvoformat='"o"'
21721			uvxformat='"x"'
21722			uvXUformat='"X"'
21723		else
21724			: far out
21725			if $test X"$ivsize" = X"$shortsize"; then
21726				ivdformat='"hd"'
21727				uvuformat='"hu"'
21728				uvoformat='"ho"'
21729				uvxformat='"hx"'
21730				uvXUformat='"hX"'
21731			fi
21732		fi
21733	fi
21734fi
21735
21736if $test X"$usequadmath" = X"$define"; then
21737    nveformat='"Qe"'
21738    nvfformat='"Qf"'
21739    nvgformat='"Qg"'
21740    nvEUformat='"QE"'
21741    nvFUformat='"QF"'
21742    nvGUformat='"QG"'
21743else
21744    if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
21745	nveformat="$sPRIeldbl"
21746	nvfformat="$sPRIfldbl"
21747	nvgformat="$sPRIgldbl"
21748	nvEUformat="$sPRIEUldbl"
21749	nvFUformat="$sPRIFUldbl"
21750	nvGUformat="$sPRIGUldbl"
21751    else
21752	nveformat='"e"'
21753	nvfformat='"f"'
21754	nvgformat='"g"'
21755	nvEUformat='"E"'
21756	nvFUformat='"F"'
21757	nvGUformat='"G"'
21758    fi
21759fi
21760
21761case "$ivdformat" in
21762'') echo "$0: Fatal: failed to find format strings, cannot continue." >&4
21763    exit 1
21764    ;;
21765esac
21766
21767: Check format string for GID
21768
21769echo " "
21770$echo "Checking the format string to be used for gids..." >&4
21771
21772case "$gidsign" in
21773-1)	if $test X"$gidsize" = X"$ivsize"; then
21774		gidformat="$ivdformat"
21775	else
21776		if $test X"$gidsize" = X"$longsize"; then
21777			gidformat='"ld"'
21778		else
21779			if $test X"$gidsize" = X"$intsize"; then
21780				gidformat='"d"'
21781			else
21782				if $test X"$gidsize" = X"$shortsize"; then
21783					gidformat='"hd"'
21784				fi
21785			fi
21786		fi
21787	fi
21788	;;
21789*)	if $test X"$gidsize" = X"$uvsize"; then
21790		gidformat="$uvuformat"
21791	else
21792		if $test X"$gidsize" = X"$longsize"; then
21793			gidformat='"lu"'
21794		else
21795			if $test X"$gidsize" = X"$intsize"; then
21796				gidformat='"u"'
21797			else
21798				if $test X"$gidsize" = X"$shortsize"; then
21799					gidformat='"hu"'
21800				fi
21801			fi
21802		fi
21803	fi
21804	;;
21805esac
21806
21807: see if getgroups exists
21808set getgroups d_getgrps
21809eval $inlibc
21810
21811: see if setgroups exists
21812set setgroups d_setgrps
21813eval $inlibc
21814
21815: Find type of 2nd arg to 'getgroups()' and 'setgroups()'
21816echo " "
21817case "$d_getgrps$d_setgrps" in
21818*define*)
21819	case "$groupstype" in
21820	'') dflt="$gidtype" ;;
21821	*)  dflt="$groupstype" ;;
21822	esac
21823	$cat <<EOM
21824What type of pointer is the second argument to getgroups() and setgroups()?
21825Usually this is the same as group ids, $gidtype, but not always.
21826
21827EOM
21828	rp='What type pointer is the second argument to getgroups() and setgroups()?'
21829	. ./myread
21830	groupstype="$ans"
21831	;;
21832*)  groupstype="$gidtype";;
21833esac
21834
21835: check whether make sets MAKE
21836echo " "
21837echo "Checking if your $make program sets \$(MAKE)..." >&4
21838case "$make_set_make" in
21839'')
21840	$sed 's/^X //' > testmake.mak << 'EOF'
21841Xall:
21842X 	@echo 'maketemp="$(MAKE)"'
21843EOF
21844	case "`$make -f testmake.mak 2>/dev/null`" in
21845	*maketemp=*) make_set_make='#' ;;
21846	*)	make_set_make="MAKE=$make" ;;
21847	esac
21848	$rm -f testmake.mak
21849	;;
21850esac
21851case "$make_set_make" in
21852'#') echo "Yup, it does.";;
21853*) echo "Nope, it doesn't.";;
21854esac
21855
21856: see what type is used for mode_t
21857rp="What is the type used for file modes for system calls (e.g. fchmod())?"
21858set mode_t modetype int stdio.h sys/types.h
21859eval $typedef_ask
21860
21861: see if we need va_copy
21862echo " "
21863$cat >try.c <<EOCP
21864#include <stdarg.h>
21865#include <stdio.h>
21866#include <stdlib.h>
21867#include <signal.h>
21868
21869int
21870ivfprintf(FILE *f, const char *fmt, va_list *valp)
21871{
21872  return vfprintf(f, fmt, *valp);
21873}
21874
21875int
21876myvfprintf(FILE *f, const  char *fmt, va_list val)
21877{
21878  return ivfprintf(f, fmt, &val);
21879}
21880
21881int
21882myprintf(char *fmt, ...)
21883{
21884  va_list val;
21885  va_start(val, fmt);
21886  return myvfprintf(stdout, fmt, val);
21887}
21888
21889int
21890main(int ac, char **av)
21891{
21892  signal(SIGSEGV, exit);
21893#ifdef SIGBUS
21894  signal(SIGBUS,  exit);
21895#endif
21896
21897  myprintf("%s%cs all right, then\n", "that", '\'');
21898  exit(0);
21899}
21900EOCP
21901set try
21902if eval $compile && $run ./try 2>&1 >/dev/null; then
21903	case "`$run ./try`" in
21904	"that's all right, then")
21905		okay=yes
21906		;;
21907	esac
21908fi
21909case "$okay" in
21910yes)	echo "It seems that you don't need va_copy()." >&4
21911	need_va_copy="$undef"
21912	;;
21913*)	echo "It seems that va_copy() or similar will be needed." >&4
21914	need_va_copy="$define"
21915	;;
21916esac
21917$rm_try
21918
21919: see what type is used for size_t
21920rp="What is the type used for the length parameter for string functions?"
21921set size_t sizetype 'unsigned int' stdio.h sys/types.h
21922eval $typedef_ask
21923
21924: check for type of arguments to gethostbyaddr.
21925if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
21926	case "$d_gethbyaddr" in
21927	$define)
21928		$cat <<EOM
21929
21930Checking to see what type of arguments are accepted by gethostbyaddr().
21931EOM
21932		hdrs="$define sys/types.h
21933			$d_socket sys/socket.h
21934			$i_niin netinet/in.h
21935			$i_netdb netdb.h
21936			$i_unistd unistd.h"
21937		: The first arg can 'char *' or 'void *'
21938		: The second arg is some of integral type
21939		for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
21940			for yyy in size_t long int; do
21941				case "$netdb_host_type" in
21942				'')	try="$extern_C struct hostent *gethostbyaddr($xxx, $yyy, int);"
21943					if ./protochk "$try" $hdrs; then
21944						echo "Your system accepts $xxx for the first arg."
21945						echo "...and $yyy for the second arg."
21946						netdb_host_type="$xxx"
21947						netdb_hlen_type="$yyy"
21948					fi
21949					;;
21950				esac
21951			done
21952		done
21953		: In case none of those worked, prompt the user.
21954		case "$netdb_host_type" in
21955		'')	rp='What is the type for the 1st argument to gethostbyaddr?'
21956			dflt='char *'
21957			. ./myread
21958			netdb_host_type=$ans
21959			rp='What is the type for the 2nd argument to gethostbyaddr?'
21960			dflt="$sizetype"
21961			. ./myread
21962			netdb_hlen_type=$ans
21963			;;
21964		esac
21965		;;
21966	*)	: no gethostbyaddr, so pick harmless defaults
21967		netdb_host_type='char *'
21968		netdb_hlen_type="$sizetype"
21969		;;
21970	esac
21971	# Remove the "const" if needed. -- but then we'll have a
21972	# prototype clash!
21973	# netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
21974fi
21975
21976: check for type of argument to gethostbyname.
21977if test "X$netdb_name_type" = X ; then
21978	case "$d_gethbyname" in
21979	$define)
21980		$cat <<EOM
21981
21982Checking to see what type of argument is accepted by gethostbyname().
21983EOM
21984		hdrs="$define sys/types.h
21985			$d_socket sys/socket.h
21986			$i_niin netinet/in.h
21987			$i_netdb netdb.h
21988			$i_unistd unistd.h"
21989		for xxx in "const char *" "char *"; do
21990			case "$netdb_name_type" in
21991			'')	try="$extern_C struct hostent *gethostbyname($xxx);"
21992				if ./protochk "$try" $hdrs; then
21993					echo "Your system accepts $xxx."
21994					netdb_name_type="$xxx"
21995				fi
21996				;;
21997			esac
21998		done
21999		: In case none of those worked, prompt the user.
22000		case "$netdb_name_type" in
22001		'')	rp='What is the type for the 1st argument to gethostbyname?'
22002			dflt='char *'
22003			. ./myread
22004			netdb_name_type=$ans
22005			;;
22006		esac
22007		;;
22008	*)	: no gethostbyname, so pick harmless default
22009		netdb_name_type='char *'
22010		;;
22011	esac
22012fi
22013
22014: check for type of 1st argument to getnetbyaddr.
22015if test "X$netdb_net_type" = X ; then
22016	case "$d_getnbyaddr" in
22017	$define)
22018		$cat <<EOM
22019
22020Checking to see what type of 1st argument is accepted by getnetbyaddr().
22021EOM
22022		hdrs="$define sys/types.h
22023			$d_socket sys/socket.h
22024			$i_niin netinet/in.h
22025			$i_netdb netdb.h
22026			$i_unistd unistd.h"
22027		for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
22028			case "$netdb_net_type" in
22029			'')	try="$extern_C struct netent *getnetbyaddr($xxx, int);"
22030				if ./protochk "$try" $hdrs; then
22031					echo "Your system accepts $xxx."
22032					netdb_net_type="$xxx"
22033				fi
22034				;;
22035			esac
22036		done
22037		: In case none of those worked, prompt the user.
22038		case "$netdb_net_type" in
22039		'')	rp='What is the type for the 1st argument to getnetbyaddr?'
22040			dflt='long'
22041			. ./myread
22042			netdb_net_type=$ans
22043			;;
22044		esac
22045		;;
22046	*)	: no getnetbyaddr, so pick harmless default
22047		netdb_net_type='long'
22048		;;
22049	esac
22050fi
22051: locate the preferred pager for this system
22052fn=f/
22053case "$pager" in
22054'')
22055	dflt=''
22056	case "$pg" in
22057	/*) dflt=$pg;;
22058	[a-zA-Z]:/*) dflt=$pg;;
22059	esac
22060	case "$more" in
22061	/*) dflt=$more;;
22062	[a-zA-Z]:/*) dflt=$more;;
22063	esac
22064	case "$less" in
22065	/*) dflt=$less;;
22066	[a-zA-Z]:/*) dflt=$less;;
22067	esac
22068	case "$dflt" in
22069	'') dflt=/usr/ucb/more;;
22070	esac
22071	;;
22072*)	dflt="$pager"
22073	;;
22074esac
22075fn="f/($dflt)"
22076echo " "
22077rp='What pager is used on your system?'
22078. ./getfile
22079pager="$ans"
22080
22081: see if ar generates random libraries by itself
22082echo " "
22083echo "Checking how to generate random libraries on your machine..." >&4
22084echo 'int bar1() { return bar2(); }' > bar1.c
22085echo 'int bar2() { return 2; }' > bar2.c
22086$cat > foo.c <<EOP
22087#$i_stdlib I_STDLIB
22088#ifdef I_STDLIB
22089#include <stdlib.h>
22090#endif
22091int main() { printf("%d\n", bar1()); exit(0); }
22092EOP
22093$cc $ccflags -c bar1.c >/dev/null 2>&1
22094$cc $ccflags -c bar2.c >/dev/null 2>&1
22095$cc $ccflags -c foo.c >/dev/null 2>&1
22096$ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
22097if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
22098	$run ./foobar >/dev/null 2>&1; then
22099	echo "$ar appears to generate random libraries itself."
22100	orderlib=false
22101	if [ "X$ranlib" = "X" ]; then
22102	    ranlib=":"
22103	fi
22104elif $ar s bar$_a >/dev/null 2>&1 &&
22105	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
22106	$run ./foobar >/dev/null 2>&1; then
22107		echo "a table of contents needs to be added with '$ar s'."
22108		orderlib=false
22109		ranlib="$ar s"
22110elif $ar ts bar$_a >/dev/null 2>&1 &&
22111	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
22112	$run ./foobar >/dev/null 2>&1; then
22113		echo "a table of contents needs to be added with '$ar ts'."
22114		orderlib=false
22115		ranlib="$ar ts"
22116else
22117	case "$ranlib" in
22118	:) ranlib='';;
22119	'')
22120		ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
22121		$test -f $ranlib || ranlib=''
22122		;;
22123	esac
22124	if $test -n "$ranlib"; then
22125		echo "your system has '$ranlib'; we'll use that."
22126		orderlib=false
22127	else
22128		echo "your system doesn't seem to support random libraries"
22129		echo "so we'll use lorder and tsort to order the libraries."
22130		orderlib=true
22131		ranlib=":"
22132	fi
22133fi
22134$rm -f foo* bar*
22135
22136: Check the max offset that gmtime and localtime accept
22137echo "Checking max offsets that gmtime () accepts"
22138
22139case "$sGMTIME_min/$sGMTIME_max" in
22140    0/0|/)
22141	$cat >try.c <<EOCP
22142#include <sys/types.h>
22143#include <stdio.h>
22144#include <time.h>
22145
22146int i;
22147struct tm *tmp;
22148time_t pt;
22149
22150void gm_check (time_t t, int min_year, int max_year)
22151{
22152    tmp = gmtime (&t);
22153    if ( tmp == NULL ||
22154	/* Check tm_year overflow */
22155	 tmp->tm_year < min_year || tmp->tm_year > max_year)
22156	tmp = NULL;
22157    else
22158	pt = t;
22159    } /* gm_check */
22160
22161int check_max ()
22162{
22163    tmp = NULL;
22164    pt  = 0;
22165#ifdef MAXLONG
22166    gm_check (MAXLONG, 69, 0x7fffffff);
22167#endif
22168    if (tmp == NULL || tmp->tm_year < 0) {
22169	for (i = 63; i >= 0; i--) {
22170	    time_t x = pt | ((time_t)1 << i);
22171	    if (x < 0 || x < pt) continue;
22172	    gm_check (x, 69, 0x7fffffff);
22173	    }
22174	}
22175    printf ("sGMTIME_max=%ld\n", pt);
22176    return (0);
22177    } /* check_max */
22178
22179int check_min ()
22180{
22181    tmp = NULL;
22182    pt  = 0;
22183#ifdef MINLONG
22184    gm_check (MINLONG, -1900, 70);
22185#endif
22186    if (tmp == NULL) {
22187	for (i = 36; i >= 0; i--) {
22188	    time_t x = pt - ((time_t)1 << i);
22189	    if (x > 0) continue;
22190	    gm_check (x, -1900, 70);
22191	    }
22192	}
22193    printf ("sGMTIME_min=%ld\n", pt);
22194    return (0);
22195    } /* check_min */
22196
22197int main (int argc, char *argv[])
22198{
22199    /* fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t)); */
22200    check_max ();
22201    check_min ();
22202    return (0);
22203    } /* main */
22204EOCP
22205	set try
22206	if eval $compile; then
22207	    eval `$run ./try 2>/dev/null`
22208	else
22209	    echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
22210	    fi
22211	$rm_try
22212	;;
22213    esac
22214
22215echo "Checking max offsets that localtime () accepts"
22216
22217case "$sLOCALTIME_min/$sLOCALTIME_max" in
22218    0/0|/)
22219	$cat >try.c <<EOCP
22220#include <sys/types.h>
22221#include <stdio.h>
22222#include <time.h>
22223
22224int i;
22225struct tm *tmp;
22226time_t pt;
22227
22228void local_check (time_t t, int min_year, int max_year)
22229{
22230    if (sizeof (time_t) > 4 && t > 0x7ffffffffffff000LL)
22231	tmp = NULL;
22232    else
22233	tmp = localtime (&t);
22234    if ( tmp == NULL ||
22235	/* Check tm_year overflow */
22236	 tmp->tm_year < min_year || tmp->tm_year > max_year)
22237	tmp = NULL;
22238    else
22239	pt = t;
22240    } /* local_check */
22241
22242int check_max ()
22243{
22244    tmp = NULL;
22245    pt  = 0;
22246#ifdef MAXLONG
22247    local_check (MAXLONG, 69, 0x7fffffff);
22248#endif
22249    if (tmp == NULL || tmp->tm_year < 0) {
22250	for (i = 63; i >= 0; i--) {
22251	    time_t x = pt | ((time_t)1 << i);
22252	    if (x < 0 || x < pt) continue;
22253	    local_check (x, 69, 0x7fffffff);
22254	    }
22255	}
22256    printf ("sLOCALTIME_max=%ld\n", pt);
22257    return (0);
22258   } /* check_max */
22259
22260int check_min ()
22261{
22262    tmp = NULL;
22263    pt  = 0;
22264#ifdef MINLONG
22265    local_check (MINLONG, -1900, 70);
22266#endif
22267    if (tmp == NULL) {
22268	for (i = 36; i >= 0; i--) {
22269	    time_t x = pt - ((time_t)1 << i);
22270	    if (x > 0) continue;
22271	    local_check (x, -1900, 70);
22272	    }
22273	}
22274    printf ("sLOCALTIME_min=%ld\n", pt);
22275    return (0);
22276    } /* check_min */
22277
22278int main (int argc, char *argv[])
22279{
22280    check_max ();
22281    check_min ();
22282    return (0);
22283    } /* main */
22284EOCP
22285	set try
22286	if eval $compile; then
22287	    eval `$run ./try 2>/dev/null`
22288	else
22289	    echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
22290	    fi
22291	$rm_try
22292	;;
22293    esac
22294
22295: check for type of arguments to select.
22296case "$selecttype" in
22297'') case "$d_select" in
22298	$define)
22299		echo " "
22300		$cat <<EOM
22301Checking to see what type of arguments are accepted by select().
22302EOM
22303		hdrs="$define sys/types.h
22304			$i_systime sys/time.h
22305			$i_sysselct sys/select.h
22306			$d_socket sys/socket.h"
22307		: The first arg can be int, unsigned, or size_t
22308		: The last arg may or may not be 'const'
22309		val=''
22310		: void pointer has been seen but using that
22311		: breaks the selectminbits test
22312		for xxx in 'fd_set *' 'int *'; do
22313			for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
22314				for tmo in 'struct timeval *' 'const struct timeval *'; do
22315					case "$val" in
22316					'')	try="$extern_C select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
22317						if ./protochk "$try" $hdrs; then
22318							echo "Your system accepts $xxx."
22319							val="$xxx"
22320						fi
22321						;;
22322					esac
22323				done
22324			done
22325		done
22326		case "$val" in
22327		'')	rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
22328			case "$d_fd_set" in
22329				$define) dflt="fd_set *" ;;
22330				*)		dflt="int *" ;;
22331			esac
22332			. ./myread
22333			val=$ans
22334			;;
22335		esac
22336		selecttype="$val"
22337		;;
22338	*)	: no select, so pick a harmless default
22339		selecttype='int *'
22340		;;
22341	esac
22342	;;
22343esac
22344
22345: check for the select 'width'
22346case "$selectminbits" in
22347'') safebits=`expr $ptrsize \* 8`
22348    case "$d_select" in
22349	$define)
22350		$cat <<EOM
22351
22352Checking to see on how many bits at a time your select() operates...
22353EOM
22354		$cat >try.c <<EOCP
22355#include <sys/types.h>
22356#$i_time I_TIME
22357#$i_systime I_SYS_TIME
22358#$i_systimek I_SYS_TIME_KERNEL
22359#ifdef I_TIME
22360#   include <time.h>
22361#endif
22362#ifdef I_SYS_TIME
22363#   ifdef I_SYS_TIME_KERNEL
22364#	define KERNEL
22365#   endif
22366#   include <sys/time.h>
22367#   ifdef I_SYS_TIME_KERNEL
22368#	undef KERNEL
22369#   endif
22370#endif
22371#$i_sysselct I_SYS_SELECT
22372#ifdef I_SYS_SELECT
22373#include <sys/select.h>
22374#endif
22375#$d_socket HAS_SOCKET
22376#ifdef HAS_SOCKET
22377#   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
22378#endif
22379#include <stdio.h>
22380#$i_stdlib I_STDLIB
22381#ifdef I_STDLIB
22382#include <stdlib.h>
22383#endif
22384$selecttype b;
22385#define S sizeof(*(b))
22386#define MINBITS	64
22387#define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
22388#define NBITS  (NBYTES * 8)
22389int main() {
22390    char *s = (char *)malloc(NBYTES);
22391    struct timeval t;
22392    int i;
22393    FILE* fp;
22394    int fd;
22395
22396    if (!s)
22397	exit(1);
22398    fclose(stdin);
22399    fp = fopen("try.c", "r");
22400    if (fp == 0)
22401      exit(2);
22402    fd = fileno(fp);
22403    if (fd < 0)
22404      exit(3);
22405    b = ($selecttype)s;
22406    for (i = 0; i < NBITS; i++)
22407	FD_SET(i, b);
22408    t.tv_sec  = 0;
22409    t.tv_usec = 0;
22410    select(fd + 1, b, 0, 0, &t);
22411    for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
22412    free(s);
22413    printf("%d\n", i + 1);
22414    return 0;
22415}
22416EOCP
22417		set try
22418		if eval $compile_ok; then
22419			selectminbits=`$run ./try 2>/dev/null`
22420			case "$selectminbits" in
22421			'')	cat >&4 <<EOM
22422Cannot figure out on how many bits at a time your select() operates.
22423I'll play safe and guess it is $safebits bits.
22424EOM
22425				selectminbits=$safebits
22426				bits="$safebits bits"
22427				;;
22428			1)	bits="1 bit" ;;
22429			*)	bits="$selectminbits bits" ;;
22430			esac
22431			echo "Your select() operates on $bits at a time." >&4
22432		else
22433			rp='What is the minimum number of bits your select() operates on?'
22434			case "$byteorder" in
22435			12345678)	dflt=64 ;;
22436			1234)		dflt=32 ;;
22437			*)		dflt=1	;;
22438			esac
22439			. ./myread
22440			val=$ans
22441			selectminbits="$val"
22442		fi
22443		$rm_try
22444		;;
22445	*)	: no select, so pick a harmless default
22446		selectminbits=$safebits
22447		;;
22448	esac
22449	;;
22450esac
22451
22452: Trace out the files included by signal.h, then look for SIGxxx names.
22453case "$sig_num_init" in
22454'')
22455if [ "X$fieldn" = X ]; then
22456	: Just make some guesses.  We check them later.
22457	xxx="$sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h"
22458else
22459	xxx=`echo '#include <signal.h>' |
22460	$cppstdin $cppminus $cppflags 2>/dev/null |
22461	$grep '^[ 	]*#.*include' |
22462	$awk "{print \\$$fieldn}" | $sed 's!"!!g' |\
22463		$sed 's!\\\\\\\\!/!g' | $sort | $uniq`
22464fi
22465xxxfiles=''
22466for xx in $xxx /dev/null ; do
22467	$test -f "$xx" && xxxfiles="$xxxfiles $xx"
22468done
22469case "$xxxfiles" in
22470'')	xxxfiles=`./findhdr signal.h` ;;
22471esac
22472xxx=`awk '
22473$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
22474	print substr($2, 4, 20)
22475}
22476$1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
22477	print substr($3, 4, 20)
22478}' $xxxfiles`
22479: Append some common names just in case the awk scan failed.
22480xxx="$xxx ABRT ALRM BUS CANCEL CHLD CLD CONT DIL EMT FPE"
22481xxx="$xxx FREEZE HUP ILL INT IO IOT KILL LOST LWP PHONE"
22482xxx="$xxx PIPE POLL PROF PWR QUIT RTMAX RTMIN SEGV STKFLT STOP"
22483xxx="$xxx SYS TERM THAW TRAP TSTP TTIN TTOU URG USR1 USR2"
22484xxx="$xxx USR3 USR4 VTALRM WAITING WINCH WIND WINDOW XCPU XFSZ"
22485
22486: generate a few handy files for later
22487$cat > signal.c <<EOCP
22488#include <sys/types.h>
22489#include <signal.h>
22490#$i_stdlib I_STDLIB
22491#ifdef I_STDLIB
22492#include <stdlib.h>
22493#endif
22494#include <stdio.h>
22495int main() {
22496
22497/* Strange style to avoid deeply-nested #if/#else/#endif */
22498#ifndef NSIG
22499#  ifdef _NSIG
22500#    define NSIG (_NSIG)
22501#  endif
22502#endif
22503
22504#ifndef NSIG
22505#  ifdef SIGMAX
22506#    define NSIG (SIGMAX+1)
22507#  endif
22508#endif
22509
22510#ifndef NSIG
22511#  ifdef SIG_MAX
22512#    define NSIG (SIG_MAX+1)
22513#  endif
22514#endif
22515
22516#ifndef NSIG
22517#  ifdef _SIG_MAX
22518#    define NSIG (_SIG_MAX+1)
22519#  endif
22520#endif
22521
22522#ifndef NSIG
22523#  ifdef MAXSIG
22524#    define NSIG (MAXSIG+1)
22525#  endif
22526#endif
22527
22528#ifndef NSIG
22529#  ifdef MAX_SIG
22530#    define NSIG (MAX_SIG+1)
22531#  endif
22532#endif
22533
22534#ifndef NSIG
22535#  ifdef SIGARRAYSIZE
22536#    define NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */
22537#  endif
22538#endif
22539
22540#ifndef NSIG
22541#  ifdef _sys_nsig
22542#    define NSIG (_sys_nsig) /* Solaris 2.5 */
22543#  endif
22544#endif
22545
22546/* Default to some arbitrary number that's big enough to get most
22547   of the common signals.
22548*/
22549#ifndef NSIG
22550#    define NSIG 50
22551#endif
22552
22553printf("NSIG %d\n", NSIG);
22554
22555#ifndef JUST_NSIG
22556
22557EOCP
22558
22559echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
22560{
22561	printf "#ifdef SIG"; printf $1; printf "\n"
22562	printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
22563	printf $1; printf ");\n"
22564	printf "#endif\n"
22565}
22566END {
22567	printf "#endif /* JUST_NSIG */\n";
22568	printf "exit(0);\n}\n";
22569}
22570' >>signal.c
22571$cat >signal.awk <<'EOP'
22572BEGIN { ndups = 0 }
22573$1 ~ /^NSIG$/ { nsig = $2 }
22574($1 !~ /^NSIG$/) && (NF == 2) && ($2 ~ /^[0-9][0-9]*$/) {
22575    if ($2 > maxsig) { maxsig = $2 }
22576    if (sig_name[$2]) {
22577	dup_name[ndups] = $1
22578	dup_num[ndups] = $2
22579	ndups++
22580    }
22581    else {
22582	sig_name[$2] = $1
22583	sig_num[$2] = $2
22584    }
22585}
22586END {
22587    if (nsig == 0) {
22588    	nsig = maxsig + 1
22589    }
22590    printf("NSIG %d\n", nsig);
22591    for (n = 1; n < nsig; n++) {
22592 	if (sig_name[n]) {
22593 	    printf("%s %d\n", sig_name[n], sig_num[n])
22594	}
22595 	else {
22596 	    printf("NUM%d %d\n", n, n)
22597 	}
22598    }
22599    for (n = 0; n < ndups; n++) {
22600 	printf("%s %d\n", dup_name[n], dup_num[n])
22601    }
22602}
22603EOP
22604$cat >signal_cmd <<EOS
22605$startsh
22606if $test -s signal.lst; then
22607    echo "Using your existing signal.lst file"
22608	exit 0
22609fi
22610xxx="$xxx"
22611EOS
22612$cat >>signal_cmd <<'EOS'
22613
22614set signal
22615if eval $compile_ok; then
22616	$run ./signal$_exe | ($sort -n -k 2 2>/dev/null || $sort -n +1) |\
22617		$uniq | $awk -f signal.awk >signal.lst
22618else
22619	echo "(I can't seem be able to compile the whole test program)" >&4
22620	echo "(I'll try it in little pieces.)" >&4
22621	set signal -DJUST_NSIG
22622	if eval $compile_ok; then
22623		$run ./signal$_exe > signal.nsg
22624		$cat signal.nsg
22625	else
22626		echo "I can't seem to figure out how many signals you have." >&4
22627		echo "Guessing 50." >&4
22628		echo 'NSIG 50' > signal.nsg
22629	fi
22630	: Now look at all the signal names, one at a time.
22631	for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
22632		$cat > signal.c <<EOCP
22633#include <sys/types.h>
22634#include <signal.h>
22635#include <stdio.h>
22636int main() {
22637printf("$xx %d\n", SIG${xx});
22638return 0;
22639}
22640EOCP
22641		set signal
22642		if eval $compile; then
22643			echo "SIG${xx} found."
22644			$run ./signal$_exe  >> signal.ls1
22645		else
22646			echo "SIG${xx} NOT found."
22647		fi
22648	done
22649	if $test -s signal.ls1; then
22650		$cat signal.nsg signal.ls1 |
22651			$sort -n | $uniq | $awk -f signal.awk >signal.lst
22652	fi
22653
22654fi
22655if $test -s signal.lst; then
22656	:
22657else
22658	echo "(AAK! I can't compile the test programs -- Guessing)" >&4
22659	echo 'kill -l' >signal
22660	set X `csh -f <signal`
22661	$rm -f signal
22662	shift
22663	case $# in
22664	0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
22665	esac
22666	echo $@ | $tr ' ' $trnl | \
22667 	    $awk '{ printf "%s %d\n", $1, ++s; }
22668 		  END { printf "NSIG %d\n", ++s }' >signal.lst
22669fi
22670$rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
22671EOS
22672chmod a+x signal_cmd
22673$eunicefix signal_cmd
22674;;
22675esac
22676
22677: generate list of signal names
22678case "$sig_num_init" in
22679'')
22680echo " "
22681case "$sig_name_init" in
22682'') doinit=yes ;;
22683*)  case "$sig_num_init" in
22684    ''|*,*) doinit=yes ;;
22685    esac ;;
22686esac
22687case "$doinit" in
22688yes)
22689	echo "Generating a list of signal names and numbers..." >&4
22690	. ./signal_cmd
22691	sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
22692	sig_name=`$awk 'BEGIN { printf "ZERO " }
22693			!/^NSIG/ { printf "%s ", $1 }' signal.lst`
22694	sig_num=`$awk  'BEGIN { printf "0 " }
22695			!/^NSIG/ { printf "%d ", $2 }' signal.lst`
22696	sig_name_init=`$awk 'BEGIN	{ printf "\"ZERO\", " }
22697			     !/^NSIG/	{ printf "\"%s\", ", $1 }
22698			     END	{ printf "0\n" }' signal.lst`
22699	sig_num_init=`$awk  'BEGIN	{ printf "0, " }
22700			     !/^NSIG/	{ printf "%d, ", $2}
22701			     END	{ printf "0\n"}' signal.lst`
22702	;;
22703esac
22704echo "The following $sig_count signals are available:"
22705echo " "
22706echo $sig_name | $awk \
22707'BEGIN { linelen = 0 }
22708{
22709	for (i = 1; i <= NF; i++) {
22710		name = "SIG" $i " "
22711		linelen = linelen + length(name)
22712		if (linelen > 70) {
22713			printf "\n"
22714			linelen = length(name)
22715		}
22716		printf "%s", name
22717	}
22718	printf "\n"
22719}'
22720sig_size=`echo $sig_name | awk '{print NF}'`
22721$rm -f signal signal.c signal.awk signal.lst signal_cmd
22722;;
22723esac
22724
22725: Check size of size
22726echo " "
22727case "$sizetype" in
22728*_t) zzz="$sizetype"	;;
22729*)   zzz="filesize"	;;
22730esac
22731echo "Checking the size of $zzz..." >&4
22732cat > try.c <<EOCP
22733#include <sys/types.h>
22734#include <stdio.h>
22735#$i_stdlib I_STDLIB
22736#ifdef I_STDLIB
22737#include <stdlib.h>
22738#endif
22739int main() {
22740    printf("%d\n", (int)sizeof($sizetype));
22741    exit(0);
22742}
22743EOCP
22744set try
22745if eval $compile_ok; then
22746	yyy=`$run ./try`
22747	case "$yyy" in
22748	'')	sizesize=4
22749		echo "(I can't execute the test program--guessing $sizesize.)" >&4
22750		;;
22751	*)	sizesize=$yyy
22752		echo "Your $zzz size is $sizesize bytes."
22753		;;
22754	esac
22755else
22756	sizesize=4
22757	echo "(I can't compile the test program--guessing $sizesize.)" >&4
22758fi
22759
22760: check for socklen_t
22761echo " "
22762echo "Checking to see if you have socklen_t..." >&4
22763$cat >try.c <<EOCP
22764#include <sys/types.h>
22765#$d_socket HAS_SOCKET
22766#ifdef HAS_SOCKET
22767#include <sys/socket.h>
22768#endif
22769int main() { socklen_t x = 16; }
22770EOCP
22771set try
22772if eval $compile; then
22773	val="$define"
22774	echo "You have socklen_t."
22775else
22776	val="$undef"
22777	echo "You do not have socklen_t."
22778	case "$sizetype" in
22779	size_t) echo "(You do have size_t, that might work. Some people are happy with just an int.)" ;;
22780	esac
22781fi
22782$rm_try
22783set d_socklen_t
22784eval $setvar
22785
22786: see if this is a socks.h system
22787set socks.h i_socks
22788eval $inhdr
22789
22790: check for type of the size argument to socket calls
22791case "$d_socket" in
22792"$define")
22793	$cat <<EOM
22794
22795Checking to see what type is the last argument of accept().
22796EOM
22797	yyy=''
22798	case "$d_socklen_t" in
22799	"$define") yyy="$yyy socklen_t"
22800	esac
22801	yyy="$yyy $sizetype int long unsigned"
22802	for xxx in $yyy; do
22803		case "$socksizetype" in
22804		'')	try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
22805			case "$usesocks" in
22806			"$define")
22807				if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
22808					echo "Your system accepts '$xxx *' for the last argument of accept()."
22809					socksizetype="$xxx"
22810				fi
22811				;;
22812			*)	if ./protochk "$try"  $i_systypes sys/types.h $d_socket sys/socket.h; then
22813					echo "Your system accepts '$xxx *' for the last argument of accept()."
22814					socksizetype="$xxx"
22815				fi
22816				;;
22817			esac
22818			;;
22819		esac
22820	done
22821: In case none of those worked, prompt the user.
22822	case "$socksizetype" in
22823	'')	rp='What is the type for socket address structure sizes?'
22824		dflt='int'
22825		. ./myread
22826		socksizetype=$ans
22827		;;
22828	esac
22829	;;
22830*)	: no sockets, so pick relatively harmless default
22831	socksizetype='int'
22832	;;
22833esac
22834
22835: see what type is used for signed size_t
22836set ssize_t ssizetype int stdio.h sys/types.h
22837eval $typedef
22838dflt="$ssizetype"
22839$cat > try.c <<EOM
22840#include <stdio.h>
22841#$i_stdlib I_STDLIB
22842#ifdef I_STDLIB
22843#include <stdlib.h>
22844#endif
22845#include <sys/types.h>
22846#define Size_t $sizetype
22847#define SSize_t $dflt
22848int main()
22849{
22850	if (sizeof(Size_t) == sizeof(SSize_t))
22851		printf("$dflt\n");
22852	else if (sizeof(Size_t) == sizeof(int))
22853		printf("int\n");
22854	else
22855		printf("long\n");
22856	exit(0);
22857}
22858EOM
22859echo " "
22860set try
22861if eval $compile_ok && $run ./try > /dev/null; then
22862	ssizetype=`$run ./try`
22863	echo "I'll be using $ssizetype for functions returning a byte count." >&4
22864else
22865	$cat >&4 <<EOM
22866Help! I can't compile and run the ssize_t test program: please enlighten me!
22867(This is probably a misconfiguration in your system or libraries, and
22868you really ought to fix it.  Still, I'll try anyway.)
22869
22870I need a type that is the same size as $sizetype, but is guaranteed to
22871be signed.  Common values are ssize_t, int and long.
22872
22873EOM
22874	rp="What signed type is the same size as $sizetype?"
22875	. ./myread
22876	ssizetype="$ans"
22877fi
22878$rm_try
22879
22880: Check the size of st_dev
22881$echo " "
22882$echo "Checking the size of st_dev..." >&4
22883$cat > try.c <<EOCP
22884#include <sys/stat.h>
22885#include <stdio.h>
22886#$i_stdlib I_STDLIB
22887#ifdef I_STDLIB
22888#include <stdlib.h>
22889#endif
22890int main() {
22891    struct stat st;
22892    printf("%d\n", (int)sizeof(st.st_dev));
22893    exit(0);
22894}
22895EOCP
22896set try
22897if eval $compile_ok; then
22898	val=`$run ./try`
22899	case "$val" in
22900	'')	st_dev_size=4
22901		$echo "(I can't execute the test program--guessing $st_dev_size.)" >&4
22902		;;
22903	*)	st_dev_size=$val
22904		$echo "Your st_dev is $st_dev_size bytes long."
22905		;;
22906	esac
22907else
22908	st_dev_size=4
22909	$echo "(I can't compile the test program--guessing $st_dev_size.)" >&4
22910fi
22911$rm_try
22912
22913: Check if st_dev is signed
22914$echo " "
22915$echo "Checking the sign of st_dev..." >&4
22916$cat > try.c <<EOCP
22917#include <sys/stat.h>
22918#include <stdio.h>
22919int main() {
22920	struct stat foo;
22921        foo.st_dev = -1;
22922	if (foo.st_dev < 0)
22923		printf("-1\n");
22924	else
22925		printf("1\n");
22926}
22927EOCP
22928set try
22929if eval $compile; then
22930	val=`$run ./try`
22931	case "$val" in
22932	'')	st_dev_sign=1
22933		$echo "(I can't execute the test program--guessing unsigned.)" >&4
22934		;;
22935	*)	st_dev_sign=$val
22936		case "$st_dev_sign" in
22937		 1) $echo "Your st_dev is unsigned." ;;
22938		-1) $echo "Your st_dev is signed."   ;;
22939		esac
22940		;;
22941	esac
22942else
22943	st_dev_sign=1
22944	$echo "(I can't compile the test program--guessing unsigned.)" >&4
22945fi
22946$rm_try
22947
22948: Check the size of st_ino
22949$echo " "
22950$echo "Checking the size of st_ino..." >&4
22951$cat > try.c <<EOCP
22952#include <sys/stat.h>
22953#include <stdio.h>
22954#$i_stdlib I_STDLIB
22955#ifdef I_STDLIB
22956#include <stdlib.h>
22957#endif
22958int main() {
22959    struct stat st;
22960    printf("%d\n", (int)sizeof(st.st_ino));
22961    exit(0);
22962}
22963EOCP
22964set try
22965if eval $compile_ok; then
22966	val=`$run ./try`
22967	case "$val" in
22968	'')	st_ino_size=4
22969		$echo "(I can't execute the test program--guessing $st_ino_size.)" >&4
22970		;;
22971	*)	st_ino_size=$val
22972		$echo "Your st_ino is $st_ino_size bytes long."
22973		;;
22974	esac
22975else
22976	st_ino_size=4
22977	$echo "(I can't compile the test program--guessing $st_ino_size.)" >&4
22978fi
22979$rm_try
22980
22981: Check if st_ino is signed
22982$echo " "
22983$echo "Checking the sign of st_ino..." >&4
22984$cat > try.c <<EOCP
22985#include <sys/stat.h>
22986#include <stdio.h>
22987int main() {
22988	struct stat foo;
22989        foo.st_ino = -1;
22990	if (foo.st_ino < 0)
22991		printf("-1\n");
22992	else
22993		printf("1\n");
22994}
22995EOCP
22996set try
22997if eval $compile; then
22998	val=`$run ./try`
22999	case "$val" in
23000	'')	st_ino_sign=1
23001		$echo "(I can't execute the test program--guessing unsigned.)" >&4
23002		;;
23003	*)	st_ino_sign=$val
23004		case "$st_ino_sign" in
23005		 1) $echo "Your st_ino is unsigned." ;;
23006		-1) $echo "Your st_ino is signed."   ;;
23007		esac
23008		;;
23009	esac
23010else
23011	st_ino_sign=1
23012	$echo "(I can't compile the test program--guessing unsigned.)" >&4
23013fi
23014$rm_try
23015
23016: see what type of char stdio uses.
23017echo " "
23018echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
23019if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
23020	echo "Your stdio uses unsigned chars." >&4
23021	stdchar="unsigned char"
23022else
23023	echo "Your stdio uses signed chars." >&4
23024	stdchar="char"
23025fi
23026$rm -f stdioh
23027
23028: Check size of UID
23029echo " "
23030case "$uidtype" in
23031*_t) zzz="$uidtype"	;;
23032*)   zzz="uid"		;;
23033esac
23034echo "Checking the size of $zzz..." >&4
23035cat > try.c <<EOCP
23036#include <sys/types.h>
23037#include <stdio.h>
23038#$i_stdlib I_STDLIB
23039#ifdef I_STDLIB
23040#include <stdlib.h>
23041#endif
23042int main() {
23043    printf("%d\n", (int)sizeof($uidtype));
23044    exit(0);
23045}
23046EOCP
23047set try
23048if eval $compile_ok; then
23049	yyy=`$run ./try`
23050	case "$yyy" in
23051	'')	uidsize=4
23052		echo "(I can't execute the test program--guessing $uidsize.)" >&4
23053		;;
23054	*)	uidsize=$yyy
23055		echo "Your $zzz is $uidsize bytes long."
23056		;;
23057	esac
23058else
23059	uidsize=4
23060	echo "(I can't compile the test program--guessing $uidsize.)" >&4
23061fi
23062
23063: Check if UID is signed
23064echo " "
23065case "$uidtype" in
23066*_t) zzz="$uidtype"	;;
23067*)   zzz="uid"		;;
23068esac
23069echo "Checking the sign of $zzz..." >&4
23070cat > try.c <<EOCP
23071#include <sys/types.h>
23072#include <stdio.h>
23073int main() {
23074	$uidtype foo = -1;
23075	if (foo < 0)
23076		printf("-1\n");
23077	else
23078		printf("1\n");
23079}
23080EOCP
23081set try
23082if eval $compile; then
23083	yyy=`$run ./try`
23084	case "$yyy" in
23085	'')	uidsign=1
23086		echo "(I can't execute the test program--guessing unsigned.)" >&4
23087		;;
23088	*)	uidsign=$yyy
23089		case "$uidsign" in
23090		 1) echo "Your $zzz is unsigned." ;;
23091		-1) echo "Your $zzz is signed."   ;;
23092		esac
23093		;;
23094	esac
23095else
23096	uidsign=1
23097	echo "(I can't compile the test program--guessing unsigned.)" >&4
23098fi
23099
23100: Check format string for UID
23101echo " "
23102$echo "Checking the format string to be used for uids..." >&4
23103
23104case "$uidsign" in
23105-1)	if $test X"$uidsize" = X"$ivsize"; then
23106		uidformat="$ivdformat"
23107	else
23108		if $test X"$uidsize" = X"$longsize"; then
23109			uidformat='"ld"'
23110		else
23111			if $test X"$uidsize" = X"$intsize"; then
23112				uidformat='"d"'
23113			else
23114				if $test X"$uidsize" = X"$shortsize"; then
23115					uidformat='"hd"'
23116				fi
23117			fi
23118		fi
23119	fi
23120	;;
23121*)	if $test X"$uidsize" = X"$uvsize"; then
23122		uidformat="$uvuformat"
23123	else
23124		if $test X"$uidsize" = X"$longsize"; then
23125			uidformat='"lu"'
23126		else
23127			if $test X"$uidsize" = X"$intsize"; then
23128				uidformat='"u"'
23129			else
23130				if $test X"$uidsize" = X"$shortsize"; then
23131					uidformat='"hu"'
23132				fi
23133			fi
23134		fi
23135	fi
23136	;;
23137esac
23138
23139: Ask about strict by default.
23140case "$usedefaultstrict" in
23141    $define|true|[Yy]*)
23142       dflt="y"
23143       ;;
23144    *)
23145       dflt="n"
23146       ;;
23147    esac
23148
23149cat <<EOM
23150
23151EXPERIMENTAL: Perl can now be built with strict on by default when not
23152invoked with -e or -E. This is a diagnostic tool for development.
23153
23154Unless you are familiar with this feature, you should probably answer 'no'.
23155
23156EOM
23157
23158rp='Would you like to build perl with strict enabled by default?'
23159. ./myread
23160case "$ans" in
23161y|Y) val="$define" ;;
23162*)   val="$undef"  ;;
23163esac
23164set usedefaultstrict
23165eval $setvar
23166
23167: Determine if we can use sysctl with KERN_PROC_PATHNAME to find executing program
23168echo " "
23169echo "Determining whether we can use sysctl with KERN_PROC_PATHNAME to find executing program..." >&4
23170$cat >try.c <<'EOM'
23171/* Intentionally a long probe as I'd like to sanity check that the exact
23172   approach is going to work, as thinking it will work, but only having it
23173   part working at runtime is worse than not having it.  */
23174
23175#include <sys/types.h>
23176#include <sys/sysctl.h>
23177#include <sys/param.h>
23178#include <stdio.h>
23179#include <string.h>
23180#include <stdlib.h>
23181#include <unistd.h>
23182
23183int
23184main(int argc, char **argv) {
23185    char *buffer;
23186    char *argv_leaf = strrchr(argv[0], '/');
23187    char *buffer_leaf;
23188    size_t size = 0;
23189    int mib[4];
23190
23191    mib[0] = CTL_KERN;
23192    mib[1] = KERN_PROC;
23193    mib[2] = KERN_PROC_PATHNAME;
23194    mib[3] = -1;
23195
23196    if (!argv_leaf) {
23197	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
23198	return 1;
23199    }
23200
23201    if (sysctl(mib, 4, NULL, &size, NULL, 0)) {
23202	perror("sysctl");
23203	return 2;
23204    }
23205
23206    if (size < strlen(argv_leaf) + 1) {
23207	fprintf(stderr, "size %lu is too short for a path\n",
23208		(unsigned long) size);
23209	return 3;
23210    }
23211
23212    if (size > MAXPATHLEN * MAXPATHLEN) {
23213	fprintf(stderr, "size %lu is too long for a path\n",
23214		(unsigned long) size);
23215	return 4;
23216    }
23217
23218    buffer = (char *)malloc(size);
23219    if (!buffer) {
23220	perror("malloc");
23221	return 5;
23222    }
23223
23224    if (sysctl(mib, 4, buffer, &size, NULL, 0)) {
23225	perror("sysctl");
23226	return 6;
23227    }
23228
23229    if (strlen(buffer) + 1 != size) {
23230	fprintf(stderr, "size != strlen(buffer) + 1 (%lu != %lu)\n",
23231		(unsigned long)size, (unsigned long)strlen(buffer) + 1);
23232        return 7;
23233    }
23234
23235
23236    if (*buffer != '/') {
23237	fprintf(stderr, "Not an absolute path: '%s'\n", buffer);
23238	return 8;
23239    }
23240
23241    if (strstr(buffer, "/./")) {
23242	fprintf(stderr, "Contains /./: '%s'\n", buffer);
23243	return 9;
23244    }
23245
23246    if (strstr(buffer, "/../")) {
23247	fprintf(stderr, "Contains /../: '%s'\n", buffer);
23248	return 10;
23249    }
23250
23251    buffer_leaf = strrchr(buffer, '/');
23252    if (strcmp(buffer_leaf, argv_leaf) != 0) {
23253	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], buffer);
23254	return 11;
23255    }
23256
23257    free(buffer);
23258
23259    return 0;
23260}
23261EOM
23262
23263val=$undef
23264set try
23265if eval $compile; then
23266	if $run ./try; then
23267		echo "You can use sysctl with KERN_PROC_PATHNAME to find the executing program." >&4
23268		val="$define"
23269	else
23270		echo "Nope, sysctl with KERN_PROC_PATHNAME doesn't work here." >&4
23271		val="$undef"
23272	fi
23273else
23274	echo "I'm unable to compile the test program." >&4
23275	echo "I'll assume no sysctl with KERN_PROC_PATHNAME here." >&4
23276	val="$undef"
23277fi
23278$rm_try
23279set usekernprocpathname
23280eval $setvar
23281
23282: Determine if we can use _NSGetExecutablePath to find executing program
23283echo " "
23284echo "Determining whether we can use _NSGetExecutablePath to find executing program..." >&4
23285$cat >try.c <<'EOM'
23286/* Intentionally a long probe as I'd like to sanity check that the exact
23287   approach is going to work, as thinking it will work, but only having it
23288   part working at runtime is worse than not having it.  */
23289#include <mach-o/dyld.h>
23290#include <stdio.h>
23291#include <stdlib.h>
23292#include <sys/param.h>
23293#include <string.h>
23294
23295int
23296main(int argc, char **argv) {
23297    char buf[1];
23298    uint32_t size = sizeof(buf);
23299    int result;
23300    char *buffer;
23301    char *tidied;
23302    char *argv_leaf = strrchr(argv[0], '/');
23303    char *tidied_leaf;
23304
23305    if (!argv_leaf) {
23306	fprintf(stderr, "Can't locate / in '%s'\n", argv[0]);
23307	return 1;
23308    }
23309
23310    _NSGetExecutablePath(buf, &size);
23311    if (size > MAXPATHLEN * MAXPATHLEN) {
23312	fprintf(stderr, "_NSGetExecutablePath size %u is too long for a path\n",
23313		(unsigned int) size);
23314	return 2;
23315    }
23316
23317    buffer = (char *)malloc(size);
23318    if (!buffer) {
23319	perror("malloc");
23320	return 3;
23321    }
23322
23323    result = _NSGetExecutablePath(buffer, &size);
23324    if (result != 0) {
23325	fprintf(stderr, "_NSGetExecutablePath returned %i for a size of %u\n",
23326		result, (unsigned int) size);
23327	return 4;
23328    }
23329
23330    tidied = realpath(buffer, NULL);
23331    if (!tidied) {
23332	perror("realpath");
23333	return 5;
23334    }
23335
23336    free(buffer);
23337
23338    if (*tidied != '/') {
23339	fprintf(stderr, "Not an absolute path: '%s'\n", tidied);
23340	return 6;
23341    }
23342
23343    if (strstr(tidied, "/./")) {
23344	fprintf(stderr, "Contains /./: '%s'\n", tidied);
23345	return 7;
23346    }
23347
23348    if (strstr(tidied, "/../")) {
23349	fprintf(stderr, "Contains /../: '%s'\n", tidied);
23350	return 8;
23351    }
23352
23353    tidied_leaf = strrchr(tidied, '/');
23354    if (strcmp(tidied_leaf, argv_leaf) != 0) {
23355	fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], tidied);
23356	return 9;
23357    }
23358
23359    free(tidied);
23360
23361    return 0;
23362}
23363EOM
23364
23365val=$undef
23366set try
23367if eval $compile; then
23368	if $run ./try; then
23369		echo "You can use _NSGetExecutablePath to find the executing program." >&4
23370		val="$define"
23371	else
23372		echo "Nope, _NSGetExecutablePath doesn't work here." >&4
23373	fi
23374else
23375	echo "I'm unable to compile the test program." >&4
23376	echo "I'll assume no _NSGetExecutablePath here." >&4
23377fi
23378$rm_try
23379set usensgetexecutablepath
23380eval $setvar
23381
23382: Check if site customization support was requested
23383case "$usesitecustomize" in
23384    $define|true|[Yy]*)
23385	usesitecustomize="$define"
23386	;;
23387    *)
23388	usesitecustomize="$undef"
23389	;;
23390    esac
23391
23392: determine compiler compiler
23393case "$yacc" in
23394'')
23395	dflt=yacc;;
23396*)
23397	dflt="$yacc";;
23398esac
23399echo " "
23400comp='yacc'
23401if $test -f "$byacc$_exe"; then
23402	dflt="$byacc"
23403	comp="byacc or $comp"
23404fi
23405if $test -f "$bison$_exe"; then
23406	comp="$comp or bison -y"
23407fi
23408rp="Which compiler compiler ($comp) shall I use?"
23409. ./myread
23410yacc="$ans"
23411case "$yacc" in
23412*bis*)
23413	case "$yacc" in
23414	*-y*) ;;
23415	*)
23416		yacc="$yacc -y"
23417		echo "(Adding -y option to bison to get yacc-compatible behavior.)"
23418		;;
23419	esac
23420	;;
23421esac
23422
23423: see if this is a bfd.h system
23424set bfd.h i_bfd
23425eval $inhdr
23426
23427: see if this is an execinfo.h system
23428set execinfo.h i_execinfo
23429eval $inhdr
23430
23431: see if this is a fenv.h system
23432set fenv.h i_fenv
23433eval $inhdr
23434
23435: see if this is a fp.h system
23436set fp.h i_fp
23437eval $inhdr
23438
23439: see if this is a fp_class.h system
23440set fp_class.h i_fp_class
23441eval $inhdr
23442
23443: see if gdbm.h is available
23444set gdbm.h t_gdbm
23445eval $inhdr
23446case "$t_gdbm" in
23447$define)
23448	: see if gdbm_open exists
23449	set gdbm_open d_gdbm_open
23450	eval $inlibc
23451	case "$d_gdbm_open" in
23452	$undef)
23453		t_gdbm="$undef"
23454		echo "We won't be including <gdbm.h>"
23455		;;
23456	esac
23457	;;
23458esac
23459val="$t_gdbm"
23460set i_gdbm
23461eval $setvar
23462
23463: see if this is a ieeefp.h system
23464case "$i_ieeefp" in
23465'' ) set ieeefp.h i_ieeefp
23466     eval $inhdr
23467     ;;
23468esac
23469
23470: see if this is a libutil.h system
23471set libutil.h i_libutil
23472eval $inhdr
23473
23474: see if mach cthreads are available
23475if test "X$usethreads" = "X$define"; then
23476	set mach/cthreads.h i_machcthr
23477	eval $inhdr
23478else
23479	i_machcthr="$undef"
23480fi
23481
23482: see if this is a mntent.h system
23483set mntent.h i_mntent
23484eval $inhdr
23485
23486: see if net/errno.h is available
23487val=''
23488set net/errno.h val
23489eval $inhdr
23490
23491: Unfortunately, it causes problems on some systems.  Arrgh.
23492case "$val" in
23493$define)
23494	cat > try.c <<'EOM'
23495#include <stdio.h>
23496#include <errno.h>
23497#include <net/errno.h>
23498int func()
23499{
23500	return ENOTSOCK;
23501}
23502EOM
23503	if $cc $ccflags -c try.c >/dev/null 2>&1; then
23504		echo "We'll be including <net/errno.h>." >&4
23505	else
23506		echo "We won't be including <net/errno.h>." >&4
23507		val="$undef"
23508	fi
23509	$rm_try
23510	;;
23511esac
23512set i_neterrno
23513eval $setvar
23514
23515: see if netinet/tcp.h is available
23516set netinet/tcp.h i_netinettcp
23517eval $inhdr
23518
23519: see if this is a poll.h system
23520set poll.h i_poll
23521eval $inhdr
23522
23523: see if this is a prot.h system
23524set prot.h i_prot
23525eval $inhdr
23526
23527: Preprocessor symbols
23528echo " "
23529$echo "Guessing which symbols your C compiler and preprocessor define..." >&4
23530$cat <<'EOSH' > Cppsym.know
23531a29k aarch64 ABI64 aegis AES_SOURCE AIX AIX32 AIX370 AIX41 AIX42
23532AIX43 aixpc AIX_SOURCE alliant ALL_SOURCE alpha AM29000 am29000
23533AMD64 amd64 amiga AMIGAOS AMIX ansi ANSI_C_SOURCE apollo arch_ppc
23534arch_pwr ardent ARM ARM32 atarist att386 att3b
23535BeOS BIG_ENDIAN BIT_MSF BSD bsd bsd43 bsd4_2 BSD4_3 bsd4_3 bsd4_4
23536BSDCOMPAT bsdi BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES bull
23537byteorder byte_order
23538c cadmus clang clipper CMU COFF COMPILER_VERSION concurrent
23539convex cpu CRAY cray CRAYMPP ctix CX_UX CYGWIN
23540DECC DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO Dynix DynixPTX
23541ELF encore EPI EXTENSIONS
23542FAVOR_BSD FILE_OFFSET_BITS FORTIFY_SOURCE FreeBSD
23543GCC_NEW_VARARGS gcos gcx gimpel GLIBC GLIBC_MINOR GNUC GNUC_MINOR
23544GNU_LIBRARY GNU_SOURCE GO32 gould GOULD_PN
23545H3050R H3050RX hbullx20 hcx host_mips hp200 hp300 HP700 hp700
23546hp800 hp9000 hp9000s200 hp9000s300 hp9000s400
23547hp9000s700 hp9000s800 hp9k8 hppa hpux HPUX_SOURCE hp_osf
23548i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960 IA32 IA64
23549iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
23550INLINE_INTRINSICS INT64 INTEL interdata INTRINSICS is68k itanium
23551ksr1
23552LANGUAGE_C LARGEFILE64_SOURCE LARGEFILE_SOURCE LARGE_FILE_API
23553LFS64_LARGEFILE LFS_LARGEFILE LIBCATAMOUNT Linux LITTLE_ENDIAN
23554LONG64 LONGDOUBLE LONGLONG LONG_DOUBLE LONG_LONG LP64 luna
23555luna88k Lynx
23556M68000 m68k m88100 m88k M88KBCS_TARGET MACH machine MachTen
23557MATH_HAS_NO_SIDE_EFFECTS mc300 mc500 mc68000 mc68010 mc68020
23558mc68030 mc68040 mc68060 mc68k mc68k32 mc700 mc88000 mc88100
23559merlin mert MiNT mips MIPSEB MIPSEL MIPS_FPSET MIPS_ISA MIPS_SIM
23560MIPS_SZINT MIPS_SZLONG MIPS_SZPTR MODERN_C motorola MSDOS
23561MTXINU MULTIMAX MVS mvs M_AMD64 M_ARM M_ARMT M_COFF M_I186 M_I286
23562M_I386 M_I8086 M_I86 M_I86SM M_IA64 M_IX86 M_PPC M_SYS3 M_SYS5
23563M_SYSIII M_SYSV M_UNIX M_X86 M_XENIX
23564n16 ncl_el ncl_mr NetBSD news1500 news1700 news1800 news1900
23565news3700 news700 news800 news900 NeXT NLS nonstopux ns16000
23566ns32000 ns32016 ns32332 ns32k nsc32000
23567OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
23568PARAGON parisc pa_risc PA_RISC1_1 PA_RISC2_0 pc532 pdp11 PGC PIC
23569plexus PORTAR posix POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
23570POSIX_C_SOURCE POSIX_SOURCE POWER powerpc ppc PROTOTYPES PWB pyr
23571QK_USER QNX
23572R3000 REENTRANT RES Rhapsody RISC6000 riscix riscos RT
23573S390 S390x SA110 SCO scs sequent sgi SGI_SOURCE SH SH3 sinix
23574SIZE_INT SIZE_LONG SIZE_PTR SOCKETS_SOURCE SOCKET_SOURCE sony
23575sonyrisc sony_news sparc sparclite sparcv8 sparcv9 spectrum
23576stardent stdc STDC_EXT stratos sun sun3 sun386 Sun386i svr3 svr4
23577SVR4_2 SVR4_SOURCE svr5 SX system SYSTYPE_BSD SYSTYPE_BSD43
23578SYSTYPE_BSD44 SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3
23579SYSV4 SYSV5 sysV68 sysV88
23580Tek4132 Tek4300 thumb thw_370 thw_intel thw_rs6000 titan TM3200
23581TM5400 TM5600 tower tower32 tower32_200 tower32_600 tower32_700
23582tower32_800 tower32_850 tss
23583u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5 ultrix UMAXV UnicomPBB
23584UnicomPBD UNICOS UNICOSMK unix UNIX95 UNIX99 unixpc unos USE_BSD
23585USE_FILE_OFFSET64 USE_GNU USE_ISOC9X USE_LARGEFILE
23586USE_LARGEFILE64 USE_MISC USE_POSIX USE_POSIX199309
23587USE_POSIX199506 USE_POSIX2 USE_REENTRANT USE_SVID USE_UNIX98
23588USE_XOPEN USE_XOPEN_EXTENDED USGr4 USGr4_2 UTek Utek UTS UWIN
23589uxpm uxps
23590vax venix VMESA vms
23591x86_64 xenix Xenix286 XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2
23592XPG2_EXTENDED XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
23593z8000 zarch
23594EOSH
23595# Maybe put other stuff here too.
23596./tr '-' '_' <<EOSH >>Cppsym.know
23597$osname
23598EOSH
23599./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
23600./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b
23601$cat Cppsym.know > Cppsym.c
23602$cat Cppsym.a Cppsym.b Cppsym.c | $tr ' ' $trnl | $sort | $uniq > Cppsym.know
23603$rm -f Cppsym.a Cppsym.b Cppsym.c
23604cat <<EOSH > Cppsym
23605$startsh
23606if $test \$# -gt 0; then
23607    echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
23608    if $test -s Cppsym.got; then
23609	$rm -f Cppsym.got
23610	exit 0
23611    fi
23612    $rm -f Cppsym.got
23613    exit 1
23614else
23615    $tr " " "$trnl" | ./Cppsym.try
23616    exit 0
23617fi
23618EOSH
23619chmod +x Cppsym
23620$eunicefix Cppsym
23621cat <<EOSH > Cppsym.try
23622$startsh
23623cat <<'EOCP' > try.c
23624#include <stdio.h>
23625#if cpp_stuff == 1
23626#define STRINGIFY(a)    "a"
23627#endif
23628#if cpp_stuff == 42
23629#define StGiFy(a)  #a
23630#define STRINGIFY(a)    StGiFy(a)
23631#endif
23632#if $cpp_stuff != 1 && $cpp_stuff != 42
23633#   include "Bletch: How does this C preprocessor stringify macros?"
23634#endif
23635int main() {
23636EOCP
23637$awk \\
23638EOSH
23639cat <<'EOSH' >> Cppsym.try
23640'length($1) > 0 {
23641    printf "#ifdef %s\nprintf(\"%s=%%s\\n\", STRINGIFY(%s));\n#endif\n", $1, $1, $1
23642    printf "#ifdef _%s\nprintf(\"_%s=%%s\\n\", STRINGIFY(_%s));\n#endif\n", $1, $1, $1
23643    printf "#ifdef __%s\nprintf(\"__%s=%%s\\n\", STRINGIFY(__%s));\n#endif\n", $1, $1, $1
23644    printf "#ifdef __%s__\nprintf(\"__%s__=%%s\\n\", STRINGIFY(__%s__));\n#endif\n", $1, $1, $1
23645}' >> try.c
23646echo 'return 0;}' >> try.c
23647EOSH
23648cat <<EOSH >> Cppsym.try
23649ccflags="$ccflags"
23650case "$osname-$gccversion" in
23651irix-) ccflags="\$ccflags -woff 1178" ;;
23652os2-*) ccflags="\$ccflags -Zlinker /PM:VIO" ;;
23653esac
23654$cc -o try -Dcpp_stuff=$cpp_stuff $optimize \$ccflags $ldflags try.c $libs 2>/dev/null && $run ./try | $sed 's/ /\\\\ /g'
23655EOSH
23656chmod +x Cppsym.try
23657$eunicefix Cppsym.try
23658./Cppsym < Cppsym.know | $sort | $uniq > Cppsym.true
23659: Add in any Linux cpp "predefined macros":
23660case "$osname::$gccversion" in
23661  *linux*::*.*|*gnukfreebsd*::*.*|gnu::*.*)
23662    tHdrH=_tmpHdr
23663    rm -f $tHdrH'.h' $tHdrH
23664    touch $tHdrH'.h'
23665    # Filter out macro arguments, such as Linux's __INT8_C(c)
23666    if $cpp -dM $tHdrH'.h' > $tHdrH'_cppsym.h' && [ -s $tHdrH'_cppsym.h' ]; then
23667       sed -e 's/#define[\ \  ]*//;s/[\ \     ].*$//' -e 's/(.*//' <$tHdrH'_cppsym.h' >$tHdrH'_cppsym.real'
23668       if [ -s $tHdrH'_cppsym.real' ]; then
23669	  cat $tHdrH'_cppsym.real' Cppsym.know | sort | uniq | ./Cppsym | sort | uniq > Cppsym.true
23670       fi
23671    fi
23672    rm -f $tHdrH'.h' $tHdrH'_cppsym.h' $tHdrH'_cppsym.real'
23673  ;;
23674esac
23675: now check the C compiler for additional symbols
23676postprocess_cc_v=''
23677case "$osname" in
23678aix) postprocess_cc_v="|$tr , ' '" ;;
23679esac
23680$cat >ccsym <<EOS
23681$startsh
23682$cat >tmp.c <<EOF
23683extern int foo;
23684EOF
23685for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
23686do
23687	case "\$i" in
23688	-D*) echo "\$i" | $sed 's/^-D//';;
23689	-A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A//' | $sed 's/\(.*\)(\(.*\))/\1=\2/';;
23690	esac
23691done
23692$rm_try
23693EOS
23694postprocess_cc_v=''
23695chmod +x ccsym
23696$eunicefix ccsym
23697./ccsym > ccsym1.raw
23698if $test -s ccsym1.raw; then
23699    $sort ccsym1.raw | $uniq >ccsym.raw
23700else
23701    mv ccsym1.raw ccsym.raw
23702fi
23703
23704$awk '/\=/ { print $0; next }
23705	{ print $0"=1" }' ccsym.raw >ccsym.list
23706$comm -13 Cppsym.true ccsym.list >ccsym.own
23707$comm -12 Cppsym.true ccsym.list >ccsym.com
23708$comm -23 Cppsym.true ccsym.list >ccsym.cpp
23709also=''
23710if $test -z ccsym.raw; then
23711	echo "Your C compiler doesn't seem to define any symbols!" >&4
23712	echo " "
23713	echo "However, your C preprocessor defines the following symbols:"
23714	$cat Cppsym.true
23715	ccsymbols=''
23716	cppsymbols=`$cat Cppsym.true`
23717	cppsymbols=`echo $cppsymbols`
23718	cppccsymbols="$cppsymbols"
23719else
23720	if $test -s ccsym.com; then
23721		echo "Your C compiler and pre-processor define these symbols:"
23722		$sed -e 's/\(..*\)=.*/\1/' ccsym.com
23723		also='also '
23724		symbols='ones'
23725		cppccsymbols=`$cat ccsym.com`
23726		cppccsymbols=`echo $cppccsymbols`
23727		$test "$silent" || sleep 1
23728	fi
23729	if $test -s ccsym.cpp; then
23730		$test "$also" && echo " "
23731		echo "Your C pre-processor ${also}defines the following symbols:"
23732		$sed -e 's/\(..*\)=.*/\1/' ccsym.cpp
23733		also='further '
23734		cppsymbols=`$cat ccsym.cpp`
23735		cppsymbols=`echo $cppsymbols`
23736		$test "$silent" || sleep 1
23737	fi
23738	if $test -s ccsym.own; then
23739		$test "$also" && echo " "
23740		echo "Your C compiler ${also}defines the following cpp symbols:"
23741		$sed -e 's/\(..*\)=1/\1/' ccsym.own
23742		$sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
23743		ccsymbols=`$cat ccsym.own`
23744		ccsymbols=`echo $ccsymbols`
23745		$test "$silent" || sleep 1
23746	fi
23747fi
23748
23749: add -D_FORTIFY_SOURCE if feasible and not already there
23750case "$gccversion" in
23751[456789].*|[1-9][0-9]*)	case "$optimize$ccflags" in
23752	*-O*)	case "$ccflags$cppsymbols" in
23753		*_FORTIFY_SOURCE=*) # Don't add it again.
23754			echo "You seem to have -D_FORTIFY_SOURCE already, not adding it." >&4
23755			;;
23756		*)	echo "Adding -D_FORTIFY_SOURCE=2 to ccflags..." >&4
23757			ccflags="$ccflags -D_FORTIFY_SOURCE=2"
23758			;;
23759		esac
23760		;;
23761	*)	echo "You have gcc 4.* or later but not optimizing, not adding -D_FORTIFY_SOURCE." >&4
23762		;;
23763	esac
23764	;;
23765*)	echo "You seem not to have gcc 4.* or later, not adding -D_FORTIFY_SOURCE." >&4
23766	;;
23767esac
23768
23769: script used to emit important warnings
23770cat >warn <<EOS
23771$startsh
23772if test \$# -gt 0; then
23773	echo "\$@" >msg
23774else
23775	cat >msg
23776fi
23777echo "*** WARNING:" >&4
23778sed -e 's/^/*** /' <msg >&4
23779echo "*** " >&4
23780cat msg >>config.msg
23781echo " " >>config.msg
23782rm -f msg
23783EOS
23784chmod +x warn
23785$eunicefix warn
23786
23787: see if this is a termio system
23788val="$undef"
23789val2="$undef"
23790val3="$undef"
23791if $test `./findhdr termios.h`; then
23792    set tcsetattr i_termios
23793    eval $inlibc
23794    val3="$i_termios"
23795fi
23796echo " "
23797case "$val3" in
23798    "$define") echo "You have POSIX termios.h... good!" >&4;;
23799    *)  if ./Cppsym pyr; then
23800	    case "`$run /bin/universe`" in
23801		ucb) if $test `./findhdr sgtty.h`; then
23802			val2="$define"
23803			echo "<sgtty.h> found." >&4
23804		    else
23805			echo "System is pyramid with BSD universe."
23806			./warn "<sgtty.h> not found--you could have problems."
23807		    fi;;
23808		*)  if $test `./findhdr termio.h`; then
23809			val="$define"
23810			echo "<termio.h> found." >&4
23811		    else
23812			echo "System is pyramid with USG universe."
23813			./warn "<termio.h> not found--you could have problems."
23814		    fi;;
23815	    esac
23816	elif ./usg; then
23817	    if $test `./findhdr termio.h`; then
23818		echo "<termio.h> found." >&4
23819		val="$define"
23820	    elif $test `./findhdr sgtty.h`; then
23821		echo "<sgtty.h> found." >&4
23822		val2="$define"
23823	    else
23824		./warn "Neither <termio.h> nor <sgtty.h> found--cross fingers!"
23825	    fi
23826	else
23827	    if $test `./findhdr sgtty.h`; then
23828		echo "<sgtty.h> found." >&4
23829		val2="$define"
23830	    elif $test `./findhdr termio.h`; then
23831		echo "<termio.h> found." >&4
23832		val="$define"
23833	    else
23834		./warn "Neither <sgtty.h> nor <termio.h> found--cross fingers!"
23835	    fi
23836	fi;;
23837esac
23838set i_termio; eval $setvar
23839val=$val2; set i_sgtty; eval $setvar
23840val=$val3; set i_termios; eval $setvar
23841
23842: see if stdbool is available
23843: we want a real compile instead of Inhdr because some Solaris systems
23844: have stdbool.h, but it can only be used if the compiler indicates it
23845: is sufficiently c99-compliant.
23846echo " "
23847$cat >try.c <<EOCP
23848#include <stdio.h>
23849#include <stdbool.h>
23850int func(bool x)
23851{
23852    return x ? 1 : 0;
23853}
23854int main(int argc, char **argv)
23855{
23856    return func(0);
23857}
23858EOCP
23859set try
23860if eval $compile; then
23861	echo "<stdbool.h> found." >&4
23862	val="$define"
23863else
23864	echo "<stdbool.h> NOT found." >&4
23865	val="$undef"
23866fi
23867$rm_try
23868set i_stdbool
23869eval $setvar
23870
23871: see if stdint is available
23872set stdint.h i_stdint
23873eval $inhdr
23874
23875: see if sys/access.h is available
23876set sys/access.h i_sysaccess
23877eval $inhdr
23878
23879: see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
23880set sys/filio.h i_sysfilio
23881eval $inhdr
23882echo " "
23883if $test `./findhdr sys/ioctl.h`; then
23884	val="$define"
23885	echo '<sys/ioctl.h> found.' >&4
23886else
23887	val="$undef"
23888	if $test $i_sysfilio = "$define"; then
23889	    echo '<sys/ioctl.h> NOT found.' >&4
23890	else
23891		$test $i_sgtty = "$define" && xxx="sgtty.h"
23892		$test $i_termio = "$define" && xxx="termio.h"
23893		$test $i_termios = "$define" && xxx="termios.h"
23894echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
23895	fi
23896fi
23897set i_sysioctl
23898eval $setvar
23899
23900: see if socket ioctl defs are in sys/sockio.h
23901echo " "
23902xxx=`./findhdr sys/sockio.h`
23903if $test "$xxx"; then
23904	if $contains SIOCATMARK $xxx >/dev/null 2>&1; then
23905		val="$define"
23906		echo "You have socket ioctls defined in <sys/sockio.h>." >&4
23907	else
23908		val="$undef"
23909		echo "No socket ioctls found in <sys/sockio.h>." >&4
23910	fi
23911else
23912	val="$undef"
23913	$cat <<EOM
23914<sys/sockio.h> not found, assuming socket ioctls are in <sys/ioctl.h>.
23915EOM
23916fi
23917set i_syssockio
23918eval $setvar
23919
23920: see if this is a syslog.h system
23921set syslog.h i_syslog
23922eval $inhdr
23923
23924: see if this is a sys/mode.h system
23925set sys/mode.h i_sysmode
23926eval $inhdr
23927
23928: see if there is a sys/poll.h file
23929set sys/poll.h i_syspoll
23930eval $inhdr
23931
23932: see if sys/resource.h has to be included
23933set sys/resource.h i_sysresrc
23934eval $inhdr
23935
23936: see if sys/security.h is available
23937set sys/security.h i_syssecrt
23938eval $inhdr
23939
23940: see if this is a sys/statvfs.h system
23941set sys/statvfs.h i_sysstatvfs
23942eval $inhdr
23943
23944: see if this is a sys/un.h system
23945set sys/un.h i_sysun
23946eval $inhdr
23947
23948: see if this is a sys/utsname.h system
23949set sys/utsname.h i_sysutsname
23950eval $inhdr
23951
23952: see if this is a syswait system
23953set sys/wait.h i_syswait
23954eval $inhdr
23955
23956: see if this is a ustat.h system
23957set ustat.h i_ustat
23958eval $inhdr
23959
23960: see if this is an utime system
23961set utime.h i_utime
23962eval $inhdr
23963
23964: see if this is a vfork system
23965case "$d_vfork" in
23966"$define")
23967	set vfork.h i_vfork
23968	eval $inhdr
23969	;;
23970*)
23971	i_vfork="$undef"
23972	;;
23973esac
23974
23975: see if wchar.h is present
23976set wchar.h i_wchar
23977eval $inhdr
23978
23979: Check extensions
23980echo " "
23981echo "Looking for extensions..." >&4
23982: If we are using the old config.sh, nonxs_extensions and xs_extensions may
23983: contain old or inaccurate or duplicate values.
23984nonxs_extensions=''
23985xs_extensions=''
23986: We do not use find because it might not be available.
23987: We do not just use MANIFEST because the user may have dropped
23988: some additional extensions into the source tree and expect them
23989: to be built.
23990
23991: Function to recursively find available extensions, ignoring DynaLoader
23992: NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
23993: In 5.10.1 and later, extensions are stored in directories
23994: like File-Glob instead of the older File/Glob/.
23995find_extensions='
23996    for xxx in *; do
23997	case "$xxx" in
23998	    CVS) ;;
23999	    DynaLoader|dynaload) ;;
24000	    *)
24001	    this_ext=`echo "$xxx" | $sed -e s/-/\\\//g`;
24002	    case "$this_ext" in
24003		Scalar/List/Utils) this_ext="List/Util"	;;
24004		PathTools)         this_ext="Cwd"	;;
24005	    esac;
24006	    echo " $xs_extensions $nonxs_extensions" > "$tdir/$$.tmp";
24007	    if $contains " $this_ext " "$tdir/$$.tmp"; then
24008		echo >&4;
24009		echo "Duplicate directories detected for extension $xxx" >&4;
24010		echo "Configure cannot correctly recover from this - shall I abort?" >&4;
24011		case "$knowitall" in
24012		"") dflt=y;;
24013		*) dflt=n;;
24014		esac;
24015		. ../UU/myread;
24016		case "$ans" in
24017		n*|N*) ;;
24018		*) echo >&4;
24019		    echo "Ok.  Stopping Configure." >&4;
24020		    echo "Please remove the duplicate directory (e.g. using git clean) and then re-run Configure" >&4;
24021		    exit 1;;
24022		esac;
24023		echo "Ok.  You will need to correct config.sh before running make." >&4;
24024	    fi;
24025	    $ls -1 "$xxx" > "$tdir/$$.tmp";
24026	    if   $contains "\.xs$" "$tdir/$$.tmp" > /dev/null 2>&1; then
24027		xs_extensions="$xs_extensions $this_ext";
24028	    elif $contains "\.c$"  "$tdir/$$.tmp" > /dev/null 2>&1; then
24029		xs_extensions="$xs_extensions $this_ext";
24030	    elif $test -d "$xxx"; then
24031		nonxs_extensions="$nonxs_extensions $this_ext";
24032	    fi;
24033	    $rm -f "$tdir/$$.tmp";
24034	    ;;
24035	esac;
24036    done'
24037tdir=`pwd`
24038cd "$rsrc/cpan"
24039set X
24040shift
24041eval $find_extensions
24042cd "$rsrc/dist"
24043set X
24044shift
24045eval $find_extensions
24046cd "$rsrc/ext"
24047set X
24048shift
24049eval $find_extensions
24050set X $xs_extensions
24051shift
24052xs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
24053set X $nonxs_extensions
24054shift
24055nonxs_extensions=`echo "$*" | tr ' ' $trnl | $sort | tr $trnl ' '`
24056cd "$tdir"
24057known_extensions=`echo $nonxs_extensions $xs_extensions  | tr ' ' $trnl | $sort | tr $trnl ' '`
24058
24059: Now see which are supported on this system.
24060avail_ext=''
24061for xxx in $xs_extensions ; do
24062	case "$xxx" in
24063	Amiga*)
24064		case "$osname" in
24065		amigaos) avail_ext="$avail_ext $xxx" ;;
24066		esac
24067		;;
24068	DB_File|db_file)
24069		case "$i_db" in
24070		$define) avail_ext="$avail_ext $xxx" ;;
24071		esac
24072		;;
24073	GDBM_File|gdbm_fil)
24074		case "$i_gdbm" in
24075		$define) avail_ext="$avail_ext $xxx" ;;
24076		esac
24077		;;
24078	IPC/SysV|ipc/sysv)
24079		: XXX Do we need a useipcsysv variable here
24080		case "${d_msg}${d_sem}${d_shm}" in
24081		*"${define}"*) avail_ext="$avail_ext $xxx" ;;
24082		esac
24083		;;
24084	NDBM_File|ndbm_fil)
24085		case "$d_ndbm" in
24086		$define)
24087		    case "$osname-$use64bitint" in
24088		    hpux-define)
24089			case "$libs" in
24090			*-lndbm*) avail_ext="$avail_ext $xxx" ;;
24091			esac
24092			;;
24093		    *) avail_ext="$avail_ext $xxx" ;;
24094		    esac
24095		    ;;
24096		esac
24097		;;
24098	ODBM_File|odbm_fil)
24099		case "${i_dbm}${i_rpcsvcdbm}" in
24100		*"${define}"*)
24101		    case "$d_cplusplus" in
24102		    define) ;; # delete as a function name will not work
24103		    *)  case "$osname-$use64bitint" in
24104			hpux-define)
24105			    case "$libs" in
24106			    *-ldbm*) avail_ext="$avail_ext $xxx" ;;
24107			    esac
24108			    ;;
24109			*) avail_ext="$avail_ext $xxx" ;;
24110			esac
24111			;;
24112		    esac
24113		    ;;
24114		esac
24115		;;
24116	Opcode|opcode)
24117		case "$useopcode" in
24118		true|define|y) avail_ext="$avail_ext $xxx" ;;
24119		esac
24120		;;
24121	POSIX|posix)
24122		case "$useposix" in
24123		true|define|y) avail_ext="$avail_ext $xxx" ;;
24124		esac
24125		;;
24126	Socket|socket)
24127		case "$d_socket" in
24128		true|$define|y) avail_ext="$avail_ext $xxx" ;;
24129		esac
24130		;;
24131	I18N/Langinfo|langinfo)
24132		case "$uselanginfo" in
24133		true|define|y) avail_ext="$avail_ext $xxx" ;;
24134		esac
24135		;;
24136	Sys/Syslog|sys/syslog)
24137		case $osname in
24138			amigaos) ;; # not really very useful on AmigaOS
24139			*)
24140			: XXX syslog requires socket
24141			case "$d_socket" in
24142			true|$define|y) avail_ext="$avail_ext $xxx" ;;
24143			esac
24144			;;
24145		esac
24146		;;
24147	threads|threads/shared)
24148		# threads and threads::shared are special cases.
24149		# To stop people from asking "Perl 5.8.0 was supposed
24150		# to have this new fancy threads implementation but my
24151		# perl doesn't have it" and from people trying to
24152		# (re)install the threads module using CPAN.pm and
24153		# CPAN.pm then offering to reinstall Perl 5.8.0,
24154		# the threads.pm and threads/shared.pm will always be
24155		# there, croaking informatively ("you need to rebuild
24156		# all of Perl with threads, sorry") when threads haven't
24157		# been compiled in.
24158		# --jhi
24159		avail_ext="$avail_ext $xxx"
24160		;;
24161	VMS*)
24162		;;
24163	Win32*)
24164		case "$osname" in
24165		cygwin) avail_ext="$avail_ext $xxx" ;;
24166		esac
24167		;;
24168	XS/APItest|xs/apitest)
24169		# This is just for testing.  Skip it unless we have dynamic loading.
24170
24171		case "$usedl" in
24172		$define) avail_ext="$avail_ext $xxx" ;;
24173		esac
24174		;;
24175	XS/Typemap|xs/typemap)
24176		# This is just for testing.  Skip it unless we have dynamic loading.
24177		case "$usedl" in
24178		$define) avail_ext="$avail_ext $xxx" ;;
24179		esac
24180		;;
24181	*)	avail_ext="$avail_ext $xxx"
24182		;;
24183	esac
24184done
24185
24186set X $avail_ext
24187shift
24188avail_ext="$*"
24189
24190case "$onlyextensions" in
24191'') ;;
24192*)  keepextensions=''
24193    echo "You have requested that only certain extensions be included..." >&4
24194    for i in $onlyextensions; do
24195        case " $avail_ext " in
24196        *" $i "*)
24197            echo "Keeping extension $i."
24198            keepextensions="$keepextensions $i"
24199            ;;
24200        *) echo "Ignoring extension $i." ;;
24201        esac
24202    done
24203    avail_ext="$keepextensions"
24204    ;;
24205esac
24206
24207case "$noextensions" in
24208'') ;;
24209*)  keepextensions=''
24210    echo "You have requested that certain extensions be ignored..." >&4
24211    for i in $avail_ext; do
24212        case " $noextensions " in
24213        *" $i "*) echo "Ignoring extension $i." ;;
24214        *) echo "Keeping extension $i.";
24215           keepextensions="$keepextensions $i"
24216           ;;
24217        esac
24218    done
24219    avail_ext="$keepextensions"
24220    ;;
24221esac
24222
24223: Now see which nonxs extensions are supported on this system.
24224: For now assume all are.
24225nonxs_ext=''
24226for xxx in $nonxs_extensions ; do
24227	case "$xxx" in
24228	CVS|RCS|SCCS|.svn)
24229		;;
24230	VMS*)
24231		;;
24232	*)	nonxs_ext="$nonxs_ext $xxx"
24233		;;
24234	esac
24235done
24236
24237set X $nonxs_ext
24238shift
24239nonxs_ext="$*"
24240
24241case $usedl in
24242$define)
24243	$cat <<EOM
24244A number of extensions are supplied with $package.  You may choose to
24245compile these extensions for dynamic loading (the default), compile
24246them into the $package executable (static loading), or not include
24247them at all.  Answer "none" to include no extensions.
24248Note that DynaLoader is always built and need not be mentioned here.
24249
24250EOM
24251	case "$dynamic_ext" in
24252	'')
24253		: Exclude those listed in static_ext
24254		dflt=''
24255		for xxx in $avail_ext; do
24256			case " $static_ext " in
24257			*" $xxx "*) ;;
24258			*) dflt="$dflt $xxx" ;;
24259			esac
24260		done
24261		set X $dflt
24262		shift
24263		dflt="$*"
24264		;;
24265	*)	dflt="$dynamic_ext"
24266		# Perhaps we are reusing an old out-of-date config.sh.
24267		case "$hint" in
24268		previous)
24269			if test X"$dynamic_ext" != X"$avail_ext"; then
24270				$cat <<EOM
24271NOTICE:  Your previous config.sh list may be incorrect.
24272The extensions now available to you are
24273	${avail_ext}
24274but the default list from your previous config.sh is
24275	${dynamic_ext}
24276
24277EOM
24278			fi
24279			;;
24280		esac
24281		;;
24282	esac
24283	case "$dflt" in
24284	'')	dflt=none;;
24285	esac
24286	rp="What extensions do you wish to load dynamically?"
24287	. ./myread
24288	case "$ans" in
24289	none) dynamic_ext=' ' ;;
24290	*) dynamic_ext="$ans" ;;
24291	esac
24292
24293	case "$static_ext" in
24294	'')
24295		: Exclude those already listed in dynamic linking
24296		dflt=''
24297		for xxx in $avail_ext; do
24298			case " $dynamic_ext " in
24299			*" $xxx "*) ;;
24300			*) dflt="$dflt $xxx" ;;
24301			esac
24302		done
24303		set X $dflt
24304		shift
24305		dflt="$*"
24306		;;
24307	*)  dflt="$static_ext"
24308		;;
24309	esac
24310
24311	case "$dflt" in
24312	'')	dflt=none;;
24313	esac
24314	rp="What extensions do you wish to load statically?"
24315	. ./myread
24316	case "$ans" in
24317	none) static_ext=' ' ;;
24318	*) static_ext="$ans" ;;
24319	esac
24320	;;
24321*)
24322	$cat <<EOM
24323A number of extensions are supplied with $package.  Answer "none"
24324to include no extensions.
24325Note that DynaLoader is always built and need not be mentioned here.
24326
24327EOM
24328	case "$static_ext" in
24329	'') dflt="$avail_ext" ;;
24330	*)	dflt="$static_ext"
24331		# Perhaps we are reusing an old out-of-date config.sh.
24332		case "$hint" in
24333		previous)
24334			if test X"$static_ext" != X"$avail_ext"; then
24335				$cat <<EOM
24336NOTICE:  Your previous config.sh list may be incorrect.
24337The extensions now available to you are
24338	${avail_ext}
24339but the default list from your previous config.sh is
24340	${static_ext}
24341
24342EOM
24343			fi
24344			;;
24345		esac
24346		;;
24347	esac
24348	: Exclude those that are not xs extensions
24349	case "$dflt" in
24350	'')	dflt=none;;
24351	esac
24352	rp="What extensions do you wish to include?"
24353	. ./myread
24354	case "$ans" in
24355	none) static_ext=' ' ;;
24356	*) static_ext="$ans" ;;
24357	esac
24358	;;
24359esac
24360#
24361# Encode is a special case.  If we are building Encode as a static
24362# extension, we need to explicitly list its subextensions as well.
24363# For other nested extensions, this is handled automatically by
24364# the appropriate Makefile.PL.
24365case " $static_ext " in
24366	*" Encode "*) # Add the subextensions of Encode
24367	cd "$rsrc/cpan"
24368	for xxx in `ls Encode/*/Makefile.PL|awk -F/ '{print $2}'`; do
24369		static_ext="$static_ext Encode/$xxx"
24370		known_extensions="$known_extensions Encode/$xxx"
24371	done
24372	cd "$tdir"
24373	;;
24374esac
24375
24376set X $dynamic_ext $static_ext $nonxs_ext
24377shift
24378extensions="$*"
24379
24380# Sanity check:  We require an extension suitable for use with
24381# AnyDBM_File, as well as Fcntl and IO.  (Failure to have these
24382# should show up as failures in the test suite, but it's helpful to
24383# catch them now.) The 'extensions' list is normally sorted
24384# alphabetically, so we need to accept either
24385#    DB_File ... Fcntl ... IO  ....
24386# or something like
24387#    Fcntl ... NDBM_File ... IO  ....
24388case " $extensions"  in
24389*"_File "*" Fcntl "*" IO "*) ;; # DB_File
24390*" Fcntl "*"_File "*" IO "*) ;; # GDBM_File
24391*" Fcntl "*" IO "*"_File "*) ;; # NDBM_File
24392*) echo "WARNING: Extensions DB_File or *DBM_File, Fcntl, and IO not configured." >&4
24393   echo "WARNING: The Perl you are building will be quite crippled." >& 4
24394   ;;
24395esac
24396
24397: Remove libraries needed only for extensions
24398: The appropriate ext/Foo/Makefile.PL will add them back in, if necessary.
24399: The exception is SunOS 4.x, which needs them.
24400case "${osname}X${osvers}" in
24401sunos*X4*)
24402    perllibs="$libs"
24403    ;;
24404*) case "$usedl" in
24405    $define|true|[yY]*)
24406	    set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -lgdbm_compat @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
24407	    shift
24408	    perllibs="$*"
24409	    ;;
24410    *)	perllibs="$libs"
24411	    ;;
24412    esac
24413    ;;
24414esac
24415
24416: Remove build directory name from cppstdin so it can be used from
24417: either the present location or the final installed location.
24418echo " "
24419: Get out of the UU directory to get correct path name.
24420cd ..
24421case "$cppstdin" in
24422`pwd`/cppstdin)
24423	echo "Stripping down cppstdin path name"
24424	cppstdin=cppstdin
24425	;;
24426esac
24427cd UU
24428
24429: end of configuration questions
24430echo " "
24431echo "End of configuration questions."
24432echo " "
24433
24434: back to where it started
24435if test -d ../UU; then
24436	cd ..
24437fi
24438
24439: configuration may be unconditionally patched via a 'config.arch' file
24440if $test -f config.arch; then
24441	echo "I see a config.arch file, loading it." >&4
24442	. ./config.arch
24443fi
24444
24445: configuration may be patched via a 'config.over' file
24446if $test -f config.over; then
24447	echo " "
24448	dflt=y
24449	rp='I see a config.over file.  Do you wish to load it?'
24450	. UU/myread
24451	case "$ans" in
24452	n*) echo "OK, I'll ignore it.";;
24453	*)	. ./config.over
24454		echo "Configuration override changes have been loaded."
24455		;;
24456	esac
24457fi
24458
24459: in case they want portability, strip down executable paths
24460case "$d_portable" in
24461"$define")
24462	echo " "
24463	echo "Stripping down executable paths..." >&4
24464	for file in $loclist $trylist; do
24465		eval temp=\$$file
24466		eval $file=`basename $temp`
24467	done
24468	;;
24469esac
24470
24471: create config.sh file
24472echo " "
24473echo "Creating config.sh..." >&4
24474$spitshell <<EOT >config.sh
24475$startsh
24476#
24477# This file was produced by running the Configure script. It holds all the
24478# definitions figured out by Configure. Should you modify one of these values,
24479# do not forget to propagate your changes by running "Configure -der". You may
24480# instead choose to run each of the .SH files by yourself, or "Configure -S".
24481#
24482
24483# Package name      : $package
24484# Source directory  : $src
24485# Configuration time: $cf_time
24486# Configured by     : $cf_by
24487# Target system     : $myuname
24488
24489EOT
24490: Add in command line options if available
24491$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
24492
24493$spitshell <<EOT >>config.sh
24494
24495Author='$Author'
24496Date='$Date'
24497Header='$Header'
24498Id='$Id'
24499Locker='$Locker'
24500Log='$Log'
24501RCSfile='$RCSfile'
24502Revision='$Revision'
24503Source='$Source'
24504State='$State'
24505_a='$_a'
24506_exe='$_exe'
24507_o='$_o'
24508afs='$afs'
24509afsroot='$afsroot'
24510alignbytes='$alignbytes'
24511aphostname='$aphostname'
24512api_revision='$api_revision'
24513api_subversion='$api_subversion'
24514api_version='$api_version'
24515api_versionstring='$api_versionstring'
24516ar='$ar'
24517archlib='$archlib'
24518archlibexp='$archlibexp'
24519archname64='$archname64'
24520archname='$archname'
24521archobjs='$archobjs'
24522asctime_r_proto='$asctime_r_proto'
24523awk='$awk'
24524baserev='$baserev'
24525bash='$bash'
24526bin='$bin'
24527bin_ELF='$bin_ELF'
24528binexp='$binexp'
24529bison='$bison'
24530byacc='$byacc'
24531byteorder='$byteorder'
24532c='$c'
24533castflags='$castflags'
24534cat='$cat'
24535cc='$cc'
24536cccdlflags='$cccdlflags'
24537ccdlflags='$ccdlflags'
24538ccflags='$ccflags'
24539ccflags_uselargefiles='$ccflags_uselargefiles'
24540ccname='$ccname'
24541ccsymbols='$ccsymbols'
24542ccversion='$ccversion'
24543cf_by='$cf_by'
24544cf_email='$cf_email'
24545cf_time='$cf_time'
24546charbits='$charbits'
24547charsize='$charsize'
24548chgrp='$chgrp'
24549chmod='$chmod'
24550chown='$chown'
24551clocktype='$clocktype'
24552comm='$comm'
24553compiler_warning='$compiler_warning'
24554compress='$compress'
24555contains='$contains'
24556cp='$cp'
24557cpio='$cpio'
24558cpp='$cpp'
24559cpp_stuff='$cpp_stuff'
24560cppccsymbols='$cppccsymbols'
24561cppflags='$cppflags'
24562cpplast='$cpplast'
24563cppminus='$cppminus'
24564cpprun='$cpprun'
24565cppstdin='$cppstdin'
24566cppsymbols='$cppsymbols'
24567crypt_r_proto='$crypt_r_proto'
24568cryptlib='$cryptlib'
24569csh='$csh'
24570ctermid_r_proto='$ctermid_r_proto'
24571ctime_r_proto='$ctime_r_proto'
24572d_Gconvert='$d_Gconvert'
24573d_PRIEUldbl='$d_PRIEUldbl'
24574d_PRIFUldbl='$d_PRIFUldbl'
24575d_PRIGUldbl='$d_PRIGUldbl'
24576d_PRIXU64='$d_PRIXU64'
24577d_PRId64='$d_PRId64'
24578d_PRIeldbl='$d_PRIeldbl'
24579d_PRIfldbl='$d_PRIfldbl'
24580d_PRIgldbl='$d_PRIgldbl'
24581d_PRIi64='$d_PRIi64'
24582d_PRIo64='$d_PRIo64'
24583d_PRIu64='$d_PRIu64'
24584d_PRIx64='$d_PRIx64'
24585d_SCNfldbl='$d_SCNfldbl'
24586d__fwalk='$d__fwalk'
24587d_accept4='$d_accept4'
24588d_access='$d_access'
24589d_accessx='$d_accessx'
24590d_acosh='$d_acosh'
24591d_aintl='$d_aintl'
24592d_alarm='$d_alarm'
24593d_archlib='$d_archlib'
24594d_asctime64='$d_asctime64'
24595d_asctime_r='$d_asctime_r'
24596d_asinh='$d_asinh'
24597d_atanh='$d_atanh'
24598d_atolf='$d_atolf'
24599d_atoll='$d_atoll'
24600d_attribute_always_inline='$d_attribute_always_inline'
24601d_attribute_deprecated='$d_attribute_deprecated'
24602d_attribute_format='$d_attribute_format'
24603d_attribute_malloc='$d_attribute_malloc'
24604d_attribute_nonnull='$d_attribute_nonnull'
24605d_attribute_noreturn='$d_attribute_noreturn'
24606d_attribute_pure='$d_attribute_pure'
24607d_attribute_unused='$d_attribute_unused'
24608d_attribute_warn_unused_result='$d_attribute_warn_unused_result'
24609d_backtrace='$d_backtrace'
24610d_bsd='$d_bsd'
24611d_bsdgetpgrp='$d_bsdgetpgrp'
24612d_bsdsetpgrp='$d_bsdsetpgrp'
24613d_builtin_add_overflow='$d_builtin_add_overflow'
24614d_builtin_choose_expr='$d_builtin_choose_expr'
24615d_builtin_expect='$d_builtin_expect'
24616d_builtin_mul_overflow='$d_builtin_mul_overflow'
24617d_builtin_sub_overflow='$d_builtin_sub_overflow'
24618d_c99_variadic_macros='$d_c99_variadic_macros'
24619d_casti32='$d_casti32'
24620d_castneg='$d_castneg'
24621d_cbrt='$d_cbrt'
24622d_chown='$d_chown'
24623d_chroot='$d_chroot'
24624d_chsize='$d_chsize'
24625d_class='$d_class'
24626d_clearenv='$d_clearenv'
24627d_closedir='$d_closedir'
24628d_cmsghdr_s='$d_cmsghdr_s'
24629d_copysign='$d_copysign'
24630d_copysignl='$d_copysignl'
24631d_cplusplus='$d_cplusplus'
24632d_crypt='$d_crypt'
24633d_crypt_r='$d_crypt_r'
24634d_csh='$d_csh'
24635d_ctermid='$d_ctermid'
24636d_ctermid_r='$d_ctermid_r'
24637d_ctime64='$d_ctime64'
24638d_ctime_r='$d_ctime_r'
24639d_cuserid='$d_cuserid'
24640d_dbminitproto='$d_dbminitproto'
24641d_difftime64='$d_difftime64'
24642d_difftime='$d_difftime'
24643d_dir_dd_fd='$d_dir_dd_fd'
24644d_dirfd='$d_dirfd'
24645d_dirnamlen='$d_dirnamlen'
24646d_dladdr='$d_dladdr'
24647d_dlerror='$d_dlerror'
24648d_dlopen='$d_dlopen'
24649d_dlsymun='$d_dlsymun'
24650d_dosuid='$d_dosuid'
24651d_double_has_inf='$d_double_has_inf'
24652d_double_has_nan='$d_double_has_nan'
24653d_double_has_negative_zero='$d_double_has_negative_zero'
24654d_double_has_subnormals='$d_double_has_subnormals'
24655d_double_style_cray='$d_double_style_cray'
24656d_double_style_ibm='$d_double_style_ibm'
24657d_double_style_ieee='$d_double_style_ieee'
24658d_double_style_vax='$d_double_style_vax'
24659d_drand48_r='$d_drand48_r'
24660d_drand48proto='$d_drand48proto'
24661d_dup2='$d_dup2'
24662d_dup3='$d_dup3'
24663d_duplocale='$d_duplocale'
24664d_eaccess='$d_eaccess'
24665d_endgrent='$d_endgrent'
24666d_endgrent_r='$d_endgrent_r'
24667d_endhent='$d_endhent'
24668d_endhostent_r='$d_endhostent_r'
24669d_endnent='$d_endnent'
24670d_endnetent_r='$d_endnetent_r'
24671d_endpent='$d_endpent'
24672d_endprotoent_r='$d_endprotoent_r'
24673d_endpwent='$d_endpwent'
24674d_endpwent_r='$d_endpwent_r'
24675d_endsent='$d_endsent'
24676d_endservent_r='$d_endservent_r'
24677d_eofnblk='$d_eofnblk'
24678d_erf='$d_erf'
24679d_erfc='$d_erfc'
24680d_eunice='$d_eunice'
24681d_exp2='$d_exp2'
24682d_expm1='$d_expm1'
24683d_faststdio='$d_faststdio'
24684d_fchdir='$d_fchdir'
24685d_fchmod='$d_fchmod'
24686d_fchmodat='$d_fchmodat'
24687d_fchown='$d_fchown'
24688d_fcntl='$d_fcntl'
24689d_fcntl_can_lock='$d_fcntl_can_lock'
24690d_fd_macros='$d_fd_macros'
24691d_fd_set='$d_fd_set'
24692d_fdclose='$d_fdclose'
24693d_fdim='$d_fdim'
24694d_fds_bits='$d_fds_bits'
24695d_fegetround='$d_fegetround'
24696d_ffs='$d_ffs'
24697d_ffsl='$d_ffsl'
24698d_fgetpos='$d_fgetpos'
24699d_finite='$d_finite'
24700d_finitel='$d_finitel'
24701d_flexfnam='$d_flexfnam'
24702d_flock='$d_flock'
24703d_flockproto='$d_flockproto'
24704d_fma='$d_fma'
24705d_fmax='$d_fmax'
24706d_fmin='$d_fmin'
24707d_fork='$d_fork'
24708d_fp_class='$d_fp_class'
24709d_fp_classify='$d_fp_classify'
24710d_fp_classl='$d_fp_classl'
24711d_fpathconf='$d_fpathconf'
24712d_fpclass='$d_fpclass'
24713d_fpclassify='$d_fpclassify'
24714d_fpclassl='$d_fpclassl'
24715d_fpgetround='$d_fpgetround'
24716d_fpos64_t='$d_fpos64_t'
24717d_freelocale='$d_freelocale'
24718d_frexpl='$d_frexpl'
24719d_fs_data_s='$d_fs_data_s'
24720d_fseeko='$d_fseeko'
24721d_fsetpos='$d_fsetpos'
24722d_fstatfs='$d_fstatfs'
24723d_fstatvfs='$d_fstatvfs'
24724d_fsync='$d_fsync'
24725d_ftello='$d_ftello'
24726d_ftime='$d_ftime'
24727d_futimes='$d_futimes'
24728d_gai_strerror='$d_gai_strerror'
24729d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes'
24730d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes'
24731d_getaddrinfo='$d_getaddrinfo'
24732d_getcwd='$d_getcwd'
24733d_getenv_preserves_other_thread='$d_getenv_preserves_other_thread'
24734d_getespwnam='$d_getespwnam'
24735d_getfsstat='$d_getfsstat'
24736d_getgrent='$d_getgrent'
24737d_getgrent_r='$d_getgrent_r'
24738d_getgrgid_r='$d_getgrgid_r'
24739d_getgrnam_r='$d_getgrnam_r'
24740d_getgrps='$d_getgrps'
24741d_gethbyaddr='$d_gethbyaddr'
24742d_gethbyname='$d_gethbyname'
24743d_gethent='$d_gethent'
24744d_gethname='$d_gethname'
24745d_gethostbyaddr_r='$d_gethostbyaddr_r'
24746d_gethostbyname_r='$d_gethostbyname_r'
24747d_gethostent_r='$d_gethostent_r'
24748d_gethostprotos='$d_gethostprotos'
24749d_getitimer='$d_getitimer'
24750d_getlogin='$d_getlogin'
24751d_getlogin_r='$d_getlogin_r'
24752d_getmnt='$d_getmnt'
24753d_getmntent='$d_getmntent'
24754d_getnameinfo='$d_getnameinfo'
24755d_getnbyaddr='$d_getnbyaddr'
24756d_getnbyname='$d_getnbyname'
24757d_getnent='$d_getnent'
24758d_getnetbyaddr_r='$d_getnetbyaddr_r'
24759d_getnetbyname_r='$d_getnetbyname_r'
24760d_getnetent_r='$d_getnetent_r'
24761d_getnetprotos='$d_getnetprotos'
24762d_getpagsz='$d_getpagsz'
24763d_getpbyname='$d_getpbyname'
24764d_getpbynumber='$d_getpbynumber'
24765d_getpent='$d_getpent'
24766d_getpgid='$d_getpgid'
24767d_getpgrp2='$d_getpgrp2'
24768d_getpgrp='$d_getpgrp'
24769d_getppid='$d_getppid'
24770d_getprior='$d_getprior'
24771d_getprotobyname_r='$d_getprotobyname_r'
24772d_getprotobynumber_r='$d_getprotobynumber_r'
24773d_getprotoent_r='$d_getprotoent_r'
24774d_getprotoprotos='$d_getprotoprotos'
24775d_getprpwnam='$d_getprpwnam'
24776d_getpwent='$d_getpwent'
24777d_getpwent_r='$d_getpwent_r'
24778d_getpwnam_r='$d_getpwnam_r'
24779d_getpwuid_r='$d_getpwuid_r'
24780d_getsbyname='$d_getsbyname'
24781d_getsbyport='$d_getsbyport'
24782d_getsent='$d_getsent'
24783d_getservbyname_r='$d_getservbyname_r'
24784d_getservbyport_r='$d_getservbyport_r'
24785d_getservent_r='$d_getservent_r'
24786d_getservprotos='$d_getservprotos'
24787d_getspnam='$d_getspnam'
24788d_getspnam_r='$d_getspnam_r'
24789d_gettimeod='$d_gettimeod'
24790d_gmtime64='$d_gmtime64'
24791d_gmtime_r='$d_gmtime_r'
24792d_gnulibc='$d_gnulibc'
24793d_grpasswd='$d_grpasswd'
24794d_has_C_UTF8='$d_has_C_UTF8'
24795d_hasmntopt='$d_hasmntopt'
24796d_htonl='$d_htonl'
24797d_hypot='$d_hypot'
24798d_ilogb='$d_ilogb'
24799d_ilogbl='$d_ilogbl'
24800d_inc_version_list='$d_inc_version_list'
24801d_inetaton='$d_inetaton'
24802d_inetntop='$d_inetntop'
24803d_inetpton='$d_inetpton'
24804d_int64_t='$d_int64_t'
24805d_ip_mreq='$d_ip_mreq'
24806d_ip_mreq_source='$d_ip_mreq_source'
24807d_ipv6_mreq='$d_ipv6_mreq'
24808d_ipv6_mreq_source='$d_ipv6_mreq_source'
24809d_isascii='$d_isascii'
24810d_isblank='$d_isblank'
24811d_isfinite='$d_isfinite'
24812d_isfinitel='$d_isfinitel'
24813d_isinf='$d_isinf'
24814d_isinfl='$d_isinfl'
24815d_isless='$d_isless'
24816d_isnan='$d_isnan'
24817d_isnanl='$d_isnanl'
24818d_isnormal='$d_isnormal'
24819d_j0='$d_j0'
24820d_j0l='$d_j0l'
24821d_killpg='$d_killpg'
24822d_lc_monetary_2008='$d_lc_monetary_2008'
24823d_lchown='$d_lchown'
24824d_ldbl_dig='$d_ldbl_dig'
24825d_ldexpl='$d_ldexpl'
24826d_lgamma='$d_lgamma'
24827d_lgamma_r='$d_lgamma_r'
24828d_libm_lib_version='$d_libm_lib_version'
24829d_libname_unique='$d_libname_unique'
24830d_link='$d_link'
24831d_linkat='$d_linkat'
24832d_llrint='$d_llrint'
24833d_llrintl='$d_llrintl'
24834d_llround='$d_llround'
24835d_llroundl='$d_llroundl'
24836d_localeconv_l='$d_localeconv_l'
24837d_localtime64='$d_localtime64'
24838d_localtime_r='$d_localtime_r'
24839d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
24840d_locconv='$d_locconv'
24841d_lockf='$d_lockf'
24842d_log1p='$d_log1p'
24843d_log2='$d_log2'
24844d_logb='$d_logb'
24845d_long_double_style_ieee='$d_long_double_style_ieee'
24846d_long_double_style_ieee_doubledouble='$d_long_double_style_ieee_doubledouble'
24847d_long_double_style_ieee_extended='$d_long_double_style_ieee_extended'
24848d_long_double_style_ieee_std='$d_long_double_style_ieee_std'
24849d_long_double_style_vax='$d_long_double_style_vax'
24850d_longdbl='$d_longdbl'
24851d_longlong='$d_longlong'
24852d_lrint='$d_lrint'
24853d_lrintl='$d_lrintl'
24854d_lround='$d_lround'
24855d_lroundl='$d_lroundl'
24856d_lseekproto='$d_lseekproto'
24857d_lstat='$d_lstat'
24858d_madvise='$d_madvise'
24859d_malloc_good_size='$d_malloc_good_size'
24860d_malloc_size='$d_malloc_size'
24861d_malloc_usable_size='$d_malloc_usable_size'
24862d_mblen='$d_mblen'
24863d_mbrlen='$d_mbrlen'
24864d_mbrtowc='$d_mbrtowc'
24865d_mbstowcs='$d_mbstowcs'
24866d_mbtowc='$d_mbtowc'
24867d_memmem='$d_memmem'
24868d_memrchr='$d_memrchr'
24869d_mkdir='$d_mkdir'
24870d_mkdtemp='$d_mkdtemp'
24871d_mkfifo='$d_mkfifo'
24872d_mkostemp='$d_mkostemp'
24873d_mkstemp='$d_mkstemp'
24874d_mkstemps='$d_mkstemps'
24875d_mktime64='$d_mktime64'
24876d_mktime='$d_mktime'
24877d_mmap='$d_mmap'
24878d_modfl='$d_modfl'
24879d_modflproto='$d_modflproto'
24880d_mprotect='$d_mprotect'
24881d_msg='$d_msg'
24882d_msg_ctrunc='$d_msg_ctrunc'
24883d_msg_dontroute='$d_msg_dontroute'
24884d_msg_oob='$d_msg_oob'
24885d_msg_peek='$d_msg_peek'
24886d_msg_proxy='$d_msg_proxy'
24887d_msgctl='$d_msgctl'
24888d_msgget='$d_msgget'
24889d_msghdr_s='$d_msghdr_s'
24890d_msgrcv='$d_msgrcv'
24891d_msgsnd='$d_msgsnd'
24892d_msync='$d_msync'
24893d_munmap='$d_munmap'
24894d_mymalloc='$d_mymalloc'
24895d_nan='$d_nan'
24896d_nanosleep='$d_nanosleep'
24897d_ndbm='$d_ndbm'
24898d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes'
24899d_nearbyint='$d_nearbyint'
24900d_newlocale='$d_newlocale'
24901d_nextafter='$d_nextafter'
24902d_nexttoward='$d_nexttoward'
24903d_nice='$d_nice'
24904d_nl_langinfo='$d_nl_langinfo'
24905d_nl_langinfo_l='$d_nl_langinfo_l'
24906d_non_int_bitfields='$d_non_int_bitfields'
24907d_nv_preserves_uv='$d_nv_preserves_uv'
24908d_nv_zero_is_allbits_zero='$d_nv_zero_is_allbits_zero'
24909d_off64_t='$d_off64_t'
24910d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
24911d_oldpthreads='$d_oldpthreads'
24912d_oldsock='$d_oldsock'
24913d_open3='$d_open3'
24914d_openat='$d_openat'
24915d_pathconf='$d_pathconf'
24916d_pause='$d_pause'
24917d_perl_otherlibdirs='$d_perl_otherlibdirs'
24918d_phostname='$d_phostname'
24919d_pipe2='$d_pipe2'
24920d_pipe='$d_pipe'
24921d_poll='$d_poll'
24922d_portable='$d_portable'
24923d_prctl='$d_prctl'
24924d_prctl_set_name='$d_prctl_set_name'
24925d_printf_format_null='$d_printf_format_null'
24926d_procselfexe='$d_procselfexe'
24927d_pseudofork='$d_pseudofork'
24928d_pthread_atfork='$d_pthread_atfork'
24929d_pthread_attr_setscope='$d_pthread_attr_setscope'
24930d_pthread_yield='$d_pthread_yield'
24931d_ptrdiff_t='$d_ptrdiff_t'
24932d_pwage='$d_pwage'
24933d_pwchange='$d_pwchange'
24934d_pwclass='$d_pwclass'
24935d_pwcomment='$d_pwcomment'
24936d_pwexpire='$d_pwexpire'
24937d_pwgecos='$d_pwgecos'
24938d_pwpasswd='$d_pwpasswd'
24939d_pwquota='$d_pwquota'
24940d_qgcvt='$d_qgcvt'
24941d_quad='$d_quad'
24942d_querylocale='$d_querylocale'
24943d_random_r='$d_random_r'
24944d_re_comp='$d_re_comp'
24945d_readdir64_r='$d_readdir64_r'
24946d_readdir='$d_readdir'
24947d_readdir_r='$d_readdir_r'
24948d_readlink='$d_readlink'
24949d_readv='$d_readv'
24950d_recvmsg='$d_recvmsg'
24951d_regcmp='$d_regcmp'
24952d_regcomp='$d_regcomp'
24953d_remainder='$d_remainder'
24954d_remquo='$d_remquo'
24955d_rename='$d_rename'
24956d_renameat='$d_renameat'
24957d_rewinddir='$d_rewinddir'
24958d_rint='$d_rint'
24959d_rmdir='$d_rmdir'
24960d_round='$d_round'
24961d_sbrkproto='$d_sbrkproto'
24962d_scalbn='$d_scalbn'
24963d_scalbnl='$d_scalbnl'
24964d_sched_yield='$d_sched_yield'
24965d_scm_rights='$d_scm_rights'
24966d_seekdir='$d_seekdir'
24967d_select='$d_select'
24968d_sem='$d_sem'
24969d_semctl='$d_semctl'
24970d_semctl_semid_ds='$d_semctl_semid_ds'
24971d_semctl_semun='$d_semctl_semun'
24972d_semget='$d_semget'
24973d_semop='$d_semop'
24974d_sendmsg='$d_sendmsg'
24975d_setegid='$d_setegid'
24976d_seteuid='$d_seteuid'
24977d_setgrent='$d_setgrent'
24978d_setgrent_r='$d_setgrent_r'
24979d_setgrps='$d_setgrps'
24980d_sethent='$d_sethent'
24981d_sethostent_r='$d_sethostent_r'
24982d_setitimer='$d_setitimer'
24983d_setlinebuf='$d_setlinebuf'
24984d_setlocale='$d_setlocale'
24985d_setlocale_accepts_any_locale_name='$d_setlocale_accepts_any_locale_name'
24986d_setlocale_r='$d_setlocale_r'
24987d_setnent='$d_setnent'
24988d_setnetent_r='$d_setnetent_r'
24989d_setpent='$d_setpent'
24990d_setpgid='$d_setpgid'
24991d_setpgrp2='$d_setpgrp2'
24992d_setpgrp='$d_setpgrp'
24993d_setprior='$d_setprior'
24994d_setproctitle='$d_setproctitle'
24995d_setprotoent_r='$d_setprotoent_r'
24996d_setpwent='$d_setpwent'
24997d_setpwent_r='$d_setpwent_r'
24998d_setregid='$d_setregid'
24999d_setresgid='$d_setresgid'
25000d_setresuid='$d_setresuid'
25001d_setreuid='$d_setreuid'
25002d_setrgid='$d_setrgid'
25003d_setruid='$d_setruid'
25004d_setsent='$d_setsent'
25005d_setservent_r='$d_setservent_r'
25006d_setsid='$d_setsid'
25007d_setvbuf='$d_setvbuf'
25008d_shm='$d_shm'
25009d_shmat='$d_shmat'
25010d_shmatprototype='$d_shmatprototype'
25011d_shmctl='$d_shmctl'
25012d_shmdt='$d_shmdt'
25013d_shmget='$d_shmget'
25014d_sigaction='$d_sigaction'
25015d_siginfo_si_addr='$d_siginfo_si_addr'
25016d_siginfo_si_band='$d_siginfo_si_band'
25017d_siginfo_si_errno='$d_siginfo_si_errno'
25018d_siginfo_si_fd='$d_siginfo_si_fd'
25019d_siginfo_si_pid='$d_siginfo_si_pid'
25020d_siginfo_si_status='$d_siginfo_si_status'
25021d_siginfo_si_uid='$d_siginfo_si_uid'
25022d_siginfo_si_value='$d_siginfo_si_value'
25023d_signbit='$d_signbit'
25024d_sigprocmask='$d_sigprocmask'
25025d_sigsetjmp='$d_sigsetjmp'
25026d_sin6_scope_id='$d_sin6_scope_id'
25027d_sitearch='$d_sitearch'
25028d_snprintf='$d_snprintf'
25029d_sockaddr_in6='$d_sockaddr_in6'
25030d_sockaddr_sa_len='$d_sockaddr_sa_len'
25031d_sockaddr_storage='$d_sockaddr_storage'
25032d_sockatmark='$d_sockatmark'
25033d_sockatmarkproto='$d_sockatmarkproto'
25034d_socket='$d_socket'
25035d_socklen_t='$d_socklen_t'
25036d_sockpair='$d_sockpair'
25037d_socks5_init='$d_socks5_init'
25038d_sqrtl='$d_sqrtl'
25039d_srand48_r='$d_srand48_r'
25040d_srandom_r='$d_srandom_r'
25041d_sresgproto='$d_sresgproto'
25042d_sresuproto='$d_sresuproto'
25043d_stat='$d_stat'
25044d_statblks='$d_statblks'
25045d_statfs_f_flags='$d_statfs_f_flags'
25046d_statfs_s='$d_statfs_s'
25047d_static_inline='$d_static_inline'
25048d_statvfs='$d_statvfs'
25049d_stdio_cnt_lval='$d_stdio_cnt_lval'
25050d_stdio_ptr_lval='$d_stdio_ptr_lval'
25051d_stdio_ptr_lval_nochange_cnt='$d_stdio_ptr_lval_nochange_cnt'
25052d_stdio_ptr_lval_sets_cnt='$d_stdio_ptr_lval_sets_cnt'
25053d_stdio_stream_array='$d_stdio_stream_array'
25054d_stdiobase='$d_stdiobase'
25055d_stdstdio='$d_stdstdio'
25056d_strcoll='$d_strcoll'
25057d_strerror_l='$d_strerror_l'
25058d_strerror_r='$d_strerror_r'
25059d_strftime='$d_strftime'
25060d_strlcat='$d_strlcat'
25061d_strlcpy='$d_strlcpy'
25062d_strnlen='$d_strnlen'
25063d_strtod='$d_strtod'
25064d_strtod_l='$d_strtod_l'
25065d_strtol='$d_strtol'
25066d_strtold='$d_strtold'
25067d_strtold_l='$d_strtold_l'
25068d_strtoll='$d_strtoll'
25069d_strtoq='$d_strtoq'
25070d_strtoul='$d_strtoul'
25071d_strtoull='$d_strtoull'
25072d_strtouq='$d_strtouq'
25073d_strxfrm='$d_strxfrm'
25074d_strxfrm_l='$d_strxfrm_l'
25075d_suidsafe='$d_suidsafe'
25076d_symlink='$d_symlink'
25077d_syscall='$d_syscall'
25078d_syscallproto='$d_syscallproto'
25079d_sysconf='$d_sysconf'
25080d_sysernlst='$d_sysernlst'
25081d_syserrlst='$d_syserrlst'
25082d_system='$d_system'
25083d_tcgetpgrp='$d_tcgetpgrp'
25084d_tcsetpgrp='$d_tcsetpgrp'
25085d_telldir='$d_telldir'
25086d_telldirproto='$d_telldirproto'
25087d_tgamma='$d_tgamma'
25088d_thread_local='$d_thread_local'
25089d_thread_safe_nl_langinfo_l='$d_thread_safe_nl_langinfo_l'
25090d_time='$d_time'
25091d_timegm='$d_timegm'
25092d_times='$d_times'
25093d_tm_tm_gmtoff='$d_tm_tm_gmtoff'
25094d_tm_tm_zone='$d_tm_tm_zone'
25095d_tmpnam_r='$d_tmpnam_r'
25096d_towlower='$d_towlower'
25097d_towupper='$d_towupper'
25098d_trunc='$d_trunc'
25099d_truncate='$d_truncate'
25100d_truncl='$d_truncl'
25101d_ttyname_r='$d_ttyname_r'
25102d_tzname='$d_tzname'
25103d_u32align='$d_u32align'
25104d_ualarm='$d_ualarm'
25105d_umask='$d_umask'
25106d_uname='$d_uname'
25107d_union_semun='$d_union_semun'
25108d_unlinkat='$d_unlinkat'
25109d_unordered='$d_unordered'
25110d_unsetenv='$d_unsetenv'
25111d_uselocale='$d_uselocale'
25112d_usleep='$d_usleep'
25113d_usleepproto='$d_usleepproto'
25114d_ustat='$d_ustat'
25115d_vendorarch='$d_vendorarch'
25116d_vendorbin='$d_vendorbin'
25117d_vendorlib='$d_vendorlib'
25118d_vendorscript='$d_vendorscript'
25119d_vfork='$d_vfork'
25120d_void_closedir='$d_void_closedir'
25121d_voidsig='$d_voidsig'
25122d_voidtty='$d_voidtty'
25123d_vsnprintf='$d_vsnprintf'
25124d_wait4='$d_wait4'
25125d_waitpid='$d_waitpid'
25126d_wcrtomb='$d_wcrtomb'
25127d_wcscmp='$d_wcscmp'
25128d_wcstombs='$d_wcstombs'
25129d_wcsxfrm='$d_wcsxfrm'
25130d_wctomb='$d_wctomb'
25131d_writev='$d_writev'
25132d_xenix='$d_xenix'
25133date='$date'
25134db_hashtype='$db_hashtype'
25135db_prefixtype='$db_prefixtype'
25136db_version_major='$db_version_major'
25137db_version_minor='$db_version_minor'
25138db_version_patch='$db_version_patch'
25139default_inc_excludes_dot='$default_inc_excludes_dot'
25140direntrytype='$direntrytype'
25141dlext='$dlext'
25142dlsrc='$dlsrc'
25143doubleinfbytes='$doubleinfbytes'
25144doublekind='$doublekind'
25145doublemantbits='$doublemantbits'
25146doublenanbytes='$doublenanbytes'
25147doublesize='$doublesize'
25148drand01='$drand01'
25149drand48_r_proto='$drand48_r_proto'
25150dtrace='$dtrace'
25151dtraceobject='$dtraceobject'
25152dtracexnolibs='$dtracexnolibs'
25153dynamic_ext='$dynamic_ext'
25154eagain='$eagain'
25155ebcdic='$ebcdic'
25156echo='$echo'
25157egrep='$egrep'
25158emacs='$emacs'
25159endgrent_r_proto='$endgrent_r_proto'
25160endhostent_r_proto='$endhostent_r_proto'
25161endnetent_r_proto='$endnetent_r_proto'
25162endprotoent_r_proto='$endprotoent_r_proto'
25163endpwent_r_proto='$endpwent_r_proto'
25164endservent_r_proto='$endservent_r_proto'
25165eunicefix='$eunicefix'
25166exe_ext='$exe_ext'
25167expr='$expr'
25168extensions='$extensions'
25169extern_C='$extern_C'
25170extras='$extras'
25171fflushNULL='$fflushNULL'
25172fflushall='$fflushall'
25173find='$find'
25174firstmakefile='$firstmakefile'
25175flex='$flex'
25176fpossize='$fpossize'
25177fpostype='$fpostype'
25178freetype='$freetype'
25179from='$from'
25180full_ar='$full_ar'
25181full_csh='$full_csh'
25182full_sed='$full_sed'
25183gccansipedantic='$gccansipedantic'
25184gccosandvers='$gccosandvers'
25185gccversion='$gccversion'
25186getgrent_r_proto='$getgrent_r_proto'
25187getgrgid_r_proto='$getgrgid_r_proto'
25188getgrnam_r_proto='$getgrnam_r_proto'
25189gethostbyaddr_r_proto='$gethostbyaddr_r_proto'
25190gethostbyname_r_proto='$gethostbyname_r_proto'
25191gethostent_r_proto='$gethostent_r_proto'
25192getlogin_r_proto='$getlogin_r_proto'
25193getnetbyaddr_r_proto='$getnetbyaddr_r_proto'
25194getnetbyname_r_proto='$getnetbyname_r_proto'
25195getnetent_r_proto='$getnetent_r_proto'
25196getprotobyname_r_proto='$getprotobyname_r_proto'
25197getprotobynumber_r_proto='$getprotobynumber_r_proto'
25198getprotoent_r_proto='$getprotoent_r_proto'
25199getpwent_r_proto='$getpwent_r_proto'
25200getpwnam_r_proto='$getpwnam_r_proto'
25201getpwuid_r_proto='$getpwuid_r_proto'
25202getservbyname_r_proto='$getservbyname_r_proto'
25203getservbyport_r_proto='$getservbyport_r_proto'
25204getservent_r_proto='$getservent_r_proto'
25205getspnam_r_proto='$getspnam_r_proto'
25206gidformat='$gidformat'
25207gidsign='$gidsign'
25208gidsize='$gidsize'
25209gidtype='$gidtype'
25210glibpth='$glibpth'
25211gmake='$gmake'
25212gmtime_r_proto='$gmtime_r_proto'
25213gnulibc_version='$gnulibc_version'
25214grep='$grep'
25215groupcat='$groupcat'
25216groupstype='$groupstype'
25217gzip='$gzip'
25218h_fcntl='$h_fcntl'
25219h_sysfile='$h_sysfile'
25220hint='$hint'
25221hostcat='$hostcat'
25222hostgenerate='$hostgenerate'
25223hostosname='$hostosname'
25224hostperl='$hostperl'
25225html1dir='$html1dir'
25226html1direxp='$html1direxp'
25227html3dir='$html3dir'
25228html3direxp='$html3direxp'
25229i16size='$i16size'
25230i16type='$i16type'
25231i32size='$i32size'
25232i32type='$i32type'
25233i64size='$i64size'
25234i64type='$i64type'
25235i8size='$i8size'
25236i8type='$i8type'
25237i_arpainet='$i_arpainet'
25238i_bfd='$i_bfd'
25239i_bsdioctl='$i_bsdioctl'
25240i_crypt='$i_crypt'
25241i_db='$i_db'
25242i_dbm='$i_dbm'
25243i_dirent='$i_dirent'
25244i_dlfcn='$i_dlfcn'
25245i_execinfo='$i_execinfo'
25246i_fcntl='$i_fcntl'
25247i_fenv='$i_fenv'
25248i_fp='$i_fp'
25249i_fp_class='$i_fp_class'
25250i_gdbm='$i_gdbm'
25251i_gdbm_ndbm='$i_gdbm_ndbm'
25252i_gdbmndbm='$i_gdbmndbm'
25253i_grp='$i_grp'
25254i_ieeefp='$i_ieeefp'
25255i_inttypes='$i_inttypes'
25256i_langinfo='$i_langinfo'
25257i_libutil='$i_libutil'
25258i_locale='$i_locale'
25259i_machcthr='$i_machcthr'
25260i_malloc='$i_malloc'
25261i_mallocmalloc='$i_mallocmalloc'
25262i_mntent='$i_mntent'
25263i_ndbm='$i_ndbm'
25264i_netdb='$i_netdb'
25265i_neterrno='$i_neterrno'
25266i_netinettcp='$i_netinettcp'
25267i_niin='$i_niin'
25268i_poll='$i_poll'
25269i_prot='$i_prot'
25270i_pthread='$i_pthread'
25271i_pwd='$i_pwd'
25272i_quadmath='$i_quadmath'
25273i_rpcsvcdbm='$i_rpcsvcdbm'
25274i_sgtty='$i_sgtty'
25275i_shadow='$i_shadow'
25276i_socks='$i_socks'
25277i_stdbool='$i_stdbool'
25278i_stdint='$i_stdint'
25279i_stdlib='$i_stdlib'
25280i_sunmath='$i_sunmath'
25281i_sysaccess='$i_sysaccess'
25282i_sysdir='$i_sysdir'
25283i_sysfile='$i_sysfile'
25284i_sysfilio='$i_sysfilio'
25285i_sysin='$i_sysin'
25286i_sysioctl='$i_sysioctl'
25287i_syslog='$i_syslog'
25288i_sysmman='$i_sysmman'
25289i_sysmode='$i_sysmode'
25290i_sysmount='$i_sysmount'
25291i_sysndir='$i_sysndir'
25292i_sysparam='$i_sysparam'
25293i_syspoll='$i_syspoll'
25294i_sysresrc='$i_sysresrc'
25295i_syssecrt='$i_syssecrt'
25296i_sysselct='$i_sysselct'
25297i_syssockio='$i_syssockio'
25298i_sysstat='$i_sysstat'
25299i_sysstatfs='$i_sysstatfs'
25300i_sysstatvfs='$i_sysstatvfs'
25301i_systime='$i_systime'
25302i_systimek='$i_systimek'
25303i_systimes='$i_systimes'
25304i_systypes='$i_systypes'
25305i_sysuio='$i_sysuio'
25306i_sysun='$i_sysun'
25307i_sysutsname='$i_sysutsname'
25308i_sysvfs='$i_sysvfs'
25309i_syswait='$i_syswait'
25310i_termio='$i_termio'
25311i_termios='$i_termios'
25312i_time='$i_time'
25313i_unistd='$i_unistd'
25314i_ustat='$i_ustat'
25315i_utime='$i_utime'
25316i_vfork='$i_vfork'
25317i_wchar='$i_wchar'
25318i_wctype='$i_wctype'
25319i_xlocale='$i_xlocale'
25320ignore_versioned_solibs='$ignore_versioned_solibs'
25321inc_version_list='$inc_version_list'
25322inc_version_list_init='$inc_version_list_init'
25323incpath='$incpath'
25324incpth='$incpth'
25325inews='$inews'
25326initialinstalllocation='$initialinstalllocation'
25327installarchlib='$installarchlib'
25328installbin='$installbin'
25329installhtml1dir='$installhtml1dir'
25330installhtml3dir='$installhtml3dir'
25331installman1dir='$installman1dir'
25332installman3dir='$installman3dir'
25333installprefix='$installprefix'
25334installprefixexp='$installprefixexp'
25335installprivlib='$installprivlib'
25336installscript='$installscript'
25337installsitearch='$installsitearch'
25338installsitebin='$installsitebin'
25339installsitehtml1dir='$installsitehtml1dir'
25340installsitehtml3dir='$installsitehtml3dir'
25341installsitelib='$installsitelib'
25342installsiteman1dir='$installsiteman1dir'
25343installsiteman3dir='$installsiteman3dir'
25344installsitescript='$installsitescript'
25345installstyle='$installstyle'
25346installusrbinperl='$installusrbinperl'
25347installvendorarch='$installvendorarch'
25348installvendorbin='$installvendorbin'
25349installvendorhtml1dir='$installvendorhtml1dir'
25350installvendorhtml3dir='$installvendorhtml3dir'
25351installvendorlib='$installvendorlib'
25352installvendorman1dir='$installvendorman1dir'
25353installvendorman3dir='$installvendorman3dir'
25354installvendorscript='$installvendorscript'
25355intsize='$intsize'
25356issymlink='$issymlink'
25357ivdformat='$ivdformat'
25358ivsize='$ivsize'
25359ivtype='$ivtype'
25360known_extensions='$known_extensions'
25361ksh='$ksh'
25362ld='$ld'
25363ld_can_script='$ld_can_script'
25364lddlflags='$lddlflags'
25365ldflags='$ldflags'
25366ldflags_uselargefiles='$ldflags_uselargefiles'
25367ldlibpthname='$ldlibpthname'
25368less='$less'
25369lib_ext='$lib_ext'
25370libc='$libc'
25371libperl='$libperl'
25372libpth='$libpth'
25373libs='$libs'
25374libsdirs='$libsdirs'
25375libsfiles='$libsfiles'
25376libsfound='$libsfound'
25377libspath='$libspath'
25378libswanted='$libswanted'
25379libswanted_uselargefiles='$libswanted_uselargefiles'
25380line='$line'
25381lint='$lint'
25382lkflags='$lkflags'
25383ln='$ln'
25384lns='$lns'
25385localtime_r_proto='$localtime_r_proto'
25386locincpth='$locincpth'
25387loclibpth='$loclibpth'
25388longdblinfbytes='$longdblinfbytes'
25389longdblkind='$longdblkind'
25390longdblmantbits='$longdblmantbits'
25391longdblnanbytes='$longdblnanbytes'
25392longdblsize='$longdblsize'
25393longlongsize='$longlongsize'
25394longsize='$longsize'
25395lp='$lp'
25396lpr='$lpr'
25397ls='$ls'
25398lseeksize='$lseeksize'
25399lseektype='$lseektype'
25400mail='$mail'
25401mailx='$mailx'
25402make='$make'
25403make_set_make='$make_set_make'
25404mallocobj='$mallocobj'
25405mallocsrc='$mallocsrc'
25406malloctype='$malloctype'
25407man1dir='$man1dir'
25408man1direxp='$man1direxp'
25409man1ext='$man1ext'
25410man3dir='$man3dir'
25411man3direxp='$man3direxp'
25412man3ext='$man3ext'
25413mips_type='$mips_type'
25414mistrustnm='$mistrustnm'
25415mkdir='$mkdir'
25416mmaptype='$mmaptype'
25417modetype='$modetype'
25418more='$more'
25419multiarch='$multiarch'
25420mv='$mv'
25421myarchname='$myarchname'
25422mydomain='$mydomain'
25423myhostname='$myhostname'
25424myuname='$myuname'
25425n='$n'
25426need_va_copy='$need_va_copy'
25427netdb_hlen_type='$netdb_hlen_type'
25428netdb_host_type='$netdb_host_type'
25429netdb_name_type='$netdb_name_type'
25430netdb_net_type='$netdb_net_type'
25431nm='$nm'
25432nm_opt='$nm_opt'
25433nm_so_opt='$nm_so_opt'
25434nonxs_ext='$nonxs_ext'
25435nroff='$nroff'
25436nvEUformat='$nvEUformat'
25437nvFUformat='$nvFUformat'
25438nvGUformat='$nvGUformat'
25439nv_overflows_integers_at='$nv_overflows_integers_at'
25440nv_preserves_uv_bits='$nv_preserves_uv_bits'
25441nveformat='$nveformat'
25442nvfformat='$nvfformat'
25443nvgformat='$nvgformat'
25444nvmantbits='$nvmantbits'
25445nvsize='$nvsize'
25446nvtype='$nvtype'
25447o_nonblock='$o_nonblock'
25448obj_ext='$obj_ext'
25449old_pthread_create_joinable='$old_pthread_create_joinable'
25450optimize='$optimize'
25451orderlib='$orderlib'
25452osname='$osname'
25453osvers='$osvers'
25454otherlibdirs='$otherlibdirs'
25455package='$package'
25456pager='$pager'
25457passcat='$passcat'
25458patchlevel='$patchlevel'
25459path_sep='$path_sep'
25460perl5='$perl5'
25461perl='$perl'
25462perl_patchlevel='$perl_patchlevel'
25463perl_static_inline='$perl_static_inline'
25464perl_thread_local='$perl_thread_local'
25465perladmin='$perladmin'
25466perllibs='$perllibs'
25467perlpath='$perlpath'
25468pg='$pg'
25469phostname='$phostname'
25470pidtype='$pidtype'
25471plibpth='$plibpth'
25472pmake='$pmake'
25473pr='$pr'
25474prefix='$prefix'
25475prefixexp='$prefixexp'
25476privlib='$privlib'
25477privlibexp='$privlibexp'
25478procselfexe='$procselfexe'
25479ptrsize='$ptrsize'
25480quadkind='$quadkind'
25481quadtype='$quadtype'
25482randbits='$randbits'
25483randfunc='$randfunc'
25484random_r_proto='$random_r_proto'
25485randseedtype='$randseedtype'
25486ranlib='$ranlib'
25487rd_nodata='$rd_nodata'
25488readdir64_r_proto='$readdir64_r_proto'
25489readdir_r_proto='$readdir_r_proto'
25490revision='$revision'
25491rm='$rm'
25492rm_try='$rm_try'
25493rmail='$rmail'
25494run='$run'
25495runnm='$runnm'
25496sGMTIME_max='$sGMTIME_max'
25497sGMTIME_min='$sGMTIME_min'
25498sLOCALTIME_max='$sLOCALTIME_max'
25499sLOCALTIME_min='$sLOCALTIME_min'
25500sPRIEUldbl='$sPRIEUldbl'
25501sPRIFUldbl='$sPRIFUldbl'
25502sPRIGUldbl='$sPRIGUldbl'
25503sPRIXU64='$sPRIXU64'
25504sPRId64='$sPRId64'
25505sPRIeldbl='$sPRIeldbl'
25506sPRIfldbl='$sPRIfldbl'
25507sPRIgldbl='$sPRIgldbl'
25508sPRIi64='$sPRIi64'
25509sPRIo64='$sPRIo64'
25510sPRIu64='$sPRIu64'
25511sPRIx64='$sPRIx64'
25512sSCNfldbl='$sSCNfldbl'
25513sched_yield='$sched_yield'
25514scriptdir='$scriptdir'
25515scriptdirexp='$scriptdirexp'
25516sed='$sed'
25517seedfunc='$seedfunc'
25518selectminbits='$selectminbits'
25519selecttype='$selecttype'
25520sendmail='$sendmail'
25521setgrent_r_proto='$setgrent_r_proto'
25522sethostent_r_proto='$sethostent_r_proto'
25523setlocale_r_proto='$setlocale_r_proto'
25524setnetent_r_proto='$setnetent_r_proto'
25525setprotoent_r_proto='$setprotoent_r_proto'
25526setpwent_r_proto='$setpwent_r_proto'
25527setservent_r_proto='$setservent_r_proto'
25528sh='$sh'
25529shar='$shar'
25530sharpbang='$sharpbang'
25531shmattype='$shmattype'
25532shortsize='$shortsize'
25533shrpenv='$shrpenv'
25534shsharp='$shsharp'
25535sig_count='$sig_count'
25536sig_name='$sig_name'
25537sig_name_init='$sig_name_init'
25538sig_num='$sig_num'
25539sig_num_init='$sig_num_init'
25540sig_size='$sig_size'
25541signal_t='$signal_t'
25542sitearch='$sitearch'
25543sitearchexp='$sitearchexp'
25544sitebin='$sitebin'
25545sitebinexp='$sitebinexp'
25546sitehtml1dir='$sitehtml1dir'
25547sitehtml1direxp='$sitehtml1direxp'
25548sitehtml3dir='$sitehtml3dir'
25549sitehtml3direxp='$sitehtml3direxp'
25550sitelib='$sitelib'
25551sitelib_stem='$sitelib_stem'
25552sitelibexp='$sitelibexp'
25553siteman1dir='$siteman1dir'
25554siteman1direxp='$siteman1direxp'
25555siteman3dir='$siteman3dir'
25556siteman3direxp='$siteman3direxp'
25557siteprefix='$siteprefix'
25558siteprefixexp='$siteprefixexp'
25559sitescript='$sitescript'
25560sitescriptexp='$sitescriptexp'
25561sizesize='$sizesize'
25562sizetype='$sizetype'
25563sleep='$sleep'
25564smail='$smail'
25565so='$so'
25566sockethdr='$sockethdr'
25567socketlib='$socketlib'
25568socksizetype='$socksizetype'
25569sort='$sort'
25570spackage='$spackage'
25571spitshell='$spitshell'
25572srand48_r_proto='$srand48_r_proto'
25573srandom_r_proto='$srandom_r_proto'
25574src='$src'
25575ssizetype='$ssizetype'
25576st_dev_sign='$st_dev_sign'
25577st_dev_size='$st_dev_size'
25578st_ino_sign='$st_ino_sign'
25579st_ino_size='$st_ino_size'
25580startperl='$startperl'
25581startsh='$startsh'
25582static_ext='$static_ext'
25583stdchar='$stdchar'
25584stdio_base='$stdio_base'
25585stdio_bufsiz='$stdio_bufsiz'
25586stdio_cnt='$stdio_cnt'
25587stdio_filbuf='$stdio_filbuf'
25588stdio_ptr='$stdio_ptr'
25589stdio_stream_array='$stdio_stream_array'
25590strerror_r_proto='$strerror_r_proto'
25591submit='$submit'
25592subversion='$subversion'
25593sysman='$sysman'
25594sysroot='$sysroot'
25595tail='$tail'
25596tar='$tar'
25597targetarch='$targetarch'
25598targetdir='$targetdir'
25599targetenv='$targetenv'
25600targethost='$targethost'
25601targetmkdir='$targetmkdir'
25602targetport='$targetport'
25603targetsh='$targetsh'
25604tbl='$tbl'
25605tee='$tee'
25606test='$test'
25607timeincl='$timeincl'
25608timetype='$timetype'
25609tmpnam_r_proto='$tmpnam_r_proto'
25610to='$to'
25611touch='$touch'
25612tr='$tr'
25613trnl='$trnl'
25614troff='$troff'
25615ttyname_r_proto='$ttyname_r_proto'
25616u16size='$u16size'
25617u16type='$u16type'
25618u32size='$u32size'
25619u32type='$u32type'
25620u64size='$u64size'
25621u64type='$u64type'
25622u8size='$u8size'
25623u8type='$u8type'
25624uidformat='$uidformat'
25625uidsign='$uidsign'
25626uidsize='$uidsize'
25627uidtype='$uidtype'
25628uname='$uname'
25629uniq='$uniq'
25630uquadtype='$uquadtype'
25631use64bitall='$use64bitall'
25632use64bitint='$use64bitint'
25633usecbacktrace='$usecbacktrace'
25634usecrosscompile='$usecrosscompile'
25635usedefaultstrict='$usedefaultstrict'
25636usedevel='$usedevel'
25637usedl='$usedl'
25638usedtrace='$usedtrace'
25639usefaststdio='$usefaststdio'
25640useithreads='$useithreads'
25641usekernprocpathname='$usekernprocpathname'
25642uselanginfo='$uselanginfo'
25643uselargefiles='$uselargefiles'
25644uselongdouble='$uselongdouble'
25645usemallocwrap='$usemallocwrap'
25646usemorebits='$usemorebits'
25647usemultiplicity='$usemultiplicity'
25648usemymalloc='$usemymalloc'
25649usenm='$usenm'
25650usensgetexecutablepath='$usensgetexecutablepath'
25651useopcode='$useopcode'
25652useperlio='$useperlio'
25653useposix='$useposix'
25654usequadmath='$usequadmath'
25655usereentrant='$usereentrant'
25656userelocatableinc='$userelocatableinc'
25657useshrplib='$useshrplib'
25658usesitecustomize='$usesitecustomize'
25659usesocks='$usesocks'
25660usethreads='$usethreads'
25661usevendorprefix='$usevendorprefix'
25662useversionedarchname='$useversionedarchname'
25663usevfork='$usevfork'
25664usrinc='$usrinc'
25665uuname='$uuname'
25666uvXUformat='$uvXUformat'
25667uvoformat='$uvoformat'
25668uvsize='$uvsize'
25669uvtype='$uvtype'
25670uvuformat='$uvuformat'
25671uvxformat='$uvxformat'
25672vendorarch='$vendorarch'
25673vendorarchexp='$vendorarchexp'
25674vendorbin='$vendorbin'
25675vendorbinexp='$vendorbinexp'
25676vendorhtml1dir='$vendorhtml1dir'
25677vendorhtml1direxp='$vendorhtml1direxp'
25678vendorhtml3dir='$vendorhtml3dir'
25679vendorhtml3direxp='$vendorhtml3direxp'
25680vendorlib='$vendorlib'
25681vendorlib_stem='$vendorlib_stem'
25682vendorlibexp='$vendorlibexp'
25683vendorman1dir='$vendorman1dir'
25684vendorman1direxp='$vendorman1direxp'
25685vendorman3dir='$vendorman3dir'
25686vendorman3direxp='$vendorman3direxp'
25687vendorprefix='$vendorprefix'
25688vendorprefixexp='$vendorprefixexp'
25689vendorscript='$vendorscript'
25690vendorscriptexp='$vendorscriptexp'
25691version='$version'
25692version_patchlevel_string='$version_patchlevel_string'
25693versiononly='$versiononly'
25694vi='$vi'
25695xlibpth='$xlibpth'
25696xlocale_needed='$xlocale_needed'
25697yacc='$yacc'
25698yaccflags='$yaccflags'
25699zcat='$zcat'
25700zip='$zip'
25701EOT
25702
25703: add special variables
25704$test -f $src/patchlevel.h && \
25705awk '/^#define[ 	]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
25706echo "PERL_PATCHLEVEL='$perl_patchlevel'" >>config.sh
25707echo "PERL_CONFIG_SH=true" >>config.sh
25708
25709: propagate old symbols
25710if $test -f UU/config.sh; then
25711	<UU/config.sh $sort | $uniq >UU/oldconfig.sh
25712	$sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' \
25713		config.sh config.sh UU/oldconfig.sh |\
25714		$sort | $uniq -u >UU/oldsyms
25715	set X `$cat UU/oldsyms`
25716	shift
25717	case $# in
25718	0) ;;
25719	*)
25720		$cat <<EOM
25721Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
25722EOM
25723		echo ": Variables propagated from previous config.sh file." >>config.sh
25724		for sym in `$cat UU/oldsyms`; do
25725			echo "    Propagating $hint variable "'$'"$sym..."
25726			eval 'tmp="$'"${sym}"'"'
25727			echo "$tmp" | \
25728				sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
25729		done
25730		;;
25731	esac
25732fi
25733
25734: preserve RCS keywords in files with variable substitution, grrr
25735Id='$Id'
25736
25737: Finish up by extracting the .SH files
25738case "$alldone" in
25739exit)
25740	echo "Stopping at your request, leaving temporary files around."
25741	exit 0
25742	;;
25743cont)
25744	;;
25745'')
25746	dflt=''
25747	nostick=true
25748	$cat <<EOM
25749
25750If you'd like to make any changes to the config.sh file before I begin
25751to configure things, do it as a shell escape now (e.g. !vi config.sh).
25752
25753EOM
25754	rp="Press return or use a shell escape to edit config.sh:"
25755	. UU/myread
25756	nostick=''
25757	case "$ans" in
25758	'') ;;
25759	*) : in case they cannot read
25760		sh 1>&4 -c "$ans";;
25761	esac
25762	;;
25763esac
25764
25765: if this fails, just run all the .SH files by hand
25766. ./config.sh
25767
25768echo " "
25769exec 1>&4
25770pwd=`pwd`
25771. ./UU/extract
25772cd "$pwd"
25773
25774if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
25775	dflt=y
25776	case "$silent" in
25777	true) ;;
25778	*)
25779		$cat <<EOM
25780
25781Now you need to generate make dependencies by running "$make depend".
25782You might prefer to run it in background: "$make depend > makedepend.out &"
25783It can take a while, so you might not want to run it right now.
25784
25785EOM
25786		;;
25787	esac
25788	rp="Run $make depend now?"
25789	. UU/myread
25790	case "$ans" in
25791	y*)
25792		$make depend && echo "Now you must run '$make'."
25793		;;
25794	*)
25795		echo "You must run '$make depend' then '$make'."
25796		;;
25797	esac
25798elif test -f [Mm]akefile; then
25799	echo " "
25800	echo "Now you must run a $make."
25801else
25802	echo "Configure done."
25803fi
25804
25805if $test -f Policy.sh; then
25806    $cat <<EOM
25807
25808If you compile $package on a different machine or from a different object
25809directory, copy the Policy.sh file from this object directory to the
25810new one before you run Configure -- this will help you with most of
25811the policy defaults.
25812
25813EOM
25814fi
25815if $test -f UU/config.msg; then
25816    echo "Hmm.  I also noted the following information while running:"
25817    echo " "
25818    $cat UU/config.msg >&4
25819fi
25820$rm -f kit*isdone ark*isdone
25821$rm -rf UU
25822
25823: End of Configure
25824
25825